pico-extras icon indicating copy to clipboard operation
pico-extras copied to clipboard

Return the number of blocks completely read when querying read completion

Open MichaelBell opened this issue 4 years ago • 4 comments

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.

MichaelBell avatar Feb 27 '21 22:02 MichaelBell

nice, yes i had planned such a feature! will take a look

kilograham avatar Feb 27 '21 23:02 kilograham

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.

MichaelBell avatar Mar 01 '21 15:03 MichaelBell

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.

yeah, the API is obviously not currenlty ideal :-)

kilograham avatar Mar 01 '21 15:03 kilograham

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:

  1. Keep this as is, document it as not working if you call scatter directly.
  2. 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.
  3. 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.

MichaelBell avatar Mar 01 '21 18:03 MichaelBell