Skip to content

Commit 0ffdc57

Browse files
committed
Update rtc_api.c
1 parent 216fca1 commit 0ffdc57

File tree

1 file changed

+5
-8
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32L4

1 file changed

+5
-8
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32L4/rtc_api.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333

3434
#include "mbed_error.h"
3535

36-
static int rtc_inited = 0;
37-
3836
static RTC_HandleTypeDef RtcHandle;
3937

4038
void rtc_init(void)
@@ -43,9 +41,6 @@ void rtc_init(void)
4341
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
4442
uint32_t rtc_freq = 0;
4543

46-
if (rtc_inited) return;
47-
rtc_inited = 1;
48-
4944
RtcHandle.Instance = RTC;
5045

5146
// Enable Power clock
@@ -128,13 +123,15 @@ void rtc_free(void)
128123
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
129124
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
130125
HAL_RCC_OscConfig(&RCC_OscInitStruct);
131-
132-
rtc_inited = 0;
133126
}
134127

135128
int rtc_isenabled(void)
136129
{
137-
return rtc_inited;
130+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS){
131+
return 1;
132+
} else {
133+
return 0;
134+
}
138135
}
139136

140137
/*

0 commit comments

Comments
 (0)