Skip to content

Commit 9d26461

Browse files
committed
tests: drivers: uart: Add test for async API using two instance
Add test which is using two independent UART devices. Validate behavior of asynchronous API. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent d4d8163 commit 9d26461

17 files changed

+1353
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(uart_async_dual)
7+
8+
target_sources(app PRIVATE src/main.c)
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config UART_ASYNC_DUAL_TEST_TIMEOUT
5+
int "Single test case length (in milliseconds)"
6+
# For the simulated devices, which are run by default in CI, we set it to less to not spend too
7+
# much CI time
8+
default 500 if SOC_SERIES_BSIM_NRFXX
9+
default 3000
10+
help
11+
For how many loops will the stress test run. The higher this number the longer the
12+
test and therefore the higher likelihood an unlikely race/event will be triggered.
13+
14+
config PM_RUNTIME_IN_TEST
15+
bool "Use runtime PM in the test"
16+
select PM_DEVICE
17+
select PM_DEVICE_RUNTIME
18+
19+
# Include Zephyr's Kconfig
20+
source "Kconfig"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
&pinctrl {
4+
uart0_default: uart0_default {
5+
group1 {
6+
psels = <NRF_PSEL(UART_RX, 1, 1)>,
7+
<NRF_PSEL(UART_TX, 1, 2)>,
8+
<NRF_PSEL(UART_RTS, 1, 3)>,
9+
<NRF_PSEL(UART_CTS, 1, 4)>;
10+
};
11+
};
12+
13+
uart0_sleep: uart0_sleep {
14+
group1 {
15+
psels = <NRF_PSEL(UART_RX, 1, 1)>,
16+
<NRF_PSEL(UART_TX, 1, 2)>,
17+
<NRF_PSEL(UART_RTS, 1, 3)>,
18+
<NRF_PSEL(UART_CTS, 1, 4)>;
19+
low-power-enable;
20+
};
21+
};
22+
};
23+
24+
dut: &uart0 {
25+
status = "okay";
26+
current-speed = <115200>;
27+
pinctrl-0 = <&uart0_default>;
28+
pinctrl-1 = <&uart0_sleep>;
29+
pinctrl-names = "default", "sleep";
30+
hw-flow-control;
31+
zephyr,pm-device-runtime-auto;
32+
};
33+
34+
&timer0 {
35+
status = "okay";
36+
interrupts = <8 0>;
37+
};
38+
39+
/ {
40+
busy-sim {
41+
compatible = "vnd,busy-sim";
42+
status = "okay";
43+
counter = <&timer0>;
44+
};
45+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
&pinctrl {
4+
uart134_alt_default: uart134_alt_default {
5+
group1 {
6+
psels = <NRF_PSEL(UART_RX, 0, 6)>;
7+
bias-pull-up;
8+
};
9+
group2 {
10+
psels = <NRF_PSEL(UART_RTS, 0, 8)>;
11+
};
12+
};
13+
14+
uart134_alt_sleep: uart134_alt_sleep {
15+
group1 {
16+
psels = <NRF_PSEL(UART_RX, 0, 6)>,
17+
<NRF_PSEL(UART_RTS, 0, 8)>;
18+
low-power-enable;
19+
};
20+
};
21+
22+
uart137_alt_default: uart137_alt_default {
23+
group1 {
24+
psels = <NRF_PSEL(UART_TX, 0, 7)>;
25+
};
26+
group2 {
27+
psels = <NRF_PSEL(UART_CTS, 0, 9)>;
28+
bias-pull-up;
29+
};
30+
};
31+
32+
uart137_alt_sleep: uart137_alt_sleep {
33+
group1 {
34+
psels = <NRF_PSEL(UART_TX, 0, 7)>,
35+
<NRF_PSEL(UART_CTS, 0, 9)>;
36+
low-power-enable;
37+
};
38+
};
39+
40+
uart120_default_alt: uart120_default_alt {
41+
group1 {
42+
psels = <NRF_PSEL(UART_TX, 7, 7)>,
43+
<NRF_PSEL(UART_RTS, 7, 5)>;
44+
};
45+
group2 {
46+
psels = <NRF_PSEL(UART_RX, 7, 4)>,
47+
<NRF_PSEL(UART_CTS, 7, 6)>;
48+
bias-pull-up;
49+
};
50+
};
51+
52+
uart120_sleep_alt: uart120_sleep_alt {
53+
group1 {
54+
psels = <NRF_PSEL(UART_TX, 7, 7)>,
55+
<NRF_PSEL(UART_RX, 7, 4)>,
56+
<NRF_PSEL(UART_RTS, 7, 5)>,
57+
<NRF_PSEL(UART_CTS, 7, 6)>;
58+
low-power-enable;
59+
};
60+
};
61+
};
62+
63+
dut: &uart134 {
64+
status = "okay";
65+
current-speed = <115200>;
66+
pinctrl-0 = <&uart134_alt_default>;
67+
pinctrl-1 = <&uart134_alt_sleep>;
68+
pinctrl-names = "default", "sleep";
69+
hw-flow-control;
70+
zephyr,pm-device-runtime-auto;
71+
};
72+
73+
dut_aux: &uart137 {
74+
status = "okay";
75+
current-speed = <115200>;
76+
pinctrl-0 = <&uart137_alt_default>;
77+
pinctrl-1 = <&uart137_alt_sleep>;
78+
pinctrl-names = "default", "sleep";
79+
hw-flow-control;
80+
zephyr,pm-device-runtime-auto;
81+
};
82+
83+
dut2: &uart120 {
84+
pinctrl-0 = <&uart120_default_alt>;
85+
pinctrl-1 = <&uart120_sleep_alt>;
86+
pinctrl-names = "default", "sleep";
87+
current-speed = <115200>;
88+
hw-flow-control;
89+
zephyr,pm-device-runtime-auto;
90+
};
91+
92+
&timer137 {
93+
status = "okay";
94+
interrupts = <467 0>;
95+
};
96+
97+
/ {
98+
busy-sim {
99+
compatible = "vnd,busy-sim";
100+
status = "okay";
101+
counter = <&timer137>;
102+
};
103+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_PM_DEVICE=y
2+
CONFIG_PM_DEVICE_RUNTIME=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
#include "nrf54h20dk_nrf54h20_common.dtsi"
4+
5+
&dut {
6+
memory-regions = <&cpuapp_dma_region>;
7+
};
8+
9+
&dut_aux {
10+
memory-regions = <&cpuapp_dma_region>;
11+
};
12+
13+
14+
&dma_fast_region {
15+
status = "okay";
16+
};
17+
18+
&dut2 {
19+
status = "okay";
20+
memory-regions = <&dma_fast_region>;
21+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
#include "nrf54h20dk_nrf54h20_common.dtsi"
4+
5+
&timer137 {
6+
interrupts = <467 (NRF_DEFAULT_IRQ_PRIORITY + 1)>;
7+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
#include "nrf54h20dk_nrf54h20_common.dtsi"
4+
5+
&dut {
6+
memory-regions = <&cpurad_dma_region>;
7+
};
8+
9+
&dut_aux {
10+
memory-regions = <&cpurad_dma_region>;
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
&pinctrl {
4+
uart21_default: uart21_default {
5+
group1 {
6+
psels = <NRF_PSEL(UART_RX, 1, 8)>;
7+
bias-pull-up;
8+
};
9+
group2 {
10+
psels = <NRF_PSEL(UART_RTS, 1, 10)>;
11+
};
12+
};
13+
14+
uart21_sleep: uart21_sleep {
15+
group1 {
16+
psels = <NRF_PSEL(UART_RX, 1, 8)>,
17+
<NRF_PSEL(UART_RTS, 1, 10)>;
18+
low-power-enable;
19+
};
20+
};
21+
22+
uart22_default: uart22_default {
23+
group1 {
24+
psels = <NRF_PSEL(UART_TX, 1, 9)>;
25+
};
26+
group2 {
27+
psels = <NRF_PSEL(UART_CTS, 1, 11)>;
28+
bias-pull-up;
29+
};
30+
};
31+
32+
uart22_sleep: uart22_sleep {
33+
group1 {
34+
psels = <NRF_PSEL(UART_TX, 1, 9)>,
35+
<NRF_PSEL(UART_CTS, 1, 11)>;
36+
low-power-enable;
37+
};
38+
};
39+
};
40+
41+
dut: &uart21 {
42+
status = "okay";
43+
current-speed = <115200>;
44+
pinctrl-0 = <&uart21_default>;
45+
pinctrl-1 = <&uart21_sleep>;
46+
pinctrl-names = "default", "sleep";
47+
hw-flow-control;
48+
};
49+
50+
dut_aux: &uart22 {
51+
status = "okay";
52+
current-speed = <115200>;
53+
pinctrl-0 = <&uart22_default>;
54+
pinctrl-1 = <&uart22_sleep>;
55+
pinctrl-names = "default", "sleep";
56+
hw-flow-control;
57+
};
58+
59+
&timer20 {
60+
status = "okay";
61+
interrupts = <202 0>;
62+
};
63+
64+
/ {
65+
busy-sim {
66+
compatible = "vnd,busy-sim";
67+
status = "okay";
68+
counter = <&timer20>;
69+
};
70+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
&pinctrl {
4+
uart21_default: uart21_default {
5+
group1 {
6+
psels = <NRF_PSEL(UART_RX, 1, 8)>;
7+
bias-pull-up;
8+
};
9+
group2 {
10+
psels = <NRF_PSEL(UART_RTS, 1, 10)>;
11+
};
12+
};
13+
14+
uart21_sleep: uart21_sleep {
15+
group1 {
16+
psels = <NRF_PSEL(UART_RX, 1, 8)>,
17+
<NRF_PSEL(UART_RTS, 1, 10)>;
18+
low-power-enable;
19+
};
20+
};
21+
22+
uart22_default: uart22_default {
23+
group1 {
24+
psels = <NRF_PSEL(UART_TX, 1, 9)>;
25+
};
26+
group2 {
27+
psels = <NRF_PSEL(UART_CTS, 1, 11)>;
28+
bias-pull-up;
29+
};
30+
};
31+
32+
uart22_sleep: uart22_sleep {
33+
group1 {
34+
psels = <NRF_PSEL(UART_TX, 1, 9)>,
35+
<NRF_PSEL(UART_CTS, 1, 11)>;
36+
low-power-enable;
37+
};
38+
};
39+
};
40+
41+
dut: &uart21 {
42+
status = "okay";
43+
current-speed = <115200>;
44+
pinctrl-0 = <&uart21_default>;
45+
pinctrl-1 = <&uart21_sleep>;
46+
pinctrl-names = "default", "sleep";
47+
hw-flow-control;
48+
zephyr,pm-device-runtime-auto;
49+
};
50+
51+
dut_aux: &uart22 {
52+
status = "okay";
53+
current-speed = <115200>;
54+
pinctrl-0 = <&uart22_default>;
55+
pinctrl-1 = <&uart22_sleep>;
56+
pinctrl-names = "default", "sleep";
57+
hw-flow-control;
58+
zephyr,pm-device-runtime-auto;
59+
};
60+
61+
&timer20 {
62+
status = "okay";
63+
interrupts = <202 0>;
64+
};
65+
66+
/ {
67+
busy-sim {
68+
compatible = "vnd,busy-sim";
69+
status = "okay";
70+
counter = <&timer20>;
71+
};
72+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y

0 commit comments

Comments
 (0)