-
Notifications
You must be signed in to change notification settings - Fork 1.4k
tests: drivers: uart: Add UART mode to mode full duplex transmission … #25351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # | ||
| # Copyright (c) 2025 Nordic Semiconductor ASA | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
|
|
||
| project(uart_mode_to_mode) | ||
|
|
||
| if(CONFIG_ASYNC_AND_INT) | ||
| target_sources(app PRIVATE src/common.c src/async_int.c) | ||
| elseif(CONFIG_ASYNC_AND_POLL) | ||
| target_sources(app PRIVATE src/common.c src/async_poll.c) | ||
| else() | ||
| target_sources(app PRIVATE src/common.c src/int_poll.c) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # | ||
| # Copyright (c) 2025 Nordic Semiconductor ASA | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| source "Kconfig.zephyr" | ||
|
|
||
| config ASYNC_AND_INT | ||
| bool "Async and int mode uart transmission test" | ||
|
|
||
| config ASYNC_AND_POLL | ||
| bool "Async and poll mode uart transmission test" | ||
|
|
||
| config INT_AND_POLL | ||
| bool "Int and poll mode uart transmission test" |
77 changes: 77 additions & 0 deletions
77
tests/drivers/uart/uart_mixed_modes/boards/nrf54h20dk_nrf54h20_cpuapp.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Copyright (c) 2025 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| /* | ||
| * Required loopbacks: | ||
| * P0.08 <-> P0.09 | ||
| * P0.06 <-> P0.07 | ||
| */ | ||
|
|
||
| &pinctrl { | ||
| uart134_default_test: uart134_default_test { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_RX, 0, 9)>; | ||
| bias-pull-up; | ||
| }; | ||
|
|
||
| group2 { | ||
| psels = <NRF_PSEL(UART_TX, 0, 6)>; | ||
| }; | ||
| }; | ||
|
|
||
| uart134_sleep_test: uart134_sleep_test { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_TX, 0, 6)>, | ||
| <NRF_PSEL(UART_RX, 0, 9)>; | ||
| low-power-enable; | ||
| }; | ||
| }; | ||
|
|
||
| uart131_default_test: uart131_default_test { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_RX, 0, 7)>; | ||
| bias-pull-up; | ||
| }; | ||
|
|
||
| group2 { | ||
| psels = <NRF_PSEL(UART_TX, 0, 8)>; | ||
| }; | ||
| }; | ||
|
|
||
| uart131_sleep_test: uart131_sleep_test { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_TX, 0, 7)>, | ||
| <NRF_PSEL(UART_RX, 0, 8)>; | ||
| low-power-enable; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| &cpuapp_dma_region { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| dut_uart_a: &uart134 { | ||
| compatible = "nordic,nrf-uarte"; | ||
| current-speed = <115200>; | ||
| status = "okay"; | ||
| memory-regions = <&cpuapp_dma_region>; | ||
| pinctrl-0 = <&uart134_default_test>; | ||
| pinctrl-1 = <&uart134_sleep_test>; | ||
| pinctrl-names = "default", "sleep"; | ||
| /delete-property/ hw-flow-control; | ||
| }; | ||
|
|
||
| dut_uart_b: &uart131 { | ||
| compatible = "nordic,nrf-uarte"; | ||
| current-speed = <115200>; | ||
| status = "okay"; | ||
| memory-regions = <&cpuapp_dma_region>; | ||
| pinctrl-0 = <&uart131_default_test>; | ||
| pinctrl-1 = <&uart131_sleep_test>; | ||
| pinctrl-names = "default", "sleep"; | ||
| /delete-property/ hw-flow-control; | ||
| }; | ||
61 changes: 61 additions & 0 deletions
61
tests/drivers/uart/uart_mixed_modes/boards/nrf54l15dk_nrf54l15_cpuapp.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright (c) 2025 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| /* | ||
| * Required loopbacks: | ||
| * P1.08 <-> P1.09 | ||
| * P1.10 <-> P1.11 | ||
| */ | ||
|
|
||
| &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_uart_a: &uart21 { | ||
| status = "okay"; | ||
| current-speed = <115200>; | ||
| pinctrl-0 = <&uart21_default>; | ||
| pinctrl-1 = <&uart21_sleep>; | ||
| pinctrl-names = "default", "sleep"; | ||
| }; | ||
|
|
||
| dut_uart_b: &uart22 { | ||
| status = "okay"; | ||
| current-speed = <115200>; | ||
| pinctrl-0 = <&uart22_default>; | ||
| pinctrl-1 = <&uart22_sleep>; | ||
| pinctrl-names = "default", "sleep"; | ||
| }; |
61 changes: 61 additions & 0 deletions
61
tests/drivers/uart/uart_mixed_modes/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright (c) 2025 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| /* | ||
| * Required loopbacks: | ||
| * P1.13 <-> P1.14 | ||
| * P1.23 <-> P1.24 | ||
| */ | ||
|
|
||
| &pinctrl { | ||
| uart21_default: uart21_default { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_TX, 1, 13)>, | ||
| <NRF_PSEL(UART_RX, 1, 23)>; | ||
| bias-pull-up; | ||
| }; | ||
| }; | ||
|
|
||
| uart21_sleep: uart21_sleep { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_TX, 1, 13)>, | ||
| <NRF_PSEL(UART_RX, 1, 23)>; | ||
| low-power-enable; | ||
| }; | ||
| }; | ||
|
|
||
| uart22_default: uart22_default { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_TX, 1, 24)>, | ||
| <NRF_PSEL(UART_RX, 1, 14)>; | ||
| bias-pull-up; | ||
| }; | ||
| }; | ||
|
|
||
| uart22_sleep: uart22_sleep { | ||
| group1 { | ||
| psels = <NRF_PSEL(UART_TX, 1, 24)>, | ||
| <NRF_PSEL(UART_RX, 1, 14)>; | ||
| low-power-enable; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| dut_uart_a: &uart21 { | ||
| status = "okay"; | ||
| current-speed = <115200>; | ||
| pinctrl-0 = <&uart21_default>; | ||
| pinctrl-1 = <&uart21_sleep>; | ||
| pinctrl-names = "default", "sleep"; | ||
| }; | ||
|
|
||
| dut_uart_b: &uart22 { | ||
| status = "okay"; | ||
| current-speed = <115200>; | ||
| pinctrl-0 = <&uart22_default>; | ||
| pinctrl-1 = <&uart22_sleep>; | ||
| pinctrl-names = "default", "sleep"; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| CONFIG_SERIAL=y | ||
| CONFIG_UART_USE_RUNTIME_CONFIGURE=y | ||
|
|
||
| CONFIG_ZTEST=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright (c) 2025 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #include "common.h" | ||
|
|
||
| const struct device *const uart_dev_async_mode = DEVICE_DT_GET(UART_NODE_MODE_A); | ||
| const struct device *const uart_dev_int_mode = DEVICE_DT_GET(UART_NODE_MODE_B); | ||
|
|
||
| extern struct k_sem uart_async_mode_rx_ready_sem; | ||
| extern struct k_sem uart_interrupt_mode_rx_done_sem; | ||
|
|
||
| extern uint8_t uart_a_tx_test_buffer[BUFFER_SIZE]; | ||
| extern uint8_t uart_a_rx_test_buffer[BUFFER_SIZE]; | ||
| extern uint8_t uart_b_tx_test_buffer[BUFFER_SIZE]; | ||
| extern uint8_t uart_b_rx_test_buffer[BUFFER_SIZE]; | ||
|
|
||
| extern volatile uint32_t tx_byte_offset; | ||
| extern volatile uint32_t rx_byte_offset; | ||
|
|
||
| ZTEST(uart_async_int, test_uart_async_int_transmission) | ||
| { | ||
| int err, rx_done_async_sem_take_result, rx_done_int_sem_take_result; | ||
| uint32_t sleep_time_ms = 0; | ||
| uart_test_data uart_async_test_data; | ||
| uart_test_data uart_int_test_data; | ||
|
|
||
| tx_byte_offset = 0; | ||
| rx_byte_offset = 0; | ||
|
|
||
| uart_async_test_data.tx_buffer = uart_a_tx_test_buffer; | ||
| uart_async_test_data.rx_buffer = uart_a_rx_test_buffer; | ||
| uart_async_test_data.buffer_size = BUFFER_SIZE; | ||
|
|
||
| uart_int_test_data.tx_buffer = uart_b_tx_test_buffer; | ||
| uart_int_test_data.rx_buffer = uart_b_rx_test_buffer; | ||
| uart_int_test_data.buffer_size = BUFFER_SIZE; | ||
|
|
||
| set_test_pattern(&uart_async_test_data); | ||
| set_test_pattern(&uart_int_test_data); | ||
|
|
||
| TC_PRINT("UART full duplex transmission test: UART (ASYNC) <-> UART (INT)\n"); | ||
|
|
||
| err = uart_callback_set(uart_dev_async_mode, async_uart_callback, NULL); | ||
| zassert_equal(err, 0, "ASYNC UART callback setup failed"); | ||
|
|
||
| err = uart_irq_callback_set(uart_dev_int_mode, uart_isr_handler); | ||
| zassert_equal(err, 0, "Unexpected error when setting callback for INT UART: %d", err); | ||
| err = uart_irq_callback_user_data_set(uart_dev_int_mode, uart_isr_handler, | ||
| (void *)&uart_int_test_data); | ||
| zassert_equal(err, 0, | ||
| "Unexpected error when setting user data for callback for INT UART: %d", err); | ||
|
|
||
| TC_PRINT("Starting transmission\n"); | ||
| enable_uart_rx(uart_dev_async_mode, &uart_async_test_data); | ||
| uart_irq_rx_enable(uart_dev_int_mode); | ||
|
|
||
| uart_irq_tx_enable(uart_dev_int_mode); | ||
| err = uart_tx(uart_dev_async_mode, uart_async_test_data.tx_buffer, BUFFER_SIZE, | ||
| UART_TIMEOUT_US); | ||
|
|
||
| TC_PRINT("Waiting for transmission to finish\n"); | ||
| while (1) { | ||
| rx_done_async_sem_take_result = | ||
| k_sem_take(&uart_async_mode_rx_ready_sem, K_NO_WAIT); | ||
| rx_done_int_sem_take_result = | ||
| k_sem_take(&uart_interrupt_mode_rx_done_sem, K_NO_WAIT); | ||
| if ((rx_done_async_sem_take_result + rx_done_int_sem_take_result) == 0) { | ||
| TC_PRINT("Full duplex transmission completed\n"); | ||
| break; | ||
| } | ||
| k_msleep(SEM_CHECK_DEAD_TIME_MS); | ||
| sleep_time_ms += SEM_CHECK_DEAD_TIME_MS; | ||
| zassert_true(sleep_time_ms < TRANSMISSION_TIMEOUT_MS, "Transmission timed out\n"); | ||
| } | ||
| uart_rx_disable(uart_dev_async_mode); | ||
| uart_irq_rx_disable(uart_dev_int_mode); | ||
| uart_irq_tx_disable(uart_dev_int_mode); | ||
| zassert_mem_equal(uart_async_test_data.rx_buffer, uart_int_test_data.rx_buffer, BUFFER_SIZE, | ||
| "UART (ASYNC) RX buffer != UART (INT) RX buffer\n"); | ||
| } | ||
|
|
||
| void *test_setup(void) | ||
| { | ||
| zassert_true(device_is_ready(uart_dev_async_mode), "UART in ASYNC mode is not ready"); | ||
| zassert_true(device_is_ready(uart_dev_int_mode), "UART in INTERRUPT mode is not ready"); | ||
|
|
||
| return NULL; | ||
| } | ||
|
|
||
| ZTEST_SUITE(uart_async_int, NULL, test_setup, NULL, NULL, NULL); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.