Skip to content

Commit

Permalink
applications: Add Peripheral Sensor Node app
Browse files Browse the repository at this point in the history
Add Peripheral sensor node application for the the nrf54L15 PDK.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Signed-off-by: Marcin Jelinski <marcin.jelinski@nordicsemi.no>
  • Loading branch information
Emil Obalski authored and nordicjm committed Aug 20, 2024
1 parent 5f15c74 commit c2f91b0
Show file tree
Hide file tree
Showing 27 changed files with 1,854 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
/applications/nrf_desktop/ @MarekPieta
/applications/nrf5340_audio/ @nrfconnect/ncs-audio
/applications/audio/ @nrfconnect/ncs-audio
/applications/peripheral_sensor_node/ @rakons maje-emb
/applications/serial_lte_modem/ @SeppoTakalo @MarkusLassila @rlubos @tomi-font
/applications/zigbee_weather_station/ @milewr
# Boards
Expand Down
45 changes: 45 additions & 0 deletions applications/peripheral_sensor_node/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright (c) 2023 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
cmake_minimum_required(VERSION 3.20.0)

if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}")
message(FATAL_ERROR
"Board ${BOARD} is not supported.\n"
"Please make sure board specific configuration files are added to "
"${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}")
endif()

################################################################################

# The application uses the configuration/<board> scheme for configuration files.
# Configuring here to ensure BOARD contains BOARD_REVISION
set(APPLICATION_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/configuration/\${NORMALIZED_BOARD_TARGET}")

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project("Peripheral Sensor Node"
VERSION 0.1)

################################################################################

# NORDIC SDK APP START
target_sources(app PRIVATE
src/main.c
)
# NORDIC SDK APP END

# Include application events and configuration headers
target_include_directories(app PRIVATE
src/events
src/modules
)

zephyr_include_directories(
configuration/common
${APPLICATION_CONFIG_DIR}
)

add_subdirectory(src/events)
add_subdirectory(src/modules)
14 changes: 14 additions & 0 deletions applications/peripheral_sensor_node/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2023 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

menu "Peripheral sensor node application"
rsource "src/events/Kconfig"
rsource "src/modules/Kconfig"
endmenu

menu "Zephyr Kernel"
source "Kconfig.zephyr"
endmenu
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef _SENSOR_SAMPLER_H_
#define _SENSOR_SAMPLER_H_

#include <zephyr/drivers/sensor.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Description of single channel
*
* The description of the channel to do the measurement on.
*/
struct sampled_channel {
/** @brief Channel identifier */
enum sensor_channel chan;
/** @brief Number of data samples in selected channel */
uint8_t data_cnt;
};

/**
* @brief Sensor configuration
*
* The sensor configuration is provided by the application in file specified by
* the :kconfig:option:`CONFIG_CAF_SENSOR_SAMPLER_DEF_PATH` option.
*/
struct sensor_config {
/**
* @brief Device
*/
const struct device *dev;
/**
* @brief Event descriptor
*
* Descriptor that would be used to identify source of sensor_events
* by the application modules.
*/
const char *event_descr;
/**
* @brief Used channels description
*
* Channels in the sensor that should be handled by sensor sampler module
*/
const struct sampled_channel *chans;
/**
* @brief Number of channels
*
* Number of channels handled for the sensor
*/
uint8_t chan_cnt;
/**
* @brief Allowed number of unprocessed events
*
* This is a protection against OOM error when event processing is blocked.
* No more events related to this sensor than the number defined would
* be passed to Application Event Manager.
*/
uint8_t events_limit;
};


#ifdef __cplusplus
}
#endif

#endif /* _SENSOR_SAMPLER_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/{
/delete-node/ leds;

leds1 {
compatible = "gpio-leds";
led1: led_1 {
gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
label = "Green LED 1";
};
};

aliases {
/delete-property/ led0;
/delete-property/ led1;
/delete-property/ led2;
/delete-property/ led3;
/delete-property/ sw0;
};
};

/delete-node/ &button0; // P1.13 is bmi270 chip select signal

&cpuapp_rram {
/delete-node/ partitions;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x0 DT_SIZE_K(64)>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x10000 DT_SIZE_K(312)>;
};
slot0_ns_partition: partition@5e000 {
label = "image-0-nonsecure";
reg = <0x5e000 DT_SIZE_K(312)>;
};
slot1_partition: partition@ac000 {
label = "image-1";
reg = <0xac000 DT_SIZE_K(312)>;
};
slot1_ns_partition: partition@fa000 {
label = "image-1-nonsecure";
reg = <0xfa000 DT_SIZE_K(312)>;
};
sensor_data_storage: partition@148000 {
label = "sensor-data-storage";
reg = <0x00148000 DT_SIZE_K(48)>;
};
/* 32k from 0x154000 to 0x15bfff reserved for TF-M partitions */
storage_partition: partition@15c000 {
label = "storage";
reg = <0x15c000 DT_SIZE_K(36)>;
};
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <caf/led_effect.h>

/**
* @file
* @brief Configuration file for LED states and effects.
*
* This configuration file is included only once from led_state module and holds
* information about LED effect associated with each state.
*/

/**
* @brief Structure to ensure single inclusion of this header file.
*
* This structure enforces the header file is included only once in the build.
* Violating this requirement triggers a multiple definition error at link time.
*/
const struct {} led_state_def_include_once;

/** @brief Enumeration of LED identifiers. */
enum led_id {
LED_ID_1, /**< Identifier for the LED 1. */

LED_ID_COUNT /**< Total count of LED identifiers. */
};

/** @brief LED effect for turning the LED. */
static const struct led_effect led_effect_on = LED_EFFECT_LED_ON(LED_COLOR(255, 255, 255));
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#
# Copyright (c) 2023 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_GPIO=y

# Enable UART console
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_ASYNC_API=y
# Enable float printing
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Peripheral Sensor Node"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_ADV_PROV_DEVICE_NAME=y
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1
CONFIG_BT_L2CAP_TX_MTU=498
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

# Enable the Nordic Status Message service
CONFIG_BT_NSMS=y
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_BUF_ACL_TX_SIZE=502
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Config logger
CONFIG_LOG=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG_PRINTK=n

CONFIG_ASSERT=y

CONFIG_SENSOR=y
CONFIG_ADXL362=y
CONFIG_ADXL362_ACCEL_RANGE_8G=y
CONFIG_ADXL362_ACCEL_ODR_100=y
CONFIG_ADXL362_TRIGGER_GLOBAL_THREAD=y
CONFIG_ADXL362_INACTIVITY_THRESHOLD=0
CONFIG_ADXL362_ACTIVITY_THRESHOLD=70
CONFIG_ADXL362_ABS_REF_MODE=1

CONFIG_APP_EVENT_MANAGER=y
CONFIG_REBOOT=y

# Dependencies for CAF_LEDS
CONFIG_LED=y

# CAF modules configuration
CONFIG_CAF=y
CONFIG_CAF_LEDS=y
CONFIG_CAF_BLE_ADV=y
CONFIG_CAF_BLE_STATE=y
CONFIG_CAF_SETTINGS_LOADER=y

# CAF events configuration
CONFIG_CAF_INIT_LOG_SENSOR_EVENTS=n

# Application configuration
CONFIG_APP_SENSORS=y

# Enable nordic security backend and PSA APIs
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y

CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=8192

CONFIG_PSA_WANT_GENERATE_RANDOM=y
Loading

0 comments on commit c2f91b0

Please sign in to comment.