Skip to content

Commit

Permalink
tests: drivers: uart: Add test for async API using two instance
Browse files Browse the repository at this point in the history
Add test which is using two independent UART devices. Validate behavior of
asynchronous API.

Signed-off-by: Krzysztof Chruściński <[email protected]>
  • Loading branch information
nordic-krch committed Sep 19, 2024
1 parent fd5ecef commit b9f3391
Show file tree
Hide file tree
Showing 8 changed files with 843 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/drivers/uart/uart_async_dual/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(uart_async_dual)

target_sources(app PRIVATE src/main.c)
15 changes: 15 additions & 0 deletions tests/drivers/uart/uart_async_dual/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config UART_ASYNC_DUAL_TEST_TIMEOUT
int "Single test case length (in milliseconds)"
# For the simulated devices, which are run by default in CI, we set it to less to not spend too
# much CI time
default 500 if SOC_SERIES_BSIM_NRFXX
default 3000
help
For how many loops will the stress test run. The higher this number the longer the
test and therefore the higher likelihood an unlikely race/event will be triggered.

# Include Zephyr's Kconfig
source "Kconfig"
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* SPDX-License-Identifier: Apache-2.0 */

&pinctrl {
uart134_alt_default: uart134_alt_default {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 6)>;
bias-pull-up;
};
group2 {
psels = <NRF_PSEL(UART_RTS, 0, 8)>;
};
};

uart134_alt_sleep: uart134_alt_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 6)>,
<NRF_PSEL(UART_RTS, 0, 8)>;
low-power-enable;
};
};

uart137_alt_default: uart137_alt_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 7)>;
};
group2 {
psels = <NRF_PSEL(UART_CTS, 0, 9)>;
bias-pull-up;
};
};

uart137_alt_sleep: uart137_alt_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 7)>,
<NRF_PSEL(UART_CTS, 0, 9)>;
low-power-enable;
};
};
};

dut: &uart134 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart134_alt_default>;
pinctrl-1 = <&uart134_alt_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};

dut_aux: &uart137 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart137_alt_default>;
pinctrl-1 = <&uart137_alt_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};

&timer137 {
status = "okay";
interrupts = <467 0>;
};

/ {
busy-sim {
compatible = "vnd,busy-sim";
status = "okay";
counter = <&timer137>;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: Apache-2.0 */

#include "nrf54h20dk_nrf54h20_common.dtsi"

&dut {
memory-regions = <&cpuapp_dma_region>;
};

&dut_aux {
memory-regions = <&cpuapp_dma_region>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* SPDX-License-Identifier: Apache-2.0 */

&pinctrl {
uart21_default: uart21_default {
group1 {
psels = <NRF_PSEL(UART_RX, 1, 8)>;
bias-pull-up;
};
group2 {
psels = <NRF_PSEL(UART_RTS, 1, 10)>;
};
};

uart21_sleep: uart21_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 1, 8)>,
<NRF_PSEL(UART_RTS, 1, 10)>;
low-power-enable;
};
};

uart22_default: uart22_default {
group1 {
psels = <NRF_PSEL(UART_TX, 1, 9)>;
};
group2 {
psels = <NRF_PSEL(UART_CTS, 1, 11)>;
bias-pull-up;
};
};

uart22_sleep: uart22_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 1, 9)>,
<NRF_PSEL(UART_CTS, 1, 11)>;
low-power-enable;
};
};
};

dut: &uart21 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart21_default>;
pinctrl-1 = <&uart21_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};

dut_aux: &uart22 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart22_default>;
pinctrl-1 = <&uart22_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};

&timer20 {
status = "okay";
interrupts = <202 0>;
};

/ {
busy-sim {
compatible = "vnd,busy-sim";
status = "okay";
counter = <&timer20>;
};
};
7 changes: 7 additions & 0 deletions tests/drivers/uart/uart_async_dual/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_ZTEST=y
CONFIG_TEST_BUSY_SIM=y
CONFIG_RING_BUFFER=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
Loading

0 comments on commit b9f3391

Please sign in to comment.