diff --git a/source/common/rtc.c b/source/common/rtc.c index 4b726b3..ecc3911 100644 --- a/source/common/rtc.c +++ b/source/common/rtc.c @@ -28,13 +28,13 @@ bool is_valid_dstime(DsTime* dstime) { } bool get_dstime(DsTime* dstime) { - return (I2C_readRegBuf(I2C_DEV_MCU, 0x30, (void*) dstime, 7)); + return (I2C_readRegBuf(I2C_DEV_MCU, 0x30, (void*) dstime, sizeof(DsTime))); } bool set_dstime(DsTime* dstime) { if (!is_valid_dstime(dstime)) return false; - for (u32 i = 0; i < 7; i++) { - if (i == 3) continue; // skip the unknown byte + for (u32 i = 0; i < sizeof(DsTime); i++) { + if ((i == 3) || (i == 7)) continue; // skip the unused bytes if (!I2C_writeReg(I2C_DEV_MCU, 0x30+i, ((u8*)dstime)[i])) return false; } diff --git a/source/common/rtc.h b/source/common/rtc.h index 140f9ed..39829e8 100644 --- a/source/common/rtc.h +++ b/source/common/rtc.h @@ -12,10 +12,11 @@ typedef struct { u8 bcd_s; u8 bcd_m; u8 bcd_h; - u8 unknown; + u8 weekday; u8 bcd_D; u8 bcd_M; u8 bcd_Y; + u8 leap_count; } __attribute__((packed)) DsTime; bool is_valid_dstime(DsTime* dstime);