[nrf528xx] move to openthread/ot-nrf528xx (#6585)

This commit is contained in:
Jonathan Hui
2021-05-11 16:53:13 -07:00
committed by GitHub
parent a40b42e299
commit 550c2056de
711 changed files with 13 additions and 699632 deletions
-3
View File
@@ -175,9 +175,6 @@ if(OT_PLATFORM STREQUAL "posix")
add_subdirectory("${PROJECT_SOURCE_DIR}/src/posix/platform")
elseif(OT_PLATFORM STREQUAL "external")
# skip in this case
elseif(OT_PLATFORM MATCHES "^nrf*")
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/${OT_PLATFORM})
add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx")
else()
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM})
add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}")
+4 -16
View File
@@ -780,14 +780,14 @@ AC_MSG_CHECKING([whether to build examples])
AC_ARG_WITH(examples,
[AS_HELP_STRING([--with-examples=TARGET],
[Build example applications for one of: simulation, cc2538, nrf52811, nrf52833, nrf52840 @<:@default=no@:>@.
[Build example applications for one of: simulation, cc2538 @<:@default=no@:>@.
Note that building example applications also builds the associated OpenThread platform libraries
and any third_party libraries needed to support the examples.])],
[
case "${with_examples}" in
no)
;;
simulation|cc2538|nrf52811|nrf52833|nrf52840)
simulation|cc2538)
;;
*)
AC_MSG_RESULT(ERROR)
@@ -801,14 +801,9 @@ AM_CONDITIONAL([OPENTHREAD_ENABLE_EXAMPLES], [test ${with_examples} != "no"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_SIMULATION],[test "${with_examples}" = "simulation"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_CC2538], [test "${with_examples}" = "cc2538"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52811], [test "${with_examples}" = "nrf52811"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52833], [test "${with_examples}" = "nrf52833"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52840], [test "${with_examples}" = "nrf52840"])
AM_COND_IF([OPENTHREAD_EXAMPLES_SIMULATION], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=0")
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF528XX], [test OPENTHREAD_EXAMPLES_NRF52811 || test OPENTHREAD_EXAMPLES_NRF52833 || test OPENTHREAD_EXAMPLES_NRF52840])
case ${with_examples} in
no)
AC_MSG_RESULT([no])
@@ -826,11 +821,11 @@ AC_MSG_CHECKING([whether to build platform libraries])
AC_ARG_WITH(platform,
[AS_HELP_STRING([--with-platform=TARGET],
[Build OpenThread platform libraries for one of: cc2538, nrf52811, nrf52833, nrf52840, posix, simulation @<:@default=simulation@:>@.])],
[Build OpenThread platform libraries for one of: cc2538, posix, simulation @<:@default=simulation@:>@.])],
[
# Make sure the given target is valid.
case "${with_platform}" in
no|cc2538|nrf52811|nrf52833|nrf52840|posix|simulation)
no|cc2538|posix|simulation)
;;
*)
AC_MSG_RESULT(ERROR)
@@ -862,14 +857,9 @@ AM_CONDITIONAL([OPENTHREAD_ENABLE_PLATFORM], [test ${with_platform} != "no"])
OPENTHREAD_ENABLE_PLATFORM=${with_platform}
AM_CONDITIONAL([OPENTHREAD_PLATFORM_CC2538], [test "${with_platform}" = "cc2538"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52811], [test "${with_platform}" = "nrf52811"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52833], [test "${with_platform}" = "nrf52833"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52840], [test "${with_platform}" = "nrf52840"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_POSIX], [test "${with_platform}" = "posix"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_SIMULATION],[test "${with_platform}" = "simulation"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF528XX], [test OPENTHREAD_PLATFORM_NRF52811 || test OPENTHREAD_PLATFORM_NRF52833 || test OPENTHREAD_PLATFORM_NRF52840])
AM_COND_IF([OPENTHREAD_PLATFORM_POSIX], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX=0")
case ${with_platform} in
@@ -1002,14 +992,12 @@ src/lib/url/Makefile
third_party/Makefile
third_party/jlink/Makefile
third_party/mbedtls/Makefile
third_party/NordicSemiconductor/Makefile
examples/Makefile
examples/apps/Makefile
examples/apps/cli/Makefile
examples/apps/ncp/Makefile
examples/platforms/Makefile
examples/platforms/cc2538/Makefile
examples/platforms/nrf528xx/Makefile
examples/platforms/simulation/Makefile
examples/platforms/utils/Makefile
tools/Makefile
+3 -5
View File
@@ -30,16 +30,14 @@
function(ot_get_platforms arg_platforms)
list(APPEND result "NO" "posix" "external")
set(platforms_dir "${PROJECT_SOURCE_DIR}/examples/platforms")
file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*"
RELATIVE "${platforms_dir}/nrf528xx" "${platforms_dir}/nrf528xx/nrf*")
file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*")
foreach(platform IN LISTS platforms)
if((IS_DIRECTORY "${platforms_dir}/${platform}") OR
(IS_DIRECTORY "${platforms_dir}/nrf528xx/${platform}"))
if(IS_DIRECTORY "${platforms_dir}/${platform}")
list(APPEND result "${platform}")
endif()
endforeach()
list(REMOVE_ITEM result utils nrf528xx)
list(REMOVE_ITEM result utils)
list(SORT result)
set(${arg_platforms} "${result}" PARENT_SCOPE)
endfunction()
-309
View File
@@ -1,309 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = $(CCPREFIX) arm-none-eabi-gcc
CPP = arm-none-eabi-cpp
CC = $(CCPREFIX) arm-none-eabi-gcc
CXX = $(CCPREFIX) arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d.`)
configure_OPTIONS = \
--enable-mtd \
--enable-linker-map \
--with-examples=nrf52811 \
MBEDTLS_CPPFLAGS="$(NRF52811_MBEDTLS_CPPFLAGS)" \
$(NULL)
ifdef SRC_PATH
configure_OPTIONS += --srcdir="$(SRC_PATH)"
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
NRF52811_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
NRF52811_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"nrf52811-mbedtls-config.h\"'
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/nrfx/mdk
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/cmsis
NRF52811_MBEDTLS_CPPFLAGS += -DNRF52811_XXAA
NRF52811_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-nrf52811-config.h\"'
NRF52811_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-nrf52811-config-check.h\"'
NRF52811_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52811
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
$(NRF52811_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
ifeq ($(DCDC),1)
COMMONCFLAGS += -DDCDC_ENABLE
endif
#
# Select transport which CLI, NCP and RCP examples will use to communicate.
# To disable all transports use the DISABLE_TRANSPORTS switch. This will disable
# the build of all above examples.
# If NCP_SPI switch is set, only NCP and RCP examples will be built.
# Otherwise, the default serial transport is UART.
#
ifndef DISABLE_TRANSPORTS
configure_OPTIONS += --enable-radio-only
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DSPIS_AS_SERIAL_TRANSPORT=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
COMMONCFLAGS += -DUART_AS_SERIAL_TRANSPORT=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1
configure_OPTIONS += --enable-cli
endif # NCP_SPI == 1
endif # DISABLE_TRANSPORTS
NRF52811_MBEDTLS_CPPFLAGS += -DDISABLE_CC310=1
ifeq ($(shell expr $(GCCVersion) \>= 7), 1)
COMMONCFLAGS += -Wno-expansion-to-defined
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
CCASFLAGS += \
$(COMMONCCASFLAGS) \
$(target_CCASFLAGS) \
-x \
assembler-with-cpp \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = nrf52811
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(TargetTuple) && $(AbsTopSourceDir)/configure \
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" CCAS="$(CCAS)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CCASFLAGS="$(CCASFLAGS)" LDFLAGS="$(LDFLAGS)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): target_CCASFLAGS=$($(1)_target_CCASFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# Cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb -mabi=aapcs
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb -mabi=aapcs
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb -mabi=aapcs
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb -mabi=aapcs
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
-342
View File
@@ -1,342 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = $(CCPREFIX) arm-none-eabi-gcc
CPP = arm-none-eabi-cpp
CC = $(CCPREFIX) arm-none-eabi-gcc
CXX = $(CCPREFIX) arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d.`)
configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-linker-map \
--with-examples=nrf52833 \
MBEDTLS_CPPFLAGS="$(NRF52833_MBEDTLS_CPPFLAGS)" \
$(NULL)
ifdef SRC_PATH
configure_OPTIONS += --srcdir="$(SRC_PATH)"
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
NRF52833_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
NRF52833_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"nrf52833-mbedtls-config.h\"'
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/nrfx/mdk
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/cmsis
NRF52833_MBEDTLS_CPPFLAGS += -DNRF52833_XXAA
NRF52833_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-nrf52833-config.h\"'
NRF52833_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-nrf52833-config-check.h\"'
NRF52833_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
$(NRF52833_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
ifeq ($(BOOTLOADER),1)
$(info Warning: BOOTLOADER=1 switch is deprecated. Defaulting to BOOTLOADER=USB.)
override BOOTLOADER = USB
endif
ifeq ($(BOOTLOADER),USB)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833/nrf52833_bootloader_usb.ld
COMMONCFLAGS += -DAPP_USBD_NRF_DFU_TRIGGER_ENABLED=1
endif
ifeq ($(BOOTLOADER),UART)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833/nrf52833_bootloader_uart.ld
endif
ifeq ($(BOOTLOADER),BLE)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833/nrf52833_bootloader_ble.ld
endif
#
# Select transport which CLI, NCP and RCP examples will use to communicate.
# To disable all transports use the DISABLE_TRANSPORTS switch. This will disable
# the build of all above examples.
# If NCP_SPI switch is set, only NCP and RCP examples will be built.
# Otherwise the user can select USB transport. If no transports were selected,
# the default serial transport is UART.
#
ifndef DISABLE_TRANSPORTS
configure_OPTIONS += --enable-ncp
configure_OPTIONS += --enable-radio-only
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DSPIS_AS_SERIAL_TRANSPORT=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1
configure_OPTIONS += --enable-cli
ifeq ($(USB),1)
COMMONCFLAGS += -DUSB_CDC_AS_SERIAL_TRANSPORT=1
else
COMMONCFLAGS += -DUART_AS_SERIAL_TRANSPORT=1
endif # USB == 1
endif # NCP_SPI == 1
endif # DISABLE_TRANSPORTS
NRF52833_MBEDTLS_CPPFLAGS += -DDISABLE_CC310=1
ifeq ($(shell expr $(GCCVersion) \>= 7), 1)
COMMONCFLAGS += -Wno-expansion-to-defined
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
CCASFLAGS += \
$(COMMONCCASFLAGS) \
$(target_CCASFLAGS) \
-x \
assembler-with-cpp \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = nrf52833
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(TargetTuple) && $(AbsTopSourceDir)/configure \
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" CCAS="$(CCAS)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CCASFLAGS="$(CCASFLAGS)" LDFLAGS="$(LDFLAGS)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): target_CCASFLAGS=$($(1)_target_CCASFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# Cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Flashing / Debugging
#
TARGET_APP ?= ot-cli-ftd
APP_FILE_NAME = $(TopResultDir)/$(TargetTuple)/bin/$(TARGET_APP)
APP_FILE_HEX = $(TopResultDir)/$(TargetTuple)/bin/$(TARGET_APP).hex
nrfjprog: $(APP_FILE_NAME)
arm-none-eabi-objcopy -O ihex $(<) $(APP_FILE_HEX)
nrfjprog -f NRF52 --sectorerase --reset --program $(APP_FILE_HEX)
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
-376
View File
@@ -1,376 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = $(CCPREFIX) arm-none-eabi-gcc
CPP = arm-none-eabi-cpp
CC = $(CCPREFIX) arm-none-eabi-gcc
CXX = $(CCPREFIX) arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d.`)
# Disable built-in mbedTLS by default allowing for nrf_security implementation with hardware acceleration.
# When set to 0 built-in, software implementation would be used.
DISABLE_BUILTIN_MBEDTLS ?= 1
ifeq ($(DISABLE_CC310), 1)
$(error DISABLE_CC310=1 is deprecated, please use DISABLE_BUILTIN_MBEDTLS=0)
endif
configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-linker-map \
--with-examples=nrf52840 \
$(NULL)
ifdef SRC_PATH
configure_OPTIONS += --srcdir="$(SRC_PATH)"
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"nrf52840-mbedtls-config.h\"'
NRF52840_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config
ifeq ($(DISABLE_BUILTIN_MBEDTLS), 1)
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_CONFIG_FILE='\"nrf-config.h\"'
NRF52840_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/include
NRF52840_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/config
NRF52840_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/nrf_cc310_plat/include
else
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
NRF52840_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
NRF52840_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
NRF52840_MBEDTLS_CPPFLAGS += -DNRF52840_XXAA
endif
ifeq ($(MBEDTLS_THREADING), 1)
ifeq ($(DISABLE_BUILTIN_MBEDTLS), 1)
$(error Cannot use MBEDTLS_THREADING with CC310 support. CC310 library comes with built-in threading support. To disable CC310 please use DISABLE_BUILTIN_MBEDTLS=0)
else
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_THREADING_C
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_THREADING_ALT
NRF52840_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/include/software-only-threading
endif
endif
ifdef MBEDTLS_THREADING_MUTEX_DEF
ifneq ($(MBEDTLS_THREADING), 1)
$(error Cannot use MBEDTLS_THREADING_MUTEX_DEF without MBEDTLS_THREADING=1)
else
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_THREADING_MUTEX_DEF='\"$(MBEDTLS_THREADING_MUTEX_DEF)\"'
endif
endif
NRF52840_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-nrf52840-config.h\"'
NRF52840_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-nrf52840-config-check.h\"'
NRF52840_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52840
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
$(NRF52840_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
ifeq ($(DISABLE_BUILTIN_MBEDTLS),1)
COMMONCFLAGS += $(NRF52840_MBEDTLS_CPPFLAGS)
else
configure_OPTIONS += MBEDTLS_CPPFLAGS="$(NRF52840_MBEDTLS_CPPFLAGS)"
endif
ifeq ($(BOOTLOADER),1)
$(info Warning: BOOTLOADER=1 switch is deprecated. Defaulting to BOOTLOADER=USB.)
override BOOTLOADER = USB
endif
ifeq ($(BOOTLOADER),USB)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52840/nrf52840_bootloader_usb.ld
COMMONCFLAGS += -DAPP_USBD_NRF_DFU_TRIGGER_ENABLED=1
endif
ifeq ($(BOOTLOADER),UART)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52840/nrf52840_bootloader_uart.ld
endif
ifeq ($(BOOTLOADER),BLE)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52840/nrf52840_bootloader_ble.ld
endif
#
# Select transport which CLI, NCP and RCP examples will use to communicate.
# To disable all transports use the DISABLE_TRANSPORTS switch. This will disable
# the build of all above examples.
# If NCP_SPI switch is set, only NCP and RCP examples will be built.
# Otherwise the user can select USB transport. If no transports were selected,
# the default serial transport is UART.
#
ifndef DISABLE_TRANSPORTS
configure_OPTIONS += --enable-ncp
configure_OPTIONS += --enable-radio-only
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DSPIS_AS_SERIAL_TRANSPORT=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1
configure_OPTIONS += --enable-cli
ifeq ($(USB),1)
COMMONCFLAGS += -DUSB_CDC_AS_SERIAL_TRANSPORT=1
else
COMMONCFLAGS += -DUART_AS_SERIAL_TRANSPORT=1
endif # USB == 1
endif # NCP_SPI == 1
endif # DISABLE_TRANSPORTS
ifeq ($(shell expr $(GCCVersion) \>= 7), 1)
COMMONCFLAGS += -Wno-expansion-to-defined
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
CCASFLAGS += \
$(COMMONCCASFLAGS) \
$(target_CCASFLAGS) \
-x \
assembler-with-cpp \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = nrf52840
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(TargetTuple) && $(AbsTopSourceDir)/configure \
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" CCAS="$(CCAS)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CCASFLAGS="$(CCASFLAGS)" LDFLAGS="$(LDFLAGS)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): target_CCASFLAGS=$($(1)_target_CCASFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# Cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Flashing / Debugging
#
TARGET_APP ?= ot-cli-ftd
APP_FILE_NAME = $(TopResultDir)/$(TargetTuple)/bin/$(TARGET_APP)
APP_FILE_HEX = $(TopResultDir)/$(TargetTuple)/bin/$(TARGET_APP).hex
nrfjprog: $(APP_FILE_NAME)
arm-none-eabi-objcopy -O ihex $(<) $(APP_FILE_HEX)
nrfjprog -f NRF52 --sectorerase --reset --program $(APP_FILE_HEX)
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
+1 -5
View File
@@ -35,6 +35,7 @@ EXTRA_DIST = \
gp712 \
k32w \
kw41z \
nrf528xx \
qpg6095 \
qpg6100 \
qpg7015m \
@@ -45,7 +46,6 @@ EXTRA_DIST = \
DIST_SUBDIRS = \
cc2538 \
nrf528xx \
simulation \
utils \
$(NULL)
@@ -60,10 +60,6 @@ if OPENTHREAD_PLATFORM_CC2538
SUBDIRS += cc2538
endif
if OPENTHREAD_PLATFORM_NRF528XX
SUBDIRS += nrf528xx
endif
if OPENTHREAD_PLATFORM_SIMULATION
SUBDIRS += simulation
endif
-12
View File
@@ -45,18 +45,6 @@ if OPENTHREAD_EXAMPLES_CC2538
include $(top_srcdir)/examples/platforms/cc2538/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_NRF52811
include $(top_srcdir)/examples/platforms/nrf528xx/nrf52811/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_NRF52833
include $(top_srcdir)/examples/platforms/nrf528xx/nrf52833/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_NRF52840
include $(top_srcdir)/examples/platforms/nrf528xx/nrf52840/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_SIMULATION
include $(top_srcdir)/examples/platforms/simulation/Makefile.platform.am
endif
-103
View File
@@ -1,103 +0,0 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# 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.
#
if(OT_NCP_SPI)
list(APPEND OT_PLATFORM_DEFINES "SPIS_AS_SERIAL_TRANSPORT=1")
else()
option(OT_USB "enable nrf USB as serial transport support")
if(OT_USB)
list(APPEND OT_PLATFORM_DEFINES "USB_CDC_AS_SERIAL_TRANSPORT=1")
else()
list(APPEND OT_PLATFORM_DEFINES "UART_AS_SERIAL_TRANSPORT=1")
endif()
endif()
set(NRF_COMM_SOURCES
src/alarm.c
src/diag.c
src/entropy.c
src/fem.c
src/flash.c
src/logging.c
src/misc.c
src/radio.c
src/system.c
src/temp.c
)
set(NRF_TRANSPORT_SOURCES
src/transport/spi-slave.c
src/transport/transport.c
src/transport/uart.c
src/transport/usb-cdc-uart.c
)
set(NRF_SINGLEPHY_SOURCES
src/flash_nosd.c
)
set(NRF_SOFTDEVICE_SOURCES
src/flash_sd.c
src/softdevice.c
)
set(NRF_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/examples/platforms
${PROJECT_SOURCE_DIR}/src/core
)
if(OT_PLATFORM STREQUAL "nrf52811")
set(NRF_TRANSPORT_SOURCES
src/transport/spi-slave.c
src/transport/transport.c
src/transport/uart.c
)
set(NRF52811_3RD_LIBS
nordicsemi-nrf52811-radio-driver
nordicsemi-nrf52811-sdk
jlinkrtt
)
include(nrf52811/nrf52811.cmake)
elseif(OT_PLATFORM STREQUAL "nrf52833")
set(NRF52833_3RD_LIBS
nordicsemi-nrf52833-radio-driver
nordicsemi-nrf52833-radio-driver-softdevice
nordicsemi-nrf52833-sdk
jlinkrtt
)
include(nrf52833/nrf52833.cmake)
elseif(OT_PLATFORM STREQUAL "nrf52840")
set(NRF52840_3RD_LIBS
nordicsemi-nrf52840-radio-driver
nordicsemi-nrf52840-radio-driver-softdevice
nordicsemi-nrf52840-sdk
jlinkrtt
)
include(nrf52840/nrf52840.cmake)
endif()
-174
View File
@@ -1,174 +0,0 @@
## Diagnostic module
nRF52811 and nRF52840 ports extend [OpenThread Diagnostics Module][diag].
New commands allow for more accurate low level radio testing.
### New commands
- [diag ccathreshold](#diag-ccathreshold)
- [diag gpio](#diag-gpio)
- [diag id](#diag-id)
- [diag listen](#diag-listen)
- [diag temp](#diag-temp)
- [diag transmit](#diag-transmit)
### Diagnostic radio packet
[diag listen](#diag-listen) and [diag transmit](#diag-transmit) use radio frame payload specified below.
```c
struct PlatformDiagMessage
{
const char mMessageDescriptor[11];
uint8_t mChannel;
int16_t mID;
uint32_t mCnt;
};
```
`mMessageDescriptor` is a constant string `"DiagMessage"`.<br /> `mChannel` contains the channel number on which the packet was transmitted.<br /> `mID` contains the board ID set with the [diag id](#diag-id) command.<br /> `mCnt` is a counter incremented every time the board transmits diagnostic radio packet.
If the [listen mode](#diag-listen) is enabled and OpenThread was built with the`DEFAULT_LOGGING` flag, JSON string is printed every time a diagnostic radio packet is received.
```JSON
{"Frame":{
"LocalChannel":"<listening board channel>",
"RemoteChannel":"<mChannel>",
"CNT":"<mCnt>",
"LocalID":"<listening board ID>",
"RemoteID":"<mID>",
"RSSI":"<packet RSSI>"
}}
```
### diag ccathreshold
Get the current CCA threshold.
### diag ccathreshold \<threshold\>
Set the CCA threshold.
Value range: 0 to 255.
Default: `45`.
### diag gpio
Manage GPIO pins.
### diag gpio \<pinnum\>
Return the current value of the gpio.
Note: \<pinnum\> is an integer that combines port and pin into a single, contiguous number space as follows:
```
pinnum = (port * 32) + pin
```
See also the [`NRF_GPIO_PIN_MAP`](../../../third_party/NordicSemiconductor/hal/nrf_gpio.h) macro.
```bash
> diag gpio 47
gpio 47 = 0
```
### diag gpio out \<pinnum\>
Set the given GPIO to the output mode.
```bash
> diag gpio out 47
gpio 47: out
```
### diag gpio in \<pinnum\>
Sets the given GPIO to the input mode with no pull variant.
```bash
> diag gpio in 47
gpio 47: in no pull
```
### diag gpio set \<pinnum\>
Sets the given output gpio to high.
```bash
> diag gpio set 47
gpio 47 = 1
```
### diag gpio clr \<pinnum\>
Sets the given output gpio to low.
```bash
> diag gpio clr 47
gpio 47 = 0
```
### diag id
Get board ID.
### diag id \<id\>
Set board ID.
Value range: 0 to 32767.
Default: `-1`.
### diag listen
Get the listen state.
### diag listen \<listen\>
Set the listen state.
`0` disables the listen state.<br /> `1` enables the listen state.
By default, the listen state is disabled.
### diag temp
Get the temperature from the internal temperature sensor (in degrees Celsius).
### diag transmit
Get the message count and the interval between the messages that will be transmitted after `diag transmit start`.
### diag transmit interval \<interval\>
Set the interval in ms between the transmitted messages.
Value range: 1 to 4294967295.
Default: `1`.
### diag transmit count \<count\>
Set the number of messages to be transmitted.
Value range: 1 to 2147483647<br /> or<br /> For continuous transmission: `-1`
Default: `1`
### diag transmit stop
Stop the ongoing transmission regardless of the remaining number of messages to be sent.
### diag transmit start
Start transmiting messages with specified interval.
### diag transmit carrier
Start transmitting continuous carrier wave.
[diag]: ./../../../src/core/diags/README.md
-44
View File
@@ -1,44 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
# Use automake includes since we cannot use SUBDIRS feature due to cleanup
# errors - few targets may use the same source file but dependency file is
# created only once which leads to errors when auto-generated Makefile tries
# to remove .Po files that were already removed
if OPENTHREAD_PLATFORM_NRF52811
include nrf52811/Makefile.am
endif
if OPENTHREAD_PLATFORM_NRF52833
include nrf52833/Makefile.am
endif
if OPENTHREAD_PLATFORM_NRF52840
include nrf52840/Makefile.am
endif
-17
View File
@@ -1,17 +0,0 @@
# OpenThread on nRF528xx Example
This directory contains example platform drivers for [Nordic Semiconductor nRF52840 SoC][nrf52840], [Nordic Semiconductor nRF52833 SoC][nrf52833] and [Nordic Semiconductor nRF52811 SoC][nrf52811].
[nrf52840]: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52840
[nrf52833]: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52833
[nrf52811]: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52811
To learn more about building and running the examples please check:
- [OpenThread on nRF52840 examples][nrf52840-page]
- [OpenThread on nRF52833 examples][nrf52833-page]
- [OpenThread on nRF52811 examples][nrf52811-page]
[nrf52840-page]: ./nrf52840/README.md
[nrf52833-page]: ./nrf52833/README.md
[nrf52811-page]: ./nrf52811/README.md
@@ -1,175 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = \
libopenthread-nrf52811.a \
libopenthread-nrf52811-sdk.a \
libopenthread-nrf52811-transport.a \
$(NULL)
# Do not enable -pedantic-errors for nRF52811 driver library
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for nRF52811 driver library
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
# Do not enable -Wcast-align for nRF52811 driver library
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
COMMONCPPFLAGS = \
-DCONFIG_GPIO_AS_PINRESET \
-DNRF52811_XXAA \
-DUSE_APP_CONFIG=1 \
-I$(srcdir) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/nrf528xx/src \
-I$(top_srcdir)/examples/platforms/nrf528xx/src/transport \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/lp_timer \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/temperature \
$(NULL)
# Only reference the SDK header files included in third_party/NordicSemiconductor
# when building the example applications.
#
# When building just the platform libraries, the caller of configure is expected
# to provide the correct -I arguments to locate the necessary header files in an
# external copy of the Nordic nRF5 SDK.
#
# Note that an exception is made for the 802.15.4 radio driver, which is always
# built using the sources in third_party/NordicSemiconductor/drivers/radio.
if OPENTHREAD_ENABLE_EXAMPLES
COMMONCPPFLAGS += \
-I$(top_srcdir)/third_party/NordicSemiconductor \
-I$(top_srcdir)/third_party/NordicSemiconductor/cmsis \
-I$(top_srcdir)/third_party/NordicSemiconductor/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52811/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/dependencies \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/clock \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/common \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/power \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/systick \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/soc \
$(NULL)
endif
PLATFORM_COMMON_SOURCES = \
src/alarm.c \
src/diag.c \
src/entropy.c \
src/fem.c \
src/flash.c \
src/logging.c \
src/misc.c \
src/radio.c \
src/system.c \
src/temp.c \
$(NULL)
TRANSPORT_SOURCES = \
src/transport/spi-slave.c \
src/transport/uart.c \
src/transport/transport.c \
$(NULL)
SINGLEPHY_SOURCES = \
src/flash_nosd.c \
$(NULL)
SINGLEPHY_CPPFLAGS = \
-DRAAL_SINGLE_PHY=1 \
$(NULL)
PLATFORM_SOURCES = \
$(PLATFORM_COMMON_SOURCES) \
$(NULL)
libopenthread_nrf52811_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SINGLEPHY_CPPFLAGS) \
$(NULL)
libopenthread_nrf52811_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SINGLEPHY_SOURCES) \
$(NULL)
libopenthread_nrf52811_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SINGLEPHY_CPPFLAGS) \
$(NULL)
libopenthread_nrf52811_sdk_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SINGLEPHY_SOURCES) \
$(NULL)
libopenthread_nrf52811_transport_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NULL)
libopenthread_nrf52811_transport_a_SOURCES = \
$(TRANSPORT_SOURCES) \
$(NULL)
Dash = -
libopenthread_nrf52811_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52811_sdk_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52811_transport_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,48 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
#
# nrf52811 platform-specific Makefile
#
LDADD_COMMON += \
$(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52811.a \
$(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52811-transport.a \
$(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52811-sdk.a \
$(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52811-radio-driver.a \
$(NULL)
if OPENTHREAD_ENABLE_CUSTOM_LINKER_FILE
LDFLAGS_COMMON += \
-T $(OPENTHREAD_CUSTOM_LINKER_FILE) \
$(NULL)
else
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/nrf528xx/nrf52811/nrf52811.ld \
$(NULL)
endif
+1 -366
View File
@@ -1,366 +1 @@
# OpenThread on nRF52811 Example
This directory contains example platform drivers for [Nordic Semiconductor nRF52811 SoC][nrf52811].
[nrf52811]: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52811
This SoC is meant to be used in the configuration that involves the Host Processor and the IEEE 802.15.4 radio. In this configuration, the full OpenThread stack is running on the Host Processor and the nRF52811 SoC acts as an IEEE 802.15.4 radio. The radio is running a minimal OpenThread implementation that allows for communication between the Host Processor and the nRF52811. In this architecture the nRF52811 SoC device is called RCP (Radio Co-Processor).
The nRF52811 platform is currently under development.
For the SoC capable to a run full OpenThread stack, see the [nRF52840 platform][nrf52840-page].
[nrf52840-page]: ./../nrf52840/README.md
## Emulation on nRF52840
You can use examples for nRF52811 on nRF52840 without any changes in the generated binary files. This allows for easier testing in early stages of development.
## Prerequisites
Before you start building the examples, you must download and install the toolchain and the tools required for flashing and debugging.
### Toolchain
Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
[gnu-toolchain]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
To install the GNU toolchain and its dependencies, run the following commands in Bash:
```bash
$ cd <path-to-openthread>
$ ./script/bootstrap
```
### Flashing and debugging tools
[nrf-command-line-tools]: https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools
Install the [nRF Command Line Tools][nrf-command-line-tools] to flash, debug, and make use of logging features on the nRF52811 DK with SEGGER J-Link.
## Building the examples
With this platform, you can build:
- Limited version of CLI example (e.g. without Thread commissioning functionality)
- RCP example that consists of two parts:
- firmware that is flashed to the nRF52811 SoC
- host executables to be executed on a POSIX platform in case of the RCP usage
### Building host executables
```bash
$ cd <path-to-openthread>
$ ./bootstrap
$ make -f src/posix/Makefile-posix
```
After a successful build, executables can be found in `<path-to-openthread>/openthread/output/posix/<system-architecture>/bin`. It is recommended to copy them to `/usr/bin` for easier access.
### Building the firmware with UART support
To build the firmware using default UART RCP transport, run the following make commands:
```bash
$ cd <path-to-openthread>
$ ./bootstrap
$ make -f examples/Makefile-nrf52811
```
After a successful build, the `elf` files can be found in `<path-to-openthread>/output/nrf52811/bin`. You can convert them to hex using `arm-none-eabi-objcopy`:
```bash
$ arm-none-eabi-objcopy -O ihex ot-cli-mtd ot-cli-mtd.hex
$ arm-none-eabi-objcopy -O ihex ot-rcp ot-rcp.hex
```
### Building the firmware with native SPI support
You can build the libraries with support for the native SPI Slave. To do so, build the libraries with the following parameter:
```
$ make -f examples/Makefile-nrf52811 NCP_SPI=1
```
With this option enabled, the RCP example can communicate through SPI with wpantund (provided that the wpantund host supports SPI Master). To achieve this communication, choose the right SPI device in the wpantund configuration file, `/etc/wpantund.conf`. See the following example.
```
Config:NCP:SocketPath "system:/usr/bin/ot-ncp /usr/bin/spi-hdlc-adapter -- '--stdio -i /sys/class/gpio/gpio25 /dev/spidev0.1'"
```
In this example, [spi-hdlc-adapter][spi-hdlc-adapter] is a tool that you can use to communicate between RCP and wpantund over SPI. For this example, `spi-hdlc-adapter` is installed in `/usr/bin`.
The default SPI Slave pin configuration for nRF52811 is defined in `examples/platforms/nrf52811/transport-config.h`.
[spi-hdlc-adapter]: https://github.com/openthread/openthread/tree/master/tools/spi-hdlc-adapter
### IEEE EUI-64 address
When the Thread device is configured to obtain the Thread Network security credentials with either Thread Commissioning or an out-of-band method, the extended MAC address should be constructed out of the globally unique IEEE EUI-64.
The IEEE EUI-64 address consists of two parts:
- 24 bits of MA-L (MAC Address Block Large), formerly called OUI (Organizationally Unique Identifier)
- 40-bit device unique identifier
By default, the device uses Nordic Semiconductor's MA-L (f4-ce-36). You can modify it by overwriting the `OPENTHREAD_CONFIG_STACK_VENDOR_OUI` define, located in the `openthread-core-nrf52811-config.h` file. This value must be publicly registered by the IEEE Registration Authority.
You can also provide the full IEEE EUI-64 address by providing a custom `otPlatRadioGetIeeeEui64` function. To do this, define the flag `OPENTHREAD_CONFIG_ENABLE_PLATFORM_EUI64_CUSTOM_SOURCE`.
After the Thread Network security credentials have been successfully obtained, the device uses randomly generated extended MAC address.
## Flashing binaries
Once the examples and libraries are built, flash the compiled binaries onto nRF52811 using `nrfjprog` that is part of the [nRF Command Line Tools][nrf-command-line-tools].
Run the following command:
```bash
$ nrfjprog -f nrf52 --chiperase --program output/nrf52811/bin/ot-cli-mtd.hex --reset
```
## Running the example
To test the example:
1. Prepare two boards.
2. Flash one with the `CLI MTD Example` (ot-cli-mtd.hex, as shown above).
3. Flash `RCP Example` (ot-rcp.hex) to the other board.
4. Connect the RCP to the PC.
5. Start the ot-cli host application and connect with the RCP. It is assumed that the default UART version of RCP is being used (make executed without the NCP-SPI=1 flag). On Linux system, call a port name, for example `/dev/ttyACM0` for the first connected development kit, and `/dev/ttyACM1` for the second one.
```bash
$ /usr/bin/ot-cli /dev/ttyACM0 115200
```
You are now connected with the CLI on the first board
6. Use the following commands to form a network:
```bash
> dataset init new
Done
> dataset
Active Timestamp: 1
Channel: 13
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
Security Policy: 0, onrcb
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done
```
After a couple of seconds the node will become a Leader of the network.
```bash
> state
leader
```
7. Open a terminal connection on the second board and attach a node to the network:
a. Start a terminal emulator like screen.
b. Connect to the used COM port with the following direct UART settings:
- Baud rate: 115200
- 8 data bits
- 1 stop bit
- No parity
- HW flow control: RTS/CTS This allows you to view the raw UART output.
c. Run the following command to connect to the second board.
```shell
screen /dev/ttyACM1 115200
```
You are now connected with the CLI on the second board
8. Use the following commands to attach to the network on the second board:
```bash
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done
```
After a couple of seconds the second node will attach and become a Child.
```bash
> state
child
```
9. List all IPv6 addresses of the first board.
```bash
> ipaddr
fd3d:b50b:f96d:722d:0:ff:fe00:fc00
fd3d:b50b:f96d:722d:0:ff:fe00:c00
fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
fe80:0:0:0:6c41:9001:f3d6:4148
Done
```
10. Choose one of them and send an ICMPv6 ping from the second board.
```bash
> ping fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
16 bytes from fd3d:b50b:f96d:722d:558:f56b:d688:799: icmp_seq=1 hlim=64 time=24ms
```
For a list of all available commands, visit [OpenThread CLI Reference README.md][cli].
[cli]: ./../../../src/cli/README.md
## SEGGER J-Link tools
SEGGER J-Link tools allow to debug and flash generated firmware using on-board debugger or external one.
### Working with RTT logging
By default, the OpenThread's logging module provides functions to output logging information over SEGGER's Real Time Transfer (RTT).
You can set the desired log level by using the `OPENTHREAD_CONFIG_LOG_LEVEL` define.
To enable the highest verbosity level, append `FULL_LOGS` flag to the `make` command:
```
$ make -f examples/Makefile-nrf52811 FULL_LOGS=1
```
#### Enable logging on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link RTT Viewer`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52810_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
#### Enable logging on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52810_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID> -RTTTelnetPort 19021
```
3. Run `JLinkRTTTelnet` to obtain the RTT logs from the connected device in a separate console. For example:
```
JLinkRTTClient -RTTTelnetPort 19021
```
### Mass Storage Device known issue
Depending on your version, due to a known issue in SEGGER's J-Link firmware, you might experience data corruption or data drops if you use the serial port. You can avoid this issue by disabling the Mass Storage Device.
#### Disabling the Mass Storage Device on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link Commander`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52810_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
5. Run the following command:
```
MSDDisable
```
6. Power cycle the DK.
#### Disabling the Mass Storage Device on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52810_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID>
```
3. Run the following command:
```
MSDDisable
```
4. Power cycle the DK.
### Hardware Flow Control detection
By default, SEGGER J-Link automatically detects at runtime whether the target is using Hardware Flow Control (HWFC).
The automatic HWFC detection is done by driving P0.07 (Clear to Send - CTS) from the interface MCU and evaluating the state of P0.05 (Request to Send - RTS) when the first data is sent or received. If the state of P0.05 (RTS) is high, it is assumed that HWFC is not used.
To avoid potential race conditions, you can force HWFC and bypass the runtime auto-detection.
#### Disabling the HWFC detection on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link Commander`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52810_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
5. Run the following command:
```
SetHWFC Force
```
6. Power cycle the DK.
#### Disabling the HWFC detection on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52810_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID>
```
3. Run the following command:
```
SetHWFC Force
```
4. Power cycle the DK.
You can find more details [here][j-link-ob].
[j-link-ob]: https://wiki.segger.com/J-Link_OB_SAM3U_NordicSemi#Hardware_flow_control_support
## Diagnostic module
nRF52811 supports [OpenThread Diagnostics Module][diag], with some additional features.
For more information, see [nRF Diag command reference][nrfdiag].
[diag]: ./../../../src/core/diags/README.md
[nrfdiag]: ./../DIAG.md
## Radio driver documentation
The radio driver documentation includes \*.uml state machines sequence diagrams that can be opened with [PlantUML][plantuml-url].
[plantuml-url]: http://plantuml.com/
The OpenThread on nRF528xx example has moved to https://github.com/openthread/ot-nrf528xx
@@ -1,56 +0,0 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# 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.
#
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
set(CMAKE_RANLIB arm-none-eabi-ranlib)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mfloat-abi=soft -mthumb -mabi=aapcs -fdata-sections -ffunction-sections")
if(COMPILER_VERSION VERSION_GREATER_EQUAL 7)
set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -Wno-expansion-to-defined")
endif()
set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti")
set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS} -x assembler-with-cpp")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs")
set(CMAKE_C_FLAGS_DEBUG "-Og -g")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
set(CMAKE_ASM_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_ASM_FLAGS_RELEASE "")
@@ -1,173 +0,0 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# 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.
#
set(OT_PLATFORM_LIB "openthread-nrf52811" "openthread-nrf52811-transport" PARENT_SCOPE)
if(NOT OT_CONFIG)
set(OT_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/nrf52811/openthread-core-nrf52811-config.h")
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
endif()
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52811/nrf52811.ld")
set(COMM_FLAGS
-DDISABLE_CC310=1
-DCONFIG_GPIO_AS_PINRESET
-DNRF52811_XXAA
-DUSE_APP_CONFIG=1
-Wno-unused-parameter
-Wno-expansion-to-defined
)
list(APPEND OT_PLATFORM_DEFINES
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-nrf52811-config-check.h\""
)
list(APPEND OT_PUBLIC_INCLUDES
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config"
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/mdk"
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/cmsis"
)
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
target_compile_definitions(ot-config INTERFACE
"MBEDTLS_USER_CONFIG_FILE=\"nrf52811-mbedtls-config.h\""
)
set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE)
if(OT_CFLAGS MATCHES "-pedantic-errors")
string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}")
endif()
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
add_library(openthread-nrf52811
${NRF_COMM_SOURCES}
${NRF_SINGLEPHY_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
add_library(openthread-nrf52811-transport
${NRF_TRANSPORT_SOURCES}
)
add_library(openthread-nrf52811-sdk
${NRF_COMM_SOURCES}
${NRF_SINGLEPHY_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
target_link_libraries(openthread-nrf52811
PUBLIC
${OT_MBEDTLS}
${NRF52811_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_link_libraries(openthread-nrf52811-transport
PUBLIC
${OT_MBEDTLS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
nordicsemi-nrf52811-sdk
ot-config
)
target_link_libraries(openthread-nrf52811-sdk
PUBLIC
${OT_MBEDTLS}
${NRF52811_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_compile_definitions(openthread-nrf52811
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52811-transport
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52811-sdk
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_options(openthread-nrf52811
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
-DRAAL_SINGLE_PHY=1
)
target_compile_options(openthread-nrf52811-transport
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
)
target_compile_options(openthread-nrf52811-sdk
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
-DRAAL_SINGLE_PHY=1
)
target_include_directories(openthread-nrf52811
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52811
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52811-transport
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52811
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52811-sdk
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52811
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52811.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x30000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x6000
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 2;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,36 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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 OPENTHREAD_CORE_NRF52811_CONFIG_CHECK_H_
#define OPENTHREAD_CORE_NRF52811_CONFIG_CHECK_H_
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
#error "Platform nrf52811 doesn't support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
#endif
#endif /* OPENTHREAD_CORE_NRF52811_CONFIG_CHECK_H_ */
@@ -1,268 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes nrf52811 compile-time configuration constants
* for OpenThread.
*/
#ifndef OPENTHREAD_CORE_NRF52811_CONFIG_H_
#define OPENTHREAD_CORE_NRF52811_CONFIG_H_
/*
* The GNU Autoconf system defines a PACKAGE macro which is the name
* of the software package. This name collides with PACKAGE field in
* the nRF52 Factory Information Configuration Registers (FICR)
* structure.
*/
#undef PACKAGE
/**
* @def OPENTHREAD_CONFIG_LOG_OUTPUT
*
* The nrf52811 platform provides an otPlatLog() function.
*/
#ifndef OPENTHREAD_CONFIG_LOG_OUTPUT
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_INFO
*
* The platform-specific string to insert into the OpenThread version string.
*
*/
#define OPENTHREAD_CONFIG_PLATFORM_INFO "NRF52811"
/**
* @def OPENTHREAD_CONFIG_STACK_VENDOR_OUI
*
* The Organizationally Unique Identifier for the vendor.
*
*/
#ifndef OPENTHREAD_CONFIG_STACK_VENDOR_OUI
#define OPENTHREAD_CONFIG_STACK_VENDOR_OUI 0xf4ce36
#endif
/**
* @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
*
* The number of message buffers in the buffer pool.
*
*/
#ifndef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 60
#endif
/**
* @def OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
*
* The maximum number of state-changed callback handlers (set using `otSetStateChangedCallback()`).
*
*/
#ifndef OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
#endif
/**
* @def OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
*
* The number of EID-to-RLOC cache entries.
*
*/
#ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
#define OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES 20
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_PREPREND_LEVEL
*
* Define to prepend the log level to all log messages
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
*
* Define to 1 if you want to enable software ACK timeout logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
*
* Define to 1 if you want to enable software retransmission logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
*
* Define to 1 if you want to enable software CSMA-CA backoff logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
*
* Define to 1 if you want to enable software transmission security logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE
*
* Define to 1 to enable software transmission target time logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE
*
* Define to 1 to enable software reception target time logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
*
* Define to 1 if you want to support microsecond timer in platform.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
*
* Define to 1 to enable otPlatFlash* APIs to support non-volatile storage.
*
* When defined to 1, the platform MUST implement the otPlatFlash* APIs instead of the otPlatSettings* APIs.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
*
* Define as 1 to enable the time synchronization service feature.
*
*/
#ifndef OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
*
* Define as 1 to support IEEE 802.15.4-2015 Header IE (Information Element) generation and parsing, it must be set
* to support following features:
* 1. Time synchronization service feature (i.e., OPENTHREAD_CONFIG_TIME_SYNC_ENABLE is set).
*
* @note If it's enabled, plaforms must support interrupt context and concurrent access AES.
*
*/
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#define OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT 1
#endif
/**
* @def RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
*
* The number of short source address table entries.
*
*/
#ifndef RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
#define RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM 0
#endif
/**
* @def RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
*
* The number of extended source address table entries.
*
*/
#ifndef RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
#define RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM 0
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
*
* Reception scheduling and ramp up time needed for the CSL receiver to be ready, in units of microseconds.
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 2000
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON
*
* The minimum CSL receive window (in microseconds) required to receive an IEEE 802.15.4 frame.
* - Frame preamble: 6*2 symbols + margin
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON
#define OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 12 * 16
#endif
/*
* Suppress the ARMCC warning on unreachable statement,
* e.g. break after assert(false) or ExitNow() macro.
*/
#if defined(__CC_ARM)
_Pragma("diag_suppress=111") _Pragma("diag_suppress=128")
#endif
#endif // OPENTHREAD_CORE_NRF52811_CONFIG_H_
@@ -1,216 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the platform-specific configuration.
*
*/
#ifndef PLATFORM_CONFIG_H_
#define PLATFORM_CONFIG_H_
#include "nrf.h"
#include "nrf_drv_clock.h"
#include "nrf_peripherals.h"
#include "hal/nrf_radio.h"
#include "hal/nrf_uart.h"
#include "openthread-core-config.h"
#include <openthread/config.h>
/*******************************************************************************
* @section Alarm Driver Configuration.
******************************************************************************/
/**
* @def RTC_INSTANCE
*
* RTC Instance.
*
*/
#ifndef RTC_INSTANCE
#define RTC_INSTANCE NRF_RTC1
#endif
/**
* @def RTC_IRQ_HANDLER
*
* RTC interrupt handler name
*
*/
#ifndef RTC_IRQ_HANDLER
#define RTC_IRQ_HANDLER RTC1_IRQHandler
#endif
/**
* @def RTC_IRQN
*
* RTC Interrupt number.
*
*/
#ifndef RTC_IRQN
#define RTC_IRQN RTC1_IRQn
#endif
/**
* @def RTC_IRQ_PRIORITY
*
* RTC Interrupt priority.
*
*/
#ifndef RTC_IRQ_PRIORITY
#define RTC_IRQ_PRIORITY 6
#endif
/*******************************************************************************
* @section Random Number Generator Driver Configuration.
******************************************************************************/
/**
* @def RNG_BUFFER_SIZE
*
* True Random Number Generator buffer size.
*
*/
#ifndef RNG_BUFFER_SIZE
#define RNG_BUFFER_SIZE 128
#endif
/**
* @def RNG_IRQ_PRIORITY
*
* RNG Interrupt priority.
*
*/
#ifndef RNG_IRQ_PRIORITY
#define RNG_IRQ_PRIORITY 6
#endif
/*******************************************************************************
* @section Platform Flash Configuration
******************************************************************************/
/**
* @def PLATFORM_FLASH_PAGE_NUM
*
* Number of flash pages to use for OpenThread's non-volatile settings.
*
* @note This define applies only for MDK-ARM Keil toolchain configuration.
*
*/
#ifndef PLATFORM_FLASH_PAGE_NUM
#define PLATFORM_FLASH_PAGE_NUM 2
#endif
/*******************************************************************************
* @section Platform FEM Configuration
******************************************************************************/
/**
* @def PLATFORM_FEM_ENABLE_DEFAULT_CONFIG
*
* Enable default front end module configuration.
*
*/
#ifndef PLATFORM_FEM_ENABLE_DEFAULT_CONFIG
#define PLATFORM_FEM_ENABLE_DEFAULT_CONFIG 0
#endif
/*******************************************************************************
* @section Radio driver configuration.
******************************************************************************/
/**
* @def NRF_802154_PENDING_SHORT_ADDRESSES
*
* Number of slots containing short addresses of nodes for which pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_SHORT_ADDRESSES
#define NRF_802154_PENDING_SHORT_ADDRESSES OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#endif
/**
* @def NRF_802154_PENDING_EXTENDED_ADDRESSES
*
* Number of slots containing extended addresses of nodes for which pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_EXTENDED_ADDRESSES
#define NRF_802154_PENDING_EXTENDED_ADDRESSES OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#endif
/**
* @def NRF_802154_CSMA_CA_ENABLED
*
* If CSMA-CA procedure should be enabled by the driver. Disabling CSMA-CA procedure improves
* driver performance.
*
*/
#ifndef NRF_802154_CSMA_CA_ENABLED
#define NRF_802154_CSMA_CA_ENABLED 1
#endif
/**
* @def NRF_802154_ACK_TIMEOUT_ENABLED
*
* If ACK timeout feature should be enabled in the driver.
*
*/
#ifndef NRF_802154_ACK_TIMEOUT_ENABLED
#define NRF_802154_ACK_TIMEOUT_ENABLED 1
#endif
/*******************************************************************************
* @section Temperature sensor driver configuration.
******************************************************************************/
/**
* @def TEMP_MEASUREMENT_INTERVAL
*
* Interval of consecutive temperature measurements [s].
*
*/
#ifndef TEMP_MEASUREMENT_INTERVAL
#define TEMP_MEASUREMENT_INTERVAL 30
#endif
/**
* @def NRF_802154_TX_STARTED_NOTIFY_ENABLED
*
* If notification of started transmission should be enabled in the driver.
*
* @note This feature must be enabled to support Header IE related features.
*
*/
#ifndef NRF_802154_TX_STARTED_NOTIFY_ENABLED
#define NRF_802154_TX_STARTED_NOTIFY_ENABLED 1
#endif
#endif // PLATFORM_CONFIG_H_
@@ -1,260 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the transport-specific configuration.
*
*/
#ifndef TRANSPORT_CONFIG_H_
#define TRANSPORT_CONFIG_H_
#include "nrf.h"
#include "nrf_drv_clock.h"
#include "nrf_peripherals.h"
#include "hal/nrf_radio.h"
#include "hal/nrf_uart.h"
#include "openthread-core-config.h"
#include <openthread/config.h>
/*******************************************************************************
* @section UART Driver Configuration.
******************************************************************************/
/**
* @def UART_INSTANCE
*
* UART Instance.
*
*/
#ifndef UART_INSTANCE
#define UART_INSTANCE NRF_UARTE0
#endif
/**
* @def UART_PARITY
*
* UART Parity configuration.
*
* @brief Possible values:
* \ref NRF_UARTE_PARITY_EXCLUDED - Parity bit is not present.
* \ref NRF_UARTE_PARITY_INCLUDED - Parity bit is present.
*
*/
#ifndef UART_PARITY
#define UART_PARITY NRF_UARTE_PARITY_EXCLUDED
#endif
/**
* @def UART_HWFC_ENABLED
*
* Enable UART Hardware Flow Control.
*
*/
#ifndef UART_HWFC_ENABLED
#define UART_HWFC_ENABLED 1
#endif
/**
* @def UART_BAUDRATE
*
* UART Baudrate.
*
* @brief Possible values:
* \ref NRF_UARTE_BAUDRATE_1200 - 1200 baud.
* \ref NRF_UARTE_BAUDRATE_2400 - 2400 baud.
* \ref NRF_UARTE_BAUDRATE_4800 - 4800 baud.
* \ref NRF_UARTE_BAUDRATE_9600 - 9600 baud.
* \ref NRF_UARTE_BAUDRATE_14400 - 14400 baud.
* \ref NRF_UARTE_BAUDRATE_19200 - 19200 baud.
* \ref NRF_UARTE_BAUDRATE_28800 - 28800 baud.
* \ref NRF_UARTE_BAUDRATE_38400 - 38400 baud.
* \ref NRF_UARTE_BAUDRATE_57600 - 57600 baud.
* \ref NRF_UARTE_BAUDRATE_76800 - 76800 baud.
* \ref NRF_UARTE_BAUDRATE_115200 - 115200 baud.
* \ref NRF_UARTE_BAUDRATE_230400 - 230400 baud.
* \ref NRF_UARTE_BAUDRATE_250000 - 250000 baud.
* \ref NRF_UARTE_BAUDRATE_460800 - 460800 baud.
* \ref NRF_UARTE_BAUDRATE_921600 - 921600 baud.
* \ref NRF_UARTE_BAUDRATE_1000000 - 1000000 baud.
*
*/
#ifndef UART_BAUDRATE
#define UART_BAUDRATE NRF_UARTE_BAUDRATE_115200
#endif
/**
* @def UART_IRQN
*
* UART Interrupt number.
*
*/
#ifndef UART_IRQN
#define UART_IRQN UARTE0_UART0_IRQn
#endif
/**
* @def UART_IRQ_PRIORITY
*
* UART Interrupt priority.
*
*/
#ifndef UART_IRQ_PRIORITY
#define UART_IRQ_PRIORITY 6
#endif
/**
* @def UART_RX_BUFFER_SIZE
*
* UART Receive buffer size.
*
*/
#ifndef UART_RX_BUFFER_SIZE
#define UART_RX_BUFFER_SIZE 256
#endif
/**
* @def UART_PIN_TX
*
* UART TX Pin.
*
*/
#ifndef UART_PIN_TX
#define UART_PIN_TX 6
#endif
/**
* @def UART_PIN_RX
*
* UART RX Pin.
*
*/
#ifndef UART_PIN_RX
#define UART_PIN_RX 8
#endif
/**
* @def UART_PIN_CTS
*
* UART CTS Pin.
*
*/
#ifndef UART_PIN_CTS
#define UART_PIN_CTS 7
#endif
/**
* @def UART_PIN_RTS
*
* UART RTS Pin.
*
*/
#ifndef UART_PIN_RTS
#define UART_PIN_RTS 5
#endif
/*******************************************************************************
* @section SPI Slave configuration.
******************************************************************************/
/**
* @def SPIS Instance.
*/
#ifndef SPIS_INSTANCE
#define SPIS_INSTANCE 0
#endif
/**
* @def SPIS mode.
*
* @brief Possible values:
* \ref NRF_SPIS_MODE_0 - SCK active high, sample on leading edge of clock.
* \ref NRF_SPIS_MODE_1 - SCK active high, sample on trailing edge of clock.
* \ref NRF_SPIS_MODE_2 - SCK active low, sample on leading edge of clock.
* \ref NRF_SPIS_MODE_3 - SCK active low, sample on trailing edge of clock.
*/
#ifndef SPIS_MODE
#define SPIS_MODE NRF_SPIS_MODE_0
#endif
/**
* @def SPIS bit orders.
*
* @brief Possible values:
* \ref NRF_SPIS_BIT_ORDER_MSB_FIRST - Most significant bit shifted out first.
* \ref NRF_SPIS_BIT_ORDER_LSB_FIRST - Least significant bit shifted out first.
*/
#ifndef SPIS_BIT_ORDER
#define SPIS_BIT_ORDER NRF_SPIS_BIT_ORDER_MSB_FIRST
#endif
/**
* @def SPIS Interrupt priority.
*/
#ifndef SPIS_IRQ_PRIORITY
#define SPIS_IRQ_PRIORITY 6
#endif
/**
* @def SPIS MOSI Pin.
*/
#ifndef SPIS_PIN_MOSI
#define SPIS_PIN_MOSI 4
#endif
/**
* @def SPIS MISO Pin.
*/
#ifndef SPIS_PIN_MISO
#define SPIS_PIN_MISO 28
#endif
/**
* @def SPIS SCK Pin.
*/
#ifndef SPIS_PIN_SCK
#define SPIS_PIN_SCK 3
#endif
/**
* @def SPIS CSN Pin.
*/
#ifndef SPIS_PIN_CSN
#define SPIS_PIN_CSN 29
#endif
/**
* @def SPIS Host IRQ Pin.
*/
#ifndef SPIS_PIN_HOST_IRQ
#define SPIS_PIN_HOST_IRQ 30
#endif
#endif // TRANSPORT_CONFIG_H_
@@ -1,205 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = \
libopenthread-nrf52833.a \
libopenthread-nrf52833-sdk.a \
libopenthread-nrf52833-softdevice-sdk.a \
libopenthread-nrf52833-transport.a \
$(NULL)
# Do not enable -pedantic-errors for nRF52833 driver library
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for nRF52833 driver library
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
# Do not enable -Wcast-align for nRF52833 driver library
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
COMMONCPPFLAGS = \
-DCONFIG_GPIO_AS_PINRESET \
-DNRF52833_XXAA \
-DUSE_APP_CONFIG=1 \
-I$(srcdir) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/nrf528xx/src \
-I$(top_srcdir)/examples/platforms/nrf528xx/src/transport \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/softdevice \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/lp_timer \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/temperature \
$(NULL)
# Only reference the SDK header files included in third_party/NordicSemiconductor
# when building the example applications.
#
# When building just the platform libraries, the caller of configure is expected
# to provide the correct -I arguments to locate the necessary header files in an
# external copy of the Nordic nRF5 SDK.
#
# Note that an exception is made for the 802.15.4 radio driver, which is always
# built using the sources in third_party/NordicSemiconductor/drivers/radio.
if OPENTHREAD_ENABLE_EXAMPLES
COMMONCPPFLAGS += \
-I$(top_srcdir)/third_party/NordicSemiconductor \
-I$(top_srcdir)/third_party/NordicSemiconductor/cmsis \
-I$(top_srcdir)/third_party/NordicSemiconductor/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52833/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/dependencies \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/clock \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/common \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/power \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/systick \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/soc \
-I$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers \
-I$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf52 \
$(NULL)
endif
PLATFORM_COMMON_SOURCES = \
src/alarm.c \
src/diag.c \
src/entropy.c \
src/fem.c \
src/flash.c \
src/logging.c \
src/misc.c \
src/radio.c \
src/system.c \
src/temp.c \
$(NULL)
TRANSPORT_SOURCES = \
src/transport/spi-slave.c \
src/transport/uart.c \
src/transport/usb-cdc-uart.c \
src/transport/transport.c \
$(NULL)
SINGLEPHY_SOURCES = \
src/flash_nosd.c \
$(NULL)
SOFTDEVICE_SOURCES = \
src/flash_sd.c \
src/softdevice.c \
$(NULL)
SOFTDEVICE_CPPFLAGS = \
-DSOFTDEVICE_PRESENT \
-DS140 \
-Wno-unused-parameter \
$(NULL)
PLATFORM_SOURCES = \
$(PLATFORM_COMMON_SOURCES) \
$(NULL)
libopenthread_nrf52833_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SINGLEPHY_CPPFLAGS) \
$(NULL)
libopenthread_nrf52833_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SINGLEPHY_SOURCES) \
$(NULL)
libopenthread_nrf52833_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SINGLEPHY_CPPFLAGS) \
$(NULL)
libopenthread_nrf52833_sdk_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SINGLEPHY_SOURCES) \
$(NULL)
libopenthread_nrf52833_softdevice_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SOFTDEVICE_CPPFLAGS) \
$(NULL)
libopenthread_nrf52833_softdevice_sdk_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SOFTDEVICE_SOURCES) \
$(NULL)
libopenthread_nrf52833_transport_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NULL)
libopenthread_nrf52833_transport_a_SOURCES = \
$(TRANSPORT_SOURCES) \
$(NULL)
Dash = -
libopenthread_nrf52833_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52833_sdk_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52833_softdevice_sdk_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52833_transport_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,48 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
#
# nrf52833 platform-specific Makefile
#
LDADD_COMMON += \
$(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52833.a \
$(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52833-transport.a \
$(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52833-sdk.a \
$(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52833-radio-driver.a \
$(NULL)
if OPENTHREAD_ENABLE_CUSTOM_LINKER_FILE
LDFLAGS_COMMON += \
-T $(OPENTHREAD_CUSTOM_LINKER_FILE) \
$(NULL)
else
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/nrf528xx/nrf52833/nrf52833.ld \
$(NULL)
endif
+1 -407
View File
@@ -1,407 +1 @@
# OpenThread on nRF52833 Example
This directory contains example platform drivers for [Nordic Semiconductor nRF52833 SoC][nrf52833].
To facilitate Thread products development with the nRF52833 platform, Nordic Semiconductor provides <i>nRF5 SDK for Thread and Zigbee</i>. See [Nordic Semiconductor's nRF5 SDK for Thread and Zigbee][nrf5-sdk-section] section for more details.
[nrf52833]: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52833
[nrf5-sdk-section]: #nordic-semiconductors-nrf5-sdk-for-thread-and-zigbee
## Prerequisites
Before you start building the examples, you must download and install the toolchain and the tools required for flashing and debugging.
### Toolchain
Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
[gnu-toolchain]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
To install the GNU toolchain and its dependencies, run the following commands in Bash:
```bash
$ cd <path-to-openthread>
$ ./script/bootstrap
```
### Flashing and debugging tools
[nrf5-command-line-tools]: https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF5-Command-Line-Tools
Install the [nRF5 Command Line Tools][nrf5-command-line-tools] to flash, debug, and make use of logging features on the nRF52833 DK with SEGGER J-Link.
## Building the examples
To build the examples, run the following command in Bash:
```bash
$ cd <path-to-openthread>
$ ./bootstrap
$ make -f examples/Makefile-nrf52833
```
After a successful build, the `elf` files can be found in `<path-to-openthread>/output/nrf52833/bin`. You can convert them to hex using `arm-none-eabi-objcopy`:
```bash
$ arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.hex
```
### USB CDC ACM support
You can build the libraries with support for the native USB CDC ACM as a serial transport. To do so, build the firmware with the following parameter:
```
$ make -f examples/Makefile-nrf52833 USB=1
```
Note that the USB CDC ACM serial transport is not supported with Engineering sample A of the nRF52833 chip.
If you are using Windows 7 or earlier, you must load an additional USB CDC driver. The driver can be found in `third_party/NordicSemiconductor/libraries/usb/nordic_cdc_acm_example.inf`.
### Bootloader support
The examples support the following bootloaders for performing a Device Firmware Upgrade (DFU):
- USB bootloader
- UART bootloader
- BLE bootloader
The support for a particular bootloader can be enabled with the following switches:
- USB: `BOOTLOADER=USB`
- UART: `BOOTLOADER=UART`
- BLE: `BOOTLOADER=BLE`
### Native SPI support
You can build the libraries with support for native SPI Slave. To build the libraries, run make with the following parameter:
```
$ make -f examples/Makefile-nrf52833 NCP_SPI=1
```
With this option enabled, SPI communication between the NCP example and wpantund is possible (provided that the wpantund host supports SPI Master). To achieve that, an appropriate SPI device should be chosen in wpantund configuration file, `/etc/wpantund.conf`. You can find an example below.
```
Config:NCP:SocketPath "system:/usr/bin/spi-hdlc-adapter --gpio-int /sys/class/gpio/gpio25 /dev/spidev0.0"
```
In this example, [spi-hdlc-adapter][spi-hdlc-adapter] is a tool that you can use to communicate between NCP and wpantund over SPI. For this example, `spi-hdlc-adapter` is installed in `/usr/bin`.
The default SPI Slave pin configuration for nRF52833 is defined in `examples/platforms/nrf52833/transport-config.h`.
Note that the native SPI Slave support is not intended to be used with Engineering sample A of the nRF52833 chip due to single transfer size limitation.
[spi-hdlc-adapter]: https://github.com/openthread/openthread/tree/master/tools/spi-hdlc-adapter
### Optional prefix for compiler command
You can prefix the compiler command using the CCPREFIX parameter. This speeds up the compilation when you use tools like [ccache][ccache-website]. Example usage:
[ccache-website]: https://ccache.samba.org/
```
$ make -f examples/Makefile-nrf52833 USB=1 CCPREFIX=ccache
```
### Optional mbedTLS threading support
By default, mbedTLS library is built without support for multiple threads. You can enable this built-in support by building OpenThread with the following parameter:
```
$ make -f examples/Makefile-nrf52833 MBEDTLS_THREADING=1
```
The simple mutex definition is used as shown below:
```
typedef void * mbedtls_threading_mutex_t;
```
However, you can modify it, by providing a path to a header file with proper definition. To do that, build OpenThread with the following parameter:
```
$ make -f examples/Makefile-nrf52833 MBEDTLS_THREADING=1 MBEDTLS_THREADING_MUTEX_DEF="path_to_a_header_file_with_mutex_definition.h"
```
See [mbedTls Thread Safety and Multi Threading][mbedtls-thread-safety-and-multi-threading] for more details.
[mbedtls-thread-safety-and-multi-threading]: https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
### IEEE EUI-64 address
When the Thread device is configured to obtain the Thread Network security credentials with either Thread Commissioning or an out-of-band method, the extended MAC address should be constructed out of the globally unique IEEE EUI-64.
The IEEE EUI-64 address consists of two parts:
- 24 bits of MA-L (MAC Address Block Large), formerly called OUI (Organizationally Unique Identifier)
- 40-bit device unique identifier
By default, the device uses Nordic Semiconductor's MA-L (f4-ce-36). You can modify it by overwriting the `OPENTHREAD_CONFIG_STACK_VENDOR_OUI` define, located in the `openthread-core-nrf52833-config.h` file. This value must be publicly registered by the IEEE Registration Authority.
You can also provide the full IEEE EUI-64 address by providing a custom `otPlatRadioGetIeeeEui64` function. To do this, define the flag `OPENTHREAD_CONFIG_ENABLE_PLATFORM_EUI64_CUSTOM_SOURCE`.
After the Thread Network security credentials have been successfully obtained, the device uses randomly generated extended MAC address.
## Flashing the binaries
Flash the compiled binaries onto nRF52833 using `nrfjprog` which is part of the [nRF5 Command Line Tools][nrf5-command-line-tools].
```bash
$ nrfjprog -f nrf52 --chiperase --program output/nrf52833/bin/ot-cli-ftd.hex --reset
```
## Running the example
To test the example:
1. Prepare two boards with the flashed `CLI Example` (as shown above). The CLI FTD example uses the direct UART connection.
2. Open a terminal connection on two boards:
a. Start a terminal emulator like screen.
b. Connect to the used COM port with the following direct UART settings:
- Baud rate: 115200
- 8 data bits
- 1 stop bit
- No parity
- HW flow control: RTS/CTS This allows you to view the raw UART output.
On Linux system a port name should be called e.g. `/dev/ttyACM0` or `/dev/ttyACM1`.
c. Run the following command to connect to a board.
```shell
screen /dev/ttyACM0 115200
```
Now you are connected with the CLI.
3. Use the following commands to form a network on the first board.
```bash
> dataset init new
Done
> dataset
Active Timestamp: 1
Channel: 13
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
Security Policy: 0, onrcb
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done
```
After a couple of seconds the node will become a Leader of the network.
```bash
> state
leader
```
4. Use the following commands to attach to the network on the second board.
```bash
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done
```
After a couple of seconds the second node will attach and become a Child.
```bash
> state
child
```
5. List all IPv6 addresses of the first board.
```bash
> ipaddr
fd3d:b50b:f96d:722d:0:ff:fe00:fc00
fd3d:b50b:f96d:722d:0:ff:fe00:c00
fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
fe80:0:0:0:6c41:9001:f3d6:4148
Done
```
6. Choose one of them and send an ICMPv6 ping from the second board.
```bash
> ping fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
16 bytes from fd3d:b50b:f96d:722d:558:f56b:d688:799: icmp_seq=1 hlim=64 time=24ms
```
For a list of all available commands, visit [OpenThread CLI Reference README.md][cli].
[cli]: ./../../../src/cli/README.md
## SEGGER J-Link tools
SEGGER J-Link tools allow to debug and flash generated firmware using on-board debugger or external one.
### Working with RTT logging
By default, the OpenThread's logging module provides functions to output logging information over SEGGER's Real Time Transfer (RTT).
You can set the desired log level by using the `OPENTHREAD_CONFIG_LOG_LEVEL` define.
To enable the highest verbosity level, append `FULL_LOGS` flag to the `make` command:
```
$ make -f examples/Makefile-nrf52833 FULL_LOGS=1
```
#### Enable logging on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link RTT Viewer`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52833_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
#### Enable logging on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52833_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID> -RTTTelnetPort 19021
```
3. Run `JLinkRTTTelnet` to obtain the RTT logs from the connected device in a separate console. For example:
```
JLinkRTTClient -RTTTelnetPort 19021
```
### Mass Storage Device known issue
Depending on your version, due to a known issue in SEGGER's J-Link firmware, you might experience data corruption or data drops if you use the serial port. You can avoid this issue by disabling the Mass Storage Device.
#### Disabling the Mass Storage Device on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link Commander`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52833_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
5. Run the following command:
```
MSDDisable
```
6. Power cycle the DK.
#### Disabling the Mass Storage Device on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52833_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID>
```
3. Run the following command:
```
MSDDisable
```
4. Power cycle the DK.
### Hardware Flow Control detection
By default, SEGGER J-Link automatically detects at runtime whether the target is using Hardware Flow Control (HWFC).
The automatic HWFC detection is done by driving P0.07 (Clear to Send - CTS) from the interface MCU and evaluating the state of P0.05 (Request to Send - RTS) when the first data is sent or received. If the state of P0.05 (RTS) is high, it is assumed that HWFC is not used.
To avoid potential race conditions, you can force HWFC and bypass the runtime auto-detection.
#### Disabling the HWFC detection on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link Commander`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52833_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
5. Run the following command:
```
SetHWFC Force
```
6. Power cycle the DK.
#### Disabling the HWFC detection on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52833_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID>
```
3. Run the following command:
```
SetHWFC Force
```
4. Power cycle the DK.
You can find more details [here][j-link-ob].
[j-link-ob]: https://wiki.segger.com/J-Link_OB_SAM3U_NordicSemi#Hardware_flow_control_support
## Diagnostic module
nRF52833 port extends [OpenThread Diagnostics Module][diag].
You can read about all the features [here][nrfdiag].
[diag]: ./../../../src/core/diags/README.md
[nrfdiag]: ./../DIAG.md
## Radio driver documentation
The radio driver comes with documentation that describes the operation of state machines in this module. To open the `*.uml` sequence diagrams, use [PlantUML][plantuml-url].
[plantuml-url]: http://plantuml.com/
# Nordic Semiconductor's nRF5 SDK for Thread and Zigbee
Use [nRF5 Software Development Kit (SDK) for Thread and Zigbee][nrf5-sdk-thread-zigbee] when developing Thread products with Nordic Semiconductor's advanced nRF52840, nRF52833 or nRF52811 SoCs.
The <i>nRF5 SDK for Thread and Zigbee</i> includes:
- a pre-built OpenThread stack for the Nordic nRF52840, nRF52833 and nRF52811 SoCs,
- support for hardware-accelerated cryptographic operations using ARM® CryptoCell-310,
- unique Thread/Bluetooth Low Energy dynamic multiprotocol solution which allows for concurrent operation of Thread and Bluetooth Low Energy utilizing OpenThread and SoftDevice (Nordics Bluetooth Low Energy stack) with accompanying example applications,
- Thread/Bluetooth Low Energy switched multiprotocol solution with accompanying example applications,
- unique support for DFU-over-Thread (Device Firmware Upgrade),
- examples to demonstrate interactions between nodes performing different Thread roles with the use of OpenThread and CoAP, CoAP Secure or MQTT-SN protocols,
- support for OpenThread Network Co-Processor (NCP) and Radio Co-Processor (RCP) using UART, USB or SPI transport protocol,
- Border Router and cloud connectivity example (e.g. with Google Cloud Platform),
- Thread native commissioning with NFC example,
- example applications demonstrating the use of FreeRTOS with OpenThread,
- support for IAR, Keil MDK-ARM and SEGGER Embedded Studio (SES) IDEs for OpenThread stack and all example applications,
- range of PC tools including Thread Topology Monitor and nRF Sniffer for 802.15.4,
- software modules inherited from the nRF5 SDK e.g. peripheral drivers, NFC libraries, Bluetooth Low Energy libraries etc.
[nrf5-sdk-thread-zigbee]: https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK-for-Thread-and-Zigbee
The OpenThread on nRF528xx example has moved to https://github.com/openthread/ot-nrf528xx
@@ -1,56 +0,0 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# 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.
#
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
set(CMAKE_RANLIB arm-none-eabi-ranlib)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs -fdata-sections -ffunction-sections")
if(COMPILER_VERSION VERSION_GREATER_EQUAL 7)
set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -Wno-expansion-to-defined")
endif()
set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti")
set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS} -x assembler-with-cpp")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs")
set(CMAKE_C_FLAGS_DEBUG "-Og -g")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
set(CMAKE_ASM_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_ASM_FLAGS_RELEASE "")
@@ -1,214 +0,0 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# 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.
#
set(OT_PLATFORM_LIB "openthread-nrf52833" "openthread-nrf52833-transport" PARENT_SCOPE)
if(NOT OT_CONFIG)
set(OT_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/nrf52833/openthread-core-nrf52833-config.h")
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
endif()
option(OT_BOOTLOADER "OT nrf bootloader type")
if(OT_BOOTLOADER STREQUAL "USB")
list(APPEND OT_PLATFORM_DEFINES "APP_USBD_NRF_DFU_TRIGGER_ENABLED=1")
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52833/nrf52833_bootloader_usb.ld")
elseif(OT_BOOTLOADER STREQUAL "UART")
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52833/nrf52833_bootloader_uart.ld")
elseif(OT_BOOTLOADER STREQUAL "BLE")
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52833/nrf52833_bootloader_ble.ld")
else()
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52833/nrf52833.ld")
endif()
list(APPEND OT_PLATFORM_DEFINES
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-nrf52833-config-check.h\""
)
list(APPEND OT_PUBLIC_INCLUDES
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config"
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/nrfx/mdk"
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/cmsis"
)
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
target_compile_definitions(ot-config INTERFACE
"MBEDTLS_USER_CONFIG_FILE=\"nrf52833-mbedtls-config.h\""
)
set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE)
set(COMM_FLAGS
-DDISABLE_CC310=1
-DCONFIG_GPIO_AS_PINRESET
-DNRF52833_XXAA
-DUSE_APP_CONFIG=1
-Wno-unused-parameter
-Wno-expansion-to-defined
)
if(OT_CFLAGS MATCHES "-pedantic-errors")
string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}")
endif()
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
add_library(openthread-nrf52833
${NRF_COMM_SOURCES}
${NRF_SINGLEPHY_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
add_library(openthread-nrf52833-transport
${NRF_TRANSPORT_SOURCES}
)
add_library(openthread-nrf52833-sdk
${NRF_COMM_SOURCES}
${NRF_SINGLEPHY_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
add_library(openthread-nrf52833-softdevice-sdk
${NRF_COMM_SOURCES}
${NRF_SOFTDEVICE_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
target_link_libraries(openthread-nrf52833
PUBLIC
${OT_MBEDTLS}
${NRF52833_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_link_libraries(openthread-nrf52833-transport
PUBLIC
${OT_MBEDTLS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
nordicsemi-nrf52833-sdk
ot-config
)
target_link_libraries(openthread-nrf52833-sdk
PUBLIC
${OT_MBEDTLS}
${NRF52833_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_link_libraries(openthread-nrf52833-softdevice-sdk
PUBLIC
${OT_MBEDTLS}
${NRF52833_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_compile_definitions(openthread-nrf52833
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52833-transport
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52833-sdk
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52833-softdevice-sdk
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_options(openthread-nrf52833
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
)
target_compile_options(openthread-nrf52833-transport
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
)
target_compile_options(openthread-nrf52833-sdk
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
)
target_compile_options(openthread-nrf52833-softdevice-sdk
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
-DSOFTDEVICE_PRESENT
-DS140
)
target_include_directories(openthread-nrf52833
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52833
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52833-transport
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52833
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52833-sdk
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52833
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52833-softdevice-sdk
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52833
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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) HOWEVEpR 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.
*/
/**
* @file
* GCC linker script for nRF52833.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x80000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 2;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52833 with BLE bootloader.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00026000, LENGTH = 0x52000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x1fff8
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 2;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52833 with UART bootloader.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 0x77000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x1fff8
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 2;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2018, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52833 with USB bootloader.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 0x5f000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x1fff8
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 2;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,36 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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 OPENTHREAD_CORE_NRF52833_CONFIG_CHECK_H_
#define OPENTHREAD_CORE_NRF52833_CONFIG_CHECK_H_
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
#error "Platform nrf52833 doesn't support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
#endif
#endif /* OPENTHREAD_CORE_NRF52833_CONFIG_CHECK_H_ */
@@ -1,320 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes nrf52833 compile-time configuration constants
* for OpenThread.
*/
#ifndef OPENTHREAD_CORE_NRF52833_CONFIG_H_
#define OPENTHREAD_CORE_NRF52833_CONFIG_H_
/*
* The GNU Autoconf system defines a PACKAGE macro which is the name
* of the software package. This name collides with PACKAGE field in
* the nRF52 Factory Information Configuration Registers (FICR)
* structure.
*/
#undef PACKAGE
/**
* @def OPENTHREAD_CONFIG_LOG_OUTPUT
*
* The nrf52833 platform provides an otPlatLog() function.
*/
#ifndef OPENTHREAD_CONFIG_LOG_OUTPUT
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_INFO
*
* The platform-specific string to insert into the OpenThread version string.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_INFO
#define OPENTHREAD_CONFIG_PLATFORM_INFO "NRF52833"
#endif
/**
* @def OPENTHREAD_CONFIG_STACK_VENDOR_OUI
*
* The Organizationally Unique Identifier for the vendor.
*
*/
#ifndef OPENTHREAD_CONFIG_STACK_VENDOR_OUI
#define OPENTHREAD_CONFIG_STACK_VENDOR_OUI 0xf4ce36
#endif
/**
* @def OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
*
* The maximum number of children.
*
*/
#ifndef OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#define OPENTHREAD_CONFIG_MLE_MAX_CHILDREN 32
#endif
/**
* @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
*
* The number of message buffers in the buffer pool.
*
*/
#ifndef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 160
#endif
/**
* @def OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD
*
* The maximum number of supported IPv6 address registrations per child.
*
*/
#ifndef OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD
#define OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD 6
#endif
/**
* @def OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
*
* The maximum number of state-changed callback handlers (set using `otSetStateChangedCallback()`).
*
*/
#ifndef OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
#endif
/**
* @def OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
*
* The number of EID-to-RLOC cache entries.
*
*/
#ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
#define OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES 32
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_PREPREND_LEVEL
*
* Define to prepend the log level to all log messages
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
*
* Define to 1 if you want to enable software ACK timeout logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
*
* Define to 1 if you want to enable software retransmission logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
*
* Define to 1 if you want to enable software CSMA-CA backoff logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
*
* Define to 1 if you want to enable software transmission security logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE
*
* Define to 1 to enable software transmission target time logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE
*
* Define to 1 to enable software reception target time logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
*
* Define to 1 if you want to support microsecond timer in platform.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
*
* Define to 1 to enable otPlatFlash* APIs to support non-volatile storage.
*
* When defined to 1, the platform MUST implement the otPlatFlash* APIs instead of the otPlatSettings* APIs.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE
*
* The size of heap buffer when DTLS is enabled.
*
*/
#ifndef OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE
#define OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE (4096 * sizeof(void *))
#endif
/**
* @def OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE_NO_DTLS
*
* The size of heap buffer when DTLS is disabled.
*
*/
#ifndef OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE_NO_DTLS
#define OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE_NO_DTLS 4000
#endif
/**
* @def OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
*
* Define as 1 to enable the time synchronization service feature.
*
*/
#ifndef OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_CLI_TX_BUFFER_SIZE
*
* The size of CLI message buffer in bytes
*
*/
#ifndef OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE
#define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 2048
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
*
* Define as 1 to support IEEE 802.15.4-2015 Header IE (Information Element) generation and parsing, it must be set
* to support following features:
* 1. Time synchronization service feature (i.e., OPENTHREAD_CONFIG_TIME_SYNC_ENABLE is set).
*
* @note If it's enabled, plaforms must support interrupt context and concurrent access AES.
*
*/
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#define OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT 1
#endif
/**
* @def RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
*
* The number of short source address table entries.
*
*/
#ifndef RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
#define RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM 0
#endif
/**
* @def RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
*
* The number of extended source address table entries.
*
*/
#ifndef RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
#define RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM 0
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
*
* Reception scheduling and ramp up time needed for the CSL receiver to be ready, in units of microseconds.
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 2000
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON
*
* The minimum CSL receive window (in microseconds) required to receive an IEEE 802.15.4 frame.
* - Frame preamble: 6*2 symbols + margin
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON
#define OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 12 * 16
#endif
/*
* Suppress the ARMCC warning on unreachable statement,
* e.g. break after assert(false) or ExitNow() macro.
*/
#if defined(__CC_ARM)
_Pragma("diag_suppress=111") _Pragma("diag_suppress=128")
#endif
#endif // OPENTHREAD_CORE_NRF52833_CONFIG_H_
@@ -1,215 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the platform-specific configuration.
*
*/
#ifndef PLATFORM_CONFIG_H_
#define PLATFORM_CONFIG_H_
#include "nrf.h"
#include "nrf_drv_clock.h"
#include "nrf_peripherals.h"
#include "hal/nrf_radio.h"
#include "openthread-core-config.h"
#include <openthread/config.h>
/*******************************************************************************
* @section Alarm Driver Configuration.
******************************************************************************/
/**
* @def RTC_INSTANCE
*
* RTC Instance.
*
*/
#ifndef RTC_INSTANCE
#define RTC_INSTANCE NRF_RTC2
#endif
/**
* @def RTC_IRQ_HANDLER
*
* RTC interrupt handler name
*
*/
#ifndef RTC_IRQ_HANDLER
#define RTC_IRQ_HANDLER RTC2_IRQHandler
#endif
/**
* @def RTC_IRQN
*
* RTC Interrupt number.
*
*/
#ifndef RTC_IRQN
#define RTC_IRQN RTC2_IRQn
#endif
/**
* @def RTC_IRQ_PRIORITY
*
* RTC Interrupt priority.
*
*/
#ifndef RTC_IRQ_PRIORITY
#define RTC_IRQ_PRIORITY 6
#endif
/*******************************************************************************
* @section Random Number Generator Driver Configuration.
******************************************************************************/
/**
* @def RNG_BUFFER_SIZE
*
* True Random Number Generator buffer size.
*
*/
#ifndef RNG_BUFFER_SIZE
#define RNG_BUFFER_SIZE 128
#endif
/**
* @def RNG_IRQ_PRIORITY
*
* RNG Interrupt priority.
*
*/
#ifndef RNG_IRQ_PRIORITY
#define RNG_IRQ_PRIORITY 6
#endif
/*******************************************************************************
* @section Platform Flash Configuration
******************************************************************************/
/**
* @def PLATFORM_FLASH_PAGE_NUM
*
* Number of flash pages to use for OpenThread's non-volatile settings.
*
* @note This define applies only for MDK-ARM Keil toolchain configuration.
*
*/
#ifndef PLATFORM_FLASH_PAGE_NUM
#define PLATFORM_FLASH_PAGE_NUM 2
#endif
/*******************************************************************************
* @section Platform FEM Configuration
******************************************************************************/
/**
* @def PLATFORM_FEM_ENABLE_DEFAULT_CONFIG
*
* Enable default front end module configuration.
*
*/
#ifndef PLATFORM_FEM_ENABLE_DEFAULT_CONFIG
#define PLATFORM_FEM_ENABLE_DEFAULT_CONFIG 0
#endif
/*******************************************************************************
* @section Radio driver configuration.
******************************************************************************/
/**
* @def NRF_802154_PENDING_SHORT_ADDRESSES
*
* Number of slots containing short addresses of nodes for which pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_SHORT_ADDRESSES
#define NRF_802154_PENDING_SHORT_ADDRESSES OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#endif
/**
* @def NRF_802154_PENDING_EXTENDED_ADDRESSES
*
* Number of slots containing extended addresses of nodes for which pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_EXTENDED_ADDRESSES
#define NRF_802154_PENDING_EXTENDED_ADDRESSES OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#endif
/**
* @def NRF_802154_CSMA_CA_ENABLED
*
* If CSMA-CA procedure should be enabled by the driver. Disabling CSMA-CA procedure improves
* driver performance.
*
*/
#ifndef NRF_802154_CSMA_CA_ENABLED
#define NRF_802154_CSMA_CA_ENABLED 1
#endif
/**
* @def NRF_802154_ACK_TIMEOUT_ENABLED
*
* If ACK timeout feature should be enabled in the driver.
*
*/
#ifndef NRF_802154_ACK_TIMEOUT_ENABLED
#define NRF_802154_ACK_TIMEOUT_ENABLED 1
#endif
/*******************************************************************************
* @section Temperature sensor driver configuration.
******************************************************************************/
/**
* @def TEMP_MEASUREMENT_INTERVAL
*
* Interval of consecutive temperature measurements [s].
*
*/
#ifndef TEMP_MEASUREMENT_INTERVAL
#define TEMP_MEASUREMENT_INTERVAL 30
#endif
/**
* @def NRF_802154_TX_STARTED_NOTIFY_ENABLED
*
* If notification of started transmission should be enabled in the driver.
*
* @note This feature must be enabled to support Header IE related features.
*
*/
#ifndef NRF_802154_TX_STARTED_NOTIFY_ENABLED
#define NRF_802154_TX_STARTED_NOTIFY_ENABLED 1
#endif
#endif // PLATFORM_CONFIG_H_
@@ -1,309 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the transport-specific configuration.
*
*/
#ifndef TRANSPORT_CONFIG_H_
#define TRANSPORT_CONFIG_H_
#include "nrf.h"
#include "hal/nrf_spis.h"
#include "hal/nrf_uart.h"
/*******************************************************************************
* @section UART Driver Configuration.
******************************************************************************/
/**
* @def UART_INSTANCE
*
* UART Instance.
*
*/
#ifndef UART_INSTANCE
#define UART_INSTANCE NRF_UARTE0
#endif
/**
* @def UART_PARITY
*
* UART Parity configuration.
*
* @brief Possible values:
* \ref NRF_UARTE_PARITY_EXCLUDED - Parity bit is not present.
* \ref NRF_UARTE_PARITY_INCLUDED - Parity bit is present.
*
*/
#ifndef UART_PARITY
#define UART_PARITY NRF_UARTE_PARITY_EXCLUDED
#endif
/**
* @def UART_HWFC_ENABLED
*
* Enable UART Hardware Flow Control.
*
*/
#ifndef UART_HWFC_ENABLED
#define UART_HWFC_ENABLED 1
#endif
/**
* @def UART_BAUDRATE
*
* UART Baudrate.
*
* @brief Possible values:
* \ref NRF_UARTE_BAUDRATE_1200 - 1200 baud.
* \ref NRF_UARTE_BAUDRATE_2400 - 2400 baud.
* \ref NRF_UARTE_BAUDRATE_4800 - 4800 baud.
* \ref NRF_UARTE_BAUDRATE_9600 - 9600 baud.
* \ref NRF_UARTE_BAUDRATE_14400 - 14400 baud.
* \ref NRF_UARTE_BAUDRATE_19200 - 19200 baud.
* \ref NRF_UARTE_BAUDRATE_28800 - 28800 baud.
* \ref NRF_UARTE_BAUDRATE_38400 - 38400 baud.
* \ref NRF_UARTE_BAUDRATE_57600 - 57600 baud.
* \ref NRF_UARTE_BAUDRATE_76800 - 76800 baud.
* \ref NRF_UARTE_BAUDRATE_115200 - 115200 baud.
* \ref NRF_UARTE_BAUDRATE_230400 - 230400 baud.
* \ref NRF_UARTE_BAUDRATE_250000 - 250000 baud.
* \ref NRF_UARTE_BAUDRATE_460800 - 460800 baud.
* \ref NRF_UARTE_BAUDRATE_921600 - 921600 baud.
* \ref NRF_UARTE_BAUDRATE_1000000 - 1000000 baud.
*
*/
#ifndef UART_BAUDRATE
#define UART_BAUDRATE NRF_UARTE_BAUDRATE_115200
#endif
/**
* @def UART_IRQN
*
* UART Interrupt number.
*
*/
#ifndef UART_IRQN
#define UART_IRQN UARTE0_UART0_IRQn
#endif
/**
* @def UART_IRQ_PRIORITY
*
* UART Interrupt priority.
*
*/
#ifndef UART_IRQ_PRIORITY
#define UART_IRQ_PRIORITY 6
#endif
/**
* @def UART_RX_BUFFER_SIZE
*
* UART Receive buffer size.
*
*/
#ifndef UART_RX_BUFFER_SIZE
#define UART_RX_BUFFER_SIZE 512
#endif
/**
* @def UART_PIN_TX
*
* UART TX Pin.
*
*/
#ifndef UART_PIN_TX
#define UART_PIN_TX 6
#endif
/**
* @def UART_PIN_RX
*
* UART RX Pin.
*
*/
#ifndef UART_PIN_RX
#define UART_PIN_RX 8
#endif
/**
* @def UART_PIN_CTS
*
* UART CTS Pin.
*
*/
#ifndef UART_PIN_CTS
#define UART_PIN_CTS 7
#endif
/**
* @def UART_PIN_RTS
*
* UART RTS Pin.
*
*/
#ifndef UART_PIN_RTS
#define UART_PIN_RTS 5
#endif
/*******************************************************************************
* @section SPI Slave configuration.
******************************************************************************/
/**
* @def SPIS Instance.
*/
#ifndef SPIS_INSTANCE
#define SPIS_INSTANCE 0
#endif
/**
* @def SPIS mode.
*
* @brief Possible values:
* \ref NRF_SPIS_MODE_0 - SCK active high, sample on leading edge of clock.
* \ref NRF_SPIS_MODE_1 - SCK active high, sample on trailing edge of clock.
* \ref NRF_SPIS_MODE_2 - SCK active low, sample on leading edge of clock.
* \ref NRF_SPIS_MODE_3 - SCK active low, sample on trailing edge of clock.
*/
#ifndef SPIS_MODE
#define SPIS_MODE NRF_SPIS_MODE_0
#endif
/**
* @def SPIS bit orders.
*
* @brief Possible values:
* \ref NRF_SPIS_BIT_ORDER_MSB_FIRST - Most significant bit shifted out first.
* \ref NRF_SPIS_BIT_ORDER_LSB_FIRST - Least significant bit shifted out first.
*/
#ifndef SPIS_BIT_ORDER
#define SPIS_BIT_ORDER NRF_SPIS_BIT_ORDER_MSB_FIRST
#endif
/**
* @def SPIS Interrupt priority.
*/
#ifndef SPIS_IRQ_PRIORITY
#define SPIS_IRQ_PRIORITY 6
#endif
/**
* @def SPIS MOSI Pin.
*/
#ifndef SPIS_PIN_MOSI
#define SPIS_PIN_MOSI 4
#endif
/**
* @def SPIS MISO Pin.
*/
#ifndef SPIS_PIN_MISO
#define SPIS_PIN_MISO 28
#endif
/**
* @def SPIS SCK Pin.
*/
#ifndef SPIS_PIN_SCK
#define SPIS_PIN_SCK 3
#endif
/**
* @def SPIS CSN Pin.
*/
#ifndef SPIS_PIN_CSN
#define SPIS_PIN_CSN 29
#endif
/**
* @def SPIS Host IRQ Pin.
*/
#ifndef SPIS_PIN_HOST_IRQ
#define SPIS_PIN_HOST_IRQ 30
#endif
/*******************************************************************************
* @section USB driver configuration.
******************************************************************************/
/**
* @def USB_HOST_UART_CONFIG_DELAY_MS
*
* Delay after DTR gets asserted that we start send any queued data. This allows slow
* Linux-based hosts to have enough time to configure their port for raw mode.
*
*/
#ifndef USB_HOST_UART_CONFIG_DELAY_MS
#define USB_HOST_UART_CONFIG_DELAY_MS 10
#endif
/**
* @def USB_CDC_AS_SERIAL_TRANSPORT
*
* Use USB CDC driver for serial communication.
*/
#ifndef USB_CDC_AS_SERIAL_TRANSPORT
#define USB_CDC_AS_SERIAL_TRANSPORT 0
#endif
/**
* @def The USB interface to use for CDC ACM COMM.
*
* According to the USB Specification, interface numbers cannot have gaps. Tailor this value to adhere to this
* limitation. Takes values between 0-255.
*/
#ifndef USB_CDC_ACM_COMM_INTERFACE
#define USB_CDC_ACM_COMM_INTERFACE 1
#endif
/**
* @def The USB interface to use for CDC ACM DATA.
*
* According to the USB Specification, interface numbers cannot have gaps. Tailor this value to adhere to this
* limitation. Takes values between 0-255.
*/
#ifndef USB_CDC_ACM_DATA_INTERFACE
#define USB_CDC_ACM_DATA_INTERFACE 2
#endif
/**
* @def OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
*
* Reset the application, not the chip, when a software reset is requested.
* via `otPlatReset()`.
*/
#ifndef OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
#define OPENTHREAD_PLATFORM_USE_PSEUDO_RESET USB_CDC_AS_SERIAL_TRANSPORT
#endif
#endif // TRANSPORT_CONFIG_H_
@@ -1,207 +0,0 @@
#
# Copyright (c) 2016-2017, The OpenThread Authors.
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = \
libopenthread-nrf52840.a \
libopenthread-nrf52840-sdk.a \
libopenthread-nrf52840-softdevice-sdk.a \
libopenthread-nrf52840-transport.a \
$(NULL)
# Do not enable -pedantic-errors for nRF52840 driver library
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for nRF52840 driver library
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
# Do not enable -Wcast-align for nRF52840 driver library
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
COMMONCPPFLAGS = \
-DCONFIG_GPIO_AS_PINRESET \
-DNRF52840_XXAA \
-DUSE_APP_CONFIG=1 \
-I$(srcdir) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/nrf528xx/src \
-I$(top_srcdir)/examples/platforms/nrf528xx/src/transport \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/softdevice \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/lp_timer \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/temperature \
$(NULL)
# Only reference the SDK header files included in third_party/NordicSemiconductor
# when building the example applications.
#
# When building just the platform libraries, the caller of configure is expected
# to provide the correct -I arguments to locate the necessary header files in an
# external copy of the Nordic nRF5 SDK.
#
# Note that an exception is made for the 802.15.4 radio driver, which is always
# built using the sources in third_party/NordicSemiconductor/drivers/radio.
if OPENTHREAD_ENABLE_EXAMPLES
COMMONCPPFLAGS += \
-I$(top_srcdir)/third_party/NordicSemiconductor \
-I$(top_srcdir)/third_party/NordicSemiconductor/cmsis \
-I$(top_srcdir)/third_party/NordicSemiconductor/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52840/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/dependencies \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/clock \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/common \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/power \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/systick \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/soc \
-I$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers \
-I$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf52 \
$(NULL)
endif
PLATFORM_COMMON_SOURCES = \
src/alarm.c \
src/diag.c \
src/entropy.c \
src/fem.c \
src/flash.c \
src/logging.c \
src/misc.c \
src/radio.c \
src/system.c \
src/temp.c \
$(NULL)
TRANSPORT_SOURCES = \
src/transport/spi-slave.c \
src/transport/uart.c \
src/transport/usb-cdc-uart.c \
src/transport/transport.c \
$(NULL)
SINGLEPHY_SOURCES = \
src/flash_nosd.c \
$(NULL)
SOFTDEVICE_SOURCES = \
src/flash_sd.c \
src/softdevice.c \
src/softdevice.h \
$(NULL)
SOFTDEVICE_CPPFLAGS = \
-DSOFTDEVICE_PRESENT \
-DS140 \
-Wno-unused-parameter \
$(NULL)
PLATFORM_SOURCES = \
$(PLATFORM_COMMON_SOURCES) \
$(NULL)
libopenthread_nrf52840_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SINGLEPHY_CPPFLAGS) \
-DPLATFORM_OPENTHREAD_VANILLA \
$(NULL)
libopenthread_nrf52840_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SINGLEPHY_SOURCES) \
$(NULL)
libopenthread_nrf52840_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SINGLEPHY_CPPFLAGS) \
$(NULL)
libopenthread_nrf52840_sdk_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SINGLEPHY_SOURCES) \
$(NULL)
libopenthread_nrf52840_softdevice_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(SOFTDEVICE_CPPFLAGS) \
$(NULL)
libopenthread_nrf52840_softdevice_sdk_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(SOFTDEVICE_SOURCES) \
$(NULL)
libopenthread_nrf52840_transport_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NULL)
libopenthread_nrf52840_transport_a_SOURCES = \
$(TRANSPORT_SOURCES) \
$(NULL)
Dash = -
libopenthread_nrf52840_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52840_sdk_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52840_softdevice_sdk_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
libopenthread_nrf52840_transport_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,61 +0,0 @@
#
# Copyright (c) 2017, The OpenThread Authors.
# 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.
#
#
# nrf52840 platform-specific Makefile
#
LDADD_COMMON += \
$(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52840.a \
$(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52840-transport.a \
$(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52840-sdk.a \
$(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52840-radio-driver.a \
$(NULL)
if !OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
# !!!!Order of linking is important here!!!!
LDADD_COMMON += \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_shared.a \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_tls_vanilla.a \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_x509_vanilla.a \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_cc3xx.a \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_security/lib/libnrf_cc310_platform_0.9.4.a \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_oberon.a \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_base_vanilla.a \
$(NULL)
endif
if OPENTHREAD_ENABLE_CUSTOM_LINKER_FILE
LDFLAGS_COMMON += \
-T $(OPENTHREAD_CUSTOM_LINKER_FILE) \
$(NULL)
else
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/nrf528xx/nrf52840/nrf52840.ld \
$(NULL)
endif
+1 -571
View File
@@ -1,571 +1 @@
# OpenThread on nRF52840 Example
<a href="http://threadgroup.org/technology/ourtechnology#certifiedproducts">
<img src="https://cdn.rawgit.com/openthread/openthread/ab4c4e1e/doc/images/certified.svg" alt="Thread Certified Component" width="150px" align="right">
</a>
This directory contains example platform drivers for [Nordic Semiconductor nRF52840 SoC][nrf52840]. The OpenThread stack has been officially certified as a _Thread Certified Component_ on this platform.
[nrf52840]: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52840
To facilitate Thread products development with the nRF52840 platform, Nordic Semiconductor provides <i>nRF5 SDK for Thread and Zigbee</i>. See [Nordic Semiconductor's nRF5 SDK for Thread and Zigbee][nrf5-sdk-section] section for more details.
[nrf5-sdk-section]: #nordic-semiconductors-nrf5-sdk-for-thread-and-zigbee
## Prerequisites
Before you start building the examples, you must download and install the toolchain and the tools required for flashing and debugging.
### Toolchain
Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
[gnu-toolchain]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
To install the GNU toolchain and its dependencies, run the following commands in Bash:
```bash
$ cd <path-to-openthread>
$ ./script/bootstrap
```
### Flashing and debugging tools
[nrf-command-line-tools]: https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools
Install the [nRF Command Line Tools][nrf-command-line-tools] to flash, debug, and make use of logging features on the nRF52840 DK with SEGGER J-Link.
## Building the examples
To build the examples, run the following command in Bash:
```bash
$ cd <path-to-openthread>
$ ./bootstrap
$ make -f examples/Makefile-nrf52840
```
After a successful build, the `elf` files can be found in `<path-to-openthread>/output/nrf52840/bin`. You can convert them to hex using `arm-none-eabi-objcopy`:
```bash
$ arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.hex
```
### USB CDC ACM support
You can build the libraries with support for the native USB CDC ACM as a serial transport. To do so, build the firmware with the following parameter:
```
$ make -f examples/Makefile-nrf52840 USB=1
```
Note that the USB CDC ACM serial transport is not supported with Engineering sample A of the nRF52840 chip.
If you are using Windows 7 or earlier, you must load an additional USB CDC driver. The driver can be found in `third_party/NordicSemiconductor/libraries/usb/nordic_cdc_acm_example.inf`.
### Bootloader support
The examples support the following bootloaders for performing a Device Firmware Upgrade (DFU):
- USB bootloader
- UART bootloader
- BLE bootloader
The support for a particular bootloader can be enabled with the following switches:
- USB: `BOOTLOADER=USB`
- UART: `BOOTLOADER=UART`
- BLE: `BOOTLOADER=BLE`
### nRF52840 dongle support (PCA10059)
You can build the libraries with support for the USB bootloader with USB DFU trigger support in PCA10059. As this dongle uses the native USB support, you must enable it as well.
To build the libraries, run make with the following parameters:
```
$ make -f examples/Makefile-nrf52840 USB=1 BOOTLOADER=USB
```
See [nRF52840 Dongle Programming][nrf52840-dongle-programming] for more details about how to use the USB bootloader.
[nrf52840-dongle-programming]: https://infocenter.nordicsemi.com/topic/ug_nc_programmer/UG/nrf_connect_programmer/ncp_programming_dongle.html
### Native SPI support
You can build the libraries with support for native SPI Slave. To build the libraries, run make with the following parameter:
```
$ make -f examples/Makefile-nrf52840 NCP_SPI=1
```
With this option enabled, SPI communication between the NCP example and wpantund is possible (provided that the wpantund host supports SPI Master). To achieve that, an appropriate SPI device should be chosen in wpantund configuration file, `/etc/wpantund.conf`. You can find an example below.
```
Config:NCP:SocketPath "system:/usr/bin/spi-hdlc-adapter --gpio-int /sys/class/gpio/gpio25 /dev/spidev0.0"
```
In this example, [spi-hdlc-adapter][spi-hdlc-adapter] is a tool that you can use to communicate between NCP and wpantund over SPI. For this example, `spi-hdlc-adapter` is installed in `/usr/bin`.
The default SPI Slave pin configuration for nRF52840 is defined in `examples/platforms/nrf52840/transport-config.h`.
Note that the native SPI Slave support is not intended to be used with Engineering sample A of the nRF52840 chip due to single transfer size limitation.
[spi-hdlc-adapter]: https://github.com/openthread/openthread/tree/master/tools/spi-hdlc-adapter
### Optional prefix for compiler command
You can prefix the compiler command using the CCPREFIX parameter. This speeds up the compilation when you use tools like [ccache][ccache-website]. Example usage:
[ccache-website]: https://ccache.samba.org/
```
$ make -f examples/Makefile-nrf52840 USB=1 CCPREFIX=ccache
```
### CryptoCell 310 support
By default, OpenThread uses mbedTLS library with support for CryptoCell 310 hardware acceleration of cryptographic operations. When building the application, an explicit setup is needed (error checking omitted):
```
mbedtls_platform_set_calloc_free(calloc, free);
mbedtls_platform_setup(NULL);
```
When building an external application with OpenThread libraries and CryptoCell 310 hardware acceleration, use the following configuration:
- Crypto libraries:
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_shared.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_tls_vanilla.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_x509_vanilla.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_cc3xx.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libnrf_cc310_platform_0.9.4.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_oberon.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_base_vanilla.a`
- Include directories:
- `third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_platform_config`
- `third_party/NordicSemiconductor/libraries/nrf_security/include`
- `third_party/NordicSemiconductor/libraries/nrf_security/config`
- `third_party/NordicSemiconductor/libraries/nrf_security/nrf_cc310_platform/include`
- Defines:
- `MBEDTLS_CONFIG_FILE` set to `"nrf-config.h"`
- `MBEDTLS_USER_CONFIG_FILE` set to `"nrf52840-mbedtls-config.h"`
### Optional disabling of CryptoCell 310 support
By default, OpenThread uses mbedTLS library with support for CryptoCell 310 hardware acceleration of cryptographic operations. You can disable CryptoCell 310 and use software cryptography instead by building OpenThread with the following parameter:
```
$ make -f examples/Makefile-nrf52840 DISABLE_BUILTIN_MBEDTLS=0 ...
```
When building an external application with OpenThread libraries and software cryptography, use the following configuration:
- Crypto libraries:
- `output/nrf52840/lib/libmbedcrypto.a` (present after successful build)
- Include directories:
- `third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_platform_config`
- `third_party/mbedtls`
- `third_party/mbedtls/repo/include`
- Defines:
- `MBEDTLS_CONFIG_FILE` set to `"mbedtls-config.h"`
- `MBEDTLS_USER_CONFIG_FILE` set to `"nrf52840-mbedtls-config.h"`
### CryptoCell 310 abort mechanism
The CryptoCell 310 platform implements an abort mechanism. By default, any fault in the CryptoCell 310 library results in the system reset. This behavior can be changed by a call to the `nrf_cc310_platform_set_abort()` function. This function must be called before `mbedtls_platform_setup`:
```
void nrf_cc310_platform_set_abort(
nrf_cc310_platform_abort_apis_t const * const apis)
```
### CryptoCell 310 RTOS support
The hardware-accelerated mbedTLS library supports access from multiple threads. By default, simple blocking implementation of mutexes is used. The locking mechanism can be replaced by using the `nrf_cc310_platform_set_mutexes()` function. This function must be called before `mbedtls_platform_setup`:
```
void nrf_cc310_platform_set_mutexes(nrf_cc310_platform_mutex_apis_t const * const apis,
nrf_cc310_platform_mutexes_t const * const mutexes)
```
The sample implementation of mutexes for FreeRTOS and Zephyr operating systems can be found in `nrf_cc3xx_platform_mutex_freertos.c` and `nrf_cc3xx_platform_mutex_zephyr.c`. Both files implement the function `int nrf_cc310_platform_mutex_init(void)`. This function must be called before `mbedtls_platform_setup`.
The sample implementation of the abort functionality for FreeRTOS and Zephyr operating systems can be found in `nrf_cc3xx_platform_abort_freertos.c` and `nrf_cc3xx_platform_abort_zephyr.c`. Both files implement the function `void nrf_cc310_platform_abort_init(void)`. This function must be called before `mbedtls_platform_setup`.
The typical setup in the RTOS environment (error checking omitted) is as follows:
```
mbedtls_platform_set_calloc_free(calloc, free);
nrf_cc310_platform_abort_init();
nrf_cc310_platform_mutex_init();
mbedtls_platform_setup(NULL);
```
When building an external application that uses RTOS with OpenThread libraries and the CryptoCell 310 hardware acceleration, use the following configuration:
- Crypto libraries:
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_shared.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_tls_vanilla.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_x509_vanilla.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_cc3xx.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libnrf_cc310_platform_0.9.4.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedcrypto_oberon.a`
- `/third_party/NordicSemiconductor/libraries/nrf_security/lib/libmbedtls_base_vanilla.a`
- Include directories:
- `third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_platform_config`
- `third_party/NordicSemiconductor/libraries/nrf_security/include`
- `third_party/NordicSemiconductor/libraries/nrf_security/config`
- `third_party/NordicSemiconductor/libraries/nrf_security/nrf_cc310_platform/include`
- Defines:
- `MBEDTLS_CONFIG_FILE` set to `"nrf-config.h"`
- `MBEDTLS_USER_CONFIG_FILE` set to `"nrf52840-mbedtls-config.h"`
- Sources:
- `nrf_cc3xx_platform_mutex_freertos.c` or `nrf_cc3xx_platform_mutex_zephyr.c` from `third_party/NordicSemiconductor/libraries/nrf_security/nrf_cc310_platform/src`, depending on the RTOS used.
- `nrf_cc3xx_platform_abort_freertos.c` or `nrf_cc3xx_platform_abort_zephyr.c` from `third_party/NordicSemiconductor/libraries/nrf_security/nrf_cc310_platform/src`, depending on the RTOS used.
See [mbedTls Thread Safety and Multi Threading][mbedtls-thread-safety-and-multi-threading] for more details.
### Optional software only mbedTLS threading support
By default, the software-only mbedTLS library is built without support for multiple threads. You can enable this built-in support by building OpenThread with the following parameter:
```
$ make -f examples/Makefile-nrf52840 MBEDTLS_THREADING=1
```
The simple mutex definition is used as shown below:
```
typedef void * mbedtls_threading_mutex_t;
```
However, you can modify it, by providing a path to a header file with proper definition. To do that, build OpenThread with the following parameter:
```
$ make -f examples/Makefile-nrf52840 MBEDTLS_THREADING=1 MBEDTLS_THREADING_MUTEX_DEF="path_to_a_header_file_with_mutex_definition.h"
```
When building an external application that uses RTOS with OpenThread libraries and software cryptography, use the following configuration:
- Crypto libraries:
- `output/nrf52840/lib/libmbedcrypto.a` (present after successful build)
- Include directories:
- `third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_platform_config`
- `third_party/mbedtls`
- `third_party/mbedtls/repo/include`
- `third_party/NordicSemiconductor/libraries/nrf_security/include/software-only-threading`
- Defines:
- `MBEDTLS_CONFIG_FILE` set to `"mbedtls-config.h"`
- `MBEDTLS_USER_CONFIG_FILE` set to `"nrf52840-mbedtls-config.h"`
- `MBEDTLS_THREADING_C`
- `MBEDTLS_THREADING_ALT`
See [mbedTls Thread Safety and Multi Threading][mbedtls-thread-safety-and-multi-threading] for more details.
[mbedtls-thread-safety-and-multi-threading]: https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
### IEEE EUI-64 address
When the Thread device is configured to obtain the Thread Network security credentials with either Thread Commissioning or an out-of-band method, the extended MAC address should be constructed out of the globally unique IEEE EUI-64.
The IEEE EUI-64 address consists of two parts:
- 24 bits of MA-L (MAC Address Block Large), formerly called OUI (Organizationally Unique Identifier)
- 40-bit device unique identifier
By default, the device uses Nordic Semiconductor's MA-L (f4-ce-36). You can modify it by overwriting the `OPENTHREAD_CONFIG_STACK_VENDOR_OUI` define, located in the `openthread-core-nrf52840-config.h` file. This value must be publicly registered by the IEEE Registration Authority.
You can also provide the full IEEE EUI-64 address by providing a custom `otPlatRadioGetIeeeEui64` function. To do this, define the flag `OPENTHREAD_CONFIG_ENABLE_PLATFORM_EUI64_CUSTOM_SOURCE`.
After the Thread Network security credentials have been successfully obtained, the device uses randomly generated extended MAC address.
## Flashing the binaries
Flash the compiled binaries onto nRF52840 using `nrfjprog` which is part of the [nRF Command Line Tools][nrf-command-line-tools].
```bash
$ nrfjprog -f nrf52 --chiperase --program output/nrf52840/bin/ot-cli-ftd.hex --reset
```
## Running the example
To test the example:
1. Prepare two boards with the flashed `CLI Example` (as shown above). The CLI FTD example uses the direct UART connection.
2. Open a terminal connection on two boards:
a. Start a terminal emulator like screen.
b. Connect to the used COM port with the following direct UART settings:
- Baud rate: 115200
- 8 data bits
- 1 stop bit
- No parity
- HW flow control: RTS/CTS This allows you to view the raw UART output.
On Linux system a port name should be called e.g. `/dev/ttyACM0` or `/dev/ttyACM1`.
c. Run the following command to connect to a board.
```shell
screen /dev/ttyACM0 115200
```
Now you are connected with the CLI.
3. Use the following commands to form a network on the first board.
```bash
> dataset init new
Done
> dataset
Active Timestamp: 1
Channel: 13
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
Security Policy: 0, onrcb
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done
```
After a couple of seconds the node will become a Leader of the network.
```bash
> state
leader
```
4. Use the following commands to attach to the network on the second board.
```bash
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done
```
After a couple of seconds the second node will attach and become a Child.
```bash
> state
child
```
5. List all IPv6 addresses of the first board.
```bash
> ipaddr
fd3d:b50b:f96d:722d:0:ff:fe00:fc00
fd3d:b50b:f96d:722d:0:ff:fe00:c00
fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
fe80:0:0:0:6c41:9001:f3d6:4148
Done
```
6. Choose one of them and send an ICMPv6 ping from the second board.
```bash
> ping fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
16 bytes from fd3d:b50b:f96d:722d:558:f56b:d688:799: icmp_seq=1 hlim=64 time=24ms
```
For a list of all available commands, visit [OpenThread CLI Reference README.md][cli].
[cli]: ./../../../src/cli/README.md
## SEGGER J-Link tools
SEGGER J-Link tools allow to debug and flash generated firmware using on-board debugger or external one.
### Working with RTT logging
By default, the OpenThread's logging module provides functions to output logging information over SEGGER's Real Time Transfer (RTT).
You can set the desired log level by using the `OPENTHREAD_CONFIG_LOG_LEVEL` define.
To enable the highest verbosity level, append `FULL_LOGS` flag to the `make` command:
```
$ make -f examples/Makefile-nrf52840 FULL_LOGS=1
```
#### Enable logging on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link RTT Viewer`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52840_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
#### Enable logging on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52840_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID> -RTTTelnetPort 19021
```
3. Run `JLinkRTTTelnet` to obtain the RTT logs from the connected device in a separate console. For example:
```
JLinkRTTClient -RTTTelnetPort 19021
```
### Mass Storage Device known issue
Depending on your version, due to a known issue in SEGGER's J-Link firmware, you might experience data corruption or data drops if you use the serial port. You can avoid this issue by disabling the Mass Storage Device.
#### Disabling the Mass Storage Device on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link Commander`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52840_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
5. Run the following command:
```
MSDDisable
```
6. Power cycle the DK.
#### Disabling the Mass Storage Device on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52840_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID>
```
3. Run the following command:
```
MSDDisable
```
4. Power cycle the DK.
### Hardware Flow Control detection
By default, SEGGER J-Link automatically detects at runtime whether the target is using Hardware Flow Control (HWFC).
The automatic HWFC detection is done by driving P0.07 (Clear to Send - CTS) from the interface MCU and evaluating the state of P0.05 (Request to Send - RTS) when the first data is sent or received. If the state of P0.05 (RTS) is high, it is assumed that HWFC is not used.
To avoid potential race conditions, you can force HWFC and bypass the runtime auto-detection.
#### Disabling the HWFC detection on Windows
1. Connect the DK to your machine with a USB cable.
2. Run `J-Link Commander`. The configuration window appears.
3. From the Specify Target Device dropdown menu, select `NRF52840_XXAA`.
4. From the Target Interface & Speed dropdown menu, select `SWD`.
5. Run the following command:
```
SetHWFC Force
```
6. Power cycle the DK.
#### Disabling the HWFC detection on Linux
1. Connect the DK to your machine with a USB cable.
2. Run `JLinkExe` to connect to the target. For example:
```
JLinkExe -device NRF52840_XXAA -if SWD -speed 4000 -autoconnect 1 -SelectEmuBySN <SEGGER_ID>
```
3. Run the following command:
```
SetHWFC Force
```
4. Power cycle the DK.
You can find more details [here][j-link-ob].
[j-link-ob]: https://wiki.segger.com/J-Link_OB_SAM3U_NordicSemi#Hardware_flow_control_support
## Diagnostic module
nRF52840 port extends [OpenThread Diagnostics Module][diag].
You can read about all the features [here][nrfdiag].
[diag]: ./../../../src/core/diags/README.md
[nrfdiag]: ./../DIAG.md
## Radio driver documentation
The radio driver comes with documentation that describes the operation of state machines in this module. To open the `*.uml` sequence diagrams, use [PlantUML][plantuml-url].
[plantuml-url]: http://plantuml.com/
## Verification
The following development kits have been used for testing and verification:
- PCA10056 1.0.0
- PCA10059 1.0.0
- PCA10068 0.5.0
The following toolchains have been used for testing and verification:
- GCC: GCC ARM Embedded 7.2018 q2 update
- IAR: IAR Workbench 7.80.4
- SES: SES 4.12
- ARM: MDK-ARM version 5.25
The following OpenThread commits have been verified with nRF52840 and nRF52811 examples by Nordic Semiconductor:
- `2279ef6` - 23.05.2019 (the latest checked)
- `23ff101` - 22.03.2019
- `704511c` - 18.09.2018
- `ec59d7e` - 06.04.2018
- `a89eb88` - 16.11.2017
- `6a15261` - 29.06.2017
- `030efba` - 22.04.2017
- `de48acf` - 02.03.2017
- `50db58d` - 23.01.2017
# Nordic Semiconductor's nRF5 SDK for Thread and Zigbee
Use [nRF5 Software Development Kit (SDK) for Thread and Zigbee][nrf5-sdk-thread-zigbee] when developing Thread products with Nordic Semiconductor's advanced nRF52840, nRF52833 or nRF52811 SoCs.
The <i>nRF5 SDK for Thread and Zigbee</i> includes:
- a pre-built OpenThread stack for the Nordic nRF52840 and nRF52811 SoCs,
- support for hardware-accelerated cryptographic operations using ARM® CryptoCell-310,
- unique Thread/Bluetooth Low Energy dynamic multiprotocol solution which allows for concurrent operation of Thread and Bluetooth Low Energy utilizing OpenThread and SoftDevice (Nordics Bluetooth Low Energy stack) with accompanying example applications,
- Thread/Bluetooth Low Energy switched multiprotocol solution with accompanying example applications,
- unique support for DFU-over-Thread (Device Firmware Upgrade),
- examples to demonstrate interactions between nodes performing different Thread roles with the use of OpenThread and CoAP, CoAP Secure or MQTT-SN protocols,
- support for OpenThread Network Co-Processor (NCP) and Radio Co-Processor (RCP) using UART, USB or SPI transport protocol,
- Border Router and cloud connectivity example (e.g. with Google Cloud Platform),
- Thread native commissioning with NFC example,
- example applications demonstrating the use of FreeRTOS with OpenThread,
- support for IAR, Keil MDK-ARM and SEGGER Embedded Studio (SES) IDEs for OpenThread stack and all example applications,
- range of PC tools including Thread Topology Monitor and nRF Sniffer for 802.15.4,
- software modules inherited from the nRF5 SDK e.g. peripheral drivers, NFC libraries, Bluetooth Low Energy libraries etc.
[nrf5-sdk-thread-zigbee]: https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK-for-Thread-and-Zigbee
The OpenThread on nRF528xx example has moved to https://github.com/openthread/ot-nrf528xx
@@ -1,56 +0,0 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# 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.
#
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
set(CMAKE_RANLIB arm-none-eabi-ranlib)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs -fdata-sections -ffunction-sections")
if(COMPILER_VERSION VERSION_GREATER_EQUAL 7)
set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -Wno-expansion-to-defined")
endif()
set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti")
set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS} -x assembler-with-cpp")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs")
set(CMAKE_C_FLAGS_DEBUG "-Og -g")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
set(CMAKE_ASM_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_ASM_FLAGS_RELEASE "")
@@ -1,227 +0,0 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# 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.
#
set(OT_PLATFORM_LIB "openthread-nrf52840" "openthread-nrf52840-transport" PARENT_SCOPE)
if(NOT OT_CONFIG)
set(OT_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/nrf52840/openthread-core-nrf52840-config.h")
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
endif()
option(OT_BOOTLOADER "OT nrf bootloader type")
if(OT_BOOTLOADER STREQUAL "USB")
list(APPEND OT_PLATFORM_DEFINES "APP_USBD_NRF_DFU_TRIGGER_ENABLED=1")
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52840/nrf52840_bootloader_usb.ld")
elseif(OT_BOOTLOADER STREQUAL "UART")
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52840/nrf52840_bootloader_uart.ld")
elseif(OT_BOOTLOADER STREQUAL "BLE")
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52840/nrf52840_bootloader_ble.ld")
else()
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52840/nrf52840.ld")
endif()
list(APPEND OT_PLATFORM_DEFINES
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-nrf52840-config-check.h\""
)
if(NOT OT_EXTERNAL_MBEDTLS)
if(OT_MBEDTLS_THREADING)
list(APPEND OT_PLATFORM_DEFINES "MBEDTLS_THREADING_C")
list(APPEND OT_PLATFORM_DEFINES "MBEDTLS_THREADING_ALT")
list(APPEND OT_PUBLIC_INCLUDES
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/include/software-only-threading"
)
endif()
else()
list(APPEND OT_PLATFORM_DEFINES "MBEDTLS_CONFIG_FILE=\"nrf-config.h\"")
list(APPEND OT_PUBLIC_INCLUDES
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/include"
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/config"
"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/nrf_cc310_plat/include"
)
endif()
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
target_compile_definitions(ot-config INTERFACE
"MBEDTLS_USER_CONFIG_FILE=\"nrf52840-mbedtls-config.h\""
)
list(APPEND OT_PUBLIC_INCLUDES "${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config")
set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE)
set(COMM_FLAGS
-DCONFIG_GPIO_AS_PINRESET
-DNRF52840_XXAA
-DUSE_APP_CONFIG=1
-Wno-unused-parameter
-Wno-expansion-to-defined
)
if(OT_CFLAGS MATCHES "-pedantic-errors")
string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}")
endif()
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
add_library(openthread-nrf52840
${NRF_COMM_SOURCES}
${NRF_SINGLEPHY_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
add_library(openthread-nrf52840-transport
${NRF_TRANSPORT_SOURCES}
)
add_library(openthread-nrf52840-sdk
${NRF_COMM_SOURCES}
${NRF_SINGLEPHY_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
add_library(openthread-nrf52840-softdevice-sdk
${NRF_COMM_SOURCES}
${NRF_SOFTDEVICE_SOURCES}
$<TARGET_OBJECTS:openthread-platform-utils>
)
target_link_libraries(openthread-nrf52840
PUBLIC
${OT_MBEDTLS}
${NRF52840_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_link_libraries(openthread-nrf52840-transport
PUBLIC
${OT_MBEDTLS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
nordicsemi-nrf52840-sdk
ot-config
)
target_link_libraries(openthread-nrf52840-sdk
PUBLIC
${OT_MBEDTLS}
${NRF52840_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_link_libraries(openthread-nrf52840-softdevice-sdk
PUBLIC
${OT_MBEDTLS}
${NRF52840_3RD_LIBS}
-T${LD_FILE}
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
PRIVATE
ot-config
)
target_compile_definitions(openthread-nrf52840
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52840-transport
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52840-sdk
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_definitions(openthread-nrf52840-softdevice-sdk
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_options(openthread-nrf52840
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
-DPLATFORM_OPENTHREAD_VANILLA
)
target_compile_options(openthread-nrf52840-transport
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
-DPLATFORM_OPENTHREAD_VANILLA
)
target_compile_options(openthread-nrf52840-sdk
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
)
target_compile_options(openthread-nrf52840-softdevice-sdk
PRIVATE
${OT_CFLAGS}
${COMM_FLAGS}
-DSOFTDEVICE_PRESENT
-DS140
)
target_include_directories(openthread-nrf52840
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52840
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52840-transport
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52840
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52840-sdk
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52840
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
target_include_directories(openthread-nrf52840-softdevice-sdk
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/nrf52840
${NRF_INCLUDES}
${OT_PUBLIC_INCLUDES}
)
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52840.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 4;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52840 with BLE bootloader.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00026000, LENGTH = 0xd2000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 4;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52840 with UART bootloader.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 0xf7000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 4;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,168 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* GCC linker script for nRF52840 with USB bootloader.
*/
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 0xdf000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8
}
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
ENTRY(Reset_Handler)
FLASH_PAGE_SIZE = 4096;
FLASH_DATA_PAGES_USED = 4;
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
__stop_ot_flash_data = (ORIGIN(FLASH) + LENGTH(FLASH));
__start_ot_flash_data = (__stop_ot_flash_data - (FLASH_PAGE_SIZE * FLASH_DATA_PAGES_USED));
/* Assure that code does not overlap flash data area.*/
ASSERT((__start_ot_flash_data >= __etext + SIZEOF(.data)), "Error: Code overlaps flash data area.")
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -1,36 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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 OPENTHREAD_CORE_NRF52840_CONFIG_CHECK_H_
#define OPENTHREAD_CORE_NRF52840_CONFIG_CHECK_H_
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
#error "Platform nrf52840 doesn't support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
#endif
#endif /* OPENTHREAD_CORE_NRF52840_CONFIG_CHECK_H_ */
@@ -1,320 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes nrf52840 compile-time configuration constants
* for OpenThread.
*/
#ifndef OPENTHREAD_CORE_NRF52840_CONFIG_H_
#define OPENTHREAD_CORE_NRF52840_CONFIG_H_
/*
* The GNU Autoconf system defines a PACKAGE macro which is the name
* of the software package. This name collides with PACKAGE field in
* the nRF52 Factory Information Configuration Registers (FICR)
* structure.
*/
#undef PACKAGE
/**
* @def OPENTHREAD_CONFIG_LOG_OUTPUT
*
* The nrf52840 platform provides an otPlatLog() function.
*/
#ifndef OPENTHREAD_CONFIG_LOG_OUTPUT
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_INFO
*
* The platform-specific string to insert into the OpenThread version string.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_INFO
#define OPENTHREAD_CONFIG_PLATFORM_INFO "NRF52840"
#endif
/**
* @def OPENTHREAD_CONFIG_STACK_VENDOR_OUI
*
* The Organizationally Unique Identifier for the vendor.
*
*/
#ifndef OPENTHREAD_CONFIG_STACK_VENDOR_OUI
#define OPENTHREAD_CONFIG_STACK_VENDOR_OUI 0xf4ce36
#endif
/**
* @def OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
*
* The maximum number of children.
*
*/
#ifndef OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#define OPENTHREAD_CONFIG_MLE_MAX_CHILDREN 32
#endif
/**
* @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
*
* The number of message buffers in the buffer pool.
*
*/
#ifndef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 160
#endif
/**
* @def OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD
*
* The maximum number of supported IPv6 address registrations per child.
*
*/
#ifndef OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD
#define OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD 6
#endif
/**
* @def OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
*
* The maximum number of state-changed callback handlers (set using `otSetStateChangedCallback()`).
*
*/
#ifndef OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
#endif
/**
* @def OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
*
* The number of EID-to-RLOC cache entries.
*
*/
#ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
#define OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES 32
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_PREPREND_LEVEL
*
* Define to prepend the log level to all log messages
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
*
* Define to 1 if you want to enable software ACK timeout logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
*
* Define to 1 if you want to enable software retransmission logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
*
* Define to 1 if you want to enable software CSMA-CA backoff logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
*
* Define to 1 if you want to enable software transmission security logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE
*
* Define to 1 to enable software transmission target time logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE
*
* Define to 1 to enable software reception target time logic.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
*
* Define to 1 if you want to support microsecond timer in platform.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
*
* Define to 1 to enable otPlatFlash* APIs to support non-volatile storage.
*
* When defined to 1, the platform MUST implement the otPlatFlash* APIs instead of the otPlatSettings* APIs.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE
*
* The size of heap buffer when DTLS is enabled.
*
*/
#ifndef OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE
#define OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE (4096 * sizeof(void *))
#endif
/**
* @def OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE_NO_DTLS
*
* The size of heap buffer when DTLS is disabled.
*
*/
#ifndef OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE_NO_DTLS
#define OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE_NO_DTLS 4000
#endif
/**
* @def OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
*
* Define as 1 to enable the time synchronization service feature.
*
*/
#ifndef OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_CLI_TX_BUFFER_SIZE
*
* The size of CLI message buffer in bytes
*
*/
#ifndef OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE
#define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 2048
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
*
* Define as 1 to support IEEE 802.15.4-2015 Header IE (Information Element) generation and parsing, it must be set
* to support following features:
* 1. Time synchronization service feature (i.e., OPENTHREAD_CONFIG_TIME_SYNC_ENABLE is set).
*
* @note If it's enabled, plaforms must support interrupt context and concurrent access AES.
*
*/
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#define OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT 1
#endif
/**
* @def RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
*
* The number of short source address table entries.
*
*/
#ifndef RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
#define RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM 0
#endif
/**
* @def RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
*
* The number of extended source address table entries.
*
*/
#ifndef RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
#define RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM 0
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
*
* Reception scheduling and ramp up time needed for the CSL receiver to be ready, in units of microseconds.
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 2000
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON
*
* The minimum CSL receive window (in microseconds) required to receive an IEEE 802.15.4 frame.
* - Frame preamble: 6*2 symbols + margin
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON
#define OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 12 * 16
#endif
/*
* Suppress the ARMCC warning on unreachable statement,
* e.g. break after assert(false) or ExitNow() macro.
*/
#if defined(__CC_ARM)
_Pragma("diag_suppress=111") _Pragma("diag_suppress=128")
#endif
#endif // OPENTHREAD_CORE_NRF52840_CONFIG_H_
@@ -1,215 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the platform-specific configuration.
*
*/
#ifndef PLATFORM_CONFIG_H_
#define PLATFORM_CONFIG_H_
#include "nrf.h"
#include "nrf_drv_clock.h"
#include "nrf_peripherals.h"
#include "hal/nrf_radio.h"
#include "openthread-core-config.h"
#include <openthread/config.h>
/*******************************************************************************
* @section Alarm Driver Configuration.
******************************************************************************/
/**
* @def RTC_INSTANCE
*
* RTC Instance.
*
*/
#ifndef RTC_INSTANCE
#define RTC_INSTANCE NRF_RTC2
#endif
/**
* @def RTC_IRQ_HANDLER
*
* RTC interrupt handler name
*
*/
#ifndef RTC_IRQ_HANDLER
#define RTC_IRQ_HANDLER RTC2_IRQHandler
#endif
/**
* @def RTC_IRQN
*
* RTC Interrupt number.
*
*/
#ifndef RTC_IRQN
#define RTC_IRQN RTC2_IRQn
#endif
/**
* @def RTC_IRQ_PRIORITY
*
* RTC Interrupt priority.
*
*/
#ifndef RTC_IRQ_PRIORITY
#define RTC_IRQ_PRIORITY 6
#endif
/*******************************************************************************
* @section Random Number Generator Driver Configuration.
******************************************************************************/
/**
* @def RNG_BUFFER_SIZE
*
* True Random Number Generator buffer size.
*
*/
#ifndef RNG_BUFFER_SIZE
#define RNG_BUFFER_SIZE 128
#endif
/**
* @def RNG_IRQ_PRIORITY
*
* RNG Interrupt priority.
*
*/
#ifndef RNG_IRQ_PRIORITY
#define RNG_IRQ_PRIORITY 6
#endif
/*******************************************************************************
* @section Platform Flash Configuration
******************************************************************************/
/**
* @def PLATFORM_FLASH_PAGE_NUM
*
* Number of flash pages to use for OpenThread's non-volatile settings.
*
* @note This define applies only for MDK-ARM Keil toolchain configuration.
*
*/
#ifndef PLATFORM_FLASH_PAGE_NUM
#define PLATFORM_FLASH_PAGE_NUM 4
#endif
/*******************************************************************************
* @section Platform FEM Configuration
******************************************************************************/
/**
* @def PLATFORM_FEM_ENABLE_DEFAULT_CONFIG
*
* Enable default front end module configuration.
*
*/
#ifndef PLATFORM_FEM_ENABLE_DEFAULT_CONFIG
#define PLATFORM_FEM_ENABLE_DEFAULT_CONFIG 0
#endif
/*******************************************************************************
* @section Radio driver configuration.
******************************************************************************/
/**
* @def NRF_802154_PENDING_SHORT_ADDRESSES
*
* Number of slots containing short addresses of nodes for which pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_SHORT_ADDRESSES
#define NRF_802154_PENDING_SHORT_ADDRESSES OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#endif
/**
* @def NRF_802154_PENDING_EXTENDED_ADDRESSES
*
* Number of slots containing extended addresses of nodes for which pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_EXTENDED_ADDRESSES
#define NRF_802154_PENDING_EXTENDED_ADDRESSES OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#endif
/**
* @def NRF_802154_CSMA_CA_ENABLED
*
* If CSMA-CA procedure should be enabled by the driver. Disabling CSMA-CA procedure improves
* driver performance.
*
*/
#ifndef NRF_802154_CSMA_CA_ENABLED
#define NRF_802154_CSMA_CA_ENABLED 1
#endif
/**
* @def NRF_802154_ACK_TIMEOUT_ENABLED
*
* If ACK timeout feature should be enabled in the driver.
*
*/
#ifndef NRF_802154_ACK_TIMEOUT_ENABLED
#define NRF_802154_ACK_TIMEOUT_ENABLED 1
#endif
/*******************************************************************************
* @section Temperature sensor driver configuration.
******************************************************************************/
/**
* @def TEMP_MEASUREMENT_INTERVAL
*
* Interval of consecutive temperature measurements [s].
*
*/
#ifndef TEMP_MEASUREMENT_INTERVAL
#define TEMP_MEASUREMENT_INTERVAL 30
#endif
/**
* @def NRF_802154_TX_STARTED_NOTIFY_ENABLED
*
* If notification of started transmission should be enabled in the driver.
*
* @note This feature must be enabled to support Header IE related features.
*
*/
#ifndef NRF_802154_TX_STARTED_NOTIFY_ENABLED
#define NRF_802154_TX_STARTED_NOTIFY_ENABLED 1
#endif
#endif // PLATFORM_CONFIG_H_
@@ -1,309 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the transport-specific configuration.
*
*/
#ifndef TRANSPORT_CONFIG_H_
#define TRANSPORT_CONFIG_H_
#include "nrf.h"
#include "hal/nrf_spis.h"
#include "hal/nrf_uart.h"
/*******************************************************************************
* @section UART Driver Configuration.
******************************************************************************/
/**
* @def UART_INSTANCE
*
* UART Instance.
*
*/
#ifndef UART_INSTANCE
#define UART_INSTANCE NRF_UARTE0
#endif
/**
* @def UART_PARITY
*
* UART Parity configuration.
*
* @brief Possible values:
* \ref NRF_UARTE_PARITY_EXCLUDED - Parity bit is not present.
* \ref NRF_UARTE_PARITY_INCLUDED - Parity bit is present.
*
*/
#ifndef UART_PARITY
#define UART_PARITY NRF_UARTE_PARITY_EXCLUDED
#endif
/**
* @def UART_HWFC_ENABLED
*
* Enable UART Hardware Flow Control.
*
*/
#ifndef UART_HWFC_ENABLED
#define UART_HWFC_ENABLED 1
#endif
/**
* @def UART_BAUDRATE
*
* UART Baudrate.
*
* @brief Possible values:
* \ref NRF_UARTE_BAUDRATE_1200 - 1200 baud.
* \ref NRF_UARTE_BAUDRATE_2400 - 2400 baud.
* \ref NRF_UARTE_BAUDRATE_4800 - 4800 baud.
* \ref NRF_UARTE_BAUDRATE_9600 - 9600 baud.
* \ref NRF_UARTE_BAUDRATE_14400 - 14400 baud.
* \ref NRF_UARTE_BAUDRATE_19200 - 19200 baud.
* \ref NRF_UARTE_BAUDRATE_28800 - 28800 baud.
* \ref NRF_UARTE_BAUDRATE_38400 - 38400 baud.
* \ref NRF_UARTE_BAUDRATE_57600 - 57600 baud.
* \ref NRF_UARTE_BAUDRATE_76800 - 76800 baud.
* \ref NRF_UARTE_BAUDRATE_115200 - 115200 baud.
* \ref NRF_UARTE_BAUDRATE_230400 - 230400 baud.
* \ref NRF_UARTE_BAUDRATE_250000 - 250000 baud.
* \ref NRF_UARTE_BAUDRATE_460800 - 460800 baud.
* \ref NRF_UARTE_BAUDRATE_921600 - 921600 baud.
* \ref NRF_UARTE_BAUDRATE_1000000 - 1000000 baud.
*
*/
#ifndef UART_BAUDRATE
#define UART_BAUDRATE NRF_UARTE_BAUDRATE_115200
#endif
/**
* @def UART_IRQN
*
* UART Interrupt number.
*
*/
#ifndef UART_IRQN
#define UART_IRQN UARTE0_UART0_IRQn
#endif
/**
* @def UART_IRQ_PRIORITY
*
* UART Interrupt priority.
*
*/
#ifndef UART_IRQ_PRIORITY
#define UART_IRQ_PRIORITY 6
#endif
/**
* @def UART_RX_BUFFER_SIZE
*
* UART Receive buffer size.
*
*/
#ifndef UART_RX_BUFFER_SIZE
#define UART_RX_BUFFER_SIZE 512
#endif
/**
* @def UART_PIN_TX
*
* UART TX Pin.
*
*/
#ifndef UART_PIN_TX
#define UART_PIN_TX 6
#endif
/**
* @def UART_PIN_RX
*
* UART RX Pin.
*
*/
#ifndef UART_PIN_RX
#define UART_PIN_RX 8
#endif
/**
* @def UART_PIN_CTS
*
* UART CTS Pin.
*
*/
#ifndef UART_PIN_CTS
#define UART_PIN_CTS 7
#endif
/**
* @def UART_PIN_RTS
*
* UART RTS Pin.
*
*/
#ifndef UART_PIN_RTS
#define UART_PIN_RTS 5
#endif
/*******************************************************************************
* @section SPI Slave configuration.
******************************************************************************/
/**
* @def SPIS Instance.
*/
#ifndef SPIS_INSTANCE
#define SPIS_INSTANCE 0
#endif
/**
* @def SPIS mode.
*
* @brief Possible values:
* \ref NRF_SPIS_MODE_0 - SCK active high, sample on leading edge of clock.
* \ref NRF_SPIS_MODE_1 - SCK active high, sample on trailing edge of clock.
* \ref NRF_SPIS_MODE_2 - SCK active low, sample on leading edge of clock.
* \ref NRF_SPIS_MODE_3 - SCK active low, sample on trailing edge of clock.
*/
#ifndef SPIS_MODE
#define SPIS_MODE NRF_SPIS_MODE_0
#endif
/**
* @def SPIS bit orders.
*
* @brief Possible values:
* \ref NRF_SPIS_BIT_ORDER_MSB_FIRST - Most significant bit shifted out first.
* \ref NRF_SPIS_BIT_ORDER_LSB_FIRST - Least significant bit shifted out first.
*/
#ifndef SPIS_BIT_ORDER
#define SPIS_BIT_ORDER NRF_SPIS_BIT_ORDER_MSB_FIRST
#endif
/**
* @def SPIS Interrupt priority.
*/
#ifndef SPIS_IRQ_PRIORITY
#define SPIS_IRQ_PRIORITY 6
#endif
/**
* @def SPIS MOSI Pin.
*/
#ifndef SPIS_PIN_MOSI
#define SPIS_PIN_MOSI 4
#endif
/**
* @def SPIS MISO Pin.
*/
#ifndef SPIS_PIN_MISO
#define SPIS_PIN_MISO 28
#endif
/**
* @def SPIS SCK Pin.
*/
#ifndef SPIS_PIN_SCK
#define SPIS_PIN_SCK 3
#endif
/**
* @def SPIS CSN Pin.
*/
#ifndef SPIS_PIN_CSN
#define SPIS_PIN_CSN 29
#endif
/**
* @def SPIS Host IRQ Pin.
*/
#ifndef SPIS_PIN_HOST_IRQ
#define SPIS_PIN_HOST_IRQ 30
#endif
/*******************************************************************************
* @section USB driver configuration.
******************************************************************************/
/**
* @def USB_HOST_UART_CONFIG_DELAY_MS
*
* Delay after DTR gets asserted that we start send any queued data. This allows slow
* Linux-based hosts to have enough time to configure their port for raw mode.
*
*/
#ifndef USB_HOST_UART_CONFIG_DELAY_MS
#define USB_HOST_UART_CONFIG_DELAY_MS 10
#endif
/**
* @def USB_CDC_AS_SERIAL_TRANSPORT
*
* Use USB CDC driver for serial communication.
*/
#ifndef USB_CDC_AS_SERIAL_TRANSPORT
#define USB_CDC_AS_SERIAL_TRANSPORT 0
#endif
/**
* @def The USB interface to use for CDC ACM COMM.
*
* According to the USB Specification, interface numbers cannot have gaps. Tailor this value to adhere to this
* limitation. Takes values between 0-255.
*/
#ifndef USB_CDC_ACM_COMM_INTERFACE
#define USB_CDC_ACM_COMM_INTERFACE 1
#endif
/**
* @def The USB interface to use for CDC ACM DATA.
*
* According to the USB Specification, interface numbers cannot have gaps. Tailor this value to adhere to this
* limitation. Takes values between 0-255.
*/
#ifndef USB_CDC_ACM_DATA_INTERFACE
#define USB_CDC_ACM_DATA_INTERFACE 2
#endif
/**
* @def OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
*
* Reset the application, not the chip, when a software reset is requested.
* via `otPlatReset()`.
*/
#ifndef OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
#define OPENTHREAD_PLATFORM_USE_PSEUDO_RESET USB_CDC_AS_SERIAL_TRANSPORT
#endif
#endif // TRANSPORT_CONFIG_H_
-699
View File
@@ -1,699 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for the alarm.
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <openthread/platform/alarm-micro.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include <openthread/platform/time.h>
#include "openthread-system.h"
#include "platform-config.h"
#include "platform-nrf5.h"
#include <nrf_802154_lp_timer.h>
#include <nrf_802154_utils.h>
#include <nrf_drv_clock.h>
#include <hal/nrf_rtc.h>
#include <openthread/config.h>
// clang-format off
#define RTC_FREQUENCY NRF_802154_RTC_FREQUENCY
#define US_PER_MS 1000ULL
#define US_PER_S NRF_802154_US_PER_S
#define US_PER_OVERFLOW (512UL * NRF_802154_US_PER_S) ///< Time that has passed between overflow events. On full RTC speed, it occurs every 512 s.
#define RTC_COUNTER_BITS 24 ///< Number of bits in RTC COUNTER register.
#define MS_PER_S 1000UL
#define MIN_RTC_COMPARE_EVENT_TICKS 2 ///< Minimum number of RTC ticks delay that guarantees that RTC compare event will fire.
#define MIN_RTC_COMPARE_EVENT_DT (MIN_RTC_COMPARE_EVENT_TICKS * NRF_802154_US_PER_TICK) ///< Minimum time delta from now before RTC compare event is guaranteed to fire.
#define EPOCH_32BIT_US (1ULL << 32)
#define EPOCH_FROM_TIME(time) ((time) & ((uint64_t)UINT32_MAX << 32))
#define XTAL_ACCURACY 40 // The crystal used on nRF52840PDK has ±20ppm accuracy.
// clang-format on
typedef enum
{
kMsTimer,
kUsTimer,
k802154Timer,
k802154Sync,
kNumTimers
} AlarmIndex;
typedef struct
{
volatile bool mFireAlarm; ///< Information for processing function, that alarm should fire.
uint64_t mTargetTime; ///< Alarm fire time (in millisecond for MsTimer, in microsecond for UsTimer)
} AlarmData;
typedef struct
{
uint32_t mChannelNumber;
uint32_t mCompareEventMask;
nrf_rtc_event_t mCompareEvent;
nrf_rtc_int_t mCompareInt;
} AlarmChannelData;
static volatile uint32_t sOverflowCounter; ///< Counter of RTC overflowCounter, incremented by 2 on each OVERFLOW event.
static volatile uint8_t sMutex; ///< Mutex for write access to @ref sOverflowCounter.
static volatile uint64_t sTimeOffset = 0; ///< Time overflowCounter to keep track of current time (in millisecond).
static volatile bool sEventPending; ///< Timer fired and upper layer should be notified.
static AlarmData sTimerData[kNumTimers]; ///< Data of the timers.
static const AlarmChannelData sChannelData[kNumTimers] = //
{ //
[kMsTimer] =
{
.mChannelNumber = 0,
.mCompareEventMask = RTC_EVTEN_COMPARE0_Msk,
.mCompareEvent = NRF_RTC_EVENT_COMPARE_0,
.mCompareInt = NRF_RTC_INT_COMPARE0_MASK,
},
[kUsTimer] =
{
.mChannelNumber = 1,
.mCompareEventMask = RTC_EVTEN_COMPARE1_Msk,
.mCompareEvent = NRF_RTC_EVENT_COMPARE_1,
.mCompareInt = NRF_RTC_INT_COMPARE1_MASK,
},
[k802154Timer] =
{
.mChannelNumber = 2,
.mCompareEventMask = RTC_EVTEN_COMPARE2_Msk,
.mCompareEvent = NRF_RTC_EVENT_COMPARE_2,
.mCompareInt = NRF_RTC_INT_COMPARE2_MASK,
},
[k802154Sync] = {
.mChannelNumber = 3,
.mCompareEventMask = RTC_EVTEN_COMPARE3_Msk,
.mCompareEvent = NRF_RTC_EVENT_COMPARE_3,
.mCompareInt = NRF_RTC_INT_COMPARE3_MASK,
}};
static inline bool MutexGet(void)
{
do
{
volatile uint8_t mutexValue = __LDREXB(&sMutex);
if (mutexValue)
{
__CLREX();
return false;
}
} while (__STREXB(1, &sMutex));
// Disable OVERFLOW interrupt to prevent lock-up in interrupt context while mutex is locked from lower priority
// context and OVERFLOW event flag is stil up.
nrf_rtc_int_disable(RTC_INSTANCE, NRF_RTC_INT_OVERFLOW_MASK);
__DMB();
return true;
}
static inline void MutexRelease(void)
{
// Re-enable OVERFLOW interrupt.
nrf_rtc_int_enable(RTC_INSTANCE, NRF_RTC_INT_OVERFLOW_MASK);
__DMB();
sMutex = 0;
}
static inline uint64_t TimeToTicks(uint64_t aTime, AlarmIndex aIndex)
{
if (aIndex == kMsTimer)
{
aTime *= US_PER_MS;
}
return NRF_802154_US_TO_RTC_TICKS(aTime);
}
static inline uint64_t TicksToTime(uint64_t aTicks, AlarmIndex aIndex)
{
uint64_t result = NRF_802154_RTC_TICKS_TO_US(aTicks);
if (aIndex == kMsTimer)
{
result /= US_PER_MS;
}
return result;
}
static inline bool AlarmShallStrike(uint64_t aNow, AlarmIndex aIndex)
{
return aNow >= sTimerData[aIndex].mTargetTime;
}
static uint32_t GetOverflowCounter(void)
{
uint32_t overflowCounter;
// Get mutual access for writing to sOverflowCounter variable.
if (MutexGet())
{
bool increasing = false;
// Check if interrupt was handled already.
if (nrf_rtc_event_pending(RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW))
{
sOverflowCounter++;
increasing = true;
__DMB();
// Mark that interrupt was handled.
nrf_rtc_event_clear(RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW);
// Result should be incremented. sOverflowCounter will be incremented after mutex is released.
}
else
{
// Either overflow handling is not needed OR we acquired the mutex just after it was released.
// Overflow is handled after mutex is released, but it cannot be assured that sOverflowCounter
// was incremented for the second time, so we increment the result here.
}
overflowCounter = (sOverflowCounter + 1) / 2;
MutexRelease();
if (increasing)
{
// It's virtually impossible that overflow event is pending again before next instruction is performed. It
// is an error condition.
assert(sOverflowCounter & 0x01);
// Increment the counter for the second time, to allow instructions from other context get correct value of
// the counter.
sOverflowCounter++;
}
}
else
{
// Failed to acquire mutex.
if (nrf_rtc_event_pending(RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW) || (sOverflowCounter & 0x01))
{
// Lower priority context is currently incrementing sOverflowCounter variable.
overflowCounter = (sOverflowCounter + 2) / 2;
}
else
{
// Lower priority context has already incremented sOverflowCounter variable or incrementing is not needed
// now.
overflowCounter = sOverflowCounter / 2;
}
}
return overflowCounter;
}
static uint32_t GetRtcCounter(void)
{
return nrf_rtc_counter_get(RTC_INSTANCE);
}
static void GetOffsetAndCounter(uint32_t *aOffset, uint32_t *aCounter)
{
uint32_t offset1 = GetOverflowCounter();
__DMB();
uint32_t rtcValue1 = GetRtcCounter();
__DMB();
uint32_t offset2 = GetOverflowCounter();
*aOffset = offset2;
*aCounter = (offset1 == offset2) ? rtcValue1 : GetRtcCounter();
}
static uint64_t GetTime(uint32_t aOffset, uint32_t aCounter, AlarmIndex aIndex)
{
uint64_t result = (uint64_t)aOffset * US_PER_OVERFLOW + TicksToTime(aCounter, kUsTimer);
if (aIndex == kMsTimer)
{
result /= US_PER_MS;
}
return result;
}
static uint64_t GetCurrentTime(AlarmIndex aIndex)
{
uint32_t offset;
uint32_t rtc_counter;
GetOffsetAndCounter(&offset, &rtc_counter);
return GetTime(offset, rtc_counter, aIndex);
}
static void HandleCompareMatch(AlarmIndex aIndex, bool aSkipCheck)
{
nrf_rtc_event_clear(RTC_INSTANCE, sChannelData[aIndex].mCompareEvent);
uint64_t now = GetCurrentTime(aIndex);
// In case the target time was larger than single overflow,
// we should only strike the timer on final compare event.
if (aSkipCheck || AlarmShallStrike(now, aIndex))
{
nrf_rtc_event_disable(RTC_INSTANCE, sChannelData[aIndex].mCompareEventMask);
nrf_rtc_int_disable(RTC_INSTANCE, sChannelData[aIndex].mCompareInt);
switch (aIndex)
{
case k802154Timer:
nrf_802154_lp_timer_fired();
break;
case k802154Sync:
nrf_802154_lp_timer_synchronized();
break;
case kMsTimer:
case kUsTimer:
sTimerData[aIndex].mFireAlarm = true;
sEventPending = true;
otSysEventSignalPending();
break;
default:
assert(false);
}
}
}
static uint64_t ConvertT0AndDtTo64BitTime(uint32_t aT0, uint32_t aDt, const uint64_t *aNow)
{
uint64_t now;
now = *aNow;
if (((uint32_t)now < aT0) && ((aT0 - (uint32_t)now) > (UINT32_MAX / 2)))
{
now -= EPOCH_32BIT_US;
}
else if (((uint32_t)now > aT0) && (((uint32_t)now) - aT0 > (UINT32_MAX / 2)))
{
now += EPOCH_32BIT_US;
}
return (EPOCH_FROM_TIME(now)) + aT0 + aDt;
}
static uint64_t RoundUpTimeToTimerTicksMultiply(uint64_t aTime, AlarmIndex aIndex)
{
uint64_t ticks = TimeToTicks(aTime, aIndex);
uint64_t result = TicksToTime(ticks, aIndex);
return result;
}
static void TimerStartAt(uint32_t aT0, uint32_t aDt, AlarmIndex aIndex, const uint64_t *aNow)
{
uint64_t targetCounter;
uint64_t targetTime;
nrf_rtc_int_disable(RTC_INSTANCE, sChannelData[aIndex].mCompareInt);
nrf_rtc_event_enable(RTC_INSTANCE, sChannelData[aIndex].mCompareEventMask);
targetTime = ConvertT0AndDtTo64BitTime(aT0, aDt, aNow);
targetCounter = TimeToTicks(targetTime, aIndex) & RTC_CC_COMPARE_Msk;
sTimerData[aIndex].mTargetTime = RoundUpTimeToTimerTicksMultiply(targetTime, aIndex);
nrf_rtc_cc_set(RTC_INSTANCE, sChannelData[aIndex].mChannelNumber, targetCounter);
}
static void AlarmStartAt(uint32_t aT0, uint32_t aDt, AlarmIndex aIndex)
{
uint32_t offset;
uint32_t rtc_value;
uint64_t now;
uint64_t now_rtc_protected;
GetOffsetAndCounter(&offset, &rtc_value);
now = GetTime(offset, rtc_value, aIndex);
TimerStartAt(aT0, aDt, aIndex, &now);
if (rtc_value != GetRtcCounter())
{
GetOffsetAndCounter(&offset, &rtc_value);
}
now_rtc_protected = GetTime(offset, rtc_value + MIN_RTC_COMPARE_EVENT_TICKS, aIndex);
if (AlarmShallStrike(now_rtc_protected, aIndex))
{
HandleCompareMatch(aIndex, true);
/**
* Normally ISR sets event flag automatically.
* Here we are calling HandleCompareMatch explicitly and no ISR will be fired.
* To prevent possible permanent sleep on next WFE we have to set event flag.
*/
__SEV();
}
else
{
nrf_rtc_int_enable(RTC_INSTANCE, sChannelData[aIndex].mCompareInt);
}
}
static void TimerSyncStartAt(uint32_t aT0, uint32_t aDt, const uint64_t *aNow)
{
TimerStartAt(aT0, aDt, k802154Sync, aNow);
nrf_rtc_int_enable(RTC_INSTANCE, sChannelData[k802154Sync].mCompareInt);
}
static void AlarmStop(AlarmIndex aIndex)
{
nrf_rtc_event_disable(RTC_INSTANCE, sChannelData[aIndex].mCompareEventMask);
nrf_rtc_int_disable(RTC_INSTANCE, sChannelData[aIndex].mCompareInt);
nrf_rtc_event_clear(RTC_INSTANCE, sChannelData[aIndex].mCompareEvent);
sTimerData[aIndex].mFireAlarm = false;
}
void nrf5AlarmInit(void)
{
memset(sTimerData, 0, sizeof(sTimerData));
sOverflowCounter = 0;
sMutex = 0;
sTimeOffset = 0;
// Setup low frequency clock.
nrf_drv_clock_lfclk_request(NULL);
while (!nrf_drv_clock_lfclk_is_running())
{
}
// Setup RTC timer.
NVIC_SetPriority(RTC_IRQN, RTC_IRQ_PRIORITY);
NVIC_ClearPendingIRQ(RTC_IRQN);
NVIC_EnableIRQ(RTC_IRQN);
nrf_rtc_prescaler_set(RTC_INSTANCE, 0);
nrf_rtc_event_clear(RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW);
nrf_rtc_event_enable(RTC_INSTANCE, RTC_EVTEN_OVRFLW_Msk);
nrf_rtc_int_enable(RTC_INSTANCE, NRF_RTC_INT_OVERFLOW_MASK);
for (uint32_t i = 0; i < kNumTimers; i++)
{
nrf_rtc_event_clear(RTC_INSTANCE, sChannelData[i].mCompareEvent);
nrf_rtc_event_disable(RTC_INSTANCE, sChannelData[i].mCompareEventMask);
nrf_rtc_int_disable(RTC_INSTANCE, sChannelData[i].mCompareInt);
}
nrf_rtc_task_trigger(RTC_INSTANCE, NRF_RTC_TASK_START);
}
void nrf5AlarmDeinit(void)
{
nrf_rtc_task_trigger(RTC_INSTANCE, NRF_RTC_TASK_STOP);
for (uint32_t i = 0; i < kNumTimers; i++)
{
nrf_rtc_event_clear(RTC_INSTANCE, sChannelData[i].mCompareEvent);
nrf_rtc_event_disable(RTC_INSTANCE, sChannelData[i].mCompareEventMask);
nrf_rtc_int_disable(RTC_INSTANCE, sChannelData[i].mCompareInt);
}
nrf_rtc_int_disable(RTC_INSTANCE, NRF_RTC_INT_OVERFLOW_MASK);
nrf_rtc_event_disable(RTC_INSTANCE, RTC_EVTEN_OVRFLW_Msk);
nrf_rtc_event_clear(RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW);
nrf_802154_lp_timer_sync_stop();
NVIC_DisableIRQ(RTC_IRQN);
NVIC_ClearPendingIRQ(RTC_IRQN);
NVIC_SetPriority(RTC_IRQN, 0);
nrf_drv_clock_lfclk_release();
}
void nrf5AlarmProcess(otInstance *aInstance)
{
do
{
sEventPending = false;
if (sTimerData[kMsTimer].mFireAlarm)
{
sTimerData[kMsTimer].mFireAlarm = false;
#if OPENTHREAD_CONFIG_DIAG_ENABLE
if (otPlatDiagModeGet())
{
otPlatDiagAlarmFired(aInstance);
}
else
#endif
{
otPlatAlarmMilliFired(aInstance);
}
}
if (sTimerData[kUsTimer].mFireAlarm)
{
sTimerData[kUsTimer].mFireAlarm = false;
otPlatAlarmMicroFired(aInstance);
}
} while (sEventPending);
}
inline uint64_t nrf5AlarmGetCurrentTime(void)
{
return GetCurrentTime(kUsTimer);
}
uint64_t nrf5AlarmGetRawCounter(void)
{
uint32_t offset = 0;
uint32_t counter = 0;
GetOffsetAndCounter(&offset, &counter);
return (((uint64_t)offset) << RTC_COUNTER_BITS) | counter;
}
uint32_t otPlatAlarmMilliGetNow(void)
{
return (uint32_t)(nrf5AlarmGetCurrentTime() / US_PER_MS);
}
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
OT_UNUSED_VARIABLE(aInstance);
AlarmStartAt(aT0, aDt, kMsTimer);
}
void otPlatAlarmMilliStop(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
AlarmStop(kMsTimer);
}
uint32_t otPlatAlarmMicroGetNow(void)
{
return (uint32_t)nrf5AlarmGetCurrentTime();
}
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
OT_UNUSED_VARIABLE(aInstance);
AlarmStartAt(aT0, aDt, kUsTimer);
}
void otPlatAlarmMicroStop(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
AlarmStop(kUsTimer);
}
/**
* Radio driver timer abstraction API
*/
void nrf_802154_lp_timer_init(void)
{
// Intentionally empty
}
void nrf_802154_lp_timer_deinit(void)
{
// Intentionally empty
}
void nrf_802154_lp_timer_critical_section_enter(void)
{
nrf_rtc_int_disable(RTC_INSTANCE, sChannelData[k802154Timer].mCompareInt);
__DSB();
__ISB();
}
void nrf_802154_lp_timer_critical_section_exit(void)
{
nrf_rtc_int_enable(RTC_INSTANCE, sChannelData[k802154Timer].mCompareInt);
}
uint32_t nrf_802154_lp_timer_time_get(void)
{
return (uint32_t)nrf5AlarmGetCurrentTime();
}
uint32_t nrf_802154_lp_timer_granularity_get(void)
{
return NRF_802154_US_PER_TICK;
}
void nrf_802154_lp_timer_start(uint32_t t0, uint32_t dt)
{
AlarmStartAt(t0, dt, k802154Timer);
}
bool nrf_802154_lp_timer_is_running(void)
{
return nrf_rtc_int_is_enabled(RTC_INSTANCE, sChannelData[k802154Timer].mCompareInt);
}
void nrf_802154_lp_timer_stop(void)
{
AlarmStop(k802154Timer);
}
void nrf_802154_lp_timer_sync_start_now(void)
{
uint32_t counter;
uint32_t offset;
uint64_t now;
do
{
GetOffsetAndCounter(&offset, &counter);
now = GetTime(offset, counter, k802154Sync);
TimerSyncStartAt((uint32_t)now, MIN_RTC_COMPARE_EVENT_DT, &now);
} while (GetRtcCounter() != counter);
}
void nrf_802154_lp_timer_sync_start_at(uint32_t t0, uint32_t dt)
{
uint64_t now = GetCurrentTime(k802154Sync);
TimerSyncStartAt(t0, dt, &now);
}
void nrf_802154_lp_timer_sync_stop(void)
{
AlarmStop(k802154Sync);
}
uint32_t nrf_802154_lp_timer_sync_event_get(void)
{
return (uint32_t)nrf_rtc_event_address_get(RTC_INSTANCE, sChannelData[k802154Sync].mCompareEvent);
}
uint32_t nrf_802154_lp_timer_sync_time_get(void)
{
return (uint32_t)sTimerData[k802154Sync].mTargetTime;
}
/**
* RTC IRQ handler
*/
void RTC_IRQ_HANDLER(void)
{
// Handle overflow.
if (nrf_rtc_event_pending(RTC_INSTANCE, NRF_RTC_EVENT_OVERFLOW))
{
// Disable OVERFLOW interrupt to prevent lock-up in interrupt context while mutex is locked from lower priority
// context and OVERFLOW event flag is stil up. OVERFLOW interrupt will be re-enabled when mutex is released -
// either from this handler, or from lower priority context, that locked the mutex.
nrf_rtc_int_disable(RTC_INSTANCE, NRF_RTC_INT_OVERFLOW_MASK);
// Handle OVERFLOW event by reading current value of overflow counter.
(void)GetOverflowCounter();
}
// Handle compare match.
for (uint32_t i = 0; i < kNumTimers; i++)
{
if (nrf_rtc_int_is_enabled(RTC_INSTANCE, sChannelData[i].mCompareInt) &&
nrf_rtc_event_pending(RTC_INSTANCE, sChannelData[i].mCompareEvent))
{
HandleCompareMatch((AlarmIndex)i, false);
}
}
}
uint64_t otPlatTimeGet(void)
{
return nrf5AlarmGetCurrentTime();
}
uint16_t otPlatTimeGetXtalAccuracy(void)
{
return XTAL_ACCURACY;
}
-535
View File
@@ -1,535 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "platform-nrf5.h"
#include <hal/nrf_gpio.h>
#include <openthread/cli.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include <openthread/platform/radio.h>
#include <openthread/platform/toolchain.h>
#include <common/logging.hpp>
#include <nrf_802154.h>
#include <utils/code_utils.h>
typedef enum
{
kDiagTransmitModeIdle,
kDiagTransmitModePackets,
kDiagTransmitModeCarrier
} DiagTrasmitMode;
struct PlatformDiagCommand
{
const char *mName;
otError (*mCommand)(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen);
};
struct PlatformDiagMessage
{
const char mMessageDescriptor[11];
uint8_t mChannel;
int16_t mID;
uint32_t mCnt;
};
/**
* Diagnostics mode variables.
*
*/
static bool sDiagMode = false;
static bool sListen = false;
static DiagTrasmitMode sTransmitMode = kDiagTransmitModeIdle;
static uint8_t sChannel = 20;
static int8_t sTxPower = 0;
static uint32_t sTxPeriod = 1;
static int32_t sTxCount = 0;
static int32_t sTxRequestedCount = 1;
static int16_t sID = -1;
static struct PlatformDiagMessage sDiagMessage = {.mMessageDescriptor = "DiagMessage",
.mChannel = 0,
.mID = 0,
.mCnt = 0};
static otError parseLong(char *aArgs, long *aValue)
{
char *endptr;
*aValue = strtol(aArgs, &endptr, 0);
return (*endptr == '\0') ? OT_ERROR_NONE : OT_ERROR_PARSE;
}
static void appendErrorResult(otError aError, char *aOutput, size_t aOutputMaxLen)
{
if (aError != OT_ERROR_NONE)
{
snprintf(aOutput, aOutputMaxLen, "failed\r\nstatus %#x\r\n", aError);
}
}
static bool startCarrierTransmision(void)
{
nrf_802154_channel_set(sChannel);
nrf_802154_tx_power_set(sTxPower);
return nrf_802154_continuous_carrier();
}
static otError processListen(otInstance *aInstance,
uint8_t aArgsLength,
char * aArgs[],
char * aOutput,
size_t aOutputMaxLen)
{
OT_UNUSED_VARIABLE(aInstance);
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
if (aArgsLength == 0)
{
snprintf(aOutput, aOutputMaxLen, "listen: %s\r\n", sListen == true ? "yes" : "no");
}
else
{
long value;
error = parseLong(aArgs[0], &value);
otEXPECT(error == OT_ERROR_NONE);
sListen = (bool)(value);
snprintf(aOutput, aOutputMaxLen, "set listen to %s\r\nstatus 0x%02x\r\n", sListen == true ? "yes" : "no",
error);
}
exit:
appendErrorResult(error, aOutput, aOutputMaxLen);
return error;
}
static otError processID(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen)
{
OT_UNUSED_VARIABLE(aInstance);
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
if (aArgsLength == 0)
{
snprintf(aOutput, aOutputMaxLen, "ID: %" PRId16 "\r\n", sID);
}
else
{
long value;
error = parseLong(aArgs[0], &value);
otEXPECT(error == OT_ERROR_NONE);
otEXPECT_ACTION(value >= 0, error = OT_ERROR_INVALID_ARGS);
sID = (int16_t)(value);
snprintf(aOutput, aOutputMaxLen, "set ID to %" PRId16 "\r\nstatus 0x%02x\r\n", sID, error);
}
exit:
appendErrorResult(error, aOutput, aOutputMaxLen);
return error;
}
static otError processTransmit(otInstance *aInstance,
uint8_t aArgsLength,
char * aArgs[],
char * aOutput,
size_t aOutputMaxLen)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
if (aArgsLength == 0)
{
snprintf(aOutput, aOutputMaxLen,
"transmit will send %" PRId32 " diagnostic messages with %" PRIu32 " ms interval\r\nstatus 0x%02x\r\n",
sTxRequestedCount, sTxPeriod, error);
}
else if (strcmp(aArgs[0], "stop") == 0)
{
otEXPECT_ACTION(sTransmitMode != kDiagTransmitModeIdle, error = OT_ERROR_INVALID_STATE);
otPlatAlarmMilliStop(aInstance);
snprintf(aOutput, aOutputMaxLen, "diagnostic message transmission is stopped\r\nstatus 0x%02x\r\n", error);
sTransmitMode = kDiagTransmitModeIdle;
otPlatRadioReceive(aInstance, sChannel);
}
else if (strcmp(aArgs[0], "start") == 0)
{
otEXPECT_ACTION(sTransmitMode == kDiagTransmitModeIdle, error = OT_ERROR_INVALID_STATE);
otPlatAlarmMilliStop(aInstance);
sTransmitMode = kDiagTransmitModePackets;
sTxCount = sTxRequestedCount;
uint32_t now = otPlatAlarmMilliGetNow();
otPlatAlarmMilliStartAt(aInstance, now, sTxPeriod);
snprintf(aOutput, aOutputMaxLen,
"sending %" PRId32 " diagnostic messages with %" PRIu32 " ms interval\r\nstatus 0x%02x\r\n",
sTxRequestedCount, sTxPeriod, error);
}
else if (strcmp(aArgs[0], "carrier") == 0)
{
otEXPECT_ACTION(sTransmitMode == kDiagTransmitModeIdle, error = OT_ERROR_INVALID_STATE);
otEXPECT_ACTION(startCarrierTransmision(), error = OT_ERROR_FAILED);
sTransmitMode = kDiagTransmitModeCarrier;
snprintf(aOutput, aOutputMaxLen, "sending carrier on channel %d with tx power %d\r\nstatus 0x%02x\r\n",
sChannel, sTxPower, error);
}
else if (strcmp(aArgs[0], "interval") == 0)
{
long value;
otEXPECT_ACTION(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
error = parseLong(aArgs[1], &value);
otEXPECT(error == OT_ERROR_NONE);
otEXPECT_ACTION(value > 0, error = OT_ERROR_INVALID_ARGS);
sTxPeriod = (uint32_t)(value);
snprintf(aOutput, aOutputMaxLen, "set diagnostic messages interval to %" PRIu32 " ms\r\nstatus 0x%02x\r\n",
sTxPeriod, error);
}
else if (strcmp(aArgs[0], "count") == 0)
{
long value;
otEXPECT_ACTION(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
error = parseLong(aArgs[1], &value);
otEXPECT(error == OT_ERROR_NONE);
otEXPECT_ACTION((value > 0) || (value == -1), error = OT_ERROR_INVALID_ARGS);
sTxRequestedCount = (uint32_t)(value);
snprintf(aOutput, aOutputMaxLen, "set diagnostic messages count to %" PRId32 "\r\nstatus 0x%02x\r\n",
sTxRequestedCount, error);
}
else
{
error = OT_ERROR_INVALID_ARGS;
}
exit:
appendErrorResult(error, aOutput, aOutputMaxLen);
return error;
}
static otError processGpio(otInstance *aInstance,
uint8_t aArgsLength,
char * aArgs[],
char * aOutput,
size_t aOutputMaxLen)
{
OT_UNUSED_VARIABLE(aInstance);
long pinnum;
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
if (aArgsLength == 1)
{
uint32_t value;
nrf_gpio_pin_dir_t pindir;
error = parseLong(aArgs[0], &pinnum);
otEXPECT(error == OT_ERROR_NONE);
pindir = nrf_gpio_pin_dir_get(pinnum);
if (pindir == NRF_GPIO_PIN_DIR_INPUT)
{
value = nrf_gpio_pin_read(pinnum);
}
else
{
value = nrf_gpio_pin_out_read(pinnum);
}
snprintf(aOutput, aOutputMaxLen, "gpio %d = %d\r\n", (uint8_t)pinnum, (uint8_t)value);
}
else if (strcmp(aArgs[0], "set") == 0)
{
otEXPECT_ACTION(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
error = parseLong(aArgs[1], &pinnum);
otEXPECT(error == OT_ERROR_NONE);
nrf_gpio_pin_set(pinnum);
snprintf(aOutput, aOutputMaxLen, "gpio %d = 1\r\n", (uint8_t)pinnum);
}
else if (strcmp(aArgs[0], "clr") == 0)
{
otEXPECT_ACTION(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
error = parseLong(aArgs[1], &pinnum);
otEXPECT(error == OT_ERROR_NONE);
nrf_gpio_pin_clear(pinnum);
snprintf(aOutput, aOutputMaxLen, "gpio %d = 0\r\n", (uint8_t)pinnum);
}
else if (strcmp(aArgs[0], "out") == 0)
{
otEXPECT_ACTION(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
error = parseLong(aArgs[1], &pinnum);
otEXPECT(error == OT_ERROR_NONE);
nrf_gpio_cfg_output(pinnum);
snprintf(aOutput, aOutputMaxLen, "gpio %d: out\r\n", (uint8_t)pinnum);
}
else if (strcmp(aArgs[0], "in") == 0)
{
otEXPECT_ACTION(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
error = parseLong(aArgs[1], &pinnum);
otEXPECT(error == OT_ERROR_NONE);
nrf_gpio_cfg_input(pinnum, NRF_GPIO_PIN_NOPULL);
snprintf(aOutput, aOutputMaxLen, "gpio %d: in no pull\r\n", (uint8_t)pinnum);
}
else
{
error = OT_ERROR_INVALID_ARGS;
}
exit:
appendErrorResult(error, aOutput, aOutputMaxLen);
return error;
}
static otError processTemp(otInstance *aInstance,
uint8_t aArgsLength,
char * aArgs[],
char * aOutput,
size_t aOutputMaxLen)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aArgs);
otError error = OT_ERROR_NONE;
int32_t temperature;
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
otEXPECT_ACTION(aArgsLength == 0, error = OT_ERROR_INVALID_ARGS);
temperature = nrf5TempGet();
// Measurement resolution is 0.25 degrees Celsius
// Convert the temperature measurement to a decimal value, in degrees Celsius
snprintf(aOutput, aOutputMaxLen, "%" PRId32 ".%02" PRId32 "\r\n", temperature / 4, 25 * (temperature % 4));
exit:
appendErrorResult(error, aOutput, aOutputMaxLen);
return error;
}
static otError processCcaThreshold(otInstance *aInstance,
uint8_t aArgsLength,
char * aArgs[],
char * aOutput,
size_t aOutputMaxLen)
{
OT_UNUSED_VARIABLE(aInstance);
otError error = OT_ERROR_NONE;
nrf_802154_cca_cfg_t ccaConfig;
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
if (aArgsLength == 0)
{
nrf_802154_cca_cfg_get(&ccaConfig);
snprintf(aOutput, aOutputMaxLen, "cca threshold: %u\r\n", ccaConfig.ed_threshold);
}
else
{
long value;
error = parseLong(aArgs[0], &value);
otEXPECT(error == OT_ERROR_NONE);
otEXPECT_ACTION(value >= 0 && value <= 0xFF, error = OT_ERROR_INVALID_ARGS);
memset(&ccaConfig, 0, sizeof(ccaConfig));
ccaConfig.mode = NRF_RADIO_CCA_MODE_ED;
ccaConfig.ed_threshold = (uint8_t)value;
nrf_802154_cca_cfg_set(&ccaConfig);
snprintf(aOutput, aOutputMaxLen, "set cca threshold to %u\r\nstatus 0x%02x\r\n", ccaConfig.ed_threshold, error);
}
exit:
appendErrorResult(error, aOutput, aOutputMaxLen);
return error;
}
const struct PlatformDiagCommand sCommands[] = {
{"ccathreshold", &processCcaThreshold},
{"gpio", &processGpio},
{"id", &processID},
{"listen", &processListen},
{"temp", &processTemp},
{"transmit", &processTransmit},
};
otError otPlatDiagProcess(otInstance *aInstance,
uint8_t aArgsLength,
char * aArgs[],
char * aOutput,
size_t aOutputMaxLen)
{
otError error = OT_ERROR_INVALID_COMMAND;
size_t i;
for (i = 0; i < otARRAY_LENGTH(sCommands); i++)
{
if (strcmp(aArgs[0], sCommands[i].mName) == 0)
{
error = sCommands[i].mCommand(aInstance, aArgsLength - 1, aArgsLength > 1 ? &aArgs[1] : NULL, aOutput,
aOutputMaxLen);
break;
}
}
return error;
}
void otPlatDiagModeSet(bool aMode)
{
sDiagMode = aMode;
if (!sDiagMode)
{
otPlatRadioReceive(NULL, sChannel);
otPlatRadioSleep(NULL);
// Clear all remaining events before switching to MAC callbacks.
nrf5RadioClearPendingEvents();
}
else
{
// Reinit
sTransmitMode = kDiagTransmitModeIdle;
}
}
bool otPlatDiagModeGet()
{
return sDiagMode;
}
void otPlatDiagChannelSet(uint8_t aChannel)
{
sChannel = aChannel;
}
void otPlatDiagTxPowerSet(int8_t aTxPower)
{
sTxPower = aTxPower;
}
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
{
OT_UNUSED_VARIABLE(aInstance);
if (sListen && (aError == OT_ERROR_NONE))
{
if (aFrame->mLength == sizeof(struct PlatformDiagMessage))
{
struct PlatformDiagMessage *message = (struct PlatformDiagMessage *)aFrame->mPsdu;
if (strncmp(message->mMessageDescriptor, "DiagMessage", 11) == 0)
{
otPlatLog(OT_LOG_LEVEL_DEBG, OT_LOG_REGION_PLATFORM,
"{\"Frame\":{"
"\"LocalChannel\":%u ,"
"\"RemoteChannel\":%u,"
"\"CNT\":%" PRIu32 ","
"\"LocalID\":%" PRId16 ","
"\"RemoteID\":%" PRId16 ","
"\"RSSI\":%d"
"}}\r\n",
aFrame->mChannel, message->mChannel, message->mCnt, sID, message->mID,
aFrame->mInfo.mRxInfo.mRssi);
}
}
}
}
void otPlatDiagAlarmCallback(otInstance *aInstance)
{
if (sTransmitMode == kDiagTransmitModePackets)
{
if ((sTxCount > 0) || (sTxCount == -1))
{
otRadioFrame *sTxPacket = otPlatRadioGetTransmitBuffer(aInstance);
sTxPacket->mLength = sizeof(struct PlatformDiagMessage);
sTxPacket->mChannel = sChannel;
sDiagMessage.mChannel = sTxPacket->mChannel;
sDiagMessage.mID = sID;
memcpy(sTxPacket->mPsdu, &sDiagMessage, sizeof(struct PlatformDiagMessage));
otPlatRadioTransmit(aInstance, sTxPacket);
sDiagMessage.mCnt++;
if (sTxCount != -1)
{
sTxCount--;
}
uint32_t now = otPlatAlarmMilliGetNow();
otPlatAlarmMilliStartAt(aInstance, now, sTxPeriod);
}
else
{
sTransmitMode = kDiagTransmitModeIdle;
otPlatAlarmMilliStop(aInstance);
otPlatLog(OT_LOG_LEVEL_DEBG, OT_LOG_REGION_PLATFORM, "Transmit done");
}
}
}
-240
View File
@@ -1,240 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements an entropy source based on TRNG.
*
*/
#include <openthread/platform/entropy.h>
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <utils/code_utils.h>
#include "platform-nrf5.h"
static volatile bool sEntropyGetEntered;
#if SOFTDEVICE_PRESENT
#include "softdevice.h"
#else
#include <hal/nrf_rng.h>
static uint8_t sBuffer[RNG_BUFFER_SIZE];
static volatile uint32_t sReadPosition;
static volatile uint32_t sWritePosition;
static inline uint32_t bufferCount(void)
{
uint32_t writePos = sWritePosition;
return writePos - sReadPosition;
}
static inline bool bufferIsEmpty(void)
{
return (bufferCount() == 0);
}
static inline bool bufferIsUint32Ready(void)
{
return (bufferCount() >= 4);
}
static inline bool bufferIsFull(void)
{
return (bufferCount() >= RNG_BUFFER_SIZE);
}
static inline void bufferPut(uint8_t val)
{
if (!bufferIsFull())
{
sBuffer[(sWritePosition++) % RNG_BUFFER_SIZE] = val;
}
}
static inline uint8_t bufferGet()
{
uint8_t retVal = 0;
if (!bufferIsEmpty())
{
retVal = sBuffer[sReadPosition++ % RNG_BUFFER_SIZE];
}
return retVal;
}
static inline uint32_t bufferGetUint32()
{
uint32_t retVal = 0;
if (bufferIsUint32Ready())
{
for (uint32_t i = 0; i < 4; i++)
{
retVal <<= 8;
retVal |= bufferGet();
}
}
return retVal;
}
static void generatorStart(void)
{
nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY);
nrf_rng_int_enable(NRF_RNG_INT_VALRDY_MASK);
nrf_rng_task_trigger(NRF_RNG_TASK_START);
}
static void generatorStop(void)
{
nrf_rng_int_disable(NRF_RNG_INT_VALRDY_MASK);
nrf_rng_task_trigger(NRF_RNG_TASK_STOP);
}
void RNG_IRQHandler(void)
{
if (nrf_rng_event_get(NRF_RNG_EVENT_VALRDY) && nrf_rng_int_get(NRF_RNG_INT_VALRDY_MASK))
{
nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY);
bufferPut(nrf_rng_random_value_get());
if (bufferIsFull())
{
generatorStop();
}
}
}
#endif // SOFTDEVICE_PRESENT
void nrf5RandomInit(void)
{
uint32_t seed = 0;
#if SOFTDEVICE_PRESENT
uint32_t retval;
do
{
// Wait for the first randomized 4 bytes, to randomize software generator seed.
retval = sd_rand_application_vector_get((uint8_t *)&seed, sizeof(seed));
} while (retval != NRF_SUCCESS && seed == 0);
#else // SOFTDEVICE_PRESENT
memset(sBuffer, 0, sizeof(sBuffer));
sReadPosition = 0;
sWritePosition = 0;
NVIC_SetPriority(RNG_IRQn, RNG_IRQ_PRIORITY);
NVIC_ClearPendingIRQ(RNG_IRQn);
NVIC_EnableIRQ(RNG_IRQn);
nrf_rng_error_correction_enable();
nrf_rng_shorts_disable(NRF_RNG_SHORT_VALRDY_STOP_MASK);
generatorStart();
// Wait for the first randomized 4 bytes, to randomize software generator seed.
while (!bufferIsUint32Ready())
;
seed = bufferGetUint32();
#endif // SOFTDEVICE_PRESENT
srand(seed);
}
void nrf5RandomDeinit(void)
{
#ifndef SOFTDEVICE_PRESENT
generatorStop();
NVIC_DisableIRQ(RNG_IRQn);
NVIC_ClearPendingIRQ(RNG_IRQn);
NVIC_SetPriority(RNG_IRQn, 0);
#endif // SOFTDEVICE_PRESENT
}
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
{
otError error = OT_ERROR_NONE;
uint8_t copyLength;
uint16_t index = 0;
assert(!sEntropyGetEntered);
sEntropyGetEntered = true;
otEXPECT_ACTION(aOutput && aOutputLength, error = OT_ERROR_INVALID_ARGS);
do
{
#if SOFTDEVICE_PRESENT
sd_rand_application_bytes_available_get(&copyLength);
#else // SOFTDEVICE_PRESENT
copyLength = (uint8_t)bufferCount();
#endif // SOFTDEVICE_PRESENT
if (copyLength > aOutputLength - index)
{
copyLength = aOutputLength - index;
}
if (copyLength > 0)
{
#if SOFTDEVICE_PRESENT
uint32_t retval = sd_rand_application_vector_get(aOutput + index, copyLength);
otEXPECT_ACTION(retval == NRF_SUCCESS, error = OT_ERROR_FAILED);
#else // SOFTDEVICE_PRESENT
for (uint32_t i = 0; i < copyLength; i++)
{
aOutput[i + index] = bufferGet();
}
generatorStart();
#endif // SOFTDEVICE_PRESENT
index += copyLength;
}
} while (index < aOutputLength);
exit:
sEntropyGetEntered = false;
return error;
}
-208
View File
@@ -1,208 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the OpenThread FEM helper functions.
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <stdint.h>
#include <string.h>
#include "platform-config.h"
#include "platform-fem.h"
#define ENABLE_FEM 1
#include <nrf_802154.h>
// clang-format off
/**
* @brief Configuration parameters for the Front End Module.
*/
#define PLATFORM_FEM_DEFAULT_PA_PIN 26 /**< Default Power Amplifier pin. */
#define PLATFORM_FEM_DEFAULT_LNA_PIN 27 /**< Default Low Noise Amplifier pin. */
#define PLATFORM_FEM_DEFAULT_PDN_PIN 28 /**< Default Power Down pin. */
#define PLATFORM_FEM_DEFAULT_SET_PPI_CHANNEL 15 /**< Default PPI channel for pin setting. */
#define PLATFORM_FEM_DEFAULT_CLR_PPI_CHANNEL 16 /**< Default PPI channel for pin clearing. */
#define PLATFORM_FEM_DEFAULT_PDN_PPI_CHANNEL 14 /**< Default PPI channel for Power Down control. */
#define PLATFORM_FEM_DEFAULT_TIMER_MATCH_PPI_GROUP 4 /**< Default PPI channel group used to disable timer match PPI. */
#define PLATFORM_FEM_DEFAULT_RADIO_DISABLED_PPI_GROUP 5 /**< Default PPI channel group used to disable radio disabled PPI. */
#define PLATFORM_FEM_DEFAULT_PA_GPIOTE_CHANNEL 6 /**< Default PA GPIOTE channel for FEM control. */
#define PLATFORM_FEM_DEFAULT_LNA_GPIOTE_CHANNEL 7 /**< Default LNA GPIOTE channel for FEM control. */
#define PLATFORM_FEM_DEFAULT_PDN_GPIOTE_CHANNEL 5 /**< Default PDN GPIOTE channel for FEM control. */
/**
* @brief Configuration parameters for the Front End Module timings and gain.
*/
#define PLATFORM_FEM_PA_TIME_IN_ADVANCE_US 13 /**< Default time in microseconds when PA GPIO is activated before the radio is ready for transmission. */
#define PLATFORM_FEM_LNA_TIME_IN_ADVANCE_US 13 /**< Default time in microseconds when LNA GPIO is activated before the radio is ready for reception. */
#define PLATFORM_FEM_PDN_SETTLE_US 18 /**< Default the time between activating the PDN and asserting the RX_EN/TX_EN. */
#define PLATFORM_FEM_TRX_HOLD_US 5 /**< Default the time between deasserting the RX_EN/TX_EN and deactivating PDN. */
#define PLATFORM_FEM_PA_GAIN_DB 0 /**< Default PA gain. Ignored if the amplifier is not supporting this feature. */
#define PLATFORM_FEM_LNA_GAIN_DB 0 /**< Default LNA gain. Ignored if the amplifier is not supporting this feature. */
// clang-format on
#define PLATFORM_FEM_DEFAULT_CONFIG \
((PlatformFemConfigParams){ \
.mFemPhyCfg = \
{ \
.mPaTimeGapUs = PLATFORM_FEM_PA_TIME_IN_ADVANCE_US, \
.mLnaTimeGapUs = PLATFORM_FEM_LNA_TIME_IN_ADVANCE_US, \
.mPdnSettleUs = PLATFORM_FEM_PDN_SETTLE_US, \
.mTrxHoldUs = PLATFORM_FEM_TRX_HOLD_US, \
.mPaGainDb = PLATFORM_FEM_PA_GAIN_DB, \
.mLnaGainDb = PLATFORM_FEM_LNA_GAIN_DB, \
}, \
.mPaCfg = \
{ \
.mEnable = 1, \
.mActiveHigh = 1, \
.mGpioPin = PLATFORM_FEM_DEFAULT_PA_PIN, \
.mGpioteChId = PLATFORM_FEM_DEFAULT_PA_GPIOTE_CHANNEL, \
}, \
.mLnaCfg = \
{ \
.mEnable = 1, \
.mActiveHigh = 1, \
.mGpioPin = PLATFORM_FEM_DEFAULT_LNA_PIN, \
.mGpioteChId = PLATFORM_FEM_DEFAULT_LNA_GPIOTE_CHANNEL, \
}, \
.mPdnCfg = \
{ \
.mEnable = 1, \
.mActiveHigh = 1, \
.mGpioPin = PLATFORM_FEM_DEFAULT_PDN_PIN, \
.mGpioteChId = PLATFORM_FEM_DEFAULT_PDN_GPIOTE_CHANNEL, \
}, \
.mPpiChIdClr = PLATFORM_FEM_DEFAULT_CLR_PPI_CHANNEL, \
.mPpiChIdSet = PLATFORM_FEM_DEFAULT_SET_PPI_CHANNEL, \
.mPpiChIdPdn = PLATFORM_FEM_DEFAULT_PDN_PPI_CHANNEL, \
})
/**
* @brief Configuration parameters for FEM PHY.
*/
typedef struct
{
uint32_t mPaTimeGapUs;
uint32_t mLnaTimeGapUs;
uint32_t mPdnSettleUs;
uint32_t mTrxHoldUs;
uint8_t mPaGainDb;
uint8_t mLnaGainDb;
} PlatformFemPhyConfig;
/**
* @brief Configuration parameters for the PA and LNA.
*/
typedef struct
{
uint8_t mEnable : 1; /**< Enable toggling for this amplifier */
uint8_t mActiveHigh : 1; /**< Set the pin to be active high */
uint8_t mGpioPin : 6; /**< The GPIO pin to toggle for this amplifier */
uint8_t mGpioteChId; /**< The GPIOTE Channel ID used for toggling pins */
} PlatformFemPinConfig;
/**
* @brief PA & LNA GPIO toggle configuration
*
* This option configures the nRF 802.15.4 radio driver to toggle pins when the radio
* is active for use with a power amplifier and/or a low noise amplifier.
*
* Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided
* by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled.
*
* @note Changing this configuration while the radio is in use may have undefined
* consequences and must be avoided by the application.
*/
typedef struct
{
PlatformFemPhyConfig mFemPhyCfg; /**< Front End Module Physical layer configuration */
PlatformFemPinConfig mPaCfg; /**< Power Amplifier configuration */
PlatformFemPinConfig mLnaCfg; /**< Low Noise Amplifier configuration */
PlatformFemPinConfig mPdnCfg; /**< Power Down configuration */
uint8_t mPpiChIdSet; /**< PPI channel to be used for setting pins */
uint8_t mPpiChIdClr; /**< PPI channel to be used for clearing pins */
uint8_t mPpiChIdPdn; /**< PPI channel to handle PDN pin */
} PlatformFemConfigParams;
void PlatformFemSetConfigParams(const PlatformFemConfigParams *aConfig)
{
nrf_fem_interface_config_t cfg;
memset(&cfg, 0, sizeof(cfg));
cfg.fem_config.pa_time_gap_us = aConfig->mFemPhyCfg.mPaTimeGapUs;
cfg.fem_config.lna_time_gap_us = aConfig->mFemPhyCfg.mLnaTimeGapUs;
cfg.fem_config.pdn_settle_us = aConfig->mFemPhyCfg.mPdnSettleUs;
cfg.fem_config.trx_hold_us = aConfig->mFemPhyCfg.mTrxHoldUs;
cfg.fem_config.pa_gain_db = aConfig->mFemPhyCfg.mPaGainDb;
cfg.fem_config.lna_gain_db = aConfig->mFemPhyCfg.mLnaGainDb;
cfg.pa_pin_config.enable = aConfig->mPaCfg.mEnable;
cfg.pa_pin_config.active_high = aConfig->mPaCfg.mActiveHigh;
cfg.pa_pin_config.gpio_pin = aConfig->mPaCfg.mGpioPin;
cfg.pa_pin_config.gpiote_ch_id = aConfig->mPaCfg.mGpioteChId;
cfg.lna_pin_config.enable = aConfig->mLnaCfg.mEnable;
cfg.lna_pin_config.active_high = aConfig->mLnaCfg.mActiveHigh;
cfg.lna_pin_config.gpio_pin = aConfig->mLnaCfg.mGpioPin;
cfg.lna_pin_config.gpiote_ch_id = aConfig->mLnaCfg.mGpioteChId;
cfg.pdn_pin_config.enable = aConfig->mPdnCfg.mEnable;
cfg.pdn_pin_config.active_high = aConfig->mPdnCfg.mActiveHigh;
cfg.pdn_pin_config.gpio_pin = aConfig->mPdnCfg.mGpioPin;
cfg.pdn_pin_config.gpiote_ch_id = aConfig->mPdnCfg.mGpioteChId;
cfg.ppi_ch_id_clr = aConfig->mPpiChIdClr;
cfg.ppi_ch_id_set = aConfig->mPpiChIdSet;
cfg.ppi_ch_id_pdn = aConfig->mPpiChIdPdn;
nrf_fem_interface_configuration_set(&cfg);
}
void nrf5FemInit(void)
{
#if PLATFORM_FEM_ENABLE_DEFAULT_CONFIG
PlatformFemSetConfigParams(&PLATFORM_FEM_DEFAULT_CONFIG);
#endif
}
void nrf5FemDeinit(void)
{
}
void nrf5FemEnable(void)
{
}
void nrf5FemDisable(void)
{
}
-149
View File
@@ -1,149 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include "platform-nrf5.h"
/**
* @def PLATFORM_FLASH_PAGE_NUM
*
* Number of flash pages to use for OpenThread's non-volatile settings.
*
* @note This define applies only for MDK-ARM Keil toolchain configuration.
*
*/
#ifndef PLATFORM_FLASH_PAGE_NUM
#define PLATFORM_FLASH_PAGE_NUM 4
#endif
#define FLASH_PAGE_ADDR_MASK 0xFFFFF000
#define FLASH_PAGE_SIZE 4096
static uint32_t sFlashDataStart;
static uint32_t sFlashDataEnd;
static uint32_t sSwapSize;
static inline uint32_t mapAddress(uint8_t aSwapIndex, uint32_t aOffset)
{
uint32_t address;
address = sFlashDataStart + aOffset;
if (aSwapIndex)
{
address += sSwapSize;
}
return address;
}
void otPlatFlashInit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
#if defined(__CC_ARM)
// Temporary solution for Keil compiler.
uint32_t const bootloaderAddr = NRF_UICR->NRFFW[0];
uint32_t const pageSize = NRF_FICR->CODEPAGESIZE;
uint32_t const codeSize = NRF_FICR->CODESIZE;
if (bootloaderAddr != 0xFFFFFFFF)
{
sFlashDataEnd = bootloaderAddr;
}
else
{
sFlashDataEnd = pageSize * codeSize;
}
sFlashDataStart = sFlashDataEnd - (pageSize * PLATFORM_FLASH_PAGE_NUM);
#elif defined(__GNUC__) || defined(__ICCARM__)
extern uint32_t __start_ot_flash_data;
extern uint32_t __stop_ot_flash_data;
sFlashDataStart = (uint32_t)&__start_ot_flash_data;
sFlashDataEnd = (uint32_t)&__stop_ot_flash_data;
#endif
// Just ensure that the start and end addresses are page-aligned.
assert((sFlashDataStart % FLASH_PAGE_SIZE) == 0);
assert((sFlashDataEnd % FLASH_PAGE_SIZE) == 0);
sSwapSize = ((sFlashDataEnd - sFlashDataStart) / FLASH_PAGE_SIZE / 2) * FLASH_PAGE_SIZE;
assert(sSwapSize > 0);
}
uint32_t otPlatFlashGetSwapSize(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return sSwapSize;
}
void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex)
{
OT_UNUSED_VARIABLE(aInstance);
otError error;
for (uint32_t offset = 0; offset < sSwapSize; offset += FLASH_PAGE_SIZE)
{
error = nrf5FlashPageErase(mapAddress(aSwapIndex, offset));
assert(error == OT_ERROR_NONE);
while (nrf5FlashIsBusy())
{
}
}
OT_UNUSED_VARIABLE(error);
}
void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
{
OT_UNUSED_VARIABLE(aInstance);
otError error;
error = nrf5FlashWrite(mapAddress(aSwapIndex, aOffset), aData, aSize);
assert(error == OT_ERROR_NONE);
OT_UNUSED_VARIABLE(error);
}
void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize)
{
OT_UNUSED_VARIABLE(aInstance);
memcpy(aData, (uint8_t *)mapAddress(aSwapIndex, aOffset), aSize);
}
@@ -1,51 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
#include <stdint.h>
#include "platform-nrf5.h"
#include "drivers/include/nrfx_nvmc.h"
otError nrf5FlashPageErase(uint32_t aAddress)
{
nrfx_nvmc_page_erase(aAddress);
return OT_ERROR_NONE;
}
bool nrf5FlashIsBusy(void)
{
return NRF_NVMC->READY != NVMC_READY_READY_Ready;
}
otError nrf5FlashWrite(uint32_t aAddress, const uint8_t *aData, uint32_t aSize)
{
nrfx_nvmc_bytes_write(aAddress, aData, aSize);
return OT_ERROR_NONE;
}
-265
View File
@@ -1,265 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <openthread/platform/alarm-milli.h>
#include <utils/code_utils.h>
#include "platform-nrf5.h"
#include "softdevice.h"
#define FLASH_PAGE_SIZE 4096
#define FLASH_MAX_RETRY 5
typedef enum
{
FLASH_STATE_IDLE,
FLASH_STATE_WAITING_FOR_IDLE,
FLASH_STATE_PENDING,
FLASH_STATE_COMPLETE_SUCCESS,
FLASH_STATE_COMPLETE_FAILED
} SdFlashState;
static volatile SdFlashState sState;
void nrf5SdSocFlashProcess(uint32_t aEvtId)
{
switch (aEvtId)
{
case NRF_EVT_FLASH_OPERATION_SUCCESS:
switch (sState)
{
case FLASH_STATE_PENDING:
sState = FLASH_STATE_COMPLETE_SUCCESS;
break;
case FLASH_STATE_WAITING_FOR_IDLE:
sState = FLASH_STATE_IDLE;
break;
default:
break;
}
break;
case NRF_EVT_FLASH_OPERATION_ERROR:
switch (sState)
{
case FLASH_STATE_PENDING:
sState = FLASH_STATE_COMPLETE_FAILED;
break;
case FLASH_STATE_WAITING_FOR_IDLE:
sState = FLASH_STATE_IDLE;
break;
default:
break;
}
break;
default:
break;
}
}
static void waitInState(SdFlashState state)
{
do
{
nrf_sdh_evts_poll();
} while (sState == state);
}
static otError sdFlashSingleWrite(uint32_t aAddress, const uint8_t *aData, uint32_t aSize)
{
uint32_t retval;
uint32_t maxRetry = FLASH_MAX_RETRY;
do
{
nrf_sdh_suspend();
do
{
sState = FLASH_STATE_PENDING;
retval = sd_flash_write((uint32_t *)aAddress, (uint32_t *)aData, aSize);
if (retval == NRF_SUCCESS)
{
break;
}
else if (retval == NRF_ERROR_BUSY)
{
sState = FLASH_STATE_WAITING_FOR_IDLE;
}
else
{
assert(false);
}
waitInState(FLASH_STATE_WAITING_FOR_IDLE);
} while (retval == NRF_ERROR_BUSY);
waitInState(FLASH_STATE_PENDING);
if (sState != FLASH_STATE_COMPLETE_SUCCESS)
{
retval = NRF_ERROR_INTERNAL;
}
sState = FLASH_STATE_IDLE;
nrf_sdh_resume();
} while (retval != NRF_SUCCESS && maxRetry--);
return nrf5SdErrorToOtError(retval);
}
otError nrf5FlashPageErase(uint32_t aAddress)
{
uint32_t retval;
uint32_t maxRetry = FLASH_MAX_RETRY;
do
{
nrf_sdh_suspend();
do
{
sState = FLASH_STATE_PENDING;
retval = sd_flash_page_erase(aAddress / FLASH_PAGE_SIZE);
if (retval == NRF_SUCCESS)
{
break;
}
else if (retval == NRF_ERROR_BUSY)
{
sState = FLASH_STATE_WAITING_FOR_IDLE;
}
else
{
assert(false);
}
waitInState(FLASH_STATE_WAITING_FOR_IDLE);
} while (retval == NRF_ERROR_BUSY);
waitInState(FLASH_STATE_PENDING);
if (sState != FLASH_STATE_COMPLETE_SUCCESS)
{
retval = NRF_ERROR_INTERNAL;
}
sState = FLASH_STATE_IDLE;
nrf_sdh_resume();
} while (retval != NRF_SUCCESS && maxRetry--);
return nrf5SdErrorToOtError(retval);
}
bool nrf5FlashIsBusy(void)
{
return sState != FLASH_STATE_IDLE;
}
otError nrf5FlashWrite(uint32_t aAddress, const uint8_t *aData, uint32_t aSize)
{
otError error = OT_ERROR_NONE;
uint32_t remainder = (aAddress % sizeof(uint32_t));
uint32_t blockSize;
uint32_t blockValue;
otEXPECT_ACTION(sState == FLASH_STATE_IDLE, error = OT_ERROR_BUSY);
// Check if @p aAddress is aligned to full word size. If not, make additional
// flash write at the beginning.
if (remainder)
{
blockSize = MIN((sizeof(uint32_t) - remainder), aSize);
blockValue = 0xffffffff;
memcpy((uint8_t *)&blockValue + remainder, aData, blockSize);
error = sdFlashSingleWrite(aAddress - remainder, (uint8_t *)&blockValue, sizeof(blockValue) / sizeof(uint32_t));
otEXPECT(error == OT_ERROR_NONE);
aAddress += blockSize;
aData += blockSize;
aSize -= blockSize;
}
otEXPECT(aSize);
// Store the middle block of data.
remainder = aSize % sizeof(uint32_t);
blockSize = aSize - remainder;
error = sdFlashSingleWrite(aAddress, aData, blockSize / sizeof(uint32_t));
otEXPECT(error == OT_ERROR_NONE);
aAddress += blockSize;
aData += blockSize;
aSize -= blockSize;
// Store any additional bytes that didn't fit into middle block.
if (remainder)
{
blockValue = 0xffffffff;
memcpy((uint8_t *)&blockValue, aData, remainder);
error = sdFlashSingleWrite(aAddress, (uint8_t *)&blockValue, sizeof(blockValue) / sizeof(uint32_t));
otEXPECT(error == OT_ERROR_NONE);
}
exit:
return error;
}
-63
View File
@@ -1,63 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for logging.
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/logging.h>
#include <utils/logging_rtt.h>
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
void nrf5LogInit(void)
{
utilsLogRttInit();
}
void nrf5LogDeinit(void)
{
utilsLogRttDeinit();
}
OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
va_list ap;
va_start(ap, aFormat);
utilsLogRttOutput(aLogLevel, aLogRegion, aFormat, ap);
va_end(ap);
}
#endif
-134
View File
@@ -1,134 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <openthread/platform/misc.h>
#include <nrf.h>
#include "platform-nrf5-transport.h"
#include "platform-nrf5.h"
#if SOFTDEVICE_PRESENT
#include "softdevice.h"
#endif // SOFTDEVICE_PRESENT
static uint32_t sResetReason;
bool gPlatformPseudoResetWasRequested;
#if NRF52840_XXAA
__WEAK void nrf5CryptoInit(void)
{
// This function is defined as weak so it could be overridden with external implementation.
}
__WEAK void nrf5CryptoDeinit(void)
{
// This function is defined as weak so it could be overridden with external implementation.
}
#endif
void nrf5MiscInit(void)
{
#if SOFTDEVICE_PRESENT
sd_power_reset_reason_get(&sResetReason);
sd_power_reset_reason_clr(0xFFFFFFFF);
#else
sResetReason = NRF_POWER->RESETREAS;
NRF_POWER->RESETREAS = 0xFFFFFFFF;
#endif // SOFTDEVICE_PRESENT
}
void nrf5MiscDeinit(void)
{
// Intentionally empty.
}
void otPlatReset(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
gPlatformPseudoResetWasRequested = nrf5TransportPseudoResetRequired();
if (gPlatformPseudoResetWasRequested)
{
sResetReason = POWER_RESETREAS_SREQ_Msk;
}
else
{
NVIC_SystemReset();
}
}
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
otPlatResetReason reason;
if (sResetReason & POWER_RESETREAS_RESETPIN_Msk)
{
reason = OT_PLAT_RESET_REASON_EXTERNAL;
}
else if (sResetReason & POWER_RESETREAS_DOG_Msk)
{
reason = OT_PLAT_RESET_REASON_WATCHDOG;
}
else if (sResetReason & POWER_RESETREAS_SREQ_Msk)
{
reason = OT_PLAT_RESET_REASON_SOFTWARE;
}
else if (sResetReason & POWER_RESETREAS_LOCKUP_Msk)
{
reason = OT_PLAT_RESET_REASON_FAULT;
}
else if ((sResetReason & POWER_RESETREAS_OFF_Msk) || (sResetReason & POWER_RESETREAS_DIF_Msk))
{
reason = OT_PLAT_RESET_REASON_OTHER;
}
#if NRF52840_XXAA
else if ((sResetReason & POWER_RESETREAS_LPCOMP_Msk) || (sResetReason & POWER_RESETREAS_NFC_Msk) ||
(sResetReason & POWER_RESETREAS_VBUS_Msk))
{
reason = OT_PLAT_RESET_REASON_OTHER;
}
#endif // NRF52840_XXAA
else
{
reason = OT_PLAT_RESET_REASON_POWER_ON;
}
return reason;
}
void otPlatWakeHost(void)
{
// TODO: implement an operation to wake the host from sleep state.
}
@@ -1,64 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes front end module platform-specific functions.
*
*/
#ifndef PLATFORM_FEM_H_
#define PLATFORM_FEM_H_
#include <stdint.h>
/**
* Initialization of the FEM.
*
*/
void nrf5FemInit(void);
/**
* Deinitialization of the FEM.
*
*/
void nrf5FemDeinit(void);
/**
* Enable the FEM.
*
*/
void nrf5FemEnable(void);
/**
* Disable the FEM.
*
*/
void nrf5FemDisable(void);
#endif // PLATFORM_FEM_H_
@@ -1,66 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the platform-specific transport initializers.
*
*/
#ifndef PLATFORM_NRF5_TRANSPORT_H_
#define PLATFORM_NRF5_TRANSPORT_H_
#include <stdbool.h>
#include "transport-config.h"
/**
* Initialization of transport.
*
*/
void nrf5TransportInit(bool aPseudoReset);
/**
* Deinitialization of transport.
*
*/
void nrf5TransportDeinit(bool aPseudoReset);
/**
* This function performs transport processing.
*
*/
void nrf5TransportProcess(void);
/**
* This function returns true if transport driver should not be affected
* by reset. Otherwise, false is returned.
*/
bool nrf5TransportPseudoResetRequired(void);
#endif
@@ -1,208 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the platform-specific initializers.
*
*/
#ifndef PLATFORM_NRF5_H_
#define PLATFORM_NRF5_H_
#include <stdint.h>
#include <openthread/instance.h>
#include "platform-config.h"
void nrf5AlarmInit(void);
/**
* Deinitialization of Alarm driver.
*
*/
void nrf5AlarmDeinit(void);
/**
* Function for processing Alarm.
*
*/
void nrf5AlarmProcess(otInstance *aInstance);
/**
* Function for geting current time in mircosecond.
*
*/
uint64_t nrf5AlarmGetCurrentTime(void);
/**
* Function for getting raw counter value in RTC ticks.
*
*/
uint64_t nrf5AlarmGetRawCounter(void);
/**
* Initialization of Random Number Generator.
*
*/
void nrf5RandomInit(void);
/**
* Deinitialization of Random Number Generator.
*
*/
void nrf5RandomDeinit(void);
/**
* Initialization of Logger driver.
*
*/
void nrf5LogInit(void);
/**
* Deinitialization of Logger driver.
*
*/
void nrf5LogDeinit(void);
/**
* Initialization of Misc module.
*
*/
void nrf5MiscInit(void);
/**
* Deinitialization of Misc module.
*
*/
void nrf5MiscDeinit(void);
/**
* Initialization of Radio driver.
*
*/
void nrf5RadioInit(void);
/**
* Deinitialization of Radio driver.
*
*/
void nrf5RadioDeinit(void);
/**
* Function for processing Radio.
*
*/
void nrf5RadioProcess(otInstance *aInstance);
/**
* Function for clearing Radio driver pending events.
*
*/
void nrf5RadioClearPendingEvents(void);
/**
* Initialization of hardware crypto engine.
*
*/
void nrf5CryptoInit(void);
/**
* Deinitialization of hardware crypto engine.
*
*/
void nrf5CryptoDeinit(void);
/**
* Function for erasing page in flash.
*
*/
otError nrf5FlashPageErase(uint32_t aAddress);
/**
* Function for checking state of flash driver.
*
*/
bool nrf5FlashIsBusy(void);
/**
* Function for writing data into flash.
*
*/
otError nrf5FlashWrite(uint32_t aAddress, const uint8_t *aData, uint32_t aSize);
/**
* Initialization of temperature controller.
*
*/
void nrf5TempInit(void);
/**
* Deinitialization of temperature controller.
*
*/
void nrf5TempDeinit(void);
/**
* Function for processing temperature controller.
*
*/
void nrf5TempProcess(void);
/**
* Function for measuring internal temperature.
*
* @return Temperature value measured.
*
*/
int32_t nrf5TempGet(void);
#if SOFTDEVICE_PRESENT
/**
* Function for translating SoftDevice error into OpenThread's one.
*
*/
otError nrf5SdErrorToOtError(uint32_t aSdError);
/**
* Function for processing SoftDevice SoC events in flash module.
*
*/
void nrf5SdSocFlashProcess(uint32_t aEvtId);
#endif // SOFTDEVICE_PRESENT
int8_t nrf5GetChannelMaxTransmitPower(uint8_t aChannel);
/**
* Callback function for region changed.
*
*/
void nrf5HandleRegionChanged(uint16_t aRegionCode);
#endif // PLATFORM_NRF5_H_
@@ -1,74 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the SoftDevice platform-specific functions.
*
*/
#ifndef PLATFORM_SOFTDEVICE_H_
#define PLATFORM_SOFTDEVICE_H_
#include <stdint.h>
/** @brief RAAL Softdevice default parameters. */
#define PLATFORM_SOFTDEVICE_RAAL_TIMESLOT_DEFAULT_LENGTH 6400
#define PLATFORM_SOFTDEVICE_RAAL_TIMESLOT_DEFAULT_ALLOC_ITERS 5
#define PLATFORM_SOFTDEVICE_RAAL_TIMESLOT_DEFAULT_SAFE_MARGIN 126
#define PLATFORM_SOFTDEVICE_RAAL_TIMESLOT_DEFAULT_TIMEOUT 6400
#define PLATFORM_SOFTDEVICE_RAAL_TIMESLOT_DEFAULT_MAX_LENGTH 120000000
#define PLATFORM_SOFTDEVICE_RAAL_DEFAULT_LF_CLK_ACCURACY_PPM 500
/** @brief RAAL Softdevice configuration parameters. */
typedef struct
{
uint32_t timeslotLength; /**< Timeslot length requested by the module in microseconds. */
uint32_t
timeslotTimeout; /**< Longest acceptable delay until the start of the requested timeslot in microseconds. */
uint32_t timeslotMaxLength; /**< Maximum single timeslot length created by extension processing in microseconds. */
uint16_t timeslotAllocIters; /**< Maximum number of iteration of dividing timeslot_length by factor of 2 performed
by arbiter. */
uint16_t timeslotSafeMargin; /**< Safe margin before timeslot is finished and nrf_raal_timeslot_ended should be
called in microseconds. */
uint16_t lfClkAccuracyPpm; /**< Clock accuracy in ppm unit. */
} otSysSoftdeviceRaalConfigParams;
/**
* Function for processing SoftDevice SoC events.
*
*/
void otSysSoftdeviceSocEvtHandler(uint32_t aEvtId);
/**
* Function used to set non-default parameters of Softdevice RAAL.
*
*/
void otSysSoftdeviceRaalConfig(const otSysSoftdeviceRaalConfigParams *aConfig);
#endif // PLATFORM_SOFTDEVICE_H_
File diff suppressed because it is too large Load Diff
@@ -1,104 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the OpenThread softdevice helper functions.
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "platform-nrf5.h"
#include "platform-softdevice.h"
#include "softdevice.h"
#include <nrf_raal_softdevice.h>
otError nrf5SdErrorToOtError(uint32_t aSdError)
{
switch (aSdError)
{
case NRF_SUCCESS:
return OT_ERROR_NONE;
break;
case NRF_ERROR_INVALID_STATE:
case NRF_ERROR_BUSY:
return OT_ERROR_INVALID_STATE;
break;
case NRF_ERROR_INVALID_PARAM:
case NRF_ERROR_INVALID_ADDR:
return OT_ERROR_INVALID_ARGS;
break;
case NRF_ERROR_NO_MEM:
return OT_ERROR_NO_BUFS;
break;
case NRF_ERROR_NOT_FOUND:
return OT_ERROR_NOT_FOUND;
break;
case NRF_ERROR_NOT_SUPPORTED:
return OT_ERROR_NOT_IMPLEMENTED;
break;
default:
return OT_ERROR_FAILED;
break;
}
}
void otSysSoftdeviceSocEvtHandler(uint32_t aEvtId)
{
nrf5SdSocFlashProcess(aEvtId);
nrf_raal_softdevice_soc_evt_handler(aEvtId);
}
void otSysSoftdeviceRaalConfig(const otSysSoftdeviceRaalConfigParams *aConfig)
{
nrf_raal_softdevice_cfg_t cfg;
memset(&cfg, 0, sizeof(cfg));
cfg.timeslot_length = aConfig->timeslotLength;
cfg.timeslot_timeout = aConfig->timeslotTimeout;
cfg.timeslot_max_length = aConfig->timeslotMaxLength;
cfg.timeslot_alloc_iters = aConfig->timeslotAllocIters;
cfg.timeslot_safe_margin = aConfig->timeslotSafeMargin;
cfg.lf_clk_accuracy_ppm = aConfig->lfClkAccuracyPpm;
nrf_raal_softdevice_config(&cfg);
}
@@ -1,82 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the common SoftDevice headers.
*
*/
#ifndef SOFTDEVICE_H_
#define SOFTDEVICE_H_
// clang-format off
#if defined(__GNUC__)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"")
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
_Pragma("GCC diagnostic ignored \"-Wpedantic\"")
#endif
#include <nrf_svc.h>
#include <nrf_sdm.h>
#include <nrf_soc.h>
#include <nrf_nvic.h>
#if defined(__GNUC__)
_Pragma("GCC diagnostic pop")
#endif
/*******************************************************************************
* @section nRF SoftDevice Handler declarations.
*
* @note Definitions for below functions are placed in nRF5 SDK.
******************************************************************************/
/**
* @brief Function for stopping the incoming stack events.
*
* This function disables the SoftDevice interrupt. To resume polling for events,
* call @ref nrf_sdh_resume.
*/
void nrf_sdh_suspend(void);
/**
* @brief Function for resuming polling incoming events from the SoftDevice.
*/
void nrf_sdh_resume(void);
/**
* @brief Function for polling stack events from the SoftDevice.
*
* The events are passed to the application using the registered event handlers.
*/
void nrf_sdh_evts_poll(void);
// clang-format on
#endif // SOFTDEVICE_H_
-150
View File
@@ -1,150 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes the platform-specific initializers.
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <openthread/platform/logging.h>
#include "openthread-system.h"
#include "platform-fem.h"
#include "platform-nrf5-transport.h"
#include "platform-nrf5.h"
#include <nrf.h>
#include <nrf_drv_clock.h>
#include <openthread/config.h>
#if !OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT && PLATFORM_OPENTHREAD_VANILLA
#include <mbedtls/platform.h>
#include <mbedtls/threading.h>
#include <openthread/heap.h>
#endif
extern bool gPlatformPseudoResetWasRequested;
void __cxa_pure_virtual(void)
{
while (1)
;
}
void otSysInit(int argc, char *argv[])
{
OT_UNUSED_VARIABLE(argc);
OT_UNUSED_VARIABLE(argv);
if (gPlatformPseudoResetWasRequested)
{
otSysDeinit();
}
#if ((!SOFTDEVICE_PRESENT) && (NRF52840_XXAA))
// Enable I-code cache
NRF_NVMC->ICACHECNF = NVMC_ICACHECNF_CACHEEN_Enabled;
#elif (DCDC_ENABLE)
NRF_POWER->DCDCEN = 1;
#endif
#if !OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT && PLATFORM_OPENTHREAD_VANILLA
mbedtls_platform_set_calloc_free(otHeapCAlloc, otHeapFree);
mbedtls_platform_setup(NULL);
#endif
nrf_drv_clock_init();
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
nrf5LogInit();
#endif
nrf5AlarmInit();
nrf5RandomInit();
if (!gPlatformPseudoResetWasRequested)
{
#if NRF52840_XXAA
nrf5CryptoInit();
#endif
}
nrf5TransportInit(gPlatformPseudoResetWasRequested);
nrf5MiscInit();
nrf5RadioInit();
nrf5TempInit();
nrf5FemInit();
gPlatformPseudoResetWasRequested = false;
}
void otSysDeinit(void)
{
nrf5FemDeinit();
nrf5TempDeinit();
nrf5RadioDeinit();
nrf5MiscDeinit();
if (!gPlatformPseudoResetWasRequested)
{
#if NRF52840_XXAA
nrf5CryptoDeinit();
#endif
}
nrf5TransportDeinit(gPlatformPseudoResetWasRequested);
nrf5RandomDeinit();
nrf5AlarmDeinit();
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
nrf5LogDeinit();
#endif
#if !OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT && PLATFORM_OPENTHREAD_VANILLA
mbedtls_platform_teardown(NULL);
#endif
}
bool otSysPseudoResetWasRequested(void)
{
return gPlatformPseudoResetWasRequested;
}
void otSysProcessDrivers(otInstance *aInstance)
{
nrf5RadioProcess(aInstance);
nrf5TransportProcess();
nrf5TempProcess();
nrf5AlarmProcess(aInstance);
}
__WEAK void otSysEventSignalPending(void)
{
// Intentionally empty
}
-129
View File
@@ -1,129 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include <hal/nrf_temp.h>
#include <utils/code_utils.h>
#include "platform-nrf5.h"
#include <nrf_802154_temperature.h>
#if SOFTDEVICE_PRESENT
#include "softdevice.h"
#endif
#define US_PER_S 1000000ULL
static uint64_t sLastReadTimestamp;
static int32_t sTemperature;
#if !SOFTDEVICE_PRESENT
__STATIC_INLINE void dataReadyEventClear(void)
{
NRF_TEMP->EVENTS_DATARDY = 0;
volatile uint32_t dummy = NRF_TEMP->EVENTS_DATARDY;
OT_UNUSED_VARIABLE(dummy);
}
#endif
void nrf5TempInit(void)
{
#if !SOFTDEVICE_PRESENT
nrf_temp_init();
NRF_TEMP->TASKS_START = 1;
#endif
}
void nrf5TempDeinit(void)
{
#if !SOFTDEVICE_PRESENT
NRF_TEMP->TASKS_STOP = 1;
#endif
}
void nrf5TempProcess(void)
{
int32_t prevTemperature = sTemperature;
uint64_t now;
#if SOFTDEVICE_PRESENT
now = nrf5AlarmGetCurrentTime();
if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S))
{
(void)sd_temp_get(&sTemperature);
sLastReadTimestamp = now;
}
#else
if (NRF_TEMP->EVENTS_DATARDY)
{
dataReadyEventClear();
sTemperature = nrf_temp_read();
}
now = nrf5AlarmGetCurrentTime();
if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S))
{
NRF_TEMP->TASKS_START = 1;
sLastReadTimestamp = now;
}
#endif
if (prevTemperature != sTemperature)
{
nrf_802154_temperature_changed();
}
}
int32_t nrf5TempGet(void)
{
// Provide temperature value in [0.25 C] unit.
return sTemperature;
}
void nrf_802154_temperature_init(void)
{
// Intentionally empty
}
void nrf_802154_temperature_deinit(void)
{
// Intentionally empty
}
int8_t nrf_802154_temperature_get(void)
{
// Provide temperature value in [C].
return (int8_t)(sTemperature / 4);
}
@@ -1,217 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for SPIS communication.
*
*/
#include <assert.h>
#include <utils/code_utils.h>
#include <openthread/platform/spi-slave.h>
#include "platform-nrf5-transport.h"
#include <hal/nrf_gpio.h>
#include <nrfx.h>
#include <nrfx_spis.h>
#include "openthread-system.h"
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
/**
* SPI Slave transaction variables.
*/
static void * sContext = NULL;
static uint8_t * sOutputBuf = NULL;
static uint16_t sOutputBufLen = 0;
static uint8_t * sInputBuf = NULL;
static uint16_t sInputBufLen = 0;
static bool sRequestTransactionFlag = false;
static bool sFurtherProcessingFlag = false;
static otPlatSpiSlaveTransactionProcessCallback sProcessCallback = NULL;
static otPlatSpiSlaveTransactionCompleteCallback sCompleteCallback = NULL;
static const nrfx_spis_t sSpiSlaveInstance = NRFX_SPIS_INSTANCE(SPIS_INSTANCE);
static void spisEventHandler(nrfx_spis_evt_t const *aEvent, void *aContext)
{
OT_UNUSED_VARIABLE(aContext);
switch (aEvent->evt_type)
{
case NRFX_SPIS_BUFFERS_SET_DONE:
if (sRequestTransactionFlag)
{
// Host IRQ pin is active low.
nrf_gpio_pin_clear(SPIS_PIN_HOST_IRQ);
}
break;
case NRFX_SPIS_XFER_DONE:
// Ensure Host IRQ pin is set.
nrf_gpio_pin_set(SPIS_PIN_HOST_IRQ);
// Execute application callback.
if (sCompleteCallback(sContext, aEvent->tx_buffer, aEvent->tx_buffer_size, aEvent->rx_buffer,
aEvent->rx_buffer_size, aEvent->rx_amount))
{
// Further processing is required.
sFurtherProcessingFlag = true;
otSysEventSignalPending();
}
break;
default:
assert(false);
break;
}
}
void nrf5SpiSlaveInit(void)
{
// Intentionally empty.
}
void nrf5SpiSlaveDeinit(void)
{
sOutputBuf = NULL;
sOutputBufLen = 0;
sInputBuf = NULL;
sInputBufLen = 0;
sRequestTransactionFlag = false;
otPlatSpiSlaveDisable();
}
void nrf5SpiSlaveProcess(void)
{
otEXPECT(sFurtherProcessingFlag == true);
// Clear further processing flag.
sFurtherProcessingFlag = false;
// Perform any further processing if necessary.
sProcessCallback(sContext);
exit:
return;
}
otError otPlatSpiSlaveEnable(otPlatSpiSlaveTransactionCompleteCallback aCompleteCallback,
otPlatSpiSlaveTransactionProcessCallback aProcessCallback,
void * aContext)
{
otError result = OT_ERROR_NONE;
nrfx_err_t error = NRFX_SUCCESS;
nrfx_spis_config_t config = NRFX_SPIS_DEFAULT_CONFIG;
assert(aCompleteCallback != NULL);
assert(aProcessCallback != NULL);
// Check if SPI Slave interface is already enabled.
otEXPECT_ACTION(sCompleteCallback == NULL, error = OT_ERROR_ALREADY);
config.csn_pin = SPIS_PIN_CSN;
config.miso_pin = SPIS_PIN_MISO;
config.mosi_pin = SPIS_PIN_MOSI;
config.sck_pin = SPIS_PIN_SCK;
config.mode = SPIS_MODE;
config.bit_order = SPIS_BIT_ORDER;
config.irq_priority = SPIS_IRQ_PRIORITY;
error = nrfx_spis_init(&sSpiSlaveInstance, &config, spisEventHandler, NULL);
assert(error == NRFX_SUCCESS);
if (error != NRFX_SUCCESS)
{
result = OT_ERROR_FAILED;
}
// Set up Host IRQ pin.
nrf_gpio_pin_set(SPIS_PIN_HOST_IRQ);
nrf_gpio_cfg_output(SPIS_PIN_HOST_IRQ);
// Set proper callback and context.
sProcessCallback = aProcessCallback;
sCompleteCallback = aCompleteCallback;
sContext = aContext;
exit:
return result;
}
void otPlatSpiSlaveDisable(void)
{
nrfx_spis_uninit(&sSpiSlaveInstance);
}
otError otPlatSpiSlavePrepareTransaction(uint8_t *aOutputBuf,
uint16_t aOutputBufLen,
uint8_t *aInputBuf,
uint16_t aInputBufLen,
bool aRequestTransactionFlag)
{
otError result = OT_ERROR_NONE;
nrfx_err_t error = NRFX_SUCCESS;
nrf_spis_semstat_t semaphore_status = nrf_spis_semaphore_status_get(sSpiSlaveInstance.p_reg);
assert(sCompleteCallback != NULL);
otEXPECT_ACTION(((semaphore_status != NRF_SPIS_SEMSTAT_SPIS) && (semaphore_status != NRF_SPIS_SEMSTAT_CPUPENDING)),
result = OT_ERROR_BUSY);
if (aOutputBuf != NULL)
{
sOutputBuf = aOutputBuf;
sOutputBufLen = aOutputBufLen;
}
if (aInputBuf != NULL)
{
sInputBuf = aInputBuf;
sInputBufLen = aInputBufLen;
}
sRequestTransactionFlag = aRequestTransactionFlag;
error = nrfx_spis_buffers_set(&sSpiSlaveInstance, sOutputBuf, sOutputBufLen, sInputBuf, sInputBufLen);
if (error == NRFX_ERROR_INVALID_STATE)
{
result = OT_ERROR_BUSY;
}
else
{
assert(error == NRFX_SUCCESS);
}
exit:
return result;
}
#endif // SPIS_AS_SERIAL_TRANSPORT == 1
@@ -1,79 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file includes UART/USB and SPI driver initializers.
*
*/
#ifndef TRANSPORT_DRIVERS_H_
#define TRANSPORT_DRIVERS_H_
/**
* Initialization of UART driver.
*
*/
void nrf5UartInit(void);
/**
* Deinitialization of UART driver.
*
*/
void nrf5UartDeinit(void);
/**
* Clear pending UART data.
*
*/
void nrf5UartClearPendingData(void);
/**
* This function performs UART driver processing.
*
*/
void nrf5UartProcess(void);
/**
* Initialization of SPI Slave driver.
*
*/
void nrf5SpiSlaveInit(void);
/**
* Deinitialization of SPI Slave driver.
*
*/
void nrf5SpiSlaveDeinit(void);
/**
* Function for processing SPI Slave driver.
*/
void nrf5SpiSlaveProcess(void);
#endif
@@ -1,94 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the nrf5 platform transport initialization functions.
*
*/
#include <openthread/platform/toolchain.h>
#include "platform-nrf5-transport.h"
#include "transport-drivers.h"
void nrf5TransportInit(bool aPseudoReset)
{
OT_UNUSED_VARIABLE(aPseudoReset);
#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1))
if (!aPseudoReset)
{
nrf5UartInit();
}
else
{
nrf5UartClearPendingData();
}
#endif
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
nrf5SpiSlaveInit();
#endif
}
void nrf5TransportDeinit(bool aPseudoReset)
{
OT_UNUSED_VARIABLE(aPseudoReset);
#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1))
if (!aPseudoReset)
{
nrf5UartDeinit();
}
#endif
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
nrf5SpiSlaveDeinit();
#endif
}
void nrf5TransportProcess(void)
{
#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1))
nrf5UartProcess();
#endif
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
nrf5SpiSlaveProcess();
#endif
}
bool nrf5TransportPseudoResetRequired(void)
{
#if OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
return true;
#else // if OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
return false;
#endif
}
@@ -1,361 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for UART communication.
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <utils/code_utils.h>
#include <utils/uart.h>
#include <openthread/platform/toolchain.h>
#include "openthread-system.h"
#include "platform-nrf5-transport.h"
#include <hal/nrf_gpio.h>
#include <hal/nrf_uarte.h>
#include <nrf_drv_clock.h>
#if (UART_AS_SERIAL_TRANSPORT == 1)
/**
* UART enable flag.
*/
bool sUartEnabled = false;
/**
* UART TX buffer variables.
*/
static const uint8_t *sTransmitBuffer = NULL;
static volatile bool sTransmitDone = 0;
/**
* UART RX ring buffer variables.
*/
static uint8_t sReceiveBuffer[UART_RX_BUFFER_SIZE];
static volatile uint16_t sReceiveHead = 0;
static volatile uint16_t sReceiveTail = 0;
/**
* Function for returning the next RX buffer index.
*
* @return Next RX buffer index.
*/
static __INLINE uint16_t getNextRxBufferIndex()
{
return (sReceiveHead + 1) % UART_RX_BUFFER_SIZE;
}
/**
* Function for checking if RX buffer is full.
*
* @retval true RX buffer is full.
* @retval false RX buffer is not full.
*/
static __INLINE bool isRxBufferFull()
{
return getNextRxBufferIndex() == sReceiveTail;
}
/**
* Function for checking if RX buffer is empty.
*
* @retval true RX buffer is empty.
* @retval false RX buffer is not empty.
*/
static __INLINE bool isRxBufferEmpty()
{
uint16_t head = sReceiveHead;
return (head == sReceiveTail);
}
/**
* Function for notifying application about new bytes received.
*/
static void processReceive(void)
{
// Set head position to not be changed during read procedure.
uint16_t head = sReceiveHead;
uint8_t *position;
otEXPECT(isRxBufferEmpty() == false);
// In case head roll back to the beginning of the buffer, notify about left
// bytes from the end of the buffer.
if (head < sReceiveTail)
{
position = &sReceiveBuffer[sReceiveTail];
otPlatUartReceived(position, (UART_RX_BUFFER_SIZE - sReceiveTail));
sReceiveTail = 0;
}
// Notify about received bytes.
if (head > sReceiveTail)
{
position = &sReceiveBuffer[sReceiveTail];
otPlatUartReceived(position, (head - sReceiveTail));
sReceiveTail = head;
}
// In case interrupts were disabled due to the full buffer, re-enable it now.
if (!nrf_uarte_int_enable_check(UART_INSTANCE, NRF_UARTE_INT_RXDRDY_MASK))
{
nrf_uarte_int_enable(UART_INSTANCE, NRF_UARTE_INT_RXDRDY_MASK | NRF_UARTE_INT_ERROR_MASK);
}
exit:
return;
}
otError otPlatUartFlush(void)
{
return OT_ERROR_NOT_IMPLEMENTED;
}
/**
* Function for notifying application about transmission being done.
*/
static void processTransmit(void)
{
otEXPECT(sTransmitBuffer != NULL);
if (sTransmitDone)
{
// Clear Transmition transaction and notify application.
sTransmitBuffer = NULL;
sTransmitDone = false;
otPlatUartSendDone();
}
exit:
return;
}
void nrf5UartProcess(void)
{
processReceive();
processTransmit();
}
void nrf5UartInit(void)
{
// Intentionally empty.
}
void nrf5UartClearPendingData(void)
{
// Intentionally empty.
}
void nrf5UartDeinit(void)
{
if (sUartEnabled)
{
otPlatUartDisable();
}
}
otError otPlatUartEnable(void)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(sUartEnabled == false, error = OT_ERROR_ALREADY);
// Set up TX and RX pins.
nrf_gpio_pin_set(UART_PIN_TX);
nrf_gpio_cfg_output(UART_PIN_TX);
nrf_gpio_cfg_input(UART_PIN_RX, NRF_GPIO_PIN_NOPULL);
nrf_uarte_txrx_pins_set(UART_INSTANCE, UART_PIN_TX, UART_PIN_RX);
#if (UART_HWFC_ENABLED == 1)
// Set up CTS and RTS pins.
nrf_gpio_cfg_input(UART_PIN_CTS, NRF_GPIO_PIN_NOPULL);
nrf_gpio_pin_set(UART_PIN_RTS);
nrf_gpio_cfg_output(UART_PIN_RTS);
nrf_uarte_hwfc_pins_set(UART_INSTANCE, UART_PIN_RTS, UART_PIN_CTS);
nrf_uarte_configure(UART_INSTANCE, UART_PARITY, NRF_UARTE_HWFC_ENABLED);
#else
nrf_uarte_configure(UART_INSTANCE, UART_PARITY, NRF_UARTE_HWFC_DISABLED);
#endif
// Configure baudrate.
nrf_uarte_baudrate_set(UART_INSTANCE, UART_BAUDRATE);
// Clear UART specific events.
nrf_uarte_event_clear(UART_INSTANCE, NRF_UARTE_EVENT_ENDTX);
nrf_uarte_event_clear(UART_INSTANCE, NRF_UARTE_EVENT_ERROR);
nrf_uarte_event_clear(UART_INSTANCE, NRF_UARTE_EVENT_RXDRDY);
// Enable interrupts for TX.
nrf_uarte_int_enable(UART_INSTANCE, NRF_UARTE_INT_ENDTX_MASK);
// Enable interrupts for RX.
nrf_uarte_int_enable(UART_INSTANCE, NRF_UARTE_INT_RXDRDY_MASK | NRF_UARTE_INT_ERROR_MASK);
// Configure NVIC to handle UART interrupts.
NVIC_SetPriority(UART_IRQN, UART_IRQ_PRIORITY);
NVIC_ClearPendingIRQ(UART_IRQN);
NVIC_EnableIRQ(UART_IRQN);
// Start HFCLK
nrf_drv_clock_hfclk_request(NULL);
while (!nrf_drv_clock_hfclk_is_running())
{
}
// Enable UART instance, and start RX on it.
nrf_uarte_enable(UART_INSTANCE);
nrf_uarte_task_trigger(UART_INSTANCE, NRF_UARTE_TASK_STARTRX);
sUartEnabled = true;
exit:
return error;
}
otError otPlatUartDisable(void)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(sUartEnabled == true, error = OT_ERROR_ALREADY);
// Disable NVIC interrupt.
NVIC_DisableIRQ(UART_IRQN);
NVIC_ClearPendingIRQ(UART_IRQN);
NVIC_SetPriority(UART_IRQN, 0);
// Disable interrupts for TX.
nrf_uarte_int_disable(UART_INSTANCE, NRF_UARTE_INT_ENDTX_MASK);
// Disable interrupts for RX.
nrf_uarte_int_disable(UART_INSTANCE, NRF_UARTE_INT_RXDRDY_MASK | NRF_UARTE_INT_ERROR_MASK);
// Disable UART instance.
nrf_uarte_disable(UART_INSTANCE);
// Release HF clock.
nrf_drv_clock_hfclk_release();
sUartEnabled = false;
exit:
return error;
}
otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(sTransmitBuffer == NULL, error = OT_ERROR_BUSY);
// Set up transmit buffer.
sTransmitBuffer = aBuf;
// Initiate transmission process.
nrf_uarte_event_clear(UART_INSTANCE, NRF_UARTE_EVENT_ENDTX);
nrf_uarte_tx_buffer_set(UART_INSTANCE, sTransmitBuffer, aBufLength);
nrf_uarte_task_trigger(UART_INSTANCE, NRF_UARTE_TASK_STARTTX);
exit:
return error;
}
/**
* Interrupt handler of UART0 peripherial.
*/
void UARTE0_UART0_IRQHandler(void)
{
// Check if any error has been detected.
if (nrf_uarte_int_enable_check(UART_INSTANCE, NRF_UARTE_INT_ERROR_MASK) &&
nrf_uarte_event_check(UART_INSTANCE, NRF_UARTE_EVENT_ERROR))
{
nrf_uarte_event_clear(UART_INSTANCE, NRF_UARTE_EVENT_ERROR);
}
else if (nrf_uarte_int_enable_check(UART_INSTANCE, NRF_UARTE_INT_RXDRDY_MASK) &&
nrf_uarte_event_check(UART_INSTANCE, NRF_UARTE_EVENT_RXDRDY))
{
// Clear RXDRDY event.
nrf_uarte_event_clear(UART_INSTANCE, NRF_UARTE_EVENT_RXDRDY);
// Read byte from the UART buffer.
uint8_t byte = nrf_uart_rxd_get((NRF_UART_Type *)UART_INSTANCE);
assert(!isRxBufferFull());
sReceiveBuffer[sReceiveHead] = byte;
sReceiveHead = getNextRxBufferIndex();
// Check if we are able to process next RX bytes.
if (isRxBufferFull())
{
// Disable interrupts for RX.
nrf_uarte_int_disable(UART_INSTANCE, NRF_UARTE_INT_RXDRDY_MASK | NRF_UARTE_INT_ERROR_MASK);
}
otSysEventSignalPending();
}
if (nrf_uarte_event_check(UART_INSTANCE, NRF_UARTE_EVENT_ENDTX))
{
// Clear ENDTX event.
nrf_uarte_event_clear(UART_INSTANCE, NRF_UARTE_EVENT_ENDTX);
sTransmitDone = true;
nrf_uarte_task_trigger(UART_INSTANCE, NRF_UARTE_TASK_STOPTX);
otSysEventSignalPending();
}
}
#endif // UART_AS_SERIAL_TRANSPORT == 1
/**
* The UART driver weak functions definition.
*
*/
OT_TOOL_WEAK void otPlatUartSendDone(void)
{
}
OT_TOOL_WEAK void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
{
OT_UNUSED_VARIABLE(aBuf);
OT_UNUSED_VARIABLE(aBufLength);
}
@@ -1,372 +0,0 @@
/*
* Copyright (c) 2017, The OpenThread Authors.
* 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.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for UART communication over USB CDC.
*
*/
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <common/logging.hpp>
#include <openthread-system.h>
#include <utils/code_utils.h>
#include <utils/uart.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include <openthread/platform/misc.h>
#include "platform-nrf5-transport.h"
#include "app_usbd.h"
#include "app_usbd_serial_num.h"
#include "nrf_dfu_trigger_usb.h"
#include "nrf_drv_clock.h"
#include "nrf_drv_power.h"
#include "class/cdc/acm/app_usbd_cdc_acm.h"
#if (USB_CDC_AS_SERIAL_TRANSPORT == 1)
static void cdcAcmUserEventHandler(app_usbd_class_inst_t const *aInstance, app_usbd_cdc_acm_user_event_t aEvent);
#define CDC_ACM_COMM_EPIN NRF_DRV_USBD_EPIN2
#define CDC_ACM_DATA_EPIN NRF_DRV_USBD_EPIN1
#define CDC_ACM_DATA_EPOUT NRF_DRV_USBD_EPOUT1
APP_USBD_CDC_ACM_GLOBAL_DEF(sAppCdcAcm,
cdcAcmUserEventHandler,
USB_CDC_ACM_COMM_INTERFACE,
USB_CDC_ACM_DATA_INTERFACE,
CDC_ACM_COMM_EPIN,
CDC_ACM_DATA_EPIN,
CDC_ACM_DATA_EPOUT,
APP_USBD_CDC_COMM_PROTOCOL_NONE);
// Rx buffer length must by multiple of NRF_DRV_USBD_EPSIZE.
static char sRxBuffer[NRF_DRV_USBD_EPSIZE * ((UART_RX_BUFFER_SIZE + NRF_DRV_USBD_EPSIZE - 1) / NRF_DRV_USBD_EPSIZE)];
static struct
{
const uint8_t *mTxBuffer;
uint16_t mTxSize;
size_t mReceivedDataSize;
bool mUartEnabled;
bool mLastConnectionStatus;
uint32_t mOpenTimestamp;
volatile bool mConnected;
volatile bool mReadyToStart;
volatile bool mTransferInProgress;
volatile bool mTransferDone;
volatile bool mReceiveDone;
} sUsbState;
static void cdcAcmUserEventHandler(app_usbd_class_inst_t const *aCdcAcmInstance, app_usbd_cdc_acm_user_event_t aEvent)
{
app_usbd_cdc_acm_t const *cdcAcmClass = app_usbd_cdc_acm_class_get(aCdcAcmInstance);
switch (aEvent)
{
case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN:
// Setup first transfer.
(void)app_usbd_cdc_acm_read_any(&sAppCdcAcm, sRxBuffer, sizeof(sRxBuffer));
sUsbState.mOpenTimestamp = otPlatAlarmMilliGetNow();
break;
case APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE:
break;
case APP_USBD_CDC_ACM_USER_EVT_TX_DONE:
sUsbState.mTransferDone = true;
break;
case APP_USBD_CDC_ACM_USER_EVT_RX_DONE:
sUsbState.mReceiveDone = true;
// Get amount of data received.
sUsbState.mReceivedDataSize = app_usbd_cdc_acm_rx_size(cdcAcmClass);
break;
default:
break;
}
}
static void usbdIsrHandler(app_usbd_internal_evt_t const *const aEvent, bool aQueued)
{
(void)aEvent;
(void)aQueued;
otSysEventSignalPending();
}
static void usbdUserEventHandler(app_usbd_event_type_t aEvent)
{
switch (aEvent)
{
case APP_USBD_EVT_STOPPED:
app_usbd_disable();
break;
case APP_USBD_EVT_POWER_DETECTED:
// Workaround for missing port open event.
sAppCdcAcm.specific.p_data->ctx.line_state = 0;
sUsbState.mConnected = true;
break;
case APP_USBD_EVT_POWER_REMOVED:
sUsbState.mConnected = false;
break;
case APP_USBD_EVT_POWER_READY:
sUsbState.mReadyToStart = true;
break;
default:
break;
}
}
static bool hasPortOpenDelayPassed(void)
{
int32_t timeDiff = otPlatAlarmMilliGetNow() - sUsbState.mOpenTimestamp;
return (timeDiff < 0) || (timeDiff > USB_HOST_UART_CONFIG_DELAY_MS);
}
static bool isPortOpened(void)
{
uint32_t value;
if (app_usbd_cdc_acm_line_state_get(&sAppCdcAcm, APP_USBD_CDC_ACM_LINE_STATE_DTR, &value) == NRF_SUCCESS)
{
return (value != 0) && hasPortOpenDelayPassed();
}
return false;
}
static void processConnection(void)
{
bool connectionStatus = sUsbState.mUartEnabled && sUsbState.mConnected;
if (sUsbState.mLastConnectionStatus != connectionStatus)
{
sUsbState.mLastConnectionStatus = connectionStatus;
if (connectionStatus)
{
if (!nrf_drv_usbd_is_enabled())
{
app_usbd_enable();
}
}
else
{
if (nrf_drv_usbd_is_started())
{
app_usbd_stop();
}
else
{
app_usbd_disable();
}
}
}
// Provide some delay so the OS can re-enumerate the device in case of reset.
if (sUsbState.mReadyToStart)
{
sUsbState.mReadyToStart = false;
if (nrf_drv_usbd_is_enabled())
{
app_usbd_start();
}
}
}
static void processReceive(void)
{
if (sUsbState.mReceiveDone)
{
if (sUsbState.mReceivedDataSize != 0)
{
otPlatUartReceived((const uint8_t *)sRxBuffer, sUsbState.mReceivedDataSize);
sUsbState.mReceivedDataSize = 0;
}
// Setup next transfer.
if (app_usbd_cdc_acm_read_any(&sAppCdcAcm, sRxBuffer, sizeof(sRxBuffer)) == NRF_SUCCESS)
{
sUsbState.mReceiveDone = false;
}
}
}
static void processTransmit(void)
{
// If some data was requested to send while port was closed, send it now.
if ((sUsbState.mTxBuffer != NULL) && isPortOpened())
{
if (app_usbd_cdc_acm_write(&sAppCdcAcm, sUsbState.mTxBuffer, sUsbState.mTxSize) == NRF_SUCCESS)
{
sUsbState.mTransferInProgress = true;
sUsbState.mTxBuffer = NULL;
sUsbState.mTxSize = 0;
}
}
else if (sUsbState.mTransferDone)
{
sUsbState.mTransferDone = false;
sUsbState.mTransferInProgress = false;
otPlatUartSendDone();
}
}
void nrf5UartInit(void)
{
static const app_usbd_config_t usbdConfig = {
.ev_state_proc = usbdUserEventHandler,
.ev_isr_handler = usbdIsrHandler,
};
memset((void *)&sUsbState, 0, sizeof(sUsbState));
app_usbd_serial_num_generate();
ret_code_t ret = app_usbd_init(&usbdConfig);
assert(ret == NRF_SUCCESS);
#if NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER)
ret = nrf_dfu_trigger_usb_init();
assert(ret == NRF_SUCCESS);
#endif // NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER)
app_usbd_class_inst_t const *cdcAcmInstance = app_usbd_cdc_acm_class_inst_get(&sAppCdcAcm);
ret = app_usbd_class_append(cdcAcmInstance);
assert(ret == NRF_SUCCESS);
ret = app_usbd_power_events_enable();
assert(ret == NRF_SUCCESS);
OT_UNUSED_VARIABLE(ret);
}
void nrf5UartDeinit(void)
{
if (nrf_drv_usbd_is_started())
{
app_usbd_stop();
while (app_usbd_event_queue_process())
{
}
}
else if (nrf_drv_usbd_is_enabled())
{
app_usbd_disable();
}
app_usbd_class_remove_all();
app_usbd_uninit();
}
void nrf5UartClearPendingData(void)
{
sUsbState.mTransferInProgress = false;
sUsbState.mTxBuffer = NULL;
sUsbState.mTxSize = 0;
}
void nrf5UartProcess(void)
{
while (app_usbd_event_queue_process())
{
}
processConnection();
processReceive();
processTransmit();
}
otError otPlatUartEnable(void)
{
sUsbState.mUartEnabled = true;
return OT_ERROR_NONE;
}
otError otPlatUartDisable(void)
{
sUsbState.mUartEnabled = false;
return OT_ERROR_NONE;
}
otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(sUsbState.mTransferInProgress == false, error = OT_ERROR_BUSY);
otEXPECT_ACTION(sUsbState.mTxBuffer == NULL, error = OT_ERROR_BUSY);
if (!isPortOpened())
{
// If port is closed, queue the message until it can be sent.
sUsbState.mTxBuffer = aBuf;
sUsbState.mTxSize = aBufLength;
}
else
{
otEXPECT_ACTION(app_usbd_cdc_acm_write(&sAppCdcAcm, aBuf, aBufLength) == NRF_SUCCESS, error = OT_ERROR_FAILED);
sUsbState.mTransferInProgress = true;
}
exit:
return error;
}
otError otPlatUartFlush(void)
{
return OT_ERROR_NOT_IMPLEMENTED;
}
#endif // USB_CDC_AS_SERIAL_TRANSPORT == 1
-121
View File
@@ -51,124 +51,6 @@ build_cc2538()
make -f examples/Makefile-cc2538 "${options[@]}"
}
build_nrf52811()
{
local options=(
"COAP=1"
"DNS_CLIENT=1"
"LINK_RAW=1"
"MAC_FILTER=1"
"MTD_NETDIAG=1"
)
# UART transport
reset_source
make -f examples/Makefile-nrf52811 "${options[@]}"
# SPI transport for NCP
reset_source
make -f examples/Makefile-nrf52811 "${options[@]}" NCP_SPI=1
# Build without transport (no CLI or NCP applications)
reset_source
make -f examples/Makefile-nrf52811 DISABLE_TRANSPORTS=1
}
build_nrf52833()
{
local options=(
"BORDER_AGENT=1"
"BORDER_ROUTER=1"
"COAP=1"
"COAPS=1"
"COMMISSIONER=1"
"DHCP6_CLIENT=1"
"DHCP6_SERVER=1"
"DNS_CLIENT=1"
"ECDSA=1"
"FULL_LOGS=1"
"IP6_FRAGM=1"
"JOINER=1"
"LINK_RAW=1"
"MAC_FILTER=1"
"MTD_NETDIAG=1"
"PING_SENDER=1"
"SERVICE=1"
"SLAAC=1"
"SNTP_CLIENT=1"
"SRP_CLIENT=1"
"UDP_FORWARD=1"
)
# UART transport
reset_source
make -f examples/Makefile-nrf52833 "${options[@]}"
# USB transport
reset_source
make -f examples/Makefile-nrf52833 "${options[@]}" USB=1
# SPI transport for NCP
reset_source
make -f examples/Makefile-nrf52833 "${options[@]}" NCP_SPI=1
# Build without transport (no CLI or NCP applications)
reset_source
make -f examples/Makefile-nrf52833 "${options[@]}" DISABLE_TRANSPORTS=1
}
build_nrf52840()
{
local options=(
"BORDER_AGENT=1"
"BORDER_ROUTER=1"
"COAP=1"
"COAPS=1"
"COMMISSIONER=1"
"DEBUG=1"
"DHCP6_CLIENT=1"
"DHCP6_SERVER=1"
"DNS_CLIENT=1"
"ECDSA=1"
"FULL_LOGS=1"
"IP6_FRAGM=1"
"JOINER=1"
"LINK_RAW=1"
"MAC_FILTER=1"
"MTD_NETDIAG=1"
"PING_SENDER=1"
"SERVICE=1"
"SLAAC=1"
"SNTP_CLIENT=1"
"SRP_CLIENT=1"
"UDP_FORWARD=1"
)
# UART transport
reset_source
make -f examples/Makefile-nrf52840 "${options[@]}"
# USB transport with bootloader e.g. to support PCA10059 dongle
reset_source
make -f examples/Makefile-nrf52840 "${options[@]}" BOOTLOADER=1 USB=1
# SPI transport for NCP
reset_source
make -f examples/Makefile-nrf52840 "${options[@]}" NCP_SPI=1
# Build without transport (no CLI or NCP applications)
reset_source
make -f examples/Makefile-nrf52840 "${options[@]}" DISABLE_TRANSPORTS=1
# Software cryptography
reset_source
make -f examples/Makefile-nrf52840 "${options[@]}" DISABLE_BUILTIN_MBEDTLS=0
# Software cryptography with threading support
reset_source
make -f examples/Makefile-nrf52840 "${options[@]}" DISABLE_BUILTIN_MBEDTLS=0 MBEDTLS_THREADING=1
}
main()
{
./bootstrap
@@ -177,9 +59,6 @@ main()
if [[ $# == 0 ]]; then
build_cc2538
build_nrf52811
build_nrf52833
build_nrf52840
return 0
fi
-28
View File
@@ -59,40 +59,12 @@ build_cc2538()
"$(dirname "$0")"/cmake-build cc2538 "${OT_COMMON_OPTIONS[@]}" "${OT_BASIC_CHECK_OPTIONS[@]}" "${options[@]}"
}
build_nrf52811()
{
reset_source
"$(dirname "$0")"/cmake-build nrf52811 "$1" "${OT_COMMON_OPTIONS[@]}"
}
build_nrf52833()
{
reset_source
"$(dirname "$0")"/cmake-build nrf52833 "$1" "${OT_COMMON_OPTIONS[@]}" "${OT_BASIC_CHECK_OPTIONS[@]}"
}
build_nrf52840()
{
reset_source
"$(dirname "$0")"/cmake-build nrf52840 "$1" "${OT_COMMON_OPTIONS[@]}" "${OT_BASIC_CHECK_OPTIONS[@]}"
}
main()
{
export CPPFLAGS="${CPPFLAGS:-} -DNDEBUG"
if [[ $# == 0 ]]; then
build_cc2538
# UART transport
build_nrf52840 UART_trans
# USB transport with bootloader e.g. to support PCA10059 dongle
build_nrf52840 USB_trans_bl
# SPI transport for NCP
build_nrf52840 SPI_trans_NCP
# Software cryptography
build_nrf52840 soft_crypto
# Software cryptography with threading support
build_nrf52840 soft_crypto_threading
return 0
fi
+1 -89
View File
@@ -42,10 +42,6 @@
#
# script/cmake-build ${platform} -D${option}=OFF
#
# Need to add build type when compilling nrf528xx:
#
# script/cmake-build ${platform} ${nrf_build_type} -D${option}=ON -D${option}=OFF
#
# Compile with the specified ninja build target:
#
# OT_CMAKE_NINJA_TARGET="ot-cli-ftd" script/cmake-build ${platform}
@@ -68,8 +64,7 @@ set -euxo pipefail
OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-}
readonly OT_SRCDIR="$(pwd)"
readonly OT_PLATFORMS=(cc2538 nrf52811 nrf52833 nrf52840 simulation posix)
readonly OT_NRF528XX_BUILD_TYPES=(UART_trans USB_trans_bl SPI_trans_NCP soft_crypto soft_crypto_threading)
readonly OT_PLATFORMS=(cc2538 simulation posix)
readonly OT_POSIX_SIM_COMMON_OPTIONS=(
"-DOT_BORDER_AGENT=ON"
"-DOT_BORDER_ROUTER=ON"
@@ -105,33 +100,6 @@ readonly OT_POSIX_SIM_COMMON_OPTIONS=(
"-DOT_RCP_RESTORATION_MAX_COUNT=2"
)
readonly OT_nrf52811_OPTIONS=(
"-DOT_BORDER_ROUTER=ON"
"-DOT_COAP=ON"
"-DOT_DNS_CLIENT=ON"
"-DOT_LINK_RAW=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_MTD_NETDIAG=ON"
)
readonly OT_nrf52833_OPTIONS=(
"-DOT_BORDER_AGENT=ON"
"-DOT_BORDER_ROUTER=ON"
"-DOT_COAP=ON"
"-DOT_COAPS=ON"
"-DOT_ECDSA=ON"
"-DOT_FULL_LOGS=ON"
"-DOT_IP6_FRAGM=ON"
"-DOT_LINK_RAW=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_MTD_NETDIAG=ON"
"-DOT_SERVICE=ON"
"-DOT_SNTP_CLIENT=ON"
"-DOT_UDP_FORWARD=ON"
)
readonly OT_nrf52840_OPTIONS=("${OT_nrf52833_OPTIONS[@]:0}")
die()
{
echo " ** ERROR: Openthread CMake doesn't support platform \"$1\""
@@ -169,13 +137,6 @@ main()
# Check if the platform supports cmake.
echo "${OT_PLATFORMS[@]}" | grep -wq "${platform}" || die "${platform}"
local nrf_build_type=""
if [[ ${platform} == nrf528* ]]; then
nrf_build_type="$2"
echo "${OT_NRF528XX_BUILD_TYPES[@]}" | grep -wq "${nrf_build_type}" || die "${nrf_build_type}"
shift
fi
shift
local local_options=()
local options=(
@@ -198,55 +159,6 @@ main()
cc2538)
options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel")
;;
nrf52811)
local_options+=("${OT_nrf52811_OPTIONS[@]}" "-DCMAKE_TOOLCHAIN_FILE=examples/platforms/nrf528xx/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=Release")
case "${nrf_build_type}" in
UART_trans)
OT_CMAKE_NINJA_TARGET=("ot-cli-mtd" "ot-ncp-mtd" "ot-rcp")
options+=("${local_options[@]}")
;;
SPI_trans_NCP)
OT_CMAKE_NINJA_TARGET=("ot-ncp-mtd" "ot-rcp")
options+=("${local_options[@]}" "-DOT_NCP_SPI=ON")
;;
esac
;;
nrf52833)
local_options+=("${OT_nrf52833_OPTIONS[@]}" "-DCMAKE_TOOLCHAIN_FILE=examples/platforms/nrf528xx/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=Release")
case "${nrf_build_type}" in
UART_trans)
options+=("${local_options[@]}")
;;
USB_trans_bl)
options+=("${local_options[@]}" "-DOT_USB=ON" "-DOT_BOOTLOADER=USB")
;;
SPI_trans_NCP)
OT_CMAKE_NINJA_TARGET=("ot-ncp-ftd" "ot-ncp-mtd" "ot-rcp")
options+=("${local_options[@]}" "-DOT_NCP_SPI=ON")
;;
esac
;;
nrf52840)
local_options+=("${OT_nrf52840_OPTIONS[@]}" "-DCMAKE_TOOLCHAIN_FILE=examples/platforms/nrf528xx/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=Release")
case "${nrf_build_type}" in
UART_trans)
options+=("${local_options[@]}" "-DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls")
;;
USB_trans_bl)
options+=("${local_options[@]}" "-DOT_USB=ON" "-DOT_BOOTLOADER=USB" "-DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls")
;;
SPI_trans_NCP)
OT_CMAKE_NINJA_TARGET=("ot-ncp-ftd" "ot-ncp-mtd" "ot-rcp")
options+=("${local_options[@]}" "-DOT_NCP_SPI=ON" "-DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls")
;;
soft_crypto)
options+=("${local_options[@]}")
;;
soft_crypto_threading)
options+=("${local_options[@]}" "-DOT_MBEDTLS_THREADING=ON")
;;
esac
;;
*)
options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake")
;;
-5
View File
@@ -29,8 +29,3 @@
if(NOT OT_EXTERNAL_MBEDTLS)
add_subdirectory(mbedtls)
endif()
if(OT_PLATFORM MATCHES "^nrf*")
add_subdirectory(jlink)
add_subdirectory(NordicSemiconductor)
endif()
+1 -37
View File
@@ -31,7 +31,6 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
EXTRA_DIST = \
nlbuild-autotools \
openthread-test-driver \
NordicSemiconductor \
$(NULL)
# Always package (e.g. for 'make dist') these subdirectories.
@@ -41,43 +40,8 @@ DIST_SUBDIRS = \
mbedtls \
$(NULL)
SUBDIRS =
if OPENTHREAD_PLATFORM_NRF52811
SUBDIRS += \
NordicSemiconductor \
SUBDIRS = \
$(NULL)
endif
if OPENTHREAD_EXAMPLES_NRF52811
SUBDIRS += \
jlink \
$(NULL)
endif
if OPENTHREAD_PLATFORM_NRF52833
SUBDIRS += \
NordicSemiconductor \
$(NULL)
endif
if OPENTHREAD_EXAMPLES_NRF52833
SUBDIRS += \
jlink \
$(NULL)
endif
if OPENTHREAD_PLATFORM_NRF52840
SUBDIRS += \
NordicSemiconductor \
$(NULL)
endif
if OPENTHREAD_EXAMPLES_NRF52840
SUBDIRS += \
jlink \
$(NULL)
endif
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
SUBDIRS += \
-375
View File
@@ -1,375 +0,0 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
set(COMMON_INCLUDES
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/core
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/fem
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/fem/three_pin_gpio
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/mac_features
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/mac_features/ack_generator
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/platform/temperature
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/platform/lp_timer
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/rsch
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/rsch/raal
${CMAKE_CURRENT_SOURCE_DIR}/drivers/radio/rsch/raal/softdevice
)
set(EXAMPLE_INCLUDES
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/cmsis
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/dependencies
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/drivers/clock
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/drivers/common
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/drivers/power
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/drivers/systick
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/drivers/usbd
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/app_error
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/atfifo
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/atomic
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/block_dev
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/delay
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/usb
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/usb/config
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/usb/class/cdc
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/utf_converter
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/hal
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/drivers
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/drivers/include
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/mdk
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/soc
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/softdevice/s140/headers
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/softdevice/s140/headers/nrf52
)
set(COMMON_FLAG
-DSPIS_ENABLED=1
-DSPIS0_ENABLED=1
-DNRFX_SPIS_ENABLED=1
-DNRFX_SPIS0_ENABLED=1
-DCONFIG_GPIO_AS_PINRESET
-DENABLE_FEM=1
-DUSE_APP_CONFIG=1
)
set(COMMON_SOURCES
dependencies/app_util_platform.c
drivers/clock/nrf_drv_clock.c
drivers/power/nrf_drv_power.c
libraries/app_error/app_error.c
libraries/app_error/app_error_weak.c
libraries/utf_converter/utf.c
nrfx/drivers/src/nrfx_clock.c
nrfx/drivers/src/nrfx_nvmc.c
nrfx/drivers/src/nrfx_power.c
nrfx/drivers/src/nrfx_spis.c
nrfx/drivers/src/nrfx_systick.c
nrfx/hal/nrf_nvmc.c
nrfx/soc/nrfx_atomic.c
)
set(USB_SOURCES
nrfx/drivers/src/nrfx_usbd.c
libraries/atfifo/nrf_atfifo.c
libraries/atomic/nrf_atomic.c
libraries/usb/app_usbd.c
libraries/usb/app_usbd_core.c
libraries/usb/app_usbd_string_desc.c
libraries/usb/app_usbd_serial_num.c
libraries/usb/app_usbd_nrf_dfu_trigger.c
libraries/usb/nrf_dfu_trigger_usb.c
libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c
)
set(RADIO_DRIVER_SOURCES
drivers/radio/fal/nrf_802154_fal.c
drivers/radio/mac_features/ack_generator/nrf_802154_ack_data.c
drivers/radio/mac_features/ack_generator/nrf_802154_ack_generator.c
drivers/radio/mac_features/ack_generator/nrf_802154_enh_ack_generator.c
drivers/radio/mac_features/ack_generator/nrf_802154_imm_ack_generator.c
drivers/radio/mac_features/nrf_802154_csma_ca.c
drivers/radio/mac_features/nrf_802154_delayed_trx.c
drivers/radio/mac_features/nrf_802154_filter.c
drivers/radio/mac_features/nrf_802154_frame_parser.c
drivers/radio/mac_features/nrf_802154_precise_ack_timeout.c
drivers/radio/fem/three_pin_gpio/nrf_fem_three_pin_gpio.c
drivers/radio/nrf_802154_core_hooks.c
drivers/radio/nrf_802154_core.c
drivers/radio/nrf_802154_critical_section.c
drivers/radio/nrf_802154_debug.c
drivers/radio/nrf_802154_pib.c
drivers/radio/nrf_802154_rssi.c
drivers/radio/nrf_802154_rx_buffer.c
drivers/radio/nrf_802154_timer_coord.c
drivers/radio/nrf_802154.c
drivers/radio/platform/coex/nrf_802154_wifi_coex_none.c
drivers/radio/platform/clock/nrf_802154_clock_ot.c
drivers/radio/platform/hp_timer/nrf_802154_hp_timer.c
drivers/radio/rsch/nrf_802154_rsch_crit_sect.c
drivers/radio/rsch/nrf_802154_rsch.c
drivers/radio/timer_scheduler/nrf_802154_timer_sched.c
)
set(SINGLE_PHY_SOURCES
drivers/radio/nrf_802154_notification_direct.c
drivers/radio/nrf_802154_priority_drop_direct.c
drivers/radio/nrf_802154_request_direct.c
drivers/radio/rsch/raal/single_phy/single_phy.c
)
set(RADIO_DRIVER_SOFTDEVICE_SOURCES
drivers/radio/nrf_802154_notification_swi.c
drivers/radio/nrf_802154_priority_drop_swi.c
drivers/radio/nrf_802154_request_swi.c
drivers/radio/nrf_802154_swi.c
drivers/radio/rsch/raal/softdevice/nrf_raal_softdevice.c
)
set(RADIO_DRIVER_SINGLE_PHY_SOURCES
drivers/radio/nrf_802154_notification_direct.c
drivers/radio/nrf_802154_priority_drop_direct.c
drivers/radio/nrf_802154_request_direct.c
drivers/radio/rsch/raal/single_phy/single_phy.c
)
if(OT_PLATFORM STREQUAL "nrf52811")
add_library(nordicsemi-nrf52811-sdk)
target_compile_definitions(nordicsemi-nrf52811-sdk
PRIVATE
${COMMON_FLAG}
-DNRF52811_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
-D__HEAP_SIZE=0
-D__STACK_SIZE=2048
)
target_include_directories(nordicsemi-nrf52811-sdk
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52811
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52811/config
)
set_property(SOURCE nrfx/mdk/gcc_startup_nrf52811.S PROPERTY LANGUAGE C)
target_sources(nordicsemi-nrf52811-sdk
PRIVATE
${COMMON_SOURCES}
nrfx/mdk/gcc_startup_nrf52811.S
nrfx/mdk/system_nrf52811.c
)
target_link_libraries(nordicsemi-nrf52811-sdk PRIVATE ot-config)
add_library(nordicsemi-nrf52811-radio-driver)
target_compile_definitions(nordicsemi-nrf52811-radio-driver
PRIVATE
${COMMON_FLAG}
-DNRF52811_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
-D__HEAP_SIZE=0
-D__STACK_SIZE=2048
-DRAAL_SINGLE_PHY=1
)
target_include_directories(nordicsemi-nrf52811-radio-driver
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52811
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52811/config
)
target_sources(nordicsemi-nrf52811-radio-driver
PRIVATE
${RADIO_DRIVER_SOURCES}
${RADIO_DRIVER_SINGLE_PHY_SOURCES}
)
elseif(OT_PLATFORM STREQUAL "nrf52833")
add_library(nordicsemi-nrf52833-sdk)
target_compile_definitions(nordicsemi-nrf52833-sdk
PRIVATE
${COMMON_FLAG}
-DNRF52833_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
)
target_include_directories(nordicsemi-nrf52833-sdk
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52833
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52833/config
)
set_property(SOURCE nrfx/mdk/gcc_startup_nrf52833.S PROPERTY LANGUAGE C)
target_sources(nordicsemi-nrf52833-sdk
PRIVATE
${COMMON_SOURCES}
${USB_SOURCES}
nrfx/mdk/gcc_startup_nrf52833.S
nrfx/mdk/system_nrf52833.c
)
target_link_libraries(nordicsemi-nrf52833-sdk PRIVATE ot-config)
add_library(nordicsemi-nrf52833-radio-driver)
target_compile_definitions(nordicsemi-nrf52833-radio-driver
PRIVATE
${COMMON_FLAG}
-DNRF52833_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
-DRAAL_SINGLE_PHY=1
)
target_include_directories(nordicsemi-nrf52833-radio-driver
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52833
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52833/config
)
target_sources(nordicsemi-nrf52833-radio-driver
PRIVATE
${RADIO_DRIVER_SOURCES}
${RADIO_DRIVER_SINGLE_PHY_SOURCES}
)
add_library(nordicsemi-nrf52833-radio-driver-softdevice)
target_compile_definitions(nordicsemi-nrf52833-radio-driver-softdevice
PRIVATE
${COMMON_FLAG}
-DNRF52833_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
-DRAAL_SINGLE_PHY=1
-DSOFTDEVICE_PRESENT
-DS140
-DRAAL_SOFTDEVICE=1
)
target_include_directories(nordicsemi-nrf52833-radio-driver-softdevice
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52833
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52833/config
)
target_sources(nordicsemi-nrf52833-radio-driver-softdevice
PRIVATE
${RADIO_DRIVER_SOURCES}
${RADIO_DRIVER_SINGLE_PHY_SOURCES}
)
elseif(OT_PLATFORM STREQUAL "nrf52840")
add_library(nordicsemi-nrf52840-sdk)
target_compile_definitions(nordicsemi-nrf52840-sdk
PRIVATE
${COMMON_FLAG}
-DNRF52840_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
)
target_include_directories(nordicsemi-nrf52840-sdk
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52840/
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52840/config
)
set_property(SOURCE nrfx/mdk/gcc_startup_nrf52840.S PROPERTY LANGUAGE C)
target_sources(nordicsemi-nrf52840-sdk
PRIVATE
${COMMON_SOURCES}
${USB_SOURCES}
nrfx/mdk/gcc_startup_nrf52840.S
nrfx/mdk/system_nrf52840.c
)
target_link_libraries(nordicsemi-nrf52840-sdk PRIVATE ot-config)
add_library(nordicsemi-nrf52840-radio-driver)
target_compile_definitions(nordicsemi-nrf52840-radio-driver
PRIVATE
${COMMON_FLAG}
-DNRF52840_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
-DRAAL_SINGLE_PHY=1
)
target_include_directories(nordicsemi-nrf52840-radio-driver
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52840/
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52840/config
)
target_sources(nordicsemi-nrf52840-radio-driver
PRIVATE
${RADIO_DRIVER_SOURCES}
${RADIO_DRIVER_SINGLE_PHY_SOURCES}
)
add_library(nordicsemi-nrf52840-radio-driver-softdevice)
target_compile_definitions(nordicsemi-nrf52840-radio-driver-softdevice
PRIVATE
${COMMON_FLAG}
-DNRF52840_XXAA
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\"
-DRAAL_SINGLE_PHY=1
-DSOFTDEVICE_PRESENT
-DS140
-DRAAL_SOFTDEVICE=1
)
target_include_directories(nordicsemi-nrf52840-radio-driver-softdevice
PUBLIC
${COMMON_INCLUDES}
${EXAMPLE_INCLUDES}
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/nrf52840/
${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/nrf52840/config
)
target_sources(nordicsemi-nrf52840-radio-driver-softdevice
PRIVATE
${RADIO_DRIVER_SOURCES}
${RADIO_DRIVER_SINGLE_PHY_SOURCES}
)
else()
message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}")
endif()
add_library(nordicsemi-mbedtls INTERFACE)
target_link_libraries(nordicsemi-mbedtls
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedcrypto_shared.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedtls_tls_vanilla.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedtls_x509_vanilla.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedcrypto_cc3xx.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libnrf_cc310_platform_0.9.4.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedcrypto_oberon.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedtls_base_vanilla.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedcrypto_cc3xx.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedtls_base_vanilla.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libmbedcrypto_shared.a
${CMAKE_CURRENT_SOURCE_DIR}/libraries/nrf_security/lib/libnrf_cc310_platform_0.9.4.a
)
-541
View File
@@ -1,541 +0,0 @@
#
# Copyright (c) 2016-2019, The OpenThread Authors.
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = \
$(NULL)
# Build radio drivers when building platform libraries.
if OPENTHREAD_PLATFORM_NRF52811
lib_LIBRARIES += \
libnordicsemi-nrf52811-radio-driver.a \
$(NULL)
endif
if OPENTHREAD_PLATFORM_NRF52833
lib_LIBRARIES += \
libnordicsemi-nrf52833-radio-driver.a \
libnordicsemi-nrf52833-radio-driver-softdevice.a \
$(NULL)
endif
if OPENTHREAD_PLATFORM_NRF52840
lib_LIBRARIES += \
libnordicsemi-nrf52840-radio-driver.a \
libnordicsemi-nrf52840-radio-driver-softdevice.a \
$(NULL)
endif
# Only build the SDK library when building the example applications.
if OPENTHREAD_EXAMPLES_NRF52811
lib_LIBRARIES += \
libnordicsemi-nrf52811-sdk.a \
$(NULL)
endif
if OPENTHREAD_EXAMPLES_NRF52833
lib_LIBRARIES += \
libnordicsemi-nrf52833-sdk.a \
$(NULL)
endif
if OPENTHREAD_EXAMPLES_NRF52840
lib_LIBRARIES += \
libnordicsemi-nrf52840-sdk.a \
$(NULL)
endif
# Do not enable -pedantic-errors for Nordic Semiconductor driver library
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for Nordic Semiconductor driver library
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
# Do not enable -Wcast-align for Nordic Semiconductor driver library
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
CFLAGS += -Wno-unused-but-set-variable
CXXFLAGS += -Wno-unused-but-set-variable
COMMONCPPFLAGS = \
-DCONFIG_GPIO_AS_PINRESET \
-DENABLE_FEM=1 \
-DUSE_APP_CONFIG=1 \
-I$(srcdir) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/softdevice \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator \
$(NULL)
# Only reference the SDK header files included in third_party/NordicSemiconductor
# when building the example applications.
#
# When building just the platform libraries, the caller of configure is expected
# to provide the correct -I arguments to locate the necessary header files in an
# external copy of the Nordic nRF5 SDK.
#
# Note that an exception is made for the 802.15.4 radio driver, which is always built
# using the sources in third_party/NordicSemiconductor/drivers/radio.
if OPENTHREAD_ENABLE_EXAMPLES
COMMONCPPFLAGS += \
-I$(top_srcdir)/third_party/NordicSemiconductor \
-I$(top_srcdir)/third_party/NordicSemiconductor/cmsis \
-I$(top_srcdir)/third_party/NordicSemiconductor/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/dependencies \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/clock \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/common \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/power \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/systick \
-I$(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm \
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk \
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/soc \
-I$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers \
-I$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf52 \
-Wno-unused-parameter \
$(NULL)
NRF52811_CPPFLAGS = \
-DNRF52811_XXAA \
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\" \
-D__HEAP_SIZE=0 \
-D__STACK_SIZE=2048 \
-I$(top_srcdir)/examples/platforms/nrf528xx/nrf52811 \
-I$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52811/config \
$(NULL)
endif
NRF52833_CPPFLAGS = \
-DNRF52833_XXAA \
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\" \
-I$(top_srcdir)/examples/platforms/nrf52833 \
-I$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52833/config \
$(NULL)
NRF52840_CPPFLAGS = \
-DNRF52840_XXAA \
-DNRF_802154_PROJECT_CONFIG=\"platform-config.h\" \
-I$(top_srcdir)/examples/platforms/nrf528xx/nrf52840/ \
-I$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52840/config \
$(NULL)
NORDICSEMI_COMMON_SOURCES = \
dependencies/app_util_platform.c \
drivers/clock/nrf_drv_clock.c \
drivers/power/nrf_drv_power.c \
libraries/app_error/app_error.c \
libraries/app_error/app_error_weak.c \
libraries/utf_converter/utf.c \
nrfx/drivers/src/nrfx_clock.c \
nrfx/drivers/src/nrfx_nvmc.c \
nrfx/drivers/src/nrfx_power.c \
nrfx/drivers/src/nrfx_spis.c \
nrfx/drivers/src/nrfx_systick.c \
nrfx/hal/nrf_nvmc.c \
nrfx/soc/nrfx_atomic.c \
$(NULL)
NORDICSEMI_USB_SOURCES = \
nrfx/drivers/src/nrfx_usbd.c \
libraries/atfifo/nrf_atfifo.c \
libraries/atomic/nrf_atomic.c \
libraries/usb/app_usbd.c \
libraries/usb/app_usbd_core.c \
libraries/usb/app_usbd_string_desc.c \
libraries/usb/app_usbd_serial_num.c \
libraries/usb/app_usbd_nrf_dfu_trigger.c \
libraries/usb/nrf_dfu_trigger_usb.c \
libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c \
$(NULL)
NORDICSEMI_NRF52811_SOURCES = \
nrfx/mdk/gcc_startup_nrf52811.S \
nrfx/mdk/system_nrf52811.c \
$(NULL)
NORDICSEMI_NRF52833_SOURCES = \
nrfx/mdk/gcc_startup_nrf52833.S \
nrfx/mdk/system_nrf52833.c \
$(NULL)
NORDICSEMI_NRF52840_SOURCES = \
nrfx/mdk/gcc_startup_nrf52840.S \
nrfx/mdk/system_nrf52840.c \
$(NULL)
RADIO_DRIVER_SOURCES = \
drivers/radio/fal/nrf_802154_fal.c \
drivers/radio/mac_features/ack_generator/nrf_802154_ack_data.c \
drivers/radio/mac_features/ack_generator/nrf_802154_ack_generator.c \
drivers/radio/mac_features/ack_generator/nrf_802154_enh_ack_generator.c \
drivers/radio/mac_features/ack_generator/nrf_802154_imm_ack_generator.c \
drivers/radio/mac_features/nrf_802154_csma_ca.c \
drivers/radio/mac_features/nrf_802154_delayed_trx.c \
drivers/radio/mac_features/nrf_802154_filter.c \
drivers/radio/mac_features/nrf_802154_frame_parser.c \
drivers/radio/mac_features/nrf_802154_precise_ack_timeout.c \
drivers/radio/fem/three_pin_gpio/nrf_fem_three_pin_gpio.c \
drivers/radio/nrf_802154_core_hooks.c \
drivers/radio/nrf_802154_core.c \
drivers/radio/nrf_802154_critical_section.c \
drivers/radio/nrf_802154_debug.c \
drivers/radio/nrf_802154_pib.c \
drivers/radio/nrf_802154_rssi.c \
drivers/radio/nrf_802154_rx_buffer.c \
drivers/radio/nrf_802154_timer_coord.c \
drivers/radio/nrf_802154.c \
drivers/radio/platform/coex/nrf_802154_wifi_coex_none.c \
drivers/radio/platform/clock/nrf_802154_clock_ot.c \
drivers/radio/platform/hp_timer/nrf_802154_hp_timer.c \
drivers/radio/rsch/nrf_802154_rsch_crit_sect.c \
drivers/radio/rsch/nrf_802154_rsch.c \
drivers/radio/timer_scheduler/nrf_802154_timer_sched.c \
$(NULL)
RADIO_DRIVER_SINGLE_PHY_SOURCES = \
drivers/radio/nrf_802154_notification_direct.c \
drivers/radio/nrf_802154_priority_drop_direct.c \
drivers/radio/nrf_802154_request_direct.c \
drivers/radio/rsch/raal/single_phy/single_phy.c \
$(NULL)
RADIO_DRIVER_SINGLE_PHY_CPPFLAGS = \
-DRAAL_SINGLE_PHY=1 \
$(NULL)
RADIO_DRIVER_SOFTDEVICE_SOURCES = \
drivers/radio/nrf_802154_notification_swi.c \
drivers/radio/nrf_802154_priority_drop_swi.c \
drivers/radio/nrf_802154_request_swi.c \
drivers/radio/nrf_802154_swi.c \
drivers/radio/rsch/raal/softdevice/nrf_raal_softdevice.c \
$(NULL)
RADIO_DRIVER_SOFTDEVICE_CPPFLAGS = \
-DRAAL_SOFTDEVICE=1 \
$(NULL)
SOFTDEVICE_CPPFLAGS = \
-DSOFTDEVICE_PRESENT \
-DS140 \
-DRAAL_SOFTDEVICE=1 \
$(NULL)
libnordicsemi_nrf52811_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52811_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52811_sdk_a_SOURCES = \
$(NORDICSEMI_COMMON_SOURCES) \
$(NORDICSEMI_NRF52811_SOURCES) \
$(NULL)
libnordicsemi_nrf52811_radio_driver_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52811_CPPFLAGS) \
$(RADIO_DRIVER_SINGLE_PHY_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52811_radio_driver_a_SOURCES = \
$(RADIO_DRIVER_SOURCES) \
$(RADIO_DRIVER_SINGLE_PHY_SOURCES) \
$(NULL)
libnordicsemi_nrf52833_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52833_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52833_sdk_a_SOURCES = \
$(NORDICSEMI_COMMON_SOURCES) \
$(NORDICSEMI_USB_SOURCES) \
$(NORDICSEMI_NRF52833_SOURCES) \
$(NULL)
libnordicsemi_nrf52833_radio_driver_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52833_CPPFLAGS) \
$(RADIO_DRIVER_SINGLE_PHY_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52833_radio_driver_a_SOURCES = \
$(RADIO_DRIVER_SOURCES) \
$(RADIO_DRIVER_SINGLE_PHY_SOURCES) \
$(NULL)
libnordicsemi_nrf52833_radio_driver_softdevice_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52833_CPPFLAGS) \
$(SOFTDEVICE_CPPFLAGS) \
$(RADIO_DRIVER_SOFTDEVICE_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52833_radio_driver_softdevice_a_SOURCES = \
$(RADIO_DRIVER_SOURCES) \
$(RADIO_DRIVER_SOFTDEVICE_SOURCES) \
$(NULL)
libnordicsemi_nrf52840_sdk_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52840_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52840_sdk_a_SOURCES = \
$(NORDICSEMI_COMMON_SOURCES) \
$(NORDICSEMI_USB_SOURCES) \
$(NORDICSEMI_NRF52840_SOURCES) \
$(NULL)
libnordicsemi_nrf52840_radio_driver_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52840_CPPFLAGS) \
$(RADIO_DRIVER_SINGLE_PHY_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52840_radio_driver_a_SOURCES = \
$(RADIO_DRIVER_SOURCES) \
$(RADIO_DRIVER_SINGLE_PHY_SOURCES) \
$(NULL)
libnordicsemi_nrf52840_radio_driver_softdevice_a_CPPFLAGS = \
$(COMMONCPPFLAGS) \
$(NRF52840_CPPFLAGS) \
$(SOFTDEVICE_CPPFLAGS) \
$(RADIO_DRIVER_SOFTDEVICE_CPPFLAGS) \
$(NULL)
libnordicsemi_nrf52840_radio_driver_softdevice_a_SOURCES = \
$(RADIO_DRIVER_SOURCES) \
$(RADIO_DRIVER_SOFTDEVICE_SOURCES) \
$(NULL)
noinst_HEADERS = \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/arm_math.h \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_armcc_V6.h \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_armcc.h \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/cmsis_gcc.h \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cm4.h \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmFunc.h \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmInstr.h \
$(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmSimd.h \
$(top_srcdir)/third_party/NordicSemiconductor/config/app_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52811/config/sdk_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52833/config/sdk_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/config/nrf52840/config/sdk_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util_platform.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/legacy/apply_old_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nordic_common.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_assert.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_error.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_instance.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_internal.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_types.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_ctrl.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_ctrl_internal.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_section.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_glue.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_log.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_common.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_errors.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_macros.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_os.h \
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/sdk_resources.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/common/nrf_drv_common.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/systick/nrf_drv_systick.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd_errata.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fal/nrf_802154_fal.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/none/nrf_fem_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_protocol_api.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_protocol_legacy_api.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/simple_gpio/nrf_fem_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio/nrf_fem_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator/nrf_802154_ack_data.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator/nrf_802154_ack_generator.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator/nrf_802154_enh_ack_generator.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator/nrf_802154_imm_ack_generator.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_ack_timeout.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_csma_ca.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_delayed_trx.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_const.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core_hooks.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_critical_section.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug_core.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_debug.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_notification.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_peripherals.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_pib.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_priority_drop.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_procedures_duration.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_request.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rssi.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rx_buffer.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_swi.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_timer_coord.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_types.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/nrf_802154_utils.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/clock/nrf_802154_clock.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/coex/nrf_802154_wifi_coex.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/hp_timer/nrf_802154_hp_timer.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/lp_timer/nrf_802154_lp_timer.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/random/nrf_802154_random.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/platform/temperature/nrf_802154_temperature.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/nrf_802154_rsch_crit_sect.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/nrf_802154_rsch.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/nrf_raal_api.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/nrf_raal_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/simulator/nrf_802154_debug.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/softdevice/nrf_802154_debug.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/softdevice/nrf_raal_softdevice.h \
$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error/app_error_weak.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error/app_error.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo_internal.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev/nrf_block_dev.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay/nrf_delay.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_langid.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_request.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_types.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_internal.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config/app_usbd_string_config.h \
$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter/utf.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_common.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_errors.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_clock.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_nvmc.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_power_clock.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_power.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_spis.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_systick.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_usbd.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/src/nrfx_usbd_errata.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_clock.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_gpio.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_gpiote.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_egu.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_nvmc.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_ppi.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_power.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_rng.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_spis.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_uart.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal/nrf_usbd.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/compiler_abstraction.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf_peripherals.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf51_to_nrf52.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf51_to_nrf52810.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52_to_nrf52810.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf51_to_nrf52840.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52_to_nrf52833.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52_to_nrf52840.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52810_to_nrf52811.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52811.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52811_bitfields.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52811_peripherals.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52833.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52833_bitfields.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52833_peripherals.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/system_nrf52833.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840_bitfields.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/nrf52840_peripherals.h \
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/mdk/system_nrf52840.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_err.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gap.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gatt.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gattc.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_gatts.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_hci.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_l2cap.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_ranges.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/ble_types.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error_sdm.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_error_soc.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_nvic.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_sdm.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_soc.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf_svc.h \
$(top_srcdir)/third_party/NordicSemiconductor/softdevice/s140/headers/nrf52/nrf_mbr.h \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
-15
View File
@@ -1,15 +0,0 @@
Description:
This folder consists of selected components from the nRF5 SDK, that are used
in process of building the OpenThread's nRF528xx platform.
Directory consists of following folders:
- /cmsis - Core Peripheral Access Layer Headers files
- /dependencies - Dependencies for drivers and libraries from nRF5 SDK
- /drivers - Drivers for the nRF528xx platform
- /libraries - Libraries for the nRF528xx platform
- /nrfx - Standalone drivers for peripherals present in Nordic SoCs (https://github.com/NordicSemiconductor/nrfx)
- /segger_rtt - Configuration files for RTT communication
- /softdevice - SoftDevice s140 headers
The following changes comparing to the nRF5 SDK 16.0 have been incorporated:
- modified nrf_log module files in order to remove unused backend logging functions
File diff suppressed because it is too large Load Diff
-734
View File
@@ -1,734 +0,0 @@
/**************************************************************************//**
* @file cmsis_armcc.h
* @brief CMSIS Cortex-M Core Function/Instruction Header File
* @version V4.30
* @date 20. October 2015
******************************************************************************/
/* Copyright (c) 2009 - 2015 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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 __CMSIS_ARMCC_H
#define __CMSIS_ARMCC_H
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
#endif
/* ########################### Core Function Access ########################### */
/** \ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
@{
*/
/* intrinsic void __enable_irq(); */
/* intrinsic void __disable_irq(); */
/**
\brief Get Control Register
\details Returns the content of the Control Register.
\return Control Register value
*/
__STATIC_INLINE uint32_t __get_CONTROL(void)
{
register uint32_t __regControl __ASM("control");
return(__regControl);
}
/**
\brief Set Control Register
\details Writes the given value to the Control Register.
\param [in] control Control Register value to set
*/
__STATIC_INLINE void __set_CONTROL(uint32_t control)
{
register uint32_t __regControl __ASM("control");
__regControl = control;
}
/**
\brief Get IPSR Register
\details Returns the content of the IPSR Register.
\return IPSR Register value
*/
__STATIC_INLINE uint32_t __get_IPSR(void)
{
register uint32_t __regIPSR __ASM("ipsr");
return(__regIPSR);
}
/**
\brief Get APSR Register
\details Returns the content of the APSR Register.
\return APSR Register value
*/
__STATIC_INLINE uint32_t __get_APSR(void)
{
register uint32_t __regAPSR __ASM("apsr");
return(__regAPSR);
}
/**
\brief Get xPSR Register
\details Returns the content of the xPSR Register.
\return xPSR Register value
*/
__STATIC_INLINE uint32_t __get_xPSR(void)
{
register uint32_t __regXPSR __ASM("xpsr");
return(__regXPSR);
}
/**
\brief Get Process Stack Pointer
\details Returns the current value of the Process Stack Pointer (PSP).
\return PSP Register value
*/
__STATIC_INLINE uint32_t __get_PSP(void)
{
register uint32_t __regProcessStackPointer __ASM("psp");
return(__regProcessStackPointer);
}
/**
\brief Set Process Stack Pointer
\details Assigns the given value to the Process Stack Pointer (PSP).
\param [in] topOfProcStack Process Stack Pointer value to set
*/
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
{
register uint32_t __regProcessStackPointer __ASM("psp");
__regProcessStackPointer = topOfProcStack;
}
/**
\brief Get Main Stack Pointer
\details Returns the current value of the Main Stack Pointer (MSP).
\return MSP Register value
*/
__STATIC_INLINE uint32_t __get_MSP(void)
{
register uint32_t __regMainStackPointer __ASM("msp");
return(__regMainStackPointer);
}
/**
\brief Set Main Stack Pointer
\details Assigns the given value to the Main Stack Pointer (MSP).
\param [in] topOfMainStack Main Stack Pointer value to set
*/
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
{
register uint32_t __regMainStackPointer __ASM("msp");
__regMainStackPointer = topOfMainStack;
}
/**
\brief Get Priority Mask
\details Returns the current state of the priority mask bit from the Priority Mask Register.
\return Priority Mask value
*/
__STATIC_INLINE uint32_t __get_PRIMASK(void)
{
register uint32_t __regPriMask __ASM("primask");
return(__regPriMask);
}
/**
\brief Set Priority Mask
\details Assigns the given value to the Priority Mask Register.
\param [in] priMask Priority Mask
*/
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
{
register uint32_t __regPriMask __ASM("primask");
__regPriMask = (priMask);
}
#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
/**
\brief Enable FIQ
\details Enables FIQ interrupts by clearing the F-bit in the CPSR.
Can only be executed in Privileged modes.
*/
#define __enable_fault_irq __enable_fiq
/**
\brief Disable FIQ
\details Disables FIQ interrupts by setting the F-bit in the CPSR.
Can only be executed in Privileged modes.
*/
#define __disable_fault_irq __disable_fiq
/**
\brief Get Base Priority
\details Returns the current value of the Base Priority register.
\return Base Priority register value
*/
__STATIC_INLINE uint32_t __get_BASEPRI(void)
{
register uint32_t __regBasePri __ASM("basepri");
return(__regBasePri);
}
/**
\brief Set Base Priority
\details Assigns the given value to the Base Priority register.
\param [in] basePri Base Priority value to set
*/
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
{
register uint32_t __regBasePri __ASM("basepri");
__regBasePri = (basePri & 0xFFU);
}
/**
\brief Set Base Priority with condition
\details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
or the new value increases the BASEPRI priority level.
\param [in] basePri Base Priority value to set
*/
__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
{
register uint32_t __regBasePriMax __ASM("basepri_max");
__regBasePriMax = (basePri & 0xFFU);
}
/**
\brief Get Fault Mask
\details Returns the current value of the Fault Mask register.
\return Fault Mask register value
*/
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
{
register uint32_t __regFaultMask __ASM("faultmask");
return(__regFaultMask);
}
/**
\brief Set Fault Mask
\details Assigns the given value to the Fault Mask register.
\param [in] faultMask Fault Mask value to set
*/
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
{
register uint32_t __regFaultMask __ASM("faultmask");
__regFaultMask = (faultMask & (uint32_t)1);
}
#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */
#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U)
/**
\brief Get FPSCR
\details Returns the current value of the Floating Point Status/Control register.
\return Floating Point Status/Control register value
*/
__STATIC_INLINE uint32_t __get_FPSCR(void)
{
#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U)
register uint32_t __regfpscr __ASM("fpscr");
return(__regfpscr);
#else
return(0U);
#endif
}
/**
\brief Set FPSCR
\details Assigns the given value to the Floating Point Status/Control register.
\param [in] fpscr Floating Point Status/Control value to set
*/
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
{
#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U)
register uint32_t __regfpscr __ASM("fpscr");
__regfpscr = (fpscr);
#endif
}
#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */
/*@} end of CMSIS_Core_RegAccFunctions */
/* ########################## Core Instruction Access ######################### */
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
Access to dedicated instructions
@{
*/
/**
\brief No Operation
\details No Operation does nothing. This instruction can be used for code alignment purposes.
*/
#define __NOP __nop
/**
\brief Wait For Interrupt
\details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
*/
#define __WFI __wfi
/**
\brief Wait For Event
\details Wait For Event is a hint instruction that permits the processor to enter
a low-power state until one of a number of events occurs.
*/
#define __WFE __wfe
/**
\brief Send Event
\details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
*/
#define __SEV __sev
/**
\brief Instruction Synchronization Barrier
\details Instruction Synchronization Barrier flushes the pipeline in the processor,
so that all instructions following the ISB are fetched from cache or memory,
after the instruction has been completed.
*/
#define __ISB() do {\
__schedule_barrier();\
__isb(0xF);\
__schedule_barrier();\
} while (0U)
/**
\brief Data Synchronization Barrier
\details Acts as a special kind of Data Memory Barrier.
It completes when all explicit memory accesses before this instruction complete.
*/
#define __DSB() do {\
__schedule_barrier();\
__dsb(0xF);\
__schedule_barrier();\
} while (0U)
/**
\brief Data Memory Barrier
\details Ensures the apparent order of the explicit memory operations before
and after the instruction, without ensuring their completion.
*/
#define __DMB() do {\
__schedule_barrier();\
__dmb(0xF);\
__schedule_barrier();\
} while (0U)
/**
\brief Reverse byte order (32 bit)
\details Reverses the byte order in integer value.
\param [in] value Value to reverse
\return Reversed value
*/
#define __REV __rev
/**
\brief Reverse byte order (16 bit)
\details Reverses the byte order in two unsigned short values.
\param [in] value Value to reverse
\return Reversed value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
{
rev16 r0, r0
bx lr
}
#endif
/**
\brief Reverse byte order in signed short value
\details Reverses the byte order in a signed short value with sign extension to integer.
\param [in] value Value to reverse
\return Reversed value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
{
revsh r0, r0
bx lr
}
#endif
/**
\brief Rotate Right in unsigned value (32 bit)
\details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
\param [in] value Value to rotate
\param [in] value Number of Bits to rotate
\return Rotated value
*/
#define __ROR __ror
/**
\brief Breakpoint
\details Causes the processor to enter Debug state.
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
\param [in] value is ignored by the processor.
If required, a debugger can use it to store additional information about the breakpoint.
*/
#define __BKPT(value) __breakpoint(value)
/**
\brief Reverse bit order of value
\details Reverses the bit order of the given value.
\param [in] value Value to reverse
\return Reversed value
*/
#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
#define __RBIT __rbit
#else
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
{
uint32_t result;
int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */
result = value; /* r will be reversed bits of v; first get LSB of v */
for (value >>= 1U; value; value >>= 1U)
{
result <<= 1U;
result |= value & 1U;
s--;
}
result <<= s; /* shift when v's highest bits are zero */
return(result);
}
#endif
/**
\brief Count leading zeros
\details Counts the number of leading zeros of a data value.
\param [in] value Value to count the leading zeros
\return number of leading zeros in value
*/
#define __CLZ __clz
#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
/**
\brief LDR Exclusive (8 bit)
\details Executes a exclusive LDR instruction for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
#else
#define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief LDR Exclusive (16 bit)
\details Executes a exclusive LDR instruction for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
#else
#define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief LDR Exclusive (32 bit)
\details Executes a exclusive LDR instruction for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
#else
#define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief STR Exclusive (8 bit)
\details Executes a exclusive STR instruction for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXB(value, ptr) __strex(value, ptr)
#else
#define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief STR Exclusive (16 bit)
\details Executes a exclusive STR instruction for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXH(value, ptr) __strex(value, ptr)
#else
#define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief STR Exclusive (32 bit)
\details Executes a exclusive STR instruction for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXW(value, ptr) __strex(value, ptr)
#else
#define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief Remove the exclusive lock
\details Removes the exclusive lock which is created by LDREX.
*/
#define __CLREX __clrex
/**
\brief Signed Saturate
\details Saturates a signed value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (1..32)
\return Saturated value
*/
#define __SSAT __ssat
/**
\brief Unsigned Saturate
\details Saturates an unsigned value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (0..31)
\return Saturated value
*/
#define __USAT __usat
/**
\brief Rotate Right with Extend (32 bit)
\details Moves each bit of a bitstring right by one bit.
The carry input is shifted in at the left end of the bitstring.
\param [in] value Value to rotate
\return Rotated value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
{
rrx r0, r0
bx lr
}
#endif
/**
\brief LDRT Unprivileged (8 bit)
\details Executes a Unprivileged LDRT instruction for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
*/
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
/**
\brief LDRT Unprivileged (16 bit)
\details Executes a Unprivileged LDRT instruction for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
*/
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
/**
\brief LDRT Unprivileged (32 bit)
\details Executes a Unprivileged LDRT instruction for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
*/
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
/**
\brief STRT Unprivileged (8 bit)
\details Executes a Unprivileged STRT instruction for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRBT(value, ptr) __strt(value, ptr)
/**
\brief STRT Unprivileged (16 bit)
\details Executes a Unprivileged STRT instruction for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRHT(value, ptr) __strt(value, ptr)
/**
\brief STRT Unprivileged (32 bit)
\details Executes a Unprivileged STRT instruction for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRT(value, ptr) __strt(value, ptr)
#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
/* ################### Compiler specific Intrinsics ########################### */
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
Access to dedicated SIMD instructions
@{
*/
#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */
#define __SADD8 __sadd8
#define __QADD8 __qadd8
#define __SHADD8 __shadd8
#define __UADD8 __uadd8
#define __UQADD8 __uqadd8
#define __UHADD8 __uhadd8
#define __SSUB8 __ssub8
#define __QSUB8 __qsub8
#define __SHSUB8 __shsub8
#define __USUB8 __usub8
#define __UQSUB8 __uqsub8
#define __UHSUB8 __uhsub8
#define __SADD16 __sadd16
#define __QADD16 __qadd16
#define __SHADD16 __shadd16
#define __UADD16 __uadd16
#define __UQADD16 __uqadd16
#define __UHADD16 __uhadd16
#define __SSUB16 __ssub16
#define __QSUB16 __qsub16
#define __SHSUB16 __shsub16
#define __USUB16 __usub16
#define __UQSUB16 __uqsub16
#define __UHSUB16 __uhsub16
#define __SASX __sasx
#define __QASX __qasx
#define __SHASX __shasx
#define __UASX __uasx
#define __UQASX __uqasx
#define __UHASX __uhasx
#define __SSAX __ssax
#define __QSAX __qsax
#define __SHSAX __shsax
#define __USAX __usax
#define __UQSAX __uqsax
#define __UHSAX __uhsax
#define __USAD8 __usad8
#define __USADA8 __usada8
#define __SSAT16 __ssat16
#define __USAT16 __usat16
#define __UXTB16 __uxtb16
#define __UXTAB16 __uxtab16
#define __SXTB16 __sxtb16
#define __SXTAB16 __sxtab16
#define __SMUAD __smuad
#define __SMUADX __smuadx
#define __SMLAD __smlad
#define __SMLADX __smladx
#define __SMLALD __smlald
#define __SMLALDX __smlaldx
#define __SMUSD __smusd
#define __SMUSDX __smusdx
#define __SMLSD __smlsd
#define __SMLSDX __smlsdx
#define __SMLSLD __smlsld
#define __SMLSLDX __smlsldx
#define __SEL __sel
#define __QADD __qadd
#define __QSUB __qsub
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
((int64_t)(ARG3) << 32U) ) >> 32U))
#endif /* (__CORTEX_M >= 0x04) */
/*@} end of group CMSIS_SIMD_intrinsics */
#endif /* __CMSIS_ARMCC_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-86
View File
@@ -1,86 +0,0 @@
/**************************************************************************//**
* @file core_cmFunc.h
* @brief CMSIS Cortex-M Core Function Access Header File
* @version V4.30
* @date 20. October 2015
******************************************************************************/
/* Copyright (c) 2009 - 2015 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
---------------------------------------------------------------------------*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CORE_CMFUNC_H
#define __CORE_CMFUNC_H
/* ########################### Core Function Access ########################### */
/** \ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
@{
*/
/*------------------ RealView Compiler -----------------*/
#if defined ( __CC_ARM )
#include "cmsis_armcc.h"
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#include "cmsis_armcc_V6.h"
/*------------------ GNU Compiler ----------------------*/
#elif defined ( __GNUC__ )
#include "cmsis_gcc.h"
/*------------------ ICC Compiler ----------------------*/
#elif defined ( __ICCARM__ )
#include <cmsis_iar.h>
/*------------------ TI CCS Compiler -------------------*/
#elif defined ( __TMS470__ )
#include <cmsis_ccs.h>
/*------------------ TASKING Compiler ------------------*/
#elif defined ( __TASKING__ )
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all intrinsics,
* Including the CMSIS ones.
*/
/*------------------ COSMIC Compiler -------------------*/
#elif defined ( __CSMC__ )
#include <cmsis_csm.h>
#endif
/*@} end of CMSIS_Core_RegAccFunctions */
#endif /* __CORE_CMFUNC_H */
-87
View File
@@ -1,87 +0,0 @@
/**************************************************************************//**
* @file core_cmInstr.h
* @brief CMSIS Cortex-M Core Instruction Access Header File
* @version V4.30
* @date 20. October 2015
******************************************************************************/
/* Copyright (c) 2009 - 2015 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
---------------------------------------------------------------------------*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CORE_CMINSTR_H
#define __CORE_CMINSTR_H
/* ########################## Core Instruction Access ######################### */
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
Access to dedicated instructions
@{
*/
/*------------------ RealView Compiler -----------------*/
#if defined ( __CC_ARM )
#include "cmsis_armcc.h"
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#include "cmsis_armcc_V6.h"
/*------------------ GNU Compiler ----------------------*/
#elif defined ( __GNUC__ )
#include "cmsis_gcc.h"
/*------------------ ICC Compiler ----------------------*/
#elif defined ( __ICCARM__ )
#include <cmsis_iar.h>
/*------------------ TI CCS Compiler -------------------*/
#elif defined ( __TMS470__ )
#include <cmsis_ccs.h>
/*------------------ TASKING Compiler ------------------*/
#elif defined ( __TASKING__ )
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all intrinsics,
* Including the CMSIS ones.
*/
/*------------------ COSMIC Compiler -------------------*/
#elif defined ( __CSMC__ )
#include <cmsis_csm.h>
#endif
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
#endif /* __CORE_CMINSTR_H */
-96
View File
@@ -1,96 +0,0 @@
/**************************************************************************//**
* @file core_cmSimd.h
* @brief CMSIS Cortex-M SIMD Header File
* @version V4.30
* @date 20. October 2015
******************************************************************************/
/* Copyright (c) 2009 - 2015 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
---------------------------------------------------------------------------*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CORE_CMSIMD_H
#define __CORE_CMSIMD_H
#ifdef __cplusplus
extern "C" {
#endif
/* ################### Compiler specific Intrinsics ########################### */
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
Access to dedicated SIMD instructions
@{
*/
/*------------------ RealView Compiler -----------------*/
#if defined ( __CC_ARM )
#include "cmsis_armcc.h"
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#include "cmsis_armcc_V6.h"
/*------------------ GNU Compiler ----------------------*/
#elif defined ( __GNUC__ )
#include "cmsis_gcc.h"
/*------------------ ICC Compiler ----------------------*/
#elif defined ( __ICCARM__ )
#include <cmsis_iar.h>
/*------------------ TI CCS Compiler -------------------*/
#elif defined ( __TMS470__ )
#include <cmsis_ccs.h>
/*------------------ TASKING Compiler ------------------*/
#elif defined ( __TASKING__ )
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all intrinsics,
* Including the CMSIS ones.
*/
/*------------------ COSMIC Compiler -------------------*/
#elif defined ( __CSMC__ )
#include <cmsis_csm.h>
#endif
/*@} end of group CMSIS_SIMD_intrinsics */
#ifdef __cplusplus
}
#endif
#endif /* __CORE_CMSIMD_H */
-258
View File
@@ -1,258 +0,0 @@
/**
* 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
*
*/
/**
* @brief This file provides OpenThread configuration of nRF5 SDK modules.
*
* Below configuration overwrites the default sdk_config.h file for certain platform.
*
* Default configuration for the vanilla OpenThread can be overwritten by the custom configuration.
* To do that, provide the configuration through the APP_CONFIG_CUSTOM_FILE define.
*
*/
#ifndef APP_CONFIG_H
#define APP_CONFIG_H
#if (USB_CDC_AS_SERIAL_TRANSPORT == 1)
#ifndef APP_USBD_ENABLED
#define APP_USBD_ENABLED 1
#endif
#ifndef APP_USBD_VID
#define APP_USBD_VID 0x1915
#endif
#ifndef APP_USBD_PID
#define APP_USBD_PID 0xCAFE
#endif
#ifndef APP_USBD_DEVICE_VER_MAJOR
#define APP_USBD_DEVICE_VER_MAJOR 1
#endif
#ifndef APP_USBD_DEVICE_VER_MINOR
#define APP_USBD_DEVICE_VER_MINOR 0
#endif
#ifndef APP_USBD_DEVICE_VER_SUB
#define APP_USBD_DEVICE_VER_SUB 0
#endif
#ifndef APP_USBD_CONFIG_MAX_POWER
#define APP_USBD_CONFIG_MAX_POWER 500
#endif
#ifndef APP_USBD_STRING_ID_PRODUCT
#define APP_USBD_STRING_ID_PRODUCT 2
#endif
#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN
#define APP_USBD_STRINGS_PRODUCT_EXTERN 0
#endif
#ifndef APP_USBD_STRINGS_PRODUCT
#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF528xx OpenThread Device")
#endif
#ifndef APP_USBD_STRING_ID_SERIAL
#define APP_USBD_STRING_ID_SERIAL 3
#endif
#ifndef APP_USBD_STRING_SERIAL_EXTERN
#define APP_USBD_STRING_SERIAL_EXTERN 1
#endif
#ifndef APP_USBD_STRING_SERIAL
#define APP_USBD_STRING_SERIAL g_extern_serial_number
#endif
#ifndef APP_USBD_CONFIG_LOG_ENABLED
#define APP_USBD_CONFIG_LOG_ENABLED 0
#endif
#ifndef USBD_ENABLED
#define USBD_ENABLED 1
#endif
#ifndef NRFX_USBD_ENABLED
#define NRFX_USBD_ENABLED 1
#endif
#ifndef NRFX_USBD_CONFIG_IRQ_PRIORITY
#define NRFX_USBD_CONFIG_IRQ_PRIORITY 7
#endif
#ifndef NRFX_SYSTICK_ENABLED
#define NRFX_SYSTICK_ENABLED 1
#endif
#ifndef APP_USBD_CDC_ACM_ENABLED
#define APP_USBD_CDC_ACM_ENABLED 1
#endif
#endif // USB_CDC_AS_SERIAL_TRANSPORT == 1
#ifndef APP_USBD_NRF_DFU_TRIGGER_ENABLED
#define APP_USBD_NRF_DFU_TRIGGER_ENABLED 0
#endif
#ifndef BSP_SELF_PINRESET_PIN
#define BSP_SELF_PINRESET_PIN NRF_GPIO_PIN_MAP(0, 19)
#endif
#ifndef NRF_DFU_TRIGGER_USB_USB_SHARED
#define NRF_DFU_TRIGGER_USB_USB_SHARED 1
#endif
#ifndef NRF_DFU_TRIGGER_USB_INTERFACE_NUM
#define NRF_DFU_TRIGGER_USB_INTERFACE_NUM 0
#endif
#ifndef APP_NAME
#define APP_NAME "OpenThread App"
#endif
#ifndef APP_VERSION_MAJOR
#define APP_VERSION_MAJOR 1
#endif
#ifndef APP_VERSION_MINOR
#define APP_VERSION_MINOR 0
#endif
#ifndef APP_VERSION_PATCH
#define APP_VERSION_PATCH 0
#endif
#ifndef APP_ID
#define APP_ID 1
#endif
#ifndef APP_VERSION_PRERELEASE
#define APP_VERSION_PRERELEASE ""
#endif
#ifndef APP_VERSION_METADATA
#define APP_VERSION_METADATA ""
#endif
#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_UP
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512
#endif
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
#endif
#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16
#endif
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS
#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2
#endif
#ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE
#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0
#endif
#ifndef NRF_CLOCK_ENABLED
#define NRF_CLOCK_ENABLED 1
#endif
#ifndef CLOCK_CONFIG_LF_SRC
#define CLOCK_CONFIG_LF_SRC 1
#endif
#ifndef CLOCK_CONFIG_IRQ_PRIORITY
#define CLOCK_CONFIG_IRQ_PRIORITY 7
#endif
#if (USB_CDC_AS_SERIAL_TRANSPORT == 1)
#ifndef POWER_ENABLED
#define POWER_ENABLED 1
#endif
#endif // USB_CDC_AS_SERIAL_TRANSPORT == 1
#ifndef POWER_CONFIG_IRQ_PRIORITY
#define POWER_CONFIG_IRQ_PRIORITY 7
#endif
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
#ifndef SPIS_ENABLED
#define SPIS_ENABLED 1
#endif
#ifndef SPIS_DEFAULT_CONFIG_IRQ_PRIORITY
#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 7
#endif
#ifndef SPIS0_ENABLED
#define SPIS0_ENABLED 1
#endif
#endif // SPIS_AS_SERIAL_TRANSPORT == 1
#ifndef NRFX_NVMC_ENABLED
#define NRFX_NVMC_ENABLED 1
#endif
#ifndef TIMER_ENABLED
#define TIMER_ENABLED 1
#endif
#ifndef TIMER0_ENABLED
#define TIMER0_ENABLED 1
#endif
#ifndef TIMER1_ENABLED
#define TIMER1_ENABLED 1
#endif
#ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY
#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 7
#endif
#endif // APP_CONFIG_H
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,129 +0,0 @@
/**
* Copyright (c) 2014 - 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
*
*/
#include "app_util_platform.h"
#ifdef SOFTDEVICE_PRESENT
/* Global nvic state instance, required by nrf_nvic.h */
nrf_nvic_state_t nrf_nvic_state;
#endif
static uint32_t m_in_critical_region = 0;
void app_util_disable_irq(void)
{
__disable_irq();
m_in_critical_region++;
}
void app_util_enable_irq(void)
{
m_in_critical_region--;
if (m_in_critical_region == 0)
{
__enable_irq();
}
}
void app_util_critical_region_enter(uint8_t *p_nested)
{
#if __CORTEX_M == (0x04U)
ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get())
#endif
#if defined(SOFTDEVICE_PRESENT)
/* return value can be safely ignored */
(void) sd_nvic_critical_region_enter(p_nested);
#else
UNUSED_PARAMETER(p_nested);
app_util_disable_irq();
#endif
}
void app_util_critical_region_exit(uint8_t nested)
{
#if __CORTEX_M == (0x04U)
ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get())
#endif
#if defined(SOFTDEVICE_PRESENT)
/* return value can be safely ignored */
(void) sd_nvic_critical_region_exit(nested);
#else
UNUSED_PARAMETER(nested);
app_util_enable_irq();
#endif
}
uint8_t privilege_level_get(void)
{
#if __CORTEX_M == (0x00U) || defined(_WIN32) || defined(__unix) || defined(__APPLE__)
/* the Cortex-M0 has no concept of privilege */
return APP_LEVEL_PRIVILEGED;
#elif __CORTEX_M == (0x04U)
uint32_t isr_vector_num = __get_IPSR() & IPSR_ISR_Msk ;
if (0 == isr_vector_num)
{
/* Thread Mode, check nPRIV */
int32_t control = __get_CONTROL();
return control & CONTROL_nPRIV_Msk ? APP_LEVEL_UNPRIVILEGED : APP_LEVEL_PRIVILEGED;
}
else
{
/* Handler Mode, always privileged */
return APP_LEVEL_PRIVILEGED;
}
#endif
}
uint8_t current_int_priority_get(void)
{
uint32_t isr_vector_num = __get_IPSR() & IPSR_ISR_Msk ;
if (isr_vector_num > 0)
{
int32_t irq_type = ((int32_t)isr_vector_num - EXTERNAL_INT_VECTOR_OFFSET);
return (NVIC_GetPriority((IRQn_Type)irq_type) & 0xFF);
}
else
{
return APP_IRQ_PRIORITY_THREAD;
}
}
@@ -1,281 +0,0 @@
/**
* Copyright (c) 2014 - 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
*
*/
/**@file
*
* @defgroup app_util_platform Utility Functions and Definitions (Platform)
* @{
* @ingroup app_common
*
* @brief Various types and definitions available to all applications when using SoftDevice.
*/
#ifndef APP_UTIL_PLATFORM_H__
#define APP_UTIL_PLATFORM_H__
#include <stdint.h>
#include "compiler_abstraction.h"
#include "nrf.h"
#ifdef SOFTDEVICE_PRESENT
#include "nrf_soc.h"
#include "nrf_nvic.h"
#endif
#include "nrf_assert.h"
#include "app_error.h"
#ifdef __cplusplus
extern "C" {
#endif
#if __CORTEX_M == (0x00U)
#define _PRIO_SD_HIGH 0
#define _PRIO_APP_HIGH 1
#define _PRIO_APP_MID 1
#define _PRIO_SD_LOW 2
#define _PRIO_APP_LOW_MID 3
#define _PRIO_APP_LOW 3
#define _PRIO_APP_LOWEST 3
#define _PRIO_THREAD 4
#elif __CORTEX_M == (0x04U)
#define _PRIO_SD_HIGH 0
#define _PRIO_SD_MID 1
#define _PRIO_APP_HIGH 2
#define _PRIO_APP_MID 3
#define _PRIO_SD_LOW 4
#define _PRIO_APP_LOW_MID 5
#define _PRIO_APP_LOW 6
#define _PRIO_APP_LOWEST 7
#define _PRIO_THREAD 15
#else
#error "No platform defined"
#endif
//lint -save -e113 -e452
/**@brief The interrupt priorities available to the application while the SoftDevice is active. */
typedef enum
{
#ifndef SOFTDEVICE_PRESENT
APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH,
#else
APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH,
#endif
APP_IRQ_PRIORITY_HIGH = _PRIO_APP_HIGH,
#ifndef SOFTDEVICE_PRESENT
APP_IRQ_PRIORITY_MID = _PRIO_SD_LOW,
#else
APP_IRQ_PRIORITY_MID = _PRIO_APP_MID,
#endif
APP_IRQ_PRIORITY_LOW_MID = _PRIO_APP_LOW_MID,
APP_IRQ_PRIORITY_LOW = _PRIO_APP_LOW,
APP_IRQ_PRIORITY_LOWEST = _PRIO_APP_LOWEST,
APP_IRQ_PRIORITY_THREAD = _PRIO_THREAD /**< "Interrupt level" when running in Thread Mode. */
} app_irq_priority_t;
//lint -restore
/*@brief The privilege levels available to applications in Thread Mode */
typedef enum
{
APP_LEVEL_UNPRIVILEGED,
APP_LEVEL_PRIVILEGED
} app_level_t;
/**@cond NO_DOXYGEN */
#define EXTERNAL_INT_VECTOR_OFFSET 16
/**@endcond */
/**@brief Macro for setting a breakpoint.
*/
#if defined(__GNUC__)
#define NRF_BREAKPOINT __asm__("BKPT 0");
#else
#define NRF_BREAKPOINT __BKPT(0)
#endif
/** @brief Macro for setting a breakpoint.
*
* If it is possible to detect debugger presence then it is set only in that case.
*
*/
#if __CORTEX_M == 0x04
#define NRF_BREAKPOINT_COND do { \
/* C_DEBUGEN == 1 -> Debugger Connected */ \
if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) \
{ \
/* Generate breakpoint if debugger is connected */ \
NRF_BREAKPOINT; \
} \
}while (0)
#else
#define NRF_BREAKPOINT_COND NRF_BREAKPOINT
#endif // __CORTEX_M == 0x04
#if defined ( __CC_ARM )
#define PACKED(TYPE) __packed TYPE
#define PACKED_STRUCT PACKED(struct)
#elif defined ( __GNUC__ )
#define PACKED __attribute__((packed))
#define PACKED_STRUCT struct PACKED
#elif defined (__ICCARM__)
#define PACKED_STRUCT __packed struct
#endif
#if defined ( __CC_ARM )
#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("push") \
_Pragma ("O3")
#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("pop")
#elif defined ( __GNUC__ )
#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma("GCC push_options") \
_Pragma ("GCC optimize (\"Os\")")
#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("GCC pop_options")
#elif defined (__ICCARM__)
#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("optimize=high z")
#define PRAGMA_OPTIMIZATION_FORCE_END
#endif
void app_util_critical_region_enter (uint8_t *p_nested);
void app_util_critical_region_exit (uint8_t nested);
/**@brief Macro for entering a critical region.
*
* @note Due to implementation details, there must exist one and only one call to
* CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
* in the same scope.
*/
#ifdef SOFTDEVICE_PRESENT
#define CRITICAL_REGION_ENTER() \
{ \
uint8_t __CR_NESTED = 0; \
app_util_critical_region_enter(&__CR_NESTED);
#else
#define CRITICAL_REGION_ENTER() app_util_critical_region_enter(NULL)
#endif
/**@brief Macro for leaving a critical region.
*
* @note Due to implementation details, there must exist one and only one call to
* CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
* in the same scope.
*/
#ifdef SOFTDEVICE_PRESENT
#define CRITICAL_REGION_EXIT() \
app_util_critical_region_exit(__CR_NESTED); \
}
#else
#define CRITICAL_REGION_EXIT() app_util_critical_region_exit(0)
#endif
/* Workaround for Keil 4 */
#ifndef IPSR_ISR_Msk
#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
#endif
/**@brief Macro to enable anonymous unions from a certain point in the code.
*/
#if defined(__CC_ARM)
#define ANON_UNIONS_ENABLE _Pragma("push") \
_Pragma("anon_unions") \
struct semicolon_swallower
#elif defined(__ICCARM__)
#define ANON_UNIONS_ENABLE _Pragma("language=extended") \
struct semicolon_swallower
#else
#define ANON_UNIONS_ENABLE struct semicolon_swallower
// No action will be taken.
// For GCC anonymous unions are enabled by default.
#endif
/**@brief Macro to disable anonymous unions from a certain point in the code.
* @note Call only after first calling @ref ANON_UNIONS_ENABLE.
*/
#if defined(__CC_ARM)
#define ANON_UNIONS_DISABLE _Pragma("pop") \
struct semicolon_swallower
#elif defined(__ICCARM__)
#define ANON_UNIONS_DISABLE struct semicolon_swallower
// for IAR leave anonymous unions enabled
#else
#define ANON_UNIONS_DISABLE struct semicolon_swallower
// No action will be taken.
// For GCC anonymous unions are enabled by default.
#endif
/**@brief Macro for adding pragma directive only for GCC.
*/
#ifdef __GNUC__
#define GCC_PRAGMA(v) _Pragma(v)
#else
#define GCC_PRAGMA(v)
#endif
/* Workaround for Keil 4 */
#ifndef CONTROL_nPRIV_Msk
#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */
#endif
/**@brief Function for finding the current interrupt level.
*
* @return Current interrupt level.
* @retval APP_IRQ_PRIORITY_HIGH We are running in Application High interrupt level.
* @retval APP_IRQ_PRIORITY_LOW We are running in Application Low interrupt level.
* @retval APP_IRQ_PRIORITY_THREAD We are running in Thread Mode.
*/
uint8_t current_int_priority_get(void);
/**@brief Function for finding out the current privilege level.
*
* @return Current privilege level.
* @retval APP_LEVEL_UNPRIVILEGED We are running in unprivileged level.
* @retval APP_LEVEL_PRIVILEGED We are running in privileged level.
*/
uint8_t privilege_level_get(void);
#ifdef __cplusplus
}
#endif
#endif // APP_UTIL_PLATFORM_H__
/** @} */
File diff suppressed because it is too large Load Diff
@@ -1,215 +0,0 @@
/**
* Copyright (c) 2008 - 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
*
*/
/** @file
* @brief Common defines and macros for firmware developed by Nordic Semiconductor.
*/
#ifndef NORDIC_COMMON_H__
#define NORDIC_COMMON_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Check if selected module is enabled
*
* This is save function for driver enable checking.
* Correct from Lint point of view (not using default of undefined value).
*
* Usage:
* @code
#if NRF_MODULE_ENABLED(UART)
...
#endif
* @endcode
*
* @param module The module name.
*
* @retval 1 The macro <module>_ENABLE is defined and is non-zero.
* @retval 0 The macro <module>_ENABLE is not defined or it equals zero.
*
* @note
* This macro intentionally does not implement second expansion level.
* The name of the module to be checked has to be given directly as a parameter.
* And given parameter would be connected with @c _ENABLED postfix directly
* without evaluating its value.
*/
//lint -emacro(491,NRF_MODULE_ENABLED) // Suppers warning 491 "non-standard use of 'defined' preprocessor operator"
#ifdef NRF_MODULE_ENABLE_ALL
#warning "Do not use NRF_MODULE_ENABLE_ALL for real builds."
#define NRF_MODULE_ENABLED(module) 1
#else
#define NRF_MODULE_ENABLED(module) \
((defined(module ## _ENABLED) && (module ## _ENABLED)) ? 1 : 0)
#endif
/** The upper 8 bits of a 32 bit value */
//lint -emacro(572,MSB_32) // Suppress warning 572 "Excessive shift value"
#define MSB_32(a) (((a) & 0xFF000000) >> 24)
/** The lower 8 bits (of a 32 bit value) */
#define LSB_32(a) ((a) & 0x000000FF)
/** The upper 8 bits of a 16 bit value */
//lint -emacro(572,MSB_16) // Suppress warning 572 "Excessive shift value"
#define MSB_16(a) (((a) & 0xFF00) >> 8)
/** The lower 8 bits (of a 16 bit value) */
#define LSB_16(a) ((a) & 0x00FF)
/** Leaves the minimum of the two 32-bit arguments */
/*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */
#define MIN(a, b) ((a) < (b) ? (a) : (b))
/** Leaves the maximum of the two 32-bit arguments */
/*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */
#define MAX(a, b) ((a) < (b) ? (b) : (a))
/**@brief Concatenates two parameters.
*
* It realizes two level expansion to make it sure that all the parameters
* are actually expanded before gluing them together.
*
* @param p1 First parameter to concatenating
* @param p2 Second parameter to concatenating
*
* @return Two parameters glued together.
* They have to create correct C mnemonic in other case
* preprocessor error would be generated.
*
* @sa CONCAT_3
*/
#define CONCAT_2(p1, p2) CONCAT_2_(p1, p2)
/** Auxiliary macro used by @ref CONCAT_2 */
#define CONCAT_2_(p1, p2) p1##p2
/**@brief Concatenates three parameters.
*
* It realizes two level expansion to make it sure that all the parameters
* are actually expanded before gluing them together.
*
* @param p1 First parameter to concatenating
* @param p2 Second parameter to concatenating
* @param p3 Third parameter to concatenating
*
* @return Three parameters glued together.
* They have to create correct C mnemonic in other case
* preprocessor error would be generated.
*
* @sa CONCAT_2
*/
#define CONCAT_3(p1, p2, p3) CONCAT_3_(p1, p2, p3)
/** Auxiliary macro used by @ref CONCAT_3 */
#define CONCAT_3_(p1, p2, p3) p1##p2##p3
#define STRINGIFY_(val) #val
/** Converts a macro argument into a character constant.
*/
#define STRINGIFY(val) STRINGIFY_(val)
/** Counts number of elements inside the array
*/
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
/**@brief Set a bit in the uint32 word.
*
* @param[in] W Word whose bit is being set.
* @param[in] B Bit number in the word to be set.
*/
#define SET_BIT(W, B) ((W) |= (uint32_t)(1U << (B)))
/**@brief Clears a bit in the uint32 word.
*
* @param[in] W Word whose bit is to be cleared.
* @param[in] B Bit number in the word to be cleared.
*/
#define CLR_BIT(W, B) ((W) &= (~(uint32_t)(1U << (B))))
/**@brief Checks if a bit is set.
*
* @param[in] W Word whose bit is to be checked.
* @param[in] B Bit number in the word to be checked.
*
* @retval 1 if bit is set.
* @retval 0 if bit is not set.
*/
#define IS_SET(W, B) (((W) >> (B)) & 1)
#define BIT_0 0x01 /**< The value of bit 0 */
#define BIT_1 0x02 /**< The value of bit 1 */
#define BIT_2 0x04 /**< The value of bit 2 */
#define BIT_3 0x08 /**< The value of bit 3 */
#define BIT_4 0x10 /**< The value of bit 4 */
#define BIT_5 0x20 /**< The value of bit 5 */
#define BIT_6 0x40 /**< The value of bit 6 */
#define BIT_7 0x80 /**< The value of bit 7 */
#define BIT_8 0x0100 /**< The value of bit 8 */
#define BIT_9 0x0200 /**< The value of bit 9 */
#define BIT_10 0x0400 /**< The value of bit 10 */
#define BIT_11 0x0800 /**< The value of bit 11 */
#define BIT_12 0x1000 /**< The value of bit 12 */
#define BIT_13 0x2000 /**< The value of bit 13 */
#define BIT_14 0x4000 /**< The value of bit 14 */
#define BIT_15 0x8000 /**< The value of bit 15 */
#define BIT_16 0x00010000 /**< The value of bit 16 */
#define BIT_17 0x00020000 /**< The value of bit 17 */
#define BIT_18 0x00040000 /**< The value of bit 18 */
#define BIT_19 0x00080000 /**< The value of bit 19 */
#define BIT_20 0x00100000 /**< The value of bit 20 */
#define BIT_21 0x00200000 /**< The value of bit 21 */
#define BIT_22 0x00400000 /**< The value of bit 22 */
#define BIT_23 0x00800000 /**< The value of bit 23 */
#define BIT_24 0x01000000 /**< The value of bit 24 */
#define BIT_25 0x02000000 /**< The value of bit 25 */
#define BIT_26 0x04000000 /**< The value of bit 26 */
#define BIT_27 0x08000000 /**< The value of bit 27 */
#define BIT_28 0x10000000 /**< The value of bit 28 */
#define BIT_29 0x20000000 /**< The value of bit 29 */
#define BIT_30 0x40000000 /**< The value of bit 30 */
#define BIT_31 0x80000000 /**< The value of bit 31 */
#define UNUSED_VARIABLE(X) ((void)(X))
#define UNUSED_PARAMETER(X) UNUSED_VARIABLE(X)
#define UNUSED_RETURN_VALUE(X) UNUSED_VARIABLE(X)
#ifdef __cplusplus
}
#endif
#endif // NORDIC_COMMON_H__
@@ -1,122 +0,0 @@
/**
* Copyright (c) 2006 - 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
*
*/
/** @file
* @brief Utilities for verifying program logic
*/
#ifndef NRF_ASSERT_H_
#define NRF_ASSERT_H_
#include <stdint.h>
#include "nrf.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Function for handling assertions.
*
*
* @note
* This function is called when an assertion has triggered.
*
* @note
* This function is deprecated and will be removed in future releases.
* Use app_error_fault_handler instead.
*
*
* @post
* All hardware is put into an idle non-emitting state (in particular the radio is highly
* important to switch off since the radio might be in a state that makes it send
* packets continiously while a typical final infinit ASSERT loop is executing).
*
*
* @param line_num The line number where the assertion is called
* @param file_name Pointer to the file name
*/
//lint -save -esym(14, assert_nrf_callback)
void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name);
//lint -restore
#if (defined(DEBUG_NRF) || defined(DEBUG_NRF_USER))
#define NRF_ASSERT_PRESENT 1
#else
#define NRF_ASSERT_PRESENT 0
#endif
//#if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER)
/*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */
/*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \
/** @brief Function for checking intended for production code.
*
* Check passes if "expr" evaluates to true. */
#ifdef _lint
#define ASSERT(expr) \
if (expr) \
{ \
} \
else \
{ \
while (1); \
}
#else //_lint
#define ASSERT(expr) \
if (NRF_ASSERT_PRESENT) \
{ \
if (expr) \
{ \
} \
else \
{ \
assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \
} \
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* NRF_ASSERT_H_ */
@@ -1,95 +0,0 @@
/**
* Copyright (c) 2012 - 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
*
*/
/* Header guard */
#ifndef SOFTDEVICE_PRESENT
/**
@defgroup nrf_error Global Error Codes
@{
@brief Global Error definitions
*/
#ifndef NRF_ERROR_H__
#define NRF_ERROR_H__
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions
* @{ */
#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base
#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base
#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base
#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base
/** @} */
#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command
#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing
#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled
#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error
#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation
#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found
#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported
#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter
#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state
#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length
#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags
#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data
#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Data size exceeds limit
#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out
#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer
#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation
#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address
#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy
#ifdef __cplusplus
}
#endif
#endif // NRF_ERROR_H__
/**
@}
*/
#endif // SOFTDEVICE_PRESENT
-291
View File
@@ -1,291 +0,0 @@
/**
* Copyright (c) 2016 - 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
*
*/
/**@file
*
* @defgroup nrf_log Logger module
* @{
* @ingroup app_common
*
* @brief The nrf_log module interface.
*/
#ifndef NRF_LOG_H_
#define NRF_LOG_H_
#include "sdk_common.h"
#include "nrf_section.h"
#if NRF_MODULE_ENABLED(NRF_LOG)
#include "nrf_strerror.h"
#define NRF_LOG_ERROR_STRING_GET(code) nrf_strerror_get(code)
#else
#define NRF_LOG_ERROR_STRING_GET(code) ""
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Severity level for the module.
*
* The severity level can be defined in a module to override the default.
*/
#ifndef NRF_LOG_LEVEL
#define NRF_LOG_LEVEL NRF_LOG_DEFAULT_LEVEL
#endif
/** @brief Initial severity if filtering is enabled.
*/
#ifndef NRF_LOG_INITIAL_LEVEL
#define NRF_LOG_INITIAL_LEVEL NRF_LOG_LEVEL
#endif
#include "nrf_log_internal.h"
/** @def NRF_LOG_ERROR
* @brief Macro for logging error messages. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*/
/** @def NRF_LOG_WARNING
* @brief Macro for logging error messages. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes warning logs.
*/
/** @def NRF_LOG_INFO
* @brief Macro for logging error messages. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes info logs.
*/
/** @def NRF_LOG_DEBUG
* @brief Macro for logging error messages. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes debug logs.
*/
#define NRF_LOG_ERROR(...) NRF_LOG_INTERNAL_ERROR(__VA_ARGS__)
#define NRF_LOG_WARNING(...) NRF_LOG_INTERNAL_WARNING( __VA_ARGS__)
#define NRF_LOG_INFO(...) NRF_LOG_INTERNAL_INFO( __VA_ARGS__)
#define NRF_LOG_DEBUG(...) NRF_LOG_INTERNAL_DEBUG( __VA_ARGS__)
/** @def NRF_LOG_INST_ERROR
* @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @param p_inst Pointer to the instance with logging support.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*/
/** @def NRF_LOG_INST_WARNING
* @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @param p_inst Pointer to the instance with logging support.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*/
/** @def NRF_LOG_INST_INFO
* @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @param p_inst Pointer to the instance with logging support.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*/
/** @def NRF_LOG_INST_DEBUG
* @brief Macro for logging error messages for given module instance. It takes a printf-like, formatted
* string with up to seven arguments.
*
* @param p_inst Pointer to the instance with logging support.
*
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*/
#define NRF_LOG_INST_ERROR(p_inst,...) NRF_LOG_INTERNAL_INST_ERROR(p_inst,__VA_ARGS__)
#define NRF_LOG_INST_WARNING(p_inst,...) NRF_LOG_INTERNAL_INST_WARNING(p_inst,__VA_ARGS__)
#define NRF_LOG_INST_INFO(p_inst,...) NRF_LOG_INTERNAL_INST_INFO(p_inst, __VA_ARGS__)
#define NRF_LOG_INST_DEBUG(p_inst,...) NRF_LOG_INTERNAL_INST_DEBUG(p_inst, __VA_ARGS__)
/**
* @brief Macro for logging a formatted string without any prefix or timestamp.
*/
#define NRF_LOG_RAW_INFO(...) NRF_LOG_INTERNAL_RAW_INFO( __VA_ARGS__)
/** @def NRF_LOG_HEXDUMP_ERROR
* @brief Macro for logging raw bytes.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
/** @def NRF_LOG_HEXDUMP_WARNING
* @brief Macro for logging raw bytes.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes warning logs.
*
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
/** @def NRF_LOG_HEXDUMP_INFO
* @brief Macro for logging raw bytes.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes info logs.
*
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
/** @def NRF_LOG_HEXDUMP_DEBUG
* @brief Macro for logging raw bytes.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes debug logs.
*
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
#define NRF_LOG_HEXDUMP_ERROR(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_ERROR(p_data, len)
#define NRF_LOG_HEXDUMP_WARNING(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_WARNING(p_data, len)
#define NRF_LOG_HEXDUMP_INFO(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len)
#define NRF_LOG_HEXDUMP_DEBUG(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len)
/** @def NRF_LOG_HEXDUMP_INST_ERROR
* @brief Macro for logging raw bytes for a specific module instance.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*
* @param p_inst Pointer to the instance with logging support.
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
/** @def NRF_LOG_HEXDUMP_INST_WARNING
* @brief Macro for logging raw bytes for a specific module instance.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*
* @param p_inst Pointer to the instance with logging support.
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
/** @def NRF_LOG_HEXDUMP_INST_INFO
* @brief Macro for logging raw bytes for a specific module instance.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*
* @param p_inst Pointer to the instance with logging support.
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
/** @def NRF_LOG_HEXDUMP_INST_DEBUG
* @brief Macro for logging raw bytes for a specific module instance.
* @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs.
*
* @param p_inst Pointer to the instance with logging support.
* @param p_data Pointer to data.
* @param len Data length in bytes.
*/
#define NRF_LOG_HEXDUMP_INST_ERROR(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_ERROR(p_inst, p_data, len)
#define NRF_LOG_HEXDUMP_INST_WARNING(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_WARNING(p_inst, p_data, len)
#define NRF_LOG_HEXDUMP_INST_INFO(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_INFO(p_inst, p_data, len)
#define NRF_LOG_HEXDUMP_INST_DEBUG(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_DEBUG(p_inst, p_data, len)
/**
* @brief Macro for logging hexdump without any prefix or timestamp.
*/
#define NRF_LOG_RAW_HEXDUMP_INFO(p_data, len) NRF_LOG_INTERNAL_RAW_HEXDUMP_INFO(p_data, len)
/**
* @brief Macro for copying a string to internal logger buffer if logs are deferred.
*
* @param _str String.
*/
#define NRF_LOG_PUSH(_str) NRF_LOG_INTERNAL_LOG_PUSH(_str)
/**
* @brief Function for copying a string to the internal logger buffer if logs are deferred.
*
* Use this function to store a string that is volatile (for example allocated
* on stack) or that may change before the deferred logs are processed. Such string is copied
* into the internal logger buffer and is persistent until the log is processed.
*
* @note If the logs are not deferred, then this function returns the input parameter.
*
* @param p_str Pointer to the user string.
*
* @return Address to the location where the string is stored in the internal logger buffer.
*/
uint32_t nrf_log_push(char * const p_str);
/**
* @brief Macro to be used in a formatted string to a pass float number to the log.
*
* Use this macro in a formatted string instead of the %f specifier together with
* @ref NRF_LOG_FLOAT macro.
* Example: NRF_LOG_INFO("My float number" NRF_LOG_FLOAT_MARKER "\r\n", NRF_LOG_FLOAT(f)))
*/
#define NRF_LOG_FLOAT_MARKER "%s%d.%02d"
/**
* @brief Macro for dissecting a float number into two numbers (integer and residuum).
*/
#define NRF_LOG_FLOAT(val) (uint32_t)(((val) < 0 && (val) > -1.0) ? "-" : ""), \
(int32_t)(val), \
(int32_t)((((val) > 0) ? (val) - (int32_t)(val) \
: (int32_t)(val) - (val))*100)
/**
* @brief Macro for registering an independent module.
*
* Registration creates set of dynamic (RAM) and constant variables associated with the module.
*/
#define NRF_LOG_MODULE_REGISTER() NRF_LOG_INTERNAL_MODULE_REGISTER()
#ifdef __cplusplus
}
#endif
#endif // NRF_LOG_H_
/** @} */
@@ -1,252 +0,0 @@
/**
* Copyright (c) 2016 - 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, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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 NRF_LOG_CTRL_H
#define NRF_LOG_CTRL_H
/**@file
* @addtogroup nrf_log Logger module
* @ingroup app_common
*
* @defgroup nrf_log_ctrl Functions for controlling nrf_log
* @{
* @ingroup nrf_log
* @brief The nrf_log control interface.
*/
#include "sdk_config.h"
#include "sdk_errors.h"
#include <stdint.h>
#include <stdbool.h>
#include "nrf_log_types.h"
#include "nrf_log_ctrl_internal.h"
/* Different backends currently not supported. */
#define LOG_BACKEND 0
#if LOG_BACKEND
#include "nrf_log_backend_interface.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Timestamp function prototype.
*
* @return Timestamp value.
*/
typedef uint32_t (*nrf_log_timestamp_func_t)(void);
/**@brief Macro for initializing the logs.
*
* Macro has one or two parameters. First parameter (obligatory) is the timestamp function (@ref nrf_log_timestamp_func_t).
* Additionally, as the second parameter timestamp frequency in Hz can be provided. If not provided then default
* frequency is used (@ref NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY). Frequency is used to format timestamp prefix if
* @ref NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED is set.
*
* @return NRF_SUCCESS after successful initialization, otherwise an error code.
*/
#define NRF_LOG_INIT(...) NRF_LOG_INTERNAL_INIT(__VA_ARGS__)
/**@brief Macro for processing a single log entry from a queue of deferred logs.
*
* You can call this macro from the main context or from the error handler to process
* log entries one by one.
*
* @note If logs are not deferred, this call has no use and is defined as 'false'.
*
* @retval true There are more logs to process in the buffer.
* @retval false No more logs in the buffer.
*/
#define NRF_LOG_PROCESS() NRF_LOG_INTERNAL_PROCESS()
/** @brief Macro for processing all log entries from the buffer.
* It blocks until all buffered entries are processed by the backend.
*
* @note If logs are not deferred, this call has no use and is empty.
*/
#define NRF_LOG_FLUSH() NRF_LOG_INTERNAL_FLUSH()
/** @brief Macro for flushing log data before reset.
*
* @note If logs are not deferred, this call has no use and is empty.
*
* @note If RTT is used, then a breakpoint is hit once flushed.
*/
#define NRF_LOG_FINAL_FLUSH() NRF_LOG_INTERNAL_FINAL_FLUSH()
/**
* @brief Function for initializing the frontend and the default backend.
*
* @ref NRF_LOG_INIT calls this function to initialize the frontend and the backend.
* If custom backend is used, then @ref NRF_LOG_INIT should not be called.
* Instead, frontend and user backend should be verbosely initialized.
*
* @param timestamp_func Function for getting a 32-bit timestamp.
* @param timestamp_freq Frequency of the timestamp.
*
* @return Error status.
*
*/
ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func, uint32_t timestamp_freq);
#if LOG_BACKEND
/**
* @brief Function for adding new backend interface to the logger.
*
* @param p_backend Pointer to the backend interface.
* @param severity Initial value of severity level for each module forwarded to the backend. This
* option is only applicable if @ref NRF_LOG_FILTERS_ENABLED is set.
* @return -1 if backend cannot be added or positive number (backend ID).
*/
int32_t nrf_log_backend_add(nrf_log_backend_t const * p_backend, nrf_log_severity_t severity);
/**
* @brief Function for removing backend from the logger.
*
* @param p_backend Pointer to the backend interface.
*
*/
void nrf_log_backend_remove(nrf_log_backend_t const * p_backend);
#endif /* LOG_BACKEND */
/**
* @brief Function for setting logger backends into panic mode.
*
* When this function is called all attached backends are informed about panic state of the system.
* It is up to the backend to react properly (hold or process logs in blocking mode, etc.)
*/
void nrf_log_panic(void);
/**
* @brief Function for handling a single log entry.
*
* Use this function only if the logs are buffered. It takes a single entry from the
* buffer and attempts to process it.
*
* @retval true If there are more entries to process.
* @retval false If there are no more entries to process.
*/
bool nrf_log_frontend_dequeue(void);
/**
* @brief Function for getting number of independent log modules registered into the logger.
*
* @return Number of registered modules.
*/
uint32_t nrf_log_module_cnt_get(void);
/**
* @brief Function for getting module name.
*
* @param module_id Module ID.
* @param is_ordered_idx Module ID is given is index in alphabetically sorted list of modules.
* @return Pointer to string with module name.
*/
const char * nrf_log_module_name_get(uint32_t module_id, bool is_ordered_idx);
/**
* @brief Function for getting coloring of specific logs.
*
* @param module_id Module ID.
* @param severity Log severity.
*
* @return ID of the color.
*/
uint8_t nrf_log_color_id_get(uint32_t module_id, nrf_log_severity_t severity);
/**
* @brief Function for configuring filtering ofs logs in the module.
*
* Filtering of logs in modules is independent for each backend.
*
* @param backend_id Backend ID which want to chenge its configuration.
* @param module_id Module ID which logs will be reconfigured.
* @param severity New severity filter.
*/
void nrf_log_module_filter_set(uint32_t backend_id,
uint32_t module_id,
nrf_log_severity_t severity);
/**
* @brief Function for getting module severity level.
*
* @param backend_id Backend ID.
* @param module_id Module ID.
* @param is_ordered_idx Module ID is given is index in alphabetically sorted list of modules.
* @param dynamic It true current filter for given backend is returned. If false then
* compiled-in level is returned (maximum available). If this parameter is
* false then backend_id parameter is not used.
*
* @return Severity.
*/
nrf_log_severity_t nrf_log_module_filter_get(uint32_t backend_id,
uint32_t module_id,
bool is_ordered_idx,
bool dynamic);
/**
* @brief Function stores current filtering configuration into non-volatile memory using @ref fds module.
*
* @return NRF_SUCCESS or @ref fds error code.
*/
ret_code_t nrf_log_config_store(void);
/**
* @brief Function loads configuration from non-volatile memory using @ref fds module.
*
* @retval NRF_SUCCESS On successful loading.
* @retval NRF_ERROR_NOT_FOUND Configuration file not found.
* @retval NRF_ERROR_INTERNAL Other @ref fds error on reading configuration file.
*/
ret_code_t nrf_log_config_load(void);
#ifdef __cplusplus
}
#endif
#endif // NRF_LOG_CTRL_H
/**
*@}
**/

Some files were not shown because too many files have changed in this diff Show More