void rtc_settimereg(unsigned char r, unsigned char v) { unsigned char ctlb = rtc_readreg(DS_REG_CTLB); rtc_writereg(DS_REG_CTLB, ctlb | DS_CTLB_SET); rtc_writereg(r, byte_to_bcd(v)); rtc_writereg(DS_REG_CTLB, ctlb & ~DS_CTLB_SET); }
/* Convert an rtc_time from binary to BCD. * bcd_time: The destination buffer. * time: The source buffer. */ void rtc_time_to_bcd(struct rtc_time *bcd_time, const struct rtc_time *time) { bcd_time->second = byte_to_bcd(time->second); bcd_time->minute = byte_to_bcd(time->minute); bcd_time->hour = byte_to_bcd(time->hour); bcd_time->day = byte_to_bcd(time->day); bcd_time->month = byte_to_bcd(time->month); bcd_time->year = byte_to_bcd(time->year); bcd_time->day_of_week = time->day_of_week; }