STM32L4xx_HAL_Driver  1.14.0
Peripheral Control functions

Peripheral Control functions. More...

Functions

HAL_StatusTypeDef HAL_RTC_WaitForSynchro (RTC_HandleTypeDef *hrtc)
 Wait until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock. More...
 

Detailed Description

Peripheral Control functions.

 ===============================================================================
                     ##### Peripheral Control functions #####
 ===============================================================================
    [..]
    This subsection provides functions allowing to
      (+) Wait for RTC Time and Date Synchronization

Function Documentation

◆ HAL_RTC_WaitForSynchro()

HAL_StatusTypeDef HAL_RTC_WaitForSynchro ( RTC_HandleTypeDef hrtc)

Wait until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock.

Note
The RTC Resynchronization mode is write protected, use the __HAL_RTC_WRITEPROTECTION_DISABLE() before calling this function.
To read the calendar through the shadow registers after Calendar initialization, calendar update or after wakeup from low power modes the software must first clear the RSF flag. The software must then wait until it is set again before reading the calendar, which means that the calendar registers have been correctly copied into the RTC_TR and RTC_DR shadow registers.
Parameters
hrtcRTC handle
Return values
HALstatus

Definition at line 1685 of file stm32l4xx_hal_rtc.c.

1686 {
1687  uint32_t tickstart;
1688 
1689  /* Clear RSF flag */
1690 #if defined(STM32L412xx) || defined(STM32L422xx)
1691  hrtc->Instance->ICSR &= (uint32_t)RTC_RSF_MASK;
1692 #else
1693  hrtc->Instance->ISR &= (uint32_t)RTC_RSF_MASK;
1694 #endif
1695 
1696  tickstart = HAL_GetTick();
1697 
1698  /* Wait the registers to be synchronised */
1699 #if defined(STM32L412xx) || defined(STM32L422xx)
1700  while ((hrtc->Instance->ICSR & RTC_ICSR_RSF) == 0U)
1701 #else
1702  while ((hrtc->Instance->ISR & RTC_ISR_RSF) == 0U)
1703 #endif
1704  {
1705  if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1706  {
1707  return HAL_TIMEOUT;
1708  }
1709  }
1710 
1711  return HAL_OK;
1712 }
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
return HAL_OK