Skip to content

Commit 2b0e368

Browse files
committed
espressif: check for deinit in common_hal_busio_i2c_unlock()
I2C bus is unlocked in reset_board_buses(), but it might have been deinited already.
1 parent 0eddc63 commit 2b0e368

File tree

1 file changed

+4
-0
lines changed
  • ports/espressif/common-hal/busio

1 file changed

+4
-0
lines changed

ports/espressif/common-hal/busio/I2C.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
132132
xSemaphoreGive(self->xSemaphore);
133133
vSemaphoreDelete(self->xSemaphore);
134134
self->xSemaphore = NULL;
135+
self->has_lock = false;
135136

136137
common_hal_reset_pin(self->sda_pin);
137138
common_hal_reset_pin(self->scl_pin);
@@ -165,6 +166,9 @@ bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) {
165166
}
166167

167168
void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) {
169+
if (common_hal_busio_i2c_deinited(self)) {
170+
return;
171+
}
168172
xSemaphoreGive(self->xSemaphore);
169173
self->has_lock = false;
170174
}

0 commit comments

Comments
 (0)