Skip to content

Commit f6115ff

Browse files
nordic-krchnordicjm
authored andcommitted
[nrf fromtree] drivers: serial: nrfx_uarte: Improve RX FIFO flush workaround
Add configurable magic byte instead of fixed 0xAA. In some cases, it is known that certain bytes are less likely in the transmission and picking specific magic byte may reduce probability of failure of detection of the correct amount of flushed data. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 7735302)
1 parent 76495df commit f6115ff

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

drivers/serial/Kconfig.nrfx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ config UART_ASYNC_TX_CACHE_SIZE
5757
in RAM, because EasyDMA in UARTE peripherals can only transfer data
5858
from RAM.
5959

60+
config UART_NRFX_UARTE_RX_FLUSH_MAGIC_BYTE
61+
hex "Byte used for RX FIFO flush workaround"
62+
default 0xAA
63+
range 0x00 0xFF
64+
help
65+
Byte used to fill the buffer before RX FIFO is flushed into it. Due to the
66+
HW anomaly a workaround need to be applied which checks if content of the
67+
buffer changed. There are cases when specific value of the magic byte is
68+
used if it is known that certain bytes are less likely to occur.
69+
6070
if HAS_HW_NRF_UART0 || HAS_HW_NRF_UARTE0
6171
nrfx_uart_num = 0
6272
rsource "Kconfig.nrfx_uart_instance"

drivers/serial/uart_nrfx_uarte.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ static void endrx_isr(const struct device *dev)
13981398
static uint8_t rx_flush(const struct device *dev, uint8_t *buf)
13991399
{
14001400
/* Flushing RX fifo requires buffer bigger than 4 bytes to empty fifo*/
1401-
static const uint8_t dirty = 0xAA;
1401+
static const uint8_t dirty = CONFIG_UART_NRFX_UARTE_RX_FLUSH_MAGIC_BYTE;
14021402
NRF_UARTE_Type *uarte = get_uarte_instance(dev);
14031403
const struct uarte_nrfx_config *config = dev->config;
14041404
uint32_t prev_rx_amount;

0 commit comments

Comments
 (0)