From 9df88e62fc4a69f5a3873aa82c856728d7dc11c5 Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Wed, 16 Oct 2024 16:31:10 +0200 Subject: [PATCH] samples: boards: nordic: add nrf_sys_event sample Add sample for nrf system events. Signed-off-by: Bjarki Arge Andreasen --- .../nordic/nrf_sys_event/CMakeLists.txt | 9 ++++ samples/boards/nordic/nrf_sys_event/prj.conf | 4 ++ .../boards/nordic/nrf_sys_event/sample.yaml | 28 +++++++++++++ .../boards/nordic/nrf_sys_event/src/main.c | 41 +++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 samples/boards/nordic/nrf_sys_event/CMakeLists.txt create mode 100644 samples/boards/nordic/nrf_sys_event/prj.conf create mode 100644 samples/boards/nordic/nrf_sys_event/sample.yaml create mode 100644 samples/boards/nordic/nrf_sys_event/src/main.c diff --git a/samples/boards/nordic/nrf_sys_event/CMakeLists.txt b/samples/boards/nordic/nrf_sys_event/CMakeLists.txt new file mode 100644 index 00000000000..5f7335b260e --- /dev/null +++ b/samples/boards/nordic/nrf_sys_event/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(soc_sys_event) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/samples/boards/nordic/nrf_sys_event/prj.conf b/samples/boards/nordic/nrf_sys_event/prj.conf new file mode 100644 index 00000000000..28f655a7e24 --- /dev/null +++ b/samples/boards/nordic/nrf_sys_event/prj.conf @@ -0,0 +1,4 @@ +# Copyright 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_NRF_SYS_EVENT=y diff --git a/samples/boards/nordic/nrf_sys_event/sample.yaml b/samples/boards/nordic/nrf_sys_event/sample.yaml new file mode 100644 index 00000000000..c5ea3d8a23d --- /dev/null +++ b/samples/boards/nordic/nrf_sys_event/sample.yaml @@ -0,0 +1,28 @@ +sample: + name: nRF System events +tests: + sample.boards.nordic.nrf_sys_event: + harness: console + harness_config: + type: one_line + regex: + - "constant latency mode disabled" + platform_allow: + - nrf52dk/nrf52810 + - nrf52dk/nrf52832 + - nrf52833dk/nrf52820 + - nrf52833dk/nrf52833 + - nrf52840dk/nrf52811 + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf5340dk/nrf5340/cpunet + - nrf54h20dk/nrf54h20/cpuapp + - nrf54h20dk/nrf54h20/cpurad + - nrf54l15dk/nrf54l15/cpuapp + integration_platforms: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf5340dk/nrf5340/cpunet + - nrf54h20dk/nrf54h20/cpuapp + - nrf54h20dk/nrf54h20/cpurad + - nrf54l15dk/nrf54l15/cpuapp diff --git a/samples/boards/nordic/nrf_sys_event/src/main.c b/samples/boards/nordic/nrf_sys_event/src/main.c new file mode 100644 index 00000000000..e97d3c821f7 --- /dev/null +++ b/samples/boards/nordic/nrf_sys_event/src/main.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +int main(void) +{ + printf("request global constant latency mode\n"); + if (nrf_sys_event_request_global_constlat()) { + printf("failed to request global constant latency mode\n"); + return 0; + } + printf("constant latency mode enabled\n"); + + printf("request global constant latency mode again\n"); + if (nrf_sys_event_request_global_constlat()) { + printf("failed to request global constant latency mode\n"); + return 0; + } + + printf("release global constant latency mode\n"); + printf("constant latency mode will remain enabled\n"); + if (nrf_sys_event_release_global_constlat()) { + printf("failed to release global constant latency mode\n"); + return 0; + } + + printf("release global constant latency mode again\n"); + printf("constant latency mode will be disabled\n"); + if (nrf_sys_event_release_global_constlat()) { + printf("failed to release global constant latency mode\n"); + return 0; + } + + printf("constant latency mode disabled\n"); + return 0; +}