-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nRF52: set SPI TX/RX lengths even data is empty. Fixes #3868 #3877
Conversation
src/machine/machine_nrf52xxx.go
Outdated
@@ -296,6 +296,8 @@ func (spi SPI) Tx(w, r []byte) error { | |||
} | |||
spi.Bus.RXD.MAXCNT.Set(n) | |||
r = r[n:] | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if perhaps a better syntax for this entire section might be something like this:
nr := uint32(len(r))
if nr > 255 {
nr = 255
}
if nr != 0 {
spi.Bus.RXD.PTR.Set(uint32(uintptr(unsafe.Pointer(&r[0]))))
r = r[nr:]
}
spi.Bus.RXD.MAXCNT.Set(nr)
nw := uint32(len(w))
if nw > 255 {
nw = 255
}
if nw != 0 {
spi.Bus.TXD.PTR.Set(uint32(uintptr(unsafe.Pointer(&w[0]))))
w = w[nw:]
}
spi.Bus.TXD.MAXCNT.Set(nw)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the way you made this change @perttierkkila thanks!
I will squash/merge this once it passes all CI test.
Thank you! I was a bit shy at first to do the change properly and tried to keep changes in minimum and refactored it now as it should be. It reduces one branching when no data :) |
Now going to squash/merge. Thanks again @perttierkkila |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, probably a bug I originally introduced. In any case, thanks for fixing it :D
No description provided.