From f95e7653e2ae9ba75f12e7000433ddc61acb685f Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 16 Nov 2025 08:49:46 +0100 Subject: [PATCH] nrf: don't block SPI transfer Ideally we'd use something like https://github.com/tinygo-org/tinygo/pull/5016 but that's a bit more involved. As a quick improvement, call gosched() instead. Example where I use this: a custom WS2812 driver that uses SPI to transfer the data. It's useful to be able to switch back to the main goroutine during the transfer to render the next LED update. --- src/machine/machine_nrf52xxx.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/machine/machine_nrf52xxx.go b/src/machine/machine_nrf52xxx.go index 4948e134a2..90a1a7fbf5 100644 --- a/src/machine/machine_nrf52xxx.go +++ b/src/machine/machine_nrf52xxx.go @@ -335,6 +335,7 @@ func (spi *SPI) Tx(w, r []byte) error { // finished if the transfer is send-only (a common case). spi.Bus.TASKS_START.Set(1) for spi.Bus.EVENTS_END.Get() == 0 { + gosched() } spi.Bus.EVENTS_END.Set(0) }