From f8557b95fcac2b7ece79956e5f2f8f0c4d45d6bf 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 | 13 ++++++ .../boards/nordic/nrf_sys_event/src/main.c | 41 +++++++++++++++++++ 4 files changed, 67 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 000000000000000..5f7335b260e7ce1 --- /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 000000000000000..28f655a7e24eb3f --- /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 000000000000000..135d5151eb58b56 --- /dev/null +++ b/samples/boards/nordic/nrf_sys_event/sample.yaml @@ -0,0 +1,13 @@ +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: + - nrf54h20dk/nrf54h20/cpuapp + - nrf54l15dk/nrf54l15/cpuapp + - nrf5340dk/nrf5340/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 000000000000000..e97d3c821f780f7 --- /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; +}