|
|
|
@ -109,13 +109,15 @@ time_t pcf8523_now(pcf8523_t *pcf8523)
@@ -109,13 +109,15 @@ time_t pcf8523_now(pcf8523_t *pcf8523)
|
|
|
|
|
|
|
|
|
|
/* read current time */ |
|
|
|
|
pcf8253_read(pcf8523, PCF_REG_SECONDS, buf, 7); |
|
|
|
|
t.tm_sec = bcd2bin(buf[0]); |
|
|
|
|
t.tm_min = bcd2bin(buf[1]); |
|
|
|
|
t.tm_hour = bcd2bin(buf[2]); |
|
|
|
|
t.tm_mday = bcd2bin(buf[3]); |
|
|
|
|
t.tm_wday = bcd2bin(buf[4]); /* ignored by mktime */ |
|
|
|
|
t.tm_mon = bcd2bin(buf[5]); |
|
|
|
|
t.tm_year = bcd2bin(buf[6]) + 2000; |
|
|
|
|
t.tm_sec = bcd2bin(buf[0]); /* Seconds [0, 60] */ |
|
|
|
|
t.tm_min = bcd2bin(buf[1]); /* Minutes [0, 59] */ |
|
|
|
|
t.tm_hour = bcd2bin(buf[2]); /* Hour [0, 23] */ |
|
|
|
|
t.tm_mday = bcd2bin(buf[3]); /* Day of the month [1, 31] */ |
|
|
|
|
t.tm_wday = bcd2bin(buf[4]); /* Month [0, 11] (January = 0) */ |
|
|
|
|
t.tm_yday = 0; /* Day of the year [0, 365] (Jan/01 = 0) */ |
|
|
|
|
t.tm_mon = bcd2bin(buf[5]); /* Month [0, 11] (January = 0) */ |
|
|
|
|
t.tm_year = bcd2bin(buf[6]) + 100; /* Year minus 1900 */ |
|
|
|
|
/* tm_wday and tm_yday are ignored by mktime() */ |
|
|
|
|
time = mktime(&t); |
|
|
|
|
|
|
|
|
|
return time; |
|
|
|
|