/* Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock.  */
ErrorStatus RTC_WaitForSynchro(void)
/* Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock.  */
ErrorStatus RTC_WaitForSynchro(void)
{
  uint16_t rsfcount = 0;
  ErrorStatus status = ERROR;
  RTC->ISR1 &= (uint8_t)~(RTC_ISR1_RSF | RTC_ISR1_INIT);
  while (((RTC->ISR1 & RTC_ISR1_RSF) == RESET) && ( rsfcount != RSF_TIMEOUT))
  {
    rsfcount++;
  }
  if ((RTC->ISR1 & RTC_ISR1_RSF) != RESET)
  {
    status = SUCCESS;
  }
  else
  {
    status = ERROR;
  }
  return (ErrorStatus)status;
}