Advertisement
Guest User

hai

a guest
Mar 19th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. int update_flag = read_rtc_register(0x0A) & 0x80;
  2.  
  3. while (update_flag)
  4. {
  5. UniqueIRQLock l;
  6. tp.seconds = read_rtc_register(0x00);
  7. tp.minutes = read_rtc_register(0x02);
  8. tp.hours = read_rtc_register(0x04);
  9. tp.day_of_month = read_rtc_register(0x07);
  10. tp.month = read_rtc_register(0x08);
  11. tp.year = read_rtc_register(0x09);
  12. }
  13.  
  14. bool match = true;
  15.  
  16. do
  17. {
  18. UniqueIRQLock l;
  19. match = check_match(tp.seconds, read_rtc_register(0x00)) &&
  20. check_match(tp.minutes, read_rtc_register(0x02)) &&
  21. check_match(tp.hours, read_rtc_register(0x04)) &&
  22. check_match(tp.day_of_month, read_rtc_register(0x07)) &&
  23. check_match(tp.month, read_rtc_register(0x08)) &&
  24. check_match(tp.year, read_rtc_register(0x09));
  25.  
  26. } while (!match);
  27.  
  28. // checks 2nd bit of status register
  29. int binary_flag = read_rtc_register(0x0B) & 0x04;
  30.  
  31. if (!binary_flag) {
  32. tp.seconds = (tp.seconds & 0x0F) + ((tp.seconds / 16 * 10));
  33. tp.minutes = (tp.minutes & 0x0F) + ((tp.minutes / 16 * 10));
  34. tp.hours = ((tp.hours & 0x0F) + (((tp.hours & 0x70) / 16 * 10))) | (tp.hours & 0x80);
  35. tp.day_of_month = (tp.day_of_month & 0x0F) + ((tp.day_of_month / 16 * 10));
  36. tp.month = (tp.month & 0x0F) + ((tp.month / 16 * 10));
  37. tp.year = (tp.year & 0x0F) + ((tp.year / 16 * 10));
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement