Use our own flag for board crystal config.

This commit is contained in:
Scott Shawcroft 2020-04-21 14:14:30 -07:00
parent bebf27e733
commit 17d038830d
No known key found for this signature in database
GPG Key ID: 9349BC7E64B1921E
14 changed files with 21 additions and 19 deletions

View File

@ -36,5 +36,5 @@
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
#define BOARD_OSC_DIV (8)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)

View File

@ -33,5 +33,5 @@
#define FLASH_PAGE_SIZE (0x4000) //16K
#define BOARD_OSC_DIV (8)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
#define BOARD_OVERWRITE_SWD (1)

View File

@ -36,7 +36,7 @@
#define BOARD_OSC_DIV (12)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
// On-board flash
#define SPI_FLASH_MOSI_PIN (&pin_PB05)

View File

@ -36,7 +36,7 @@
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
#define BOARD_OSC_DIV (12)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
#define HSE_VALUE ((uint32_t)12000000U)
#define LSE_VALUE ((uint32_t)32000U)

View File

@ -33,4 +33,4 @@
#define FLASH_PAGE_SIZE (0x4000)
#define BOARD_OSC_DIV (8)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)

View File

@ -32,4 +32,4 @@
#define FLASH_PAGE_SIZE (0x4000)
#define BOARD_OSC_DIV (8)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)

View File

@ -33,8 +33,7 @@
#define FLASH_PAGE_SIZE (0x4000)
#define BOARD_OSC_DIV (8)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define LSE_VALUE ((uint32_t)32768U)
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
// On-board flash
#define SPI_FLASH_MOSI_PIN (&pin_PB15)

View File

@ -33,7 +33,7 @@
#define FLASH_PAGE_SIZE (0x4000)
#define BOARD_OSC_DIV (12)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
#define HSE_VALUE ((uint32_t)12000000U)
#define LSE_VALUE ((uint32_t)32000U)

View File

@ -35,7 +35,7 @@
#define BOARD_OSC_DIV (25)
#define BOARD_NO_VBUS_SENSE (1)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
#define HSE_VALUE ((uint32_t)25000000U)
// On-board flash

View File

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

View File

@ -34,7 +34,7 @@
#define BOARD_OSC_DIV (8)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
#define DEFAULT_I2C_BUS_SCL (&pin_PB10)
#define DEFAULT_I2C_BUS_SDA (&pin_PB09)

View File

@ -34,4 +34,4 @@
#define BOARD_OSC_DIV (8)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)

View File

@ -44,7 +44,7 @@
#define BOARD_OVERWRITE_SWD (1)
#define BOARD_NO_VBUS_SENSE (1)
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSI
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
#define HSE_VALUE ((uint32_t)24000000U)
// Status LEDs

View File

@ -152,7 +152,7 @@ __attribute__((used, naked)) void Reset_Handler(void) {
static RTC_HandleTypeDef _hrtc;
#if BOARD_RTC_CLOCK == RCC_RTCCLKSOURCE_LSE
#if BOARD_HAS_LOW_SPEED_CRYSTAL
#define RTC_CLOCK_FREQUENCY LSE_VALUE
#else
#define RTC_CLOCK_FREQUENCY LSI_VALUE
@ -170,14 +170,17 @@ safe_mode_t port_init(void) {
stm32_peripherals_gpio_init();
HAL_PWR_EnableBkUpAccess();
#if BOARD_RTC_CLOCK == RCC_RTCCLKSOURCE_LSE
#if BOARD_HAS_LOW_SPEED_CRYSTAL
__HAL_RCC_LSE_CONFIG(RCC_LSE_ON);
while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) {}
#else
__HAL_RCC_LSI_ENABLE();
#endif
__HAL_RCC_RTC_CONFIG(BOARD_RTC_CLOCK);
#if BOARD_HAS_LOW_SPEED_CRYSTAL
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
#else
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
#endif
__HAL_RCC_RTC_ENABLE();
_hrtc.Instance = RTC;
_hrtc.Init.HourFormat = RTC_HOURFORMAT_24;