Use our own flag for board crystal config.
This commit is contained in:
parent
bebf27e733
commit
17d038830d
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -34,4 +34,4 @@
|
|||
|
||||
#define BOARD_OSC_DIV (8)
|
||||
|
||||
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
|
||||
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue