mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +00:00
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.
This commit is contained in:
committed by
Ron Evans
parent
b203314c2f
commit
5690204224
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user