-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: benchmarks: current_consumption: add uart_idle
For nrf54l15, waiting at idle state for UART RX. Signed-off-by: Piotr Kosycarz <[email protected]>
- Loading branch information
1 parent
ad6cdc9
commit 6e0c52d
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
tests/benchmarks/current_consumption/uart_idle/CMakeLists.txt
This file contains 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,13 @@ | ||
# | ||
# Copyright (c) 2024 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_idle) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains 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,2 @@ | ||
CONFIG_UART_INTERRUPT_DRIVEN=n | ||
CONFIG_UART_ASYNC_API=y |
This file contains 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,72 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/device.h> | ||
#include <zephyr/drivers/uart.h> | ||
|
||
#define BUF_SIZE 1 | ||
static char rx_buf[BUF_SIZE]; | ||
|
||
static K_SEM_DEFINE(my_uart_sem, 0, 1); | ||
|
||
static const struct device *const uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart)); | ||
|
||
static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data) | ||
{ | ||
switch (evt->type) { | ||
case UART_TX_DONE: | ||
break; | ||
case UART_TX_ABORTED: | ||
break; | ||
case UART_RX_RDY: | ||
k_sem_give(&my_uart_sem); | ||
break; | ||
case UART_RX_BUF_REQUEST: | ||
break; | ||
case UART_RX_BUF_RELEASED: | ||
break; | ||
case UART_RX_DISABLED: | ||
break; | ||
case UART_RX_STOPPED: | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
int main(void) | ||
{ | ||
int ret; | ||
|
||
ret = device_is_ready(uart_dev); | ||
if (ret < 0) { | ||
printk("device_is_ready: %d\n", ret); | ||
return 0; | ||
} | ||
|
||
ret = uart_callback_set(uart_dev, uart_cb, NULL); | ||
if (ret < 0) { | ||
printk("uart_callback_set: %d\n", ret); | ||
return 0; | ||
} | ||
|
||
while (1) { | ||
uart_rx_enable(uart_dev, rx_buf, BUF_SIZE, 0); | ||
if (ret < 0) { | ||
printk("uart_rx_enable: %d\n", ret); | ||
return 0; | ||
} | ||
if (k_sem_take(&my_uart_sem, K_FOREVER) != 0) { | ||
printk("Failed to take a semaphore\n"); | ||
return 0; | ||
} | ||
k_busy_wait(1000000); | ||
k_sem_reset(&my_uart_sem); | ||
} | ||
|
||
return 0; | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/benchmarks/current_consumption/uart_idle/testcase.yaml
This file contains 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 @@ | ||
common: | ||
sysbuild: true | ||
tags: ci_tests_benchmarks_current_consumption ppk_power_measure | ||
|
||
tests: | ||
benchmarks.current_consumption.uart_idle: | ||
platform_allow: | ||
- nrf54l15dk/nrf54l15/cpuapp | ||
integration_platforms: | ||
- nrf54l15dk/nrf54l15/cpuapp | ||
harness: pytest | ||
harness_config: | ||
fixture: ppk_power_measure | ||
pytest_root: | ||
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_with_rx_wakeup_54L_uart_idle" | ||
timeout: 80 |