Improve DMA UART with RTS/CTS on STM32

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
mringwal
Posts: 6
Joined: Sun Jan 01, 2023 10:52 pm
Has thanked: 1 time
Been thanked: 1 time

Improve DMA UART with RTS/CTS on STM32

Post by mringwal »

Hi there

I'm working on a port of our BTstack Bluetooth Host stack for ChibiOS. BTstack's transport layer requests data from the UART in blocks and uses CTS/RTS to avoid loosing bytes. The trunk ChibiOS/HAL implementation in uart_enter_rx_idle_loop() unconditionally restarts the UART DMA leading to a loss of bytes.

I'd like to propose to change the behaviour of uart_enter_rx_idle_loop() for the case when RTS is enabled and there's no byte callback registered.

The attached patch changes this to restart DMA only if a) RTS is not active, or, b) a single byte callback is defined. With the patch, DMA is not restarted and no byte gets lost with RTS. Tested on an F4 Discovery board.

Best regards
Matthias
Attachments
stm32-uart-rts.patch.zip
(779 Bytes) Downloaded 614 times
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Improve DMA UART with RTS/CTS on STM32

Post by Giovanni »

Hi,

Added to the review board: https://review.chibios.org/

Giovanni
mringwal
Posts: 6
Joined: Sun Jan 01, 2023 10:52 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Improve DMA UART with RTS/CTS on STM32

Post by mringwal »

Fixed patch to match description. Sorry.
Attachments
stm32-uart-rts.patch.zip
(783 Bytes) Downloaded 601 times
Post Reply