Skip to content

Commit 22c4f08

Browse files
nordic-krchnordicjm
authored andcommitted
[nrf fromtree] drivers: serial: nrfx_uarte: Rework driver to support new features
Rework driver to support new way of asynchronous RX handling. Previously RX was handled in two modes: using RXDRDY interrupt for byte counting or TIMER + PPI. Both modes had flaws. RXDRDY interrupt mode could miscalculated amount of received bytes when interrupt was not handled on time. Data was not lost but was not reported on time that could lead to issues. PPI+TIMER mode requires additional resources thus it was not the default mode. Often user was not aware of that option and was expiriencing driver RX faults. New RX mode is switching buffers when there is new data (RXDRDY event not set for given amount of time). It does not require additional resources to get precise byte counting. Additionally, this is in line with new UARTE feature (RX frame timeout) which is present in nRF54X devices. The behavior of the driver is the same for legacy devices and new one. For legacy devices k_timer periodic interrupts are used to check if there are any new bytes and it is not needed when RX frame timeout is present. Improved RX mode is enabled by default (CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) but legacy modes are still available though not recommended to be used. Note that new RX mode (CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) behaves a bit different because timeout always triggers switch of buffers which means that there will be no UART_RX_RDY events with non-zero offset. It also means that every UART_RX_RDY will be followed by UART_RX_BUF_RELEASED. After rework, driver is recommended to be used for all platforms as it performs much better and takes much less code than the second UART shim available for Nordic devices. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 399a235)
1 parent d62a69c commit 22c4f08

File tree

3 files changed

+369
-219
lines changed

3 files changed

+369
-219
lines changed

drivers/serial/Kconfig.nrfx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ config UART_NRFX_UARTE_LEGACY_SHIM
3737
# New shim takes more ROM. Until it is fixed use legacy shim.
3838
default y
3939

40+
config UART_NRFX_UARTE_ENHANCED_RX
41+
bool "Enhanced RX handling"
42+
depends on UART_ASYNC_API
43+
depends on UART_NRFX_UARTE_LEGACY_SHIM
44+
default y if !(UART_0_NRF_HW_ASYNC || UART_1_NRF_HW_ASYNC || UART_2_NRF_HW_ASYNC)
45+
help
46+
Enable RX handling mode which is switching buffers on timeout. This is an
47+
enhancement compared to other two modes (default and hardware assisted).
48+
Default mode could miscount bytes when interrupt was not handled on time
49+
and hardware assisted required TIMER peripheral instance and PPI channel
50+
for accurate byte counting.
51+
4052
config UART_ASYNC_TX_CACHE_SIZE
4153
int "TX cache buffer size"
4254
depends on UART_ASYNC_API

drivers/serial/Kconfig.nrfx_uart_instance

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ config UART_$(nrfx_uart_num)_NRF_ASYNC_LOW_POWER
6868
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
6969
depends on UART_ASYNC_API
7070
depends on UART_NRFX_UARTE_LEGACY_SHIM
71+
default y
7172
help
7273
When enabled, UARTE is enabled before each TX or RX usage and disabled
7374
when not used. Disabling UARTE while in idle allows to achieve lowest

0 commit comments

Comments
 (0)