Skip to content

Commit f1f0b03

Browse files
nordic-krchjhedberg
authored andcommitted
drivers: serial: nrfx_uarte: Add mode with TIMER byte counting
Add mode to be used on UARTE with frame timeout which is using a bounce buffers and TIMER to count bytes. This mode shall be used to reliably receive data without HWFC as frame timeout approach is not 100% reliable because it can loose or corrupt a byte when new byte arrives after frame timeout is detected but before it is fully handled. This mode is similar to the one enabled with CONFIG_UART_x_NRF_HW_ASYNC but additional bounce buffers are used and UARTE is receiving data to internal buffers and copies data to the user buffer. Legacy apporach cannot be used because in new SoC DMA attempts to copy data in words so when byte is received it stays in the DMA internal buffer until 4 bytes are received or end of transfer happens then internal DMA buffer is flushed. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent 9ae8c4e commit f1f0b03

File tree

3 files changed

+972
-88
lines changed

3 files changed

+972
-88
lines changed

drivers/serial/Kconfig.nrfx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ config UART_ASYNC_TX_CACHE_SIZE
5555
in RAM, because EasyDMA in UARTE peripherals can only transfer data
5656
from RAM.
5757

58+
config UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER
59+
bool "Use TIMER to count RX bytes"
60+
depends on UART_ASYNC_API
61+
depends on UART_NRFX_UARTE_LEGACY_SHIM
62+
depends on !ARCH_POSIX # Mode not supported on BSIM target
63+
select NRFX_GPPI
64+
65+
config UART_NRFX_UARTE_BOUNCE_BUF_LEN
66+
int "RX bounce buffer size"
67+
depends on UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER
68+
default 256
69+
range 64 1024
70+
help
71+
Buffer is used when workaround with bounce buffers is applied
72+
73+
config UART_NRFX_UARTE_BOUNCE_BUF_SWAP_LATENCY
74+
int "RX bounce buffer swap latency (in microseconds)"
75+
depends on UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER
76+
default 300
77+
help
78+
Option decides how long before current bounce buffer is filled driver
79+
attempts to swap the buffer. It must be long enough to ensure that
80+
space following the buffer is not overwritten. Too high value results
81+
in more frequent buffer swaps so it impacts performance. Setting should
82+
take into account potential interrupt handling latency.
83+
5884
config UART_NRFX_UARTE_DIRECT_ISR
5985
bool "Use direct ISR"
6086
default y if !MULTITHREADING

drivers/serial/Kconfig.nrfx_uart_instance

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ config UART_$(nrfx_uart_num)_ASYNC
1717
help
1818
This option enables UART Asynchronous API support on port $(nrfx_uart_num).
1919

20+
config UART_$(nrfx_uart_num)_COUNT_BYTES_WITH_TIMER
21+
bool
22+
depends on $(dt_nodelabel_has_prop,uart$(nrfx_uart_num),timer)
23+
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
24+
default y
25+
imply UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER
26+
2027
config UART_$(nrfx_uart_num)_ENHANCED_POLL_OUT
2128
bool "Efficient poll out on port $(nrfx_uart_num)"
2229
depends on !$(dt_nodelabel_bool_prop,uart$(nrfx_uart_num),endtx-stoptx-supported)

0 commit comments

Comments
 (0)