1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

ds1307: return error when nothing is read or written on initialization

It hints at to an unconnected devices ;-)
This commit is contained in:
Martine Lenders 2017-10-23 14:41:04 +02:00
parent 775e2071e5
commit 8ce7ff2836
No known key found for this signature in database
GPG Key ID: 8E97A9FE55F25D62

View File

@ -64,7 +64,7 @@ int ds1307_init(ds1307_t *dev, const ds1307_params_t *params)
}
/* normalize hour format */
res = i2c_read_reg(dev->i2c, DS1307_I2C_ADDRESS, DS1307_REG_HOUR, &hour);
if (res < 0) {
if (res <= 0) { /* should be 1 if device is connected */
i2c_release(dev->i2c);
DEBUG("ds1307: Error reading HOUR register on init: %i\n", res);
return -1;
@ -73,7 +73,7 @@ int ds1307_init(ds1307_t *dev, const ds1307_params_t *params)
_convert_12_to_24(hour));
i2c_release(dev->i2c);
if (res < 0) {
if (res <= 0) {
DEBUG("ds1307: Error writing HOUR register on init: %i\n", res);
return -1;
}