nrfx: Use actual nrfx instead of manually modified files
Warning. This commit breaks backwards compatibility with Zephyr <= 2.4.0. With nrfx 2.3.0 it is possible to include the MDK files on non-ARM platforms. As the MDK has a depenency to cmsis core files, a simple mocked core_cm4.h has been provided. By defining NRF_DECLARE_ONLY and NRF_STATIC_INLINE to nothing, no functions are inlined. This ensures that it is possible to mock the peripherals. For a non-zephyr build, the application must provide the environment varianble NRFX_BASE. The user of the nRF MDK or nrfx must ensure that the peripheral pointers are redefined before they are used. This is done in nrfx_bsim_redef.h. Include this header after including nrf.h or similar. When using nrfx, this inclusion can be placed in nrfx_glue.h For non-zephyr builds, a nrfx_config and nrfx_glue is provided. Other builds should include nrfx_config_bsim.h and nrfx_glue_bsim.h in their config and glue files. The original implementation of the HAL APIs from the real nrfx is included in `nrf_hal_originals.c`. All these functions are labelled as weak, so they can be replaced as needed with new definition in `src/nrfx/hal/` This removes the need for duplicating code. Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
parent
401fa4f7df
commit
71a8a9ef08
|
@ -22,14 +22,12 @@ if(CONFIG_BOARD_NRF52_BSIM)
|
|||
# module, so that the local modified versions of nrfx files are used instead
|
||||
# of those from the original nrfx.
|
||||
target_include_directories(zephyr_interface BEFORE INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/hal/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/mdk/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/mdk_replacements
|
||||
)
|
||||
|
||||
zephyr_include_directories(
|
||||
src/HW_models/
|
||||
src/nrfx/nrfx_replacements
|
||||
)
|
||||
|
||||
zephyr_library()
|
||||
|
@ -44,7 +42,6 @@ if(CONFIG_BOARD_NRF52_BSIM)
|
|||
$ENV{BSIM_COMPONENTS_PATH}/ext_2G4_libPhyComv1/src/
|
||||
$ENV{BSIM_COMPONENTS_PATH}/libRandv2/src/
|
||||
src/HW_models/
|
||||
src/nrfx/
|
||||
)
|
||||
|
||||
endif()
|
||||
|
|
14
Makefile
14
Makefile
|
@ -8,12 +8,21 @@ include ${BSIM_BASE_PATH}/common/pre.make.inc
|
|||
|
||||
SRCS:=$(shell find src/ -name "*.c")
|
||||
|
||||
ifndef NRFX_BASE
|
||||
$(error NRFX_BASE must be set to the nrfx checkout folder)
|
||||
endif
|
||||
|
||||
INCLUDES:=-I${libUtilv1_COMP_PATH}/src/ \
|
||||
-I${libPhyComv1_COMP_PATH}/src/ \
|
||||
-I${2G4_libPhyComv1_COMP_PATH}/src \
|
||||
-I${libRandv2_COMP_PATH}/src/ \
|
||||
-Isrc/nrfx/mdk_replacements \
|
||||
-Isrc/HW_models/ \
|
||||
-Isrc/nrfx/
|
||||
-Isrc/nrfx_config \
|
||||
-Isrc/nrfx/nrfx_replacements \
|
||||
-I${NRFX_BASE} \
|
||||
-I${NRFX_BASE}/mdk
|
||||
|
||||
|
||||
LIB_NAME:=libNRF52_hw_models.32
|
||||
A_LIBS:=
|
||||
|
@ -25,7 +34,8 @@ ARCH:=-m32
|
|||
WARNINGS:=-Wall -pedantic
|
||||
COVERAGE:=
|
||||
CFLAGS:=${ARCH} ${DEBUG} ${OPT} ${WARNINGS} -MMD -MP -std=c11 \
|
||||
${INCLUDES} -fdata-sections -ffunction-sections
|
||||
${INCLUDES} -fdata-sections -ffunction-sections \
|
||||
-DNRF52832_XXAA
|
||||
LDFLAGS:=${ARCH} ${COVERAGE}
|
||||
CPPFLAGS:=
|
||||
|
||||
|
|
|
@ -1,11 +1,26 @@
|
|||
**Models of some of the HW present in a NRF52xxx.**<br>
|
||||
Where relevant differences exist, these models try to align with a NRF52382.
|
||||
|
||||
This repo contains both models of the NRF52 HW as well as a replacement nRFx
|
||||
HAL.<br>
|
||||
This replacement HAL is a modified version of the real nRFx to be used with
|
||||
these models.
|
||||
With it, the Zephyr SW should work without needing further changes.
|
||||
This repo contains both models of the NRF52 HW as well as some replacement nrfx
|
||||
HAL functions. When used in combination with the real nrfx, these should enable code
|
||||
meant for the nrfx to run without needing further changes.
|
||||
This includes Zephyr SW.
|
||||
|
||||
When compiling this component using the provided Makefile (not with Zephyr's build system),
|
||||
the environment variable `NRFX_BASE` must be set to the path where a nrfx has been cloned.
|
||||
The nrfx must be at least version 2.3.0.
|
||||
So for example, if the nrfx has been cloned as:
|
||||
|
||||
```
|
||||
cd /some_path/nrfx/
|
||||
git clone git@github.com:NordicSemiconductor/nrfx.git .
|
||||
```
|
||||
`NRFX_BASE` must be set as:
|
||||
|
||||
```
|
||||
export NRFX_BASE=/some_path/nrfx/
|
||||
```
|
||||
|
||||
See the [nrfx/hal/README.md](../src/nrfx/hal/README.md) for more details.
|
||||
|
||||
This models can be used directly with
|
||||
|
|
|
@ -86,7 +86,7 @@ thread into the HW models thread.
|
|||
|
||||
### The SW registers IF
|
||||
|
||||
Each perihperal model which has HW registers accessible by SW, presents
|
||||
Each peripheral model which has HW registers accessible by SW, presents
|
||||
a structure which matches those registers' layout.
|
||||
This structure will be allocated somewhere in the process memory, but certainly
|
||||
not in the same address as in the real HW.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_AAR_H
|
||||
#define _NRF_HW_MODEL_AAR_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_AES_CCM_H
|
||||
#define _NRF_HW_MODEL_AES_CCM_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_AES_ECB_H
|
||||
#define _NRF_HW_MODEL_AES_ECB_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_CLOCK_H
|
||||
#define _NRF_HW_MODEL_CLOCK_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_FICR_H
|
||||
#define _NRF_HW_MODEL_FICR_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_GPIO_H
|
||||
#define _NRF_HW_MODEL_GPIO_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_GPIOTE_H
|
||||
#define _NRF_HW_MODEL_GPIOTE_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_NVMC_H
|
||||
#define _NRF_HW_MODEL_NVMC_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_POWER_H
|
||||
#define _NRF_HW_MODEL_POWER_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_PPI_H
|
||||
#define _NRF_HW_MODEL_PPI_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_RADIO_H
|
||||
#define _NRF_RADIO_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_RNG_H
|
||||
#define _NRF_HW_MODEL_RNG_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_RTC_H
|
||||
#define _NRF_HW_MODEL_RTC_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_TEMP_H
|
||||
#define _NRF_HW_MODEL_TEMP_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef _NRF_HW_MODEL_TIMER_H
|
||||
#define _NRF_HW_MODEL_TIMER_H
|
||||
|
||||
#include "NRF_regs.h"
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mocks the CMSIS dependency of the nRF MDK headers.
|
||||
*/
|
||||
|
||||
#ifndef CORE_CM4__
|
||||
#define CORE_CM4__
|
||||
|
||||
#define __I
|
||||
#define __IO
|
||||
#define __O
|
||||
|
||||
/**
|
||||
* The model of the CPU & IRQ controller driver must provide
|
||||
* these functions below. These HW models do not provide them
|
||||
*/
|
||||
extern void __WFE(void);
|
||||
extern void __SEV(void);
|
||||
extern void NVIC_SetPendingIRQ(IRQn_Type IRQn);
|
||||
extern void NVIC_ClearPendingIRQ(IRQn_Type IRQn);
|
||||
|
||||
/* Implement the following ARM intrinsics as no-op:
|
||||
* - ARM Data Synchronization Barrier
|
||||
* - ARM Data Memory Synchronization Barrier
|
||||
* - ARM Instruction Synchronization Barrier
|
||||
* - ARM No Operation
|
||||
*/
|
||||
#ifndef __DMB
|
||||
#define __DMB()
|
||||
#endif
|
||||
|
||||
#ifndef __DSB
|
||||
#define __DSB()
|
||||
#endif
|
||||
|
||||
#ifndef __ISB
|
||||
#define __ISB()
|
||||
#endif
|
||||
|
||||
#ifndef __NOP
|
||||
#define __NOP()
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,14 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Oticon A/S
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nrfx.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "nrfx_common.h"
|
||||
|
||||
unsigned int nrfx_peripheral_from_base_address(void const * p_reg){
|
||||
IRQn_Type nrfx_get_irq_number(void const * p_reg){
|
||||
/*
|
||||
* Peripheral numbers match interrupt numbers
|
||||
* See https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/memory.html?cp=3_1_0_7_2#memorymap
|
||||
|
|
|
@ -1,261 +0,0 @@
|
|||
/*
|
||||
* Part of the real nrf_common.h from Nordic's NRFx drivers
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2019 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRFX_COMMON_H__
|
||||
#define BS_NRFX_COMMON_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../hal/nrf_soc_if.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Suppress use of anomaly workarounds in nrfx drivers that would directly
|
||||
* access hardware registers.
|
||||
*/
|
||||
#define USE_WORKAROUND_FOR_ANOMALY_132 0
|
||||
|
||||
/*
|
||||
* When nrfx drivers are compiled for a real SoC, this macro is inherited from
|
||||
* CMSIS. The below definition is needed when those drivers are compiled for
|
||||
* the simulated target.
|
||||
*/
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
|
||||
#ifndef NRFX_STATIC_INLINE
|
||||
#ifdef NRFX_DECLARE_ONLY
|
||||
#define NRFX_STATIC_INLINE
|
||||
#else
|
||||
#define NRFX_STATIC_INLINE static inline
|
||||
#endif
|
||||
#endif // NRFX_STATIC_INLINE
|
||||
|
||||
#ifndef NRF_STATIC_INLINE
|
||||
#ifdef NRF_DECLARE_ONLY
|
||||
#define NRF_STATIC_INLINE
|
||||
#else
|
||||
#define NRF_STATIC_INLINE static inline
|
||||
#endif
|
||||
#endif // NRF_STATIC_INLINE
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_common Common module
|
||||
* @{
|
||||
* @ingroup nrfx
|
||||
* @brief Common module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Macro for checking if the specified identifier is defined and it has
|
||||
* a non-zero value.
|
||||
*
|
||||
* Normally, preprocessors treat all undefined identifiers as having the value
|
||||
* zero. However, some tools, like static code analyzers, can issue a warning
|
||||
* when such identifier is evaluated. This macro gives the possibility to suppress
|
||||
* such warnings only in places where this macro is used for evaluation, not in
|
||||
* the whole analyzed code.
|
||||
*/
|
||||
#define NRFX_CHECK(module_enabled) (module_enabled)
|
||||
|
||||
/**
|
||||
* @brief Macro for concatenating two tokens in macro expansion.
|
||||
*
|
||||
* @note This macro is expanded in two steps so that tokens given as macros
|
||||
* themselves are fully expanded before they are merged.
|
||||
*
|
||||
* @param[in] p1 First token.
|
||||
* @param[in] p2 Second token.
|
||||
*
|
||||
* @return The two tokens merged into one, unless they cannot together form
|
||||
* a valid token (in such case, the preprocessor issues a warning and
|
||||
* does not perform the concatenation).
|
||||
*
|
||||
* @sa NRFX_CONCAT_3
|
||||
*/
|
||||
#define NRFX_CONCAT_2(p1, p2) NRFX_CONCAT_2_(p1, p2)
|
||||
|
||||
/** @brief Internal macro used by @ref NRFX_CONCAT_2 to perform the expansion in two steps. */
|
||||
#define NRFX_CONCAT_2_(p1, p2) p1 ## p2
|
||||
|
||||
/**
|
||||
* @brief Macro for concatenating three tokens in macro expansion.
|
||||
*
|
||||
* @note This macro is expanded in two steps so that tokens given as macros
|
||||
* themselves are fully expanded before they are merged.
|
||||
*
|
||||
* @param[in] p1 First token.
|
||||
* @param[in] p2 Second token.
|
||||
* @param[in] p3 Third token.
|
||||
*
|
||||
* @return The three tokens merged into one, unless they cannot together form
|
||||
* a valid token (in such case, the preprocessor issues a warning and
|
||||
* does not perform the concatenation).
|
||||
*
|
||||
* @sa NRFX_CONCAT_2
|
||||
*/
|
||||
#define NRFX_CONCAT_3(p1, p2, p3) NRFX_CONCAT_3_(p1, p2, p3)
|
||||
|
||||
/** @brief Internal macro used by @ref NRFX_CONCAT_3 to perform the expansion in two steps. */
|
||||
#define NRFX_CONCAT_3_(p1, p2, p3) p1 ## p2 ## p3
|
||||
|
||||
/**
|
||||
* @brief Macro for performing rounded integer division (as opposed to
|
||||
* truncating the result).
|
||||
*
|
||||
* @param[in] a Numerator.
|
||||
* @param[in] b Denominator.
|
||||
*
|
||||
* @return Rounded (integer) result of dividing @c a by @c b.
|
||||
*/
|
||||
#define NRFX_ROUNDED_DIV(a, b) (((a) + ((b) / 2)) / (b))
|
||||
|
||||
/**
|
||||
* @brief Macro for performing integer division, making sure the result is rounded up.
|
||||
*
|
||||
* @details A typical use case for this macro is to compute the number of objects
|
||||
* with size @c b required to hold @c a number of bytes.
|
||||
*
|
||||
* @param[in] a Numerator.
|
||||
* @param[in] b Denominator.
|
||||
*
|
||||
* @return Integer result of dividing @c a by @c b, rounded up.
|
||||
*/
|
||||
#define NRFX_CEIL_DIV(a, b) ((((a) - 1) / (b)) + 1)
|
||||
|
||||
/**
|
||||
* @brief Macro for getting the number of elements in an array.
|
||||
*
|
||||
* @param[in] array Name of the array.
|
||||
*
|
||||
* @return Array element count.
|
||||
*/
|
||||
#define NRFX_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
/**
|
||||
* @brief Macro for getting the offset (in bytes) from the beginning of a structure
|
||||
* of the specified type to its specified member.
|
||||
*
|
||||
* @param[in] type Structure type.
|
||||
* @param[in] member Structure member whose offset is searched for.
|
||||
*
|
||||
* @return Member offset in bytes.
|
||||
*/
|
||||
#define NRFX_OFFSETOF(type, member) ((size_t)&(((type *)0)->member))
|
||||
|
||||
/**
|
||||
* @brief Macro for waiting until condition is met.
|
||||
*
|
||||
* @param[in] condition Condition to meet.
|
||||
* @param[in] attempts Maximum number of condition checks. Must not be 0.
|
||||
* @param[in] delay_us Delay between consecutive checks, in microseconds.
|
||||
* @param[out] result Boolean variable to store the result of the wait process.
|
||||
* Set to true if the condition is met or false otherwise.
|
||||
*/
|
||||
#define NRFX_WAIT_FOR(condition, attempts, delay_us, result) \
|
||||
do { \
|
||||
result = false; \
|
||||
uint32_t remaining_attempts = (attempts); \
|
||||
do { \
|
||||
if (condition) \
|
||||
{ \
|
||||
result = true; \
|
||||
break; \
|
||||
} \
|
||||
NRFX_DELAY_US(delay_us); \
|
||||
} while (--remaining_attempts); \
|
||||
} while(0)
|
||||
|
||||
unsigned int nrfx_peripheral_from_base_address(void const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Macro for getting the ID number of the specified peripheral.
|
||||
*
|
||||
* For peripherals in Nordic SoCs, there is a direct relationship between their
|
||||
* ID numbers and their base addresses. See the chapter "Peripheral interface"
|
||||
* (section "Peripheral ID") in the Product Specification.
|
||||
*
|
||||
* @param[in] base_addr Peripheral base address or pointer.
|
||||
*
|
||||
* @return ID number associated with the specified peripheral.
|
||||
*/
|
||||
#define NRFX_PERIPHERAL_ID_GET(base_addr) (uint8_t)(nrfx_peripheral_from_base_address(base_addr))
|
||||
|
||||
/**
|
||||
* @brief Macro for getting the interrupt number assigned to a specific
|
||||
* peripheral.
|
||||
*
|
||||
* For peripherals in Nordic SoCs, the IRQ number assigned to a peripheral is
|
||||
* equal to its ID number. See the chapter "Peripheral interface" (sections
|
||||
* "Peripheral ID" and "Interrupts") in the Product Specification.
|
||||
*
|
||||
* @param[in] base_addr Peripheral base address or pointer.
|
||||
*
|
||||
* @return Interrupt number associated with the specified peripheral.
|
||||
*/
|
||||
#define NRFX_IRQ_NUMBER_GET(base_addr) NRFX_PERIPHERAL_ID_GET(base_addr)
|
||||
|
||||
/**
|
||||
* @brief IRQ handler type.
|
||||
*/
|
||||
typedef void (*nrfx_irq_handler_t)(void);
|
||||
|
||||
NRF_STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object)
|
||||
{
|
||||
return ((((uint32_t)p_object) & 0x3u) == 0u);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg)
|
||||
{
|
||||
return (IRQn_Type)NRFX_IRQ_NUMBER_GET(p_reg);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRFX_COMMON_H__ */
|
|
@ -1,7 +1,8 @@
|
|||
## nRFx HAL
|
||||
|
||||
The HAL provided with this models is a modified version of the
|
||||
[real nRFx HAL](https://github.com/NordicSemiconductor/nrfx/)
|
||||
The HAL source files provided with these models implement
|
||||
some modifications to the HAL interface [real nRFx HAL](https://github.com/NordicSemiconductor/nrfx/)
|
||||
needed due to the HW models peculiarities.
|
||||
Its main purpose is to allow unmodified Zephyr code to run directly
|
||||
using this repository HW models.
|
||||
|
||||
|
@ -23,6 +24,10 @@ There is two main differences in this HAL compared to the real one:
|
|||
function `nrf_rng_regw_sideeffects_TASK_START()` needs to be called.
|
||||
This replacement HAL functions take care of that.
|
||||
|
||||
The original implementation of the HAL APIs from the real nrfx is included in `nrf_hal_originals.c`.
|
||||
All these functions are labelled as weak, so they can be replaced as needed with new definition in `src/nrfx/hal/`
|
||||
This removes the need for duplicating code.
|
||||
|
||||
Note that this HAL version should be, wherever possible, a copy of the
|
||||
official nRFx HAL, with only minor differences due to what is described above.
|
||||
And normally most differences between the official version and this one will be
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_aar.h"
|
||||
#include "hal/nrf_aar.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_AAR.h"
|
||||
|
||||
|
||||
void nrf_aar_int_enable(NRF_AAR_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->INTENSET = mask;
|
||||
|
|
|
@ -1,237 +0,0 @@
|
|||
/**
|
||||
* Part of the real nrf_aar.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_AAR_H__
|
||||
#define BS_NRF_AAR_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief AAR events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_AAR_EVENT_END = offsetof(NRF_AAR_Type, EVENTS_END), ///< Address resolution procedure complete.
|
||||
NRF_AAR_EVENT_RESOLVED = offsetof(NRF_AAR_Type, EVENTS_RESOLVED), ///< Address resolved.
|
||||
NRF_AAR_EVENT_NOTRESOLVED = offsetof(NRF_AAR_Type, EVENTS_NOTRESOLVED), ///< Address not resolved.
|
||||
} nrf_aar_event_t;
|
||||
|
||||
/** @brief AAR tasks. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_AAR_TASK_START = offsetof(NRF_AAR_Type, TASKS_START), ///< Start address resolution procedure.
|
||||
NRF_AAR_TASK_STOP = offsetof(NRF_AAR_Type, TASKS_STOP), ///< Stop address resolution procedure.
|
||||
} nrf_aar_task_t;
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the AAR event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true Event is set.
|
||||
* @retval false Event is not set.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_aar_event_check(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified AAR event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_event_clear(NRF_AAR_Type * p_reg,
|
||||
nrf_aar_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
void nrf_aar_int_disable(NRF_AAR_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for starting an AAR task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
void nrf_aar_task_trigger(NRF_AAR_Type * p_reg, nrf_aar_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling AAR.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_enable(NRF_AAR_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling AAR.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_disable(NRF_AAR_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the Identity Resolving Keys (IRK) data structure.
|
||||
*
|
||||
* The size of the provided data structure must correspond to the number of keys available.
|
||||
* Each key occupies 16 bytes.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] irk_ptr Pointer to the IRK data structure. Must point to the Data RAM region.
|
||||
*
|
||||
* @sa nrf_aar_irk_number_set
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * irk_ptr);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the number of keys available in the Identity Resolving Keys
|
||||
* data structure.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] irk_num Number of keys available in the IRK data structure. Maximum is 16.
|
||||
* Must correspond to the size of the provided IRK data structure.
|
||||
*
|
||||
* @sa nrf_aar_irk_pointer_set
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_number_set(NRF_AAR_Type * p_reg, uint8_t irk_num);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the resolvable address.
|
||||
*
|
||||
* The resolvable address must consist of 6 bytes.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] addr_ptr Pointer to the address to resolve using the available IRK keys.
|
||||
* Must point to the Data RAM region.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_addr_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * addr_ptr);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the scratch data area.
|
||||
*
|
||||
* The scratch data area is used for temporary storage during the address resolution procedure.
|
||||
* A space of minimum 3 bytes must be reserved for the scratch data area.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] scratch_ptr Pointer to the scratch data area. Must point to the Data RAM region.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_aar_scratch_pointer_set(NRF_AAR_Type * p_reg, uint8_t * scratch_ptr);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the index of the Identity Resolving Key that was used
|
||||
* the last time an address was resolved.
|
||||
*
|
||||
* This function can be used to get the IRK index that matched the resolvable address,
|
||||
* provided that @ref NRF_AAR_EVENT_RESOLVED occured. Otherwise, it will return
|
||||
* the index of the last IRK stored in the IRK data structure.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return The index of the IRK that was used the last time an address was resolved.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_aar_resolution_status_get(NRF_AAR_Type const * p_reg);
|
||||
|
||||
/*****************************/
|
||||
/* Inlined functions bodies: */
|
||||
/*****************************/
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_aar_event_check(NRF_AAR_Type const * p_reg,
|
||||
nrf_aar_event_t aar_event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_event_clear(NRF_AAR_Type * p_reg,
|
||||
nrf_aar_event_t aar_event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event)) = 0;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_enable(NRF_AAR_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = AAR_ENABLE_ENABLE_Enabled << AAR_ENABLE_ENABLE_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_disable(NRF_AAR_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = AAR_ENABLE_ENABLE_Disabled << AAR_ENABLE_ENABLE_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * irk_ptr)
|
||||
{
|
||||
p_reg->IRKPTR = (uint32_t)irk_ptr;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_irk_number_set(NRF_AAR_Type * p_reg, uint8_t irk_num)
|
||||
{
|
||||
p_reg->NIRK = irk_num;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_addr_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * addr_ptr)
|
||||
{
|
||||
p_reg->ADDRPTR = (uint32_t)addr_ptr;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_aar_scratch_pointer_set(NRF_AAR_Type * p_reg, uint8_t * scratch_ptr)
|
||||
{
|
||||
p_reg->SCRATCHPTR = (uint32_t)scratch_ptr;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_aar_resolution_status_get(NRF_AAR_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)(p_reg->STATUS);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_AAR_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_ccm.h"
|
||||
#include "hal/nrf_ccm.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_AES_CCM.h"
|
||||
|
||||
|
|
|
@ -1,312 +0,0 @@
|
|||
/*
|
||||
* Part of the real nrf_ccm.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_CCM_H__
|
||||
#define BS_NRF_CCM_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief CCM tasks.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*lint -save -e30*/
|
||||
NRF_CCM_TASK_KSGEN = offsetof(NRF_CCM_Type, TASKS_KSGEN), ///< Start generation of key-stream.
|
||||
NRF_CCM_TASK_CRYPT = offsetof(NRF_CCM_Type, TASKS_CRYPT), ///< Start encryption/decryption.
|
||||
NRF_CCM_TASK_STOP = offsetof(NRF_CCM_Type, TASKS_STOP), ///< Stop encryption/decryption.
|
||||
#if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CCM_TASK_RATEOVERRIDE = offsetof(NRF_CCM_Type, TASKS_RATEOVERRIDE), ///< Override DATARATE setting in MODE register.
|
||||
#endif
|
||||
/*lint -restore*/
|
||||
} nrf_ccm_task_t;
|
||||
|
||||
/** @brief CCM events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CCM_EVENT_ENDKSGEN = offsetof(NRF_CCM_Type, EVENTS_ENDKSGEN), ///< Keystream generation complete.
|
||||
NRF_CCM_EVENT_ENDCRYPT = offsetof(NRF_CCM_Type, EVENTS_ENDCRYPT), ///< Encrypt/decrypt complete.
|
||||
NRF_CCM_EVENT_ERROR = offsetof(NRF_CCM_Type, EVENTS_ERROR), ///< CCM error event.
|
||||
} nrf_ccm_event_t;
|
||||
|
||||
/** @brief CCM interrupts. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CCM_INT_ENDKSGEN_MASK = CCM_INTENSET_ENDKSGEN_Msk, ///< Interrupt on ENDKSGEN event.
|
||||
NRF_CCM_INT_ENDCRYPT_MASK = CCM_INTENSET_ENDCRYPT_Msk, ///< Interrupt on ENDCRYPT event.
|
||||
NRF_CCM_INT_ERROR_MASK = CCM_INTENSET_ERROR_Msk, ///< Interrupt on ERROR event.
|
||||
} nrf_ccm_int_mask_t;
|
||||
|
||||
/** @brief CCM modes of operation. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CCM_MODE_ENCRYPTION = CCM_MODE_MODE_Encryption, ///< Encryption mode.
|
||||
NRF_CCM_MODE_DECRYPTION = CCM_MODE_MODE_Decryption, ///< Decryption mode.
|
||||
} nrf_ccm_mode_t;
|
||||
|
||||
#if defined(CCM_MODE_DATARATE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief CCM data rates. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CCM_DATARATE_1M = CCM_MODE_DATARATE_1Mbit, ///< 1 Mbps.
|
||||
NRF_CCM_DATARATE_2M = CCM_MODE_DATARATE_2Mbit, ///< 2 Mbps.
|
||||
#if defined(CCM_MODE_DATARATE_125Kbps) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CCM_DATARATE_125K = CCM_MODE_DATARATE_125Kbps, ///< 125 Kbps.
|
||||
#endif
|
||||
#if defined(CCM_MODE_DATARATE_500Kbps) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CCM_DATARATE_500K = CCM_MODE_DATARATE_500Kbps, ///< 500 Kbps.
|
||||
#endif
|
||||
} nrf_ccm_datarate_t;
|
||||
#endif // defined(CCM_MODE_DATARATE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(CCM_MODE_LENGTH_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief CCM packet length options. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CCM_LENGTH_DEFAULT = CCM_MODE_LENGTH_Default, ///< Default length.
|
||||
NRF_CCM_LENGTH_EXTENDED = CCM_MODE_LENGTH_Extended, ///< Extended length.
|
||||
} nrf_ccm_length_t;
|
||||
#endif // defined(CCM_MODE_LENGTH_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/** @brief CCM configuration. */
|
||||
typedef struct {
|
||||
nrf_ccm_mode_t mode; ///< Operation mode.
|
||||
#if defined(CCM_MODE_DATARATE_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_ccm_datarate_t datarate; ///< Data rate.
|
||||
#endif
|
||||
#if defined(CCM_MODE_LENGTH_Pos) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_ccm_length_t length; ///< Lenght of the CCM packet.
|
||||
#endif
|
||||
} nrf_ccm_config_t;
|
||||
|
||||
void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a specific CCM event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of a specific CCM event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be enabled.
|
||||
*/
|
||||
void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupts to be disabled.
|
||||
*/
|
||||
void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the CCM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the CCM peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the CCM peripheral configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_config Pointer to the structure with configuration to be set.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_config_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the MIC check result.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The MIC check passed.
|
||||
* @retval false The MIC check failed.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the data structure
|
||||
* holding the AES key and the CCM NONCE vector.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_data Pointer to the data structure.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the input data pointer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_data Input data pointer.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the output data pointer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_data Output data pointer.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the scratch area used for
|
||||
* temporary storage.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_area Pointer to the scratch area.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_area);
|
||||
|
||||
/*****************************/
|
||||
/* Inlined functions bodies: */
|
||||
/*****************************/
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
|
||||
nrf_ccm_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (CCM_ENABLE_ENABLE_Enabled << CCM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg)
|
||||
{
|
||||
p_reg->ENABLE = (CCM_ENABLE_ENABLE_Disabled << CCM_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
|
||||
nrf_ccm_config_t const * p_config)
|
||||
{
|
||||
p_reg->MODE = (((uint32_t)p_config->mode << CCM_MODE_MODE_Pos) |
|
||||
#if defined(CCM_MODE_DATARATE_Pos)
|
||||
((uint32_t)p_config->datarate << CCM_MODE_DATARATE_Pos) |
|
||||
#endif
|
||||
#if defined(CCM_MODE_LENGTH_Pos)
|
||||
((uint32_t)p_config->length << CCM_MODE_LENGTH_Pos) |
|
||||
#endif
|
||||
0);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg)
|
||||
{
|
||||
return (bool)(p_reg->MICSTATUS);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
{
|
||||
p_reg->CNFPTR = (uint32_t)p_data;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
{
|
||||
p_reg->INPTR = (uint32_t)p_data;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_data)
|
||||
{
|
||||
p_reg->OUTPTR = (uint32_t)p_data;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
|
||||
uint32_t const * p_area)
|
||||
{
|
||||
p_reg->SCRATCHPTR = (uint32_t)p_area;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_CCM_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_clock.h"
|
||||
#include "hal/nrf_clock.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_CLOCK.h"
|
||||
|
||||
|
@ -46,8 +46,3 @@ void nrf_clock_task_trigger(NRF_CLOCK_Type * p_reg, nrf_clock_task_t task)
|
|||
bs_trace_warning_line_time("Not supported task started in nrf_clock, %d\n", task);
|
||||
}
|
||||
}
|
||||
|
||||
void nrf_clock_cal_timer_timeout_set(NRF_CLOCK_Type * p_reg, uint32_t interval)
|
||||
{
|
||||
/*We don't want to model clock calibration as per now*/
|
||||
}
|
||||
|
|
|
@ -1,508 +0,0 @@
|
|||
/*
|
||||
* Part of the real nrf_clock.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_CLOCK_H__
|
||||
#define BS_NRF_CLOCK_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_clock_hal Clock HAL
|
||||
* @{
|
||||
* @ingroup nrf_clock
|
||||
* @brief Hardware access layer for managing the CLOCK peripheral.
|
||||
*
|
||||
* This code can be used to managing low-frequency clock (LFCLK) and the high-frequency clock
|
||||
* (HFCLK) settings.
|
||||
*/
|
||||
|
||||
#define NRF_CLOCK_TASK_TRIGGER (1UL)
|
||||
#define NRF_CLOCK_EVENT_CLEAR (0UL)
|
||||
|
||||
#if defined(NRF52810_XXAA) || \
|
||||
defined(NRF52832_XXAA) || defined(NRF52832_XXAB) || \
|
||||
defined(NRF52840_XXAA)
|
||||
// Enable support for external LFCLK sources. Read more in the Product Specification.
|
||||
#define NRF_CLOCK_USE_EXTERNAL_LFCLK_SOURCES
|
||||
#endif
|
||||
|
||||
#if defined(CLOCK_CTIV_CTIV_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Presence of the Low Frequency Clock calibration.
|
||||
*
|
||||
* In some MCUs there is possibility to use LFCLK calibration.
|
||||
*/
|
||||
#define NRF_CLOCK_HAS_CALIBRATION 1
|
||||
#else
|
||||
#define NRF_CLOCK_HAS_CALIBRATION 0
|
||||
#endif // defined(CLOCK_CTIV_CTIV_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if (defined(CLOCK_INTENSET_HFCLK192MSTARTED_Msk) && !defined(NRF5340_XXAA_NETWORK)) \
|
||||
|| defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Presence of the 192 MHz clock. */
|
||||
#define NRF_CLOCK_HAS_HFCLK192M 1
|
||||
#else
|
||||
#define NRF_CLOCK_HAS_HFCLK192M 0
|
||||
#endif
|
||||
|
||||
#if (defined(CLOCK_INTENSET_HFCLKAUDIOSTARTED_Msk) && !defined(NRF5340_XXAA_NETWORK)) \
|
||||
|| defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Presence of the Audio clock. */
|
||||
#define NRF_CLOCK_HAS_HFCLKAUDIO 1
|
||||
#else
|
||||
#define NRF_CLOCK_HAS_HFCLKAUDIO 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Low-frequency clock sources.
|
||||
* @details Used by LFCLKSRC, LFCLKSTAT, and LFCLKSRCCOPY registers.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
#if defined(CLOCK_LFCLKSRC_SRC_RC) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_LFCLK_RC = CLOCK_LFCLKSRC_SRC_RC, /**< Internal 32 kHz RC oscillator. */
|
||||
#else
|
||||
NRF_CLOCK_LFCLK_RC = CLOCK_LFCLKSRC_SRC_LFRC, /**< Internal 32 kHz RC oscillator. */
|
||||
#endif
|
||||
|
||||
#if defined(CLOCK_LFCLKSRC_SRC_Xtal) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_LFCLK_Xtal = CLOCK_LFCLKSRC_SRC_Xtal, /**< External 32 kHz crystal. */
|
||||
#else
|
||||
NRF_CLOCK_LFCLK_Xtal = CLOCK_LFCLKSRC_SRC_LFXO, /**< External 32 kHz crystal. */
|
||||
#endif
|
||||
|
||||
#if defined(CLOCK_LFCLKSRC_SRC_Synth) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_LFCLK_Synth = CLOCK_LFCLKSRC_SRC_Synth, /**< Internal 32 kHz synthesizer from HFCLK system clock. */
|
||||
#endif
|
||||
#if defined(NRF_CLOCK_USE_EXTERNAL_LFCLK_SOURCES) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* External 32 kHz low swing signal. Used only with the LFCLKSRC register.
|
||||
* For the others @ref NRF_CLOCK_LFCLK_Xtal is returned for this setting.
|
||||
*/
|
||||
NRF_CLOCK_LFCLK_Xtal_Low_Swing = (CLOCK_LFCLKSRC_SRC_Xtal |
|
||||
(CLOCK_LFCLKSRC_EXTERNAL_Enabled << CLOCK_LFCLKSRC_EXTERNAL_Pos)),
|
||||
/**
|
||||
* External 32 kHz full swing signal. Used only with the LFCLKSRC register.
|
||||
* For the others @ref NRF_CLOCK_LFCLK_Xtal is returned for this setting.
|
||||
*/
|
||||
NRF_CLOCK_LFCLK_Xtal_Full_Swing = (CLOCK_LFCLKSRC_SRC_Xtal |
|
||||
(CLOCK_LFCLKSRC_BYPASS_Enabled << CLOCK_LFCLKSRC_BYPASS_Pos) |
|
||||
(CLOCK_LFCLKSRC_EXTERNAL_Enabled << CLOCK_LFCLKSRC_EXTERNAL_Pos)),
|
||||
#endif // defined(NRF_CLOCK_USE_EXTERNAL_LFCLK_SOURCES) || defined(__NRFX_DOXYGEN__)
|
||||
} nrf_clock_lfclk_t;
|
||||
|
||||
/** @brief High-frequency clock sources. */
|
||||
typedef enum
|
||||
{
|
||||
#if defined(CLOCK_HFCLKSTAT_SRC_RC) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_HFCLK_LOW_ACCURACY = CLOCK_HFCLKSTAT_SRC_RC, /**< Internal 16 MHz RC oscillator. */
|
||||
#endif
|
||||
#if defined(CLOCK_HFCLKSTAT_SRC_Xtal) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_HFCLK_HIGH_ACCURACY = CLOCK_HFCLKSTAT_SRC_Xtal /**< External 16 MHz/32 MHz crystal oscillator. */
|
||||
#else
|
||||
NRF_CLOCK_HFCLK_HIGH_ACCURACY = CLOCK_HFCLKSTAT_SRC_HFXO /**< External 32 MHz crystal oscillator. */
|
||||
#endif
|
||||
} nrf_clock_hfclk_t;
|
||||
|
||||
/** @brief Clock domains. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CLOCK_DOMAIN_LFCLK,
|
||||
NRF_CLOCK_DOMAIN_HFCLK,
|
||||
#if NRF_CLOCK_HAS_HFCLK192M
|
||||
NRF_CLOCK_DOMAIN_HFCLK192M,
|
||||
#endif
|
||||
#if NRF_CLOCK_HAS_HFCLKAUDIO
|
||||
NRF_CLOCK_DOMAIN_HFCLKAUDIO,
|
||||
#endif
|
||||
} nrf_clock_domain_t;
|
||||
|
||||
/**
|
||||
* @brief Trigger status of task LFCLKSTART/HFCLKSTART.
|
||||
* @details Used by LFCLKRUN and HFCLKRUN registers.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_CLOCK_START_TASK_NOT_TRIGGERED = CLOCK_LFCLKRUN_STATUS_NotTriggered, /**< Task LFCLKSTART/HFCLKSTART has not been triggered. */
|
||||
NRF_CLOCK_START_TASK_TRIGGERED = CLOCK_LFCLKRUN_STATUS_Triggered /**< Task LFCLKSTART/HFCLKSTART has been triggered. */
|
||||
} nrf_clock_start_task_status_t;
|
||||
|
||||
/** @brief Interrupts. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CLOCK_INT_HF_STARTED_MASK = CLOCK_INTENSET_HFCLKSTARTED_Msk, /**< Interrupt on HFCLKSTARTED event. */
|
||||
NRF_CLOCK_INT_LF_STARTED_MASK = CLOCK_INTENSET_LFCLKSTARTED_Msk, /**< Interrupt on LFCLKSTARTED event. */
|
||||
#if (NRF_CLOCK_HAS_CALIBRATION) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_INT_DONE_MASK = CLOCK_INTENSET_DONE_Msk, /**< Interrupt on DONE event. */
|
||||
NRF_CLOCK_INT_CTTO_MASK = CLOCK_INTENSET_CTTO_Msk /**< Interrupt on CTTO event. */
|
||||
#endif
|
||||
} nrf_clock_int_mask_t;
|
||||
|
||||
/**
|
||||
* @brief Tasks.
|
||||
*
|
||||
* @details The NRF_CLOCK_TASK_LFCLKSTOP task cannot be set when the low-frequency clock is not running.
|
||||
* The NRF_CLOCK_TASK_HFCLKSTOP task cannot be set when the high-frequency clock is not running.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_CLOCK_TASK_HFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTART), /**< Start HFCLK clock source.*/
|
||||
NRF_CLOCK_TASK_HFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTOP), /**< Stop HFCLK clock source.*/
|
||||
NRF_CLOCK_TASK_LFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTART), /**< Start LFCLK clock source.*/
|
||||
NRF_CLOCK_TASK_LFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTOP), /**< Stop LFCLK clock source.*/
|
||||
#if (NRF_CLOCK_HAS_CALIBRATION) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_TASK_CAL = offsetof(NRF_CLOCK_Type, TASKS_CAL), /**< Start calibration of LFCLK RC oscillator.*/
|
||||
NRF_CLOCK_TASK_CTSTART = offsetof(NRF_CLOCK_Type, TASKS_CTSTART), /**< Start calibration timer.*/
|
||||
NRF_CLOCK_TASK_CTSTOP = offsetof(NRF_CLOCK_Type, TASKS_CTSTOP) /**< Stop calibration timer.*/
|
||||
#endif
|
||||
} nrf_clock_task_t;
|
||||
|
||||
/** @brief Events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_CLOCK_EVENT_HFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_HFCLKSTARTED), /**< HFCLK oscillator started.*/
|
||||
NRF_CLOCK_EVENT_LFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_LFCLKSTARTED), /**< LFCLK oscillator started.*/
|
||||
#if (NRF_CLOCK_HAS_CALIBRATION) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_CLOCK_EVENT_DONE = offsetof(NRF_CLOCK_Type, EVENTS_DONE), /**< Calibration of LFCLK RC oscillator completed.*/
|
||||
NRF_CLOCK_EVENT_CTTO = offsetof(NRF_CLOCK_Type, EVENTS_CTTO) /**< Calibration timer time-out.*/
|
||||
#endif
|
||||
} nrf_clock_event_t;
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupt.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
void nrf_clock_int_enable(NRF_CLOCK_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupt.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
void nrf_clock_int_disable(NRF_CLOCK_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
uint32_t nrf_clock_int_enable_check(NRF_CLOCK_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the specified task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
void nrf_clock_task_trigger(NRF_CLOCK_Type * p_reg, nrf_clock_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the specified event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the trigger status of the task START for given domain.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] domain Clock domain.
|
||||
*
|
||||
* @retval false The task START for the given domain has not been triggered.
|
||||
* @retval true The task START for the given domain has been triggered.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_clock_start_task_check(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_domain_t domain);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the clock.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] domain Clock domain.
|
||||
* @param[out] p_clk_src Pointer to clock source that is running. Set to NULL if not needed.
|
||||
* Ignored for HFCLKAUDIO domain. Variable pointed by @p p_clk_src
|
||||
* must be of either @ref nrf_clock_lfclk_t type for LFCLK
|
||||
* or @ref nrf_clock_hfclk_t type for HFCLK and HFCLK192M.
|
||||
*
|
||||
* @retval false The clock is not running.
|
||||
* @retval true The clock is running.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_domain_t domain,
|
||||
void * p_clk_src);
|
||||
|
||||
/**
|
||||
* @brief Function for changing the low-frequency clock source.
|
||||
* @details This function cannot be called when the low-frequency clock is running.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] source New low-frequency clock source.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the selected source for the low-frequency clock.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval NRF_CLOCK_LFCLK_RC The internal 32 kHz RC oscillator
|
||||
* is the selected source for the low-frequency clock.
|
||||
* @retval NRF_CLOCK_LFCLK_Xtal An external 32 kHz crystal oscillator
|
||||
* is the selected source for the low-frequency clock.
|
||||
* @retval NRF_CLOCK_LFCLK_Synth The internal 32 kHz synthesizer from
|
||||
* the HFCLK is the selected source for the low-frequency clock.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the clock source for the LFCLK clock when
|
||||
* the task LKCLKSTART is triggered.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval NRF_CLOCK_LFCLK_RC The internal 32 kHz RC oscillator
|
||||
* is running and generating the LFCLK clock.
|
||||
* @retval NRF_CLOCK_LFCLK_Xtal An external 32 kHz crystal oscillator
|
||||
* is running and generating the LFCLK clock.
|
||||
* @retval NRF_CLOCK_LFCLK_Synth The internal 32 kHz synthesized from
|
||||
* the HFCLK is running and generating the LFCLK clock.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get(NRF_CLOCK_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the selected source of the high-frequency clock.
|
||||
*
|
||||
* For SoCs not featuring the HFCLKSRC register, this is always also the active source
|
||||
* of the high-frequency clock.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval NRF_CLOCK_HFCLK_LOW_ACCURACY The internal RC oscillator is the selected
|
||||
* source of the high-frequency clock.
|
||||
* @retval NRF_CLOCK_HFCLK_HIGH_ACCURACY An external crystal oscillator is the selected
|
||||
* source of the high-frequency clock.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get(NRF_CLOCK_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the HFCLK clock.
|
||||
*
|
||||
* @note This function is deprecated. Use @ref nrf_clock_is_running instead.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] clk_src Clock source to be checked.
|
||||
*
|
||||
* @retval false The HFCLK clock is not running.
|
||||
* @retval true The HFCLK clock is running.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_clock_hf_is_running(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_hfclk_t clk_src);
|
||||
|
||||
/**
|
||||
* @brief Function for changing the calibration timer interval.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] interval New calibration timer interval in 0.25 s resolution
|
||||
* (range: 0.25 seconds to 31.75 seconds).
|
||||
*/
|
||||
void nrf_clock_cal_timer_timeout_set(NRF_CLOCK_Type * p_reg, uint32_t interval);
|
||||
|
||||
|
||||
/* Bodies for inlined functions */
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_clock_task_address_get(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_task_t task)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_clock_event_address_get(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_event_t event)
|
||||
{
|
||||
return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock_event_t event)
|
||||
{
|
||||
return (bool)*((volatile uint32_t *)((uint8_t *)p_reg + event));
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_clock_start_task_check(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_domain_t domain)
|
||||
{
|
||||
switch (domain)
|
||||
{
|
||||
case NRF_CLOCK_DOMAIN_LFCLK:
|
||||
return ((p_reg->LFCLKRUN & CLOCK_LFCLKRUN_STATUS_Msk)
|
||||
>> CLOCK_LFCLKRUN_STATUS_Pos);
|
||||
case NRF_CLOCK_DOMAIN_HFCLK:
|
||||
return ((p_reg->HFCLKRUN & CLOCK_HFCLKRUN_STATUS_Msk)
|
||||
>> CLOCK_HFCLKRUN_STATUS_Pos);
|
||||
default:
|
||||
NRFX_ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source)
|
||||
{
|
||||
p_reg->LFCLKSRC = (uint32_t)(source);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const * p_reg)
|
||||
{
|
||||
return (nrf_clock_lfclk_t)(p_reg->LFCLKSRC);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_domain_t domain,
|
||||
void * p_clk_src)
|
||||
{
|
||||
switch (domain)
|
||||
{
|
||||
case NRF_CLOCK_DOMAIN_LFCLK:
|
||||
if (p_clk_src != NULL)
|
||||
{
|
||||
(*(nrf_clock_lfclk_t *)p_clk_src) =
|
||||
(nrf_clock_lfclk_t)((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_SRC_Msk)
|
||||
>> CLOCK_LFCLKSTAT_SRC_Pos);
|
||||
}
|
||||
if ((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_STATE_Msk)
|
||||
>> CLOCK_LFCLKSTAT_STATE_Pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case NRF_CLOCK_DOMAIN_HFCLK:
|
||||
if (p_clk_src != NULL)
|
||||
{
|
||||
(*(nrf_clock_hfclk_t *)p_clk_src) =
|
||||
(nrf_clock_hfclk_t)((p_reg->HFCLKSTAT & CLOCK_HFCLKSTAT_SRC_Msk)
|
||||
>> CLOCK_HFCLKSTAT_SRC_Pos);
|
||||
}
|
||||
if ((p_reg->HFCLKSTAT & CLOCK_HFCLKSTAT_STATE_Msk)
|
||||
>> CLOCK_HFCLKSTAT_STATE_Pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
#if NRF_CLOCK_HAS_HFCLK192M
|
||||
case NRF_CLOCK_DOMAIN_HFCLK192M:
|
||||
if (p_clk_src != NULL)
|
||||
{
|
||||
(*(nrf_clock_hfclk_t *)p_clk_src) =
|
||||
(nrf_clock_hfclk_t)((p_reg->HFCLK192MSTAT & CLOCK_HFCLK192MSTAT_SRC_Msk)
|
||||
>> CLOCK_HFCLK192MSTAT_SRC_Pos);
|
||||
}
|
||||
if ((p_reg->HFCLK192MSTAT & CLOCK_HFCLK192MSTAT_STATE_Msk)
|
||||
>> CLOCK_HFCLK192MSTAT_STATE_Pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if NRF_CLOCK_HAS_HFCLKAUDIO
|
||||
case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
|
||||
return (p_reg->HFCLKAUDIOSTAT & CLOCK_HFCLKAUDIOSTAT_STATE_Msk) ==
|
||||
CLOCK_HFCLKAUDIOSTAT_STATE_Msk;
|
||||
#endif
|
||||
default:
|
||||
NRFX_ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get(NRF_CLOCK_Type const * p_reg)
|
||||
{
|
||||
/*simple approximation LFCLKSRC = LFCLKSRCCOPY*/
|
||||
return (nrf_clock_lfclk_t)((p_reg->LFCLKSRC & CLOCK_LFCLKSRC_SRC_Msk)
|
||||
>> CLOCK_LFCLKSRC_SRC_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get(NRF_CLOCK_Type const * p_reg)
|
||||
{
|
||||
return (nrf_clock_hfclk_t)((p_reg->HFCLKSTAT & CLOCK_HFCLKSTAT_SRC_Msk)
|
||||
>> CLOCK_HFCLKSTAT_SRC_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_clock_hf_is_running(NRF_CLOCK_Type const * p_reg,
|
||||
nrf_clock_hfclk_t clk_src)
|
||||
{
|
||||
nrf_clock_hfclk_t active_clk_src;
|
||||
bool ret = nrf_clock_is_running(p_reg, NRF_CLOCK_DOMAIN_HFCLK, &active_clk_src);
|
||||
return (ret && (active_clk_src == clk_src));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_CLOCK_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_ecb.h"
|
||||
#include "hal/nrf_ecb.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_AES_ECB.h"
|
||||
|
||||
|
|
|
@ -1,185 +0,0 @@
|
|||
/*
|
||||
* Part of the real nrf_ecb.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_ECB_H__
|
||||
#define BS_NRF_ECB_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_ecb_hal AES ECB encryption HAL
|
||||
* @{
|
||||
* @ingroup nrf_ecb
|
||||
* @brief Hardware access layer for managing the AES Electronic Codebook (ECB) peripheral.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ECB tasks.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*lint -save -e30 -esym(628,__INTADDR__)*/
|
||||
NRF_ECB_TASK_STARTECB = offsetof(NRF_ECB_Type, TASKS_STARTECB), /**< Task for starting ECB block encryption. */
|
||||
NRF_ECB_TASK_STOPECB = offsetof(NRF_ECB_Type, TASKS_STOPECB), /**< Task for stopping ECB block encryption. */
|
||||
/*lint -restore*/
|
||||
} nrf_ecb_task_t;
|
||||
|
||||
/**
|
||||
* @brief ECB events.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*lint -save -e30*/
|
||||
NRF_ECB_EVENT_ENDECB = offsetof(NRF_ECB_Type, EVENTS_ENDECB), /**< ECB block encrypt complete. */
|
||||
NRF_ECB_EVENT_ERRORECB = offsetof(NRF_ECB_Type, EVENTS_ERRORECB), /**< ECB block encrypt aborted because of a STOPECB task or due to an error. */
|
||||
/*lint -restore*/
|
||||
} nrf_ecb_event_t;
|
||||
|
||||
/**
|
||||
* @brief ECB interrupts.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_ECB_INT_ENDECB_MASK = ECB_INTENSET_ENDECB_Msk, ///< Interrupt on ENDECB event.
|
||||
NRF_ECB_INT_ERRORECB_MASK = ECB_INTENSET_ERRORECB_Msk, ///< Interrupt on ERRORECB event.
|
||||
} nrf_ecb_int_mask_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for activating a specific ECB task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] task Task to activate.
|
||||
*/
|
||||
void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified ECB event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the ECB event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] mask Interrupts to enable.
|
||||
*/
|
||||
void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] mask Interrupts to disable.
|
||||
*/
|
||||
void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the pointer to the ECB data buffer.
|
||||
*
|
||||
* @note The buffer has to be placed in the Data RAM region.
|
||||
* For description of the data structure in this buffer, see the Product Specification.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
* @param[in] p_buffer Pointer to the ECB data buffer.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the pointer to the ECB data buffer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the peripheral register structure.
|
||||
*
|
||||
* @return Pointer to the ECB data buffer.
|
||||
*/
|
||||
NRF_STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg);
|
||||
|
||||
/*****************************/
|
||||
/* Inlined functions bodies: */
|
||||
/*****************************/
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer)
|
||||
{
|
||||
p_reg->ECBDATAPTR = (uint32_t)p_buffer;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg)
|
||||
{
|
||||
return (void *)(p_reg->ECBDATAPTR);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_ECB_H__ */
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef BS_NRF_GPIO_H__
|
||||
#define BS_NRF_GPIO_H__
|
||||
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#endif /* BS_NRF_GPIO_H__ */
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef BS_NRF_GPIOTE_H__
|
||||
#define BS_NRF_GPIOTE_H__
|
||||
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#endif /* BS_NRF_TIMER_H__ */
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* We want to use all real nRFx HAL definitions, while allowing some of them to be overridden.
|
||||
* We do this by including here all real nRFx HAL provided functions, but defining them as "weak".
|
||||
* This allows the HW models to provide their own version when needed due to HW models differences.
|
||||
*/
|
||||
#define NRF_DONT_DECLARE_ONLY
|
||||
#define NRF_STATIC_INLINE __attribute__((weak))
|
||||
|
||||
#include "nrfx.h"
|
||||
|
||||
#ifdef AAR_PRESENT
|
||||
#include "hal/nrf_aar.h"
|
||||
#endif
|
||||
|
||||
#ifdef ACL_PRESENT
|
||||
#include "hal/nrf_acl.h"
|
||||
#endif
|
||||
|
||||
#ifdef ADC_PRESENT
|
||||
#include "hal/nrf_adc.h"
|
||||
#endif
|
||||
|
||||
#ifdef BPROT_PRESENT
|
||||
#include "hal/nrf_bprot.h"
|
||||
#endif
|
||||
|
||||
#ifdef CACHE_PRESENT
|
||||
#include "hal/nrf_cache.h"
|
||||
#endif
|
||||
|
||||
#ifdef CCM_PRESENT
|
||||
#include "hal/nrf_ccm.h"
|
||||
#endif
|
||||
|
||||
#ifdef CLOCK_PRESENT
|
||||
#include "hal/nrf_clock.h"
|
||||
#endif
|
||||
|
||||
#include "hal/nrf_common.h"
|
||||
|
||||
#ifdef COMP_PRESENT
|
||||
#include "hal/nrf_comp.h"
|
||||
#endif
|
||||
|
||||
#ifdef NRF_DCNF_NS
|
||||
#include "hal/nrf_dcnf.h"
|
||||
#endif
|
||||
|
||||
#ifdef DPPI_PRESENT
|
||||
#include "hal/nrf_dppi.h"
|
||||
#endif
|
||||
|
||||
#ifdef ECB_PRESENT
|
||||
#include "hal/nrf_ecb.h"
|
||||
#endif
|
||||
|
||||
#ifdef EGU_PRESENT
|
||||
#include "hal/nrf_egu.h"
|
||||
#endif
|
||||
|
||||
#include "hal/nrf_ficr.h"
|
||||
|
||||
#ifdef GPIO_PRESENT
|
||||
#include "hal/nrf_gpio.h"
|
||||
#endif
|
||||
|
||||
#ifdef GPIOTE_PRESENT
|
||||
#include "hal/nrf_gpiote.h"
|
||||
#endif
|
||||
|
||||
#ifdef I2S_PRESENT
|
||||
#include "hal/nrf_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef IPC_PRESENT
|
||||
#include "hal/nrf_ipc.h"
|
||||
#endif
|
||||
|
||||
#ifdef KMU_PRESENT
|
||||
#include "hal/nrf_kmu.h"
|
||||
#endif
|
||||
|
||||
#ifdef LPCOMP_PRESENT
|
||||
#include "hal/nrf_lpcomp.h"
|
||||
#endif
|
||||
|
||||
#ifdef MUTEX_PRESENT
|
||||
#include "hal/nrf_mutex.h"
|
||||
#endif
|
||||
|
||||
#ifdef MWU_PRESENT
|
||||
#include "hal/nrf_mwu.h"
|
||||
#endif
|
||||
|
||||
#ifdef NFCT_PRESENT
|
||||
#include "hal/nrf_nfct.h"
|
||||
#endif
|
||||
|
||||
#ifdef NVMC_PRESENT
|
||||
#include "hal/nrf_nvmc.h"
|
||||
#endif
|
||||
|
||||
#ifdef OSCILLATORS_PRESENT
|
||||
#include "hal/nrf_oscillators.h"
|
||||
#endif
|
||||
|
||||
#ifdef PDM_PRESENT
|
||||
#include "hal/nrf_pdm.h"
|
||||
#endif
|
||||
|
||||
#ifdef POWER_PRESENT
|
||||
#include "hal/nrf_power.h"
|
||||
#endif
|
||||
|
||||
#ifdef PPI_PRESENT
|
||||
#include "hal/nrf_ppi.h"
|
||||
#endif
|
||||
|
||||
#ifdef PWM_PRESENT
|
||||
#include "hal/nrf_pwm.h"
|
||||
#endif
|
||||
|
||||
#ifdef QDEC_PRESENT
|
||||
#include "hal/nrf_qdec.h"
|
||||
#endif
|
||||
|
||||
#ifdef QSPI_PRESENT
|
||||
#include "hal/nrf_qspi.h"
|
||||
#endif
|
||||
|
||||
#ifdef RADIO_PRESENT
|
||||
#include "hal/nrf_radio.h"
|
||||
#endif
|
||||
|
||||
#ifdef REGULATORS_PRESENT
|
||||
#include "hal/nrf_regulators.h"
|
||||
#endif
|
||||
|
||||
#ifdef RNG_PRESENT
|
||||
#include "hal/nrf_rng.h"
|
||||
#endif
|
||||
|
||||
#ifdef RTC_PRESENT
|
||||
#include "hal/nrf_rtc.h"
|
||||
#endif
|
||||
|
||||
#ifdef SAADC_PRESENT
|
||||
#include "hal/nrf_saadc.h"
|
||||
#endif
|
||||
|
||||
#ifdef SPI_PRESENT
|
||||
#include "hal/nrf_spi.h"
|
||||
#endif
|
||||
|
||||
#ifdef SPIM_PRESENT
|
||||
#include "hal/nrf_spim.h"
|
||||
#endif
|
||||
|
||||
#ifdef SPIS_PRESENT
|
||||
#include "hal/nrf_spis.h"
|
||||
#endif
|
||||
|
||||
#ifdef SPU_PRESENT
|
||||
#include "hal/nrf_spu.h"
|
||||
#endif
|
||||
|
||||
#ifdef TEMP_PRESENT
|
||||
#include "hal/nrf_temp.h"
|
||||
#endif
|
||||
|
||||
#ifdef TIMER_PRESENT
|
||||
#include "hal/nrf_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef TWI_PRESENT
|
||||
#include "hal/nrf_twi.h"
|
||||
#endif
|
||||
|
||||
#ifdef TWIM_PRESENT
|
||||
#include "hal/nrf_twim.h"
|
||||
#endif
|
||||
|
||||
#ifdef TWIS_PRESENT
|
||||
#include "hal/nrf_twis.h"
|
||||
#endif
|
||||
|
||||
#ifdef UART_PRESENT
|
||||
#include "hal/nrf_uart.h"
|
||||
#endif
|
||||
|
||||
#ifdef UARTE_PRESENT
|
||||
#include "hal/nrf_uarte.h"
|
||||
#endif
|
||||
|
||||
#ifdef USBD_PRESENT
|
||||
#include "hal/nrf_usbd.h"
|
||||
#endif
|
||||
|
||||
#ifdef USBREG_PRESENT
|
||||
#include "hal/nrf_usbreg.h"
|
||||
#endif
|
||||
|
||||
#ifdef VMC_PRESENT
|
||||
#include "hal/nrf_vmc.h"
|
||||
#endif
|
||||
|
||||
#ifdef VREQCTRL_PRESENT
|
||||
#include "hal/nrf_vreqctrl.h"
|
||||
#endif
|
||||
|
||||
#ifdef WDT_PRESENT
|
||||
#include "hal/nrf_wdt.h"
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef BS_NRF_NVMC_H__
|
||||
#define BS_NRF_NVMC_H__
|
||||
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#endif /* BS_NRF_NVMC_H__ */
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Oticon A/S
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
#ifndef BS_NRF_POWER_H__
|
||||
#define BS_NRF_POWER_H__
|
||||
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_power_int_enable_get(NRF_POWER_Type const * p_reg)
|
||||
{
|
||||
return p_reg->INTENSET;
|
||||
}
|
||||
|
||||
#endif /* BS_NRF_POWER_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_ppi.h"
|
||||
#include "hal/nrf_ppi.h"
|
||||
#include "NRF_PPI.h"
|
||||
#include "bs_tracing.h"
|
||||
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
/**
|
||||
* Part of the real nrf_ppi.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_PPI_H__
|
||||
#define BS_NRF_PPI_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_ppi_hal PPI HAL
|
||||
* @{
|
||||
* @ingroup nrf_ppi
|
||||
* @brief Hardware access layer for managing the Programmable Peripheral Interconnect (PPI)
|
||||
* channels.
|
||||
*/
|
||||
|
||||
#define NRF_PPI_TASK_SET (1UL)
|
||||
|
||||
/**
|
||||
* @enum nrf_ppi_channel_t
|
||||
* @brief PPI channels.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_PPI_CHANNEL0 = PPI_CHEN_CH0_Pos, /**< Channel 0. */
|
||||
NRF_PPI_CHANNEL1 = PPI_CHEN_CH1_Pos, /**< Channel 1. */
|
||||
NRF_PPI_CHANNEL2 = PPI_CHEN_CH2_Pos, /**< Channel 2. */
|
||||
NRF_PPI_CHANNEL3 = PPI_CHEN_CH3_Pos, /**< Channel 3. */
|
||||
NRF_PPI_CHANNEL4 = PPI_CHEN_CH4_Pos, /**< Channel 4. */
|
||||
NRF_PPI_CHANNEL5 = PPI_CHEN_CH5_Pos, /**< Channel 5. */
|
||||
NRF_PPI_CHANNEL6 = PPI_CHEN_CH6_Pos, /**< Channel 6. */
|
||||
NRF_PPI_CHANNEL7 = PPI_CHEN_CH7_Pos, /**< Channel 7. */
|
||||
NRF_PPI_CHANNEL8 = PPI_CHEN_CH8_Pos, /**< Channel 8. */
|
||||
NRF_PPI_CHANNEL9 = PPI_CHEN_CH9_Pos, /**< Channel 9. */
|
||||
NRF_PPI_CHANNEL10 = PPI_CHEN_CH10_Pos, /**< Channel 10. */
|
||||
NRF_PPI_CHANNEL11 = PPI_CHEN_CH11_Pos, /**< Channel 11. */
|
||||
NRF_PPI_CHANNEL12 = PPI_CHEN_CH12_Pos, /**< Channel 12. */
|
||||
NRF_PPI_CHANNEL13 = PPI_CHEN_CH13_Pos, /**< Channel 13. */
|
||||
NRF_PPI_CHANNEL14 = PPI_CHEN_CH14_Pos, /**< Channel 14. */
|
||||
NRF_PPI_CHANNEL15 = PPI_CHEN_CH15_Pos, /**< Channel 15. */
|
||||
#if (PPI_CH_NUM > 16) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_PPI_CHANNEL16 = PPI_CHEN_CH16_Pos, /**< Channel 16. */
|
||||
NRF_PPI_CHANNEL17 = PPI_CHEN_CH17_Pos, /**< Channel 17. */
|
||||
NRF_PPI_CHANNEL18 = PPI_CHEN_CH18_Pos, /**< Channel 18. */
|
||||
NRF_PPI_CHANNEL19 = PPI_CHEN_CH19_Pos, /**< Channel 19. */
|
||||
#endif
|
||||
NRF_PPI_CHANNEL20 = PPI_CHEN_CH20_Pos, /**< Channel 20. */
|
||||
NRF_PPI_CHANNEL21 = PPI_CHEN_CH21_Pos, /**< Channel 21. */
|
||||
NRF_PPI_CHANNEL22 = PPI_CHEN_CH22_Pos, /**< Channel 22. */
|
||||
NRF_PPI_CHANNEL23 = PPI_CHEN_CH23_Pos, /**< Channel 23. */
|
||||
NRF_PPI_CHANNEL24 = PPI_CHEN_CH24_Pos, /**< Channel 24. */
|
||||
NRF_PPI_CHANNEL25 = PPI_CHEN_CH25_Pos, /**< Channel 25. */
|
||||
NRF_PPI_CHANNEL26 = PPI_CHEN_CH26_Pos, /**< Channel 26. */
|
||||
NRF_PPI_CHANNEL27 = PPI_CHEN_CH27_Pos, /**< Channel 27. */
|
||||
NRF_PPI_CHANNEL28 = PPI_CHEN_CH28_Pos, /**< Channel 28. */
|
||||
NRF_PPI_CHANNEL29 = PPI_CHEN_CH29_Pos, /**< Channel 29. */
|
||||
NRF_PPI_CHANNEL30 = PPI_CHEN_CH30_Pos, /**< Channel 30. */
|
||||
NRF_PPI_CHANNEL31 = PPI_CHEN_CH31_Pos /**< Channel 31. */
|
||||
} nrf_ppi_channel_t;
|
||||
|
||||
/**
|
||||
* @enum nrf_ppi_channel_group_t
|
||||
* @brief PPI channel groups.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_PPI_CHANNEL_GROUP0 = 0, /**< Channel group 0. */
|
||||
NRF_PPI_CHANNEL_GROUP1 = 1, /**< Channel group 1. */
|
||||
NRF_PPI_CHANNEL_GROUP2 = 2, /**< Channel group 2. */
|
||||
NRF_PPI_CHANNEL_GROUP3 = 3, /**< Channel group 3. */
|
||||
#if (PPI_GROUP_NUM > 4) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_PPI_CHANNEL_GROUP4 = 4, /**< Channel group 4. */
|
||||
NRF_PPI_CHANNEL_GROUP5 = 5 /**< Channel group 5. */
|
||||
#endif
|
||||
} nrf_ppi_channel_group_t;
|
||||
|
||||
void nrf_ppi_channels_enable(NRF_PPI_Type * p_reg, uint32_t mask);
|
||||
void nrf_ppi_channels_disable(NRF_PPI_Type * p_reg, uint32_t mask);
|
||||
void nrf_ppi_channel_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep,
|
||||
uint32_t tep);
|
||||
void nrf_ppi_event_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t eep);
|
||||
void nrf_ppi_task_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t tep);
|
||||
void nrf_ppi_fork_endpoint_setup(NRF_PPI_Type * p_reg,
|
||||
nrf_ppi_channel_t channel,
|
||||
uint32_t fork_tep);
|
||||
void nrf_ppi_group_disable(NRF_PPI_Type * p_reg, nrf_ppi_channel_group_t group);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_PPI_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_radio.h"
|
||||
#include "hal/nrf_radio.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_RADIO.h"
|
||||
|
||||
|
|
|
@ -1,781 +0,0 @@
|
|||
/**
|
||||
* Part of the real nrf_radio.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_RADIO_H__
|
||||
#define BS_NRF_RADIO_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @enum nrf_radio_task_t
|
||||
* @brief RADIO tasks.
|
||||
*/
|
||||
typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */
|
||||
{
|
||||
NRF_RADIO_TASK_TXEN = offsetof(NRF_RADIO_Type, TASKS_TXEN), /**< Enable radio transmitter. */
|
||||
NRF_RADIO_TASK_RXEN = offsetof(NRF_RADIO_Type, TASKS_RXEN), /**< Enable radio receiver. */
|
||||
NRF_RADIO_TASK_START = offsetof(NRF_RADIO_Type, TASKS_START), /**< Start radio transmission or reception. */
|
||||
NRF_RADIO_TASK_STOP = offsetof(NRF_RADIO_Type, TASKS_STOP), /**< Stop radio transmission or reception. */
|
||||
NRF_RADIO_TASK_DISABLE = offsetof(NRF_RADIO_Type, TASKS_DISABLE), /**< Disable radio transmitter and receiver. */
|
||||
// Only present in NRF52840
|
||||
// NRF_RADIO_TASK_CCASTART = offsetof(NRF_RADIO_Type, TASKS_CCASTART), /**< Start Clear Channel Assessment procedure. */
|
||||
// NRF_RADIO_TASK_CCASTOP = offsetof(NRF_RADIO_Type, TASKS_CCASTOP), /**< Stop Clear Channel Assessment procedure. */
|
||||
// NRF_RADIO_TASK_EDSTART = offsetof(NRF_RADIO_Type, TASKS_EDSTART), /**< Start Energy Detection procedure. */
|
||||
NRF_RADIO_TASK_RSSISTART = offsetof(NRF_RADIO_Type, TASKS_RSSISTART), /**< Start the RSSI and take one single sample of received signal strength. */
|
||||
NRF_RADIO_TASK_RSSISTOP = offsetof(NRF_RADIO_Type, TASKS_RSSISTOP), /**< Stop the RSSI measurement. */
|
||||
} nrf_radio_task_t; /*lint -restore */
|
||||
|
||||
/**
|
||||
* @enum nrf_radio_event_t
|
||||
* @brief RADIO events.
|
||||
*/
|
||||
typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */
|
||||
{
|
||||
NRF_RADIO_EVENT_READY = offsetof(NRF_RADIO_Type, EVENTS_READY), /**< Radio has ramped up and is ready to be started. */
|
||||
NRF_RADIO_EVENT_ADDRESS = offsetof(NRF_RADIO_Type, EVENTS_ADDRESS), /**< Address sent or received. */
|
||||
NRF_RADIO_EVENT_END = offsetof(NRF_RADIO_Type, EVENTS_END), /**< Packet transmitted or received. */
|
||||
NRF_RADIO_EVENT_DISABLED = offsetof(NRF_RADIO_Type, EVENTS_DISABLED), /**< Radio has been disabled. */
|
||||
NRF_RADIO_EVENT_DEVMATCH = offsetof(NRF_RADIO_Type, EVENTS_DEVMATCH), /**< A device address match occurred on the last received packet. */
|
||||
NRF_RADIO_EVENT_DEVMISS = offsetof(NRF_RADIO_Type, EVENTS_DEVMISS), /**< No device address match occurred on the last received packet. */
|
||||
NRF_RADIO_EVENT_CRCOK = offsetof(NRF_RADIO_Type, EVENTS_CRCOK), /**< Packet received with correct CRC. */
|
||||
NRF_RADIO_EVENT_CRCERROR = offsetof(NRF_RADIO_Type, EVENTS_CRCERROR), /**< Packet received with incorrect CRC. */
|
||||
// NRF_RADIO_EVENT_CCAIDLE = offsetof(NRF_RADIO_Type, EVENTS_CCAIDLE), /**< Wireless medium is idle. */
|
||||
// NRF_RADIO_EVENT_CCABUSY = offsetof(NRF_RADIO_Type, EVENTS_CCABUSY), /**< Wireless medium is busy. */
|
||||
NRF_RADIO_EVENT_RSSIEND = offsetof(NRF_RADIO_Type, EVENTS_RSSIEND), /**< Sampling of receive signal strength complete. */
|
||||
// NRF_RADIO_EVENT_MHRMATCH = offsetof(NRF_RADIO_Type, EVENTS_MHRMATCH), /**< MAC Header match found. */
|
||||
// NRF_RADIO_EVENT_FRAMESTART = offsetof(NRF_RADIO_Type, EVENTS_FRAMESTART), /**< IEEE 802.15.4 length field received. */
|
||||
// NRF_RADIO_EVENT_EDEND = offsetof(NRF_RADIO_Type, EVENTS_EDEND), /**< Energy Detection procedure ended. */
|
||||
NRF_RADIO_EVENT_BCMATCH = offsetof(NRF_RADIO_Type, EVENTS_BCMATCH), /**< Bit counter reached bit count value. */
|
||||
} nrf_radio_event_t; /*lint -restore */
|
||||
|
||||
/**
|
||||
* @enum nrf_radio_int_mask_t
|
||||
* @brief RADIO interrupts.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_RADIO_INT_READY_MASK = RADIO_INTENSET_READY_Msk, /**< Mask for enabling or disabling an interrupt on READY event. */
|
||||
NRF_RADIO_INT_ADDRESS_MASK = RADIO_INTENSET_ADDRESS_Msk, /**< Mask for enabling or disabling an interrupt on ADDRESS event. */
|
||||
NRF_RADIO_INT_END_MASK = RADIO_INTENSET_END_Msk, /**< Mask for enabling or disabling an interrupt on END event. */
|
||||
NRF_RADIO_INT_DISABLED_MASK = RADIO_INTENSET_DISABLED_Msk, /**< Mask for enabling or disabling an interrupt on DISABLED event. */
|
||||
NRF_RADIO_INT_CRCOK_MASK = RADIO_INTENSET_CRCOK_Msk, /**< Mask for enabling or disabling an interrupt on CRCOK event. */
|
||||
NRF_RADIO_INT_CRCERROR_MASK = RADIO_INTENSET_CRCERROR_Msk, /**< Mask for enabling or disabling an interrupt on CRCERROR event. */
|
||||
// NRF_RADIO_INT_CCAIDLE_MASK = RADIO_INTENSET_CCAIDLE_Msk, /**< Mask for enabling or disabling an interrupt on CCAIDLE event. */
|
||||
// NRF_RADIO_INT_CCABUSY_MASK = RADIO_INTENSET_CCABUSY_Msk, /**< Mask for enabling or disabling an interrupt on CCABUSY event. */
|
||||
NRF_RADIO_INT_RSSIEND_MASK = RADIO_INTENSET_RSSIEND_Msk, /**< Mask for enabling or disabling an interrupt on RSSIEND event. */
|
||||
// NRF_RADIO_INT_FRAMESTART_MASK = RADIO_INTENSET_FRAMESTART_Msk, /**< Mask for enabling or disabling an interrupt on FRAMESTART event. */
|
||||
// NRF_RADIO_INT_EDEND_MASK = RADIO_INTENSET_EDEND_Msk, /**< Mask for enabling or disabling an interrupt on EDEND event. */
|
||||
NRF_RADIO_INT_BCMATCH_MASK = RADIO_INTENSET_BCMATCH_Msk, /**< Mask for enabling or disabling an interrupt on BCMATCH event. */
|
||||
} nrf_radio_int_mask_t;
|
||||
|
||||
/** @brief RADIO shortcuts. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_RADIO_SHORT_READY_START_MASK = RADIO_SHORTS_READY_START_Msk, /**< Shortcut between READY event and START task. */
|
||||
NRF_RADIO_SHORT_END_DISABLE_MASK = RADIO_SHORTS_END_DISABLE_Msk, /**< Shortcut between END event and DISABLE task. */
|
||||
NRF_RADIO_SHORT_DISABLED_TXEN_MASK = RADIO_SHORTS_DISABLED_TXEN_Msk, /**< Shortcut between DISABLED event and TXEN task. */
|
||||
NRF_RADIO_SHORT_DISABLED_RXEN_MASK = RADIO_SHORTS_DISABLED_RXEN_Msk, /**< Shortcut between DISABLED event and RXEN task. */
|
||||
NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK = RADIO_SHORTS_ADDRESS_RSSISTART_Msk, /**< Shortcut between ADDRESS event and RSSISTART task. */
|
||||
NRF_RADIO_SHORT_END_START_MASK = RADIO_SHORTS_END_START_Msk, /**< Shortcut between END event and START task. */
|
||||
NRF_RADIO_SHORT_ADDRESS_BCSTART_MASK = RADIO_SHORTS_ADDRESS_BCSTART_Msk, /**< Shortcut between ADDRESS event and BCSTART task. */
|
||||
NRF_RADIO_SHORT_DISABLED_RSSISTOP_MASK = RADIO_SHORTS_DISABLED_RSSISTOP_Msk, /**< Shortcut between DISABLED event and RSSISTOP task. */
|
||||
} nrf_radio_short_mask_t;
|
||||
|
||||
/** @brief Types of RADIO states. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_RADIO_STATE_DISABLED = RADIO_STATE_STATE_Disabled, /**< No operations are going on inside the radio and the power consumption is at a minimum. */
|
||||
NRF_RADIO_STATE_RXRU = RADIO_STATE_STATE_RxRu, /**< The radio is ramping up and preparing for reception. */
|
||||
NRF_RADIO_STATE_RXIDLE = RADIO_STATE_STATE_RxIdle, /**< The radio is ready for reception to start. */
|
||||
NRF_RADIO_STATE_RX = RADIO_STATE_STATE_Rx, /**< Reception has been started. */
|
||||
NRF_RADIO_STATE_RXDISABLE = RADIO_STATE_STATE_RxDisable, /**< The radio is disabling the receiver. */
|
||||
NRF_RADIO_STATE_TXRU = RADIO_STATE_STATE_TxRu, /**< The radio is ramping up and preparing for transmission. */
|
||||
NRF_RADIO_STATE_TXIDLE = RADIO_STATE_STATE_TxIdle, /**< The radio is ready for transmission to start. */
|
||||
NRF_RADIO_STATE_TX = RADIO_STATE_STATE_Tx, /**< The radio is transmitting a packet. */
|
||||
NRF_RADIO_STATE_TXDISABLE = RADIO_STATE_STATE_TxDisable, /**< The radio is disabling the transmitter. */
|
||||
} nrf_radio_state_t;
|
||||
|
||||
/** @brief Types of RADIO TX power. */
|
||||
typedef enum
|
||||
{
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_POS8DBM = RADIO_TXPOWER_TXPOWER_Pos8dBm, /**< 8 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos7dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_POS7DBM = RADIO_TXPOWER_TXPOWER_Pos7dBm, /**< 7 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos6dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_POS6DBM = RADIO_TXPOWER_TXPOWER_Pos6dBm, /**< 6 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos5dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_POS5DBM = RADIO_TXPOWER_TXPOWER_Pos5dBm, /**< 5 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_POS4DBM = RADIO_TXPOWER_TXPOWER_Pos4dBm, /**< 4 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_POS3DBM = RADIO_TXPOWER_TXPOWER_Pos3dBm, /**< 3 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos2dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_POS2DBM = RADIO_TXPOWER_TXPOWER_Pos2dBm, /**< 2 dBm. */
|
||||
#endif
|
||||
NRF_RADIO_TXPOWER_0DBM = RADIO_TXPOWER_TXPOWER_0dBm, /**< 0 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG4DBM = RADIO_TXPOWER_TXPOWER_Neg4dBm, /**< -4 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG8DBM = RADIO_TXPOWER_TXPOWER_Neg8dBm, /**< -8 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG12DBM = RADIO_TXPOWER_TXPOWER_Neg12dBm, /**< -12 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG16DBM = RADIO_TXPOWER_TXPOWER_Neg16dBm, /**< -16 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG20DBM = RADIO_TXPOWER_TXPOWER_Neg20dBm, /**< -20 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG30DBM = RADIO_TXPOWER_TXPOWER_Neg30dBm, /**< -30 dBm. */
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Neg40dBm) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_TXPOWER_NEG40DBM = RADIO_TXPOWER_TXPOWER_Neg40dBm, /**< -40 dBm. */
|
||||
#endif
|
||||
} nrf_radio_txpower_t;
|
||||
|
||||
/** @brief Types of RADIO modes (data rate and modulation). */
|
||||
typedef enum
|
||||
{
|
||||
NRF_RADIO_MODE_NRF_1MBIT = RADIO_MODE_MODE_Nrf_1Mbit, /**< 1Mbit/s Nordic proprietary radio mode. */
|
||||
NRF_RADIO_MODE_NRF_2MBIT = RADIO_MODE_MODE_Nrf_2Mbit, /**< 2Mbit/s Nordic proprietary radio mode. */
|
||||
#if defined(RADIO_MODE_MODE_Nrf_250Kbit) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_MODE_NRF_250KBIT = RADIO_MODE_MODE_Nrf_250Kbit, /**< 250Kbit/s Nordic proprietary radio mode. */
|
||||
#endif
|
||||
NRF_RADIO_MODE_BLE_1MBIT = RADIO_MODE_MODE_Ble_1Mbit, /**< 1 Mbit/s Bluetooth Low Energy. */
|
||||
#if defined(RADIO_MODE_MODE_Ble_2Mbit) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_MODE_BLE_2MBIT = RADIO_MODE_MODE_Ble_2Mbit, /**< 2 Mbit/s Bluetooth Low Energy. */
|
||||
#endif
|
||||
#if defined(RADIO_MODE_MODE_Ble_LR125Kbit) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_MODE_BLE_LR125KBIT = RADIO_MODE_MODE_Ble_LR125Kbit, /*!< Bluetooth Low Energy Long range 125 kbit/s TX, 125 kbit/s and 500 kbit/s RX */
|
||||
#endif
|
||||
#if defined(RADIO_MODE_MODE_Ble_LR500Kbit) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_MODE_BLE_LR500KBIT = RADIO_MODE_MODE_Ble_LR500Kbit, /*!< Bluetooth Low Energy Long range 500 kbit/s TX, 125 kbit/s and 500 kbit/s RX */
|
||||
#endif
|
||||
#if defined(RADIO_MODE_MODE_Ieee802154_250Kbit) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_RADIO_MODE_IEEE802154_250KBIT = RADIO_MODE_MODE_Ieee802154_250Kbit, /**< IEEE 802.15.4-2006 250 kbit/s. */
|
||||
#endif
|
||||
} nrf_radio_mode_t;
|
||||
|
||||
#if defined(RADIO_PCNF0_PLEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
/** @brief Types of preamble length. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_RADIO_PREAMBLE_LENGTH_8BIT = RADIO_PCNF0_PLEN_8bit, /**< 8-bit preamble. */
|
||||
NRF_RADIO_PREAMBLE_LENGTH_16BIT = RADIO_PCNF0_PLEN_16bit, /**< 16-bit preamble. */
|
||||
} nrf_radio_preamble_length_t;
|
||||
#endif // defined(RADIO_PCNF0_PLEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/** @brief Types of CRC calculatons regarding address. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_RADIO_CRC_ADDR_INCLUDE = RADIO_CRCCNF_SKIPADDR_Include, /**< CRC calculation includes address field. */
|
||||
NRF_RADIO_CRC_ADDR_SKIP = RADIO_CRCCNF_SKIPADDR_Skip, /**< CRC calculation does not include address field. */
|
||||
} nrf_radio_crc_addr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t lflen; /**< Length on air of LENGTH field in number of bits. */
|
||||
uint8_t s0len; /**< Length on air of S0 field in number of bytes. */
|
||||
uint8_t s1len; /**< Length on air of S1 field in number of bits. */
|
||||
#if defined(RADIO_PCNF0_S1INCL_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
bool s1incl; /**< Include or exclude S1 field in RAM. */
|
||||
#endif
|
||||
#if defined(RADIO_PCNF0_PLEN_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
nrf_radio_preamble_length_t plen; /**< Length of preamble on air. Decision point: TASKS_START task. */
|
||||
#endif
|
||||
uint8_t maxlen; /**< Maximum length of packet payload. */
|
||||
uint8_t statlen; /**< Static length in number of bytes. */
|
||||
uint8_t balen; /**< Base address length in number of bytes. */
|
||||
bool big_endian; /**< On air endianness of packet. */
|
||||
bool whiteen; /**< Enable or disable packet whitening. */
|
||||
} nrf_radio_packet_conf_t;
|
||||
|
||||
/**
|
||||
* @brief Function for activating a specific RADIO task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
void nrf_radio_task_trigger(NRF_RADIO_Type * p_reg, nrf_radio_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a specific RADIO event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clean.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_event_clear(NRF_RADIO_Type * p_reg, nrf_radio_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the RADIO event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_radio_event_check(NRF_RADIO_Type const * p_reg, nrf_radio_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified RADIO shortcuts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] shorts_mask Mask of shortcuts.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_shorts_enable(NRF_RADIO_Type * p_reg, uint32_t shorts_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified RADIO shortcuts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] shorts_mask Mask of shortcuts.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_shorts_disable(NRF_RADIO_Type * p_reg, uint32_t shorts_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the configuration of RADIO shortcuts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] shorts_mask Shortcuts configuration to set.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_shorts_set(NRF_RADIO_Type * p_reg, uint32_t shorts_mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling specified RADIO interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
void nrf_radio_int_enable(NRF_RADIO_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling specified RADIO interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
void nrf_radio_int_disable(NRF_RADIO_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_radio_int_enable_check(NRF_RADIO_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting CRC status of last received packet.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @retval true The packet was received without CRC error.
|
||||
* @retval false The packet was received with CRC error.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_radio_crc_status_check(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the device address match index.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Device adress match index.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_dai_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting packet pointer to given location in memory.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_packet Packet pointer.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_packetptr_set(NRF_RADIO_Type * p_reg, void const * p_packet);
|
||||
|
||||
/**
|
||||
* @brief Function for getting packet pointer.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Pointer to tx or rx packet buffer.
|
||||
*/
|
||||
NRF_STATIC_INLINE void * nrf_radio_packetptr_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the radio frequency.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] radio_frequency Frequency in MHz.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_frequency_set(NRF_RADIO_Type * p_reg, uint16_t radio_frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the radio transmit power.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] tx_power Transmit power of the radio [dBm].
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_txpower_set(NRF_RADIO_Type * p_reg, nrf_radio_txpower_t tx_power);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the radio data rate and modulation settings.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] radio_mode Radio data rate and modulation.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_mode_set(NRF_RADIO_Type * p_reg, nrf_radio_mode_t radio_mode);
|
||||
|
||||
/**
|
||||
* @brief Function for getting Radio data rate and modulation settings.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Radio data rate and modulation.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_radio_mode_t nrf_radio_mode_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the packet configuration.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] p_config Pointer to the structure with packet configuration.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_packet_configure(NRF_RADIO_Type * p_reg,
|
||||
nrf_radio_packet_conf_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the base address 0.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] address Base address 0 value.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_base0_set(NRF_RADIO_Type * p_reg, uint32_t address);
|
||||
|
||||
/**
|
||||
* @brief Function for setting prefixes bytes for logical addresses 0-3.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] prefixes Prefixes bytes for logical addresses 0-3.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_prefix0_set(NRF_RADIO_Type * p_reg, uint32_t prefixes);
|
||||
|
||||
/**
|
||||
* @brief Function for for selecting the receive addresses.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rxaddresses Enable or disable reception on logical address i.
|
||||
* Read more in the Product Specification.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_rxaddresses_set(NRF_RADIO_Type * p_reg, uint8_t rxaddresses);
|
||||
|
||||
/**
|
||||
* @brief Function for configure CRC.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] crc_length CRC length in number of bytes [0-3].
|
||||
* @param[in] crc_address Include or exclude packet address field out of CRC.
|
||||
* @param[in] crc_polynominal CRC polynominal to set.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_crc_configure(NRF_RADIO_Type * p_reg,
|
||||
uint8_t crc_length,
|
||||
nrf_radio_crc_addr_t crc_address,
|
||||
uint32_t crc_polynominal);
|
||||
|
||||
/**
|
||||
* @brief Function for setting CRC initial value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] crc_init_value CRC initial value
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_crcinit_set(NRF_RADIO_Type * p_reg, uint32_t crc_init_value);
|
||||
|
||||
/**
|
||||
* @brief Function for getting CRC initial value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return CRC initial value.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_radio_crcinit_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting RSSI sample result.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @note The read value is a positive value while the actual received signal
|
||||
* is a negative value. Actual received signal strength is therefore as follows:
|
||||
* received signal strength = - read_value dBm .
|
||||
*
|
||||
* @return RSSI sample result.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_rssi_sample_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the current state of the radio module.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Current radio state.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_radio_state_t nrf_radio_state_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the data whitening initial value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] datawhiteiv Data whitening initial value.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_datawhiteiv_set(NRF_RADIO_Type * p_reg, uint8_t datawhiteiv);
|
||||
|
||||
/**
|
||||
* @brief Function for setting Bit counter compare.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] radio_bcc Bit counter compare [bits].
|
||||
*/
|
||||
void nrf_radio_bcc_set(NRF_RADIO_Type * p_reg, uint32_t radio_bcc);
|
||||
|
||||
/**
|
||||
* @brief Function for setting Device address base segment.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] dab_value Particular base segment value.
|
||||
* @param[in] segment Index of the particular Device address base segment register.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_dab_set(NRF_RADIO_Type * p_reg,
|
||||
uint32_t dab_value,
|
||||
uint8_t segment);
|
||||
|
||||
/**
|
||||
* @brief Function for setting device address prefix.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] dap_value Particular device address prefix value.
|
||||
* @param[in] prefix_index Index of the particular device address prefix register.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_dap_set(NRF_RADIO_Type * p_reg,
|
||||
uint16_t dap_value,
|
||||
uint8_t prefix_index);
|
||||
|
||||
/**
|
||||
* @brief Function for setting device address match configuration.
|
||||
*
|
||||
* @note Read more about configuring device address match in the Product Specification.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ena Device address matching bitmask.
|
||||
* @param[in] txadd TxAdd bitmask.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_dacnf_set(NRF_RADIO_Type * p_reg, uint8_t ena, uint8_t txadd);
|
||||
|
||||
/**
|
||||
* @brief Function for getting ENA field of the Device address match configuration register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return ENA field of the Device address match configuration register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_dacnf_ena_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for getting TXADD field of the Device address match configuration register.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return TXADD field of the Device address match configuration register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_dacnf_txadd_get(NRF_RADIO_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting Radio mode configuration register 0.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] fast_ramp_up Use fast radio ramp-up time
|
||||
* @param[in] default_tx Default TX value during inactivity.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_radio_modecnf0_set(NRF_RADIO_Type * p_reg,
|
||||
bool fast_ramp_up,
|
||||
uint8_t default_tx);
|
||||
|
||||
/**
|
||||
* @brief Function for setting power mode of the radio peripheral.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] radio_power If radio should be powered on.
|
||||
*/
|
||||
void nrf_radio_power_set(NRF_RADIO_Type * p_reg, bool radio_power);
|
||||
|
||||
/*****************************/
|
||||
/* Inlined functions bodies: */
|
||||
/*****************************/
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_event_clear(NRF_RADIO_Type * p_reg, nrf_radio_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_radio_event_check(NRF_RADIO_Type const * p_reg, nrf_radio_event_t event)
|
||||
{
|
||||
return (bool) *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_shorts_enable(NRF_RADIO_Type * p_reg, uint32_t shorts_mask)
|
||||
{
|
||||
p_reg->SHORTS |= shorts_mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_shorts_disable(NRF_RADIO_Type * p_reg, uint32_t shorts_mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~shorts_mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_shorts_set(NRF_RADIO_Type * p_reg, uint32_t shorts_mask)
|
||||
{
|
||||
p_reg->SHORTS = shorts_mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_radio_int_enable_check(NRF_RADIO_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_radio_crc_status_check(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return ((p_reg->CRCSTATUS & RADIO_CRCSTATUS_CRCSTATUS_Msk) >> RADIO_CRCSTATUS_CRCSTATUS_Pos)
|
||||
== RADIO_CRCSTATUS_CRCSTATUS_CRCOk ;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_dai_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)p_reg->DAI;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_packetptr_set(NRF_RADIO_Type * p_reg, void const * p_packet)
|
||||
{
|
||||
p_reg->PACKETPTR = (uint32_t)p_packet;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void * nrf_radio_packetptr_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return (void *)p_reg->PACKETPTR;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_frequency_set(NRF_RADIO_Type * p_reg, uint16_t radio_frequency)
|
||||
{
|
||||
NRFX_ASSERT(radio_frequency <= 2500);
|
||||
NRFX_ASSERT(radio_frequency >= 2400);
|
||||
p_reg->FREQUENCY = (uint32_t)(radio_frequency - 2400);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_txpower_set(NRF_RADIO_Type * p_reg, nrf_radio_txpower_t tx_power)
|
||||
{
|
||||
p_reg->TXPOWER = (((uint32_t)tx_power) << RADIO_TXPOWER_TXPOWER_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_mode_set(NRF_RADIO_Type * p_reg, nrf_radio_mode_t radio_mode)
|
||||
{
|
||||
p_reg->MODE = ((uint32_t) radio_mode << RADIO_MODE_MODE_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_radio_mode_t nrf_radio_mode_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return (nrf_radio_mode_t)((p_reg->MODE & RADIO_MODE_MODE_Msk) >> RADIO_MODE_MODE_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_packet_configure(NRF_RADIO_Type * p_reg,
|
||||
nrf_radio_packet_conf_t const * p_config)
|
||||
{
|
||||
p_reg->PCNF0 = (((uint32_t)p_config->lflen << RADIO_PCNF0_LFLEN_Pos) |
|
||||
((uint32_t)p_config->s0len << RADIO_PCNF0_S0LEN_Pos) |
|
||||
((uint32_t)p_config->s1len << RADIO_PCNF0_S1LEN_Pos) |
|
||||
#if defined(RADIO_PCNF0_S1INCL_Msk)
|
||||
(p_config->s1incl ?
|
||||
(RADIO_PCNF0_S1INCL_Include << RADIO_PCNF0_S1INCL_Pos) :
|
||||
(RADIO_PCNF0_S1INCL_Automatic << RADIO_PCNF0_S1INCL_Pos) ) |
|
||||
#endif
|
||||
#if defined(RADIO_PCNF0_CILEN_Msk)
|
||||
((uint32_t)p_config->cilen << RADIO_PCNF0_CILEN_Pos) |
|
||||
#endif
|
||||
#if defined(RADIO_PCNF0_PLEN_Msk)
|
||||
((uint32_t)p_config->plen << RADIO_PCNF0_PLEN_Pos) |
|
||||
#endif
|
||||
#if defined(RADIO_PCNF0_CRCINC_Msk)
|
||||
(p_config->crcinc ?
|
||||
(RADIO_PCNF0_CRCINC_Include << RADIO_PCNF0_CRCINC_Pos) :
|
||||
(RADIO_PCNF0_CRCINC_Exclude << RADIO_PCNF0_CRCINC_Pos) ) |
|
||||
#endif
|
||||
#if defined(RADIO_PCNF0_TERMLEN_Msk)
|
||||
((uint32_t)p_config->termlen << RADIO_PCNF0_TERMLEN_Pos) |
|
||||
#endif
|
||||
0);
|
||||
|
||||
p_reg->PCNF1 = (((uint32_t)p_config->maxlen << RADIO_PCNF1_MAXLEN_Pos) |
|
||||
((uint32_t)p_config->statlen << RADIO_PCNF1_STATLEN_Pos) |
|
||||
((uint32_t)p_config->balen << RADIO_PCNF1_BALEN_Pos) |
|
||||
(p_config->big_endian ?
|
||||
(RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) :
|
||||
(RADIO_PCNF1_ENDIAN_Little << RADIO_PCNF1_ENDIAN_Pos) ) |
|
||||
(p_config->whiteen ?
|
||||
(RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos) :
|
||||
(RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) ));
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_base0_set(NRF_RADIO_Type * p_reg, uint32_t address)
|
||||
{
|
||||
p_reg->BASE0 = address;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_prefix0_set(NRF_RADIO_Type * p_reg, uint32_t prefixes)
|
||||
{
|
||||
p_reg->PREFIX0 = prefixes;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_rxaddresses_set(NRF_RADIO_Type * p_reg, uint8_t rxaddresses)
|
||||
{
|
||||
p_reg->RXADDRESSES = (uint32_t)(rxaddresses);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_crc_configure(NRF_RADIO_Type * p_reg,
|
||||
uint8_t crc_length,
|
||||
nrf_radio_crc_addr_t crc_address,
|
||||
uint32_t crc_polynominal)
|
||||
{
|
||||
p_reg->CRCCNF = ((uint32_t)crc_length << RADIO_CRCCNF_LEN_Pos) |
|
||||
((uint32_t)crc_address << RADIO_CRCCNF_SKIPADDR_Pos);
|
||||
p_reg->CRCPOLY = (crc_polynominal << RADIO_CRCPOLY_CRCPOLY_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_crcinit_set(NRF_RADIO_Type * p_reg, uint32_t crc_init_value)
|
||||
{
|
||||
p_reg->CRCINIT = crc_init_value;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_radio_crcinit_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return p_reg->CRCINIT;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_rssi_sample_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)((p_reg->RSSISAMPLE & RADIO_RSSISAMPLE_RSSISAMPLE_Msk) >>
|
||||
RADIO_RSSISAMPLE_RSSISAMPLE_Pos);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_radio_state_t nrf_radio_state_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return (nrf_radio_state_t) p_reg->STATE;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_datawhiteiv_set(NRF_RADIO_Type * p_reg, uint8_t datawhiteiv)
|
||||
{
|
||||
p_reg->DATAWHITEIV = (((uint32_t)datawhiteiv) & RADIO_DATAWHITEIV_DATAWHITEIV_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_dab_set(NRF_RADIO_Type * p_reg,
|
||||
uint32_t dab_value,
|
||||
uint8_t segment)
|
||||
{
|
||||
NRFX_ASSERT(segment < 8);
|
||||
p_reg->DAB[segment] = dab_value;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_dap_set(NRF_RADIO_Type * p_reg,
|
||||
uint16_t dap_value,
|
||||
uint8_t prefix_index)
|
||||
{
|
||||
NRFX_ASSERT(prefix_index < 8);
|
||||
p_reg->DAP[prefix_index] = (uint32_t)dap_value;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_dacnf_set(NRF_RADIO_Type * p_reg, uint8_t ena, uint8_t txadd)
|
||||
{
|
||||
p_reg->DACNF = (((uint32_t)ena << RADIO_DACNF_ENA0_Pos) |
|
||||
((uint32_t)txadd << RADIO_DACNF_TXADD0_Pos));
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_dacnf_ena_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return (p_reg->DACNF & (RADIO_DACNF_ENA0_Msk |
|
||||
RADIO_DACNF_ENA1_Msk |
|
||||
RADIO_DACNF_ENA2_Msk |
|
||||
RADIO_DACNF_ENA3_Msk |
|
||||
RADIO_DACNF_ENA4_Msk |
|
||||
RADIO_DACNF_ENA5_Msk |
|
||||
RADIO_DACNF_ENA6_Msk |
|
||||
RADIO_DACNF_ENA7_Msk)) >> RADIO_DACNF_ENA0_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_radio_dacnf_txadd_get(NRF_RADIO_Type const * p_reg)
|
||||
{
|
||||
return (p_reg->DACNF & (RADIO_DACNF_TXADD0_Msk |
|
||||
RADIO_DACNF_TXADD1_Msk |
|
||||
RADIO_DACNF_TXADD2_Msk |
|
||||
RADIO_DACNF_TXADD3_Msk |
|
||||
RADIO_DACNF_TXADD4_Msk |
|
||||
RADIO_DACNF_TXADD5_Msk |
|
||||
RADIO_DACNF_TXADD6_Msk |
|
||||
RADIO_DACNF_TXADD7_Msk)) >> RADIO_DACNF_TXADD0_Pos;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_radio_modecnf0_set(NRF_RADIO_Type * p_reg,
|
||||
bool fast_ramp_up,
|
||||
uint8_t default_tx)
|
||||
{
|
||||
p_reg->MODECNF0 = (fast_ramp_up ? (RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos) :
|
||||
(RADIO_MODECNF0_RU_Default << RADIO_MODECNF0_RU_Pos) ) |
|
||||
(((uint32_t)default_tx) << RADIO_MODECNF0_DTX_Pos);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_RADIO_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_rng.h"
|
||||
#include "hal/nrf_rng.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_RNG.h"
|
||||
|
||||
|
|
|
@ -1,214 +0,0 @@
|
|||
/**
|
||||
* Part of the real nrf_rng.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_RNG_H__
|
||||
#define BS_NRF_RNG_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_rng_hal RNG HAL
|
||||
* @{
|
||||
* @ingroup nrf_rng
|
||||
* @brief Hardware access layer for managing the Random Number Generator (RNG) peripheral.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @enum nrf_rng_task_t
|
||||
* @brief RNG tasks.
|
||||
*/
|
||||
typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */
|
||||
{
|
||||
NRF_RNG_TASK_START = offsetof(NRF_RNG_Type, TASKS_START), /**< Start the random number generator. */
|
||||
NRF_RNG_TASK_STOP = offsetof(NRF_RNG_Type, TASKS_STOP) /**< Stop the random number generator. */
|
||||
} nrf_rng_task_t; /*lint -restore */
|
||||
|
||||
/**
|
||||
* @enum nrf_rng_event_t
|
||||
* @brief RNG events.
|
||||
*/
|
||||
typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */
|
||||
{
|
||||
NRF_RNG_EVENT_VALRDY = offsetof(NRF_RNG_Type, EVENTS_VALRDY) /**< New random number generated event. */
|
||||
} nrf_rng_event_t; /*lint -restore */
|
||||
|
||||
/**
|
||||
* @enum nrf_rng_int_mask_t
|
||||
* @brief RNG interrupts.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_RNG_INT_VALRDY_MASK = RNG_INTENSET_VALRDY_Msk /**< Mask for enabling or disabling an interrupt on VALRDY event. */
|
||||
} nrf_rng_int_mask_t;
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
void nrf_rng_int_enable(NRF_RNG_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
void nrf_rng_int_disable(NRF_RNG_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the specified task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_task The specified Task.
|
||||
*/
|
||||
void nrf_rng_task_trigger(NRF_RNG_Type * p_reg, nrf_rng_task_t rng_task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_event The specified event.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the specified event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] rng_event The specified event.
|
||||
*
|
||||
* @retval true The event is set.
|
||||
* @retval false The event is not set.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing shortcuts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of shortcuts.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rng_shorts_disable(NRF_RNG_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the previously generated random value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Previously generated random value.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling digital error correction.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling digital error correction.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg);
|
||||
|
||||
|
||||
|
||||
/* Bodies for inlined functions */
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event)) = 0x0UL;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event)
|
||||
{
|
||||
return (bool) * ((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event));
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_rng_shorts_disable(NRF_RNG_Type * p_reg, uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg)
|
||||
{
|
||||
return (uint8_t)(p_reg->VALUE & RNG_VALUE_VALUE_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg)
|
||||
{
|
||||
p_reg->CONFIG |= RNG_CONFIG_DERCEN_Msk;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg)
|
||||
{
|
||||
p_reg->CONFIG &= ~RNG_CONFIG_DERCEN_Msk;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_RNG_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_rtc.h"
|
||||
#include "hal/nrf_rtc.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_RTC.h"
|
||||
|
||||
|
|
|
@ -1,283 +0,0 @@
|
|||
/**
|
||||
* Part of the real nrf_rtc.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_RTC_H__
|
||||
#define BS_NRF_RTC_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @enum nrf_rtc_task_t
|
||||
* @brief RTC tasks.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*lint -save -e30*/
|
||||
NRF_RTC_TASK_START = offsetof(NRF_RTC_Type,TASKS_START), /**< Start. */
|
||||
NRF_RTC_TASK_STOP = offsetof(NRF_RTC_Type,TASKS_STOP), /**< Stop. */
|
||||
NRF_RTC_TASK_CLEAR = offsetof(NRF_RTC_Type,TASKS_CLEAR), /**< Clear. */
|
||||
NRF_RTC_TASK_TRIGGER_OVERFLOW = offsetof(NRF_RTC_Type,TASKS_TRIGOVRFLW),/**< Trigger overflow. */
|
||||
/*lint -restore*/
|
||||
} nrf_rtc_task_t;
|
||||
|
||||
/**
|
||||
* @enum nrf_rtc_event_t
|
||||
* @brief RTC events.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*lint -save -e30*/
|
||||
NRF_RTC_EVENT_TICK = offsetof(NRF_RTC_Type,EVENTS_TICK), /**< Tick event. */
|
||||
NRF_RTC_EVENT_OVERFLOW = offsetof(NRF_RTC_Type,EVENTS_OVRFLW), /**< Overflow event. */
|
||||
NRF_RTC_EVENT_COMPARE_0 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[0]), /**< Compare 0 event. */
|
||||
NRF_RTC_EVENT_COMPARE_1 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[1]), /**< Compare 1 event. */
|
||||
NRF_RTC_EVENT_COMPARE_2 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[2]), /**< Compare 2 event. */
|
||||
NRF_RTC_EVENT_COMPARE_3 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[3]) /**< Compare 3 event. */
|
||||
/*lint -restore*/
|
||||
} nrf_rtc_event_t;
|
||||
|
||||
/**
|
||||
* @enum nrf_rtc_int_t
|
||||
* @brief RTC interrupts.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_RTC_INT_TICK_MASK = RTC_INTENSET_TICK_Msk, /**< RTC interrupt from tick event. */
|
||||
NRF_RTC_INT_OVERFLOW_MASK = RTC_INTENSET_OVRFLW_Msk, /**< RTC interrupt from overflow event. */
|
||||
NRF_RTC_INT_COMPARE0_MASK = RTC_INTENSET_COMPARE0_Msk, /**< RTC interrupt from compare event on channel 0. */
|
||||
NRF_RTC_INT_COMPARE1_MASK = RTC_INTENSET_COMPARE1_Msk, /**< RTC interrupt from compare event on channel 1. */
|
||||
NRF_RTC_INT_COMPARE2_MASK = RTC_INTENSET_COMPARE2_Msk, /**< RTC interrupt from compare event on channel 2. */
|
||||
NRF_RTC_INT_COMPARE3_MASK = RTC_INTENSET_COMPARE3_Msk /**< RTC interrupt from compare event on channel 3. */
|
||||
} nrf_rtc_int_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for setting a compare value for a channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ch Channel.
|
||||
* @param[in] cc_val Compare value to be set.
|
||||
*/
|
||||
void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the compare value for a channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] ch Channel.
|
||||
*
|
||||
* @return COMPARE[ch] value.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupt mask to be enabled.
|
||||
*/
|
||||
void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Interrupt mask to be disabled.
|
||||
*/
|
||||
void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the RTC event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing an event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be cleared.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning a counter value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
*
|
||||
* @return Counter value.
|
||||
*/
|
||||
uint32_t nrf_rtc_counter_get(NRF_RTC_Type const * p_reg);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a prescaler value.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] val Value to set the prescaler to.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of an event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Requested event.
|
||||
*
|
||||
* @return Address of the requested event register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of a task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Requested task.
|
||||
*
|
||||
* @return Address of the requested task register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for starting a task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Requested task.
|
||||
*/
|
||||
void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling events.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of event flags to be enabled.
|
||||
*/
|
||||
void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling an event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Requested event.
|
||||
*/
|
||||
void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the COMPARE event associated with the specified compare channel.
|
||||
*
|
||||
* @param[in] index Compare channel index.
|
||||
*
|
||||
* @return Requested COMPARE event.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index);
|
||||
|
||||
/*****************************/
|
||||
/* Inlined functions bodies: */
|
||||
/*****************************/
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch)
|
||||
{
|
||||
return p_reg->CC[ch];
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val)
|
||||
{
|
||||
p_reg->PRESCALER = val;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_event_t event)
|
||||
{
|
||||
return (uint32_t)p_reg + event;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
|
||||
nrf_rtc_task_t task)
|
||||
{
|
||||
return (uint32_t)p_reg + task;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index)
|
||||
{
|
||||
return (nrf_rtc_event_t)NRFX_OFFSETOF(NRF_RTC_Type, EVENTS_COMPARE[index]);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_RTC_H__ */
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Oticon A/S
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/*
|
||||
* Zephyr's drives and the nrfx HAL
|
||||
* expect a few symbols/definitions to be available:
|
||||
* The registers addresses
|
||||
* A few SOC related functions.
|
||||
* We provide these here.
|
||||
*
|
||||
* But note that this model does not provide an actual model
|
||||
* of these SOC functions. It is the Zephyr board who is meant
|
||||
* to implement them
|
||||
*/
|
||||
|
||||
#ifndef NRF_SOC_IF_H
|
||||
#define NRF_SOC_IF_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "NRF_regs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Redefine the addresses to the HW we will be using, so we point
|
||||
* to the HW models registers instead of hard addresses
|
||||
*/
|
||||
extern NRF_AAR_Type NRF_AAR_regs;
|
||||
#undef NRF_AAR_BASE
|
||||
#define NRF_AAR_BASE (&NRF_AAR_regs)
|
||||
extern NRF_RNG_Type NRF_RNG_regs;
|
||||
#undef NRF_RNG_BASE
|
||||
#define NRF_RNG_BASE (&NRF_RNG_regs)
|
||||
extern NRF_TEMP_Type NRF_TEMP_regs;
|
||||
#undef NRF_TEMP_BASE
|
||||
#define NRF_TEMP_BASE (&NRF_TEMP_regs)
|
||||
extern NRF_RTC_Type NRF_RTC_regs[];
|
||||
#undef NRF_RTC0_BASE
|
||||
#define NRF_RTC0_BASE (&NRF_RTC_regs[0])
|
||||
#undef NRF_RTC1_BASE
|
||||
#define NRF_RTC1_BASE (&NRF_RTC_regs[1])
|
||||
extern NRF_ECB_Type NRF_ECB_regs;
|
||||
#undef NRF_ECB_BASE
|
||||
#define NRF_ECB_BASE (&NRF_ECB_regs)
|
||||
extern NRF_CCM_Type NRF_CCM_regs;
|
||||
#undef NRF_CCM_BASE
|
||||
#define NRF_CCM_BASE (&NRF_CCM_regs)
|
||||
extern NRF_RADIO_Type NRF_RADIO_regs;
|
||||
#undef NRF_RADIO_BASE
|
||||
#define NRF_RADIO_BASE (&NRF_RADIO_regs)
|
||||
extern NRF_CLOCK_Type NRF_CLOCK_regs;
|
||||
#undef NRF_CLOCK_BASE
|
||||
#define NRF_CLOCK_BASE (&NRF_CLOCK_regs)
|
||||
extern NRF_FICR_Type NRF_FICR_regs;
|
||||
#undef NRF_FICR_BASE
|
||||
#define NRF_FICR_BASE (&NRF_FICR_regs)
|
||||
extern NRF_PPI_Type NRF_PPI_regs;
|
||||
#undef NRF_PPI_BASE
|
||||
#define NRF_PPI_BASE (&NRF_PPI_regs)
|
||||
extern NRF_TIMER_Type NRF_TIMER_regs[];
|
||||
#undef NRF_TIMER0_BASE
|
||||
#define NRF_TIMER0_BASE (&NRF_TIMER_regs[0])
|
||||
#undef NRF_TIMER1_BASE
|
||||
#define NRF_TIMER1_BASE (&NRF_TIMER_regs[1])
|
||||
#undef NRF_TIMER2_BASE
|
||||
#define NRF_TIMER2_BASE (&NRF_TIMER_regs[2])
|
||||
#undef NRF_TIMER3_BASE
|
||||
#define NRF_TIMER3_BASE (&NRF_TIMER_regs[3])
|
||||
#undef NRF_TIMER4_BASE
|
||||
#define NRF_TIMER4_BASE (&NRF_TIMER_regs[4])
|
||||
extern NRF_POWER_Type NRF_POWER_regs;
|
||||
#define NRF_POWER_BASE (&NRF_POWER_regs)
|
||||
extern NRF_GPIO_Type NRF_P0_regs;
|
||||
#undef NRF_P0_BASE
|
||||
#define NRF_P0_BASE (&NRF_P0_regs)
|
||||
extern NRF_GPIOTE_Type NRF_GPIOTE_regs;
|
||||
#undef NRF_GPIOTE_BASE
|
||||
#define NRF_GPIOTE_BASE (&NRF_GPIOTE_regs)
|
||||
extern NRF_NVMC_Type NRF_NVMC_regs;
|
||||
#undef NRF_NVMC_BASE
|
||||
#define NRF_NVMC_BASE (&NRF_NVMC_regs)
|
||||
|
||||
|
||||
/**
|
||||
* Note that the model of the CPU & IRQ controller driver must provide
|
||||
* these functions below. These HW models do not provide them
|
||||
*/
|
||||
extern void __WFE(void);
|
||||
extern void __SEV(void);
|
||||
extern void NVIC_SetPendingIRQ(IRQn_Type IRQn);
|
||||
extern void NVIC_ClearPendingIRQ(IRQn_Type IRQn);
|
||||
|
||||
#ifndef NRFX_ASSERT
|
||||
#define NRFX_ASSERT(...)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef BS_NRF_TEMP_H__
|
||||
#define BS_NRF_TEMP_H__
|
||||
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#endif /* BS_NRF_TEMP_H__ */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Note that the function prototypes are taken from the NRFx HAL
|
||||
*/
|
||||
#include "nrf_timer.h"
|
||||
#include "hal/nrf_timer.h"
|
||||
#include "bs_tracing.h"
|
||||
#include "NRF_TIMER.h"
|
||||
|
||||
|
|
|
@ -1,370 +0,0 @@
|
|||
/**
|
||||
* Part of the real nrf_timer.h from Nordic's NRFx HAL
|
||||
*
|
||||
* Note that there is a few changes compared to the original
|
||||
* Where relevant, these changes are:
|
||||
* Copyright (c) 2017 Oticon A/S
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 BS_NRF_TIMER_H__
|
||||
#define BS_NRF_TIMER_H__
|
||||
|
||||
#include "nrf_soc_if.h"
|
||||
#include "../drivers/nrfx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Timer tasks.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*lint -save -e30 -esym(628,__INTADDR__)*/
|
||||
NRF_TIMER_TASK_START = offsetof(NRF_TIMER_Type, TASKS_START), ///< Task for starting the timer.
|
||||
NRF_TIMER_TASK_STOP = offsetof(NRF_TIMER_Type, TASKS_STOP), ///< Task for stopping the timer.
|
||||
NRF_TIMER_TASK_COUNT = offsetof(NRF_TIMER_Type, TASKS_COUNT), ///< Task for incrementing the timer (in counter mode).
|
||||
NRF_TIMER_TASK_CLEAR = offsetof(NRF_TIMER_Type, TASKS_CLEAR), ///< Task for resetting the timer value.
|
||||
NRF_TIMER_TASK_SHUTDOWN = offsetof(NRF_TIMER_Type, TASKS_SHUTDOWN), ///< Task for powering off the timer.
|
||||
NRF_TIMER_TASK_CAPTURE0 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[0]), ///< Task for capturing the timer value on channel 0.
|
||||
NRF_TIMER_TASK_CAPTURE1 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[1]), ///< Task for capturing the timer value on channel 1.
|
||||
NRF_TIMER_TASK_CAPTURE2 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[2]), ///< Task for capturing the timer value on channel 2.
|
||||
NRF_TIMER_TASK_CAPTURE3 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[3]), ///< Task for capturing the timer value on channel 3.
|
||||
#if defined(TIMER_INTENSET_COMPARE4_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_TASK_CAPTURE4 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[4]), ///< Task for capturing the timer value on channel 4.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE5_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_TASK_CAPTURE5 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[5]), ///< Task for capturing the timer value on channel 5.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE6_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_TASK_CAPTURE6 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[6]), ///< Task for capturing the timer value on channel 6.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE7_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_TASK_CAPTURE7 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[7]), ///< Task for capturing the timer value on channel 7.
|
||||
#endif
|
||||
/*lint -restore*/
|
||||
} nrf_timer_task_t;
|
||||
|
||||
/** @brief Timer events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_TIMER_EVENT_COMPARE0 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[0]), ///< Event from compare channel 0.
|
||||
NRF_TIMER_EVENT_COMPARE1 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[1]), ///< Event from compare channel 1.
|
||||
NRF_TIMER_EVENT_COMPARE2 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[2]), ///< Event from compare channel 2.
|
||||
NRF_TIMER_EVENT_COMPARE3 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[3]), ///< Event from compare channel 3.
|
||||
#if defined(TIMER_INTENSET_COMPARE4_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_EVENT_COMPARE4 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[4]), ///< Event from compare channel 4.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE5_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_EVENT_COMPARE5 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[5]), ///< Event from compare channel 5.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE6_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_EVENT_COMPARE6 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[6]), ///< Event from compare channel 6.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE7_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_EVENT_COMPARE7 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[7]), ///< Event from compare channel 7.
|
||||
#endif
|
||||
} nrf_timer_event_t;
|
||||
|
||||
/** @brief Timer modes. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_TIMER_MODE_TIMER = TIMER_MODE_MODE_Timer, ///< Timer mode: timer.
|
||||
NRF_TIMER_MODE_COUNTER = TIMER_MODE_MODE_Counter, ///< Timer mode: counter.
|
||||
#if defined(TIMER_MODE_MODE_LowPowerCounter) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_MODE_LOW_POWER_COUNTER = TIMER_MODE_MODE_LowPowerCounter, ///< Timer mode: low-power counter.
|
||||
#endif
|
||||
} nrf_timer_mode_t;
|
||||
|
||||
/** @brief Timer bit width. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_TIMER_BIT_WIDTH_8 = TIMER_BITMODE_BITMODE_08Bit, ///< Timer bit width 8 bit.
|
||||
NRF_TIMER_BIT_WIDTH_16 = TIMER_BITMODE_BITMODE_16Bit, ///< Timer bit width 16 bit.
|
||||
NRF_TIMER_BIT_WIDTH_24 = TIMER_BITMODE_BITMODE_24Bit, ///< Timer bit width 24 bit.
|
||||
NRF_TIMER_BIT_WIDTH_32 = TIMER_BITMODE_BITMODE_32Bit ///< Timer bit width 32 bit.
|
||||
} nrf_timer_bit_width_t;
|
||||
|
||||
/** @brief Timer prescalers. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_TIMER_FREQ_16MHz = 0, ///< Timer frequency 16 MHz.
|
||||
NRF_TIMER_FREQ_8MHz, ///< Timer frequency 8 MHz.
|
||||
NRF_TIMER_FREQ_4MHz, ///< Timer frequency 4 MHz.
|
||||
NRF_TIMER_FREQ_2MHz, ///< Timer frequency 2 MHz.
|
||||
NRF_TIMER_FREQ_1MHz, ///< Timer frequency 1 MHz.
|
||||
NRF_TIMER_FREQ_500kHz, ///< Timer frequency 500 kHz.
|
||||
NRF_TIMER_FREQ_250kHz, ///< Timer frequency 250 kHz.
|
||||
NRF_TIMER_FREQ_125kHz, ///< Timer frequency 125 kHz.
|
||||
NRF_TIMER_FREQ_62500Hz, ///< Timer frequency 62500 Hz.
|
||||
NRF_TIMER_FREQ_31250Hz ///< Timer frequency 31250 Hz.
|
||||
} nrf_timer_frequency_t;
|
||||
|
||||
/**
|
||||
* @brief Timer capture/compare channels.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_TIMER_CC_CHANNEL0 = 0, ///< Timer capture/compare channel 0.
|
||||
NRF_TIMER_CC_CHANNEL1, ///< Timer capture/compare channel 1.
|
||||
NRF_TIMER_CC_CHANNEL2, ///< Timer capture/compare channel 2.
|
||||
NRF_TIMER_CC_CHANNEL3, ///< Timer capture/compare channel 3.
|
||||
#if defined(TIMER_INTENSET_COMPARE4_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_CC_CHANNEL4, ///< Timer capture/compare channel 4.
|
||||
#endif
|
||||
#if defined(TIMER_INTENSET_COMPARE5_Msk) || defined(__NRFX_DOXYGEN__)
|
||||
NRF_TIMER_CC_CHANNEL5, ///< Timer capture/compare channel 5.
|
||||
#endif
|
||||
} nrf_timer_cc_channel_t;
|
||||
|
||||
/**
|
||||
* @brief Function for activating the specified timer task.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] task Task to be activated.
|
||||
*/
|
||||
void nrf_timer_task_trigger(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_task_t task);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the specified timer event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to clear.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the state of the TIMER event.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] event Event to be checked.
|
||||
*
|
||||
* @retval true The event has been generated.
|
||||
* @retval false The event has not been generated.
|
||||
*/
|
||||
NRF_STATIC_INLINE bool nrf_timer_event_check(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified shortcuts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be enabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified shortcuts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Shortcuts to be disabled.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling the specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be enabled.
|
||||
*/
|
||||
void nrf_timer_int_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling the specified interrupts.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be disabled.
|
||||
*/
|
||||
void nrf_timer_int_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the specified interrupts are enabled.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mask Mask of interrupts to be checked.
|
||||
*
|
||||
* @return Mask of enabled interrupts.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_int_enable_check(NRF_TIMER_Type const * p_reg, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the timer mode.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] mode Timer mode.
|
||||
*/
|
||||
void nrf_timer_mode_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the timer bit width.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] bit_width Timer bit width.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_timer_bit_width_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_bit_width_t bit_width);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the timer frequency.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] frequency Timer frequency.
|
||||
*/
|
||||
NRF_STATIC_INLINE void nrf_timer_frequency_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_frequency_t frequency);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the capture/compare register for the specified channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] cc_channel The specified capture/compare channel.
|
||||
* @param[in] cc_value Value to write to the capture/compare register.
|
||||
*/
|
||||
void nrf_timer_cc_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel,
|
||||
uint32_t cc_value);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the capture/compare value for a specified channel.
|
||||
*
|
||||
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
|
||||
* @param[in] cc_channel The specified capture/compare channel.
|
||||
*
|
||||
* @return Value from the specified capture/compare register.
|
||||
*/
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_cc_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the specified timer capture task.
|
||||
*
|
||||
* @param[in] channel Capture channel.
|
||||
*
|
||||
* @return Capture task.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get(uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the specified timer compare event.
|
||||
*
|
||||
* @param[in] channel Compare channel.
|
||||
*
|
||||
* @return Compare event.
|
||||
*/
|
||||
NRF_STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get(uint32_t channel);
|
||||
|
||||
/*****************************/
|
||||
/* Inlined functions bodies: */
|
||||
/*****************************/
|
||||
|
||||
NRF_STATIC_INLINE void nrf_timer_event_clear(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
{
|
||||
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
|
||||
#if __CORTEX_M == 0x04
|
||||
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
|
||||
(void)dummy;
|
||||
#endif
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE bool nrf_timer_event_check(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_event_t event)
|
||||
{
|
||||
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_enable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS |= mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_timer_shorts_disable(NRF_TIMER_Type * p_reg,
|
||||
uint32_t mask)
|
||||
{
|
||||
p_reg->SHORTS &= ~(mask);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_int_enable_check(NRF_TIMER_Type const * p_reg, uint32_t mask)
|
||||
{
|
||||
return p_reg->INTENSET & mask;
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_timer_bit_width_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_bit_width_t bit_width)
|
||||
{
|
||||
p_reg->BITMODE = (p_reg->BITMODE & ~TIMER_BITMODE_BITMODE_Msk) |
|
||||
((bit_width << TIMER_BITMODE_BITMODE_Pos) &
|
||||
TIMER_BITMODE_BITMODE_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE void nrf_timer_frequency_set(NRF_TIMER_Type * p_reg,
|
||||
nrf_timer_frequency_t frequency)
|
||||
{
|
||||
p_reg->PRESCALER = (p_reg->PRESCALER & ~TIMER_PRESCALER_PRESCALER_Msk) |
|
||||
((frequency << TIMER_PRESCALER_PRESCALER_Pos) &
|
||||
TIMER_PRESCALER_PRESCALER_Msk);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE uint32_t nrf_timer_cc_get(NRF_TIMER_Type const * p_reg,
|
||||
nrf_timer_cc_channel_t cc_channel)
|
||||
{
|
||||
return (uint32_t)p_reg->CC[cc_channel];
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get(uint32_t channel)
|
||||
{
|
||||
return (nrf_timer_task_t)NRFX_OFFSETOF(NRF_TIMER_Type, TASKS_CAPTURE[channel]);
|
||||
}
|
||||
|
||||
NRF_STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get(uint32_t channel)
|
||||
{
|
||||
return (nrf_timer_event_t)NRFX_OFFSETOF(NRF_TIMER_Type, EVENTS_COMPARE[channel]);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BS_NRF_TIMER_H__ */
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef NRF_H__
|
||||
#define NRF_H__
|
||||
|
||||
/* Only include the type definitions of the registers.
|
||||
*
|
||||
* This file will allow code to be compiled for either the real or
|
||||
* mocked HW. */
|
||||
|
||||
#include "NRF_regs.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Provides a mocked nrf.h.
|
||||
* This reuses the nrf.h from the MDK, but defines base registers
|
||||
* and peripheral addresses to point to mocked peripherals.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BSIM_H__
|
||||
#define NRF_BSIM_H__
|
||||
|
||||
/* Include the real nrf.h */
|
||||
#include <mdk/nrf.h>
|
||||
|
||||
/* For BSIM we require redefining the pointers to the peripherals. */
|
||||
#include "nrf_bsim_redef.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Oticon A/S
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file redefines macros from nrf that need to be different for simulated devices.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BSIM_REDEF_H
|
||||
#define NRF_BSIM_REDEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Redefine the base addresses.
|
||||
*/
|
||||
extern NRF_AAR_Type NRF_AAR_regs;
|
||||
#undef NRF_AAR_BASE
|
||||
#define NRF_AAR_BASE (&NRF_AAR_regs)
|
||||
extern NRF_RNG_Type NRF_RNG_regs;
|
||||
#undef NRF_RNG_BASE
|
||||
#define NRF_RNG_BASE (&NRF_RNG_regs)
|
||||
extern NRF_TEMP_Type NRF_TEMP_regs;
|
||||
#undef NRF_TEMP_BASE
|
||||
#define NRF_TEMP_BASE (&NRF_TEMP_regs)
|
||||
extern NRF_RTC_Type NRF_RTC_regs[];
|
||||
#undef NRF_RTC0_BASE
|
||||
#define NRF_RTC0_BASE (&NRF_RTC_regs[0])
|
||||
#undef NRF_RTC1_BASE
|
||||
#define NRF_RTC1_BASE (&NRF_RTC_regs[1])
|
||||
extern NRF_ECB_Type NRF_ECB_regs;
|
||||
#undef NRF_ECB_BASE
|
||||
#define NRF_ECB_BASE (&NRF_ECB_regs)
|
||||
extern NRF_CCM_Type NRF_CCM_regs;
|
||||
#undef NRF_CCM_BASE
|
||||
#define NRF_CCM_BASE (&NRF_CCM_regs)
|
||||
extern NRF_RADIO_Type NRF_RADIO_regs;
|
||||
#undef NRF_RADIO_BASE
|
||||
#define NRF_RADIO_BASE (&NRF_RADIO_regs)
|
||||
extern NRF_CLOCK_Type NRF_CLOCK_regs;
|
||||
#undef NRF_CLOCK_BASE
|
||||
#define NRF_CLOCK_BASE (&NRF_CLOCK_regs)
|
||||
extern NRF_FICR_Type NRF_FICR_regs;
|
||||
#undef NRF_FICR_BASE
|
||||
#define NRF_FICR_BASE (&NRF_FICR_regs)
|
||||
extern NRF_PPI_Type NRF_PPI_regs;
|
||||
#undef NRF_PPI_BASE
|
||||
#define NRF_PPI_BASE (&NRF_PPI_regs)
|
||||
extern NRF_TIMER_Type NRF_TIMER_regs[];
|
||||
#undef NRF_TIMER0_BASE
|
||||
#define NRF_TIMER0_BASE (&NRF_TIMER_regs[0])
|
||||
#undef NRF_TIMER1_BASE
|
||||
#define NRF_TIMER1_BASE (&NRF_TIMER_regs[1])
|
||||
#undef NRF_TIMER2_BASE
|
||||
#define NRF_TIMER2_BASE (&NRF_TIMER_regs[2])
|
||||
#undef NRF_TIMER3_BASE
|
||||
#define NRF_TIMER3_BASE (&NRF_TIMER_regs[3])
|
||||
#undef NRF_TIMER4_BASE
|
||||
#define NRF_TIMER4_BASE (&NRF_TIMER_regs[4])
|
||||
#undef NRF_POWER_BASE
|
||||
extern NRF_POWER_Type NRF_POWER_regs;
|
||||
#define NRF_POWER_BASE (&NRF_POWER_regs)
|
||||
extern NRF_GPIO_Type NRF_P0_regs;
|
||||
#undef NRF_P0_BASE
|
||||
#define NRF_P0_BASE (&NRF_P0_regs)
|
||||
extern NRF_GPIOTE_Type NRF_GPIOTE_regs;
|
||||
#undef NRF_GPIOTE_BASE
|
||||
#define NRF_GPIOTE_BASE (&NRF_GPIOTE_regs)
|
||||
extern NRF_NVMC_Type NRF_NVMC_regs;
|
||||
#undef NRF_NVMC_BASE
|
||||
#define NRF_NVMC_BASE (&NRF_NVMC_regs)
|
||||
|
||||
/*
|
||||
* Redefine the peripheral pointers
|
||||
*/
|
||||
#define NRF_FICR ((NRF_FICR_Type*) NRF_FICR_BASE)
|
||||
#define NRF_UICR ((NRF_UICR_Type*) NRF_UICR_BASE)
|
||||
#define NRF_BPROT ((NRF_BPROT_Type*) NRF_BPROT_BASE)
|
||||
#define NRF_POWER ((NRF_POWER_Type*) NRF_POWER_BASE)
|
||||
#define NRF_CLOCK ((NRF_CLOCK_Type*) NRF_CLOCK_BASE)
|
||||
#define NRF_RADIO ((NRF_RADIO_Type*) NRF_RADIO_BASE)
|
||||
#define NRF_UARTE0 ((NRF_UARTE_Type*) NRF_UARTE0_BASE)
|
||||
#define NRF_UART0 ((NRF_UART_Type*) NRF_UART0_BASE)
|
||||
#define NRF_SPIM0 ((NRF_SPIM_Type*) NRF_SPIM0_BASE)
|
||||
#define NRF_SPIS0 ((NRF_SPIS_Type*) NRF_SPIS0_BASE)
|
||||
#define NRF_TWIM0 ((NRF_TWIM_Type*) NRF_TWIM0_BASE)
|
||||
#define NRF_TWIS0 ((NRF_TWIS_Type*) NRF_TWIS0_BASE)
|
||||
#define NRF_SPI0 ((NRF_SPI_Type*) NRF_SPI0_BASE)
|
||||
#define NRF_TWI0 ((NRF_TWI_Type*) NRF_TWI0_BASE)
|
||||
#define NRF_SPIM1 ((NRF_SPIM_Type*) NRF_SPIM1_BASE)
|
||||
#define NRF_SPIS1 ((NRF_SPIS_Type*) NRF_SPIS1_BASE)
|
||||
#define NRF_TWIM1 ((NRF_TWIM_Type*) NRF_TWIM1_BASE)
|
||||
#define NRF_TWIS1 ((NRF_TWIS_Type*) NRF_TWIS1_BASE)
|
||||
#define NRF_SPI1 ((NRF_SPI_Type*) NRF_SPI1_BASE)
|
||||
#define NRF_TWI1 ((NRF_TWI_Type*) NRF_TWI1_BASE)
|
||||
#define NRF_NFCT ((NRF_NFCT_Type*) NRF_NFCT_BASE)
|
||||
#define NRF_GPIOTE ((NRF_GPIOTE_Type*) NRF_GPIOTE_BASE)
|
||||
#define NRF_SAADC ((NRF_SAADC_Type*) NRF_SAADC_BASE)
|
||||
#define NRF_TIMER0 ((NRF_TIMER_Type*) NRF_TIMER0_BASE)
|
||||
#define NRF_TIMER1 ((NRF_TIMER_Type*) NRF_TIMER1_BASE)
|
||||
#define NRF_TIMER2 ((NRF_TIMER_Type*) NRF_TIMER2_BASE)
|
||||
#define NRF_RTC0 ((NRF_RTC_Type*) NRF_RTC0_BASE)
|
||||
#define NRF_TEMP ((NRF_TEMP_Type*) NRF_TEMP_BASE)
|
||||
#define NRF_RNG ((NRF_RNG_Type*) NRF_RNG_BASE)
|
||||
#define NRF_ECB ((NRF_ECB_Type*) NRF_ECB_BASE)
|
||||
#define NRF_CCM ((NRF_CCM_Type*) NRF_CCM_BASE)
|
||||
#define NRF_AAR ((NRF_AAR_Type*) NRF_AAR_BASE)
|
||||
#define NRF_WDT ((NRF_WDT_Type*) NRF_WDT_BASE)
|
||||
#define NRF_RTC1 ((NRF_RTC_Type*) NRF_RTC1_BASE)
|
||||
#define NRF_QDEC ((NRF_QDEC_Type*) NRF_QDEC_BASE)
|
||||
#define NRF_COMP ((NRF_COMP_Type*) NRF_COMP_BASE)
|
||||
#define NRF_LPCOMP ((NRF_LPCOMP_Type*) NRF_LPCOMP_BASE)
|
||||
#define NRF_SWI0 ((NRF_SWI_Type*) NRF_SWI0_BASE)
|
||||
#define NRF_EGU0 ((NRF_EGU_Type*) NRF_EGU0_BASE)
|
||||
#define NRF_SWI1 ((NRF_SWI_Type*) NRF_SWI1_BASE)
|
||||
#define NRF_EGU1 ((NRF_EGU_Type*) NRF_EGU1_BASE)
|
||||
#define NRF_SWI2 ((NRF_SWI_Type*) NRF_SWI2_BASE)
|
||||
#define NRF_EGU2 ((NRF_EGU_Type*) NRF_EGU2_BASE)
|
||||
#define NRF_SWI3 ((NRF_SWI_Type*) NRF_SWI3_BASE)
|
||||
#define NRF_EGU3 ((NRF_EGU_Type*) NRF_EGU3_BASE)
|
||||
#define NRF_SWI4 ((NRF_SWI_Type*) NRF_SWI4_BASE)
|
||||
#define NRF_EGU4 ((NRF_EGU_Type*) NRF_EGU4_BASE)
|
||||
#define NRF_SWI5 ((NRF_SWI_Type*) NRF_SWI5_BASE)
|
||||
#define NRF_EGU5 ((NRF_EGU_Type*) NRF_EGU5_BASE)
|
||||
#define NRF_TIMER3 ((NRF_TIMER_Type*) NRF_TIMER3_BASE)
|
||||
#define NRF_TIMER4 ((NRF_TIMER_Type*) NRF_TIMER4_BASE)
|
||||
#define NRF_PWM0 ((NRF_PWM_Type*) NRF_PWM0_BASE)
|
||||
#define NRF_PDM ((NRF_PDM_Type*) NRF_PDM_BASE)
|
||||
#define NRF_NVMC ((NRF_NVMC_Type*) NRF_NVMC_BASE)
|
||||
#define NRF_PPI ((NRF_PPI_Type*) NRF_PPI_BASE)
|
||||
#define NRF_MWU ((NRF_MWU_Type*) NRF_MWU_BASE)
|
||||
#define NRF_PWM1 ((NRF_PWM_Type*) NRF_PWM1_BASE)
|
||||
#define NRF_PWM2 ((NRF_PWM_Type*) NRF_PWM2_BASE)
|
||||
#define NRF_SPIM2 ((NRF_SPIM_Type*) NRF_SPIM2_BASE)
|
||||
#define NRF_SPIS2 ((NRF_SPIS_Type*) NRF_SPIS2_BASE)
|
||||
#define NRF_SPI2 ((NRF_SPI_Type*) NRF_SPI2_BASE)
|
||||
#define NRF_RTC2 ((NRF_RTC_Type*) NRF_RTC2_BASE)
|
||||
#define NRF_I2S ((NRF_I2S_Type*) NRF_I2S_BASE)
|
||||
#define NRF_FPU ((NRF_FPU_Type*) NRF_FPU_BASE)
|
||||
#define NRF_P0 ((NRF_GPIO_Type*) NRF_P0_BASE)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_BSIM_REDEF_H */
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Oticon A/S
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file redefines macros from nrfx that need to be different for simulated devices.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_BSIM_REDEF_H
|
||||
#define NRFX_BSIM_REDEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Redefine nrfx common macros that are not valid when using mocked peripherals */
|
||||
#undef NRFX_PERIPHERAL_ID_GET
|
||||
#define NRFX_PERIPHERAL_ID_GET(base_addr) (uint8_t)(nrfx_get_irq_number(base_addr))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRFX_BSIM_REDEF_H */
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Provides a minimalistic nrfx_config to be used with Nordic nrfx and bsim.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_CONFIG_BSIM_H__
|
||||
#define NRFX_CONFIG_BSIM_H__
|
||||
|
||||
/* When the real nrfx HAL headers are included, this header will be included
|
||||
* from them, with the two definitions below. The normal users of the nrfx HAL
|
||||
* will only get the prototype of the functions from the real headers.
|
||||
* The HW models, will include again the real nrfx headers once more,
|
||||
* but setting NRF_DONT_DECLARE_ONLY, and replacing NRF_STATIC_INLINE.
|
||||
* In this way, the HW models will include 1 copy of the functions bodies,
|
||||
* but as normal, globally available functions, instead of inlined versions.
|
||||
* (See src/nrfx/hal/nrf_hal_originals.c for more info)
|
||||
*/
|
||||
#ifndef NRF_DONT_DECLARE_ONLY
|
||||
#define NRF_DECLARE_ONLY
|
||||
#endif
|
||||
|
||||
#ifndef NRF_STATIC_INLINE
|
||||
#define NRF_STATIC_INLINE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When nrfx drivers are compiled for a real SoC, this macro is inherited from
|
||||
* CMSIS. The below definition is needed when those drivers are compiled for
|
||||
* the simulated target.
|
||||
*/
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Suppress use of anomaly workarounds in nrfx drivers that would directly
|
||||
* access hardware registers.
|
||||
*/
|
||||
#define USE_WORKAROUND_FOR_ANOMALY_132 0
|
||||
|
||||
#endif // NRFX_CONFIG_BSIM_H__
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Provides a minimalistic nrfx_glue to be used with Nordic nrfx and bsim.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_GLUE_BSIM_H__
|
||||
#define NRFX_GLUE_BSIM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro for placing a runtime assertion.
|
||||
*
|
||||
* @param expression Expression to be evaluated.
|
||||
*/
|
||||
#ifndef NRFX_ASSERT
|
||||
#define NRFX_ASSERT(expression)
|
||||
#endif
|
||||
|
||||
#include "nrfx_bsim_redef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_GLUE_BSIM_H__
|
|
@ -0,0 +1,3 @@
|
|||
**Sample nrfx configuration files**<br>
|
||||
This folder includes a sample of nrfx configuration files.
|
||||
These are not to be used when building a zephyr application.
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Provides a minimalistic nrfx_config to be used with Nordic nrfx
|
||||
* when not used together with Zephyr.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_CONFIG_H__
|
||||
#define NRFX_CONFIG_H__
|
||||
|
||||
#ifdef __ZEPHYR__
|
||||
#error This file should not be included in builds with Zephyr. Use the one provided by the nordic_hal zephyr module in that case.
|
||||
#endif
|
||||
|
||||
#include "nrfx_config_bsim.h"
|
||||
|
||||
#endif // NRFX_CONFIG_H__
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Provides a minimalistic nrfx_glue to be used with Nordic nrfx
|
||||
* when not used together with Zephyr.
|
||||
*/
|
||||
|
||||
#ifndef NRFX_GLUE_H__
|
||||
#define NRFX_GLUE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __ZEPHYR__
|
||||
#error This file should not be included in builds with Zephyr. Use the one provided by the nordic_hal zephyr module in that case.
|
||||
#endif
|
||||
|
||||
#include "nrfx_glue_bsim.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_GLUE_H__
|
Loading…
Reference in New Issue