/******************************************************************************* * Function Name : rtc_settime * Description : sets HW-RTC with values from time-struct, takes DST into * account, HW-RTC always running in non-DST time * Input : None * Output : None * Return : not used *******************************************************************************/ bool rtc_settime (const RTC_t *rtc) { uint32_t cnt; RTC_t ts; cnt = struct_to_counter( rtc ); // non-DST counter-value counter_to_struct( cnt, &ts ); // normalize struct (for weekday) if ( isDST( &ts ) ) { cnt -= 60*60; // Subtract one hour } RTC_SetCounter( cnt ); return true; }
/******************************************************************************* * Function Name : rtc_settime * Description : sets HW-RTC with values from time-struct, takes DST into * account, HW-RTC always running in non-DST time * Input : None * Output : None * Return : not used *******************************************************************************/ void rtc_settime (const RTC_t *rtc) { uint32_t cnt; volatile uint16_t i; RTC_t ts; cnt = struct_to_counter( rtc ); // non-DST counter-value counter_to_struct( cnt, &ts ); // normalize struct (for weekday) if ( isDST( &ts ) ) { cnt -= 60*60; // Subtract one hour } PWR_BackupAccessCmd(ENABLE); my_RTC_SetCounter( cnt ); PWR_BackupAccessCmd(DISABLE); }