esp32/machine_hw_spi: Release GIL during transfers.

Release the GIL while waiting for SPI transfers to complete to allow other
threads to make progress.

Fixes #7662.
This commit is contained in:
Jonathan Hogg 2021-08-15 17:13:16 +01:00 committed by Damien George
parent a1dc7277d9
commit 5b655665ab

View File

@ -346,7 +346,9 @@ STATIC void machine_hw_spi_transfer(mp_obj_base_t *self_in, size_t len, const ui
if (offset > 0) {
// wait for previously queued transaction
MP_THREAD_GIL_EXIT();
spi_device_get_trans_result(self->spi, &result, portMAX_DELAY);
MP_THREAD_GIL_ENTER();
}
// doesn't need ceil(); loop ends when bits_remaining is 0
@ -354,7 +356,9 @@ STATIC void machine_hw_spi_transfer(mp_obj_base_t *self_in, size_t len, const ui
}
// wait for last transaction
MP_THREAD_GIL_EXIT();
spi_device_get_trans_result(self->spi, &result, portMAX_DELAY);
MP_THREAD_GIL_ENTER();
spi_device_release_bus(self->spi);
}
}