japaric / stm32f103xx-hal

HAL for the STM32F103xx family of microcontrollers
Apache License 2.0
115 stars 40 forks source link

Serial circular buffer force swap #87

Open Frans-Willem opened 6 years ago

Frans-Willem commented 6 years ago

I'm looking for a way to get the DMA to buffer anything coming in on the serial port, and then being able to pull in data whenever I'm ready. My idea was to put up a circular buffer with two decently sized buffers, then for example first let the DMA read into A, and when I'm ready, tell the DMA to start reading into B (even though it hasn't filled A yet) and report how much of A it has filled. I'll then take this data from A, do something with it, and when I'm ready, have the DMA swap again, even if it hasn't filled the buffer completely yet.

With the current API, this appears not to be possible, but I suspect the hardware should allow it. Would anyone have any ideas on how to implement this ?