File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,18 @@ void rtc_init(void)
6262 while (LL_HSEM_1StepLock (HSEM , CFG_HW_RCC_SEMID )) {
6363 }
6464#endif /* DUAL_CORE */
65- #if MBED_CONF_TARGET_LSE_AVAILABLE
65+ #if RTC_FROM_HSE
66+ #define RTC_HSE_DIV (HSE_VALUE / RTC_CLOCK)
67+ #if RTC_HSE_DIV > 31
68+ #error "HSE value too high for RTC"
69+ #endif
70+ (void )RCC_OscInitStruct ;
71+ PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_RTC ;
72+ PeriphClkInitStruct .RTCClockSelection = (RCC_RTCCLKSOURCE_HSE_DIVX | RTC_HSE_DIV << 16 );
73+ if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
74+ error ("PeriphClkInitStruct RTC failed with HSE\n" );
75+ }
76+ #elif MBED_CONF_TARGET_LSE_AVAILABLE
6677 RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSE ;
6778 RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ;
6879#if MBED_CONF_TARGET_LSE_BYPASS
Original file line number Diff line number Diff line change 3838extern "C" {
3939#endif
4040
41- #if MBED_CONF_TARGET_LSE_AVAILABLE
41+ #if RTC_FROM_HSE
42+ #define RTC_CLOCK 1000000U
43+ #elif MBED_CONF_TARGET_LSE_AVAILABLE
4244#define RTC_CLOCK LSE_VALUE
4345#else
4446#define RTC_CLOCK LSI_VALUE
@@ -47,7 +49,11 @@ extern "C" {
4749#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
4850/* PREDIV_A : 7-bit asynchronous prescaler */
4951/* PREDIV_A is set to set LPTICKER frequency to RTC_CLOCK/4 */
52+ #if RTC_FROM_HSE
53+ #define PREDIV_A_VALUE 124
54+ #else
5055#define PREDIV_A_VALUE 3
56+ #endif
5157
5258/** Read RTC counter with sub second precision
5359 *
You can’t perform that action at this time.
0 commit comments