analogdevicesinc / no-OS

Software drivers in C for systems without an operating system
http://analogdevicesinc.github.io/no-OS/
Other
882 stars 1.63k forks source link

drivers: More driver fixes for offload_transfer size #2243

Closed ahaslam2 closed 1 week ago

ahaslam2 commented 2 weeks ago

There seems to have been some mixup between what "sample" means when using offload_transfer function. Drivers sometimes sending number of bytes, and sometimes sending number of chip samples to collect, when in reality The offload_transfer funtion parameters define the "sample" argument as "Number of time the messages will be transferred"

A bug were the spi_engine would trasfer less bytes than num_samples required, may have added to the mixup, making drivers ask for more messages to fill (and sometimes overrun) their data buffer.

Also, some chips collect one channel per offload transaction (ad400x, ad469x) while others collect multiple channels per offload transaction (ad4630x), perhaps ad713x?

ad400x (single channel, 32bit DMA) one message for single channel: total_offload_mesages = num_sampels

ad469x (16 channels, 32bit DMA) one message per channel: total_offload_mesages = num_sampels * num_channel_active.

ad4630x (2 channel, 64bit DMA) one message for 2 channels: total_offload_mesages = num_sampels;

ad713x (4 channel, 128bit DMA) one message for 4 channels: total_offload_mesages = num_sampels; (not tested in real hw!)

PR Type

PR Checklist

ahaslam2 commented 2 weeks ago

if someone could test this with ad713x it would be nice, since i dont have the HW. Not sure what spi engine does if less than 4 channels are active in ad713x? since the DMA is 128 bytes large for this part (4 words) if, for example, 3 channels are active the last word contains 0 and can be discarded?