Skip to content

Commit 5b65566

Browse files
jonathanhoggdpgeorge
authored andcommitted
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 micropython#7662.
1 parent a1dc727 commit 5b65566

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ports/esp32/machine_hw_spi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,19 @@ STATIC void machine_hw_spi_transfer(mp_obj_base_t *self_in, size_t len, const ui
346346

347347
if (offset > 0) {
348348
// wait for previously queued transaction
349+
MP_THREAD_GIL_EXIT();
349350
spi_device_get_trans_result(self->spi, &result, portMAX_DELAY);
351+
MP_THREAD_GIL_ENTER();
350352
}
351353

352354
// doesn't need ceil(); loop ends when bits_remaining is 0
353355
offset += transaction->length / 8;
354356
}
355357

356358
// wait for last transaction
359+
MP_THREAD_GIL_EXIT();
357360
spi_device_get_trans_result(self->spi, &result, portMAX_DELAY);
361+
MP_THREAD_GIL_ENTER();
358362
spi_device_release_bus(self->spi);
359363
}
360364
}

0 commit comments

Comments
 (0)