rtc.h 753 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. rtc.h
  3. */
  4. #ifndef _RTC_VIEW_H
  5. #define _RTC_VIEW_H
  6. #include "stdint.h"
  7. #define BCD_SEC_UNITS 0
  8. #define BCD_SEC_TENS 1
  9. #define BCD_MIN_UNITS 2
  10. #define BCD_MIN_TENS 3
  11. #define BCD_HOUR_UNITS 4
  12. #define BCD_HOUR_TENS 5
  13. #define BCD_DAY_UNITS 6
  14. #define BCD_DAY_TENS 7
  15. #define BCD_MONTH_UNITS 8
  16. #define BCD_MONTH_TENS 9
  17. #define BCD_YEAR_UNITS 10
  18. #define BCD_YEAR_TENS 11
  19. struct _rtc_struct
  20. {
  21. uint8_t bcd[12];
  22. uint8_t sec; /* 0..59 */
  23. uint8_t min; /* 0..59 */
  24. uint8_t hour; /* 0..23 */
  25. uint8_t day; /* 1..31 */
  26. uint8_t month; /* 1..12 */
  27. uint8_t year; /* 0..99 */
  28. };
  29. typedef struct _rtc_struct rtc_t;
  30. void rtc_register_to_bcd(rtc_t *rtc);
  31. void rtc_bcd_to_ymd_hms(rtc_t *rtc);
  32. void rtc_draw_time(rtc_t *rtc, u8g2_t *u8g2);
  33. #endif