Skip to content

More granular circular DMA #242

@rudihorn

Description

@rudihorn

Currently circular DMA is implemented in a way where the circular buffer has two buffer halves, and then once one buffer half has been filled the buffer half can be read while the next one is filled. If one would like to use a larger buffer e.g. 256 bytes, this means that to use it "properly" one would need to wait until 128 bytes have been filled, making this approach only useful for bulk transfers.

There is another approach, which is to use the DMA_CNDTRx register (STM32 reference manual 13.4.4) to determine the number of bytes the DMA still has to write until the end of the buffer and use it to calculate the number of bytes already transferred into the buffer. Specifically something along the lines of cndtr_last - cndtr (and add the buffer length if negative) should return the number of bytes in the buffer.

I would suggest renaming the current CircBuffer to CircBufferHalves and then implementing new CircBuffer behaviour which provides functions has_data length dequeue or similar.

If something like this makes sense I can try putting together a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions