Improve DMA UART with RTS/CTS on STM32
Posted: Sun Jan 01, 2023 11:04 pm
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
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