Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int update_flag = read_rtc_register(0x0A) & 0x80;
- while (update_flag)
- {
- UniqueIRQLock l;
- tp.seconds = read_rtc_register(0x00);
- tp.minutes = read_rtc_register(0x02);
- tp.hours = read_rtc_register(0x04);
- tp.day_of_month = read_rtc_register(0x07);
- tp.month = read_rtc_register(0x08);
- tp.year = read_rtc_register(0x09);
- }
- bool match = true;
- do
- {
- UniqueIRQLock l;
- match = check_match(tp.seconds, read_rtc_register(0x00)) &&
- check_match(tp.minutes, read_rtc_register(0x02)) &&
- check_match(tp.hours, read_rtc_register(0x04)) &&
- check_match(tp.day_of_month, read_rtc_register(0x07)) &&
- check_match(tp.month, read_rtc_register(0x08)) &&
- check_match(tp.year, read_rtc_register(0x09));
- } while (!match);
- // checks 2nd bit of status register
- int binary_flag = read_rtc_register(0x0B) & 0x04;
- if (!binary_flag) {
- tp.seconds = (tp.seconds & 0x0F) + ((tp.seconds / 16 * 10));
- tp.minutes = (tp.minutes & 0x0F) + ((tp.minutes / 16 * 10));
- tp.hours = ((tp.hours & 0x0F) + (((tp.hours & 0x70) / 16 * 10))) | (tp.hours & 0x80);
- tp.day_of_month = (tp.day_of_month & 0x0F) + ((tp.day_of_month / 16 * 10));
- tp.month = (tp.month & 0x0F) + ((tp.month / 16 * 10));
- tp.year = (tp.year & 0x0F) + ((tp.year / 16 * 10));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement