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
This commit is contained in:
Scott Shawcroft 2021-08-24 16:02:48 -07:00
parent da320c30f0
commit 0552ce2d3b
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
2 changed files with 1 additions and 2 deletions

View File

@ -88,7 +88,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
}
#endif
self->xSemaphore = xSemaphoreCreateMutexStatic(&self->xSemaphoreBuffer);
self->xSemaphore = xSemaphoreCreateMutex();
if (self->xSemaphore == NULL) {
mp_raise_RuntimeError(translate("Unable to create lock"));
}

View File

@ -40,7 +40,6 @@ typedef struct {
const mcu_pin_obj_t *sda_pin;
i2c_port_t i2c_num;
SemaphoreHandle_t xSemaphore;
StaticSemaphore_t xSemaphoreBuffer;
bool has_lock;
} busio_i2c_obj_t;