extmod/machine_i2c: Release SDA on bus error

This commit is contained in:
Radomir Dopieralski 2016-11-13 21:18:07 +01:00 committed by Damien George
parent 9a82b67f39
commit e81a5353cb
1 changed files with 2 additions and 0 deletions

View File

@ -117,6 +117,7 @@ STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) {
}
mp_hal_i2c_delay(self);
if (!mp_hal_i2c_scl_release(self)) {
mp_hal_i2c_sda_release(self);
return 0; // failure
}
mp_hal_i2c_scl_low(self);
@ -157,6 +158,7 @@ STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack)
}
mp_hal_i2c_delay(self);
if (!mp_hal_i2c_scl_release(self)) {
mp_hal_i2c_sda_release(self);
return 0; // failure
}
mp_hal_i2c_scl_low(self);