Skip to content

Commit cd9343d

Browse files
nordic-krchkl-cruz
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 <[email protected]>
1 parent 4d3628d commit cd9343d

File tree

3 files changed

+973
-88
lines changed

3 files changed

+973
-88
lines changed

drivers/serial/Kconfig.nrfx

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

82+
config UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER
83+
bool "Use TIMER to count RX bytes"
84+
depends on UART_ASYNC_API
85+
depends on UART_NRFX_UARTE_LEGACY_SHIM
86+
depends on !ARCH_POSIX # Mode not supported on BSIM target
87+
select NRFX_GPPI
88+
89+
config UART_NRFX_UARTE_BOUNCE_BUF_LEN
90+
int "RX bounce buffer size"
91+
depends on UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER
92+
default 256
93+
range 64 1024
94+
help
95+
Buffer is used when workaround with bounce buffers is applied
96+
97+
config UART_NRFX_UARTE_BOUNCE_BUF_SWAP_LATENCY
98+
int "RX bounce buffer swap latency (in microseconds)"
99+
depends on UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER
100+
default 300
101+
help
102+
Option decides how long before current bounce buffer is filled driver
103+
attempts to swap the buffer. It must be long enough to ensure that
104+
space following the buffer is not overwritten. Too high value results
105+
in more frequent buffer swaps so it impacts performance. Setting should
106+
take into account potential interrupt handling latency.
107+
82108
config UART_NRFX_UARTE_DIRECT_ISR
83109
bool "Use direct ISR"
84110

drivers/serial/Kconfig.nrfx_uart_instance

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

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

0 commit comments

Comments
 (0)