rtc.h 823 B

12345678910111213141516171819202122
  1. #ifndef RTC_H
  2. #define RTC_H
  3. #include "syscall.h"
  4. /* Write formatted date/time into buf: "YYYY-MM-DD HH:MM:SS" (19 chars + NUL). */
  5. void rtc_read_datetime(char *buf);
  6. /* Read current hour (0-23), minute (0-59), second (0-59). */
  7. void rtc_read_hms(unsigned int *hour, unsigned int *minute, unsigned int *second);
  8. /* Read the full date/time. The two-digit RTC year is expanded with a
  9. * 1970-2069 window (70-99 -> 1900s, 00-69 -> 2000s), so a dead-battery
  10. * default such as 1980 or 1990 stays in the past. A failed read keeps the
  11. * last good value. */
  12. void rtc_read_datetime_full(struct sys_datetime *out);
  13. /* Validate and write the RTC; returns 0 on success, -1 on a bad field or a
  14. * write that could not be sequenced (see rtc.c). Accepts 1970-2069. */
  15. int rtc_set_datetime(const struct sys_datetime *in);
  16. #endif