/* Waits until the RTC Time and Date registers are synchronized with RTC APB clock.  */
uint8_t RTC_WaitForSynchro(void)
/* Waits until the RTC Time and Date registers are synchronized with RTC APB clock.  */
uint8_t RTC_WaitForSynchro(void)
{
    __IO uint32_t timeout = 0;
    RTC_DisableWriteProtection();
    RTC->STS &= (uint32_t)0xFFFFFF5F;
    while ((RTC->STS_B.RSFLG != BIT_SET) && (timeout != RTC_TIMEOUT_SYNCHRO))
    {
        timeout++;
    }
    if (RTC->STS_B.RSFLG != BIT_RESET)
    {
        RTC_EnableWriteProtection();
        return SUCCESS;
    }
    else
    {
        RTC_EnableWriteProtection();
        return ERROR;
    }
}