From cc92e9718455821f0d12a5c4b170025148517758 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 26 Feb 2024 17:01:36 +0100 Subject: [PATCH] feat(WBA): Add RTC STM32WBAxx support Signed-off-by: Frederic Pillon --- src/rtc.c | 8 ++++++-- src/rtc.h | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rtc.c b/src/rtc.c index 73c911f..536d7c4 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -441,8 +441,9 @@ bool RTC_init(hourFormat_t format, binaryMode_t mode, sourceClock_t source, bool #ifdef __HAL_RCC_RTCAPB_CLK_ENABLE __HAL_RCC_RTCAPB_CLK_ENABLE(); #endif +#ifdef __HAL_RCC_RTC_ENABLE __HAL_RCC_RTC_ENABLE(); - +#endif isAlarmASet = RTC_IsAlarmSet(ALARM_A); #ifdef RTC_ALARM_B isAlarmBSet = RTC_IsAlarmSet(ALARM_B); @@ -591,7 +592,9 @@ void RTC_DeInit(bool reset_cb) { HAL_RTC_DeInit(&RtcHandle); /* Peripheral clock disable */ +#ifdef __HAL_RCC_RTC_DISABLE __HAL_RCC_RTC_DISABLE(); +#endif #ifdef __HAL_RCC_RTCAPB_CLK_DISABLE __HAL_RCC_RTCAPB_CLK_DISABLE(); #endif @@ -1124,7 +1127,8 @@ void RTC_Alarm_IRQHandler(void) #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \ defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F070xB) || \ defined(STM32F030xC) || defined(STM32G0xx) || defined(STM32H5xx) || \ - defined(STM32L0xx) || defined(STM32L5xx) || defined(STM32U5xx) + defined(STM32L0xx) || defined(STM32L5xx) || defined(STM32U5xx) || \ + defined(STM32WBAxx) // In some cases, the same vector is used to manage WakeupTimer, // but with a dedicated HAL IRQHandler HAL_RTCEx_WakeUpTimerIRQHandler(&RtcHandle); diff --git a/src/rtc.h b/src/rtc.h index 8d0bcd8..5a20a35 100644 --- a/src/rtc.h +++ b/src/rtc.h @@ -129,7 +129,8 @@ typedef void(*voidCallbackPtr)(void *); #endif /* !STM32F1xx */ #if defined(STM32C0xx) || defined(STM32F0xx) || defined(STM32H5xx) || \ - defined(STM32L0xx) || defined(STM32L5xx) || defined(STM32U5xx) + defined(STM32L0xx) || defined(STM32L5xx) || defined(STM32U5xx) || \ + defined(STM32WBAxx) #define RTC_Alarm_IRQn RTC_IRQn #define RTC_Alarm_IRQHandler RTC_IRQHandler #endif @@ -141,7 +142,7 @@ typedef void(*voidCallbackPtr)(void *); /* mapping the IRQn for the one-second interrupt depending on the soc */ #if defined(STM32F1xx) || (defined(STM32F0xx) && defined(RTC_CR_WUTE)) || \ defined(STM32H5xx) || defined(STM32L0xx) || defined(STM32L5xx) || \ - defined(STM32U5xx) + defined(STM32U5xx) || defined(STM32WBAxx) // specific WakeUp interrupt #define ONESECOND_IRQn RTC_IRQn #elif defined(STM32MP1xx)