mirror of https://github.com/ARMmbed/mbed-os.git
Add HSE support to STM32 RTC
parent
8ba88427cd
commit
4d1161b689
|
|
@ -62,7 +62,18 @@ void rtc_init(void)
|
||||||
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
|
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
|
||||||
}
|
}
|
||||||
#endif /* DUAL_CORE */
|
#endif /* DUAL_CORE */
|
||||||
#if MBED_CONF_TARGET_LSE_AVAILABLE
|
#if RTC_FROM_HSE
|
||||||
|
#define RTC_HSE_DIV (HSE_VALUE / RTC_CLOCK)
|
||||||
|
#if RTC_HSE_DIV > 31
|
||||||
|
#error "HSE value too high for RTC"
|
||||||
|
#endif
|
||||||
|
(void)RCC_OscInitStruct;
|
||||||
|
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
|
||||||
|
PeriphClkInitStruct.RTCClockSelection = (RCC_RTCCLKSOURCE_HSE_DIVX | RTC_HSE_DIV << 16);
|
||||||
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
|
||||||
|
error("PeriphClkInitStruct RTC failed with HSE\n");
|
||||||
|
}
|
||||||
|
#elif MBED_CONF_TARGET_LSE_AVAILABLE
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||||
#if MBED_CONF_TARGET_LSE_BYPASS
|
#if MBED_CONF_TARGET_LSE_BYPASS
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MBED_CONF_TARGET_LSE_AVAILABLE
|
#if RTC_FROM_HSE
|
||||||
|
#define RTC_CLOCK 1000000U
|
||||||
|
#elif MBED_CONF_TARGET_LSE_AVAILABLE
|
||||||
#define RTC_CLOCK LSE_VALUE
|
#define RTC_CLOCK LSE_VALUE
|
||||||
#else
|
#else
|
||||||
#define RTC_CLOCK LSI_VALUE
|
#define RTC_CLOCK LSI_VALUE
|
||||||
|
|
@ -47,7 +49,11 @@ extern "C" {
|
||||||
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
|
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
|
||||||
/* PREDIV_A : 7-bit asynchronous prescaler */
|
/* PREDIV_A : 7-bit asynchronous prescaler */
|
||||||
/* PREDIV_A is set to set LPTICKER frequency to RTC_CLOCK/4 */
|
/* PREDIV_A is set to set LPTICKER frequency to RTC_CLOCK/4 */
|
||||||
|
#if RTC_FROM_HSE
|
||||||
|
#define PREDIV_A_VALUE 124
|
||||||
|
#else
|
||||||
#define PREDIV_A_VALUE 3
|
#define PREDIV_A_VALUE 3
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Read RTC counter with sub second precision
|
/** Read RTC counter with sub second precision
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue