Skip to content
Snippets Groups Projects
Commit e81a5353 authored by Radomir Dopieralski's avatar Radomir Dopieralski Committed by Damien George
Browse files

extmod/machine_i2c: Release SDA on bus error

parent 9a82b67f
No related branches found
No related tags found
No related merge requests found
...@@ -117,6 +117,7 @@ STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) { ...@@ -117,6 +117,7 @@ STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) {
} }
mp_hal_i2c_delay(self); mp_hal_i2c_delay(self);
if (!mp_hal_i2c_scl_release(self)) { if (!mp_hal_i2c_scl_release(self)) {
mp_hal_i2c_sda_release(self);
return 0; // failure return 0; // failure
} }
mp_hal_i2c_scl_low(self); 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) ...@@ -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); mp_hal_i2c_delay(self);
if (!mp_hal_i2c_scl_release(self)) { if (!mp_hal_i2c_scl_release(self)) {
mp_hal_i2c_sda_release(self);
return 0; // failure return 0; // failure
} }
mp_hal_i2c_scl_low(self); mp_hal_i2c_scl_low(self);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment