Skip to content

Commit 17d0388

Browse files
committed
Use our own flag for board crystal config.
1 parent bebf27e commit 17d0388

File tree

14 files changed

+21
-19
lines changed

14 files changed

+21
-19
lines changed

ports/stm/boards/espruino_pico/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
3737

3838
#define BOARD_OSC_DIV (8)
39-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
39+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
4040

ports/stm/boards/espruino_wifi/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
#define FLASH_PAGE_SIZE (0x4000) //16K
3434

3535
#define BOARD_OSC_DIV (8)
36-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
36+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
3737
#define BOARD_OVERWRITE_SWD (1)

ports/stm/boards/feather_stm32f405_express/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#define BOARD_OSC_DIV (12)
3838

39-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
39+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
4040

4141
// On-board flash
4242
#define SPI_FLASH_MOSI_PIN (&pin_PB05)

ports/stm/boards/meowbit_v121/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
3737

3838
#define BOARD_OSC_DIV (12)
39-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
39+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
4040
#define HSE_VALUE ((uint32_t)12000000U)
4141
#define LSE_VALUE ((uint32_t)32000U)
4242

ports/stm/boards/nucleo_f767zi/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
#define FLASH_PAGE_SIZE (0x4000)
3434

3535
#define BOARD_OSC_DIV (8)
36-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
36+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)

ports/stm/boards/nucleo_h743zi_2/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
#define FLASH_PAGE_SIZE (0x4000)
3333

3434
#define BOARD_OSC_DIV (8)
35-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
35+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)

ports/stm/boards/pyb_nano_v2/mpconfigboard.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
#define FLASH_PAGE_SIZE (0x4000)
3434

3535
#define BOARD_OSC_DIV (8)
36-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
37-
#define LSE_VALUE ((uint32_t)32768U)
36+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
3837

3938
// On-board flash
4039
#define SPI_FLASH_MOSI_PIN (&pin_PB15)

ports/stm/boards/pyboard_v11/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#define FLASH_PAGE_SIZE (0x4000)
3434

3535
#define BOARD_OSC_DIV (12)
36-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
36+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
3737
#define HSE_VALUE ((uint32_t)12000000U)
3838
#define LSE_VALUE ((uint32_t)32000U)
3939

ports/stm/boards/stm32f411ce_blackpill/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define BOARD_OSC_DIV (25)
3636
#define BOARD_NO_VBUS_SENSE (1)
3737

38-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
38+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
3939
#define HSE_VALUE ((uint32_t)25000000U)
4040

4141
// On-board flash

ports/stm/boards/stm32f411ve_discovery/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535
#define BOARD_OSC_DIV (8)
3636

37-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
37+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
3838

3939
// The schematic has a 32k crystal that isn't fitted. Uncommented the line below if you add it.
40-
// #define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
40+
// #define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
4141
// #define LSE_VALUE ((uint32_t)32000U)

ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#define BOARD_OSC_DIV (8)
3636

37-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
37+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
3838

3939
#define DEFAULT_I2C_BUS_SCL (&pin_PB10)
4040
#define DEFAULT_I2C_BUS_SDA (&pin_PB09)

ports/stm/boards/stm32f4_discovery/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434

3535
#define BOARD_OSC_DIV (8)
3636

37-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
37+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)

ports/stm/boards/thunderpack/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#define BOARD_OVERWRITE_SWD (1)
4545
#define BOARD_NO_VBUS_SENSE (1)
4646

47-
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
47+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
4848
#define HSE_VALUE ((uint32_t)24000000U)
4949

5050
// Status LEDs

ports/stm/supervisor/port.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ __attribute__((used, naked)) void Reset_Handler(void) {
152152

153153
static RTC_HandleTypeDef _hrtc;
154154

155-
#if BOARD_RTC_CLOCK == RCC_RTCCLKSOURCE_LSE
155+
#if BOARD_HAS_LOW_SPEED_CRYSTAL
156156
#define RTC_CLOCK_FREQUENCY LSE_VALUE
157157
#else
158158
#define RTC_CLOCK_FREQUENCY LSI_VALUE
@@ -170,14 +170,17 @@ safe_mode_t port_init(void) {
170170
stm32_peripherals_gpio_init();
171171

172172
HAL_PWR_EnableBkUpAccess();
173-
#if BOARD_RTC_CLOCK == RCC_RTCCLKSOURCE_LSE
173+
#if BOARD_HAS_LOW_SPEED_CRYSTAL
174174
__HAL_RCC_LSE_CONFIG(RCC_LSE_ON);
175175
while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) {}
176176
#else
177177
__HAL_RCC_LSI_ENABLE();
178178
#endif
179-
180-
__HAL_RCC_RTC_CONFIG(BOARD_RTC_CLOCK);
179+
#if BOARD_HAS_LOW_SPEED_CRYSTAL
180+
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
181+
#else
182+
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
183+
#endif
181184
__HAL_RCC_RTC_ENABLE();
182185
_hrtc.Instance = RTC;
183186
_hrtc.Init.HourFormat = RTC_HOURFORMAT_24;

0 commit comments

Comments
 (0)