/* Waits until the RTC Time register (RTC_TR) is synchronized with RTC APB clock.  */
u32 RTC_WaitForSynchro(void)
/* Waits until the RTC Time register (RTC_TR) is synchronized with RTC APB clock.  */
u32 RTC_WaitForSynchro(void)
{
	RTC_TypeDef* RTC = ((RTC_TypeDef *) RTC_BASE);
	u32 counter = 0;
	u32 status = 0;
	u32 synchrostatus = 0x00;
	if (RTC->CR & RTC_CR_BYPSHAD) {
		return 1;
	}
	RTC->WPR = 0xCA;
	RTC->WPR = 0x53;
	RTC->ISR |= RTC_ISR_RSF;
	do {
		synchrostatus = RTC->ISR & RTC_ISR_RSF;
		counter++;
	} while ((counter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
	if (RTC->ISR & RTC_ISR_RSF) {
		status = 1;
	} else {
		status = 0;
	}
	RTC->WPR = 0xFF; 
	return (status); 
}