Skip to content

Commit 24b0387

Browse files
Merge pull request #5747 from jeromecoutant/PR_RTC_SLEEP
STM32 : Fix issue to exit deepsleep when RTC has not been initialized
2 parents 31f7ea7 + 8c66213 commit 24b0387

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

targets/TARGET_STM/rtc_api.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ int rtc_isenabled(void)
291291

292292
void rtc_synchronize(void)
293293
{
294+
RtcHandle.Instance = RTC;
294295
if (HAL_RTC_WaitForSynchro(&RtcHandle) != HAL_OK) {
295296
error("rtc_synchronize error\n");
296297
}
@@ -301,6 +302,7 @@ void rtc_synchronize(void)
301302
static void RTC_IRQHandler(void)
302303
{
303304
/* Update HAL state */
305+
RtcHandle.Instance = RTC;
304306
HAL_RTCEx_WakeUpTimerIRQHandler(&RtcHandle);
305307
/* In case of registered handler, call it. */
306308
if (irq_handler) {
@@ -342,13 +344,15 @@ void rtc_set_wake_up_timer(uint32_t delta)
342344
NVIC_SetVector(RTC_WKUP_IRQn, (uint32_t)RTC_IRQHandler);
343345
NVIC_EnableIRQ(RTC_WKUP_IRQn);
344346

347+
RtcHandle.Instance = RTC;
345348
if (HAL_RTCEx_SetWakeUpTimer_IT(&RtcHandle, 0xFFFF & WakeUpCounter, WakeUpClock[DivIndex-1]) != HAL_OK) {
346349
error("rtc_set_wake_up_timer init error (%d)\n", DivIndex);
347350
}
348351
}
349352

350353
void rtc_deactivate_wake_up_timer(void)
351354
{
355+
RtcHandle.Instance = RTC;
352356
HAL_RTCEx_DeactivateWakeUpTimer(&RtcHandle);
353357
}
354358

0 commit comments

Comments
 (0)