mirror of
https://github.com/espressif/openthread.git
synced 2026-10-08 00:37:40 +00:00
[nrf528xx] move to openthread/ot-nrf528xx (#6585)
This commit is contained in:
@@ -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) ""
|
||||
@@ -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) ""
|
||||
@@ -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) ""
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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 +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 +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 (Nordic’s 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 +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 (Nordic’s 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_
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(©Length);
|
||||
#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;
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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_
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user