Initial commit for SensorSoftwareTest_

This commit is contained in:
Miguel Iglesias
2024-10-07 18:12:21 +02:00
commit 4d7f1a57fc
15 changed files with 581 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
/*
* This file is created to fulfill the requirement of a pinctrl-N
* property for nodes in the specific target overlay file.
*
* In the current implementation of samples, the specific peripheral
* driver instance is initialized at runtime with a configuration
* based on pin symbols defined in `nrfx_example.h`.
*
* To use values from specific property nodes from the device tree,
* appropriate values for the `psels` property must be provided
* instead of the dummy values defined in that file. Once done, these values
* can be accessed from the device tree through using the API implemented in
* `<zephyr/devicetree.h>` (see Zephyrs doc: Devicetree access from C/C++).
*
* Here is a sample of extracting node `psels` values to initialize a peripheral
* driver instance with a configuration based on those values:
*
* #define SPI_NODE DT_NODELABEL(spi1)
* #define SPI_PINCTRL_NODE DT_CHILD(DT_PINCTRL_0(SPI_NODE, 0), group1)
* #define SCK_PIN (DT_PROP_BY_IDX(SPI_PINCTRL_NODE, psels, 0) & 0x3F)
* #define MISO_PIN (DT_PROP_BY_IDX(SPI_PINCTRL_NODE, psels, 1) & 0x3F)
* #define MOSI_PIN (DT_PROP_BY_IDX(SPI_PINCTRL_NODE, psels, 2) & 0x3F)
*/
&pinctrl {
spi_dummy: spi_dummy {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 0)>,
<NRF_PSEL(SPIM_MISO, 0, 0)>,
<NRF_PSEL(SPIM_MOSI, 0, 0)>;
};
};
spi_master_default: spi_master_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 0)>,
<NRF_PSEL(SPIM_MISO, 0, 0)>,
<NRF_PSEL(SPIM_MOSI, 0, 0)>;
};
};
spi_slave_dummy: spi_slave_dummy {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 0)>,
<NRF_PSEL(SPIM_MISO, 0, 0)>,
<NRF_PSEL(SPIM_MOSI, 0, 0)>;
};
};
i2c_master_dummy: i2c_master_dummy {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 0)>,
<NRF_PSEL(TWIM_SCL, 0, 0)>;
};
};
i2c_slave_dummy: i2c_slave_dummy {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 0)>,
<NRF_PSEL(TWIM_SCL, 0, 0)>;
};
};
};

33
common/common.cmake Normal file
View File

@@ -0,0 +1,33 @@
# File containing common functions, macros and variables used across all examples.
# This file should be included in each CMakeLists.txt if compiled with west tool under Zephyr.
# Add common Kconfig file to project.
list(APPEND CONF_FILE "${CMAKE_CURRENT_LIST_DIR}/common.conf")
# Add project Kconfig file if it exists.
set(PRJ_CONF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/prj.conf")
if(EXISTS ${PRJ_CONF_FILE})
list(APPEND CONF_FILE ${PRJ_CONF_FILE})
endif()
# Macro adding overlay file and Kconfig file for specified board in given directory.
# If board-specific files have been found they are added to DTC_OVERLAY_FILE and CONF_FILE
# symbols that are used in west build system.
macro(GET_DEVICE_CONFIG_FILES BOARD BOARDS_DIR)
if(NOT IS_ABSOLUTE BOARDS_DIR)
set(_BOARDS_DIR ${CMAKE_CURRENT_LIST_DIR}/${BOARDS_DIR})
get_filename_component(BOARDS_DIR_ABSOLUTE "${_BOARDS_DIR}" ABSOLUTE)
else()
set(BOARDS_DIR_ABSOLUTE {BOARDS_DIR})
endif()
set(OVERLAY_FILE "${BOARDS_DIR_ABSOLUTE}/${BOARD}.overlay")
if(EXISTS ${OVERLAY_FILE})
list(APPEND DTC_OVERLAY_FILE "${OVERLAY_FILE}")
endif()
set(CONFIG_FILE "${BOARDS_DIR_ABSOLUTE}/${BOARD}.conf")
if(EXISTS ${CONFIG_FILE})
list(APPEND CONF_FILE "${CONFIG_FILE}")
endif()
endmacro()

4
common/common.conf Normal file
View File

@@ -0,0 +1,4 @@
CONFIG_LOG=y
CONFIG_BOOT_BANNER=n
CONFIG_ASSERT=y
CONFIG_LOG_PROCESS_THREAD=n

109
common/nrfx_example.h Normal file
View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 2022 - 2024, Nordic Semiconductor ASA
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NRFX_EXAMPLE_H__
#define NRFX_EXAMPLE_H__
#if defined(__ZEPHYR__)
#include <zephyr/logging/log_ctrl.h>
#define NRFX_EXAMPLE_LOG_INIT() LOG_INIT()
#define NRFX_EXAMPLE_LOG_PROCESS() while (LOG_PROCESS())
#else
#define NRFX_EXAMPLE_LOG_INIT()
#define NRFX_EXAMPLE_LOG_PROCESS()
#endif
#if defined(NRF52_SERIES)
#define LOOPBACK_PIN_1A 3
#define LOOPBACK_PIN_1B 31
#define LOOPBACK_PIN_2A 4
#define LOOPBACK_PIN_2B 30
#define LOOPBACK_PIN_3A 28
#define LOOPBACK_PIN_3B 29
#define LOOPBACK_PIN_4A 26
#define LOOPBACK_PIN_4B 27
#define ANALOG_INPUT_A0 1
#define ANALOG_INPUT_A1 2
#define ANALOG_INPUT_A2 4
#if defined(NRF52832_XXAA) || defined (NRF52832_XXAB)
#define LED1_PIN 17
#define LED2_PIN 18
#define LED3_PIN 19
#define LED4_PIN 20
#else
#define LED1_PIN 13
#define LED2_PIN 14
#define LED3_PIN 15
#define LED4_PIN 16
#endif
#elif defined(NRF53_SERIES)
#define LOOPBACK_PIN_1A 4
#define LOOPBACK_PIN_1B 26
#define LOOPBACK_PIN_2A 5
#define LOOPBACK_PIN_2B 25
#define LOOPBACK_PIN_3A 6
#define LOOPBACK_PIN_3B 7
#define LOOPBACK_PIN_4A 34
#define LOOPBACK_PIN_4B 35
#define ANALOG_INPUT_A0 0
#define ANALOG_INPUT_A1 1
#define ANALOG_INPUT_A2 2
#define LED1_PIN 28
#define LED2_PIN 29
#define LED3_PIN 30
#define LED4_PIN 31
#elif defined(NRF91_SERIES)
#define LOOPBACK_PIN_1A 14
#define LOOPBACK_PIN_1B 19
#define LOOPBACK_PIN_2A 15
#define LOOPBACK_PIN_2B 18
#define LOOPBACK_PIN_3A 16
#define LOOPBACK_PIN_3B 17
#define LOOPBACK_PIN_4A 30
#define LOOPBACK_PIN_4B 31
#define ANALOG_INPUT_A0 1
#define ANALOG_INPUT_A1 2
#define ANALOG_INPUT_A2 3
#define LED1_PIN 2
#define LED2_PIN 3
#define LED3_PIN 4
#define LED4_PIN 5
#else
#error "Unknown device."
#endif
#define ANALOG_INPUT_TO_SAADC_AIN(x) ((x) + 1)
#define ANALOG_INPUT_TO_COMP_AIN(x) (x)
#endif // NRFX_EXAMPLE_H__