-
-
Notifications
You must be signed in to change notification settings - Fork 40
fix: SPI: remove holes between transfer() #288
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
base: main
Are you sure you want to change the base?
Conversation
|
Does this actually fix the issue? The lock just prevents other callers from accessing the device, and |
|
As @KurtE's issue pointed out this seems to be an open issue on Zephyr: zephyrproject-rtos/zephyr#73930 Has anyone looked at that or at @KurtE's solution? Not sure that is really going to resolve the issue |
|
Thanks @facchinm @iabdalkader @mjs513. @facchinm - which boards did you try this on? As I mentioned in the issue #145, in the past I have tried this approach to blanketly turn on the HOLD_ON_CS flag or As @mjs513 mentioned - there are some Zephyr open issues on some of this, that appear to have several interrelated issues and or things to try, like: FIFO - is it enabled? Does it work. Is DMA enabled? Async Transfer - appears to speed things up, but ran into limits, like there may be a MAX number of bytes you can do And my guess is, it may be different for each different processor. But keeping my fingers crossed that this at least improves it. Thanks |
|
Quick update: I tried out my sort of simple ST7796 driver on Q which does some hacks, to get hold of the underlying SPI And then does several fillRects with different colors and prints out how long it took... Note: the fill code, uses temporary buffer that it fills with color and iterates calling spi_transcive.... With the beginTransaction code change, this code now appears to hang. And using SPI->transfer16... (I could try again, but that was potentially even slower)... And maybe has other issues. EDIT: In case anyone wishes to play along. |
|
@KurtE Thanks for taking the time to test this. Could you please provide a brief summary? Does the change in this PR work or not? If it works, does it improve the performance? About your custom code, assuming you're using a dev core, not a release, you could just add another overload to the SPI library, maybe something like: void transfer(void *buf, size_t count, size_t datasize);
void arduino::ZephyrSPI::transfer(void *buf, size_t count, datasize) {
int ret = transfer(buf, count, datasize==8 ? &config : &config16);
(void)ret;
}This should let you use our library to rule out any issues with your code. We could probably commit that, or later add data size to settings in the API. |
Currently it hangs with my own code. Now if I call with only SPI.transfer call, it did not hang, With the version I have that runs, using the SPI.transfer(buffer, size); Where I use temporary buffer, copy in May try some other simpler sketch to get more details
But could do with released code as changes is only in SPI library.
Could, personally I really really wish there was another API, that allows for write only and/or two buffers, write and read (can be NULL), that allows you to for example output directly out of a buffer without having it's contents overwritten. Also still wonder about hardware. Fifo? |
@KurtE Thanks for confirming. This was expected as the problem, as you and others noted, seems to be with inter-byte gaps, not with whole transfers. This change might still be helpful if you're transferring a single byte at a time, though I'm not sure if it would make sense to hold CS in that case.
I agree, the API is lacking, to say the least, but we can try to improve it. We could start by adding a data size arg somewhere. |
|
@iabdalkader @mjs513 @facchinm @pillo79 - Wondering if we should continue this here, or back to our original Note: I am mainly throwing darts here, and it has been a while since I really played with trying to improve the SPI speed. There are probably several different things that should be looked at and steps to resolve them, including: Are we properly configuring the SPI ports at the hardware level. I believe that there have been changes made in Zephyr over For those processors with FIFO on SPI, are they properly configured and software work with it? I wish there was an API part of the SPI object that returns zephyr specific information, like handle to the underlying Zephyr SPI object. Which allows apps/libraries to easier directly call the zephyr methods. Transfer APIs: allow you to set word size, write only transfers, maybe Async... Fine tunning of SPI and drivers. At least earlier with these drivers, I was finding that for things like Earlier I found that in the case here where we output <8 bit> <16 bit> <16 bit> <8 bit> <16 bit> <16 bit><8 bit> |
Fixes #145