/* Sets the RTC BCD calendar day value. 
Requires unlocking the RTC write-protection (RTC_WPR)  */
void rtc_calendar_set_day(uint8_t day)
/* Sets the RTC BCD calendar day value. 
Requires unlocking the RTC write-protection (RTC_WPR)  */
void rtc_calendar_set_day(uint8_t day)
{
	uint8_t bcd_day = _rtc_dec_to_bcd(day);
	RTC_DR &= ~(RTC_DR_DT_MASK << RTC_DR_DT_SHIFT | RTC_DR_DU_MASK << RTC_DR_DU_SHIFT);
	RTC_DR |= (((bcd_day >> 4) & RTC_DR_DT_MASK) << RTC_DR_DT_SHIFT) |
		((bcd_day & RTC_DR_DU_MASK) << RTC_DR_DU_SHIFT);
}