Skip to content

Commit

Permalink
[nrf fromtree] drivers: Extend coverage for UARTE driver
Browse files Browse the repository at this point in the history
Add more test cases for UARTE driver API

Signed-off-by: Bartosz Miller <[email protected]>
(cherry picked from commit 211477f)
  • Loading branch information
nordic-bami committed Apr 15, 2024
1 parent 3ae7585 commit 57a9aff
Show file tree
Hide file tree
Showing 13 changed files with 608 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/drivers/uart/uart_elementary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

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

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

config DUAL_UART_TEST
bool "Enable dual UART test"

config SETUP_MISMATCH_TEST
bool "Enable mismatched configuration in dual UART test"

source "Kconfig.zephyr"
13 changes: 13 additions & 0 deletions tests/drivers/uart/uart_elementary/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
The purpose of this test is to validate basic UART driver functions,
that are not tested elsewhere.
UART interrupt mode is used for the tests purpose.

Hardware setup required for these tests:
For single uart conviguration - UART0 TX connected to RX and CTS to RTS
For dual uart configuratiom - UART0 and UART1 TXs and RXs cross-connected

These test cases cover:
- UART configuration,
- UART error check,
- UART callback setup,
- Dual UART transmission with matched and mismatched configurations
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=n
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* SPDX-License-Identifier: Apache-2.0 */

&pinctrl {
uart1_default_alt: uart1_default_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 4)>,
<NRF_PSEL(UART_RX, 0, 5)>,
<NRF_PSEL(UART_RTS, 0, 6)>,
<NRF_PSEL(UART_CTS, 0, 7)>;
};
};

uart1_sleep_alt: uart1_sleep_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 4)>,
<NRF_PSEL(UART_RX, 0, 5)>,
<NRF_PSEL(UART_RTS, 0, 6)>,
<NRF_PSEL(UART_CTS, 0, 7)>;
low-power-enable;
};
};
};

dut: &uart1 {
current-speed = <115200>;
compatible = "nordic,nrf-uarte";
status = "okay";
pinctrl-0 = <&uart1_default_alt>;
pinctrl-1 = <&uart1_sleep_alt>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* SPDX-License-Identifier: Apache-2.0 */

&cpuapp_dma_region {
status="okay";
};

&pinctrl {
uart135_default_alt: uart135_default_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 7)>,
<NRF_PSEL(UART_RTS, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 9)>;
};
};

uart135_sleep_alt: uart135_sleep_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 7)>,
<NRF_PSEL(UART_RTS, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 9)>;
low-power-enable;
};
};
};

dut: &uart135 {
status = "okay";
memory-regions = <&cpuapp_dma_region>;
pinctrl-0 = <&uart135_default_alt>;
pinctrl-1 = <&uart135_sleep_alt>;
pinctrl-names = "default", "sleep";
current-speed = <115200>;
hw-flow-control;

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* SPDX-License-Identifier: Apache-2.0 */

#include "nrf54h20dk_nrf54h20_common.dtsi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* SPDX-License-Identifier: Apache-2.0 */

#include "nrf54h20dk_nrf54h20_common.dtsi"


&pinctrl {
uart135_default_alt: uart135_default_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 9)>;
};
};

uart135_sleep_alt: uart135_sleep_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 9)>;
low-power-enable;
};
};
};

dut: &uart135 {
status = "okay";
memory-regions = <&cpuapp_dma_region>;
pinctrl-0 = <&uart135_default_alt>;
pinctrl-1 = <&uart135_sleep_alt>;
pinctrl-names = "default", "sleep";
current-speed = <115200>;
};

&pinctrl {
uart137_default_alt: uart137_default_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 8)>,
<NRF_PSEL(UART_RX, 0, 7)>;
};
};

uart137_sleep_alt: uart137_sleep_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 8)>,
<NRF_PSEL(UART_RX, 0, 9)>;
low-power-enable;
};
};
};

dut_aux: &uart137 {
status = "okay";
memory-regions = <&cpuapp_dma_region>;
pinctrl-0 = <&uart137_default_alt>;
pinctrl-1 = <&uart137_sleep_alt>;
pinctrl-names = "default", "sleep";
current-speed = <115200>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* SPDX-License-Identifier: Apache-2.0 */

&pinctrl {
uart21_default: uart21_default {
group1 {
psels = <NRF_PSEL(UART_TX, 1, 10)>,
<NRF_PSEL(UART_RX, 1, 11)>,
<NRF_PSEL(UART_RTS, 1, 8)>,
<NRF_PSEL(UART_CTS, 1, 9)>;
};
};

uart21_sleep: uart21_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 1, 10)>,
<NRF_PSEL(UART_RX, 1, 11)>,
<NRF_PSEL(UART_RTS, 1, 8)>,
<NRF_PSEL(UART_CTS, 1, 9)>;
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;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* SPDX-License-Identifier: Apache-2.0 */

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

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

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

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

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

dut_aux: &uart22 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart22_default>;
pinctrl-1 = <&uart22_sleep>;
pinctrl-names = "default", "sleep";
};
6 changes: 6 additions & 0 deletions tests/drivers/uart/uart_elementary/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_SERIAL=y
CONFIG_ZTEST=y
CONFIG_TEST_USERSPACE=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
Loading

0 comments on commit 57a9aff

Please sign in to comment.