Skip to content

Commit 0552ce2

Browse files
committed
Allocate I2C mutex with IDF
This keeps the mutex info in the same spot in memory. "Statically allocating it" with CircuitPython meant that the buffer moved when the I2C object is moved to keep it alive for a display. Fixes #4962
1 parent da320c3 commit 0552ce2

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
8888
}
8989
#endif
9090

91-
self->xSemaphore = xSemaphoreCreateMutexStatic(&self->xSemaphoreBuffer);
91+
self->xSemaphore = xSemaphoreCreateMutex();
9292
if (self->xSemaphore == NULL) {
9393
mp_raise_RuntimeError(translate("Unable to create lock"));
9494
}

ports/esp32s2/common-hal/busio/I2C.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ typedef struct {
4040
const mcu_pin_obj_t *sda_pin;
4141
i2c_port_t i2c_num;
4242
SemaphoreHandle_t xSemaphore;
43-
StaticSemaphore_t xSemaphoreBuffer;
4443
bool has_lock;
4544
} busio_i2c_obj_t;
4645

0 commit comments

Comments
 (0)