-
Notifications
You must be signed in to change notification settings - Fork 928
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
atsamd5x: improve SPI #1453
atsamd5x: improve SPI #1453
Conversation
This PR seems to be working fine, but the following problems may remain
|
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.
The code looks reasonable, but I haven't tested it.
I was able to get a few NG examples. So far, the following rules appear to be in existence.
request : ok-1:
ok-2: (If the amount of response is about 1KB, sometimes there are invalid bytes in the response)
ng-1:
ng-2:
ng-3:
ng-4:
|
Reproduce the following combinations.
|
It seems that my SPI settings were incorrect. |
// read to clear RXC register | ||
for spi.Bus.INTFLAG.HasBits(sam.SERCOM_SPIM_INTFLAG_RXC) { | ||
spi.Bus.DATA.Get() | ||
} |
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.
This process is necessary because other functions are looking at RXC.
For example, if RXC is set to 1 at the time of the SPI.Transfer() call, the wait will fail.
I rebase the SPI source code because I think it is OK. old : 42088f9 new txrx : 15d8ef3 new tx : 15d8ef3 new rx : 15d8ef3 test code: package main
// This is the most minimal blinky example and should run almost everywhere.
import (
"machine"
"time"
)
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
spi := machine.SPI0
spi.Configure(machine.SPIConfig{
SCK: machine.SPI0_SCK_PIN,
SDO: machine.SPI0_SDO_PIN,
SDI: machine.SPI0_SDI_PIN,
Frequency: 48000000,
})
txbuf := make([]byte, 64)
rxbuf := make([]byte, 64)
for i := range txbuf {
txbuf[i] = byte(i)
rxbuf[i] = byte(i)
}
for {
led.Toggle()
time.Sleep(time.Millisecond * 500)
if true {
spi.Tx(txbuf, rxbuf)
}
if false {
//spi.Tx(txbuf, nil)
spi.Tx(nil, rxbuf)
}
}
} |
I made a mistake in rebasing, so I rebased it again. |
Thank you very much again for this exceptionally well documented PR. Now merging. |
I made it faster by rewriting SPI.Tx().
Originally, there was a gap of about 400ns per byte, but this is a significant improvement.
After this PR is merged, drivers/ili9341 should be able to simplify it.
tinygo-org/drivers#208
old: 6ab0106

new txrx():

new tx():

new rx():
