Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UART DMA improvements and refactoring #328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robamu
Copy link
Contributor

@robamu robamu commented Dec 29, 2022

Some preparation to allow variable sized DMA transfers as specified in #325 . I did not have to change anything in the serial_dma example, but this is unfortunately still a breaking change because of the DMA transfer wrappers which are now returned for DMA transactions. I re-tested the serial_dma example on a STM32F3-Disco. In the process of reading a it about DMA, I also saw that the datasheet recommends checking the UART TC flag for transmission completeness. I am not sure whether this was not done on purpose or simply overlooked, but the changes ensure the TC flag is now checked as well.

Copied from CHANGELOG:

Changed

  • serial: The DMA functions write_all and read_exact now returns
    the wrapper structs SerialDmaTx and SerialDmaRx instead of the direct
    DMA transfer struct. These allow checking the USART ISR events
    with is_event_triggered as well.

Fixed

  • serial: The previous DMA write_all implementation did use the DMA transfer completion
    event to check for transfer completion, but MCU datasheet specifies that the TC
    flag of the USART peripheral should be checked for transfer completion to avoid
    corruption of the last transfer. This is now done by the new SerialDmaTx wrapper.

Added

  • serial: Public is_event_triggered method which allows to check for events
    given an event and a USART reference.

If you consider this mergeable (with adaptions/changes), I also have some other branches which build on top of these changes, for example the splitting of RX and TX events. :)

@robamu
Copy link
Contributor Author

robamu commented Mar 23, 2024

Looking at this again as I am updating another application. This probably needs to be re-worked now that the split has been removed. Then again, using DMA requires TX and RX to be different entities.

1. Wrap the TX transfer struct in a helper type which also
   checks whether the TC IRQ flag was set. This is strongly
   recommended in the datasheet
2. Basic refactoring to prepare allowing checks of events
   for both the split Tx and Rx handle
@robamu robamu force-pushed the dma_improvements_and_refactoring branch from ddd1119 to cc6fc30 Compare March 23, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant