From 85c337d0b9266d58e4530e529de297b2a88ef2e9 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Fri, 17 Nov 2017 12:11:22 +0100 Subject: [PATCH] STM32 LOW_POWER_TIMER update : rtc_init procedure --- targets/TARGET_STM/rtc_api.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/TARGET_STM/rtc_api.c b/targets/TARGET_STM/rtc_api.c index ab3087df6d..eea48c02ae 100644 --- a/targets/TARGET_STM/rtc_api.c +++ b/targets/TARGET_STM/rtc_api.c @@ -55,8 +55,13 @@ void rtc_init(void) RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; // Enable access to Backup domain + __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); + if (rtc_isenabled()) { + return; + } + #if !RTC_LSI /* => LSE */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured! @@ -76,12 +81,7 @@ void rtc_init(void) error("PeriphClkInitStruct RTC failed with LSE\n"); } - if (rtc_isenabled()) return; #else /* => RTC_LSI */ - if (rtc_isenabled()) return; - - __HAL_RCC_PWR_CLK_ENABLE(); - // Reset Backup domain __HAL_RCC_BACKUPRESET_FORCE(); __HAL_RCC_BACKUPRESET_RELEASE();