nrf: fix bug in SPI.Tx
There was what appears to be a race condition in the Tx function. While it would work fine in many cases, when there were interrupts (such as when using BLE), the function would just hang waiting for `EVENTS_READY` to arrive. I think what was happening was that the `spi.Bus.RXD.Get()` would start the next transfer, which would complete (and generate an event) before `EVENTS_READY` was reset to 0. The fix is easy: clear `EVENTS_READY` before doing something that can trigger an event. I believe I've seen this bug before on the PineTime but I couldn't find the issue back then.
Этот коммит содержится в:
родитель
9ed5eae6a9
коммит
169d5f17b8
1 изменённых файлов: 2 добавлений и 2 удалений
|
@ -443,13 +443,13 @@ func (spi SPI) Tx(w, r []byte) error {
|
||||||
spi.Bus.TXD.Set(uint32(b))
|
spi.Bus.TXD.Set(uint32(b))
|
||||||
for spi.Bus.EVENTS_READY.Get() == 0 {
|
for spi.Bus.EVENTS_READY.Get() == 0 {
|
||||||
}
|
}
|
||||||
_ = spi.Bus.RXD.Get()
|
|
||||||
spi.Bus.EVENTS_READY.Set(0)
|
spi.Bus.EVENTS_READY.Set(0)
|
||||||
|
_ = spi.Bus.RXD.Get()
|
||||||
}
|
}
|
||||||
for spi.Bus.EVENTS_READY.Get() == 0 {
|
for spi.Bus.EVENTS_READY.Get() == 0 {
|
||||||
}
|
}
|
||||||
_ = spi.Bus.RXD.Get()
|
|
||||||
spi.Bus.EVENTS_READY.Set(0)
|
spi.Bus.EVENTS_READY.Set(0)
|
||||||
|
_ = spi.Bus.RXD.Get()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// write/read
|
// write/read
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче