From bab5a22f0c27e5ccef9f4497b0a59005c819ec2b Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 29 Apr 2021 14:48:16 -0400 Subject: [PATCH] Fix build issues H7 compatibility problems in port.c and peripherals/exti NRF build failures due to new use of const for PinAlarm pin objects Isolated board flash overage on blackpill_with_flash, remove audio modules --- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 4 ++-- ports/nrf/common-hal/alarm/pin/PinAlarm.h | 2 +- .../boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk | 3 +++ ports/stm/common-hal/alarm/pin/PinAlarm.h | 5 +++++ ports/stm/common-hal/alarm/time/TimeAlarm.h | 4 ++++ ports/stm/peripherals/exti.c | 4 ++++ ports/stm/supervisor/port.c | 3 +++ 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 3c38cad1ac..747ff4c8ae 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -50,7 +50,7 @@ static bool pins_configured = false; extern uint32_t reset_reason_saved; extern void dbg_dump_GPIOregs(void); -void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { +void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { if (edge) { mp_raise_ValueError(translate("Cannot wake on pin edge. Only level.")); } @@ -62,7 +62,7 @@ void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, mcu self->pull = pull; } -mcu_pin_obj_t *common_hal_alarm_pin_pinalarm_get_pin(alarm_pin_pinalarm_obj_t *self) { +const mcu_pin_obj_t *common_hal_alarm_pin_pinalarm_get_pin(alarm_pin_pinalarm_obj_t *self) { return self->pin; } diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.h b/ports/nrf/common-hal/alarm/pin/PinAlarm.h index 69684386fa..42f9f115c8 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.h +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.h @@ -29,7 +29,7 @@ typedef struct { mp_obj_base_t base; - mcu_pin_obj_t *pin; + const mcu_pin_obj_t *pin; bool value; bool pull; } alarm_pin_pinalarm_obj_t; diff --git a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk index 211a658967..4b53ef2da1 100644 --- a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk +++ b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk @@ -17,4 +17,7 @@ MCU_PACKAGE = UFQFPN48 LD_COMMON = boards/common_default.ld LD_FILE = boards/STM32F411_nvm_nofs.ld +# Too big for the flash +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_SYNTHIO = 0 diff --git a/ports/stm/common-hal/alarm/pin/PinAlarm.h b/ports/stm/common-hal/alarm/pin/PinAlarm.h index 2b94f1cb7e..bd18c840ff 100644 --- a/ports/stm/common-hal/alarm/pin/PinAlarm.h +++ b/ports/stm/common-hal/alarm/pin/PinAlarm.h @@ -24,6 +24,9 @@ * THE SOFTWARE. */ +#ifndef MICROPY_INCLUDED_STM32_COMMON_HAL_ALARM_PINALARM_H +#define MICROPY_INCLUDED_STM32_COMMON_HAL_ALARM_PINALARM_H + #include "py/obj.h" #include "py/objtuple.h" @@ -39,3 +42,5 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob void alarm_pin_pinalarm_prepare_for_deep_sleep(void); mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms); bool alarm_pin_pinalarm_woke_us_up(void); + +#endif // MICROPY_INCLUDED_STM32_COMMON_HAL_ALARM_PINALARM_H diff --git a/ports/stm/common-hal/alarm/time/TimeAlarm.h b/ports/stm/common-hal/alarm/time/TimeAlarm.h index 11c7a634c5..0d0c25deae 100644 --- a/ports/stm/common-hal/alarm/time/TimeAlarm.h +++ b/ports/stm/common-hal/alarm/time/TimeAlarm.h @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +#ifndef MICROPY_INCLUDED_STM32_COMMON_HAL_ALARM_TIMEALARM_H +#define MICROPY_INCLUDED_STM32_COMMON_HAL_ALARM_TIMEALARM_H #include "py/obj.h" @@ -40,3 +42,5 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ void alarm_time_timealarm_reset(void); void alarm_time_timealarm_prepare_for_deep_sleep(void); + +#endif // MICROPY_INCLUDED_STM32_COMMON_HAL_ALARM_TIMEALARM_H diff --git a/ports/stm/peripherals/exti.c b/ports/stm/peripherals/exti.c index fe17309f06..fe8fc14fbe 100644 --- a/ports/stm/peripherals/exti.c +++ b/ports/stm/peripherals/exti.c @@ -32,6 +32,8 @@ #include "peripherals/exti.h" +#if !(CPY_STM32H7) + STATIC bool stm_exti_reserved[STM32_GPIO_PORT_SIZE]; STATIC bool stm_exti_never_reset[STM32_GPIO_PORT_SIZE]; STATIC void (*stm_exti_callback[STM32_GPIO_PORT_SIZE])(uint8_t num); @@ -145,3 +147,5 @@ void EXTI15_10_IRQHandler(void) } } } + +#endif diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index df82398351..d435f1e175 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -175,6 +175,7 @@ safe_mode_t port_init(void) { HAL_Init(); // Turns on SysTick __HAL_RCC_SYSCFG_CLK_ENABLE(); + #if CPY_STM32F4 __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); @@ -194,6 +195,8 @@ safe_mode_t port_init(void) { __HAL_RCC_BACKUPRESET_FORCE(); __HAL_RCC_BACKUPRESET_RELEASE(); + #endif + stm32_peripherals_clocks_init(); stm32_peripherals_gpio_init(); stm32_peripherals_rtc_init();