Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f95e765

Browse files
committed
nrf: don't block SPI transfer
Ideally we'd use something like #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.
1 parent b203314 commit f95e765

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/machine/machine_nrf52xxx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ func (spi *SPI) Tx(w, r []byte) error {
335335
// finished if the transfer is send-only (a common case).
336336
spi.Bus.TASKS_START.Set(1)
337337
for spi.Bus.EVENTS_END.Get() == 0 {
338+
gosched()
338339
}
339340
spi.Bus.EVENTS_END.Set(0)
340341
}

0 commit comments

Comments
 (0)