Commit graph

12 commits

Author SHA1 Message Date
Ruben Völl
2c82681bec driver: uart: emul: Add support for async UART API
As it is up to a driver implementation if a partial filled buffer is
released, this behavior can be configured during runtime to allow testing
for this edge case.

Signed-off-by: Ruben Völl <ruben.voell@grandcentrix.net>
2024-06-11 20:05:24 +03:00
Ruben Völl
e5dd2376b3 drivers: uart: emul: Remove uart_emul_work struct
This structure is bad style and not needed. Instead get the surrounding
`struct uart_emul_data` with `CONTAINER_OF()` directly.

Signed-off-by: Ruben Völl <ruben.voell@grandcentrix.net>
2024-06-11 20:05:24 +03:00
Andreas Anderberg
2b43c3b4a3 drivers: serial: emul: Make fifo_read() respect size
uart_emul_fifo_read() didn't regard the size arg, hence if the RX ring
buffer contained more data than the size of the input rx_data buffer
size, this could result in buffer overflow. This becomes more obvious
when configuring device tree property latch-buffer-size > 1.

Signed-off-by: Andreas Anderberg <andreas.anderberg@u-blox.com>
2024-02-07 12:52:43 -06:00
Bjarki Arge Andreasen
27dfdd737e drivers: serial: emul: Make UART FIFO size realistic
Real UARTs usually write 1 to a few bytes at a time through a
latch buffer. Add latch buffer property to binding for
uart_emul and limit fifo_read and fifo_fill to not exceed the
latch buffer.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-11-03 11:44:12 +01:00
Bjarki Arge Andreasen
b74aacb4e2 drivers: serial: emul: Use local work queue
Define local thread to emulate different thread priorities.

A UART driver may call back from within a thread with higher
or lower priority than the thread calling the UART API. This
can hide potential concurrency issues, especially if the
thread priorities are the same, or even using the same thread
in case the system work queue.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-11-03 11:44:12 +01:00
Nick Kraus
0f50df41f1 drivers: uart_emul: Add Emulated Errors
Allows test code to set UART errors, for driver code wanting
to test proper error handling.

Signed-off-by: Nick Kraus <nick@nckraus.com>
2023-10-20 15:10:27 +02:00
Nick Kraus
aeb85db627 drivers: uart_emul: Add IRQ Based TX
Added an interrupt based transmit routine and interrupt based
uart_emul tests.

Signed-off-by: Nick Kraus <nick@nckraus.com>
2023-10-20 15:10:27 +02:00
Christopher Friedt
99ab1ab06c drivers: serial: uart_emul: make api implementation static
Keep uart API implementation of the uart_emul driver "private"
by adding the static keyword.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-10-03 14:58:19 -04:00
Christopher Friedt
9d79728c48 drivers: serial: uart_emul: support interrupt-driven receive
Previously, the uart_emul device did not support interrupt-driven
receive, which is an unwritten requirement for hooking up a uart to
the Zephyr console driver.

The console is a fairly high-traffic subsystem, and we should be able
to perform more extensive testing on it, aside from maching twister
output against a regular expression. With this change, we can use
the emulation uart within the body of a ZTest.

Testing Done:
```shell
west build -p auto -b qemu_riscv64 -t run tests/drivers/console_switching
...
*** Booting Zephyr OS build zephyr-v3.4.0-4277-gae0d63471be1 ***
Running TESTSUITE console_switching
===================================================================
START - test_read
read "Hello, uart_emul0!" from uart_emul0
read "Hello, uart_emul1!" from uart_emul1
read "Hello, uart_emul0!" from uart_emul0
read "Hello, uart_emul1!" from uart_emul1
 PASS - test_read in 0.005 seconds
===================================================================
START - test_write
wrote "Hello, uart_emul0!" to uart_emul0
wrote "Hello, uart_emul1!" to uart_emul1
wrote "Hello, uart_emul0!" to uart_emul0
wrote "Hello, uart_emul1!" to uart_emul1
 PASS - test_write in 0.003 seconds
===================================================================
TESTSUITE console_switching succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [console_switching]: pass = 2, fail = 0, skip = 0...
 - PASS - [console_switching.test_read] duration = 0.005 seconds
 - PASS - [console_switching.test_write] duration = 0.003 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL
```

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-10-03 14:58:19 -04:00
Daniel Leung
343772213a serial: CONFIG_UART_USE_RUNTIME_CONFIGURE on API for cfg funcs
This adds the CONFIG_UART_USE_RUNTIME_CONFIGURE guard to
disable the API function pointers if the kconfig is not enabled.
Both .configure and .config_get should only be usable if runtime
(re-)configuration of UART is needed.

Ifdef guards are added to drivers previously lacking this guard.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-21 17:46:12 -04:00
Gerard Marull-Paretas
1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Fabian Blatz
6180f96799 serial: Add driver for emulated UART
The emulated UART controller will aid in automated
integration testing.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2023-03-27 09:50:44 +02:00