Skip to content

Commit 7a30a6c

Browse files
committed
[nrf fromlist] 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. Upstream PR #: 92767 Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent cc0ffde commit 7a30a6c

File tree

3 files changed

+942
-93
lines changed

3 files changed

+942
-93
lines changed

drivers/serial/Kconfig.nrfx

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

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

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)