Skip to content

Commit 120d547

Browse files
committed
chore: harden deinit
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 3ce53c4 commit 120d547

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/rtc.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,11 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef *rtcHandle)
132132
{
133133

134134
if (rtcHandle->Instance == RTC) {
135-
/* Peripheral clock disable */
136-
__HAL_RCC_RTC_DISABLE();
137-
#ifdef __HAL_RCC_RTCAPB_CLK_DISABLE
138-
__HAL_RCC_RTCAPB_CLK_DISABLE();
139-
#endif
140135
/* RTC interrupt Deinit */
141136
#if defined(STM32WLxx)
142137
/* Only the STM32WLxx series has a TAMP_STAMP_LSECSS_SSRU_IRQn */
143138
HAL_NVIC_DisableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn);
144139
#endif /* STM32WLxx */
145-
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
146140
}
147141
}
148142

@@ -635,6 +629,15 @@ bool RTC_init(hourFormat_t format, binaryMode_t mode, sourceClock_t source, bool
635629
void RTC_DeInit(bool reset_cb)
636630
{
637631
HAL_RTC_DeInit(&RtcHandle);
632+
/* Peripheral clock disable */
633+
__HAL_RCC_RTC_DISABLE();
634+
#ifdef __HAL_RCC_RTCAPB_CLK_DISABLE
635+
__HAL_RCC_RTCAPB_CLK_DISABLE();
636+
#endif
637+
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
638+
#ifdef ONESECOND_IRQn
639+
HAL_NVIC_DisableIRQ(ONESECOND_IRQn);
640+
#endif
638641
if (reset_cb) {
639642
RTCUserCallback = NULL;
640643
callbackUserData = NULL;

0 commit comments

Comments
 (0)