-
Notifications
You must be signed in to change notification settings - Fork 119
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
SPI DMA complete callback #225
Comments
SPI.transfer(txbuf, rxbuf, count, block=false) provides an asynchronous write. Could then use the existing SPI.waitForTransfer() immediately before starting a new transfer or other transaction — this will only block if the current transfer is still in progress. If you need non-blocking, rather than a nested callback (which is probably just going to set a variable that you poll — and make sure it’s volatile), could be easier to add a “getter function” that returns the state of the SPI.dma_busy member (which will likely compile down to a direct access)…or, quick and dirty…could move that member to the “public” section…I know it’s bad form but is anyone really looking? |
My goal was to set a FreeRTOS Semaphore on completion. Polling the volatile flag could work, but its not very elegant. Perhaps I would be better off just forking for my specific use case. |
Would that be OK? It’s a pretty esoteric case and the first time it’s come up. I’d look at a PR if it’s something pretty minimal change though. |
Hello Everyone, I actually implemented this exact feature for the same reason @Timvrakas mentioned. The current implementation is technically only asynchronous for the transfer, and poling for completion sub optimal, especially if you are going to the trouble of doing a dma to save processor time to begin with. There is alot of performance that can be gained calling a function callback on dma completion as iv seen on my project with an oscilloscope. I will post this pr soon, and it also fixes #230 as well. |
Ok pull request posted :-) |
Sorry, found this issue again during a github sweep. I think the transfer bugs (along with large DMA transfers) were both addressed in the 1.6.2 release a while back. If there’s a PR with just the callback additions, I could merge that. |
I'd like to use DMA SPI transfers asynchronously. I think I can add a callback to
SPIClass
that would be called when the transfer is complete. It would involve a function pointer inSPIClass
, a setter, and a line added toSPIClass::dmaCallback()
that evaluated the callback for validity, and if valid calls it. Should I pursue this and submit a PR?Tim
The text was updated successfully, but these errors were encountered: