Skip to content

Commit 0fecc56

Browse files
committed
STM32 RTC : Start LSI clock asap
1 parent 920db63 commit 0fecc56

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

targets/TARGET_STM/mbed_overrides.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,21 @@ void mbed_sdk_init()
5454
SetSysClock();
5555
SystemCoreClockUpdate();
5656

57+
/* Start LSI clock for RTC */
58+
#if DEVICE_RTC
59+
#if !MBED_CONF_TARGET_LSE_AVAILABLE
60+
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
61+
62+
if (__HAL_RCC_GET_RTC_SOURCE() != RCC_RTCCLKSOURCE_NO_CLK) {
63+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
64+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
65+
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
66+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
67+
error("Init : cannot initialize LSI\n");
68+
}
69+
}
70+
#endif /* ! MBED_CONF_TARGET_LSE_AVAILABLE */
71+
#endif /* DEVICE_RTC */
72+
5773
mbed_sdk_inited = 1;
5874
}

0 commit comments

Comments
 (0)