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)
62
62
while (LL_HSEM_1StepLock (HSEM , CFG_HW_RCC_SEMID )) {
63
63
}
64
64
#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
66
77
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSE ;
67
78
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ;
68
79
#if MBED_CONF_TARGET_LSE_BYPASS
Original file line number Diff line number Diff line change 38
38
extern "C" {
39
39
#endif
40
40
41
- #if MBED_CONF_TARGET_LSE_AVAILABLE
41
+ #if RTC_FROM_HSE
42
+ #define RTC_CLOCK 1000000U
43
+ #elif MBED_CONF_TARGET_LSE_AVAILABLE
42
44
#define RTC_CLOCK LSE_VALUE
43
45
#else
44
46
#define RTC_CLOCK LSI_VALUE
@@ -47,7 +49,11 @@ extern "C" {
47
49
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
48
50
/* PREDIV_A : 7-bit asynchronous prescaler */
49
51
/* 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
50
55
#define PREDIV_A_VALUE 3
56
+ #endif
51
57
52
58
/** Read RTC counter with sub second precision
53
59
*
You can’t perform that action at this time.
0 commit comments