File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,17 @@ 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
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
71
+ PeriphClkInitStruct.RTCClockSelection = (RCC_RTCCLKSOURCE_HSE_DIVX | RTC_HSE_DIV << 16);
72
+ if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
73
+ error("PeriphClkInitStruct RTC failed with HSE\n");
74
+ }
75
+ #elif MBED_CONF_TARGET_LSE_AVAILABLE
66
76
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
67
77
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
68
78
#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