#include #include "rtc.h" #include "i2c.h" void rtc_int0_init(void) { INT0_DIR &= ~(1<second), DEC_2_BCD(time->minute), DEC_2_BCD(time->hour) }; i2c_writebuf(RTC_I2C_ADDR, SECOND, 3, buf); // SECOND is the first memory cell (0x02) } struct TIME rtc_read_time(void) { uint8_t buffer[3]; i2c_readbuf(RTC_I2C_ADDR, 0x02, 3, buffer); struct TIME curr_time = { BCD_2_DEC(buffer[2]), BCD_2_DEC(buffer[1]), BCD_2_DEC(buffer[0]) }; return curr_time; }