check return code
This commit is contained in:
parent
bbce44cb8f
commit
ba982e17c7
|
@ -146,7 +146,9 @@ uint8_t* rtc_ds1307_read_time(void)
|
|||
static uint8_t time[7] = {0}; // store time {seconds, minutes, hours, day, date, month, year}
|
||||
uint8_t data[7] = {0}; // to read data over I2C
|
||||
const uint8_t address[] = {0x00}; // memory address for data
|
||||
i2c_read(RTC_DS1307_I2C_ADDR, address, LENGTH(address), data, LENGTH(data)); // read all time bytes
|
||||
if (!i2c_read(RTC_DS1307_I2C_ADDR, address, LENGTH(address), data, LENGTH(data))) { // read all time bytes
|
||||
return NULL;
|
||||
}
|
||||
time[0] = ((data[0]&0x70)>>4)*10+(data[0]&0x0f); // convert seconds from BCD
|
||||
time[1] = (data[1]>>4)*10+(data[1]&0x0f); // convert minutes from BCD
|
||||
time[2] = 0; // re-initialize hours
|
||||
|
|
Loading…
Reference in New Issue