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 <krzysztof.chruscinski@nordicsemi.no>
123 lines
4.3 KiB
Plaintext
123 lines
4.3 KiB
Plaintext
#nRF UART(E) instance configuration
|
|
|
|
# Copyright (c) 2023 Nordic Semiconductor ASA
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
config UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
|
|
bool "Interrupt support on port $(nrfx_uart_num)"
|
|
depends on UART_INTERRUPT_DRIVEN
|
|
select UART_ASYNC_TO_INT_DRIVEN_API if !UART_NRFX_UARTE_LEGACY_SHIM
|
|
default y
|
|
help
|
|
This option enables UART interrupt support on port $(nrfx_uart_num).
|
|
|
|
config UART_$(nrfx_uart_num)_ASYNC
|
|
bool "Asynchronous API support on port $(nrfx_uart_num)"
|
|
depends on UART_ASYNC_API && !UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
|
|
default y
|
|
help
|
|
This option enables UART Asynchronous API support on port $(nrfx_uart_num).
|
|
|
|
config UART_$(nrfx_uart_num)_ENHANCED_POLL_OUT
|
|
bool "Efficient poll out on port $(nrfx_uart_num)"
|
|
depends on !$(dt_nodelabel_has_prop,uart$(nrfx_uart_num),short-endtx-stoptx)
|
|
default y
|
|
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
|
|
depends on HAS_HW_NRF_PPI || HAS_HW_NRF_DPPIC
|
|
select NRFX_PPI if HAS_HW_NRF_PPI
|
|
select NRFX_DPPI if HAS_HW_NRF_DPPIC
|
|
help
|
|
When enabled, polling out does not trigger interrupt which stops TX.
|
|
Feature uses a PPI channel.
|
|
|
|
config NRFX_UARTE$(nrfx_uart_num)
|
|
def_bool y if HAS_HW_NRF_UARTE$(nrfx_uart_num) && !UART_NRFX_UARTE_LEGACY_SHIM
|
|
|
|
config UART_$(nrfx_uart_num)_NRF_PARITY_BIT
|
|
bool "Parity bit"
|
|
help
|
|
Enable parity bit.
|
|
|
|
config UART_$(nrfx_uart_num)_NRF_TX_BUFFER_SIZE
|
|
int "Size of RAM buffer"
|
|
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
|
|
depends on UART_NRFX_UARTE_LEGACY_SHIM
|
|
range 1 $(UINT16_MAX)
|
|
default 32
|
|
help
|
|
Size of the transmit buffer for API function: fifo_fill.
|
|
This value is limited by range of TXD.MAXCNT register for
|
|
particular SoC.
|
|
|
|
config UART_$(nrfx_uart_num)_NRF_HW_ASYNC
|
|
bool "Use hardware RX byte counting"
|
|
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
|
|
depends on UART_ASYNC_API
|
|
depends on UART_NRFX_UARTE_LEGACY_SHIM
|
|
depends on HAS_HW_NRF_PPI || HAS_HW_NRF_DPPIC
|
|
select NRFX_PPI if HAS_HW_NRF_PPI
|
|
select NRFX_DPPI if HAS_HW_NRF_DPPIC
|
|
help
|
|
If default driver uses interrupts to count incoming bytes, it is possible
|
|
that with higher speeds and/or high cpu load some data can be lost.
|
|
It is recommended to use hardware byte counting in such scenarios.
|
|
Hardware RX byte counting requires timer instance and one PPI channel.
|
|
|
|
config UART_$(nrfx_uart_num)_NRF_ASYNC_LOW_POWER
|
|
bool "Low power mode"
|
|
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
|
|
depends on UART_ASYNC_API
|
|
depends on UART_NRFX_UARTE_LEGACY_SHIM
|
|
default y
|
|
help
|
|
When enabled, UARTE is enabled before each TX or RX usage and disabled
|
|
when not used. Disabling UARTE while in idle allows to achieve lowest
|
|
power consumption. It is only feasible if receiver is not always on.
|
|
|
|
config UART_$(nrfx_uart_num)_NRF_HW_ASYNC_TIMER
|
|
int "Timer instance"
|
|
depends on UART_$(nrfx_uart_num)_NRF_HW_ASYNC
|
|
|
|
config UART_$(nrfx_uart_num)_HAS_RX_CACHE_SECTION
|
|
def_bool $(dt_nodelabel_has_prop,uart$(nrfx_uart_num),memory-regions)
|
|
imply NRFX_UARTE_CONFIG_RX_CACHE_ENABLED
|
|
help
|
|
This helper symbol indicates the existence of a linker section which
|
|
can be dedicated to an RX cache buffer.
|
|
|
|
config UART_$(nrfx_uart_num)_TX_CACHE_SIZE
|
|
int "TX cache buffer size"
|
|
depends on !UART_NRFX_UARTE_LEGACY_SHIM
|
|
default 8
|
|
help
|
|
For UARTE, TX cache buffer is used when provided TX buffer is not located
|
|
in memory which can be used by the EasyDMA.
|
|
|
|
config UART_$(nrfx_uart_num)_RX_CACHE_SIZE
|
|
int "RX cache buffer size"
|
|
depends on !UART_NRFX_UARTE_LEGACY_SHIM
|
|
default 32 if UART_$(nrfx_uart_num)_HAS_RX_CACHE_SECTION
|
|
default 5
|
|
range 5 $(UINT8_MAX)
|
|
help
|
|
For UARTE, RX cache buffer is used when provided RX buffer is not located
|
|
in memory which can be used by the EasyDMA. It is also used to store
|
|
flushed data.
|
|
|
|
config UART_$(nrfx_uart_num)_A2I_RX_SIZE
|
|
depends on !UART_NRFX_UARTE_LEGACY_SHIM
|
|
int "Asynchronous to interrupt driven adaptation layer RX buffer size"
|
|
default 64 if UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
|
|
default 0
|
|
help
|
|
Amount of space dedicated for RX. It is divided into chunks with some
|
|
amount of that space used for control data.
|
|
|
|
config UART_$(nrfx_uart_num)_A2I_RX_BUF_COUNT
|
|
depends on !UART_NRFX_UARTE_LEGACY_SHIM
|
|
int "Asynchronous to interrupt driven adaptation layer RX buffer count"
|
|
default 8 if UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
|
|
default 0
|
|
help
|
|
Number of chunks into RX space is divided.
|