Skip to content

Commit e81a535

Browse files
deshipudpgeorge
authored andcommitted
extmod/machine_i2c: Release SDA on bus error
1 parent 9a82b67 commit e81a535

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

extmod/machine_i2c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) {
117117
}
118118
mp_hal_i2c_delay(self);
119119
if (!mp_hal_i2c_scl_release(self)) {
120+
mp_hal_i2c_sda_release(self);
120121
return 0; // failure
121122
}
122123
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)
157158
}
158159
mp_hal_i2c_delay(self);
159160
if (!mp_hal_i2c_scl_release(self)) {
161+
mp_hal_i2c_sda_release(self);
160162
return 0; // failure
161163
}
162164
mp_hal_i2c_scl_low(self);

0 commit comments

Comments
 (0)