From f81eebeb48fe72d0bfe3427a8cba0a17ef3f77d0 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 30 Mar 2021 21:59:21 -0700 Subject: [PATCH] [samr21] move to openthread/ot-samr21 (#6369) --- configure.ac | 11 +- examples/Makefile-samr21 | 286 ---- examples/platforms/Makefile.am | 9 +- examples/platforms/Makefile.platform.am | 4 - examples/platforms/samr21/CMakeLists.txt | 101 -- examples/platforms/samr21/Makefile.am | 148 --- .../platforms/samr21/Makefile.platform.am | 39 - examples/platforms/samr21/README.md | 208 +-- examples/platforms/samr21/alarm.c | 92 -- examples/platforms/samr21/arm-none-eabi.cmake | 42 - examples/platforms/samr21/crypto/aes_alt.c | 142 -- examples/platforms/samr21/crypto/aes_alt.h | 164 --- .../samr21/crypto/samr21-mbedtls-config.h | 47 - examples/platforms/samr21/cxx_helpers.c | 54 - examples/platforms/samr21/diag.c | 80 -- examples/platforms/samr21/entropy.c | 46 - examples/platforms/samr21/flash.c | 128 -- examples/platforms/samr21/logging.c | 132 -- examples/platforms/samr21/misc.c | 97 -- .../openthread-core-samr21-config-check.h | 36 - .../samr21/openthread-core-samr21-config.h | 85 -- examples/platforms/samr21/platform-samr21.h | 109 -- examples/platforms/samr21/radio.c | 676 ---------- examples/platforms/samr21/system.c | 200 --- examples/platforms/samr21/uart.c | 169 --- examples/platforms/samr21/user_row.h | 58 - script/check-arm-build-autotools | 21 - script/check-arm-build-cmake | 13 - script/cmake-build | 4 +- third_party/CMakeLists.txt | 2 - third_party/microchip/CMakeLists.txt | 127 -- third_party/microchip/README.md | 43 - third_party/microchip/include/asf.h | 112 -- third_party/microchip/include/compiler.h | 1168 ----------------- third_party/microchip/include/conf_board.h | 84 -- third_party/microchip/include/conf_clocks.h | 200 --- third_party/microchip/include/conf_extint.h | 53 - third_party/microchip/include/conf_spi.h | 53 - .../microchip/include/conf_trx_access.h | 46 - third_party/microchip/include/samr21x18a.ld | 164 --- third_party/microchip/include/status_codes.h | 148 --- third_party/microchip/include/user_board.h | 103 -- 42 files changed, 11 insertions(+), 5493 deletions(-) delete mode 100644 examples/Makefile-samr21 delete mode 100644 examples/platforms/samr21/CMakeLists.txt delete mode 100644 examples/platforms/samr21/Makefile.am delete mode 100644 examples/platforms/samr21/Makefile.platform.am delete mode 100644 examples/platforms/samr21/alarm.c delete mode 100644 examples/platforms/samr21/arm-none-eabi.cmake delete mode 100644 examples/platforms/samr21/crypto/aes_alt.c delete mode 100644 examples/platforms/samr21/crypto/aes_alt.h delete mode 100644 examples/platforms/samr21/crypto/samr21-mbedtls-config.h delete mode 100644 examples/platforms/samr21/cxx_helpers.c delete mode 100644 examples/platforms/samr21/diag.c delete mode 100644 examples/platforms/samr21/entropy.c delete mode 100644 examples/platforms/samr21/flash.c delete mode 100644 examples/platforms/samr21/logging.c delete mode 100644 examples/platforms/samr21/misc.c delete mode 100644 examples/platforms/samr21/openthread-core-samr21-config-check.h delete mode 100644 examples/platforms/samr21/openthread-core-samr21-config.h delete mode 100644 examples/platforms/samr21/platform-samr21.h delete mode 100644 examples/platforms/samr21/radio.c delete mode 100644 examples/platforms/samr21/system.c delete mode 100644 examples/platforms/samr21/uart.c delete mode 100644 examples/platforms/samr21/user_row.h delete mode 100644 third_party/microchip/CMakeLists.txt delete mode 100644 third_party/microchip/README.md delete mode 100644 third_party/microchip/include/asf.h delete mode 100644 third_party/microchip/include/compiler.h delete mode 100644 third_party/microchip/include/conf_board.h delete mode 100644 third_party/microchip/include/conf_clocks.h delete mode 100644 third_party/microchip/include/conf_extint.h delete mode 100644 third_party/microchip/include/conf_spi.h delete mode 100644 third_party/microchip/include/conf_trx_access.h delete mode 100644 third_party/microchip/include/samr21x18a.ld delete mode 100644 third_party/microchip/include/status_codes.h delete mode 100644 third_party/microchip/include/user_board.h diff --git a/configure.ac b/configure.ac index 8682eb03f..8642c154f 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/examples/Makefile-samr21 b/examples/Makefile-samr21 deleted file mode 100644 index 5dec5795a..000000000 --- a/examples/Makefile-samr21 +++ /dev/null @@ -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 -# -# 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 -# -# 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 -# -# 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 -# -# 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)) " - $(ECHO) "" diff --git a/examples/platforms/Makefile.am b/examples/platforms/Makefile.am index b090fa371..7a73f448a 100644 --- a/examples/platforms/Makefile.am +++ b/examples/platforms/Makefile.am @@ -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) diff --git a/examples/platforms/Makefile.platform.am b/examples/platforms/Makefile.platform.am index 085ec55f0..20d9fe8bc 100644 --- a/examples/platforms/Makefile.platform.am +++ b/examples/platforms/Makefile.platform.am @@ -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 diff --git a/examples/platforms/samr21/CMakeLists.txt b/examples/platforms/samr21/CMakeLists.txt deleted file mode 100644 index 041c164c3..000000000 --- a/examples/platforms/samr21/CMakeLists.txt +++ /dev/null @@ -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=$.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 -) diff --git a/examples/platforms/samr21/Makefile.am b/examples/platforms/samr21/Makefile.am deleted file mode 100644 index f7763c225..000000000 --- a/examples/platforms/samr21/Makefile.am +++ /dev/null @@ -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 diff --git a/examples/platforms/samr21/Makefile.platform.am b/examples/platforms/samr21/Makefile.platform.am deleted file mode 100644 index c5278d714..000000000 --- a/examples/platforms/samr21/Makefile.platform.am +++ /dev/null @@ -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) diff --git a/examples/platforms/samr21/README.md b/examples/platforms/samr21/README.md index 5e5a35af3..8ce10256b 100644 --- a/examples/platforms/samr21/README.md +++ b/examples/platforms/samr21/README.md @@ -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 -$ ./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 /third_party/microchip folder - -```bash -$ unzip asf-standalone-archive-3.45.0.85.zip -$ cp xdk-asf-3.45.0 -rf /third_party/microchip/asf -``` - -3. Build OpenThread Firmware (CLI example) on SAMR21 platform. - -```bash -$ cd -$ ./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= -``` - -where: - -| `` | 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 `/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 /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 -$ ./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 diff --git a/examples/platforms/samr21/alarm.c b/examples/platforms/samr21/alarm.c deleted file mode 100644 index 71856e26b..000000000 --- a/examples/platforms/samr21/alarm.c +++ /dev/null @@ -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 - -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); - } - } -} diff --git a/examples/platforms/samr21/arm-none-eabi.cmake b/examples/platforms/samr21/arm-none-eabi.cmake deleted file mode 100644 index 8ae2e8f34..000000000 --- a/examples/platforms/samr21/arm-none-eabi.cmake +++ /dev/null @@ -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") diff --git a/examples/platforms/samr21/crypto/aes_alt.c b/examples/platforms/samr21/crypto/aes_alt.c deleted file mode 100644 index b943e443a..000000000 --- a/examples/platforms/samr21/crypto/aes_alt.c +++ /dev/null @@ -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 -#include - -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 */ diff --git a/examples/platforms/samr21/crypto/aes_alt.h b/examples/platforms/samr21/crypto/aes_alt.h deleted file mode 100644 index cfe3729d2..000000000 --- a/examples/platforms/samr21/crypto/aes_alt.h +++ /dev/null @@ -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 */ diff --git a/examples/platforms/samr21/crypto/samr21-mbedtls-config.h b/examples/platforms/samr21/crypto/samr21-mbedtls-config.h deleted file mode 100644 index 193a689dc..000000000 --- a/examples/platforms/samr21/crypto/samr21-mbedtls-config.h +++ /dev/null @@ -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 diff --git a/examples/platforms/samr21/cxx_helpers.c b/examples/platforms/samr21/cxx_helpers.c deleted file mode 100644 index d4b003662..000000000 --- a/examples/platforms/samr21/cxx_helpers.c +++ /dev/null @@ -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) - ; -} diff --git a/examples/platforms/samr21/diag.c b/examples/platforms/samr21/diag.c deleted file mode 100644 index 856abf8b3..000000000 --- a/examples/platforms/samr21/diag.c +++ /dev/null @@ -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 - -#include -#include - -#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 diff --git a/examples/platforms/samr21/entropy.c b/examples/platforms/samr21/entropy.c deleted file mode 100644 index 6caef8e73..000000000 --- a/examples/platforms/samr21/entropy.c +++ /dev/null @@ -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 - -#include "phy.h" -#include "platform-samr21.h" -#include - -otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength) -{ - samr21RadioRandomGetTrue(aOutput, aOutputLength); - - return OT_ERROR_NONE; -} diff --git a/examples/platforms/samr21/flash.c b/examples/platforms/samr21/flash.c deleted file mode 100644 index 2feb46759..000000000 --- a/examples/platforms/samr21/flash.c +++ /dev/null @@ -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 - -#include - -#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); -} diff --git a/examples/platforms/samr21/logging.c b/examples/platforms/samr21/logging.c deleted file mode 100644 index 926f314a2..000000000 --- a/examples/platforms/samr21/logging.c +++ /dev/null @@ -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 -#include -#include - -#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 diff --git a/examples/platforms/samr21/misc.c b/examples/platforms/samr21/misc.c deleted file mode 100644 index a5e576b0e..000000000 --- a/examples/platforms/samr21/misc.c +++ /dev/null @@ -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 - -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. -} diff --git a/examples/platforms/samr21/openthread-core-samr21-config-check.h b/examples/platforms/samr21/openthread-core-samr21-config-check.h deleted file mode 100644 index 3b991e014..000000000 --- a/examples/platforms/samr21/openthread-core-samr21-config-check.h +++ /dev/null @@ -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_ */ diff --git a/examples/platforms/samr21/openthread-core-samr21-config.h b/examples/platforms/samr21/openthread-core-samr21-config.h deleted file mode 100644 index 54b22a948..000000000 --- a/examples/platforms/samr21/openthread-core-samr21-config.h +++ /dev/null @@ -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 - -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_ diff --git a/examples/platforms/samr21/platform-samr21.h b/examples/platforms/samr21/platform-samr21.h deleted file mode 100644 index 5c30979b5..000000000 --- a/examples/platforms/samr21/platform-samr21.h +++ /dev/null @@ -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 - -#include - -// 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_ diff --git a/examples/platforms/samr21/radio.c b/examples/platforms/samr21/radio.c deleted file mode 100644 index b38011c7d..000000000 --- a/examples/platforms/samr21/radio.c +++ /dev/null @@ -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 -#include -#include - -#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; -} diff --git a/examples/platforms/samr21/system.c b/examples/platforms/samr21/system.c deleted file mode 100644 index da4a9bcd6..000000000 --- a/examples/platforms/samr21/system.c +++ /dev/null @@ -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 -#include - -#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); -} diff --git a/examples/platforms/samr21/uart.c b/examples/platforms/samr21/uart.c deleted file mode 100644 index 6a5ebc6d3..000000000 --- a/examples/platforms/samr21/uart.c +++ /dev/null @@ -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; -} diff --git a/examples/platforms/samr21/user_row.h b/examples/platforms/samr21/user_row.h deleted file mode 100644 index 7ca381a50..000000000 --- a/examples/platforms/samr21/user_row.h +++ /dev/null @@ -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_ */ diff --git a/script/check-arm-build-autotools b/script/check-arm-build-autotools index 6c1de79e6..fb8066fa0 100755 --- a/script/check-arm-build-autotools +++ b/script/check-arm-build-autotools @@ -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 diff --git a/script/check-arm-build-cmake b/script/check-arm-build-cmake index 17a8b65e9..141c67c80 100755 --- a/script/check-arm-build-cmake +++ b/script/check-arm-build-cmake @@ -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 diff --git a/script/cmake-build b/script/cmake-build index 4b5e7db2c..a4e28fe3e 100755 --- a/script/cmake-build +++ b/script/cmake-build @@ -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) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 96ab34ab3..601b4ca0f 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -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) diff --git a/third_party/microchip/CMakeLists.txt b/third_party/microchip/CMakeLists.txt deleted file mode 100644 index 49d1d20a0..000000000 --- a/third_party/microchip/CMakeLists.txt +++ /dev/null @@ -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 -) diff --git a/third_party/microchip/README.md b/third_party/microchip/README.md deleted file mode 100644 index dfa118603..000000000 --- a/third_party/microchip/README.md +++ /dev/null @@ -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. diff --git a/third_party/microchip/include/asf.h b/third_party/microchip/include/asf.h deleted file mode 100644 index 1dc3d9db1..000000000 --- a/third_party/microchip/include/asf.h +++ /dev/null @@ -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 -#include - -// From module: Generic board support -#include - -// From module: EXTINT - External Interrupt (Callback APIs) -#include -#include - -// From module: Interrupt management - SAM implementation -#include - -// From module: NVM - Non-Volatile Memory -#include - -// From module: PORT - GPIO Pin Control -#include - -// From module: Part identification macros -#include - -// From module: SYSTEM - Clock Management for SAMD21/R21/DA/HA -#include -#include - -// From module: SERCOM Callback API -#include -#include - -// From module: SERCOM I2C - Master Mode I2C (Polled APIs) -#include -#include - -// From module: SERCOM SPI - Serial Peripheral Interface (Polled APIs) -#include - -// From module: SERCOM USART - Serial Communications (Callback APIs) -#include -#include - -// From module: SYSTEM - Core System Driver -#include - -// From module: SYSTEM - I/O Pin Multiplexer -#include - -// From module: SYSTEM - Interrupt Driver -#include - -// From module: SYSTEM - Power Management for SAM D20/D21/R21/D09/D10/D11/DA/HA -#include - -// From module: SYSTEM - Reset Management for SAM D20/D21/R21/D09/D10/D11/DA/HA -#include - -#endif // ASF_H diff --git a/third_party/microchip/include/compiler.h b/third_party/microchip/include/compiler.h deleted file mode 100644 index e8090342c..000000000 --- a/third_party/microchip/include/compiler.h +++ /dev/null @@ -1,1168 +0,0 @@ -/** - * \file - * - * \brief Commonly used includes, types and macros. - * - * 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 Microchip Support - */ - -#ifndef UTILS_COMPILER_H_INCLUDED -#define UTILS_COMPILER_H_INCLUDED - -/** - * \defgroup group_sam0_utils Compiler abstraction layer and code utilities - * - * Compiler abstraction layer and code utilities for Cortex-M0+ based Atmel SAM devices. - * This module provides various abstraction layers and utilities to make code compatible between different compilers. - * - * @{ - */ - -#if (defined __ICCARM__) -# include -#endif - -#include -#include -#include -#include -#include - -#ifndef __ASSEMBLY__ - -#include -#include -#include -#include - -/** - * \def UNUSED - * \brief Marking \a v as a unused parameter or value. - */ -#define UNUSED(v) (void)(v) - -/** - * \def barrier - * \brief Memory barrier - */ -#ifdef __GNUC__ -# define barrier() asm volatile("" ::: "memory") -#else -# define barrier() asm ("") -#endif - -/** - * \brief Emit the compiler pragma \a arg. - * - * \param[in] arg The pragma directive as it would appear after \e \#pragma - * (i.e. not stringified). - */ -#define COMPILER_PRAGMA(arg) _Pragma(#arg) - -/** - * \def COMPILER_PACK_SET(alignment) - * \brief Set maximum alignment for subsequent struct and union definitions to \a alignment. - */ -#define COMPILER_PACK_SET(alignment) COMPILER_PRAGMA(pack(alignment)) - -/** - * \def COMPILER_PACK_RESET() - * \brief Set default alignment for subsequent struct and union definitions. - */ -#define COMPILER_PACK_RESET() COMPILER_PRAGMA(pack()) - - -/** - * \brief Set aligned boundary. - */ -#if (defined __GNUC__) || (defined __CC_ARM) -# define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) -#elif (defined __ICCARM__) -# define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a) -#endif - -/** - * \brief Set word-aligned boundary. - */ -#if (defined __GNUC__) || defined(__CC_ARM) -#define COMPILER_WORD_ALIGNED __attribute__((__aligned__(4))) -#elif (defined __ICCARM__) -#define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 4) -#endif - -/** - * \def __always_inline - * \brief The function should always be inlined. - * - * This annotation instructs the compiler to ignore its inlining - * heuristics and inline the function no matter how big it thinks it - * becomes. - */ -#if !defined(__always_inline) -#if defined(__CC_ARM) -# define __always_inline __forceinline -#elif (defined __GNUC__) -# define __always_inline __attribute__((__always_inline__)) -#elif (defined __ICCARM__) -# define __always_inline _Pragma("inline=forced") -#endif -#endif - -/** - * \def __no_inline - * \brief The function should never be inlined - * - * This annotation instructs the compiler to ignore its inlining - * heuristics and not inline the function no matter how small it thinks it - * becomes. - */ -#if defined(__CC_ARM) -# define __no_inline __attribute__((noinline)) -#elif (defined __GNUC__) -# define __no_inline __attribute__((noinline)) -#elif (defined __ICCARM__) -# define __no_inline _Pragma("inline=never") -#endif - - -/** \brief This macro is used to test fatal errors. - * - * The macro tests if the expression is false. If it is, a fatal error is - * detected and the application hangs up. If \c TEST_SUITE_DEFINE_ASSERT_MACRO - * is defined, a unit test version of the macro is used, to allow execution - * of further tests after a false expression. - * - * \param[in] expr Expression to evaluate and supposed to be nonzero. - */ -#if defined(_ASSERT_ENABLE_) -# if defined(TEST_SUITE_DEFINE_ASSERT_MACRO) -# include "unit_test/suite.h" -# else -# undef TEST_SUITE_DEFINE_ASSERT_MACRO -# define Assert(expr) \ - {\ - if (!(expr)) asm("BKPT #0");\ - } -# endif -#else -# define Assert(expr) ((void) 0) -#endif - -/* Define WEAK attribute */ -#if defined ( __CC_ARM ) -# define WEAK __attribute__ ((weak)) -#elif defined ( __ICCARM__ ) -# define WEAK __weak -#elif defined ( __GNUC__ ) -# define WEAK __attribute__ ((weak)) -#endif - -/* Define NO_INIT attribute */ -#if defined ( __CC_ARM ) -# define NO_INIT __attribute__((zero_init)) -#elif defined ( __ICCARM__ ) -# define NO_INIT __no_init -#elif defined ( __GNUC__ ) -# define NO_INIT __attribute__((section(".no_init"))) -#endif - -#include "interrupt.h" - -/** \name Usual Types - * @{ */ -#ifndef __cplusplus -# if !defined(__bool_true_false_are_defined) -typedef unsigned char bool; -# endif -#endif -typedef uint16_t le16_t; -typedef uint16_t be16_t; -typedef uint32_t le32_t; -typedef uint32_t be32_t; -typedef uint32_t iram_size_t; -/** @} */ - -/** \name Aliasing Aggregate Types - * @{ */ - -/** 16-bit union. */ -typedef union -{ - int16_t s16; - uint16_t u16; - int8_t s8[2]; - uint8_t u8[2]; -} Union16; - -/** 32-bit union. */ -typedef union -{ - int32_t s32; - uint32_t u32; - int16_t s16[2]; - uint16_t u16[2]; - int8_t s8[4]; - uint8_t u8[4]; -} Union32; - -/** 64-bit union. */ -typedef union -{ - int64_t s64; - uint64_t u64; - int32_t s32[2]; - uint32_t u32[2]; - int16_t s16[4]; - uint16_t u16[4]; - int8_t s8[8]; - uint8_t u8[8]; -} Union64; - -/** Union of pointers to 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef union -{ - int64_t *s64ptr; - uint64_t *u64ptr; - int32_t *s32ptr; - uint32_t *u32ptr; - int16_t *s16ptr; - uint16_t *u16ptr; - int8_t *s8ptr; - uint8_t *u8ptr; -} UnionPtr; - -/** Union of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef union -{ - volatile int64_t *s64ptr; - volatile uint64_t *u64ptr; - volatile int32_t *s32ptr; - volatile uint32_t *u32ptr; - volatile int16_t *s16ptr; - volatile uint16_t *u16ptr; - volatile int8_t *s8ptr; - volatile uint8_t *u8ptr; -} UnionVPtr; - -/** Union of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef union -{ - const int64_t *s64ptr; - const uint64_t *u64ptr; - const int32_t *s32ptr; - const uint32_t *u32ptr; - const int16_t *s16ptr; - const uint16_t *u16ptr; - const int8_t *s8ptr; - const uint8_t *u8ptr; -} UnionCPtr; - -/** Union of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef union -{ - const volatile int64_t *s64ptr; - const volatile uint64_t *u64ptr; - const volatile int32_t *s32ptr; - const volatile uint32_t *u32ptr; - const volatile int16_t *s16ptr; - const volatile uint16_t *u16ptr; - const volatile int8_t *s8ptr; - const volatile uint8_t *u8ptr; -} UnionCVPtr; - -/** Structure of pointers to 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef struct -{ - int64_t *s64ptr; - uint64_t *u64ptr; - int32_t *s32ptr; - uint32_t *u32ptr; - int16_t *s16ptr; - uint16_t *u16ptr; - int8_t *s8ptr; - uint8_t *u8ptr; -} StructPtr; - -/** Structure of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef struct -{ - volatile int64_t *s64ptr; - volatile uint64_t *u64ptr; - volatile int32_t *s32ptr; - volatile uint32_t *u32ptr; - volatile int16_t *s16ptr; - volatile uint16_t *u16ptr; - volatile int8_t *s8ptr; - volatile uint8_t *u8ptr; -} StructVPtr; - -/** Structure of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef struct -{ - const int64_t *s64ptr; - const uint64_t *u64ptr; - const int32_t *s32ptr; - const uint32_t *u32ptr; - const int16_t *s16ptr; - const uint16_t *u16ptr; - const int8_t *s8ptr; - const uint8_t *u8ptr; -} StructCPtr; - -/** Structure of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. */ -typedef struct -{ - const volatile int64_t *s64ptr; - const volatile uint64_t *u64ptr; - const volatile int32_t *s32ptr; - const volatile uint32_t *u32ptr; - const volatile int16_t *s16ptr; - const volatile uint16_t *u16ptr; - const volatile int8_t *s8ptr; - const volatile uint8_t *u8ptr; -} StructCVPtr; - -/** @} */ - -#endif /* #ifndef __ASSEMBLY__ */ - -/** \name Usual Constants - * @{ */ -#define DISABLE 0 -#define ENABLE 1 - -#ifndef __cplusplus -# if !defined(__bool_true_false_are_defined) -# define false 0 -# define true 1 -# endif -#endif -/** @} */ - -#ifndef __ASSEMBLY__ - -/** \name Optimization Control - * @{ */ - -/** - * \def likely(exp) - * \brief The expression \a exp is likely to be true - */ -#if !defined(likely) || defined(__DOXYGEN__) -# define likely(exp) (exp) -#endif - -/** - * \def unlikely(exp) - * \brief The expression \a exp is unlikely to be true - */ -#if !defined(unlikely) || defined(__DOXYGEN__) -# define unlikely(exp) (exp) -#endif - -/** - * \def is_constant(exp) - * \brief Determine if an expression evaluates to a constant value. - * - * \param[in] exp Any expression - * - * \return true if \a exp is constant, false otherwise. - */ -#if (defined __GNUC__) || (defined __CC_ARM) -# define is_constant(exp) __builtin_constant_p(exp) -#else -# define is_constant(exp) (0) -#endif - -/** @} */ - -/** \name Bit-Field Handling - * @{ */ - -/** \brief Reads the bits of a value specified by a given bit-mask. - * - * \param[in] value Value to read bits from. - * \param[in] mask Bit-mask indicating bits to read. - * - * \return Read bits. - */ -#define Rd_bits( value, mask) ((value) & (mask)) - -/** \brief Writes the bits of a C lvalue specified by a given bit-mask. - * - * \param[in] lvalue C lvalue to write bits to. - * \param[in] mask Bit-mask indicating bits to write. - * \param[in] bits Bits to write. - * - * \return Resulting value with written bits. - */ -#define Wr_bits(lvalue, mask, bits) ((lvalue) = ((lvalue) & ~(mask)) |\ - ((bits ) & (mask))) - -/** \brief Tests the bits of a value specified by a given bit-mask. - * - * \param[in] value Value of which to test bits. - * \param[in] mask Bit-mask indicating bits to test. - * - * \return \c 1 if at least one of the tested bits is set, else \c 0. - */ -#define Tst_bits( value, mask) (Rd_bits(value, mask) != 0) - -/** \brief Clears the bits of a C lvalue specified by a given bit-mask. - * - * \param[in] lvalue C lvalue of which to clear bits. - * \param[in] mask Bit-mask indicating bits to clear. - * - * \return Resulting value with cleared bits. - */ -#define Clr_bits(lvalue, mask) ((lvalue) &= ~(mask)) - -/** \brief Sets the bits of a C lvalue specified by a given bit-mask. - * - * \param[in] lvalue C lvalue of which to set bits. - * \param[in] mask Bit-mask indicating bits to set. - * - * \return Resulting value with set bits. - */ -#define Set_bits(lvalue, mask) ((lvalue) |= (mask)) - -/** \brief Toggles the bits of a C lvalue specified by a given bit-mask. - * - * \param[in] lvalue C lvalue of which to toggle bits. - * \param[in] mask Bit-mask indicating bits to toggle. - * - * \return Resulting value with toggled bits. - */ -#define Tgl_bits(lvalue, mask) ((lvalue) ^= (mask)) - -/** \brief Reads the bit-field of a value specified by a given bit-mask. - * - * \param[in] value Value to read a bit-field from. - * \param[in] mask Bit-mask indicating the bit-field to read. - * - * \return Read bit-field. - */ -#define Rd_bitfield( value, mask) (Rd_bits( value, mask) >> ctz(mask)) - -/** \brief Writes the bit-field of a C lvalue specified by a given bit-mask. - * - * \param[in] lvalue C lvalue to write a bit-field to. - * \param[in] mask Bit-mask indicating the bit-field to write. - * \param[in] bitfield Bit-field to write. - * - * \return Resulting value with written bit-field. - */ -#define Wr_bitfield(lvalue, mask, bitfield) (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask))) - -/** @} */ - - -/** \name Zero-Bit Counting - * - * Under GCC, __builtin_clz and __builtin_ctz behave like macros when - * applied to constant expressions (values known at compile time), so they are - * more optimized than the use of the corresponding assembly instructions and - * they can be used as constant expressions e.g. to initialize objects having - * static storage duration, and like the corresponding assembly instructions - * when applied to non-constant expressions (values unknown at compile time), so - * they are more optimized than an assembly periphrasis. Hence, clz and ctz - * ensure a possible and optimized behavior for both constant and non-constant - * expressions. - * - * @{ */ - -/** \brief Counts the leading zero bits of the given value considered as a 32-bit integer. - * - * \param[in] u Value of which to count the leading zero bits. - * - * \return The count of leading zero bits in \a u. - */ -#if (defined __GNUC__) || (defined __CC_ARM) -# define clz(u) ((u) ? __builtin_clz(u) : 32) -#else -# define clz(u) (((u) == 0) ? 32 : \ - ((u) & (1ul << 31)) ? 0 : \ - ((u) & (1ul << 30)) ? 1 : \ - ((u) & (1ul << 29)) ? 2 : \ - ((u) & (1ul << 28)) ? 3 : \ - ((u) & (1ul << 27)) ? 4 : \ - ((u) & (1ul << 26)) ? 5 : \ - ((u) & (1ul << 25)) ? 6 : \ - ((u) & (1ul << 24)) ? 7 : \ - ((u) & (1ul << 23)) ? 8 : \ - ((u) & (1ul << 22)) ? 9 : \ - ((u) & (1ul << 21)) ? 10 : \ - ((u) & (1ul << 20)) ? 11 : \ - ((u) & (1ul << 19)) ? 12 : \ - ((u) & (1ul << 18)) ? 13 : \ - ((u) & (1ul << 17)) ? 14 : \ - ((u) & (1ul << 16)) ? 15 : \ - ((u) & (1ul << 15)) ? 16 : \ - ((u) & (1ul << 14)) ? 17 : \ - ((u) & (1ul << 13)) ? 18 : \ - ((u) & (1ul << 12)) ? 19 : \ - ((u) & (1ul << 11)) ? 20 : \ - ((u) & (1ul << 10)) ? 21 : \ - ((u) & (1ul << 9)) ? 22 : \ - ((u) & (1ul << 8)) ? 23 : \ - ((u) & (1ul << 7)) ? 24 : \ - ((u) & (1ul << 6)) ? 25 : \ - ((u) & (1ul << 5)) ? 26 : \ - ((u) & (1ul << 4)) ? 27 : \ - ((u) & (1ul << 3)) ? 28 : \ - ((u) & (1ul << 2)) ? 29 : \ - ((u) & (1ul << 1)) ? 30 : \ - 31) -#endif - -/** \brief Counts the trailing zero bits of the given value considered as a 32-bit integer. - * - * \param[in] u Value of which to count the trailing zero bits. - * - * \return The count of trailing zero bits in \a u. - */ -#if (defined __GNUC__) || (defined __CC_ARM) -# define ctz(u) ((u) ? __builtin_ctz(u) : 32) -#else -# define ctz(u) ((u) & (1ul << 0) ? 0 : \ - (u) & (1ul << 1) ? 1 : \ - (u) & (1ul << 2) ? 2 : \ - (u) & (1ul << 3) ? 3 : \ - (u) & (1ul << 4) ? 4 : \ - (u) & (1ul << 5) ? 5 : \ - (u) & (1ul << 6) ? 6 : \ - (u) & (1ul << 7) ? 7 : \ - (u) & (1ul << 8) ? 8 : \ - (u) & (1ul << 9) ? 9 : \ - (u) & (1ul << 10) ? 10 : \ - (u) & (1ul << 11) ? 11 : \ - (u) & (1ul << 12) ? 12 : \ - (u) & (1ul << 13) ? 13 : \ - (u) & (1ul << 14) ? 14 : \ - (u) & (1ul << 15) ? 15 : \ - (u) & (1ul << 16) ? 16 : \ - (u) & (1ul << 17) ? 17 : \ - (u) & (1ul << 18) ? 18 : \ - (u) & (1ul << 19) ? 19 : \ - (u) & (1ul << 20) ? 20 : \ - (u) & (1ul << 21) ? 21 : \ - (u) & (1ul << 22) ? 22 : \ - (u) & (1ul << 23) ? 23 : \ - (u) & (1ul << 24) ? 24 : \ - (u) & (1ul << 25) ? 25 : \ - (u) & (1ul << 26) ? 26 : \ - (u) & (1ul << 27) ? 27 : \ - (u) & (1ul << 28) ? 28 : \ - (u) & (1ul << 29) ? 29 : \ - (u) & (1ul << 30) ? 30 : \ - (u) & (1ul << 31) ? 31 : \ - 32) -#endif - -/** @} */ - - -/** \name Bit Reversing - * @{ */ - -/** \brief Reverses the bits of \a u8. - * - * \param[in] u8 U8 of which to reverse the bits. - * - * \return Value resulting from \a u8 with reversed bits. - */ -#define bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24)) - -/** \brief Reverses the bits of \a u16. - * - * \param[in] u16 U16 of which to reverse the bits. - * - * \return Value resulting from \a u16 with reversed bits. - */ -#define bit_reverse16(u16) ((uint16_t)(bit_reverse32((uint16_t)(u16)) >> 16)) - -/** \brief Reverses the bits of \a u32. - * - * \param[in] u32 U32 of which to reverse the bits. - * - * \return Value resulting from \a u32 with reversed bits. - */ -#define bit_reverse32(u32) __RBIT(u32) - -/** \brief Reverses the bits of \a u64. - * - * \param[in] u64 U64 of which to reverse the bits. - * - * \return Value resulting from \a u64 with reversed bits. - */ -#define bit_reverse64(u64) ((uint64_t)(((uint64_t)bit_reverse32((uint64_t)(u64) >> 32)) |\ - ((uint64_t)bit_reverse32((uint64_t)(u64)) << 32))) - -/** @} */ - - -/** \name Alignment - * @{ */ - -/** \brief Tests alignment of the number \a val with the \a n boundary. - * - * \param[in] val Input value. - * \param[in] n Boundary. - * - * \return \c 1 if the number \a val is aligned with the \a n boundary, else \c 0. - */ -#define Test_align(val, n) (!Tst_bits( val, (n) - 1 ) ) - -/** \brief Gets alignment of the number \a val with respect to the \a n boundary. - * - * \param[in] val Input value. - * \param[in] n Boundary. - * - * \return Alignment of the number \a val with respect to the \a n boundary. - */ -#define Get_align(val, n) ( Rd_bits( val, (n) - 1 ) ) - -/** \brief Sets alignment of the lvalue number \a lval to \a alg with respect to the \a n boundary. - * - * \param[in] lval Input/output lvalue. - * \param[in] n Boundary. - * \param[in] alg Alignment. - * - * \return New value of \a lval resulting from its alignment set to \a alg with respect to the \a n boundary. - */ -#define Set_align(lval, n, alg) ( Wr_bits(lval, (n) - 1, alg) ) - -/** \brief Aligns the number \a val with the upper \a n boundary. - * - * \param[in] val Input value. - * \param[in] n Boundary. - * - * \return Value resulting from the number \a val aligned with the upper \a n boundary. - */ -#define Align_up( val, n) (((val) + ((n) - 1)) & ~((n) - 1)) - -/** \brief Aligns the number \a val with the lower \a n boundary. - * - * \param[in] val Input value. - * \param[in] n Boundary. - * - * \return Value resulting from the number \a val aligned with the lower \a n boundary. - */ -#define Align_down(val, n) ( (val) & ~((n) - 1)) - -/** @} */ - - -/** \name Mathematics - * - * The same considerations as for clz and ctz apply here but GCC does not - * provide built-in functions to access the assembly instructions abs, min and - * max and it does not produce them by itself in most cases, so two sets of - * macros are defined here: - * - Abs, Min and Max to apply to constant expressions (values known at - * compile time); - * - abs, min and max to apply to non-constant expressions (values unknown at - * compile time), abs is found in stdlib.h. - * - * @{ */ - -/** \brief Takes the absolute value of \a a. - * - * \param[in] a Input value. - * - * \return Absolute value of \a a. - * - * \note More optimized if only used with values known at compile time. - */ -#define Abs(a) (((a) < 0 ) ? -(a) : (a)) - -#ifndef __cplusplus -/** \brief Takes the minimal value of \a a and \a b. - * - * \param[in] a Input value. - * \param[in] b Input value. - * - * \return Minimal value of \a a and \a b. - * - * \note More optimized if only used with values known at compile time. - */ -#define Min(a, b) (((a) < (b)) ? (a) : (b)) - -/** \brief Takes the maximal value of \a a and \a b. - * - * \param[in] a Input value. - * \param[in] b Input value. - * - * \return Maximal value of \a a and \a b. - * - * \note More optimized if only used with values known at compile time. - */ -#define Max(a, b) (((a) > (b)) ? (a) : (b)) - -/** \brief Takes the minimal value of \a a and \a b. - * - * \param[in] a Input value. - * \param[in] b Input value. - * - * \return Minimal value of \a a and \a b. - * - * \note More optimized if only used with values unknown at compile time. - */ -#define min(a, b) Min(a, b) - -/** \brief Takes the maximal value of \a a and \a b. - * - * \param[in] a Input value. - * \param[in] b Input value. - * - * \return Maximal value of \a a and \a b. - * - * \note More optimized if only used with values unknown at compile time. - */ -#define max(a, b) Max(a, b) -#endif - -/** @} */ - - -/** \brief Calls the routine at address \a addr. - * - * It generates a long call opcode. - * - * For example, `Long_call(0x80000000)' generates a software reset on a UC3 if - * it is invoked from the CPU supervisor mode. - * - * \param[in] addr Address of the routine to call. - * - * \note It may be used as a long jump opcode in some special cases. - */ -#define Long_call(addr) ((*(void (*)(void))(addr))()) - - -/** \name MCU Endianism Handling - * ARM is MCU little endian. - * - * @{ */ -#define BE16(x) swap16(x) -#define LE16(x) (x) - -#define le16_to_cpu(x) (x) -#define cpu_to_le16(x) (x) -#define LE16_TO_CPU(x) (x) -#define CPU_TO_LE16(x) (x) - -#define be16_to_cpu(x) swap16(x) -#define cpu_to_be16(x) swap16(x) -#define BE16_TO_CPU(x) swap16(x) -#define CPU_TO_BE16(x) swap16(x) - -#define le32_to_cpu(x) (x) -#define cpu_to_le32(x) (x) -#define LE32_TO_CPU(x) (x) -#define CPU_TO_LE32(x) (x) - -#define be32_to_cpu(x) swap32(x) -#define cpu_to_be32(x) swap32(x) -#define BE32_TO_CPU(x) swap32(x) -#define CPU_TO_BE32(x) swap32(x) -/** @} */ - - -/** \name Endianism Conversion - * - * The same considerations as for clz and ctz apply here but GCC's - * __builtin_bswap_32 and __builtin_bswap_64 do not behave like macros when - * applied to constant expressions, so two sets of macros are defined here: - * - Swap16, Swap32 and Swap64 to apply to constant expressions (values known - * at compile time); - * - swap16, swap32 and swap64 to apply to non-constant expressions (values - * unknown at compile time). - * - * @{ */ - -/** \brief Toggles the endianism of \a u16 (by swapping its bytes). - * - * \param[in] u16 U16 of which to toggle the endianism. - * - * \return Value resulting from \a u16 with toggled endianism. - * - * \note More optimized if only used with values known at compile time. - */ -#define Swap16(u16) ((uint16_t)(((uint16_t)(u16) >> 8) |\ - ((uint16_t)(u16) << 8))) - -/** \brief Toggles the endianism of \a u32 (by swapping its bytes). - * - * \param[in] u32 U32 of which to toggle the endianism. - * - * \return Value resulting from \a u32 with toggled endianism. - * - * \note More optimized if only used with values known at compile time. - */ -#define Swap32(u32) ((uint32_t)(((uint32_t)Swap16((uint32_t)(u32) >> 16)) |\ - ((uint32_t)Swap16((uint32_t)(u32)) << 16))) - -/** \brief Toggles the endianism of \a u64 (by swapping its bytes). - * - * \param[in] u64 U64 of which to toggle the endianism. - * - * \return Value resulting from \a u64 with toggled endianism. - * - * \note More optimized if only used with values known at compile time. - */ -#define Swap64(u64) ((uint64_t)(((uint64_t)Swap32((uint64_t)(u64) >> 32)) |\ - ((uint64_t)Swap32((uint64_t)(u64)) << 32))) - -/** \brief Toggles the endianism of \a u16 (by swapping its bytes). - * - * \param[in] u16 U16 of which to toggle the endianism. - * - * \return Value resulting from \a u16 with toggled endianism. - * - * \note More optimized if only used with values unknown at compile time. - */ -#define swap16(u16) Swap16(u16) - -/** \brief Toggles the endianism of \a u32 (by swapping its bytes). - * - * \param[in] u32 U32 of which to toggle the endianism. - * - * \return Value resulting from \a u32 with toggled endianism. - * - * \note More optimized if only used with values unknown at compile time. - */ -#if (defined __GNUC__) -# define swap32(u32) ((uint32_t)__builtin_bswap32((uint32_t)(u32))) -#else -# define swap32(u32) Swap32(u32) -#endif - -/** \brief Toggles the endianism of \a u64 (by swapping its bytes). - * - * \param[in] u64 U64 of which to toggle the endianism. - * - * \return Value resulting from \a u64 with toggled endianism. - * - * \note More optimized if only used with values unknown at compile time. - */ -#if (defined __GNUC__) -# define swap64(u64) ((uint64_t)__builtin_bswap64((uint64_t)(u64))) -#else -# define swap64(u64) ((uint64_t)(((uint64_t)swap32((uint64_t)(u64) >> 32)) |\ - ((uint64_t)swap32((uint64_t)(u64)) << 32))) -#endif - -/** @} */ - - -/** \name Target Abstraction - * - * @{ */ - -#define _GLOBEXT_ extern /**< extern storage-class specifier. */ -#define _CONST_TYPE_ const /**< const type qualifier. */ -#define _MEM_TYPE_SLOW_ /**< Slow memory type. */ -#define _MEM_TYPE_MEDFAST_ /**< Fairly fast memory type. */ -#define _MEM_TYPE_FAST_ /**< Fast memory type. */ - -#define memcmp_ram2ram memcmp /**< Target-specific memcmp of RAM to RAM. */ -#define memcmp_code2ram memcmp /**< Target-specific memcmp of RAM to NVRAM. */ -#define memcpy_ram2ram memcpy /**< Target-specific memcpy from RAM to RAM. */ -#define memcpy_code2ram memcpy /**< Target-specific memcpy from NVRAM to RAM. */ - -/** @} */ - -/** - * \brief Calculate \f$ \left\lceil \frac{a}{b} \right\rceil \f$ using - * integer arithmetic. - * - * \param[in] a An integer - * \param[in] b Another integer - * - * \return (\a a / \a b) rounded up to the nearest integer. - */ -#define div_ceil(a, b) (((a) + (b) - 1) / (b)) - -#endif /* #ifndef __ASSEMBLY__ */ -#ifdef __ICCARM__ -/** \name Compiler Keywords - * - * Port of some keywords from GCC to IAR Embedded Workbench. - * - * @{ */ - -#define __asm__ asm -#define __inline__ inline -#define __volatile__ - -/** @} */ - -#endif - -#define FUNC_PTR void * -/** - * \def unused - * \brief Marking \a v as a unused parameter or value. - */ -#define unused(v) do { (void)(v); } while(0) - -/* Define RAMFUNC attribute */ -#if defined ( __CC_ARM ) /* Keil uVision 4 */ -# define RAMFUNC __attribute__ ((section(".ramfunc"))) -#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ -# define RAMFUNC __ramfunc -#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */ -# define RAMFUNC __attribute__ ((section(".ramfunc"))) -#endif - -/* Define OPTIMIZE_HIGH attribute */ -#if defined ( __CC_ARM ) /* Keil uVision 4 */ -# define OPTIMIZE_HIGH _Pragma("O3") -#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ -# define OPTIMIZE_HIGH _Pragma("optimize=high") -#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */ -# define OPTIMIZE_HIGH __attribute__((optimize("s"))) -#endif -#define PASS 0 -#define FAIL 1 -#define LOW 0 -#define HIGH 1 - -typedef int8_t S8 ; //!< 8-bit signed integer. -typedef uint8_t U8 ; //!< 8-bit unsigned integer. -typedef int16_t S16; //!< 16-bit signed integer. -typedef uint16_t U16; //!< 16-bit unsigned integer. -typedef int32_t S32; //!< 32-bit signed integer. -typedef uint32_t U32; //!< 32-bit unsigned integer. -typedef int64_t S64; //!< 64-bit signed integer. -typedef uint64_t U64; //!< 64-bit unsigned integer. -typedef float F32; //!< 32-bit floating-point number. -typedef double F64; //!< 64-bit floating-point number. - -#define MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16. -#define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16. - -#define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32. -#define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32. -#define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32. -#define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32. -#define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32. -#define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32. -#define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32. -#define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32. -#define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32. -#define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32. - -#define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64. -#define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64. -#define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64. -#define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64. -#define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64. -#define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64. -#define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64. -#define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64. -#define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64. -#define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64. -#define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64. -#define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64. -#define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64. -#define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64. -#define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64. -#define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64. -#define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64. -#define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64. -#define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64. -#define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64. -#define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64. -#define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64. -#define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64. -#define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64. -#define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64. -#define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64. - -#define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32. -#define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32. -#define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32. -#define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32. -#define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32. -#define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32. -#define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32. -#define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32. - -#if defined(__ICCARM__) -#define SHORTENUM __packed -#elif defined(__GNUC__) -#define SHORTENUM __attribute__((packed)) -#endif - -/* No operation */ -#if defined(__ICCARM__) -#define nop() __no_operation() -#elif defined(__GNUC__) -#define nop() (__NOP()) -#endif - -#define FLASH_DECLARE(x) const x -#define FLASH_EXTERN(x) extern const x -#define PGM_READ_BYTE(x) *(x) -#define PGM_READ_WORD(x) *(x) -#define MEMCPY_ENDIAN memcpy -#define PGM_READ_BLOCK(dst, src, len) memcpy((dst), (src), (len)) - -/*Defines the Flash Storage for the request and response of MAC*/ -#define CMD_ID_OCTET (0) - -/* Converting of values from CPU endian to little endian. */ -#define CPU_ENDIAN_TO_LE16(x) (x) -#define CPU_ENDIAN_TO_LE32(x) (x) -#define CPU_ENDIAN_TO_LE64(x) (x) - -/* Converting of values from little endian to CPU endian. */ -#define LE16_TO_CPU_ENDIAN(x) (x) -#define LE32_TO_CPU_ENDIAN(x) (x) -#define LE64_TO_CPU_ENDIAN(x) (x) - -/* Converting of constants from little endian to CPU endian. */ -#define CLE16_TO_CPU_ENDIAN(x) (x) -#define CLE32_TO_CPU_ENDIAN(x) (x) -#define CLE64_TO_CPU_ENDIAN(x) (x) - -/* Converting of constants from CPU endian to little endian. */ -#define CCPU_ENDIAN_TO_LE16(x) (x) -#define CCPU_ENDIAN_TO_LE32(x) (x) -#define CCPU_ENDIAN_TO_LE64(x) (x) - -#define ADDR_COPY_DST_SRC_16(dst, src) ((dst) = (src)) -#define ADDR_COPY_DST_SRC_64(dst, src) ((dst) = (src)) - -/** - * @brief Converts a 64-Bit value into a 8 Byte array - * - * @param[in] value 64-Bit value - * @param[out] data Pointer to the 8 Byte array to be updated with 64-Bit value - * @ingroup apiPalApi - */ -static inline void convert_64_bit_to_byte_array(uint64_t value, uint8_t *data) -{ - uint8_t index = 0; - - while (index < 8) - { - data[index++] = value & 0xFF; - value = value >> 8; - } -} - -/** - * @brief Converts a 16-Bit value into a 2 Byte array - * - * @param[in] value 16-Bit value - * @param[out] data Pointer to the 2 Byte array to be updated with 16-Bit value - * @ingroup apiPalApi - */ -static inline void convert_16_bit_to_byte_array(uint16_t value, uint8_t *data) -{ - data[0] = value & 0xFF; - data[1] = (value >> 8) & 0xFF; -} - -/* Converts a 16-Bit value into a 2 Byte array */ -static inline void convert_spec_16_bit_to_byte_array(uint16_t value, uint8_t *data) -{ - data[0] = value & 0xFF; - data[1] = (value >> 8) & 0xFF; -} - -/* Converts a 16-Bit value into a 2 Byte array */ -static inline void convert_16_bit_to_byte_address(uint16_t value, uint8_t *data) -{ - data[0] = value & 0xFF; - data[1] = (value >> 8) & 0xFF; -} - -/* - * @brief Converts a 2 Byte array into a 16-Bit value - * - * @param data Specifies the pointer to the 2 Byte array - * - * @return 16-Bit value - * @ingroup apiPalApi - */ -static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data) -{ - return (data[0] | ((uint16_t)data[1] << 8)); -} - -/* Converts a 4 Byte array into a 32-Bit value */ -static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data) -{ - union - { - uint32_t u32; - uint8_t u8[4]; - }long_addr; - uint8_t index; - for (index = 0; index < 4; index++) - { - long_addr.u8[index] = *data++; - } - return long_addr.u32; -} - -/** - * @brief Converts a 8 Byte array into a 64-Bit value - * - * @param data Specifies the pointer to the 8 Byte array - * - * @return 64-Bit value - * @ingroup apiPalApi - */ -static inline uint64_t convert_byte_array_to_64_bit(uint8_t *data) -{ - union - { - uint64_t u64; - uint8_t u8[8]; - } long_addr; - - uint8_t index; - - for (index = 0; index < 8; index++) - { - long_addr.u8[index] = *data++; - } - - return long_addr.u64; -} - -/** @} */ - -#endif /* UTILS_COMPILER_H_INCLUDED */ diff --git a/third_party/microchip/include/conf_board.h b/third_party/microchip/include/conf_board.h deleted file mode 100644 index 79034ab80..000000000 --- a/third_party/microchip/include/conf_board.h +++ /dev/null @@ -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 Atmel Support - */ - -#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 */ diff --git a/third_party/microchip/include/conf_clocks.h b/third_party/microchip/include/conf_clocks.h deleted file mode 100644 index a681198d3..000000000 --- a/third_party/microchip/include/conf_clocks.h +++ /dev/null @@ -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 Atmel Support - */ - -#include - -#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 */ diff --git a/third_party/microchip/include/conf_extint.h b/third_party/microchip/include/conf_extint.h deleted file mode 100644 index b6d2dbe2f..000000000 --- a/third_party/microchip/include/conf_extint.h +++ /dev/null @@ -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 Atmel Support - */ - -#ifndef CONF_EXTINT_H_INCLUDED -#define CONF_EXTINT_H_INCLUDED - -#define EXTINT_CLOCK_SOURCE GCLK_GENERATOR_0 -#define EXTINT_CALLBACKS_MAX 10 - -#endif diff --git a/third_party/microchip/include/conf_spi.h b/third_party/microchip/include/conf_spi.h deleted file mode 100644 index c416d061a..000000000 --- a/third_party/microchip/include/conf_spi.h +++ /dev/null @@ -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 Atmel Support - */ - -#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 */ diff --git a/third_party/microchip/include/conf_trx_access.h b/third_party/microchip/include/conf_trx_access.h deleted file mode 100644 index c4940ba93..000000000 --- a/third_party/microchip/include/conf_trx_access.h +++ /dev/null @@ -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 */ diff --git a/third_party/microchip/include/samr21x18a.ld b/third_party/microchip/include/samr21x18a.ld deleted file mode 100644 index 886ef1a99..000000000 --- a/third_party/microchip/include/samr21x18a.ld +++ /dev/null @@ -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; -} diff --git a/third_party/microchip/include/status_codes.h b/third_party/microchip/include/status_codes.h deleted file mode 100644 index 532f8b290..000000000 --- a/third_party/microchip/include/status_codes.h +++ /dev/null @@ -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 Microchip Support - */ - -#ifndef STATUS_CODES_H_INCLUDED -#define STATUS_CODES_H_INCLUDED - -#include - -/** - * \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 */ diff --git a/third_party/microchip/include/user_board.h b/third_party/microchip/include/user_board.h deleted file mode 100644 index d18ba1ac4..000000000 --- a/third_party/microchip/include/user_board.h +++ /dev/null @@ -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 Atmel Support - */ - -#ifndef USER_BOARD_H -#define USER_BOARD_H - -#include -#include - -#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