mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[samr21] move to openthread/ot-samr21 (#6369)
This commit is contained in:
+4
-7
@@ -781,14 +781,14 @@ AC_MSG_CHECKING([whether to build examples])
|
||||
AC_ARG_WITH(examples,
|
||||
[AS_HELP_STRING([--with-examples=TARGET],
|
||||
[Build example applications for one of: simulation, cc1352, cc2538, cc2650, cc2652, efr32mg1, efr32mg12, efr32mg13, efr32mg21,
|
||||
gp712, jn5189, k32w061, kw41z, nrf52811, nrf52833, nrf52840, qpg6095, qpg6100, qpg7015m, samr21 @<:@default=no@:>@.
|
||||
gp712, jn5189, k32w061, kw41z, nrf52811, nrf52833, nrf52840, qpg6095, qpg6100, qpg7015m @<:@default=no@:>@.
|
||||
Note that building example applications also builds the associated OpenThread platform libraries
|
||||
and any third_party libraries needed to support the examples.])],
|
||||
[
|
||||
case "${with_examples}" in
|
||||
no)
|
||||
;;
|
||||
simulation|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|gp712|jn5189|k32w061|kw41z|nrf52811|nrf52833|nrf52840|qpg6095|qpg6100|qpg7015m|samr21)
|
||||
simulation|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|gp712|jn5189|k32w061|kw41z|nrf52811|nrf52833|nrf52840|qpg6095|qpg6100|qpg7015m)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(ERROR)
|
||||
@@ -819,7 +819,6 @@ AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52840], [test "${with_examples}" = "nrf5
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_QPG6095], [test "${with_examples}" = "qpg6095"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_QPG6100], [test "${with_examples}" = "qpg6100"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_QPG7015M], [test "${with_examples}" = "qpg7015m"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_SAMR21], [test "${with_examples}" = "samr21"])
|
||||
|
||||
AM_COND_IF([OPENTHREAD_EXAMPLES_SIMULATION], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=0")
|
||||
|
||||
@@ -844,11 +843,11 @@ AC_MSG_CHECKING([whether to build platform libraries])
|
||||
AC_ARG_WITH(platform,
|
||||
[AS_HELP_STRING([--with-platform=TARGET],
|
||||
[Build OpenThread platform libraries for one of: cc1352, cc2538, cc2650, cc2652,
|
||||
efr32mg1, efr32mg12, efr32mg13, efr32mg21, gp712, jn5189, kw41z, nrf52811, nrf52833, nrf52840, posix, qpg6095, qpg6100, qpg7015m, samr21, simulation @<:@default=simulation@:>@.])],
|
||||
efr32mg1, efr32mg12, efr32mg13, efr32mg21, gp712, jn5189, kw41z, nrf52811, nrf52833, nrf52840, posix, qpg6095, qpg6100, qpg7015m, simulation @<:@default=simulation@:>@.])],
|
||||
[
|
||||
# Make sure the given target is valid.
|
||||
case "${with_platform}" in
|
||||
no|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|gp712|jn5189|kw41z|nrf52811|nrf52833|nrf52840|posix|qpg6095|qpg6100|qpg7015m|samr21|simulation)
|
||||
no|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|gp712|jn5189|kw41z|nrf52811|nrf52833|nrf52840|posix|qpg6095|qpg6100|qpg7015m|simulation)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(ERROR)
|
||||
@@ -897,7 +896,6 @@ AM_CONDITIONAL([OPENTHREAD_PLATFORM_POSIX], [test "${with_platform}" = "posi
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_QPG6095], [test "${with_platform}" = "qpg6095"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_QPG6100], [test "${with_platform}" = "qpg6100"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_QPG7015M], [test "${with_platform}" = "qpg7015m"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_SAMR21], [test "${with_platform}" = "samr21"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_SIMULATION],[test "${with_platform}" = "simulation"])
|
||||
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF528XX], [test OPENTHREAD_PLATFORM_NRF52811 || test OPENTHREAD_PLATFORM_NRF52833 || test OPENTHREAD_PLATFORM_NRF52840])
|
||||
@@ -1056,7 +1054,6 @@ examples/platforms/nrf528xx/Makefile
|
||||
examples/platforms/qpg6095/Makefile
|
||||
examples/platforms/qpg6100/Makefile
|
||||
examples/platforms/qpg7015m/Makefile
|
||||
examples/platforms/samr21/Makefile
|
||||
examples/platforms/simulation/Makefile
|
||||
examples/platforms/utils/Makefile
|
||||
tools/Makefile
|
||||
|
||||
@@ -1,286 +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.
|
||||
#
|
||||
|
||||
.NOTPARALLEL:
|
||||
|
||||
AR = arm-none-eabi-ar
|
||||
CCAS = arm-none-eabi-as
|
||||
CPP = arm-none-eabi-cpp
|
||||
CC = arm-none-eabi-gcc
|
||||
CXX = 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
|
||||
|
||||
BuildJobs ?= 10
|
||||
|
||||
|
||||
# Board setup
|
||||
|
||||
BOARD ?= SAMR21_XPLAINED_PRO
|
||||
|
||||
ifeq ($(BOARD), SAMR21_XPLAINED_PRO)
|
||||
CPU = __SAMR21G18A__
|
||||
else ifeq ($(BOARD), SAMR21G18_MODULE)
|
||||
CPU = __SAMR21G18A__
|
||||
else ifeq ($(BOARD), SAMR21B18_MODULE)
|
||||
CPU=__SAMR21G18A__
|
||||
else
|
||||
$(error Invalid BOARD=$(BOARD) (currently supported SAMR21_XPLAINED_PRO, SAMR21G18_MODULE, SAMR21B18_MODULE))
|
||||
endif
|
||||
|
||||
configure_OPTIONS = \
|
||||
--enable-cli \
|
||||
--enable-ftd \
|
||||
--enable-mtd \
|
||||
--enable-ncp \
|
||||
--enable-radio-only \
|
||||
--enable-linker-map \
|
||||
--with-examples=samr21 \
|
||||
MBEDTLS_CPPFLAGS="$(SAMR21_MBEDTLS_CPPFLAGS)" \
|
||||
$(NULL)
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
SAMR21_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
|
||||
SAMR21_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"samr21-mbedtls-config.h\"'
|
||||
SAMR21_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/samr21/crypto
|
||||
SAMR21_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
|
||||
SAMR21_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
|
||||
|
||||
SAMR21_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-samr21-config.h\"'
|
||||
SAMR21_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-samr21-config-check.h\"'
|
||||
SAMR21_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/samr21/
|
||||
|
||||
COMMONCFLAGS := \
|
||||
-DBOARD=$(BOARD) \
|
||||
-D$(CPU) \
|
||||
-fdata-sections \
|
||||
-ffunction-sections \
|
||||
-Os \
|
||||
-g \
|
||||
$(SAMR21_CONFIG_FILE_CPPFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
|
||||
|
||||
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 \
|
||||
-Wl,--entry=Reset_Handler \
|
||||
$(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 = samr21
|
||||
|
||||
ARCHS = cortex-m0plus
|
||||
|
||||
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)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" 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): $(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-m0plus
|
||||
#
|
||||
|
||||
cortex-m0plus_target_ABI = cortex-m0plus
|
||||
cortex-m0plus_target_CPPFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
cortex-m0plus_target_CFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
cortex-m0plus_target_CXXFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
cortex-m0plus_target_LDFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
|
||||
# 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) ""
|
||||
@@ -28,6 +28,10 @@
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
EXTRA_DIST = \
|
||||
samr21 \
|
||||
$(NULL)
|
||||
|
||||
# Always package (e.g. for 'make dist') these subdirectories.
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
@@ -44,7 +48,6 @@ DIST_SUBDIRS = \
|
||||
qpg6095 \
|
||||
qpg6100 \
|
||||
qpg7015m \
|
||||
samr21 \
|
||||
utils \
|
||||
$(NULL)
|
||||
|
||||
@@ -106,10 +109,6 @@ if OPENTHREAD_PLATFORM_QPG7015M
|
||||
SUBDIRS += qpg7015m
|
||||
endif
|
||||
|
||||
if OPENTHREAD_EXAMPLES_SAMR21
|
||||
SUBDIRS += samr21
|
||||
endif
|
||||
|
||||
noinst_HEADERS = \
|
||||
openthread-system.h \
|
||||
$(NULL)
|
||||
|
||||
@@ -101,10 +101,6 @@ if OPENTHREAD_EXAMPLES_QPG7015M
|
||||
include $(top_srcdir)/examples/platforms/qpg7015m/Makefile.platform.am
|
||||
endif
|
||||
|
||||
if OPENTHREAD_EXAMPLES_SAMR21
|
||||
include $(top_srcdir)/examples/platforms/samr21/Makefile.platform.am
|
||||
endif # OPENTHREAD_EXAMPLES_SAMR21
|
||||
|
||||
if OPENTHREAD_EXAMPLES_SIMULATION
|
||||
include $(top_srcdir)/examples/platforms/simulation/Makefile.platform.am
|
||||
endif
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2020, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
set(OT_PLATFORM_LIB "openthread-samr21" PARENT_SCOPE)
|
||||
|
||||
if(NOT OT_CONFIG)
|
||||
set(OT_CONFIG "openthread-core-samr21-config.h")
|
||||
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES
|
||||
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-samr21-config-check.h\""
|
||||
)
|
||||
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
|
||||
|
||||
target_compile_definitions(ot-config INTERFACE "MBEDTLS_USER_CONFIG_FILE=\"samr21-mbedtls-config.h\"")
|
||||
list(APPEND OT_PUBLIC_INCLUDES
|
||||
"${PROJECT_SOURCE_DIR}/examples/platforms/samr21/crypto"
|
||||
)
|
||||
set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE)
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
|
||||
|
||||
add_library(openthread-samr21
|
||||
alarm.c
|
||||
crypto/aes_alt.c
|
||||
cxx_helpers.c
|
||||
diag.c
|
||||
entropy.c
|
||||
flash.c
|
||||
logging.c
|
||||
misc.c
|
||||
radio.c
|
||||
system.c
|
||||
uart.c
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
openthread-samr21
|
||||
PROPERTIES
|
||||
C_STANDARD 99
|
||||
CXX_STANDARD 11
|
||||
)
|
||||
|
||||
if(OT_CFLAGS MATCHES "-pedantic-errors")
|
||||
string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(openthread-samr21
|
||||
PUBLIC
|
||||
samr21-driver
|
||||
-Wl,--gc-sections
|
||||
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
|
||||
PRIVATE
|
||||
${OT_MBEDTLS}
|
||||
ot-config
|
||||
)
|
||||
|
||||
target_compile_definitions(openthread-samr21
|
||||
PUBLIC
|
||||
${OT_PLATFORM_DEFINES}
|
||||
)
|
||||
|
||||
target_compile_options(openthread-samr21
|
||||
PRIVATE
|
||||
-Wno-implicit-function-declaration
|
||||
-Wno-expansion-to-defined
|
||||
${OT_CFLAGS}
|
||||
)
|
||||
|
||||
target_include_directories(openthread-samr21
|
||||
PRIVATE
|
||||
${OT_PUBLIC_INCLUDES}
|
||||
${PROJECT_SOURCE_DIR}/src/core
|
||||
${PROJECT_SOURCE_DIR}/examples/platforms
|
||||
)
|
||||
@@ -1,148 +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 $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
lib_LIBRARIES = libopenthread-samr21.a
|
||||
|
||||
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
|
||||
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
|
||||
|
||||
# Do not enable -Wundef for this platform
|
||||
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
|
||||
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
|
||||
|
||||
# Do not enable -Wcast-align for this platform
|
||||
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
|
||||
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
|
||||
|
||||
libopenthread_samr21_a_CPPFLAGS = \
|
||||
-D ARM_MATH_CM0PLUS=true \
|
||||
-D PHY_AT86RF233 \
|
||||
-D SAL_TYPE=AT86RF2xx \
|
||||
-D USART_CALLBACK_MODE=true \
|
||||
-D EXTINT_CALLBACK_MODE=true \
|
||||
-D SPI_CALLBACK_MODE=false \
|
||||
-D CYCLE_MODE \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/platforms \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/third_party/microchip/include \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/common/boards \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/common/utils \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/common2/services/delay \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/common2/services/delay/sam0 \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/boards \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/boards/samr21_xplained_pro \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/extint \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/extint/extint_sam_d_r_h \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/nvm \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/port \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/clock \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/clock/clock_samd21_r21_da_ha1 \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/interrupt \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/interrupt/system_interrupt_samr21 \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/pinmux \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/power \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/power/power_sam_d_r_h \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/reset \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/system/reset/reset_sam_d_r_h \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/sercom \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/sercom/i2c \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/sercom/i2c/i2c_sam0 \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/sercom/spi \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/drivers/sercom/usart \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/utils/cmsis/samr21/include \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/utils/cmsis/samr21/source \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/utils/header_files \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/sam0/utils/preprocessor \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/thirdparty/CMSIS/Include \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/thirdparty/wireless/avr2130_lwmesh/source/phy/at86rf233/inc \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/thirdparty/wireless/services/sal/inc \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/thirdparty/wireless/services/trx_access \
|
||||
-I$(top_srcdir)/third_party/microchip/asf/thirdparty/wireless/services/trx_access/module_config \
|
||||
-Werror \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-implicit-function-declaration \
|
||||
-Wno-expansion-to-defined \
|
||||
-fno-strict-aliasing \
|
||||
$(NULL)
|
||||
|
||||
PLATFORM_SOURCES = \
|
||||
crypto/aes_alt.c \
|
||||
alarm.c \
|
||||
cxx_helpers.c \
|
||||
diag.c \
|
||||
entropy.c \
|
||||
flash.c \
|
||||
logging.c \
|
||||
misc.c \
|
||||
openthread-core-samr21-config.h \
|
||||
openthread-core-samr21-config-check.h \
|
||||
platform-samr21.h \
|
||||
radio.c \
|
||||
system.c \
|
||||
uart.c \
|
||||
user_row.h \
|
||||
$(NULL)
|
||||
|
||||
libopenthread_samr21_a_SOURCES = \
|
||||
$(PLATFORM_SOURCES) \
|
||||
$(NULL)
|
||||
|
||||
nodist_libopenthread_samr21_a_SOURCES = \
|
||||
@top_builddir@/third_party/microchip/asf/common/utils/interrupt/interrupt_sam_nvic.c \
|
||||
@top_builddir@/third_party/microchip/asf/common2/services/delay/sam0/cycle_counter.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/extint/extint_callback.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/extint/extint_sam_d_r_h/extint.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/nvm/nvm.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/port/port.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/system/clock/clock_samd21_r21_da_ha1/clock.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/system/clock/clock_samd21_r21_da_ha1/gclk.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/system/interrupt/system_interrupt.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/system/pinmux/pinmux.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/sercom/sercom.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/sercom/sercom_interrupt.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/sercom/i2c/i2c_sam0/i2c_master.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/sercom/spi/spi.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/sercom/usart/usart.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/drivers/sercom/usart/usart_interrupt.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/utils/cmsis/samr21/source/gcc/startup_samr21.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/utils/cmsis/samr21/source/system_samr21.c \
|
||||
@top_builddir@/third_party/microchip/asf/sam0/utils/syscalls/gcc/syscalls.c \
|
||||
@top_builddir@/third_party/microchip/asf/thirdparty/wireless/avr2130_lwmesh/source/phy/at86rf233/src/phy.c \
|
||||
@top_builddir@/third_party/microchip/asf/thirdparty/wireless/services/sal/at86rf2xx/src/sal.c \
|
||||
@top_builddir@/third_party/microchip/asf/thirdparty/wireless/services/trx_access/trx_access.c \
|
||||
$(NULL)
|
||||
|
||||
Dash = -
|
||||
libopenthread_samr21_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,39 +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.
|
||||
#
|
||||
|
||||
#
|
||||
# samr21 platform-specific Makefile
|
||||
#
|
||||
|
||||
LDADD_COMMON += \
|
||||
$(top_builddir)/examples/platforms/samr21/libopenthread-samr21.a \
|
||||
$(NULL)
|
||||
|
||||
LDFLAGS_COMMON += \
|
||||
-T $(top_srcdir)/third_party/microchip/include/samr21x18a.ld \
|
||||
$(NULL)
|
||||
@@ -1,207 +1 @@
|
||||
# OpenThread on SAMR21 Example
|
||||
|
||||
This directory contains example platform drivers for the [Microchip ATSAMR21G18A][samr21] based on [SAM R21 Xplained Pro Evaluation Kit][samr21_xplained_pro].
|
||||
|
||||
[samr21]: http://www.microchip.com/wwwproducts/en/ATSAMR21G18A
|
||||
[samr21_xplained_pro]: https://www.microchip.com/DevelopmentTools/ProductDetails/ATSAMR21-XPRO
|
||||
|
||||
The example platform drivers are intended to present the minimal code necessary to support OpenThread. See the "Run the example with SAMR21 boards" section below for an example using basic OpenThread capabilities.
|
||||
|
||||
## 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
|
||||
|
||||
In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.
|
||||
|
||||
```bash
|
||||
$ cd <path-to-openthread>
|
||||
$ ./script/bootstrap
|
||||
```
|
||||
|
||||
## Build Examples
|
||||
|
||||
1. Download [Advanced Software Framework (ASF)][asf].
|
||||
|
||||
[asf]: https://www.microchip.com/mplab/avr-support/advanced-software-framework
|
||||
|
||||
2. Unzip it to <path-to-openthread>/third_party/microchip folder
|
||||
|
||||
```bash
|
||||
$ unzip asf-standalone-archive-3.45.0.85.zip
|
||||
$ cp xdk-asf-3.45.0 -rf <path-to-openthread>/third_party/microchip/asf
|
||||
```
|
||||
|
||||
3. Build OpenThread Firmware (CLI example) on SAMR21 platform.
|
||||
|
||||
```bash
|
||||
$ cd <path-to-openthread>
|
||||
$ ./bootstrap
|
||||
$ make -f examples/Makefile-samr21
|
||||
```
|
||||
|
||||
4. This example can be built for other SAMR21 based modules e.g.:
|
||||
|
||||
- [ATSAMR21G18-MR210UA][module-mr210ua]
|
||||
- [ATSAMR21B18-MZ210PA][module-mz210pa]
|
||||
|
||||
To build for these modules set BOARD variable in command line as following:
|
||||
|
||||
```bash
|
||||
$ make -f examples/Makefile-samr21 BOARD=<MODULE>
|
||||
```
|
||||
|
||||
where:
|
||||
|
||||
| `<module>` | Board |
|
||||
| --------------------- | ----------------------------------- |
|
||||
| `SAMR21_XPLAINED_PRO` | SAM R21 Xplained Pro Evaluation Kit |
|
||||
| `SAMR21G18_MODULE` | ATSAMR21G18-MR210UA |
|
||||
| `SAMR21B18_MODULE` | ATSAMR21B18-MZ210PA |
|
||||
|
||||
[module-mr210ua]: http://ww1.microchip.com/downloads/en/devicedoc/atmel-42475-atsamr21g18-mr210ua_datasheet.pdf
|
||||
[module-mz210pa]: http://ww1.microchip.com/downloads/en/devicedoc/atmel-42486-atsamr21b18-mz210pa_datasheet.pdf
|
||||
|
||||
After a successful build, the `elf` files are found in `<path-to-openthread>/output/samr21/bin`.
|
||||
|
||||
## Flash Binaries
|
||||
|
||||
Compiled binaries may be flashed onto the SAM R21 Xplained Pro using embedded debugger EDBG.
|
||||
|
||||
```bash
|
||||
$ openocd -f board/atmel_samr21_xplained_pro.cfg
|
||||
$ cd <path-to-openthread>/output/samr21/bin
|
||||
$ arm-none-eabi-gdb ot-cli-ftd
|
||||
$ (gdb) target remote 127.0.0.1:3333
|
||||
$ (gdb) load
|
||||
$ (gdb) monitor reset
|
||||
$ (gdb) c
|
||||
```
|
||||
|
||||
## Run the example with SAM R21 Xplained Pro boards
|
||||
|
||||
1. Flash two SAM R21 Xplained Pro boards with the `CLI example` firmware (as shown above).
|
||||
2. Open terminal to first device `/dev/ttyACM0` (serial port settings: 115200 8-N-1). Type `help` for a list of commands.
|
||||
|
||||
```bash
|
||||
> help
|
||||
help
|
||||
channel
|
||||
childtimeout
|
||||
contextreusedelay
|
||||
extaddr
|
||||
extpanid
|
||||
ipaddr
|
||||
keysequence
|
||||
leaderweight
|
||||
masterkey
|
||||
mode
|
||||
netdata register
|
||||
networkidtimeout
|
||||
networkname
|
||||
panid
|
||||
ping
|
||||
prefix
|
||||
releaserouterid
|
||||
rloc16
|
||||
route
|
||||
routerupgradethreshold
|
||||
scan
|
||||
start
|
||||
state
|
||||
stop
|
||||
```
|
||||
|
||||
3. Start a Thread network as Leader.
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
wait a couple of seconds...
|
||||
|
||||
> state leader Done
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
4. Open terminal to second device `/dev/ttyACM1` (serial port settings: 115200 8-N-1) and attach it to the Thread network as a Router.
|
||||
|
||||
```bash
|
||||
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
|
||||
Done
|
||||
> dataset commit active
|
||||
Done
|
||||
> routerselectionjitter 1
|
||||
Done
|
||||
> ifconfig up
|
||||
Done
|
||||
> thread start
|
||||
Done
|
||||
|
||||
wait a couple of seconds...
|
||||
|
||||
> state
|
||||
router
|
||||
Done
|
||||
```
|
||||
|
||||
5. List all IPv6 addresses of Leader.
|
||||
|
||||
```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. Send an ICMPv6 ping to Leader's Mesh-EID IPv6 address.
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
The above example demonstrates basic OpenThread capabilities. Enable more features/roles (e.g. commissioner, joiner, DHCPv6 Server/Client, etc.) by assigning compile-options before compiling.
|
||||
|
||||
```bash
|
||||
$ cd <path-to-openthread>
|
||||
$ ./bootstrap
|
||||
$ make -f examples/Makefile-samr21 COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1
|
||||
```
|
||||
|
||||
For a list of all available commands, visit [OpenThread CLI Reference README.md][cli].
|
||||
|
||||
[cli]: https://github.com/openthread/openthread/blob/main/src/cli/README.md
|
||||
|
||||
## Other boards
|
||||
|
||||
## Verification
|
||||
|
||||
The following toolchain has been used for testing and verification:
|
||||
|
||||
- gcc version 7.3.1
|
||||
- Advanced Software Framework (ASF) version 3.45.0
|
||||
The OpenThread on SAMR21 example has moved to https://github.com/openthread/ot-samr21
|
||||
|
||||
@@ -1,92 +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 the alarm.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "asf.h"
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
static volatile uint32_t sTime = 0;
|
||||
static uint32_t sDeltaTime = 0;
|
||||
static uint32_t sStartTime = 0;
|
||||
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
sDeltaTime = aDt;
|
||||
sStartTime = aT0;
|
||||
}
|
||||
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
sDeltaTime = 0;
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return sTime;
|
||||
}
|
||||
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
sTime++;
|
||||
}
|
||||
|
||||
void samr21AlarmInit(void)
|
||||
{
|
||||
/*Configure system tick to generate periodic interrupts */
|
||||
SysTick_Config(system_gclk_gen_get_hz(GCLK_GENERATOR_0) / 1000);
|
||||
}
|
||||
|
||||
void samr21AlarmProcess(otInstance *aInstance)
|
||||
{
|
||||
if ((sDeltaTime != 0) && ((sTime - sStartTime) >= sDeltaTime))
|
||||
{
|
||||
sDeltaTime = 0;
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
|
||||
if (otPlatDiagModeGet())
|
||||
{
|
||||
otPlatDiagAlarmFired(aInstance);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2020, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
set(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)
|
||||
|
||||
set(COMMON_C_FLAGS "-mcpu=cortex-m0plus -mfloat-abi=soft -mthumb -fdata-sections -ffunction-sections")
|
||||
|
||||
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}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -Wl,--entry=Reset_Handler")
|
||||
@@ -1,142 +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 "aes_alt.h"
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
#ifdef MBEDTLS_AES_ALT
|
||||
|
||||
#include "sal.h"
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <string.h>
|
||||
|
||||
void mbedtls_aes_init(mbedtls_aes_context *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
}
|
||||
|
||||
void mbedtls_aes_free(mbedtls_aes_context *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
}
|
||||
|
||||
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
switch (keybits)
|
||||
{
|
||||
case 128:
|
||||
sal_aes_setup((uint8_t *)key, AES_MODE_ECB, AES_DIR_ENCRYPT);
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = MBEDTLS_ERR_AES_INVALID_KEY_LENGTH;
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
switch (keybits)
|
||||
{
|
||||
case 128:
|
||||
sal_aes_setup((uint8_t *)key, AES_MODE_ECB, AES_DIR_DECRYPT);
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = MBEDTLS_ERR_AES_INVALID_KEY_LENGTH;
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief AES-ECB block encryption/decryption
|
||||
*
|
||||
* \param ctx AES context
|
||||
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
|
||||
* \param input 16-byte input block
|
||||
* \param output 16-byte output block
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
sal_aes_wrrd((uint8_t *)input, NULL);
|
||||
sal_aes_read((uint8_t *)output);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int mbedtls_aes_self_test(int verbose)
|
||||
{
|
||||
(void)verbose;
|
||||
|
||||
/* 128-bit Key 2b7e151628aed2a6abf7158809cf4f3c */
|
||||
const uint8_t key_128b[16] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
|
||||
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
|
||||
mbedtls_aes_context aes;
|
||||
int retval = 0;
|
||||
|
||||
uint8_t input[16] = {0};
|
||||
uint8_t output[16] = {0};
|
||||
uint8_t decrypt[16] = {0};
|
||||
|
||||
strcpy((char *)input, (const char *)"hw_aes_test");
|
||||
|
||||
mbedtls_aes_init(&aes);
|
||||
|
||||
retval = mbedtls_aes_setkey_enc(&aes, (const unsigned char *)key_128b, 128);
|
||||
VerifyOrExit(retval != 0, retval = -1);
|
||||
|
||||
retval = mbedtls_aes_setkey_dec(&aes, (const unsigned char *)key_128b, 128);
|
||||
VerifyOrExit(retval != 0, retval = -1);
|
||||
|
||||
retval = mbedtls_aes_crypt_ecb(&aes, MBEDTLS_AES_ENCRYPT, input, output);
|
||||
VerifyOrExit(retval != 0, retval = -1);
|
||||
|
||||
retval = mbedtls_aes_crypt_ecb(&aes, MBEDTLS_AES_DECRYPT, output, decrypt);
|
||||
VerifyOrExit(retval != 0, retval = -1);
|
||||
|
||||
mbedtls_aes_free(&aes);
|
||||
|
||||
exit:
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_AES_ALT */
|
||||
@@ -1,164 +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 MBEDTLS_AES_ALT_H
|
||||
#define MBEDTLS_AES_ALT_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "samr21-mbedtls-config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#ifdef MBEDTLS_AES_ALT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hwKeyLen;
|
||||
unsigned char aes_enc_key[32]; /* Encryption key */
|
||||
unsigned char aes_dec_key[32]; /* Decryption key */
|
||||
} mbedtls_aes_context;
|
||||
|
||||
/**
|
||||
* @brief Initialize AES context
|
||||
*
|
||||
* @param [in,out] ctx AES context to be initialized
|
||||
*/
|
||||
void mbedtls_aes_init(mbedtls_aes_context *ctx);
|
||||
|
||||
/**
|
||||
* @brief Clear AES context
|
||||
*
|
||||
* \param ctx AES context to be cleared
|
||||
*/
|
||||
void mbedtls_aes_free(mbedtls_aes_context *ctx);
|
||||
|
||||
/**
|
||||
* \brief AES key schedule (encryption)
|
||||
*
|
||||
* \param ctx AES context to be initialized
|
||||
* \param key encryption key
|
||||
* \param keybits must be 128, 192 or 256
|
||||
*
|
||||
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
|
||||
*/
|
||||
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits);
|
||||
|
||||
/**
|
||||
* \brief AES key schedule (decryption)
|
||||
*
|
||||
* \param ctx AES context to be initialized
|
||||
* \param key decryption key
|
||||
* \param keybits must be 128, 192 or 256
|
||||
*
|
||||
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
|
||||
*/
|
||||
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits);
|
||||
|
||||
/**
|
||||
* \brief AES-ECB block encryption/decryption
|
||||
*
|
||||
* \param ctx AES context
|
||||
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
|
||||
* \param input 16-byte input block
|
||||
* \param output 16-byte output block
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16]);
|
||||
|
||||
/**
|
||||
* \brief AES-CBC buffer encryption/decryption
|
||||
* Length should be a multiple of the block
|
||||
* size (16 bytes)
|
||||
*
|
||||
* \note Upon exit, the content of the IV is updated so that you can
|
||||
* call the function same function again on the following
|
||||
* block(s) of data and get the same result as if it was
|
||||
* encrypted in one call. This allows a "streaming" usage.
|
||||
* If on the other hand you need to retain the contents of the
|
||||
* IV, you should either save it manually or use the cipher
|
||||
* module instead.
|
||||
*
|
||||
* \param ctx AES context
|
||||
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
|
||||
* \param length length of the input data
|
||||
* \param iv initialization vector (updated after use)
|
||||
* \param input buffer holding the input data
|
||||
* \param output buffer holding the output data
|
||||
*
|
||||
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
|
||||
*/
|
||||
int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,
|
||||
int mode,
|
||||
size_t length,
|
||||
unsigned char iv[16],
|
||||
const unsigned char *input,
|
||||
unsigned char * output);
|
||||
|
||||
/**
|
||||
* \brief AES-CTR buffer encryption/decryption
|
||||
*
|
||||
* Warning: You have to keep the maximum use of your counter in mind!
|
||||
*
|
||||
* Note: Due to the nature of CTR you should use the same key schedule for
|
||||
* both encryption and decryption. So a context initialized with
|
||||
* mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT.
|
||||
*
|
||||
* \param ctx AES context
|
||||
* \param length The length of the data
|
||||
* \param nc_off The offset in the current stream_block (for resuming
|
||||
* within current cipher stream). The offset pointer to
|
||||
* should be 0 at the start of a stream.
|
||||
* \param nonce_counter The 128-bit nonce and counter.
|
||||
* \param stream_block The saved stream-block for resuming. Is overwritten
|
||||
* by the function.
|
||||
* \param input The input data stream
|
||||
* \param output The output data stream
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx,
|
||||
size_t length,
|
||||
size_t * nc_off,
|
||||
unsigned char nonce_counter[16],
|
||||
unsigned char stream_block[16],
|
||||
const unsigned char *input,
|
||||
unsigned char * output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_AES_ALT */
|
||||
|
||||
#endif /* MBEDTLS_AES_ALT_H */
|
||||
@@ -1,47 +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 SAMR21_MBEDTLS_CONFIG_H
|
||||
#define SAMR21_MBEDTLS_CONFIG_H
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_AES_ALT
|
||||
*
|
||||
* Enable hardware acceleration for the AES block cipher
|
||||
*
|
||||
* Module: sl_crypto/src/sl_aes.c
|
||||
* or
|
||||
* sl_crypto/src/slcl_aes.c if MBEDTLS_SLCL_PLUGINS is defined.
|
||||
*
|
||||
* See MBEDTLS_AES_C for more information.
|
||||
*/
|
||||
#define MBEDTLS_AES_ALT
|
||||
|
||||
#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
|
||||
|
||||
#endif // SAMR21_MBEDTLS_CONFIG_H
|
||||
@@ -1,54 +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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Helper functions for running c++ without the standard library
|
||||
*/
|
||||
|
||||
__extension__ typedef int __guard __attribute__((mode(__DI__)));
|
||||
|
||||
int __cxa_guard_acquire(__guard *g)
|
||||
{
|
||||
return !*(char *)(g);
|
||||
}
|
||||
|
||||
void __cxa_guard_release(__guard *g)
|
||||
{
|
||||
*(char *)g = 1;
|
||||
}
|
||||
|
||||
void __cxa_guard_abort(__guard *g)
|
||||
{
|
||||
(void)g;
|
||||
}
|
||||
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
@@ -1,80 +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 the diagnostics.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
|
||||
/**
|
||||
* Diagnostics mode variables.
|
||||
*
|
||||
*/
|
||||
static bool sDiagMode = false;
|
||||
|
||||
void otPlatDiagModeSet(bool aMode)
|
||||
{
|
||||
sDiagMode = aMode;
|
||||
}
|
||||
|
||||
bool otPlatDiagModeGet()
|
||||
{
|
||||
return sDiagMode;
|
||||
}
|
||||
|
||||
void otPlatDiagChannelSet(uint8_t aChannel)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aChannel);
|
||||
}
|
||||
|
||||
void otPlatDiagTxPowerSet(int8_t aTxPower)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aTxPower);
|
||||
}
|
||||
|
||||
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aFrame);
|
||||
OT_UNUSED_VARIABLE(aError);
|
||||
}
|
||||
|
||||
void otPlatDiagAlarmCallback(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
@@ -1,46 +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 "phy.h"
|
||||
#include "platform-samr21.h"
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
samr21RadioRandomGetTrue(aOutput, aOutputLength);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
@@ -1,128 +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 the non-volatile storage.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#include "asf.h"
|
||||
|
||||
#define OT_FLASH_BASE_ADDRESS ((uint32_t)&__d_nv_mem_start)
|
||||
#define OT_FLASH_PAGE_SIZE 0x100
|
||||
|
||||
/*
|
||||
* This value should not exceed:
|
||||
* (((uint32_t)&__d_nv_mem_end - (uint32_t)&__d_nv_mem_start) / OT_FLASH_PAGE_SIZE)
|
||||
*
|
||||
* __d_nv_mem_start and __d_nv_mem_end is defined in linker script.
|
||||
* The size of NVRAM region is 4k. Page size is 256 bytes. Maximum OT_FLASH_PAGE_NUM
|
||||
* should be equal or less than 16.
|
||||
*
|
||||
*/
|
||||
#define OT_FLASH_PAGE_NUM 16
|
||||
|
||||
#define OT_FLASH_SWAP_SIZE (OT_FLASH_PAGE_SIZE * (OT_FLASH_PAGE_NUM / 2))
|
||||
|
||||
extern uint32_t __d_nv_mem_start;
|
||||
extern uint32_t __d_nv_mem_end;
|
||||
|
||||
static uint32_t mapAddress(uint8_t aSwapIndex, uint32_t aOffset)
|
||||
{
|
||||
uint32_t address = OT_FLASH_BASE_ADDRESS + aOffset;
|
||||
|
||||
if (aSwapIndex)
|
||||
{
|
||||
address += OT_FLASH_SWAP_SIZE;
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
void otPlatFlashInit(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
struct nvm_config configNvm;
|
||||
enum status_code status;
|
||||
|
||||
nvm_get_config_defaults(&configNvm);
|
||||
|
||||
configNvm.manual_page_write = false;
|
||||
while ((status = nvm_set_config(&configNvm)) == STATUS_BUSY)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t otPlatFlashGetSwapSize(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return OT_FLASH_SWAP_SIZE;
|
||||
}
|
||||
|
||||
void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
nvm_erase_row(mapAddress(aSwapIndex, 0));
|
||||
while (!nvm_is_ready())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
uint32_t address = mapAddress(aSwapIndex, aOffset);
|
||||
|
||||
for (uint32_t i = 0; i < (aSize / sizeof(uint32_t)); i++)
|
||||
{
|
||||
*((volatile uint32_t *)address) = *((uint32_t *)aData);
|
||||
aData += sizeof(uint32_t);
|
||||
address += sizeof(uint32_t);
|
||||
}
|
||||
|
||||
// check if write page command is required
|
||||
if ((address) & (NVMCTRL_PAGE_SIZE - 1))
|
||||
{
|
||||
nvm_execute_command(NVM_COMMAND_WRITE_PAGE, address & (~(NVMCTRL_PAGE_SIZE - 1)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
memcpy(aData, (void *)mapAddress(aSwapIndex, aOffset), aSize);
|
||||
}
|
||||
@@ -1,132 +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 logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "spi.h"
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
|
||||
#if BOARD == SAMR21_XPLAINED_PRO
|
||||
|
||||
#define LOG_PARSE_BUFFER_SIZE 128
|
||||
#define LOG_TIMESTAMP_ENABLE 1
|
||||
|
||||
struct spi_module sMaster;
|
||||
struct spi_slave_inst sSlave;
|
||||
|
||||
char sLogString[LOG_PARSE_BUFFER_SIZE + 1];
|
||||
|
||||
static void logOutput(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list ap)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
len = vsnprintf(sLogString, LOG_PARSE_BUFFER_SIZE, aFormat, ap);
|
||||
|
||||
otEXPECT(len >= 0);
|
||||
|
||||
exit:
|
||||
|
||||
if (len >= LOG_PARSE_BUFFER_SIZE)
|
||||
{
|
||||
len = LOG_PARSE_BUFFER_SIZE - 1;
|
||||
}
|
||||
|
||||
sLogString[len++] = '\n';
|
||||
|
||||
spi_select_slave(&sMaster, &sSlave, true);
|
||||
|
||||
spi_write_buffer_wait(&sMaster, (uint8_t *)sLogString, len);
|
||||
|
||||
spi_select_slave(&sMaster, &sSlave, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void samr21LogInit(void)
|
||||
{
|
||||
#if BOARD == SAMR21_XPLAINED_PRO
|
||||
|
||||
struct spi_slave_inst_config slaveConfig;
|
||||
struct spi_config config;
|
||||
|
||||
spi_slave_inst_get_config_defaults(&slaveConfig);
|
||||
|
||||
slaveConfig.ss_pin = EDBG_SPI_SLAVE_SELECT_PIN;
|
||||
|
||||
spi_attach_slave(&sSlave, &slaveConfig);
|
||||
|
||||
spi_get_config_defaults(&config);
|
||||
|
||||
config.mux_setting = EDBG_SPI_SERCOM_MUX_SETTING;
|
||||
config.mode_specific.master.baudrate = 8000000UL;
|
||||
config.pinmux_pad0 = EDBG_SPI_SERCOM_PINMUX_PAD0;
|
||||
config.pinmux_pad1 = EDBG_SPI_SERCOM_PINMUX_PAD1;
|
||||
config.pinmux_pad2 = EDBG_SPI_SERCOM_PINMUX_PAD2;
|
||||
config.pinmux_pad3 = EDBG_SPI_SERCOM_PINMUX_PAD3;
|
||||
|
||||
spi_init(&sMaster, EDBG_SPI_MODULE, &config);
|
||||
spi_enable(&sMaster);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
#if BOARD == SAMR21_XPLAINED_PRO
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, aFormat);
|
||||
|
||||
logOutput(aLogLevel, aLogRegion, aFormat, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
#else
|
||||
|
||||
OT_UNUSED_VARIABLE(aLogLevel);
|
||||
OT_UNUSED_VARIABLE(aLogRegion);
|
||||
OT_UNUSED_VARIABLE(aFormat);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,97 +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 miscellaneous behaviors.
|
||||
*/
|
||||
|
||||
#include "asf.h"
|
||||
|
||||
#include <openthread/platform/misc.h>
|
||||
|
||||
void otPlatReset(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
system_reset();
|
||||
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
|
||||
{
|
||||
otPlatResetReason reason;
|
||||
|
||||
switch (system_get_reset_cause())
|
||||
{
|
||||
/** The system was last reset by a software reset */
|
||||
case SYSTEM_RESET_CAUSE_SOFTWARE:
|
||||
reason = OT_PLAT_RESET_REASON_SOFTWARE;
|
||||
break;
|
||||
|
||||
/** The system was last reset by the watchdog timer */
|
||||
case SYSTEM_RESET_CAUSE_WDT:
|
||||
reason = OT_PLAT_RESET_REASON_WATCHDOG;
|
||||
break;
|
||||
|
||||
/** The system was last reset because the external reset
|
||||
line was pulled low */
|
||||
case SYSTEM_RESET_CAUSE_EXTERNAL_RESET:
|
||||
reason = OT_PLAT_RESET_REASON_EXTERNAL;
|
||||
break;
|
||||
|
||||
/** The system was last reset by the BOD33 */
|
||||
case SYSTEM_RESET_CAUSE_BOD33:
|
||||
|
||||
// no break: same reason as below
|
||||
|
||||
/** The system was last reset by the BOD12 */
|
||||
case SYSTEM_RESET_CAUSE_BOD12:
|
||||
reason = OT_PLAT_RESET_REASON_FAULT;
|
||||
break;
|
||||
|
||||
/** The system was last reset by the POR (Power on reset) */
|
||||
case SYSTEM_RESET_CAUSE_POR:
|
||||
reason = OT_PLAT_RESET_REASON_POWER_ON;
|
||||
break;
|
||||
|
||||
default:
|
||||
reason = OT_PLAT_RESET_REASON_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return reason;
|
||||
}
|
||||
|
||||
void otPlatWakeHost(void)
|
||||
{
|
||||
// TODO: implement an operation to wake the host from sleep state.
|
||||
}
|
||||
@@ -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_SAMR21_CONFIG_CHECK_H_
|
||||
#define OPENTHREAD_CORE_SAMR21_CONFIG_CHECK_H_
|
||||
|
||||
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
|
||||
#error "Platform samr21 doesn't support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
|
||||
#endif
|
||||
|
||||
#endif /* OPENTHREAD_CORE_SAMR21_CONFIG_CHECK_H_ */
|
||||
@@ -1,85 +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 samr21 compile-time configuration constants
|
||||
* for OpenThread.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CORE_SAMR21_CONFIG_H_
|
||||
#define OPENTHREAD_CORE_SAMR21_CONFIG_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint32_t __d_nv_mem_start;
|
||||
extern uint32_t __d_nv_mem_end;
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_INFO
|
||||
*
|
||||
* The platform-specific string to insert into the OpenThread version string.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_INFO "SAMR21"
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def RADIO_CONFIG_SRC_MATCH_ENTRY_NUM
|
||||
*
|
||||
* The number of source address table entries.
|
||||
*
|
||||
*/
|
||||
#define RADIO_CONFIG_SRC_MATCH_ENTRY_NUM 128
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER
|
||||
*
|
||||
* The default IEEE 802.15.4 transmit power (dBm)
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER 5
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_NCP_HDLC_ENABLE
|
||||
*
|
||||
* Define to 1 to enable NCP HDLC support.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_NCP_HDLC_ENABLE 1
|
||||
|
||||
#endif // OPENTHREAD_CORE_SAMR21_CONFIG_H_
|
||||
@@ -1,109 +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 platform-specific initializers.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PLATFORM_SAMR21_H_
|
||||
#define PLATFORM_SAMR21_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
// Global OpenThread instance structure
|
||||
extern otInstance *sInstance;
|
||||
|
||||
/**
|
||||
* This function initializes the alarm service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void samr21AlarmInit(void);
|
||||
|
||||
/**
|
||||
* This function performs alarm driver processing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void samr21AlarmProcess(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function initializes the radio service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void samr21RadioInit(void);
|
||||
|
||||
/**
|
||||
* This function performs radio driver processing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void samr21RadioProcess(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function returns 32-bits random value.
|
||||
*
|
||||
*/
|
||||
uint32_t samr21RadioRandomGet(void);
|
||||
|
||||
/**
|
||||
* This function returns random value sequence.
|
||||
*
|
||||
*/
|
||||
void samr21RadioRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength);
|
||||
|
||||
/**
|
||||
* This function initializes the random number service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void samr21RandomInit(void);
|
||||
|
||||
/**
|
||||
* This function performs UART driver processing.
|
||||
*
|
||||
*/
|
||||
void samr21UartProcess(void);
|
||||
|
||||
/**
|
||||
* This function returns platform IEEE EUI-64.
|
||||
*
|
||||
*/
|
||||
void samr21GetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64);
|
||||
|
||||
/**
|
||||
* Initialization of Logger driver.
|
||||
*
|
||||
*/
|
||||
void samr21LogInit(void);
|
||||
|
||||
#endif // PLATFORM_SAMR21_H_
|
||||
@@ -1,676 +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 radio communication.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "asf.h"
|
||||
#include "phy.h"
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "platform-samr21.h"
|
||||
|
||||
#include "common/logging.hpp"
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
enum
|
||||
{
|
||||
IEEE802154_FRAME_TYPE_ACK = 0x2,
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
IEEE802154_FCS_SIZE = 2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SAMR21_RECEIVE_SENSITIVITY = -99 // dBm
|
||||
};
|
||||
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE + 1];
|
||||
|
||||
static otRadioFrame sReceiveFrame;
|
||||
|
||||
static bool sSleep = false;
|
||||
static bool sRxEnable = false;
|
||||
static bool sTxDone = false;
|
||||
static bool sRxDone = false;
|
||||
static uint8_t sTxStatus = PHY_STATUS_SUCCESS;
|
||||
static int8_t sPower = OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static bool sPromiscuous = false;
|
||||
static uint8_t sChannel = 0xFF;
|
||||
|
||||
static int8_t sMaxRssi;
|
||||
static uint32_t sScanStartTime;
|
||||
static uint16_t sScanDuration;
|
||||
static bool sStartScan = false;
|
||||
|
||||
static int8_t sTxPowerTable[] = {4, 4, 3, 3, 3, 2, 1, 0, -1, -2, -3, -4, -6, -8, -12, -17};
|
||||
|
||||
/*******************************************************************************
|
||||
* Static
|
||||
******************************************************************************/
|
||||
|
||||
static void radioSleep()
|
||||
{
|
||||
if (!sSleep)
|
||||
{
|
||||
PHY_SetRxState(false);
|
||||
PHY_Sleep();
|
||||
|
||||
sSleep = true;
|
||||
sRxEnable = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void radioWakeup()
|
||||
{
|
||||
if (sSleep)
|
||||
{
|
||||
PHY_Wakeup();
|
||||
}
|
||||
}
|
||||
|
||||
static void radioRxEnable()
|
||||
{
|
||||
if (sSleep)
|
||||
{
|
||||
PHY_Wakeup();
|
||||
|
||||
sSleep = false;
|
||||
}
|
||||
|
||||
if (!sRxEnable)
|
||||
{
|
||||
PHY_SetRxState(true);
|
||||
|
||||
sRxEnable = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void radioTrxOff()
|
||||
{
|
||||
if (sSleep)
|
||||
{
|
||||
PHY_Wakeup();
|
||||
}
|
||||
else if (sRxEnable)
|
||||
{
|
||||
PHY_SetRxState(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void radioRestore()
|
||||
{
|
||||
if (sSleep)
|
||||
{
|
||||
PHY_Sleep();
|
||||
}
|
||||
else if (sRxEnable)
|
||||
{
|
||||
PHY_SetRxState(true);
|
||||
}
|
||||
}
|
||||
|
||||
static void setTxPower(uint8_t aPower)
|
||||
{
|
||||
if (aPower != sPower)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < (sizeof(sTxPowerTable) / sizeof(*sTxPowerTable) - 1); i++)
|
||||
{
|
||||
if (aPower >= sTxPowerTable[i])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
otLogDebgPlat("Radio set tx power: %d, %d", aPower, i);
|
||||
|
||||
radioTrxOff();
|
||||
|
||||
PHY_SetTxPower(i);
|
||||
|
||||
radioRestore();
|
||||
|
||||
sPower = aPower;
|
||||
}
|
||||
}
|
||||
|
||||
static void setChannel(uint8_t aChannel)
|
||||
{
|
||||
if (aChannel != sChannel)
|
||||
{
|
||||
otLogDebgPlat("Radio set channel: %d", aChannel);
|
||||
|
||||
radioTrxOff();
|
||||
|
||||
PHY_SetChannel(aChannel);
|
||||
|
||||
radioRestore();
|
||||
|
||||
sChannel = aChannel;
|
||||
}
|
||||
}
|
||||
|
||||
static void handleEnergyScan()
|
||||
{
|
||||
if (sStartScan)
|
||||
{
|
||||
if ((otPlatAlarmMilliGetNow() - sScanStartTime) < sScanDuration)
|
||||
{
|
||||
int8_t curRssi = PHY_EdReq();
|
||||
|
||||
if (curRssi > sMaxRssi)
|
||||
{
|
||||
sMaxRssi = curRssi;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sStartScan = false;
|
||||
|
||||
otPlatRadioEnergyScanDone(sInstance, sMaxRssi);
|
||||
|
||||
radioRestore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void handleRx(void)
|
||||
{
|
||||
if (sRxDone)
|
||||
{
|
||||
sRxDone = false;
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
#error Time sync requires the timestamp of SFD rather than that of rx done!
|
||||
#else
|
||||
if (otPlatRadioGetPromiscuous(sInstance))
|
||||
#endif
|
||||
{
|
||||
// The current driver only supports milliseconds resolution.
|
||||
sReceiveFrame.mInfo.mRxInfo.mTimestamp = otPlatAlarmMilliGetNow() * 1000;
|
||||
}
|
||||
|
||||
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
|
||||
// See https://github.com/openthread/openthread/pull/3785
|
||||
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
|
||||
if (otPlatDiagModeGet())
|
||||
{
|
||||
otPlatDiagRadioReceiveDone(sInstance, &sReceiveFrame, OT_ERROR_NONE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// signal MAC layer for each received frame if promiscous is enabled
|
||||
// otherwise only signal MAC layer for non-ACK frame
|
||||
if (sPromiscuous || sReceiveFrame.mLength > IEEE802154_ACK_LENGTH)
|
||||
{
|
||||
otLogDebgPlat("Radio receive done, rssi: %d", sReceiveFrame.mInfo.mRxInfo.mRssi);
|
||||
|
||||
otPlatRadioReceiveDone(sInstance, &sReceiveFrame, OT_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void handleTx(void)
|
||||
{
|
||||
otError otStatus;
|
||||
otRadioFrame ackFrame;
|
||||
uint8_t psdu[IEEE802154_ACK_LENGTH];
|
||||
|
||||
if (sTxDone)
|
||||
{
|
||||
sTxDone = false;
|
||||
|
||||
// SAMR21 RF doesn't provide ACK frame, generate it manually
|
||||
ackFrame.mPsdu = psdu;
|
||||
ackFrame.mLength = IEEE802154_ACK_LENGTH;
|
||||
ackFrame.mPsdu[0] = IEEE802154_FRAME_TYPE_ACK;
|
||||
ackFrame.mPsdu[1] = 0;
|
||||
ackFrame.mPsdu[2] = sTransmitFrame.mPsdu[IEEE802154_DSN_OFFSET];
|
||||
|
||||
switch (sTxStatus)
|
||||
{
|
||||
// This is WA to handle pending bit in ACK.
|
||||
// SAMR21 phy driver doesn't provide pending status and returns
|
||||
// PHY_STATUS_ERROR. This status is returned also RF transaction not yet
|
||||
// finished. This situation should not happens. Currently PHY_STATUS_ERROR
|
||||
// is only way to detect pending bit.
|
||||
case PHY_STATUS_ERROR:
|
||||
ackFrame.mPsdu[0] |= IEEE802154_FRAME_PENDING;
|
||||
// fall through
|
||||
|
||||
case PHY_STATUS_SUCCESS:
|
||||
otStatus = OT_ERROR_NONE;
|
||||
break;
|
||||
|
||||
case PHY_STATUS_CHANNEL_ACCESS_FAILURE:
|
||||
otStatus = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||
break;
|
||||
|
||||
case PHY_STATUS_NO_ACK:
|
||||
otStatus = OT_ERROR_NO_ACK;
|
||||
break;
|
||||
|
||||
default:
|
||||
otStatus = OT_ERROR_ABORT;
|
||||
break;
|
||||
}
|
||||
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
if (otPlatDiagModeGet())
|
||||
{
|
||||
otPlatDiagRadioTransmitDone(sInstance, &sTransmitFrame, otStatus);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otLogDebgPlat("Radio transmit done, status: %d", otStatus);
|
||||
|
||||
otRadioFrame *ackFramePtr = &ackFrame;
|
||||
|
||||
if (((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) || (otStatus != OT_ERROR_NONE))
|
||||
{
|
||||
ackFramePtr = NULL;
|
||||
}
|
||||
|
||||
otPlatRadioTxDone(sInstance, &sTransmitFrame, ackFramePtr, otStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* PHY
|
||||
******************************************************************************/
|
||||
|
||||
void PHY_DataInd(PHY_DataInd_t *ind)
|
||||
{
|
||||
sReceiveFrame.mPsdu = ind->data;
|
||||
sReceiveFrame.mLength = ind->size + IEEE802154_FCS_SIZE;
|
||||
sReceiveFrame.mInfo.mRxInfo.mRssi = ind->rssi;
|
||||
|
||||
sRxDone = true;
|
||||
}
|
||||
|
||||
void PHY_DataConf(uint8_t status)
|
||||
{
|
||||
sTxStatus = status;
|
||||
sTxDone = true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Platform
|
||||
******************************************************************************/
|
||||
void samr21RadioInit(void)
|
||||
{
|
||||
sTransmitFrame.mLength = 0;
|
||||
sTransmitFrame.mPsdu = sTransmitPsdu + 1;
|
||||
|
||||
sReceiveFrame.mLength = 0;
|
||||
sReceiveFrame.mPsdu = NULL;
|
||||
|
||||
PHY_Init();
|
||||
|
||||
sal_init();
|
||||
}
|
||||
|
||||
void samr21RadioProcess(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
PHY_TaskHandler();
|
||||
|
||||
handleEnergyScan();
|
||||
handleRx();
|
||||
handleTx();
|
||||
}
|
||||
|
||||
uint32_t samr21RadioRandomGet(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
radioWakeup();
|
||||
|
||||
result = PHY_RandomReq() << 16 | PHY_RandomReq();
|
||||
|
||||
radioRestore();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void samr21RadioRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
radioWakeup();
|
||||
|
||||
for (uint16_t i = 0; i < aOutputLength / sizeof(uint16_t); i++)
|
||||
{
|
||||
*((uint16_t *)aOutput) = PHY_RandomReq();
|
||||
aOutput += sizeof(uint16_t);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < aOutputLength % sizeof(uint16_t); i++)
|
||||
{
|
||||
aOutput[i] = PHY_RandomReq();
|
||||
}
|
||||
|
||||
radioRestore();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Radio
|
||||
******************************************************************************/
|
||||
otRadioState otPlatRadioGetState(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return sState;
|
||||
}
|
||||
|
||||
void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
{
|
||||
samr21GetIeeeEui64(aInstance, aIeeeEui64);
|
||||
}
|
||||
|
||||
void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Set Pan ID: 0x%04X", aPanId);
|
||||
|
||||
radioTrxOff();
|
||||
|
||||
PHY_SetPanId(aPanId);
|
||||
|
||||
radioRestore();
|
||||
}
|
||||
|
||||
void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
radioTrxOff();
|
||||
|
||||
PHY_SetIEEEAddr((uint8_t *)aAddress);
|
||||
|
||||
radioRestore();
|
||||
}
|
||||
|
||||
void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
radioTrxOff();
|
||||
|
||||
PHY_SetShortAddr(aAddress);
|
||||
|
||||
radioRestore();
|
||||
}
|
||||
|
||||
bool otPlatRadioIsEnabled(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return (sState != OT_RADIO_STATE_DISABLED);
|
||||
}
|
||||
|
||||
otError otPlatRadioEnable(otInstance *aInstance)
|
||||
{
|
||||
otLogDebgPlat("Radio enable");
|
||||
|
||||
if (!otPlatRadioIsEnabled(aInstance))
|
||||
{
|
||||
radioSleep();
|
||||
|
||||
sState = OT_RADIO_STATE_SLEEP;
|
||||
}
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatRadioDisable(otInstance *aInstance)
|
||||
{
|
||||
otLogDebgPlat("Radio disable");
|
||||
|
||||
if (otPlatRadioIsEnabled(aInstance))
|
||||
{
|
||||
radioSleep();
|
||||
|
||||
sState = OT_RADIO_STATE_DISABLED;
|
||||
}
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatRadioSleep(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Radio sleep");
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
radioSleep();
|
||||
|
||||
sState = OT_RADIO_STATE_SLEEP;
|
||||
|
||||
exit:
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Radio receive, channel: %d", aChannel);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(sState != OT_RADIO_STATE_DISABLED, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
setChannel(aChannel);
|
||||
|
||||
radioRxEnable();
|
||||
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
|
||||
exit:
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Radio transmit");
|
||||
|
||||
otEXPECT_ACTION(sState == OT_RADIO_STATE_RECEIVE, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
setChannel(aFrame->mChannel);
|
||||
|
||||
aFrame->mPsdu[-1] = aFrame->mLength - IEEE802154_FCS_SIZE;
|
||||
|
||||
PHY_DataReq(&aFrame->mPsdu[-1]);
|
||||
|
||||
otPlatRadioTxStarted(aInstance, aFrame);
|
||||
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
|
||||
exit:
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return &sTransmitFrame;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetRssi(otInstance *aInstance)
|
||||
{
|
||||
return sMaxRssi;
|
||||
}
|
||||
|
||||
otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
|
||||
{
|
||||
return OT_RADIO_CAPS_ENERGY_SCAN | OT_RADIO_CAPS_TRANSMIT_RETRIES | OT_RADIO_CAPS_ACK_TIMEOUT;
|
||||
}
|
||||
|
||||
bool otPlatRadioGetPromiscuous(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return sPromiscuous;
|
||||
}
|
||||
|
||||
void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
sPromiscuous = aEnable;
|
||||
}
|
||||
|
||||
void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aEnable);
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
|
||||
{
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
|
||||
{
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
}
|
||||
|
||||
otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
sScanStartTime = otPlatAlarmMilliGetNow();
|
||||
sScanDuration = aScanDuration;
|
||||
|
||||
sMaxRssi = PHY_EdReq();
|
||||
|
||||
sStartScan = true;
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = sPower;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Radio set default TX power: %d", aPower);
|
||||
|
||||
setTxPower(aPower);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aThreshold);
|
||||
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aThreshold);
|
||||
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return SAMR21_RECEIVE_SENSITIVITY;
|
||||
}
|
||||
@@ -1,200 +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
|
||||
* @brief
|
||||
* This file includes the platform-specific initializers.
|
||||
*/
|
||||
|
||||
#include "asf.h"
|
||||
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "openthread-system.h"
|
||||
|
||||
#include "platform-samr21.h"
|
||||
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
#ifdef CONF_USER_ROW_EXIST
|
||||
|
||||
#include "user_row.h"
|
||||
|
||||
samr21UserRow *sUserRow = (samr21UserRow *)SAMR21_USER_ROW;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONF_KIT_DATA_EXIST
|
||||
|
||||
#define EDBG_ADDRESS 0x28
|
||||
|
||||
#define EDBG_KIT_DATA_TOKEN 0xD2;
|
||||
|
||||
#define KIT_DATA_MAX_RETRY 1000
|
||||
|
||||
static uint8_t sIeeeEui64[OT_EXT_ADDRESS_SIZE];
|
||||
|
||||
struct i2c_master_module sI2cMasterInstance;
|
||||
|
||||
static void configureI2cMaster()
|
||||
{
|
||||
/* Create and initialize config structure */
|
||||
struct i2c_master_config configI2c;
|
||||
i2c_master_get_config_defaults(&configI2c);
|
||||
|
||||
/* Change pins */
|
||||
configI2c.pinmux_pad0 = EDBG_I2C_SERCOM_PINMUX_PAD0;
|
||||
configI2c.pinmux_pad1 = EDBG_I2C_SERCOM_PINMUX_PAD1;
|
||||
|
||||
/* Initialize and enable device with config */
|
||||
i2c_master_init(&sI2cMasterInstance, EDBG_I2C_MODULE, &configI2c);
|
||||
|
||||
i2c_master_enable(&sI2cMasterInstance);
|
||||
}
|
||||
|
||||
static void getKitData()
|
||||
{
|
||||
uint8_t requestToken = EDBG_KIT_DATA_TOKEN;
|
||||
uint32_t timeout;
|
||||
struct i2c_master_packet masterPacket;
|
||||
|
||||
/** Send the request token */
|
||||
masterPacket.address = EDBG_ADDRESS;
|
||||
masterPacket.data_length = 1;
|
||||
masterPacket.data = &requestToken;
|
||||
masterPacket.ten_bit_address = false;
|
||||
masterPacket.high_speed = false;
|
||||
masterPacket.hs_master_code = 0x0;
|
||||
|
||||
timeout = 0;
|
||||
|
||||
while (i2c_master_write_packet_wait_no_stop(&sI2cMasterInstance, &masterPacket) != STATUS_OK)
|
||||
{
|
||||
/* Increment timeout counter and check if timed out. */
|
||||
otEXPECT(timeout++ < KIT_DATA_MAX_RETRY);
|
||||
}
|
||||
|
||||
/** Get the extension boards info */
|
||||
masterPacket.data_length = OT_EXT_ADDRESS_SIZE;
|
||||
masterPacket.data = sIeeeEui64;
|
||||
|
||||
timeout = 0;
|
||||
|
||||
while (i2c_master_read_packet_wait(&sI2cMasterInstance, &masterPacket) != STATUS_OK)
|
||||
{
|
||||
/* Increment timeout counter and check if timed out. */
|
||||
otEXPECT(timeout++ < KIT_DATA_MAX_RETRY);
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
otInstance *sInstance;
|
||||
|
||||
void boardInit(void)
|
||||
{
|
||||
struct port_config pin_conf;
|
||||
|
||||
port_get_config_defaults(&pin_conf);
|
||||
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
|
||||
port_pin_set_config(AT86RFX_SPI_SCK, &pin_conf);
|
||||
port_pin_set_config(AT86RFX_SPI_MOSI, &pin_conf);
|
||||
port_pin_set_config(AT86RFX_SPI_CS, &pin_conf);
|
||||
port_pin_set_config(AT86RFX_RST_PIN, &pin_conf);
|
||||
port_pin_set_config(AT86RFX_SLP_PIN, &pin_conf);
|
||||
port_pin_set_output_level(AT86RFX_SPI_SCK, true);
|
||||
port_pin_set_output_level(AT86RFX_SPI_MOSI, true);
|
||||
port_pin_set_output_level(AT86RFX_SPI_CS, true);
|
||||
port_pin_set_output_level(AT86RFX_RST_PIN, true);
|
||||
port_pin_set_output_level(AT86RFX_SLP_PIN, true);
|
||||
|
||||
pin_conf.direction = PORT_PIN_DIR_INPUT;
|
||||
port_pin_set_config(AT86RFX_SPI_MISO, &pin_conf);
|
||||
}
|
||||
|
||||
void samr21GetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
{
|
||||
#if defined(CONF_KIT_DATA_EXIST)
|
||||
|
||||
memcpy(aIeeeEui64, sIeeeEui64, OT_EXT_ADDRESS_SIZE);
|
||||
|
||||
#elif defined(CONF_USER_ROW_EXIST)
|
||||
|
||||
for (uint8_t i = 0; i < OT_EXT_ADDRESS_SIZE; i++)
|
||||
{
|
||||
aIeeeEui64[i] = sUserRow->mMacAddress[OT_EXT_ADDRESS_SIZE - i - 1];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error Platform IEEE EUI-64 shall be provided
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void otSysInit(int argc, char *argv[])
|
||||
{
|
||||
system_clock_init();
|
||||
|
||||
boardInit();
|
||||
|
||||
#ifdef CONF_KIT_DATA_EXIST
|
||||
configureI2cMaster();
|
||||
getKitData();
|
||||
#endif
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
samr21LogInit();
|
||||
#endif
|
||||
samr21AlarmInit();
|
||||
samr21RadioInit();
|
||||
}
|
||||
|
||||
bool otSysPseudoResetWasRequested(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void otSysDeinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void otSysProcessDrivers(otInstance *aInstance)
|
||||
{
|
||||
sInstance = aInstance;
|
||||
|
||||
samr21UartProcess();
|
||||
samr21AlarmProcess(aInstance);
|
||||
samr21RadioProcess(aInstance);
|
||||
}
|
||||
@@ -1,169 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "asf.h"
|
||||
|
||||
#include "utils/uart.h"
|
||||
|
||||
enum
|
||||
{
|
||||
kBaudRate = 115200,
|
||||
kReceiveBufferSize = 128,
|
||||
};
|
||||
|
||||
typedef struct RecvBuffer
|
||||
{
|
||||
// The data buffer
|
||||
uint8_t mBuffer[kReceiveBufferSize];
|
||||
// The offset of the first item written to the list.
|
||||
uint16_t mHead;
|
||||
// The offset of the next item to be written to the list.
|
||||
uint16_t mTail;
|
||||
} RecvBuffer;
|
||||
|
||||
static struct usart_module sUsartInstance;
|
||||
|
||||
static RecvBuffer sReceive;
|
||||
|
||||
static bool sTransmitDone = false;
|
||||
|
||||
static void usartReadCallback(struct usart_module *const usartModule)
|
||||
{
|
||||
if (sReceive.mHead != (sReceive.mTail + 1) % kReceiveBufferSize)
|
||||
{
|
||||
sReceive.mTail = (sReceive.mTail + 1) % kReceiveBufferSize;
|
||||
}
|
||||
|
||||
usart_read_job(&sUsartInstance, (uint16_t *)&sReceive.mBuffer[sReceive.mTail]);
|
||||
}
|
||||
|
||||
static void usartWriteCallback(struct usart_module *const usartModule)
|
||||
{
|
||||
sTransmitDone = true;
|
||||
}
|
||||
|
||||
static void processReceive(void)
|
||||
{
|
||||
// Copy tail to prevent multiple reads
|
||||
uint16_t tail = sReceive.mTail;
|
||||
|
||||
// If the data wraps around, process the first part
|
||||
if (sReceive.mHead > tail)
|
||||
{
|
||||
otPlatUartReceived(sReceive.mBuffer + sReceive.mHead, kReceiveBufferSize - sReceive.mHead);
|
||||
|
||||
// Reset the buffer mHead back to zero.
|
||||
sReceive.mHead = 0;
|
||||
}
|
||||
|
||||
// For any data remaining, process it
|
||||
if (sReceive.mHead != tail)
|
||||
{
|
||||
otPlatUartReceived(sReceive.mBuffer + sReceive.mHead, tail - sReceive.mHead);
|
||||
|
||||
// Set mHead to the local tail we have cached
|
||||
sReceive.mHead = tail;
|
||||
}
|
||||
}
|
||||
|
||||
otError otPlatUartFlush(void)
|
||||
{
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static void processTransmit(void)
|
||||
{
|
||||
if (sTransmitDone)
|
||||
{
|
||||
sTransmitDone = false;
|
||||
otPlatUartSendDone();
|
||||
}
|
||||
}
|
||||
|
||||
void samr21UartProcess(void)
|
||||
{
|
||||
processReceive();
|
||||
processTransmit();
|
||||
}
|
||||
|
||||
otError otPlatUartEnable(void)
|
||||
{
|
||||
struct usart_config configUsart;
|
||||
|
||||
usart_get_config_defaults(&configUsart);
|
||||
|
||||
configUsart.baudrate = 115200;
|
||||
configUsart.mux_setting = UART_SERCOM_MUX_SETTING;
|
||||
configUsart.pinmux_pad0 = UART_SERCOM_PINMUX_PAD0;
|
||||
configUsart.pinmux_pad1 = UART_SERCOM_PINMUX_PAD1;
|
||||
configUsart.pinmux_pad2 = UART_SERCOM_PINMUX_PAD2;
|
||||
configUsart.pinmux_pad3 = UART_SERCOM_PINMUX_PAD3;
|
||||
|
||||
while (usart_init(&sUsartInstance, UART_SERCOM_MODULE, &configUsart) != STATUS_OK)
|
||||
;
|
||||
|
||||
usart_enable(&sUsartInstance);
|
||||
|
||||
sReceive.mHead = 0;
|
||||
sReceive.mTail = 0;
|
||||
|
||||
usart_register_callback(&sUsartInstance, usartWriteCallback, USART_CALLBACK_BUFFER_TRANSMITTED);
|
||||
usart_register_callback(&sUsartInstance, usartReadCallback, USART_CALLBACK_BUFFER_RECEIVED);
|
||||
|
||||
usart_enable_callback(&sUsartInstance, USART_CALLBACK_BUFFER_TRANSMITTED);
|
||||
usart_enable_callback(&sUsartInstance, USART_CALLBACK_BUFFER_RECEIVED);
|
||||
|
||||
usart_read_job(&sUsartInstance, (uint16_t *)&sReceive.mBuffer[sReceive.mTail]);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatUartDisable(void)
|
||||
{
|
||||
usart_disable(&sUsartInstance);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (usart_write_buffer_job(&sUsartInstance, (uint8_t *)aBuf, aBufLength) != STATUS_OK)
|
||||
{
|
||||
error = OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -1,58 +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 platform-specific initializers.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef USER_ROW_H_
|
||||
#define USER_ROW_H_
|
||||
|
||||
// The SAM R21 provides a user readable Non-Volatile Memory (NVM) space
|
||||
// referred to as the user row in the data sheet.
|
||||
// The base address for the application is 0x804008.
|
||||
#define SAMR21_USER_ROW 0x804008
|
||||
|
||||
// User row structure
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct samr21UserRow
|
||||
{
|
||||
uint16_t mRevision;
|
||||
uint8_t mMacAddress[8];
|
||||
uint8_t mBoardSerial[10];
|
||||
uint8_t mPartNumber[8];
|
||||
uint8_t mPcbRevision;
|
||||
uint8_t mCrystalCal;
|
||||
uint16_t mCrc16;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
typedef struct samr21UserRow samr21UserRow;
|
||||
|
||||
#endif /* USER_ROW_H_ */
|
||||
@@ -265,26 +265,6 @@ build_qpg6095()
|
||||
make -f examples/Makefile-qpg6095 "${options[@]}"
|
||||
}
|
||||
|
||||
build_samr21()
|
||||
{
|
||||
local options=(
|
||||
"COMMISSIONER=1"
|
||||
"DHCP6_CLIENT=1"
|
||||
"DHCP6_SERVER=1"
|
||||
"DNS_CLIENT=1"
|
||||
"JOINER=1"
|
||||
"SLAAC=1"
|
||||
)
|
||||
|
||||
reset_source
|
||||
|
||||
wget http://ww1.microchip.com/downloads/en/DeviceDoc/asf-standalone-archive-3.45.0.85.zip
|
||||
unzip -qq asf-standalone-archive-3.45.0.85.zip
|
||||
mv xdk-asf-3.45.0 third_party/microchip/asf
|
||||
|
||||
make -f examples/Makefile-samr21 "${options[@]}"
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
./bootstrap
|
||||
@@ -303,7 +283,6 @@ main()
|
||||
build_nrf52833
|
||||
build_nrf52840
|
||||
build_qpg6095
|
||||
build_samr21
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
@@ -125,18 +125,6 @@ build_qpg7015m()
|
||||
"$(dirname "$0")"/cmake-build qpg7015m "${OT_COMMON_OPTIONS[@]}" "${OT_BASIC_CHECK_OPTIONS[@]}"
|
||||
}
|
||||
|
||||
build_samr21()
|
||||
{
|
||||
reset_source
|
||||
|
||||
asfzip=asf-standalone-archive-3.45.0.85.zip
|
||||
wget http://ww1.microchip.com/downloads/en/DeviceDoc/${asfzip}
|
||||
unzip -qq ${asfzip}
|
||||
mv xdk-asf-3.45.0 third_party/microchip/asf
|
||||
|
||||
"$(dirname "$0")"/cmake-build samr21 "${OT_COMMON_OPTIONS[@]}" "${OT_BASIC_CHECK_OPTIONS[@]}"
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
export CPPFLAGS="${CPPFLAGS:-} -DNDEBUG"
|
||||
@@ -151,7 +139,6 @@ main()
|
||||
build_qpg6100
|
||||
build_gp712
|
||||
build_qpg7015m
|
||||
build_samr21
|
||||
# UART transport
|
||||
build_nrf52840 UART_trans
|
||||
# USB transport with bootloader e.g. to support PCA10059 dongle
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ set -euxo pipefail
|
||||
OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-}
|
||||
|
||||
readonly OT_SRCDIR="$(pwd)"
|
||||
readonly OT_PLATFORMS=(cc1352 cc2538 cc2650 cc2652 efr32mg1 efr32mg12 efr32mg13 efr32mg21 kw41z nrf52811 nrf52833 nrf52840 gp712 qpg7015m qpg6095 qpg6100 samr21 simulation posix)
|
||||
readonly OT_PLATFORMS=(cc1352 cc2538 cc2650 cc2652 efr32mg1 efr32mg12 efr32mg13 efr32mg21 kw41z nrf52811 nrf52833 nrf52840 gp712 qpg7015m qpg6095 qpg6100 simulation posix)
|
||||
readonly OT_NRF528XX_BUILD_TYPES=(UART_trans USB_trans_bl SPI_trans_NCP soft_crypto soft_crypto_threading)
|
||||
readonly OT_POSIX_SIM_COMMON_OPTIONS=(
|
||||
"-DOT_BORDER_AGENT=ON"
|
||||
@@ -232,7 +232,7 @@ main()
|
||||
OT_CMAKE_NINJA_TARGET=("ot-cli-mtd" "ot-ncp-mtd")
|
||||
options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel")
|
||||
;;
|
||||
cc1352 | cc2538 | cc2652 | kw41z | samr21)
|
||||
cc1352 | cc2538 | cc2652 | kw41z)
|
||||
options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel")
|
||||
;;
|
||||
qpg6095 | qpg6100)
|
||||
|
||||
Vendored
-2
@@ -38,8 +38,6 @@ elseif(OT_PLATFORM MATCHES "^qpg*")
|
||||
add_subdirectory(Qorvo)
|
||||
elseif(OT_PLATFORM STREQUAL "gp712")
|
||||
add_subdirectory(Qorvo)
|
||||
elseif(OT_PLATFORM STREQUAL "samr21")
|
||||
add_subdirectory(microchip)
|
||||
elseif(OT_PLATFORM MATCHES "^nrf*")
|
||||
add_subdirectory(jlink)
|
||||
add_subdirectory(NordicSemiconductor)
|
||||
|
||||
Vendored
-127
@@ -1,127 +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.
|
||||
#
|
||||
|
||||
add_library(samr21-driver
|
||||
asf/common/utils/interrupt/interrupt_sam_nvic.c
|
||||
asf/common2/services/delay/sam0/cycle_counter.c
|
||||
asf/sam0/drivers/extint/extint_callback.c
|
||||
asf/sam0/drivers/extint/extint_sam_d_r_h/extint.c
|
||||
asf/sam0/drivers/nvm/nvm.c
|
||||
asf/sam0/drivers/port/port.c
|
||||
asf/sam0/drivers/system/clock/clock_samd21_r21_da_ha1/clock.c
|
||||
asf/sam0/drivers/system/clock/clock_samd21_r21_da_ha1/gclk.c
|
||||
asf/sam0/drivers/system/interrupt/system_interrupt.c
|
||||
asf/sam0/drivers/system/pinmux/pinmux.c
|
||||
asf/sam0/drivers/sercom/sercom.c
|
||||
asf/sam0/drivers/sercom/sercom_interrupt.c
|
||||
asf/sam0/drivers/sercom/i2c/i2c_sam0/i2c_master.c
|
||||
asf/sam0/drivers/sercom/spi/spi.c
|
||||
asf/sam0/drivers/sercom/usart/usart.c
|
||||
asf/sam0/drivers/sercom/usart/usart_interrupt.c
|
||||
asf/sam0/utils/cmsis/samr21/source/gcc/startup_samr21.c
|
||||
asf/sam0/utils/cmsis/samr21/source/system_samr21.c
|
||||
asf/sam0/utils/syscalls/gcc/syscalls.c
|
||||
asf/thirdparty/wireless/avr2130_lwmesh/source/phy/at86rf233/src/phy.c
|
||||
asf/thirdparty/wireless/services/sal/at86rf2xx/src/sal.c
|
||||
asf/thirdparty/wireless/services/trx_access/trx_access.c
|
||||
)
|
||||
|
||||
if(OT_CFLAGS MATCHES "-pedantic-errors")
|
||||
string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(samr21-driver
|
||||
PUBLIC
|
||||
-T${PROJECT_SOURCE_DIR}/third_party/microchip/include/samr21x18a.ld
|
||||
PRIVATE
|
||||
ot-config
|
||||
)
|
||||
|
||||
target_compile_definitions(samr21-driver
|
||||
PUBLIC
|
||||
${OT_PLATFORM_DEFINES}
|
||||
-DBOARD=SAMR21_XPLAINED_PRO
|
||||
-D__SAMR21G18A__
|
||||
-DARM_MATH_CM0PLUS=true
|
||||
-DPHY_AT86RF233
|
||||
-DSAL_TYPE=AT86RF2xx
|
||||
-DUSART_CALLBACK_MODE=true
|
||||
-DEXTINT_CALLBACK_MODE=true
|
||||
-DSPI_CALLBACK_MODE=false
|
||||
-DCYCLE_MODE
|
||||
)
|
||||
|
||||
target_compile_options(samr21-driver
|
||||
PUBLIC
|
||||
-Werror
|
||||
-Wno-unused-parameter
|
||||
-fno-strict-aliasing
|
||||
PRIVATE
|
||||
-Wno-implicit-function-declaration
|
||||
-Wno-expansion-to-defined
|
||||
${OT_CFLAGS}
|
||||
)
|
||||
|
||||
target_include_directories(samr21-driver
|
||||
PUBLIC
|
||||
include
|
||||
asf/common/boards
|
||||
asf/common/utils
|
||||
asf/common2/services/delay
|
||||
asf/common2/services/delay/sam0
|
||||
asf/sam0/boards
|
||||
asf/sam0/boards/samr21_xplained_pro
|
||||
asf/sam0/drivers/extint
|
||||
asf/sam0/drivers/extint/extint_sam_d_r_h
|
||||
asf/sam0/drivers/nvm
|
||||
asf/sam0/drivers/port
|
||||
asf/sam0/drivers/system
|
||||
asf/sam0/drivers/system/clock
|
||||
asf/sam0/drivers/system/clock/clock_samd21_r21_da_ha1
|
||||
asf/sam0/drivers/system/interrupt
|
||||
asf/sam0/drivers/system/interrupt/system_interrupt_samr21
|
||||
asf/sam0/drivers/system/pinmux
|
||||
asf/sam0/drivers/system/power
|
||||
asf/sam0/drivers/system/power/power_sam_d_r_h
|
||||
asf/sam0/drivers/system/reset
|
||||
asf/sam0/drivers/system/reset/reset_sam_d_r_h
|
||||
asf/sam0/drivers/sercom
|
||||
asf/sam0/drivers/sercom/i2c
|
||||
asf/sam0/drivers/sercom/i2c/i2c_sam0
|
||||
asf/sam0/drivers/sercom/spi
|
||||
asf/sam0/drivers/sercom/usart
|
||||
asf/sam0/utils/cmsis/samr21/include
|
||||
asf/sam0/utils/cmsis/samr21/source
|
||||
asf/sam0/utils/header_files
|
||||
asf/sam0/utils/preprocessor
|
||||
asf/thirdparty/CMSIS/Include
|
||||
asf/thirdparty/wireless/avr2130_lwmesh/source/phy/at86rf233/inc
|
||||
asf/thirdparty/wireless/services/sal/inc
|
||||
asf/thirdparty/wireless/services/trx_access
|
||||
asf/thirdparty/wireless/services/trx_access/module_config
|
||||
)
|
||||
Vendored
-43
@@ -1,43 +0,0 @@
|
||||
# Microchip
|
||||
|
||||
URL: http://www.microchip.com/
|
||||
|
||||
ASF URL: http://www.microchip.com/avr-support/advanced-software-framework-(asf)
|
||||
|
||||
Version: 3.36.0
|
||||
|
||||
## License
|
||||
|
||||
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. The name of Atmel may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
4. This software may only be redistributed and used in connection with an
|
||||
Atmel microcontroller product.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
|
||||
## Description
|
||||
|
||||
This folder contains modified ASF include headers which configure SAMR21
|
||||
XPLAINED PRO board. In order to compile openthread for SAMR21 ASF shell
|
||||
be downloaded into asf folder.
|
||||
Vendored
-112
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Autogenerated API include file for the Atmel Software Framework (ASF)
|
||||
*
|
||||
* Copyright (c) 2012 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* 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. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel microcontroller product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ASF_H
|
||||
#define ASF_H
|
||||
|
||||
/*
|
||||
* This file includes all API header files for the selected drivers from ASF.
|
||||
* Note: There might be duplicate includes required by more than one driver.
|
||||
*
|
||||
* The file is automatically generated and will be re-written when
|
||||
* running the ASF driver selector tool. Any changes will be discarded.
|
||||
*/
|
||||
|
||||
// From module: Common SAM0 compiler driver
|
||||
#include <compiler.h>
|
||||
#include <status_codes.h>
|
||||
|
||||
// From module: Generic board support
|
||||
#include <board.h>
|
||||
|
||||
// From module: EXTINT - External Interrupt (Callback APIs)
|
||||
#include <extint.h>
|
||||
#include <extint_callback.h>
|
||||
|
||||
// From module: Interrupt management - SAM implementation
|
||||
#include <interrupt.h>
|
||||
|
||||
// From module: NVM - Non-Volatile Memory
|
||||
#include <nvm.h>
|
||||
|
||||
// From module: PORT - GPIO Pin Control
|
||||
#include <port.h>
|
||||
|
||||
// From module: Part identification macros
|
||||
#include <parts.h>
|
||||
|
||||
// From module: SYSTEM - Clock Management for SAMD21/R21/DA/HA
|
||||
#include <clock.h>
|
||||
#include <gclk.h>
|
||||
|
||||
// From module: SERCOM Callback API
|
||||
#include <sercom.h>
|
||||
#include <sercom_interrupt.h>
|
||||
|
||||
// From module: SERCOM I2C - Master Mode I2C (Polled APIs)
|
||||
#include <i2c_common.h>
|
||||
#include <i2c_master.h>
|
||||
|
||||
// From module: SERCOM SPI - Serial Peripheral Interface (Polled APIs)
|
||||
#include <spi.h>
|
||||
|
||||
// From module: SERCOM USART - Serial Communications (Callback APIs)
|
||||
#include <usart.h>
|
||||
#include <usart_interrupt.h>
|
||||
|
||||
// From module: SYSTEM - Core System Driver
|
||||
#include <system.h>
|
||||
|
||||
// From module: SYSTEM - I/O Pin Multiplexer
|
||||
#include <pinmux.h>
|
||||
|
||||
// From module: SYSTEM - Interrupt Driver
|
||||
#include <system_interrupt.h>
|
||||
|
||||
// From module: SYSTEM - Power Management for SAM D20/D21/R21/D09/D10/D11/DA/HA
|
||||
#include <power.h>
|
||||
|
||||
// From module: SYSTEM - Reset Management for SAM D20/D21/R21/D09/D10/D11/DA/HA
|
||||
#include <reset.h>
|
||||
|
||||
#endif // ASF_H
|
||||
-1168
File diff suppressed because it is too large
Load Diff
-84
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief SAM R21 Xplained Pro board configuration.
|
||||
*
|
||||
* Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* 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. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel microcontroller product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#ifndef CONF_BOARD_H_INCLUDED
|
||||
#define CONF_BOARD_H_INCLUDED
|
||||
|
||||
#define CONF_BOARD_AT86RFX
|
||||
|
||||
#define AT86RFX_SPI_BAUDRATE 5000000UL
|
||||
|
||||
#if (BOARD==SAMR21G18_MODULE) || (BOARD==SAMR21B18_MODULE)
|
||||
|
||||
#define CONF_USER_ROW_EXIST
|
||||
|
||||
#define UART_SERCOM_MODULE SERCOM2
|
||||
#define UART_SERCOM_MUX_SETTING USART_RX_3_TX_2_XCK_3
|
||||
#define UART_SERCOM_PINMUX_PAD0 PINMUX_UNUSED
|
||||
#define UART_SERCOM_PINMUX_PAD1 PINMUX_UNUSED
|
||||
#define UART_SERCOM_PINMUX_PAD2 PINMUX_PA14C_SERCOM2_PAD2
|
||||
#define UART_SERCOM_PINMUX_PAD3 PINMUX_PA15C_SERCOM2_PAD3
|
||||
#define UART_SERCOM_DMAC_ID_TX SERCOM2_DMAC_ID_TX
|
||||
#define UART_SERCOM_DMAC_ID_RX SERCOM2_DMAC_ID_RX
|
||||
|
||||
#endif
|
||||
|
||||
#if BOARD==SAMR21_XPLAINED_PRO
|
||||
|
||||
#define CONF_KIT_DATA_EXIST
|
||||
|
||||
#define UART_SERCOM_MODULE EDBG_CDC_MODULE
|
||||
#define UART_SERCOM_MUX_SETTING EDBG_CDC_SERCOM_MUX_SETTING
|
||||
#define UART_SERCOM_PINMUX_PAD0 EDBG_CDC_SERCOM_PINMUX_PAD0
|
||||
#define UART_SERCOM_PINMUX_PAD1 EDBG_CDC_SERCOM_PINMUX_PAD1
|
||||
#define UART_SERCOM_PINMUX_PAD2 EDBG_CDC_SERCOM_PINMUX_PAD2
|
||||
#define UART_SERCOM_PINMUX_PAD3 EDBG_CDC_SERCOM_PINMUX_PAD3
|
||||
#define UART_SERCOM_DMAC_ID_TX EDBG_CDC_SERCOM_DMAC_ID_TX
|
||||
#define UART_SERCOM_DMAC_ID_RX EDBG_CDC_SERCOM_DMAC_ID_RX
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* CONF_BOARD_H_INCLUDED */
|
||||
-200
@@ -1,200 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Chip-specific system clock manager configuration
|
||||
*
|
||||
* Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* 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. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel microcontroller product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include <clock.h>
|
||||
|
||||
#ifndef CONF_CLOCKS_H_INCLUDED
|
||||
#define CONF_CLOCKS_H_INCLUDED
|
||||
|
||||
/* System clock bus configuration */
|
||||
#define CONF_CLOCK_CPU_CLOCK_FAILURE_DETECT false
|
||||
#define CONF_CLOCK_FLASH_WAIT_STATES 2
|
||||
#define CONF_CLOCK_CPU_DIVIDER SYSTEM_MAIN_CLOCK_DIV_1
|
||||
#define CONF_CLOCK_APBA_DIVIDER SYSTEM_MAIN_CLOCK_DIV_1
|
||||
#define CONF_CLOCK_APBB_DIVIDER SYSTEM_MAIN_CLOCK_DIV_1
|
||||
#define CONF_CLOCK_APBC_DIVIDER SYSTEM_MAIN_CLOCK_DIV_1
|
||||
|
||||
/* SYSTEM_CLOCK_SOURCE_OSC8M configuration - Internal 8MHz oscillator */
|
||||
#define CONF_CLOCK_OSC8M_PRESCALER SYSTEM_OSC8M_DIV_1
|
||||
#define CONF_CLOCK_OSC8M_ON_DEMAND false
|
||||
#define CONF_CLOCK_OSC8M_RUN_IN_STANDBY false
|
||||
|
||||
/* SYSTEM_CLOCK_SOURCE_XOSC configuration - External clock/oscillator */
|
||||
#define CONF_CLOCK_XOSC_ENABLE false
|
||||
#define CONF_CLOCK_XOSC_EXTERNAL_CRYSTAL SYSTEM_CLOCK_EXTERNAL_CRYSTAL
|
||||
#define CONF_CLOCK_XOSC_EXTERNAL_FREQUENCY 12000000UL
|
||||
#define CONF_CLOCK_XOSC_STARTUP_TIME SYSTEM_XOSC_STARTUP_32768
|
||||
#define CONF_CLOCK_XOSC_AUTO_GAIN_CONTROL true
|
||||
#define CONF_CLOCK_XOSC_ON_DEMAND true
|
||||
#define CONF_CLOCK_XOSC_RUN_IN_STANDBY false
|
||||
|
||||
/* SYSTEM_CLOCK_SOURCE_XOSC32K configuration - External 32KHz crystal/clock
|
||||
* oscillator */
|
||||
#define CONF_CLOCK_XOSC32K_ENABLE false
|
||||
#define CONF_CLOCK_XOSC32K_EXTERNAL_CRYSTAL SYSTEM_CLOCK_EXTERNAL_CRYSTAL
|
||||
#define CONF_CLOCK_XOSC32K_STARTUP_TIME SYSTEM_XOSC32K_STARTUP_65536
|
||||
#define CONF_CLOCK_XOSC32K_AUTO_AMPLITUDE_CONTROL true
|
||||
#define CONF_CLOCK_XOSC32K_ENABLE_1KHZ_OUPUT false
|
||||
#define CONF_CLOCK_XOSC32K_ENABLE_32KHZ_OUTPUT true
|
||||
#define CONF_CLOCK_XOSC32K_ON_DEMAND true
|
||||
#define CONF_CLOCK_XOSC32K_RUN_IN_STANDBY false
|
||||
|
||||
/* SYSTEM_CLOCK_SOURCE_OSC32K configuration - Internal 32KHz oscillator */
|
||||
#define CONF_CLOCK_OSC32K_ENABLE true
|
||||
#define CONF_CLOCK_OSC32K_STARTUP_TIME SYSTEM_OSC32K_STARTUP_130
|
||||
#define CONF_CLOCK_OSC32K_ENABLE_1KHZ_OUTPUT true
|
||||
#define CONF_CLOCK_OSC32K_ENABLE_32KHZ_OUTPUT true
|
||||
#define CONF_CLOCK_OSC32K_ON_DEMAND true
|
||||
#define CONF_CLOCK_OSC32K_RUN_IN_STANDBY true
|
||||
|
||||
/* SYSTEM_CLOCK_SOURCE_DFLL configuration - Digital Frequency Locked Loop */
|
||||
#define CONF_CLOCK_DFLL_ENABLE true
|
||||
#define CONF_CLOCK_DFLL_LOOP_MODE SYSTEM_CLOCK_DFLL_LOOP_MODE_CLOSED
|
||||
#define CONF_CLOCK_DFLL_ON_DEMAND false
|
||||
#define CONF_CLOCK_DFLL_RUN_IN_STANDBY false
|
||||
|
||||
/* DFLL open loop mode configuration */
|
||||
# define CONF_CLOCK_DFLL_FINE_VALUE (512)
|
||||
|
||||
/* DFLL closed loop mode configuration */
|
||||
#define CONF_CLOCK_DFLL_SOURCE_GCLK_GENERATOR GCLK_GENERATOR_1
|
||||
#define CONF_CLOCK_DFLL_MULTIPLY_FACTOR (48000000 / 32768)
|
||||
#define CONF_CLOCK_DFLL_QUICK_LOCK true
|
||||
#define CONF_CLOCK_DFLL_TRACK_AFTER_FINE_LOCK true
|
||||
#define CONF_CLOCK_DFLL_KEEP_LOCK_ON_WAKEUP true
|
||||
#define CONF_CLOCK_DFLL_ENABLE_CHILL_CYCLE true
|
||||
#define CONF_CLOCK_DFLL_MAX_COARSE_STEP_SIZE (0x1f / 4)
|
||||
#define CONF_CLOCK_DFLL_MAX_FINE_STEP_SIZE (0xff / 4)
|
||||
|
||||
/* SYSTEM_CLOCK_SOURCE_DPLL configuration - Digital Phase-Locked Loop */
|
||||
#define CONF_CLOCK_DPLL_ENABLE false
|
||||
#define CONF_CLOCK_DPLL_ON_DEMAND true
|
||||
#define CONF_CLOCK_DPLL_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_DPLL_LOCK_BYPASS false
|
||||
#define CONF_CLOCK_DPLL_WAKE_UP_FAST false
|
||||
#define CONF_CLOCK_DPLL_LOW_POWER_ENABLE false
|
||||
|
||||
#define CONF_CLOCK_DPLL_LOCK_TIME SYSTEM_CLOCK_SOURCE_DPLL_LOCK_TIME_DEFAULT
|
||||
#define CONF_CLOCK_DPLL_REFERENCE_CLOCK SYSTEM_CLOCK_SOURCE_DPLL_REFERENCE_CLOCK_XOSC32K
|
||||
#define CONF_CLOCK_DPLL_FILTER SYSTEM_CLOCK_SOURCE_DPLL_FILTER_DEFAULT
|
||||
|
||||
#define CONF_CLOCK_DPLL_REFERENCE_FREQUENCY 32768
|
||||
#define CONF_CLOCK_DPLL_REFERENCE_DIVIDER 1
|
||||
#define CONF_CLOCK_DPLL_OUTPUT_FREQUENCY 48000000
|
||||
|
||||
/* DPLL GCLK reference configuration */
|
||||
#define CONF_CLOCK_DPLL_REFERENCE_GCLK_GENERATOR GCLK_GENERATOR_1
|
||||
/* DPLL GCLK lock timer configuration */
|
||||
#define CONF_CLOCK_DPLL_LOCK_GCLK_GENERATOR GCLK_GENERATOR_1
|
||||
|
||||
/* Set this to true to configure the GCLK when running clocks_init. If set to
|
||||
* false, none of the GCLK generators will be configured in clocks_init(). */
|
||||
#define CONF_CLOCK_CONFIGURE_GCLK true
|
||||
|
||||
/* Configure GCLK generator 0 (Main Clock) */
|
||||
#define CONF_CLOCK_GCLK_0_ENABLE true
|
||||
#define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_0_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_DFLL
|
||||
#define CONF_CLOCK_GCLK_0_PRESCALER 1
|
||||
#define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 1 */
|
||||
#define CONF_CLOCK_GCLK_1_ENABLE true
|
||||
#define CONF_CLOCK_GCLK_1_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_1_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_OSC32K
|
||||
#define CONF_CLOCK_GCLK_1_PRESCALER 1
|
||||
#define CONF_CLOCK_GCLK_1_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 2 (RTC) */
|
||||
#define CONF_CLOCK_GCLK_2_ENABLE true
|
||||
#define CONF_CLOCK_GCLK_2_RUN_IN_STANDBY true
|
||||
#define CONF_CLOCK_GCLK_2_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_OSC32K
|
||||
#define CONF_CLOCK_GCLK_2_PRESCALER 32
|
||||
#define CONF_CLOCK_GCLK_2_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 3 */
|
||||
#define CONF_CLOCK_GCLK_3_ENABLE false
|
||||
#define CONF_CLOCK_GCLK_3_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_3_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_OSC8M
|
||||
#define CONF_CLOCK_GCLK_3_PRESCALER 1
|
||||
#define CONF_CLOCK_GCLK_3_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 4 */
|
||||
#define CONF_CLOCK_GCLK_4_ENABLE true
|
||||
#define CONF_CLOCK_GCLK_4_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_4_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_ULP32K
|
||||
#define CONF_CLOCK_GCLK_4_PRESCALER 32
|
||||
#define CONF_CLOCK_GCLK_4_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 5 */
|
||||
#define CONF_CLOCK_GCLK_5_ENABLE false
|
||||
#define CONF_CLOCK_GCLK_5_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_5_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_OSC8M
|
||||
#define CONF_CLOCK_GCLK_5_PRESCALER 1
|
||||
#define CONF_CLOCK_GCLK_5_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 6 */
|
||||
#define CONF_CLOCK_GCLK_6_ENABLE false
|
||||
#define CONF_CLOCK_GCLK_6_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_6_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_OSC8M
|
||||
#define CONF_CLOCK_GCLK_6_PRESCALER 1
|
||||
#define CONF_CLOCK_GCLK_6_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 7 */
|
||||
#define CONF_CLOCK_GCLK_7_ENABLE false
|
||||
#define CONF_CLOCK_GCLK_7_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_7_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_OSC8M
|
||||
#define CONF_CLOCK_GCLK_7_PRESCALER 1
|
||||
#define CONF_CLOCK_GCLK_7_OUTPUT_ENABLE false
|
||||
|
||||
/* Configure GCLK generator 8 */
|
||||
#define CONF_CLOCK_GCLK_8_ENABLE false
|
||||
#define CONF_CLOCK_GCLK_8_RUN_IN_STANDBY false
|
||||
#define CONF_CLOCK_GCLK_8_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_OSC8M
|
||||
#define CONF_CLOCK_GCLK_8_PRESCALER 1
|
||||
#define CONF_CLOCK_GCLK_8_OUTPUT_ENABLE false
|
||||
|
||||
#endif /* CONF_CLOCKS_H_INCLUDED */
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief SAM R21 External Interrupt Driver Configuration Header
|
||||
*
|
||||
* Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* 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. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel microcontroller product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#ifndef CONF_EXTINT_H_INCLUDED
|
||||
#define CONF_EXTINT_H_INCLUDED
|
||||
|
||||
#define EXTINT_CLOCK_SOURCE GCLK_GENERATOR_0
|
||||
#define EXTINT_CALLBACKS_MAX 10
|
||||
|
||||
#endif
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief SAM R21 SPI configuration
|
||||
*
|
||||
* Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* 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. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel microcontroller product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#ifndef CONF_SPI_H_INCLUDED
|
||||
#define CONF_SPI_H_INCLUDED
|
||||
|
||||
#define CONF_SPI_MASTER_ENABLE true
|
||||
#define CONF_SPI_SLAVE_ENABLE false
|
||||
|
||||
#endif /* CONF_SPI_H_INCLUDED */
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* \file *********************************************************************
|
||||
*
|
||||
* \brief Common TRX Access Configuration
|
||||
*
|
||||
* Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* 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. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel microcontroller product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*/
|
||||
|
||||
#ifndef CONF_TRX_ACCESS_H_INCLUDED
|
||||
#define CONF_TRX_ACCESS_H_INCLUDED
|
||||
|
||||
#endif /* CONF_TRX_ACCESS_H_INCLUDED */
|
||||
-164
@@ -1,164 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Linker script for running in internal FLASH on the SAMR21x18A
|
||||
*
|
||||
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* 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. The name of Atmel may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 4. This software may only be redistributed and used in connection with an
|
||||
* Atmel microcontroller product.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
SEARCH_DIR(.)
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
|
||||
}
|
||||
|
||||
/* Section Definitions */
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sfixed = .;
|
||||
KEEP(*(.vectors .vectors.*))
|
||||
|
||||
FILL(0xFF)
|
||||
/* PDS NV memory section */
|
||||
. = ALIGN(0x100);
|
||||
PROVIDE(__d_nv_mem_start = .);
|
||||
. += ALIGN(0x1000); /* Size of D_Nv memory section is 0x1000 i.e., 4KB */
|
||||
PROVIDE(__d_nv_mem_end = .);
|
||||
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
*(.glue_7t) *(.glue_7)
|
||||
*(.rodata .rodata* .gnu.linkonce.r.*)
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
|
||||
/* Support C constructors, and C destructors in both user code
|
||||
and the C library. This also provides support for C++ code. */
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.init))
|
||||
. = ALIGN(4);
|
||||
__preinit_array_start = .;
|
||||
KEEP (*(.preinit_array))
|
||||
__preinit_array_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
__init_array_start = .;
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
__init_array_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*crtend.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
__fini_array_start = .;
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
__fini_array_end = .;
|
||||
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*crtend.o(.dtors))
|
||||
|
||||
. = ALIGN(4);
|
||||
_efixed = .; /* End of text section */
|
||||
} > rom
|
||||
|
||||
/* .ARM.exidx is sorted, so has to go in its own output section. */
|
||||
PROVIDE_HIDDEN (__exidx_start = .);
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > rom
|
||||
PROVIDE_HIDDEN (__exidx_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
|
||||
.relocate : AT (_etext)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_srelocate = .;
|
||||
*(.ramfunc .ramfunc.*);
|
||||
*(.data .data.*);
|
||||
. = ALIGN(4);
|
||||
_erelocate = .;
|
||||
} > ram
|
||||
|
||||
/* .bss section which is used for uninitialized data */
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sbss = . ;
|
||||
_szero = .;
|
||||
*(.bss .bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_ebss = . ;
|
||||
_ezero = .;
|
||||
} > ram
|
||||
|
||||
/* stack section */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
KEEP(*(.stack*))
|
||||
} > ram
|
||||
|
||||
_sstack = _ebss;
|
||||
_estack = ORIGIN(ram) + LENGTH(ram);
|
||||
|
||||
ASSERT(_sstack < _estack, "region RAM overflowed with stack")
|
||||
|
||||
. = ALIGN(4);
|
||||
_end = . ;
|
||||
end = _end;
|
||||
}
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Status code definitions.
|
||||
*
|
||||
* This file defines various status codes returned by functions,
|
||||
* indicating success or failure as well as what kind of failure.
|
||||
*
|
||||
* Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
|
||||
*
|
||||
* \asf_license_start
|
||||
*
|
||||
* \page License
|
||||
*
|
||||
* Subject to your compliance with these terms, you may use Microchip
|
||||
* software and any derivatives exclusively with Microchip products.
|
||||
* It is your responsibility to comply with third party license terms applicable
|
||||
* to your use of third party software (including open source software) that
|
||||
* may accompany Microchip software.
|
||||
*
|
||||
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
|
||||
* WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
|
||||
* INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
|
||||
* LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
|
||||
* LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
|
||||
* SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
|
||||
* ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
|
||||
* RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
|
||||
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
|
||||
*
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
|
||||
*/
|
||||
|
||||
#ifndef STATUS_CODES_H_INCLUDED
|
||||
#define STATUS_CODES_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* \defgroup group_sam0_utils_status_codes Status Codes
|
||||
*
|
||||
* \ingroup group_sam0_utils
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Mask to retrieve the error category of a status code. */
|
||||
#define STATUS_CATEGORY_MASK 0xF0
|
||||
|
||||
/** Mask to retrieve the error code within the category of a status code. */
|
||||
#define STATUS_ERROR_MASK 0x0F
|
||||
|
||||
/** Status code error categories. */
|
||||
enum status_categories {
|
||||
STATUS_CATEGORY_OK = 0x00,
|
||||
STATUS_CATEGORY_COMMON = 0x10,
|
||||
STATUS_CATEGORY_ANALOG = 0x30,
|
||||
STATUS_CATEGORY_COM = 0x40,
|
||||
STATUS_CATEGORY_IO = 0x50,
|
||||
};
|
||||
|
||||
/**
|
||||
* Status code that may be returned by shell commands and protocol
|
||||
* implementations.
|
||||
*
|
||||
* \note Any change to these status codes and the corresponding
|
||||
* message strings is strictly forbidden. New codes can be added,
|
||||
* however, but make sure that any message string tables are updated
|
||||
* at the same time.
|
||||
*/
|
||||
enum status_code {
|
||||
STATUS_OK = STATUS_CATEGORY_OK | 0x00,
|
||||
STATUS_VALID_DATA = STATUS_CATEGORY_OK | 0x01,
|
||||
STATUS_NO_CHANGE = STATUS_CATEGORY_OK | 0x02,
|
||||
STATUS_ABORTED = STATUS_CATEGORY_OK | 0x04,
|
||||
STATUS_BUSY = STATUS_CATEGORY_OK | 0x05,
|
||||
STATUS_SUSPEND = STATUS_CATEGORY_OK | 0x06,
|
||||
|
||||
STATUS_ERR_IO = STATUS_CATEGORY_COMMON | 0x00,
|
||||
STATUS_ERR_REQ_FLUSHED = STATUS_CATEGORY_COMMON | 0x01,
|
||||
STATUS_ERR_TIMEOUT = STATUS_CATEGORY_COMMON | 0x02,
|
||||
STATUS_ERR_BAD_DATA = STATUS_CATEGORY_COMMON | 0x03,
|
||||
STATUS_ERR_NOT_FOUND = STATUS_CATEGORY_COMMON | 0x04,
|
||||
STATUS_ERR_UNSUPPORTED_DEV = STATUS_CATEGORY_COMMON | 0x05,
|
||||
STATUS_ERR_NO_MEMORY = STATUS_CATEGORY_COMMON | 0x06,
|
||||
STATUS_ERR_INVALID_ARG = STATUS_CATEGORY_COMMON | 0x07,
|
||||
STATUS_ERR_BAD_ADDRESS = STATUS_CATEGORY_COMMON | 0x08,
|
||||
STATUS_ERR_BAD_FORMAT = STATUS_CATEGORY_COMMON | 0x0A,
|
||||
STATUS_ERR_BAD_FRQ = STATUS_CATEGORY_COMMON | 0x0B,
|
||||
STATUS_ERR_DENIED = STATUS_CATEGORY_COMMON | 0x0c,
|
||||
STATUS_ERR_ALREADY_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0d,
|
||||
STATUS_ERR_OVERFLOW = STATUS_CATEGORY_COMMON | 0x0e,
|
||||
STATUS_ERR_NOT_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0f,
|
||||
|
||||
STATUS_ERR_SAMPLERATE_UNAVAILABLE = STATUS_CATEGORY_ANALOG | 0x00,
|
||||
STATUS_ERR_RESOLUTION_UNAVAILABLE = STATUS_CATEGORY_ANALOG | 0x01,
|
||||
|
||||
STATUS_ERR_BAUDRATE_UNAVAILABLE = STATUS_CATEGORY_COM | 0x00,
|
||||
STATUS_ERR_PACKET_COLLISION = STATUS_CATEGORY_COM | 0x01,
|
||||
STATUS_ERR_PROTOCOL = STATUS_CATEGORY_COM | 0x02,
|
||||
|
||||
STATUS_ERR_PIN_MUX_INVALID = STATUS_CATEGORY_IO | 0x00,
|
||||
};
|
||||
typedef enum status_code status_code_genare_t;
|
||||
|
||||
/**
|
||||
Status codes used by MAC stack.
|
||||
*/
|
||||
enum status_code_wireless {
|
||||
//STATUS_OK = 0, //!< Success
|
||||
ERR_IO_ERROR = -1, //!< I/O error
|
||||
ERR_FLUSHED = -2, //!< Request flushed from queue
|
||||
ERR_TIMEOUT = -3, //!< Operation timed out
|
||||
ERR_BAD_DATA = -4, //!< Data integrity check failed
|
||||
ERR_PROTOCOL = -5, //!< Protocol error
|
||||
ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device
|
||||
ERR_NO_MEMORY = -7, //!< Insufficient memory
|
||||
ERR_INVALID_ARG = -8, //!< Invalid argument
|
||||
ERR_BAD_ADDRESS = -9, //!< Bad address
|
||||
ERR_BUSY = -10, //!< Resource is busy
|
||||
ERR_BAD_FORMAT = -11, //!< Data format not recognized
|
||||
ERR_NO_TIMER = -12, //!< No timer available
|
||||
ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running
|
||||
ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running
|
||||
|
||||
/**
|
||||
* \brief Operation in progress
|
||||
*
|
||||
* This status code is for driver-internal use when an operation
|
||||
* is currently being performed.
|
||||
*
|
||||
* \note Drivers should never return this status code to any
|
||||
* callers. It is strictly for internal use.
|
||||
*/
|
||||
OPERATION_IN_PROGRESS = -128,
|
||||
};
|
||||
|
||||
typedef enum status_code_wireless status_code_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* STATUS_CODES_H_INCLUDED */
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board definition template
|
||||
*
|
||||
*/
|
||||
|
||||
/* This file is intended to contain definitions and configuration details for
|
||||
* features and devices that are available on the board, e.g., frequency and
|
||||
* startup time for an external crystal, external memory devices, LED and USART
|
||||
* pins.
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#ifndef USER_BOARD_H
|
||||
#define USER_BOARD_H
|
||||
|
||||
#include <conf_board.h>
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Resonator definitions */
|
||||
#define BOARD_FREQ_SLCK_XTAL (32768U)
|
||||
#define BOARD_FREQ_SLCK_BYPASS (32768U)
|
||||
#define BOARD_FREQ_MAINCK_XTAL 0 /* Not Mounted */
|
||||
#define BOARD_FREQ_MAINCK_BYPASS 0 /* Not Mounted */
|
||||
#define BOARD_MCK CHIP_FREQ_CPU_MAX
|
||||
#define BOARD_OSC_STARTUP_US 15625
|
||||
|
||||
/** UART interface definitions */
|
||||
#define UART_SERCOM_MODULE SERCOM2
|
||||
#define UART_SERCOM_MUX_SETTING USART_RX_3_TX_2_XCK_3
|
||||
#define UART_SERCOM_PINMUX_PAD0 PINMUX_UNUSED
|
||||
#define UART_SERCOM_PINMUX_PAD1 PINMUX_UNUSED
|
||||
#define UART_SERCOM_PINMUX_PAD2 PINMUX_PA14C_SERCOM2_PAD2
|
||||
#define UART_SERCOM_PINMUX_PAD3 PINMUX_PA15C_SERCOM2_PAD3
|
||||
#define UART_SERCOM_DMAC_ID_TX SERCOM2_DMAC_ID_TX
|
||||
#define UART_SERCOM_DMAC_ID_RX SERCOM2_DMAC_ID_RX
|
||||
|
||||
/** RF SPI interface definitions */
|
||||
#define RF_SPI_MODULE SERCOM4
|
||||
#define RF_SPI_SERCOM_MUX_SETTING SPI_SIGNAL_MUX_SETTING_E
|
||||
#define RF_SPI_SERCOM_PINMUX_PAD0 PINMUX_PC19F_SERCOM4_PAD0
|
||||
#define RF_SPI_SERCOM_PINMUX_PAD1 PINMUX_PB31D_SERCOM5_PAD1
|
||||
#define RF_SPI_SERCOM_PINMUX_PAD2 PINMUX_PB30F_SERCOM4_PAD2
|
||||
#define RF_SPI_SERCOM_PINMUX_PAD3 PINMUX_PC18F_SERCOM4_PAD3
|
||||
|
||||
#define RF_IRQ_MODULE EIC
|
||||
#define RF_IRQ_INPUT 0
|
||||
#define RF_IRQ_PIN PIN_PB00A_EIC_EXTINT0
|
||||
#define RF_IRQ_MUX MUX_PB00A_EIC_EXTINT0
|
||||
#define RF_IRQ_PINMUX PINMUX_PB00A_EIC_EXTINT0
|
||||
|
||||
/** 802.15.4 TRX Interface definitions */
|
||||
#define AT86RFX_SPI SERCOM4
|
||||
#define AT86RFX_RST_PIN PIN_PB15
|
||||
#define AT86RFX_IRQ_PIN PIN_PB00
|
||||
#define AT86RFX_SLP_PIN PIN_PA20
|
||||
#define AT86RFX_SPI_CS PIN_PB31
|
||||
#define AT86RFX_SPI_MOSI PIN_PB30
|
||||
#define AT86RFX_SPI_MISO PIN_PC19
|
||||
#define AT86RFX_SPI_SCK PIN_PC18
|
||||
#define RFCTRL_CFG_ANT_DIV 4
|
||||
|
||||
#define AT86RFX_SPI_SERCOM_MUX_SETTING RF_SPI_SERCOM_MUX_SETTING
|
||||
#define AT86RFX_SPI_SERCOM_PINMUX_PAD0 RF_SPI_SERCOM_PINMUX_PAD0
|
||||
#define AT86RFX_SPI_SERCOM_PINMUX_PAD1 PINMUX_UNUSED
|
||||
#define AT86RFX_SPI_SERCOM_PINMUX_PAD2 RF_SPI_SERCOM_PINMUX_PAD2
|
||||
#define AT86RFX_SPI_SERCOM_PINMUX_PAD3 RF_SPI_SERCOM_PINMUX_PAD3
|
||||
|
||||
#define AT86RFX_IRQ_CHAN RF_IRQ_INPUT
|
||||
#define AT86RFX_IRQ_PINMUX RF_IRQ_PINMUX
|
||||
|
||||
/** Enables the transceiver main interrupt. */
|
||||
#define ENABLE_TRX_IRQ() \
|
||||
extint_chan_enable_callback(AT86RFX_IRQ_CHAN, EXTINT_CALLBACK_TYPE_DETECT)
|
||||
|
||||
/** Disables the transceiver main interrupt. */
|
||||
#define DISABLE_TRX_IRQ() \
|
||||
extint_chan_disable_callback(AT86RFX_IRQ_CHAN, EXTINT_CALLBACK_TYPE_DETECT)
|
||||
|
||||
/** Clears the transceiver main interrupt. */
|
||||
#define CLEAR_TRX_IRQ() \
|
||||
extint_chan_clear_detected(AT86RFX_IRQ_CHAN);
|
||||
|
||||
/** This macro saves the trx interrupt status and disables the trx interrupt. */
|
||||
#define ENTER_TRX_REGION() \
|
||||
{ extint_chan_disable_callback(AT86RFX_IRQ_CHAN, EXTINT_CALLBACK_TYPE_DETECT)
|
||||
|
||||
/* This macro restores the transceiver interrupt status */
|
||||
#define LEAVE_TRX_REGION() \
|
||||
extint_chan_enable_callback(AT86RFX_IRQ_CHAN, EXTINT_CALLBACK_TYPE_DETECT); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // USER_BOARD_H
|
||||
Reference in New Issue
Block a user