Skip to content

Commit 6b226ff

Browse files
committed
STM32 RTC update for easy maintenance
1 parent c1c94c8 commit 6b226ff

File tree

9 files changed

+24
-4
lines changed

9 files changed

+24
-4
lines changed

targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32f0xx_hal_def.h"
46+
#include "stm32f0xx_ll_rtc.h"
4647

4748
/** @addtogroup STM32F0xx_HAL_Driver
4849
* @{

targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
/* Includes ------------------------------------------------------------------*/
4747
#include "stm32f2xx_hal_def.h"
48+
#include "stm32f2xx_ll_rtc.h"
4849

4950
/** @addtogroup STM32F2xx_HAL_Driver
5051
* @{

targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32f3xx_hal_def.h"
46+
#include "stm32f3xx_ll_rtc.h"
4647

4748
/** @addtogroup STM32F3xx_HAL_Driver
4849
* @{

targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32f4xx_hal_def.h"
46+
#include "stm32f4xx_ll_rtc.h"
4647

4748
/** @addtogroup STM32F4xx_HAL_Driver
4849
* @{

targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32f7xx_hal_def.h"
46+
#include "stm32f7xx_ll_rtc.h"
4647

4748
/** @addtogroup STM32F7xx_HAL_Driver
4849
* @{

targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32l0xx_hal_def.h"
46+
#include "stm32l0xx_ll_rtc.h"
4647

4748
/** @addtogroup STM32L0xx_HAL_Driver
4849
* @{

targets/TARGET_STM/TARGET_STM32L1/device/stm32l1xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32l1xx_hal_def.h"
46+
#include "stm32l1xx_ll_rtc.h"
4647

4748
/** @addtogroup STM32L1xx_HAL_Driver
4849
* @{

targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32l4xx_hal_def.h"
46+
#include "stm32l4xx_ll_rtc.h"
4647

4748
/** @addtogroup STM32L4xx_HAL_Driver
4849
* @{

targets/TARGET_STM/rtc_api.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ void rtc_init(void)
9393
// Enable RTC
9494
__HAL_RCC_RTC_ENABLE();
9595

96+
#if defined __HAL_RCC_RTCAPB_CLK_ENABLE /* part of STM32L4 */
97+
__HAL_RCC_RTCAPB_CLK_ENABLE();
98+
#endif /* __HAL_RCC_RTCAPB_CLK_ENABLE */
99+
96100
RtcHandle.Instance = RTC;
97101
RtcHandle.State = HAL_RTC_STATE_RESET;
98102

@@ -105,6 +109,12 @@ void rtc_init(void)
105109
RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
106110
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
107111
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
112+
#if defined (RTC_OUTPUT_REMAP_NONE)
113+
RtcHandle.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
114+
#endif /* defined (RTC_OUTPUT_REMAP_NONE) */
115+
#if defined (RTC_OUTPUT_PULLUP_NONE)
116+
RtcHandle.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE;
117+
#endif /* defined (RTC_OUTPUT_PULLUP_NONE) */
108118
#endif /* TARGET_STM32F1 */
109119

110120
if (HAL_RTC_Init(&RtcHandle) != HAL_OK) {
@@ -257,11 +267,11 @@ void rtc_write(time_t t)
257267

258268
int rtc_isenabled(void)
259269
{
260-
#if !(TARGET_STM32F1)
261-
return ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS);
262-
#else /* TARGET_STM32F1 */
270+
#if defined (RTC_FLAG_INITS) /* all STM32 except STM32F1 */
271+
return LL_RTC_IsActiveFlag_INITS(RTC);
272+
#else /* RTC_FLAG_INITS */ /* TARGET_STM32F1 */
263273
return ((RTC->CRL & RTC_CRL_RSF) == RTC_CRL_RSF);
264-
#endif /* TARGET_STM32F1 */
274+
#endif /* RTC_FLAG_INITS */
265275
}
266276

267277

@@ -296,7 +306,9 @@ static void RTC_IRQHandler(void)
296306
}
297307
}
298308

309+
#ifdef __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG
299310
__HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
311+
#endif
300312
}
301313

302314
uint32_t rtc_read_lp(void)

0 commit comments

Comments
 (0)