pico-extras
pico-extras copied to clipboard
Return the number of blocks completely read when querying read completion
Especially when doing a longer async transfer, it can be useful to start reading it before it has finished.
This change allows the user to read the number of blocks already read by checking how far the chain DMA has got.
It's a breaking change, but I don't think there are many users yet, and you can just use NULL if you don't care.
nice, yes i had planned such a feature! will take a look
I've just realised that sd_readblocks_scatter_async is an externally exposed function, and if you use it then this won't work.
It should record the control words pointer passed into scatter_async and compare with that. I'll fix that and update the PR, hopefully today.
I've just realised that
sd_readblocks_scatter_asyncis an externally exposed function, and if you use it then this won't work.It should record the control words pointer passed into scatter_async and compare with that. I'll fix that and update the PR, hopefully today.
yeah, the API is obviously not currenlty ideal :-)
I'm going to switch to use the scatter read function directly in my video code.
So, really I just want a call to get the number of control words that have been consumed. But that's not a particularly user friendly interface if you are using the normal methods.
Options:
- Keep this as is, document it as not working if you call scatter directly.
- Record the chain control pointer used for the last read, if it matches then do as at present. If it doesn't, return the number of chain entries consumed, as the caller might be doing something different that 2 chain entries per block.
- Always return the number of chain entries consumed, document that when using the friendly read functions the number of sectors completed is equal to half the value returned.