[efr32] common platform abstraction layer (#5666)

This merges the PAL sources for all efr32-based platforms.
This commit is contained in:
Mason Tran
2020-10-21 12:04:27 -07:00
committed by GitHub
parent dcebe97f82
commit 968440da34
137 changed files with 963 additions and 12629 deletions
+6 -13
View File
@@ -822,6 +822,7 @@ AM_CONDITIONAL([OPENTHREAD_EXAMPLES_SAMR21], [test "${with_examples}" = "samr
AM_COND_IF([OPENTHREAD_EXAMPLES_SIMULATION], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=0")
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF528XX], [test OPENTHREAD_EXAMPLES_NRF52811 || test OPENTHREAD_EXAMPLES_NRF52833 || test OPENTHREAD_EXAMPLES_NRF52840])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32], [test "${with_examples}" = "efr32mg1" -o "${with_examples}" = "efr32mg12" -o "${with_examples}" = "efr32mg13" -o "${with_examples}" = "efr32mg21"])
case ${with_examples} in
no)
@@ -896,6 +897,7 @@ AM_CONDITIONAL([OPENTHREAD_PLATFORM_SAMR21], [test "${with_platform}" = "samr
AM_CONDITIONAL([OPENTHREAD_PLATFORM_SIMULATION],[test "${with_platform}" = "simulation"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF528XX], [test OPENTHREAD_PLATFORM_NRF52811 || test OPENTHREAD_PLATFORM_NRF52833 || test OPENTHREAD_PLATFORM_NRF52840])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32], [test "${with_platform}" = "efr32mg1" -o "${with_platform}" = "efr32mg12" -o "${with_platform}" = "efr32mg13" -o "${with_platform}" = "efr32mg21"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_K32W], [test OPENTHREAD_PLATFORM_K32W061 || test OPENTHREAD_PLATFORM_JN5189])
AM_COND_IF([OPENTHREAD_PLATFORM_POSIX], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX=0")
@@ -1039,19 +1041,10 @@ examples/platforms/cc1352/Makefile
examples/platforms/cc2538/Makefile
examples/platforms/cc2650/Makefile
examples/platforms/cc2652/Makefile
examples/platforms/efr32mg1/Makefile
examples/platforms/efr32mg12/Makefile
examples/platforms/efr32mg12/sleepy-demo/Makefile
examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/Makefile
examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-mtd/Makefile
examples/platforms/efr32mg13/Makefile
examples/platforms/efr32mg13/sleepy-demo/Makefile
examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/Makefile
examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/Makefile
examples/platforms/efr32mg21/Makefile
examples/platforms/efr32mg21/sleepy-demo/Makefile
examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/Makefile
examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/Makefile
examples/platforms/efr32/Makefile
examples/platforms/efr32/sleepy-demo/Makefile
examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile
examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile
examples/platforms/gp712/Makefile
examples/platforms/k32w/Makefile
examples/platforms/kw41z/Makefile
+22 -21
View File
@@ -39,14 +39,16 @@ NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
EFR32_PLATFORM = efr32mg1
PLATFORM_LOWERCASE = $(shell echo $(EFR32_PLATFORM) | tr A-Z a-z)
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
configure_OPTIONS = \
--enable-ncp \
--enable-radio-only \
--enable-linker-map \
--enable-builtin-mbedtls=no \
--with-examples=efr32mg1 \
configure_OPTIONS = \
--enable-ncp \
--enable-radio-only \
--enable-linker-map \
--enable-builtin-mbedtls=no \
--with-examples=$(EFR32_PLATFORM) \
MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \
$(NULL)
@@ -57,8 +59,6 @@ endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
# Needed for EFR32_MBEDTLS_CPPFLAGS
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
#
# Differentiate between boards
@@ -71,7 +71,8 @@ endif
EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls_config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg1/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/src
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include/mbedtls
@@ -82,12 +83,12 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/chip/efr32/efr32xg1x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/silicon_labs/silabs_core/memory_manager
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32mg1/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(BOARD_LOWERCASE)
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(EFR32_PLATFORM)/$(BOARD_LOWERCASE)
EFR32MG1_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32MG1_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32MG1_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
EFR32_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
COMMONCFLAGS := \
-fdata-sections \
@@ -97,7 +98,7 @@ COMMONCFLAGS := \
-I$(HAL_CONF_DIR) \
-D__START=main \
-D$(MCU) \
$(EFR32MG1_CONFIG_FILE_CPPFLAGS) \
$(EFR32_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
@@ -160,7 +161,7 @@ ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = efr32mg1
TargetTuple = $(PLATFORM_LOWERCASE)
ARCHS = cortex-m4
@@ -265,10 +266,10 @@ all: stage
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
+17 -16
View File
@@ -39,7 +39,9 @@ NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
EFR32_PLATFORM = efr32mg12
PLATFORM_LOWERCASE = $(shell echo $(EFR32_PLATFORM) | tr A-Z a-z)
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
configure_OPTIONS = \
--enable-cli \
@@ -49,7 +51,7 @@ configure_OPTIONS = \
--enable-radio-only \
--enable-linker-map \
--enable-builtin-mbedtls=no \
--with-examples=efr32mg12 \
--with-examples=$(EFR32_PLATFORM) \
MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \
$(NULL)
@@ -60,8 +62,6 @@ endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
# Needed for EFR32_MBEDTLS_CPPFLAGS
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
#
# Differentiate between boards
@@ -89,7 +89,8 @@ endif
endif
EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls_config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg12/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/src
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include/mbedtls
@@ -100,12 +101,12 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/chip/efr32/efr32xg1x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/silicon_labs/silabs_core/memory_manager
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32mg12/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(BOARD_LOWERCASE)
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(EFR32_PLATFORM)/$(BOARD_LOWERCASE)
EFR32MG12_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32MG12_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32MG12_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
EFR32_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
COMMONCFLAGS := \
-fdata-sections \
@@ -115,7 +116,7 @@ COMMONCFLAGS := \
-I$(HAL_CONF_DIR) \
-D__START=main \
-D$(MCU) \
$(EFR32MG12_CONFIG_FILE_CPPFLAGS) \
$(EFR32_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
@@ -178,7 +179,7 @@ ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = efr32mg12
TargetTuple = $(PLATFORM_LOWERCASE)
ARCHS = cortex-m4
@@ -283,10 +284,10 @@ all: stage
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
+17 -16
View File
@@ -39,7 +39,9 @@ NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
EFR32_PLATFORM = efr32mg13
PLATFORM_LOWERCASE = $(shell echo $(EFR32_PLATFORM) | tr A-Z a-z)
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
configure_OPTIONS = \
--enable-cli \
@@ -49,7 +51,7 @@ configure_OPTIONS = \
--enable-radio-only \
--enable-linker-map \
--enable-builtin-mbedtls=no \
--with-examples=efr32mg13 \
--with-examples=$(EFR32_PLATFORM) \
MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \
$(NULL)
@@ -60,8 +62,6 @@ endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
# Needed for EFR32_MBEDTLS_CPPFLAGS
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
#
# Differentiate between boards
@@ -75,7 +75,8 @@ endif
EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls_config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg13/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/src
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/efr32mg13/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include/mbedtls
@@ -86,12 +87,12 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/chip/efr32/efr32xg1x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/silicon_labs/silabs_core/memory_manager
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32mg13/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(BOARD_LOWERCASE)
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(EFR32_PLATFORM)/$(BOARD_LOWERCASE)
EFR32MG13_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32MG13_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32MG13_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
EFR32_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
COMMONCFLAGS := \
-fdata-sections \
@@ -101,7 +102,7 @@ COMMONCFLAGS := \
-I$(HAL_CONF_DIR) \
-D__START=main \
-D$(MCU) \
$(EFR32MG13_CONFIG_FILE_CPPFLAGS) \
$(EFR32_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
@@ -164,7 +165,7 @@ ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = efr32mg13
TargetTuple = $(PLATFORM_LOWERCASE)
ARCHS = cortex-m4
@@ -269,10 +270,10 @@ all: stage
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=softfp -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
+13 -12
View File
@@ -39,7 +39,9 @@ NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
EFR32_PLATFORM = efr32mg21
PLATFORM_LOWERCASE = $(shell echo $(EFR32_PLATFORM) | tr A-Z a-z)
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
configure_OPTIONS = \
--enable-cli \
@@ -49,7 +51,7 @@ configure_OPTIONS = \
--enable-radio-only \
--enable-linker-map \
--enable-builtin-mbedtls=no \
--with-examples=efr32mg21 \
--with-examples=$(EFR32_PLATFORM) \
MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \
$(NULL)
@@ -60,8 +62,6 @@ endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
# Needed for EFR32_MBEDTLS_CPPFLAGS
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
#
# Differentiate between boards
@@ -75,7 +75,8 @@ endif
EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls_config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg21/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/src
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.0/util/third_party/mbedtls/include/mbedtls
@@ -88,12 +89,12 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit
EFR32_MBEDTLS_CPPFLAGS += -Wno-unused-function
EFR32_MBEDTLS_CPPFLAGS += -Wno-unused-parameter
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32mg21/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(BOARD_LOWERCASE)
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(EFR32_PLATFORM)/$(BOARD_LOWERCASE)
EFR32MG21_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32MG21_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32MG21_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
EFR32_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
COMMONCFLAGS := \
-fdata-sections \
@@ -103,7 +104,7 @@ COMMONCFLAGS := \
-I$(HAL_CONF_DIR) \
-D__START=main \
-D$(MCU) \
$(EFR32MG21_CONFIG_FILE_CPPFLAGS) \
$(EFR32_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
@@ -166,7 +167,7 @@ ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = efr32mg21
TargetTuple = $(PLATFORM_LOWERCASE)
ARCHS = cortex-m33
+3 -18
View File
@@ -35,10 +35,7 @@ DIST_SUBDIRS = \
cc2538 \
cc2650 \
cc2652 \
efr32mg1 \
efr32mg12 \
efr32mg13 \
efr32mg21 \
efr32 \
gp712 \
k32w \
kw41z \
@@ -71,20 +68,8 @@ if OPENTHREAD_PLATFORM_CC2652
SUBDIRS += cc2652
endif
if OPENTHREAD_PLATFORM_EFR32MG1
SUBDIRS += efr32mg1
endif
if OPENTHREAD_PLATFORM_EFR32MG12
SUBDIRS += efr32mg12
endif
if OPENTHREAD_PLATFORM_EFR32MG13
SUBDIRS += efr32mg13
endif
if OPENTHREAD_PLATFORM_EFR32MG21
SUBDIRS += efr32mg21
if OPENTHREAD_PLATFORM_EFR32
SUBDIRS += efr32
endif
if OPENTHREAD_PLATFORM_GP712
+2 -14
View File
@@ -57,20 +57,8 @@ if OPENTHREAD_EXAMPLES_CC2652
include $(top_srcdir)/examples/platforms/cc2652/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG1
include $(top_srcdir)/examples/platforms/efr32mg1/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG12
include $(top_srcdir)/examples/platforms/efr32mg12/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG13
include $(top_srcdir)/examples/platforms/efr32mg13/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG21
include $(top_srcdir)/examples/platforms/efr32mg21/Makefile.platform.am
if OPENTHREAD_EXAMPLES_EFR32
include $(top_srcdir)/examples/platforms/efr32/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_GP712
+70
View File
@@ -0,0 +1,70 @@
#
# 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.
#
# Use automake includes since we cannot use SUBDIRS feature due to cleanup
# errors - few targets may use the same source file but dependency file is
# created only once which leads to errors when auto-generated Makefile tries
# to remove .Po files that were already removed
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = sleepy-demo
# Always build (e.g. for 'make all') these subdirectories.
SUBDIRS = $(NULL)
if OPENTHREAD_EXAMPLES_EFR32MG1
include efr32mg1/Makefile.am
# SUBDIRS = sleepy-demo
# NOTE: The sleepy-demo app currently does not fit on this platform.
#
# .../arm-none-eabi/bin/ld: sleepy-demo-mtd section `.bss' will not fit in region `RAM'
# .../arm-none-eabi/bin/ld: sleepy-demo-mtd section `.nvm' will not fit in region `FLASH'
# .../arm-none-eabi/bin/ld: region RAM overflowed with stack
# .../arm-none-eabi/bin/ld: region `FLASH' overflowed by 33428 bytes
# .../arm-none-eabi/bin/ld: region `RAM' overflowed by 4536 bytes
else # not OPENTHREAD_EXAMPLES_EFR32MG1
if OPENTHREAD_EXAMPLES_EFR32MG12
include efr32mg12/Makefile.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG13
include efr32mg13/Makefile.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG21
include efr32mg21/Makefile.am
endif
if OPENTHREAD_ENABLE_EXECUTABLE
SUBDIRS += sleepy-demo
endif
endif # OPENTHREAD_EXAMPLES_EFR32MG1
@@ -25,30 +25,12 @@
# 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
include $(top_srcdir)/examples/platforms/efr32/efr32_platform_defs.am
#
# efr32mg21 platform-specific Makefile
#
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
LIBRAIL = $(shell \
if [ "$(DMP)" = "1" ]; then \
echo "librail_multiprotocol_efr32xg21_gcc_release.a"; \
else \
echo "librail_efr32xg21_gcc_release.a"; \
fi )
LDADD_COMMON += \
$(top_builddir)/examples/platforms/efr32mg21/libopenthread-efr32mg21.a \
$(top_builddir)/third_party/silabs/libsilabs-efr32mg21-sdk.a \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/autogen/librail_release/$(LIBRAIL) \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a \
$(NULL)
# ==============================================================================
# Add mbedtls archive to LDADD_COMMON
# ==============================================================================
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
@@ -59,6 +41,42 @@ LDADD_COMMON +=
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/efr32mg21/efr32mg21.ld \
# ==============================================================================
# Linker flags
# ==============================================================================
RAIL_SUFFIX = $(shell echo $(PLATFORM_LOWERCASE)| tr mg xg)_gcc_release.a
LIBRAIL = $(shell \
if [ "$(DMP)" = "1" ]; then \
echo librail_multiprotocol_$(RAIL_SUFFIX); \
else \
echo librail_$(RAIL_SUFFIX); \
fi; )
LDADD_COMMON += \
$(top_builddir)/examples/platforms/efr32/libopenthread-$(PLATFORM_LOWERCASE).a \
$(top_builddir)/third_party/silabs/libsilabs-$(PLATFORM_LOWERCASE)-sdk.a \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/autogen/librail_release/$(LIBRAIL) \
$(NULL)
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(PLATFORM_LOWERCASE).ld \
$(NULL)
# ==============================================================================
# Platform includes
# ==============================================================================
if OPENTHREAD_EXAMPLES_EFR32MG1
include $(top_srcdir)/examples/platforms/efr32/efr32mg1/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG12
include $(top_srcdir)/examples/platforms/efr32/efr32mg12/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG13
include $(top_srcdir)/examples/platforms/efr32/efr32mg13/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG21
include $(top_srcdir)/examples/platforms/efr32/efr32mg21/Makefile.platform.am
endif
@@ -25,113 +25,141 @@
# 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-efr32mg21.a
# ==============================================================================
# General variables
# ==============================================================================
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
# Do not enable -Wconversion for rail
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
EFR32_PLATFORM = $(subst /,,$(exec_prefix))
# NOTE: This is a work-around that sets EFR32_PLATFORM to the correct platform name.
# Example:
# EFR32_PLATFORM = efr32mg12
# Do not enable -pedantic-errors for rail
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
PLATFORM_LOWERCASE = $(shell echo $(EFR32_PLATFORM) | tr A-Z a-z)
PLATFORM_UPPERCASE = $(shell echo $(EFR32_PLATFORM) | tr a-z A-Z)
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
$(top_builddir)/examples/platforms/efr32/libopenthread-$(PLATFORM_LOWERCASE).a:
echo MAKING examples/platforms/efr32/libopenthread-$(PLATFORM_LOWERCASE).a
(cd $(top_builddir)/examples/platforms/efr32/ && $(MAKE) $(AM_MAKEFLAGS) libopenthread-$(PLATFORM_LOWERCASE).a )
libopenthread_efr32mg21_a_CPPFLAGS = \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-Wno-sign-compare \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg21/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
# ==============================================================================
# filter-out flags for RAIL
# ==============================================================================
# Do not enable -Wconversion for rail and Silicon Labs SDK sources
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
# Do not enable -pedantic-errors for rail and Silicon Labs SDK sources
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for rail and Silicon Labs SDK sources
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
# ==============================================================================
# GSDK CPPFLAGS
# ==============================================================================
SILABS_GSDK_CPPFLAGS = \
-I$(SDK_SRC_DIR) \
-I$(SDK_SRC_DIR)/hardware/kit/$(PLATFORM_UPPERCASE)_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG21_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/base/hal/plugin/antenna/ \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG21/Include \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg2x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/service/device_init/inc \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/configs \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/include \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
alarm.c \
diag.c \
entropy.c \
fem-control.c \
flash.c \
logging.c \
misc.c \
openthread-core-efr32-config.h \
platform-efr32.h \
platform-band.h \
radio.c \
rail_config.h \
startup-gcc.c \
system.c \
uart.c \
# ==============================================================================
# Series-level CPPFLAGS
# ==============================================================================
SILABS_EFR32MG1X_CPPFLAGS = \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config/s1 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions/efr32xg1x/config \
$(NULL)
noinst_HEADERS = \
platform-efr32.h \
platform-band.h \
SILABS_EFR32MG2X_CPPFLAGS = \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config/s2 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg2x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions/efr32xg21/config \
$(NULL)
libopenthread_efr32mg21_a_SOURCES = \
$(PLATFORM_SOURCES) \
# ==============================================================================
# Platform-level CPPFLAGS
# ==============================================================================
PLATFORM_COMMON_SOURCES_LIST = \
src/alarm.c \
src/diag.c \
src/entropy.c \
src/fem-control.c \
src/flash.c \
src/logging.c \
src/misc.c \
src/openthread-core-efr32-config-check.h \
src/openthread-core-efr32-config.h \
src/platform-band.h \
src/platform-efr32.h \
src/radio.c \
src/rail_config.h \
src/startup-gcc.c \
src/system.c \
src/uart.c \
$(NULL)
Dash = -
libopenthread_efr32mg21_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
DIST_SUBDIRS = \
sleepy-demo \
SILABS_EFR32MG1_CPPFLAGS = \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG1P/Include \
$(SILABS_EFR32MG1X_CPPFLAGS) \
$(NULL)
SUBDIRS = \
sleepy-demo \
SILABS_EFR32MG12_CPPFLAGS = \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG12P/Include \
$(SILABS_EFR32MG1X_CPPFLAGS) \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
SILABS_EFR32MG13_CPPFLAGS = \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG13P/Include \
$(SILABS_EFR32MG1X_CPPFLAGS) \
$(NULL)
SILABS_EFR32MG21_CPPFLAGS = \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG21/Include \
$(SILABS_EFR32MG2X_CPPFLAGS) \
$(NULL)
@@ -0,0 +1,69 @@
#
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/efr32/efr32_platform_defs.am
lib_LIBRARIES = libopenthread-efr32mg1.a
libopenthread_efr32mg1_a_CPPFLAGS = \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
$(SILABS_EFR32MG1_CPPFLAGS) \
$(SILABS_GSDK_CPPFLAGS) \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
$(NULL)
noinst_HEADERS = \
src/platform-band.h \
src/platform-efr32.h \
$(NULL)
libopenthread_efr32mg1_a_SOURCES = \
$(PLATFORM_COMMON_SOURCES_LIST) \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_efr32mg1_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -26,22 +26,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
#
# efr32mg1 platform-specific Makefile
#
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = \
sleepy-demo-mtd \
sleepy-demo-ftd \
LDADD_COMMON += \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a \
$(NULL)
# Always build (e.g. for 'make all') these subdirectories.
SUBDIRS = \
$(NULL)
if OPENTHREAD_ENABLE_EXECUTABLE
SUBDIRS += sleepy-demo-mtd sleepy-demo-ftd
endif
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
/**
* @file
* This file includes dev borad compile-time configuration constants for efr32.
* This file includes dev board compile-time configuration constants for efr32.
*
*/
@@ -0,0 +1,69 @@
#
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/efr32/efr32_platform_defs.am
lib_LIBRARIES = libopenthread-efr32mg12.a
libopenthread_efr32mg12_a_CPPFLAGS = \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
$(SILABS_EFR32MG12_CPPFLAGS) \
$(SILABS_GSDK_CPPFLAGS) \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
$(NULL)
noinst_HEADERS = \
src/platform-band.h \
src/platform-efr32.h \
$(NULL)
libopenthread_efr32mg12_a_SOURCES = \
$(PLATFORM_COMMON_SOURCES_LIST) \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_efr32mg12_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -26,22 +26,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
#
# efr32mg12 platform-specific Makefile
#
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = \
sleepy-demo-mtd \
sleepy-demo-ftd \
LDADD_COMMON += \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a \
$(NULL)
# Always build (e.g. for 'make all') these subdirectories.
SUBDIRS = \
$(NULL)
if OPENTHREAD_ENABLE_EXECUTABLE
SUBDIRS += sleepy-demo-mtd sleepy-demo-ftd
endif
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
/**
* @file
* This file includes dev borad compile-time configuration constants for efr32.
* This file includes dev board compile-time configuration constants for efr32.
*
*/
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
/**
* @file
* This file includes dev borad compile-time configuration constants for efr32.
* This file includes dev board compile-time configuration constants for efr32.
*
*/
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
/**
* @file
* This file includes dev borad compile-time configuration constants for efr32.
* This file includes dev board compile-time configuration constants for efr32.
*
*/
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
/**
* @file
* This file includes dev borad compile-time configuration constants for efr32.
* This file includes dev board compile-time configuration constants for efr32.
*
*/
@@ -0,0 +1,69 @@
#
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/efr32/efr32_platform_defs.am
lib_LIBRARIES = libopenthread-efr32mg13.a
libopenthread_efr32mg13_a_CPPFLAGS = \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
$(SILABS_EFR32MG13_CPPFLAGS) \
$(SILABS_GSDK_CPPFLAGS) \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
$(NULL)
noinst_HEADERS = \
src/platform-band.h \
src/platform-efr32.h \
$(NULL)
libopenthread_efr32mg13_a_SOURCES = \
$(PLATFORM_COMMON_SOURCES_LIST) \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_efr32mg13_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -30,35 +30,6 @@
# efr32mg13 platform-specific Makefile
#
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
LIBRAIL = $(shell \
if [ "$(DMP)" = "1" ]; then \
echo "librail_multiprotocol_efr32xg13_gcc_release.a"; \
else \
echo "librail_efr32xg13_gcc_release.a"; \
fi )
LDADD_COMMON += \
$(top_builddir)/examples/platforms/efr32mg13/libopenthread-efr32mg13.a \
$(top_builddir)/third_party/silabs/libsilabs-efr32mg13-sdk.a \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/autogen/librail_release/$(LIBRAIL) \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
else
LDADD_COMMON += \
$(top_builddir)/third_party/silabs/libsilabs-mbedtls.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/efr32mg13/efr32mg13.ld \
$(NULL)
@@ -28,7 +28,7 @@
/**
* @file
* This file includes dev borad compile-time configuration constants for efr32.
* This file includes dev board compile-time configuration constants for efr32.
*
*/
@@ -0,0 +1,69 @@
#
# 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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/efr32/efr32_platform_defs.am
lib_LIBRARIES = libopenthread-efr32mg21.a
libopenthread_efr32mg21_a_CPPFLAGS = \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
$(SILABS_EFR32MG21_CPPFLAGS) \
$(SILABS_GSDK_CPPFLAGS) \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
$(NULL)
noinst_HEADERS = \
src/platform-band.h \
src/platform-efr32.h \
$(NULL)
libopenthread_efr32mg21_a_SOURCES = \
$(PLATFORM_COMMON_SOURCES_LIST) \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_efr32mg21_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -0,0 +1,35 @@
#
# 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.
#
#
# efr32mg21 platform-specific Makefile
#
LDADD_COMMON += \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a \
$(NULL)
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes dev board compile-time configuration constants for efr32.
*
*/
#ifndef __BOARD_CONFIG_H__
#define __BOARD_CONFIG_H__
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 /// Dev board suppports OQPSK modulation in 2.4GHz band.
#define RADIO_CONFIG_915MHZ_OQPSK_SUPPORT 0 /// Dev board doesn't support OQPSK modulation in 915MHz band.
#ifndef RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
#endif
#ifndef RADIO_CONFIG_DMP_SUPPORT
#define RADIO_CONFIG_DMP_SUPPORT 0 /// Set to 1 to enable Dynamic Multi-Protocol support in radio.c
#endif
#endif // __BOARD_CONFIG_H__
@@ -14,40 +14,43 @@
// $[ACMP1]
// [ACMP1]$
// $[ADC0]
// [ADC0]$
// $[ANTDIV]
// [ANTDIV]$
// $[BATTERYMON]
// [BATTERYMON]$
// $[BTL_BUTTON]
// [BTL_BUTTON]$
// $[BULBPWM]
// [BULBPWM]$
// $[BULBPWM_COLOR]
// [BULBPWM_COLOR]$
// $[BUTTON]
#define BSP_BUTTON_PRESENT (1)
#define BSP_BUTTON0_PIN (2U)
#define BSP_BUTTON0_PORT (gpioPortD)
#define BSP_BUTTON1_PIN (3U)
#define BSP_BUTTON1_PORT (gpioPortD)
#define BSP_BUTTON_COUNT (2U)
#define BSP_BUTTON_INIT \
{ \
{BSP_BUTTON0_PORT, BSP_BUTTON0_PIN}, { BSP_BUTTON1_PORT, BSP_BUTTON1_PIN } \
}
#define BSP_BUTTON_GPIO_DOUT (HAL_GPIO_DOUT_LOW)
#define BSP_BUTTON_GPIO_MODE (HAL_GPIO_MODE_INPUT)
// [BUTTON]$
// $[CMU]
#define HAL_CLK_HFCLK_SOURCE (HAL_CLK_HFCLK_SOURCE_HFXO)
#define BSP_CLK_LFXO_PRESENT (1)
#define HAL_CLK_EM4CLK_SOURCE (HAL_CLK_LFCLK_SOURCE_LFRCO)
#define HAL_CLK_EM23CLK_SOURCE (HAL_CLK_LFCLK_SOURCE_LFRCO)
#define BSP_CLK_HFXO_PRESENT (1)
#define BSP_CLK_LFXO_INIT CMU_LFXOINIT_DEFAULT
#define BSP_CLK_LFXO_CTUNE (79U)
#define HAL_CLK_EM4CLK_SOURCE (HAL_CLK_LFCLK_SOURCE_LFRCO)
#define HAL_CLK_RTCCCLK_SOURCE (HAL_CLK_LFCLK_SOURCE_LFRCO)
#define BSP_CLK_LFXO_FREQ (32768U)
#define BSP_CLK_HFXO_PRESENT (1)
#define BSP_CLK_HFXO_FREQ (38400000UL)
#define BSP_CLK_HFXO_CTUNE (129)
#define BSP_CLK_HFXO_INIT CMU_HFXOINIT_DEFAULT
#define BSP_CLK_HFXO_CTUNE (129)
#define BSP_CLK_LFXO_PRESENT (1)
#define BSP_CLK_LFXO_INIT CMU_LFXOINIT_DEFAULT
#define BSP_CLK_LFXO_FREQ (32768U)
#define BSP_CLK_LFXO_CTUNE (79U)
// [CMU]$
// $[COEX]
@@ -62,6 +65,9 @@
// $[EZRADIOPRO]
// [EZRADIOPRO]$
// $[FEM]
// [FEM]$
// $[GPIO]
#define PORTIO_GPIO_SWV_PIN (3U)
#define PORTIO_GPIO_SWV_PORT (gpioPortA)
@@ -95,17 +101,17 @@
#define BSP_LED1_PIN (1U)
#define BSP_LED1_PORT (gpioPortB)
#define HAL_LED_ENABLE \
{ \
0, 1 \
}
#define BSP_LED_POLARITY (1)
#define HAL_LED_COUNT (2U)
#define BSP_LED_COUNT (2U)
#define BSP_LED_INIT \
{ \
{BSP_LED0_PORT, BSP_LED0_PIN}, { BSP_LED1_PORT, BSP_LED1_PIN } \
}
#define HAL_LED_COUNT (2U)
#define HAL_LED_ENABLE \
{ \
0, 1 \
}
#define BSP_LED_POLARITY (1)
// [LED]$
// $[LETIMER0]
@@ -120,11 +126,11 @@
// $[PA]
#define HAL_PA_ENABLE (1)
#define HAL_PA_RAMP (10UL)
#define HAL_PA_SELECTION (HAL_PA_SELECTION_2P4_HP)
#define HAL_PA_POWER (252U)
#define HAL_PA_VOLTAGE (3300U)
#define HAL_PA_CURVE_HEADER "pa_curves_efr32.h"
#define HAL_PA_POWER (252U)
#define HAL_PA_RAMP (10UL)
#define BSP_PA_VOLTAGE (3300U)
#define HAL_PA_SELECTION (HAL_PA_SELECTION_2P4_HP)
// [PA]$
// $[PORTIO]
@@ -159,14 +165,15 @@
#define HAL_SERIAL_USART2_ENABLE (0)
#define HAL_SERIAL_USART3_ENABLE (0)
#define HAL_SERIAL_RXWAKE_ENABLE (0)
#define BSP_SERIAL_APP_CTS_PIN (4U)
#define BSP_SERIAL_APP_CTS_PORT (gpioPortA)
#define BSP_SERIAL_APP_TX_PIN (5U)
#define BSP_SERIAL_APP_TX_PORT (gpioPortA)
#define BSP_SERIAL_APP_RX_PIN (6U)
#define BSP_SERIAL_APP_RX_PORT (gpioPortA)
#define BSP_SERIAL_APP_TX_PIN (5U)
#define BSP_SERIAL_APP_TX_PORT (gpioPortA)
#define BSP_SERIAL_APP_CTS_PIN (4U)
#define BSP_SERIAL_APP_CTS_PORT (gpioPortA)
#define BSP_SERIAL_APP_RTS_PIN (1U)
#define BSP_SERIAL_APP_RTS_PORT (gpioPortC)
@@ -179,9 +186,6 @@
#define HAL_SERIAL_APP_FLOW_CONTROL (HAL_USART_FLOW_CONTROL_HWUART)
// [SERIAL]$
// $[SPIDISPLAY]
// [SPIDISPLAY]$
// $[SPINCP]
// [SPINCP]$
@@ -213,26 +217,26 @@
#define PORTIO_USART0_TX_PIN (5U)
#define PORTIO_USART0_TX_PORT (gpioPortA)
#define HAL_USART0_ENABLE (1)
#define BSP_USART0_TX_PIN (5U)
#define BSP_USART0_TX_PORT (gpioPortA)
#define BSP_USART0_CTS_PIN (4U)
#define BSP_USART0_CTS_PORT (gpioPortA)
#define HAL_USART0_ENABLE (1)
#define BSP_USART0_RX_PIN (6U)
#define BSP_USART0_RX_PORT (gpioPortA)
#define BSP_USART0_TX_PIN (5U)
#define BSP_USART0_TX_PORT (gpioPortA)
#define BSP_USART0_CTS_PIN (4U)
#define BSP_USART0_CTS_PORT (gpioPortA)
#define BSP_USART0_RTS_PIN (1U)
#define BSP_USART0_RTS_PORT (gpioPortC)
#define HAL_USART0_RX_QUEUE_SIZE (128UL)
#define HAL_USART0_BAUD_RATE (115200UL)
#define HAL_USART0_FLOW_CONTROL (HAL_USART_FLOW_CONTROL_HWUART)
#define HAL_USART0_RXSTOP (16UL)
#define HAL_USART0_RXSTART (16UL)
#define HAL_USART0_TX_QUEUE_SIZE (128UL)
#define HAL_USART0_FLOW_CONTROL (HAL_USART_FLOW_CONTROL_HWUART)
#define HAL_USART0_RX_QUEUE_SIZE (128UL)
// [USART0]$
// $[USART1]
@@ -26,13 +26,12 @@
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = \
sleepy-demo-mtd \
sleepy-demo-ftd \
DIST_SUBDIRS = \
sleepy-demo-mtd \
sleepy-demo-ftd \
$(NULL)
# Always build (e.g. for 'make all') these subdirectories.
@@ -41,7 +40,8 @@ SUBDIRS = \
$(NULL)
if OPENTHREAD_ENABLE_EXECUTABLE
SUBDIRS += sleepy-demo-mtd sleepy-demo-ftd
SUBDIRS += \
sleepy-demo-mtd \
sleepy-demo-ftd \
$(NULL)
endif
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,11 +1,13 @@
# EFR32MG12 Sleepy Demo Example
# EFR32 Sleepy Demo Example
The EFR32 Sleepy applications demonstrates Sleepy End Device behavior using the EFR32's low power EM2 mode. The steps below will take you through the process of building and running the demo
For setting up the build environment refer to [examples/platforms/efr32mg12/README.md](../README.md).
For setting up the build environment refer to [examples/platforms/efr32/README.md](../README.md).
## 1. Build
In this `README`, all example commands will be targeting the `efr32mg12` platform. The same commands should work for the other `efr32` platforms
```bash
$ cd <path-to-openthread>
$ ./bootstrap
@@ -22,7 +24,7 @@ $ arm-none-eabi-objcopy -O srec sleepy-demo-ftd sleepy-demo-ftd.s37
In Silicon Labs Simplicity Studio flash one device with the sleepy-demo-mtd.s37 image and the other device with the sleepy-demo-ftd.s37 image.
For instructions on flashing firmware see [examples/platforms/efr32mg12/README.md](../README.md#flash-binaries)
For instructions on flashing firmware, see [examples/platforms/efr32/README.md](../README.md#flash-binaries)
## 2. Starting nodes
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,14 +32,6 @@ include $(top_srcdir)/examples/platforms/Makefile.platform.am
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
$(top_builddir)/examples/platforms/efr32mg21/libopenthread-efr32mg21.a:
(cd $(top_builddir)/examples/platforms/efr32mg21/ && $(MAKE) $(AM_MAKEFLAGS) libopenthread-efr32mg21.a )
bin_PROGRAMS = \
$(NULL)
@@ -48,40 +40,13 @@ CPPFLAGS_COMMON +=
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-Wno-sign-compare \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg21/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG21_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG21/Include \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg2x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
$(SILABS_GSDK_CPPFLAGS) \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
@@ -99,21 +64,40 @@ SOURCES_COMMON +=
main.c \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
if OPENTHREAD_ENABLE_EXECUTABLE
bin_PROGRAMS += \
sleepy-demo-ftd \
$(NULL)
endif
sleepy_demo_ftd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
# NOTE: The order of the -I flags should always be in order from part-specific to general.
# This will make sure the correct header files are used for a part.
sleepy_demo_ftd_CPPFLAGS = $(NULL)
if OPENTHREAD_EXAMPLES_EFR32MG1
sleepy_demo_ftd_CPPFLAGS += \
$(SILABS_EFR32MG1_CPPFLAGS)
endif
if OPENTHREAD_EXAMPLES_EFR32MG12
sleepy_demo_ftd_CPPFLAGS += \
$(SILABS_EFR32MG12_CPPFLAGS)
endif
if OPENTHREAD_EXAMPLES_EFR32MG13
sleepy_demo_ftd_CPPFLAGS += \
$(SILABS_EFR32MG13_CPPFLAGS)
endif
if OPENTHREAD_EXAMPLES_EFR32MG21
sleepy_demo_ftd_CPPFLAGS += \
$(SILABS_EFR32MG21_CPPFLAGS)
endif
sleepy_demo_ftd_CPPFLAGS += $(CPPFLAGS_COMMON)
sleepy_demo_ftd_LDADD = \
$(top_builddir)/src/cli/libopenthread-cli-ftd.a \
@@ -227,7 +227,6 @@ void initUdp(void)
memset(&sockaddr, 0, sizeof(sockaddr));
otIp6AddressFromString(MULTICAST_ADDR, &sockaddr.mAddress);
sockaddr.mPort = MULTICAST_PORT;
error = otUdpOpen(instance, &sFtdSocket, sFtdReceiveCallback, NULL);
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,14 +32,6 @@ include $(top_srcdir)/examples/platforms/Makefile.platform.am
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
$(top_builddir)/examples/platforms/efr32mg21/libopenthread-efr32mg21.a:
(cd $(top_builddir)/examples/platforms/efr32mg21/ && $(MAKE) $(AM_MAKEFLAGS) libopenthread-efr32mg21.a )
bin_PROGRAMS = \
$(NULL)
@@ -48,40 +40,13 @@ CPPFLAGS_COMMON +=
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-Wno-sign-compare \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg21/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \
-I$(top_srcdir)/examples/platforms/efr32/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG21_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG21/Include \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg2x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
$(SILABS_GSDK_CPPFLAGS) \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
@@ -99,21 +64,39 @@ SOURCES_COMMON +=
main.c \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
if OPENTHREAD_ENABLE_EXECUTABLE
bin_PROGRAMS += \
sleepy-demo-mtd \
$(NULL)
endif
sleepy_demo_mtd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
# NOTE: The order of the -I flags should always be in order from part-specific to general.
# This will make sure the correct header files are used for a part.
sleepy_demo_mtd_CPPFLAGS = $(NULL)
if OPENTHREAD_EXAMPLES_EFR32MG1
sleepy_demo_mtd_CPPFLAGS += \
$(SILABS_EFR32MG1_CPPFLAGS)
endif
if OPENTHREAD_EXAMPLES_EFR32MG12
sleepy_demo_mtd_CPPFLAGS += \
$(SILABS_EFR32MG12_CPPFLAGS)
endif
if OPENTHREAD_EXAMPLES_EFR32MG13
sleepy_demo_mtd_CPPFLAGS += \
$(SILABS_EFR32MG13_CPPFLAGS)
endif
if OPENTHREAD_EXAMPLES_EFR32MG21
sleepy_demo_mtd_CPPFLAGS += \
$(SILABS_EFR32MG21_CPPFLAGS)
endif
sleepy_demo_mtd_CPPFLAGS += $(CPPFLAGS_COMMON)
sleepy_demo_mtd_LDADD = \
$(top_builddir)/src/cli/libopenthread-cli-mtd.a \
@@ -57,6 +57,8 @@ static bool sIsRunning = false;
static void AlarmCallback(sl_sleeptimer_timer_handle_t *aHandle, void *aData)
{
OT_UNUSED_VARIABLE(aHandle);
OT_UNUSED_VARIABLE(aData);
otSysEventSignalPending();
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1,9 +1,6 @@
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H
// Include the autogenerated mbedtls configuration file
#include "mbedtls_config_autogen.h"
// <<< Use Configuration Wizard in Context Menu >>>
// <h> TLS/DTLS configuration
@@ -50,6 +47,11 @@
// <i> Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0
// <q SL_MBEDTLS_HARDWARE_ACCELERATION_ENABLED> Enable hardware acceleration of crypto operations.
// <i> Default: 1
// <i> Enable hardware acceleration of crypto operations.
#define SL_MBEDTLS_HARDWARE_ACCELERATION_ENABLED 1
// </h>
// <<< end of configuration section >>>
@@ -72,6 +74,12 @@
#if SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
#endif
#if !SL_MBEDTLS_HARDWARE_ACCELERATION_ENABLED
#define NO_CRYPTO_ACCELERATION
#endif
// Include the autogenerated mbedtls configuration file
#include "mbedtls_config_autogen.h"
// Custom defines can be placed here before check_config.h is included.
#include "mbedtls/check_config.h"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,8 +57,9 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
otPlatResetReason reason;
otPlatResetReason reason = OT_PLAT_RESET_REASON_UNKNOWN;
#if defined(_EMU_RSTCAUSE_MASK)
if (sResetCause & EMU_RSTCAUSE_POR)
{
reason = OT_PLAT_RESET_REASON_POWER_ON;
@@ -85,11 +86,34 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
reason = OT_PLAT_RESET_REASON_ASSERT;
}
else
#endif
#if defined(_RMU_RSTCAUSE_MASK)
if (sResetCause & RMU_RSTCAUSE_PORST)
{
reason = OT_PLAT_RESET_REASON_UNKNOWN;
reason = OT_PLAT_RESET_REASON_POWER_ON;
}
else if (sResetCause & RMU_RSTCAUSE_SYSREQRST)
{
reason = OT_PLAT_RESET_REASON_SOFTWARE;
}
else if (sResetCause & RMU_RSTCAUSE_WDOGRST)
{
reason = OT_PLAT_RESET_REASON_WATCHDOG;
}
else if (sResetCause & RMU_RSTCAUSE_EXTRST)
{
reason = OT_PLAT_RESET_REASON_EXTERNAL;
}
else if (sResetCause & RMU_RSTCAUSE_LOCKUPRST)
{
reason = OT_PLAT_RESET_REASON_FAULT;
}
else if ((sResetCause & RMU_RSTCAUSE_AVDDBOD) || (sResetCause & RMU_RSTCAUSE_DECBOD) ||
(sResetCause & RMU_RSTCAUSE_DVDDBOD) || (sResetCause & RMU_RSTCAUSE_EM4RST))
{
reason = OT_PLAT_RESET_REASON_ASSERT;
}
#endif
return reason;
}
@@ -32,12 +32,12 @@
#include "board_config.h"
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#error "Platform efr32mg1 doesn't support configuration option: OPENTHREAD_CONFIG_TIME_SYNC_ENABLE"
#error "Platform doesn't support configuration option: OPENTHREAD_CONFIG_TIME_SYNC_ENABLE"
#endif
#ifndef RADIO_CONFIG_915MHZ_OQPSK_SUPPORT
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
#error "Platform efr32mg1 not configured to support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
#error "Platform not configured to support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
#endif
#endif
@@ -93,7 +93,7 @@
* Define to 1 if you want to enable software CSMA-CA backoff logic.
*
*/
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 0
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
@@ -109,7 +109,7 @@
* Define to 1 if you want to enable software energy scanning logic.
*
*/
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE 0
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
@@ -79,7 +79,7 @@ typedef struct efr32CommonConfig
{
RAIL_Config_t mRailConfig;
#if RADIO_CONFIG_DMP_SUPPORT
RAILSched_Config_t railSchedState;
RAILSched_Config_t mRailSchedState;
#endif
uint8_t
mRailTxFifo[RAIL_TX_FIFO_SIZE]; // must be 2 power between 64 and 4096, and bigger than OT_RADIO_FRAME_MAX_SIZE
@@ -40,7 +40,6 @@
#include "em_device.h"
#include "em_system.h"
#include "core_cm4.h"
#include "rail.h"
// Global OpenThread instance structure
@@ -95,12 +94,6 @@ void efr32UartProcess(void);
*/
void efr32MiscInit(void);
/**
* Initialization of ADC module for random number generator.
*
*/
void efr32RandomInit(void);
/**
* Initialization of Logger driver.
*
@@ -48,6 +48,7 @@
#include "utils/soft_source_match_table.h"
#include "antenna.h"
#include "board_config.h"
#include "em_cmu.h"
#include "em_core.h"
@@ -59,36 +60,27 @@
#include "rail_config.h"
#include "rail_ieee802154.h"
enum
{
IEEE802154_MIN_LENGTH = 5,
IEEE802154_MAX_LENGTH = 127,
IEEE802154_ACK_LENGTH = 5,
#define IEEE802154_MIN_LENGTH (5u)
#define IEEE802154_MAX_LENGTH (127u)
#define IEEE802154_ACK_LENGTH (5u)
// FCF + DSN + dest PANID + dest addr + src PANID + src addr (without security header)
IEEE802154_MAX_MHR_LENGTH = 2 + 1 + 2 + 8 + 2 + 8,
// FCF + DSN + dest PANID + dest addr + src PANID + src addr (without security header)
#define IEEE802154_MAX_MHR_LENGTH (2u + 1u + 2u + 8u + 2u + 8u)
IEEE802154_FRAME_TYPE_MASK = 0x7,
IEEE802154_FRAME_TYPE_ACK = 0x2,
IEEE802154_FRAME_TYPE_MAC_COMMAND = 0x3,
IEEE802154_ACK_REQUEST = 1 << 5,
IEEE802154_DSN_OFFSET = 2,
IEEE802154_FCF_OFFSET = 0,
};
#define IEEE802154_FRAME_TYPE_MASK (0x07u)
#define IEEE802154_FRAME_TYPE_ACK (0x02u)
#define IEEE802154_FRAME_TYPE_MAC_COMMAND (0x03u)
#define IEEE802154_ACK_REQUEST (1u << 5)
#define IEEE802154_DSN_OFFSET (2u)
#define IEEE802154_FCF_OFFSET (0u)
enum
{
EFR32_RECEIVE_SENSITIVITY = -100, // dBm
EFR32_RSSI_AVERAGING_TIME = 16, // us
EFR32_RSSI_AVERAGING_TIMEOUT = 300, // us
};
#define EFR32_RECEIVE_SENSITIVITY (-100) // dBm
#define EFR32_RSSI_AVERAGING_TIME (16u) // us
#define EFR32_RSSI_AVERAGING_TIMEOUT (300u) // us
enum
{
EFR32_SCHEDULER_SAMPLE_RSSI_PRIORITY = 10, // High priority
EFR32_SCHEDULER_TX_PRIORITY = 10, // High priority
EFR32_SCHEDULER_RX_PRIORITY = 20, // Low priority
};
#define EFR32_SCHEDULER_SAMPLE_RSSI_PRIORITY (10u) // High priority
#define EFR32_SCHEDULER_TX_PRIORITY (10u) // High priority
#define EFR32_SCHEDULER_RX_PRIORITY (20u) // Low priority
enum
{
@@ -163,7 +155,7 @@ static const RAIL_IEEE802154_Config_t sRailIeee802154Config = {
.ackConfig =
{
.enable = true,
.ackTimeout = 864,
.ackTimeout = 672,
.rxTransitions =
{
.success = RAIL_RF_STATE_RX,
@@ -184,17 +176,12 @@ static const RAIL_IEEE802154_Config_t sRailIeee802154Config = {
.rxSearchTimeout = 0,
.txToRxSearchTimeout = 0,
},
.framesMask = RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES,
.promiscuousMode = false,
.isPanCoordinator = false,
.framesMask = RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES,
.promiscuousMode = false,
.isPanCoordinator = false,
.defaultFramePendingInOutgoingAcks = false,
};
#if RADIO_CONFIG_PA_USES_DCDC
RAIL_DECLARE_TX_POWER_DCDC_CURVES(piecewiseSegments, curvesSg, curves24Hp, curves24Lp);
#else
RAIL_DECLARE_TX_POWER_VBAT_CURVES(piecewiseSegments, curvesSg, curves24Hp, curves24Lp);
#endif
static int8_t sTxPowerDbm = OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER;
static int8_t sCcaThresholdDbm = -75; // default -75dBm energy detect threshold
@@ -222,7 +209,7 @@ static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig)
RAIL_EVENT_RSSI_AVERAGE_DONE | //
RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | //
RAIL_EVENT_CAL_NEEDED | //
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT || RADIO_CONFIG_DMP_SUPPORT
RAIL_EVENT_CONFIG_SCHEDULED | //
RAIL_EVENT_CONFIG_UNSCHEDULED | //
#endif
@@ -230,20 +217,18 @@ static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig)
);
assert(status == RAIL_STATUS_NO_ERROR);
uint16_t actualLenth = RAIL_SetTxFifo(handle, aCommonConfig->mRailTxFifo, 0, sizeof(aCommonConfig->mRailTxFifo));
assert(actualLenth == sizeof(aCommonConfig->mRailTxFifo));
uint16_t actualLength = RAIL_SetTxFifo(handle, aCommonConfig->mRailTxFifo, 0, sizeof(aCommonConfig->mRailTxFifo));
assert(actualLength == sizeof(aCommonConfig->mRailTxFifo));
return handle;
}
static void efr32RailConfigLoad(efr32BandConfig *aBandConfig)
{
RAIL_Status_t status;
#if HAL_PA_2P4_LOWPOWER == 1
RAIL_TxPowerConfig_t txPowerConfig = {RAIL_TX_POWER_MODE_2P4_LP, HAL_PA_VOLTAGE, 10};
#else
RAIL_TxPowerConfig_t txPowerConfig = {RAIL_TX_POWER_MODE_2P4_HP, HAL_PA_VOLTAGE, 10};
#endif
RAIL_Status_t status;
RAIL_TxPowerConfig_t txPowerConfig = {SL_RAIL_UTIL_PA_SELECTION_2P4GHZ, SL_RAIL_UTIL_PA_VOLTAGE_MV, 10};
#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT
if (aBandConfig->mChannelConfig != NULL)
{
uint16_t firstChannel = RAIL_ConfigChannels(gRailHandle, aBandConfig->mChannelConfig, NULL);
@@ -252,21 +237,20 @@ static void efr32RailConfigLoad(efr32BandConfig *aBandConfig)
txPowerConfig.mode = RAIL_TX_POWER_MODE_SUBGIG;
}
else
#endif // RADIO_CONFIG_915MHZ_OQPSK_SUPPORT
{
status = RAIL_IEEE802154_Config2p4GHzRadio(gRailHandle);
assert(status == RAIL_STATUS_NO_ERROR);
}
status = RAIL_ConfigTxPower(gRailHandle, &txPowerConfig);
assert(status == RAIL_STATUS_NO_ERROR);
}
static void efr32RadioSetTxPower(int8_t aPowerDbm)
{
RAIL_Status_t status;
RAIL_TxPowerCurvesConfig_t txPowerCurvesConfig = {curves24Hp, curvesSg, curves24Lp, piecewiseSegments};
status = RAIL_InitTxPowerCurves(&txPowerCurvesConfig);
assert(status == RAIL_STATUS_NO_ERROR);
RAIL_Status_t status;
sl_rail_util_pa_init();
status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPowerDbm) * 10);
assert(status == RAIL_STATUS_NO_ERROR);
@@ -293,7 +277,7 @@ static void efr32ConfigInit(void (*aEventCallback)(RAIL_Handle_t railHandle, RAI
sCommonConfig.mRailConfig.eventsCallback = aEventCallback;
sCommonConfig.mRailConfig.protocol = NULL; // only used by Bluetooth stack
#if RADIO_CONFIG_DMP_SUPPORT
sCommonConfig.mRailConfig.scheduler = &(sCommonConfig.railSchedState);
sCommonConfig.mRailConfig.scheduler = &(sCommonConfig.mRailSchedState);
#else
sCommonConfig.mRailConfig.scheduler = NULL; // only needed for DMP
#endif
@@ -335,8 +319,6 @@ void efr32RadioInit(void)
efr32ConfigInit(RAILCb_Generic);
CMU_ClockEnable(cmuClock_PRS, true);
status = RAIL_ConfigSleep(gRailHandle, RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED);
assert(status == RAIL_STATUS_NO_ERROR);
@@ -501,6 +483,7 @@ otError otPlatRadioSleep(otInstance *aInstance)
otLogInfoPlat("State=OT_RADIO_STATE_SLEEP", NULL);
RAIL_Idle(gRailHandle, RAIL_IDLE, true);
RAIL_YieldRadio(gRailHandle);
sState = OT_RADIO_STATE_SLEEP;
exit:
@@ -606,11 +589,11 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
// 4B preamble, 1B SFD, 1B PHR is not counted in frameLength
if (RAIL_GetBitRate(gRailHandle) > 0)
{
txSchedulerInfo.transactionTime = (frameLength + 4 + 1 + 1) * 8 * 1e6 / RAIL_GetBitRate(gRailHandle);
txSchedulerInfo.transactionTime += (frameLength + 4 + 1 + 1) * 8 * 1e6 / RAIL_GetBitRate(gRailHandle);
}
else
{ // assume 250kbps
txSchedulerInfo.transactionTime = (frameLength + 4 + 1 + 1) * RADIO_TIMING_DEFAULT_BYTETIME_US;
txSchedulerInfo.transactionTime += (frameLength + 4 + 1 + 1) * RADIO_TIMING_DEFAULT_BYTETIME_US;
}
#endif
@@ -642,6 +625,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailTxStartFailed++;
#endif
// Tx started at an invalid time or an invalid paramter has been passed.
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
sTransmitBusy = false;
otSysEventSignalPending();
@@ -795,6 +779,7 @@ static void processNextRxPacket(otInstance *aInstance)
RAIL_RxPacketDetails_t packetDetails;
RAIL_Status_t status;
uint16_t length;
bool framePending = false;
packetHandle = RAIL_GetRxPacketInfo(gRailHandle, RAIL_RX_PACKET_HANDLE_OLDEST, &packetInfo);
@@ -808,15 +793,15 @@ static void processNextRxPacket(otInstance *aInstance)
length = packetInfo.packetBytes + 1;
// check the length in recv packet info structure; RAIL should take care of this.
assert(length == packetInfo.firstPortionData[0]);
otEXPECT(length == packetInfo.firstPortionData[0]);
// check the length validity of recv packet; RAIL should take care of this.
assert(length >= IEEE802154_MIN_LENGTH && length <= IEEE802154_MAX_LENGTH);
otEXPECT(length >= IEEE802154_MIN_LENGTH && length <= IEEE802154_MAX_LENGTH);
otLogInfoPlat("Received data:%d", length);
// skip length byte
assert(packetInfo.firstPortionBytes > 0);
otEXPECT(packetInfo.firstPortionBytes > 0);
packetInfo.firstPortionData++;
packetInfo.firstPortionBytes--;
packetInfo.packetBytes--;
@@ -834,8 +819,8 @@ static void processNextRxPacket(otInstance *aInstance)
if (packetDetails.isAck)
{
assert((length == IEEE802154_ACK_LENGTH) &&
(sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_ACK);
otEXPECT((length == IEEE802154_ACK_LENGTH) &&
(sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_ACK);
RAIL_YieldRadio(gRailHandle);
sTransmitBusy = false;
@@ -869,8 +854,8 @@ static void processNextRxPacket(otInstance *aInstance)
sReceiveFrame.mInfo.mRxInfo.mTimestamp = packetDetails.timeReceived.packetTime;
// Set this flag only when the packet is really acknowledged with frame pending set.
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending =
wasAckedWithFramePending(sReceiveFrame.mPsdu, sReceiveFrame.mLength);
framePending = wasAckedWithFramePending(sReceiveFrame.mPsdu, sReceiveFrame.mLength);
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = framePending;
#if OPENTHREAD_CONFIG_DIAG_ENABLE
@@ -887,8 +872,11 @@ static void processNextRxPacket(otInstance *aInstance)
sRailDebugCounters.mRailPlatRadioReceiveDoneCbCount++;
#endif
}
if (!framePending)
{
RAIL_YieldRadio(gRailHandle);
}
}
otSysEventSignalPending();
exit:
@@ -50,6 +50,7 @@
#include "em_chip.h"
#include "em_cmu.h"
#include "em_core.h"
#include "em_device.h"
#include "em_emu.h"
#include "em_system.h"
#include "hal-config.h"
@@ -57,6 +58,10 @@
#include "rail.h"
#include "sl_mpu.h"
#include "sl_sleeptimer.h"
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
#include "sl_malloc.h"
#include "openthread/heap.h"
#endif
#include "platform-efr32.h"
@@ -156,7 +161,6 @@ static void halInitChipSpecific(void)
otInstance *sInstance;
static bool (*sCanSleepCallback)(void);
static void (*sDeviceOutOfSleepCb)(void);
void otSysInit(int argc, char *argv[])
{
@@ -166,6 +170,9 @@ void otSysInit(int argc, char *argv[])
__disable_irq();
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
otHeapSetCAllocFree(sl_calloc, sl_free);
#endif
#undef FIXED_EXCEPTION
#define FIXED_EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler)
#define EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler, priorityLevel, subpriority) \
@@ -178,8 +185,11 @@ void otSysInit(int argc, char *argv[])
halInitChipSpecific();
BSP_Init(BSP_INIT_BCC);
// Enable LE peripheral clock. Needed for RTCC initialization in sl_sleeptimer_init()
#if !defined(_SILICON_LABS_32B_SERIES_2)
CMU_ClockEnable(cmuClock_HFLE, true);
CMU_OscillatorEnable(cmuOsc_LFRCO, true, true);
CMU_ClockEnable(cmuClock_RTCC, true);
#endif // !defined(_SILICON_LABS_32B_SERIES_2)
status = sl_sleeptimer_init();
assert(status == SL_STATUS_OK);
@@ -213,10 +223,9 @@ void otSysDeinit(void)
#endif
}
void efr32SetSleepCallback(bool (*aCallback)(void), void (*aCallbackWake)(void))
void efr32SetSleepCallback(bool (*aCallback)(void))
{
sCanSleepCallback = aCallback;
sDeviceOutOfSleepCb = aCallbackWake;
sCanSleepCallback = aCallback;
}
void efr32Sleep(void)
@@ -240,11 +249,6 @@ void efr32Sleep(void)
while (RAIL_Wake(0) != RAIL_STATUS_NO_ERROR)
{
}
if (sDeviceOutOfSleepCb != NULL)
{
sDeviceOutOfSleepCb();
}
}
else
{
@@ -49,30 +49,44 @@ enum
kReceiveFifoSize = 128,
};
#define USART_INIT \
{ \
USART0, /* USART port */ \
115200, /* Baud rate */ \
BSP_SERIAL_APP_TX_LOC, /* USART Tx pin location number */ \
BSP_SERIAL_APP_RX_LOC, /* USART Rx pin location number */ \
(USART_Stopbits_TypeDef)USART_FRAME_STOPBITS_ONE, /* Stop bits */ \
(USART_Parity_TypeDef)USART_FRAME_PARITY_NONE, /* Parity */ \
(USART_OVS_TypeDef)USART_CTRL_OVS_X16, /* Oversampling mode*/ \
false, /* Majority vote disable */ \
HAL_SERIAL_APP_FLOW_CONTROL, /* Flow control */ \
BSP_SERIAL_APP_CTS_PORT, /* CTS port number */ \
BSP_SERIAL_APP_CTS_PIN, /* CTS pin number */ \
BSP_SERIAL_APP_RTS_PORT, /* RTS port number */ \
BSP_SERIAL_APP_RTS_PIN, /* RTS pin number */ \
(UARTDRV_Buffer_FifoQueue_t *)&sUartRxQueue, /* RX operation queue */ \
(UARTDRV_Buffer_FifoQueue_t *)&sUartTxQueue, /* TX operation queue */ \
BSP_SERIAL_APP_CTS_LOC, /* CTS location */ \
BSP_SERIAL_APP_RTS_LOC /* RTS location */ \
}
DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_RX_BUFS, sUartRxQueue);
DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_TX_BUFS, sUartTxQueue);
static const UARTDRV_InitUart_t USART_INIT = {
.port = USART0, /* USART port */
.baudRate = HAL_SERIAL_APP_BAUD_RATE, /* Baud rate */
#if defined(_USART_ROUTELOC0_MASK)
.portLocationTx = BSP_SERIAL_APP_TX_LOC, /* USART Tx pin location number */
.portLocationRx = BSP_SERIAL_APP_RX_LOC, /* USART Rx pin location number */
#elif defined(_USART_ROUTE_MASK)
#error This configuration is not supported
// .portLocation = NULL;
#elif defined(_GPIO_USART_ROUTEEN_MASK)
.txPort = BSP_SERIAL_APP_TX_PORT, /* USART Tx port number */
.rxPort = BSP_SERIAL_APP_RX_PORT, /* USART Rx port number */
.txPin = BSP_SERIAL_APP_TX_PIN, /* USART Tx pin number */
.rxPin = BSP_SERIAL_APP_RX_PIN, /* USART Rx pin number */
.uartNum = 0, /* UART instance number */
#endif
.stopBits = (USART_Stopbits_TypeDef)USART_FRAME_STOPBITS_ONE, /* Stop bits */
.parity = (USART_Parity_TypeDef)USART_FRAME_PARITY_NONE, /* Parity */
.oversampling = (USART_OVS_TypeDef)USART_CTRL_OVS_X16, /* Oversampling mode*/
#if defined(USART_CTRL_MVDIS)
.mvdis = false, /* Majority vote disable */
#endif // USART_CTRL_MVDIS
.fcType = HAL_SERIAL_APP_FLOW_CONTROL, /* Flow control */
.ctsPort = BSP_SERIAL_APP_CTS_PORT, /* CTS port number */
.ctsPin = BSP_SERIAL_APP_CTS_PIN, /* CTS pin number */
.rtsPort = BSP_SERIAL_APP_RTS_PORT, /* RTS port number */
.rtsPin = BSP_SERIAL_APP_RTS_PIN, /* RTS pin number */
.rxQueue = (UARTDRV_Buffer_FifoQueue_t *)&sUartRxQueue, /* RX operation queue */
.txQueue = (UARTDRV_Buffer_FifoQueue_t *)&sUartTxQueue, /* TX operation queue */
#if defined(_USART_ROUTELOC1_MASK)
.portLocationCts = BSP_SERIAL_APP_CTS_LOC, /* CTS location */
.portLocationRts = BSP_SERIAL_APP_RTS_LOC /* RTS location */
#endif // _USART_ROUTELOC1_MASK
};
static UARTDRV_HandleData_t sUartHandleData;
static UARTDRV_Handle_t sUartHandle = &sUartHandleData;
static uint8_t sReceiveBuffer[2];
@@ -108,6 +122,11 @@ static void receiveDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aDat
static void transmitDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aData, UARTDRV_Count_t aCount)
{
OT_UNUSED_VARIABLE(aHandle);
OT_UNUSED_VARIABLE(aStatus);
OT_UNUSED_VARIABLE(aData);
OT_UNUSED_VARIABLE(aCount);
sTransmitLength = 0;
otSysEventSignalPending();
}
@@ -152,7 +171,7 @@ static void processTransmit(void)
otError otPlatUartEnable(void)
{
UARTDRV_Init_t uartInit = USART_INIT;
UARTDRV_InitUart_t uartInit = USART_INIT;
sReceiveFifo.mHead = 0;
sReceiveFifo.mTail = 0;
-141
View File
@@ -1,141 +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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = libopenthread-efr32mg1.a
# Do not enable -Wconversion for rail
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
# Do not enable -pedantic-errors for rail
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
libopenthread_efr32mg1_a_CPPFLAGS = \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-DCORTEXM3 \
-DPHY=EMBER_PHY_RAIL \
-DMICRO=EMBER_MICRO_CORTEXM3_EFR32 \
-DCORTEXM3_EFM32_MICRO \
-DPLAT=EMBER_PLATFORM_CORTEXM3 \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg1/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
-I$(SDK_SRC_DIR) \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG1_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/bootloader/api \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG1P/Include \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
alarm.c \
diag.c \
entropy.c \
fem-control.c \
flash.c \
logging.c \
misc.c \
openthread-core-efr32-config.h \
openthread-core-efr32-config-check.h \
platform-efr32.h \
platform-band.h \
radio.c \
rail_config.h \
startup-gcc.c \
system.c \
uart.c \
$(NULL)
noinst_HEADERS = \
platform-efr32.h \
platform-band.h \
$(NULL)
libopenthread_efr32mg1_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_efr32mg1_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
DIST_SUBDIRS = \
$(NULL)
SUBDIRS = \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,64 +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.
#
#
# efr32mg1 platform-specific Makefile
#
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
LIBRAIL = $(shell \
if [ "$(DMP)" = "1" ]; then \
echo "librail_multiprotocol_efr32xg1_gcc_release.a"; \
else \
echo "librail_efr32xg1_gcc_release.a"; \
fi )
LDADD_COMMON += \
$(top_builddir)/examples/platforms/efr32mg1/libopenthread-efr32mg1.a \
$(top_builddir)/third_party/silabs/libsilabs-efr32mg1-sdk.a \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/autogen/librail_release/$(LIBRAIL) \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
else
LDADD_COMMON += \
$(top_builddir)/third_party/silabs/libsilabs-mbedtls.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/efr32mg1/efr32mg1.ld \
$(NULL)
-145
View File
@@ -1,145 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for the alarm.
*
*/
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include "openthread-system.h"
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include "common/logging.hpp"
#include "platform-efr32.h"
#include "utils/code_utils.h"
#include "em_core.h"
#include "rail.h"
#include "sl_sleeptimer.h"
#define XTAL_ACCURACY 200
static sl_sleeptimer_timer_handle_t sl_handle;
static uint32_t sAlarm = 0;
static bool sIsRunning = false;
static void AlarmCallback(sl_sleeptimer_timer_handle_t *aHandle, void *aData)
{
otSysEventSignalPending();
}
void efr32AlarmInit(void)
{
memset(&sl_handle, 0, sizeof sl_handle);
}
uint32_t otPlatAlarmMilliGetNow(void)
{
uint64_t ticks;
uint64_t now;
sl_status_t status;
ticks = sl_sleeptimer_get_tick_count64();
status = sl_sleeptimer_tick64_to_ms(ticks, &now);
assert(status == SL_STATUS_OK);
return (uint32_t)now;
}
uint32_t otPlatTimeGetXtalAccuracy(void)
{
return XTAL_ACCURACY;
}
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
OT_UNUSED_VARIABLE(aInstance);
sl_status_t status;
int32_t remaining;
uint32_t ticks;
sl_sleeptimer_stop_timer(&sl_handle);
sAlarm = aT0 + aDt;
remaining = (int32_t)(sAlarm - otPlatAlarmMilliGetNow());
sIsRunning = true;
if (remaining <= 0)
{
otSysEventSignalPending();
}
else
{
status = sl_sleeptimer_ms32_to_tick(remaining, &ticks);
assert(status == SL_STATUS_OK);
status = sl_sleeptimer_start_timer(&sl_handle, ticks, AlarmCallback, NULL, 0,
SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG);
assert(status == SL_STATUS_OK);
}
}
void otPlatAlarmMilliStop(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
sl_sleeptimer_stop_timer(&sl_handle);
sIsRunning = false;
}
void efr32AlarmProcess(otInstance *aInstance)
{
int32_t remaining;
if (sIsRunning)
{
remaining = (int32_t)(sAlarm - otPlatAlarmMilliGetNow());
if (remaining <= 0)
{
sIsRunning = false;
#if OPENTHREAD_CONFIG_DIAG_ENABLE
if (otPlatDiagModeGet())
{
otPlatDiagAlarmFired(aInstance);
}
else
#endif
{
otPlatAlarmMilliFired(aInstance);
}
}
}
}
-109
View File
@@ -1,109 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements an entropy source based on ADC.
*
*/
#include <openthread/platform/entropy.h>
#include "utils/code_utils.h"
#include "em_adc.h"
#include "em_cmu.h"
enum
{
EFR32_ADC_REF_CLOCK = 7000000,
};
void efr32RandomInit(void)
{
/* Enable ADC Clock */
CMU_ClockEnable(cmuClock_ADC0, true);
ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
/* Initialize the ADC with the required values */
init.timebase = ADC_TimebaseCalc(0);
init.prescale = ADC_PrescaleCalc(EFR32_ADC_REF_CLOCK, 0);
ADC_Init(ADC0, &init);
/* Initialize for single conversion specific to RNG */
singleInit.reference = adcRefVEntropy;
singleInit.diff = true;
singleInit.posSel = adcPosSelVSS;
singleInit.negSel = adcNegSelVSS;
ADC_InitSingle(ADC0, &singleInit);
/* Set VINATT to maximum value and clear FIFO */
ADC0->SINGLECTRLX |= _ADC_SINGLECTRLX_VINATT_MASK;
ADC0->SINGLEFIFOCLEAR = ADC_SINGLEFIFOCLEAR_SINGLEFIFOCLEAR;
}
static uint32_t randomUint32Get(void)
{
uint8_t tmp;
uint32_t random = 0;
for (int i = 0; i < 4; i++)
{
tmp = 0;
for (int j = 0; j < 3; j++)
{
ADC_Start(ADC0, adcStartSingle);
while ((ADC0->IF & ADC_IF_SINGLE) == 0)
;
tmp |= ((ADC_DataSingleGet(ADC0) & 0x07) << (j * 3));
}
random |= (tmp & 0xff) << (i * 8);
}
return random;
}
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
for (uint16_t length = 0; length < aOutputLength; length++)
{
aOutput[length] = (uint8_t)randomUint32Get();
}
exit:
return error;
}
-98
View File
@@ -1,98 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for miscellaneous behaviors.
*/
#include <openthread/platform/misc.h>
#include "em_rmu.h"
#include "platform-efr32.h"
static uint32_t sResetCause;
void efr32MiscInit(void)
{
// Read the cause of last reset.
sResetCause = RMU_ResetCauseGet();
// Clear the register, as the causes cumulate over resets.
RMU_ResetCauseClear();
}
void otPlatReset(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
NVIC_SystemReset();
}
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
otPlatResetReason reason;
if (sResetCause & RMU_RSTCAUSE_PORST)
{
reason = OT_PLAT_RESET_REASON_POWER_ON;
}
else if (sResetCause & RMU_RSTCAUSE_SYSREQRST)
{
reason = OT_PLAT_RESET_REASON_SOFTWARE;
}
else if (sResetCause & RMU_RSTCAUSE_WDOGRST)
{
reason = OT_PLAT_RESET_REASON_WATCHDOG;
}
else if (sResetCause & RMU_RSTCAUSE_EXTRST)
{
reason = OT_PLAT_RESET_REASON_EXTERNAL;
}
else if (sResetCause & RMU_RSTCAUSE_LOCKUPRST)
{
reason = OT_PLAT_RESET_REASON_FAULT;
}
else if ((sResetCause & RMU_RSTCAUSE_AVDDBOD) || (sResetCause & RMU_RSTCAUSE_DECBOD) ||
(sResetCause & RMU_RSTCAUSE_DVDDBOD) || (sResetCause & RMU_RSTCAUSE_EM4RST))
{
reason = OT_PLAT_RESET_REASON_ASSERT;
}
else
{
reason = OT_PLAT_RESET_REASON_UNKNOWN;
}
return reason;
}
void otPlatWakeHost(void)
{
// TODO: implement an operation to wake the host from sleep state.
}
@@ -1,95 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file defines the frequency band configuration structure for efr32.
*
*/
#ifndef PLATFORM_BAND_H_
#define PLATFORM_BAND_H_
#include <openthread/platform/radio.h>
#include "rail.h"
#include "rail_config.h"
#include "rail_ieee802154.h"
#define RAIL_TX_FIFO_SIZE (OT_RADIO_FRAME_MAX_SIZE + 1)
#define RADIO_SCHEDULER_BACKGROUND_RX_PRIORITY 255
#define RADIO_SCHEDULER_CHANNEL_SCAN_PRIORITY 255
#define RADIO_SCHEDULER_CHANNEL_SLIP_TIME 500000UL
#define RADIO_SCHEDULER_TX_PRIORITY 100
#define RADIO_SCHEDULER_TX_SLIP_TIME 500000UL
#define RADIO_TIMING_CSMA_OVERHEAD_US 500
#define RADIO_TIMING_DEFAULT_BYTETIME_US 32 // only used if RAIL_GetBitRate returns 0
#define RADIO_TIMING_DEFAULT_SYMBOLTIME_US 16 // only used if RAIL_GetSymbolRate returns 0
typedef struct efr32RadioCounters
{
uint64_t mRailPlatTxTriggered;
uint64_t mRailPlatRadioReceiveDoneCbCount;
uint64_t mRailPlatRadioEnergyScanDoneCbCount;
uint64_t mRailPlatRadioTxDoneCbCount;
uint64_t mRailTxStarted;
uint64_t mRailTxStartFailed;
uint64_t mRailEventConfigScheduled;
uint64_t mRailEventConfigUnScheduled;
uint64_t mRailEventPacketSent;
uint64_t mRailEventChannelBusy;
uint64_t mRailEventEnergyScanCompleted;
uint64_t mRailEventCalNeeded;
uint64_t mRailEventPacketReceived;
uint64_t mRailEventNoAck;
uint64_t mRailEventTxAbort;
uint64_t mRailEventSchedulerStatusError;
uint64_t mRailEventsSchedulerStatusTransmitBusy;
uint32_t mRailEventsSchedulerStatusLastStatus;
} efr32RadioCounters;
typedef struct efr32CommonConfig
{
RAIL_Config_t mRailConfig;
#if RADIO_CONFIG_DMP_SUPPORT
RAILSched_Config_t railSchedState;
#endif
uint8_t
mRailTxFifo[RAIL_TX_FIFO_SIZE]; // must be 2 power between 64 and 4096, and bigger than OT_RADIO_FRAME_MAX_SIZE
} efr32CommonConfig;
typedef struct efr32BandConfig
{
const RAIL_ChannelConfig_t *mChannelConfig;
uint8_t mChannelMin;
uint8_t mChannelMax;
} efr32BandConfig;
#endif // PLATFORM_BAND_H_
-269
View File
@@ -1,269 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file includes the platform-specific initializers.
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <string.h>
#include "openthread-system.h"
#include <openthread/platform/uart.h>
#include "common/logging.hpp"
#include "bsp.h"
#include "bsp_init.h"
#include "dmadrv.h"
#include "ecode.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_core.h"
#include "em_emu.h"
#include "em_system.h"
#include "hal-config.h"
#include "hal_common.h"
#include "rail.h"
#include "sl_mpu.h"
#include "sl_sleeptimer.h"
#include "platform-efr32.h"
#if (HAL_FEM_ENABLE)
#include "fem-control.h"
#endif
#define USE_EFR32_LOG (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
void initAntenna(void);
static void boardDisableSpiFlash(void)
{
#if defined(BSP_EXTFLASH_USART) && !defined(HAL_DISABLE_EXTFLASH)
#include "mx25flash_spi.h"
MX25_init();
MX25_DP();
#endif
}
static void boardLowPowerInit(void)
{
boardDisableSpiFlash();
}
static void halInitChipSpecific(void)
{
#if defined(BSP_DK) && !defined(RAIL_IC_SIM_BUILD)
BSP_Init(BSP_INIT_DK_SPI);
#endif
BSP_initDevice();
#if !defined(RAIL_IC_SIM_BUILD)
BSP_initBoard();
#endif
#if HAL_PTI_ENABLE
RAIL_PtiConfig_t railPtiConfig = {
#if HAL_PTI_MODE == HAL_PTI_MODE_SPI
.mode = RAIL_PTI_MODE_SPI,
#elif HAL_PTI_MODE == HAL_PTI_MODE_UART
.mode = RAIL_PTI_MODE_UART,
#elif HAL_PTI_MODE == HAL_PTI_MODE_UART_ONEWIRE
.mode = RAIL_PTI_MODE_UART_ONEWIRE,
#else
.mode = RAIL_PTI_MODE_DISABLED,
#endif
.baud = HAL_PTI_BAUD_RATE,
#ifdef BSP_PTI_DOUT_LOC
.doutLoc = BSP_PTI_DOUT_LOC,
#endif
.doutPort = (uint8_t)BSP_PTI_DOUT_PORT,
.doutPin = BSP_PTI_DOUT_PIN,
#if HAL_PTI_MODE == HAL_PTI_MODE_SPI
#ifdef BSP_PTI_DCLK_LOC
.dclkLoc = BSP_PTI_DCLK_LOC,
#endif
.dclkPort = (uint8_t)BSP_PTI_DCLK_PORT,
.dclkPin = BSP_PTI_DCLK_PIN,
#endif
#if HAL_PTI_MODE != HAL_PTI_MODE_UART_ONEWIRE
#ifdef BSP_PTI_DFRAME_LOC
.dframeLoc = BSP_PTI_DFRAME_LOC,
#endif
.dframePort = (uint8_t)BSP_PTI_DFRAME_PORT,
.dframePin = BSP_PTI_DFRAME_PIN
#endif
};
RAIL_ConfigPti(RAIL_EFR32_HANDLE, &railPtiConfig);
#endif // HAL_PTI_ENABLE
#if !defined(RAIL_IC_SIM_BUILD)
initAntenna();
// Disable any unused peripherals to ensure we enter a low power mode
boardLowPowerInit();
#endif
#if RAIL_DMA_CHANNEL == DMA_CHANNEL_DMADRV
Ecode_t dmaError = DMADRV_Init();
if ((dmaError == ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED) || (dmaError == ECODE_EMDRV_DMADRV_OK))
{
unsigned int channel;
dmaError = DMADRV_AllocateChannel(&channel, NULL);
if (dmaError == ECODE_EMDRV_DMADRV_OK)
{
RAIL_UseDma(channel);
}
}
#elif defined(RAIL_DMA_CHANNEL) && (RAIL_DMA_CHANNEL != DMA_CHANNEL_INVALID)
LDMA_Init_t ldmaInit = LDMA_INIT_DEFAULT;
LDMA_Init(&ldmaInit);
RAIL_UseDma(RAIL_DMA_CHANNEL);
#endif
}
otInstance *sInstance;
static bool (*sCanSleepCallback)(void);
void otSysInit(int argc, char *argv[])
{
OT_UNUSED_VARIABLE(argc);
OT_UNUSED_VARIABLE(argv);
sl_status_t status;
__disable_irq();
#undef FIXED_EXCEPTION
#define FIXED_EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler)
#define EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler, priorityLevel, subpriority) \
NVIC_SetPriority(deviceIrqn, NVIC_EncodePriority(PRIGROUP_POSITION, priorityLevel, subpriority));
#include NVIC_CONFIG
#undef EXCEPTION
NVIC_SetPriorityGrouping(PRIGROUP_POSITION);
CHIP_Init();
halInitChipSpecific();
BSP_Init(BSP_INIT_BCC);
CMU_ClockSelectSet(cmuClock_LFE, cmuSelect_LFRCO);
CMU_ClockEnable(cmuClock_CORELE, true);
CMU_ClockEnable(cmuClock_RTCC, true);
status = sl_sleeptimer_init();
assert(status == SL_STATUS_OK);
#if (HAL_FEM_ENABLE)
initFem();
wakeupFem();
#endif
__enable_irq();
#if USE_EFR32_LOG
efr32LogInit();
#endif
efr32RadioInit();
efr32AlarmInit();
efr32MiscInit();
efr32RandomInit();
}
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void otSysDeinit(void)
{
efr32RadioDeinit();
#if USE_EFR32_LOG
efr32LogDeinit();
#endif
}
void efr32SetSleepCallback(bool (*aCallback)(void))
{
sCanSleepCallback = aCallback;
}
void efr32Sleep(void)
{
bool canDeepSleep = false;
int wakeupProcessTime = 1000;
CORE_DECLARE_IRQ_STATE;
if (RAIL_Sleep(wakeupProcessTime, &canDeepSleep) == RAIL_STATUS_NO_ERROR)
{
if (canDeepSleep)
{
CORE_ENTER_ATOMIC();
if (sCanSleepCallback != NULL && sCanSleepCallback())
{
EMU_EnterEM2(true);
}
CORE_EXIT_ATOMIC();
// TODO OT will handle an interrupt here and it mustn't call any RAIL APIs
while (RAIL_Wake(0) != RAIL_STATUS_NO_ERROR)
{
}
}
else
{
CORE_ENTER_ATOMIC();
if (sCanSleepCallback != NULL && sCanSleepCallback())
{
EMU_EnterEM1();
}
CORE_EXIT_ATOMIC();
}
}
}
void otSysProcessDrivers(otInstance *aInstance)
{
sInstance = aInstance;
// should sleep and wait for interrupts here
efr32UartProcess();
efr32RadioProcess(aInstance);
efr32AlarmProcess(aInstance);
}
__WEAK void otSysEventSignalPending(void)
{
// Intentionally empty
}
-194
View File
@@ -1,194 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for UART communication.
*
*/
#include <stddef.h>
#include "openthread-system.h"
#include <openthread/platform/uart.h>
#include "utils/code_utils.h"
#include "em_core.h"
#include "uartdrv.h"
#include "hal-config.h"
enum
{
kReceiveFifoSize = 128,
};
#define USART_INIT \
{ \
USART0, /* USART port */ \
115200, /* Baud rate */ \
BSP_SERIAL_APP_TX_LOC, /* USART Tx pin location number */ \
BSP_SERIAL_APP_RX_LOC, /* USART Rx pin location number */ \
(USART_Stopbits_TypeDef)USART_FRAME_STOPBITS_ONE, /* Stop bits */ \
(USART_Parity_TypeDef)USART_FRAME_PARITY_NONE, /* Parity */ \
(USART_OVS_TypeDef)USART_CTRL_OVS_X16, /* Oversampling mode*/ \
false, /* Majority vote disable */ \
HAL_SERIAL_APP_FLOW_CONTROL, /* Flow control */ \
BSP_SERIAL_APP_CTS_PORT, /* CTS port number */ \
BSP_SERIAL_APP_CTS_PIN, /* CTS pin number */ \
BSP_SERIAL_APP_RTS_PORT, /* RTS port number */ \
BSP_SERIAL_APP_RTS_PIN, /* RTS pin number */ \
(UARTDRV_Buffer_FifoQueue_t *)&sUartRxQueue, /* RX operation queue */ \
(UARTDRV_Buffer_FifoQueue_t *)&sUartTxQueue, /* TX operation queue */ \
BSP_SERIAL_APP_CTS_LOC, /* CTS location */ \
BSP_SERIAL_APP_RTS_LOC /* RTS location */ \
}
DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_RX_BUFS, sUartRxQueue);
DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_TX_BUFS, sUartTxQueue);
static UARTDRV_HandleData_t sUartHandleData;
static UARTDRV_Handle_t sUartHandle = &sUartHandleData;
static uint8_t sReceiveBuffer[2];
static const uint8_t * sTransmitBuffer = NULL;
static volatile uint16_t sTransmitLength = 0;
typedef struct ReceiveFifo_t
{
// The data buffer
uint8_t mBuffer[kReceiveFifoSize];
// The offset of the first item written to the list.
volatile uint16_t mHead;
// The offset of the next item to be written to the list.
volatile uint16_t mTail;
} ReceiveFifo_t;
static ReceiveFifo_t sReceiveFifo;
static void processReceive(void);
static void receiveDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aData, UARTDRV_Count_t aCount)
{
// We can only write if incrementing mTail doesn't equal mHead
if (sReceiveFifo.mHead != (sReceiveFifo.mTail + 1) % kReceiveFifoSize)
{
sReceiveFifo.mBuffer[sReceiveFifo.mTail] = aData[0];
sReceiveFifo.mTail = (sReceiveFifo.mTail + 1) % kReceiveFifoSize;
}
UARTDRV_Receive(aHandle, aData, 1, receiveDone);
otSysEventSignalPending();
}
static void transmitDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aData, UARTDRV_Count_t aCount)
{
sTransmitLength = 0;
otSysEventSignalPending();
}
static void processReceive(void)
{
// Copy tail to prevent multiple reads
uint16_t tail = sReceiveFifo.mTail;
// If the data wraps around, process the first part
if (sReceiveFifo.mHead > tail)
{
otPlatUartReceived(sReceiveFifo.mBuffer + sReceiveFifo.mHead, kReceiveFifoSize - sReceiveFifo.mHead);
// Reset the buffer mHead back to zero.
sReceiveFifo.mHead = 0;
}
// For any data remaining, process it
if (sReceiveFifo.mHead != tail)
{
otPlatUartReceived(sReceiveFifo.mBuffer + sReceiveFifo.mHead, tail - sReceiveFifo.mHead);
// Set mHead to the local tail we have cached
sReceiveFifo.mHead = tail;
}
}
otError otPlatUartFlush(void)
{
return OT_ERROR_NOT_IMPLEMENTED;
}
static void processTransmit(void)
{
if (sTransmitBuffer != NULL && sTransmitLength == 0)
{
sTransmitBuffer = NULL;
otPlatUartSendDone();
}
}
otError otPlatUartEnable(void)
{
UARTDRV_Init_t uartInit = USART_INIT;
sReceiveFifo.mHead = 0;
sReceiveFifo.mTail = 0;
UARTDRV_Init(sUartHandle, &uartInit);
for (uint8_t i = 0; i < sizeof(sReceiveBuffer); i++)
{
UARTDRV_Receive(sUartHandle, &sReceiveBuffer[i], sizeof(sReceiveBuffer[i]), receiveDone);
}
return OT_ERROR_NONE;
}
otError otPlatUartDisable(void)
{
return OT_ERROR_NOT_IMPLEMENTED;
}
otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(sTransmitBuffer == NULL, error = OT_ERROR_BUSY);
sTransmitBuffer = aBuf;
sTransmitLength = aBufLength;
UARTDRV_Transmit(sUartHandle, (uint8_t *)sTransmitBuffer, sTransmitLength, transmitDone);
exit:
return error;
}
void efr32UartProcess(void)
{
processReceive();
processTransmit();
}
-142
View File
@@ -1,142 +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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = libopenthread-efr32mg12.a
# Do not enable -Wconversion for rail
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
# Do not enable -pedantic-errors for rail
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
libopenthread_efr32mg12_a_CPPFLAGS = \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-DCORTEXM3 \
-DPHY=EMBER_PHY_RAIL \
-DMICRO=EMBER_MICRO_CORTEXM3_EFR32 \
-DCORTEXM3_EFM32_MICRO \
-DPLAT=EMBER_PLATFORM_CORTEXM3 \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg12/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
-I$(SDK_SRC_DIR) \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG12_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG12P/Include \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
alarm.c \
diag.c \
entropy.c \
fem-control.c \
flash.c \
logging.c \
misc.c \
openthread-core-efr32-config.h \
openthread-core-efr32-config-check.h \
platform-efr32.h \
platform-band.h \
radio.c \
rail_config.h \
startup-gcc.c \
system.c \
uart.c \
$(NULL)
noinst_HEADERS = \
platform-efr32.h \
platform-band.h \
$(NULL)
libopenthread_efr32mg12_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_efr32mg12_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
DIST_SUBDIRS = \
sleepy-demo \
$(NULL)
SUBDIRS = \
sleepy-demo \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,64 +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.
#
#
# efr32mg12 platform-specific Makefile
#
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
LIBRAIL = $(shell \
if [ "$(DMP)" = "1" ]; then \
echo "librail_multiprotocol_efr32xg12_gcc_release.a"; \
else \
echo "librail_efr32xg12_gcc_release.a"; \
fi )
LDADD_COMMON += \
$(top_builddir)/examples/platforms/efr32mg12/libopenthread-efr32mg12.a \
$(top_builddir)/third_party/silabs/libsilabs-efr32mg12-sdk.a \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/radio/rail_lib/autogen/librail_release/$(LIBRAIL) \
$(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
else
LDADD_COMMON += \
$(top_builddir)/third_party/silabs/libsilabs-mbedtls.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/efr32mg12/efr32mg12.ld \
$(NULL)
@@ -1,79 +0,0 @@
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H
// Include the autogenerated mbedtls configuration file
#include "mbedtls_config_autogen.h"
// <<< Use Configuration Wizard in Context Menu >>>
// <h> TLS/DTLS configuration
// <o MBEDTLS_SSL_CIPHERSUITES> Complete list of ciphersuites to use, in order of preference.
// <i> Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
// <i> Complete list of ciphersuites to use, in order of preference.
// <i> The value of this configuration should be updated for the application needs.
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
// <o MBEDTLS_SSL_MAX_CONTENT_LEN> Maximum TLS/DTLS fragment length in bytes.
// <i> Default: 768
// <i> The size configured here determines the size of each of the two
// <i> internal I/O buffers used in mbedTLS when sending and receiving data.
#define MBEDTLS_SSL_MAX_CONTENT_LEN 768
// <q SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH> Enable support for RFC 6066 max_fragment_length extension in SSL.
// <i> Default: 1
// <i> Enable support for RFC 6066 max_fragment_length extension in SSL.
#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1
// <q SL_MBEDTLS_SSL_EXPORT_KEYS> Enable support for exporting key block and master secret.
// <i> Default: 1
// <i> Enable support for exporting key block and master secret.
// <i> This is required for certain users of TLS, e.g. EAP-TLS.
#define SL_MBEDTLS_SSL_EXPORT_KEYS 1
// <q SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED> Enable the PSK based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the PSK based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 1
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED> Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED> Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 1
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED> Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0
// </h>
// <<< end of configuration section >>>
// Convert CMSIS Markup config defines to mbedTLS specific config defines
#if SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
#endif
#if SL_MBEDTLS_SSL_EXPORT_KEYS
#define MBEDTLS_SSL_EXPORT_KEYS
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
#endif
// Custom defines can be placed here before check_config.h is included.
#include "mbedtls/check_config.h"
#endif
-86
View File
@@ -1,86 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for the diagnostics.
*
*/
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/radio.h>
#include "platform-efr32.h"
#if OPENTHREAD_CONFIG_DIAG_ENABLE
/**
* Diagnostics mode variables.
*
*/
static bool sDiagMode = false;
void otPlatDiagModeSet(bool aMode)
{
sDiagMode = aMode;
}
bool otPlatDiagModeGet()
{
return sDiagMode;
}
void otPlatDiagChannelSet(uint8_t aChannel)
{
OT_UNUSED_VARIABLE(aChannel);
}
void otPlatDiagTxPowerSet(int8_t aTxPower)
{
OT_UNUSED_VARIABLE(aTxPower);
}
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aFrame);
OT_UNUSED_VARIABLE(aError);
}
void otPlatDiagAlarmCallback(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
#endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE
-109
View File
@@ -1,109 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements an entropy source based on ADC.
*
*/
#include <openthread/platform/entropy.h>
#include "utils/code_utils.h"
#include "em_adc.h"
#include "em_cmu.h"
enum
{
EFR32_ADC_REF_CLOCK = 7000000,
};
void efr32RandomInit(void)
{
/* Enable ADC Clock */
CMU_ClockEnable(cmuClock_ADC0, true);
ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
/* Initialize the ADC with the required values */
init.timebase = ADC_TimebaseCalc(0);
init.prescale = ADC_PrescaleCalc(EFR32_ADC_REF_CLOCK, 0);
ADC_Init(ADC0, &init);
/* Initialize for single conversion specific to RNG */
singleInit.reference = adcRefVEntropy;
singleInit.diff = true;
singleInit.posSel = adcPosSelVSS;
singleInit.negSel = adcNegSelVSS;
ADC_InitSingle(ADC0, &singleInit);
/* Set VINATT to maximum value and clear FIFO */
ADC0->SINGLECTRLX |= _ADC_SINGLECTRLX_VINATT_MASK;
ADC0->SINGLEFIFOCLEAR = ADC_SINGLEFIFOCLEAR_SINGLEFIFOCLEAR;
}
static uint32_t randomUint32Get(void)
{
uint8_t tmp;
uint32_t random = 0;
for (int i = 0; i < 4; i++)
{
tmp = 0;
for (int j = 0; j < 3; j++)
{
ADC_Start(ADC0, adcStartSingle);
while ((ADC0->IF & ADC_IF_SINGLE) == 0)
;
tmp |= ((ADC_DataSingleGet(ADC0) & 0x07) << (j * 3));
}
random |= (tmp & 0xff) << (i * 8);
}
return random;
}
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
for (uint16_t length = 0; length < aOutputLength; length++)
{
aOutput[length] = (uint8_t)randomUint32Get();
}
exit:
return error;
}
@@ -1,33 +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.
*/
#include "hal-config.h"
#if (HAL_FEM_ENABLE)
#include "util/plugin/plugin-common/fem-control/fem-control.c"
#endif
-364
View File
@@ -1,364 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for the non-volatile storage.
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE // Use OT NV system
#include "em_msc.h"
#include <string.h>
#include <openthread/instance.h>
#define FLASH_PAGE_NUM 2
#define FLASH_DATA_END_ADDR (FLASH_BASE + FLASH_SIZE)
#define FLASH_DATA_START_ADDR (FLASH_DATA_END_ADDR - (FLASH_PAGE_SIZE * FLASH_PAGE_NUM))
#define FLASH_SWAP_PAGE_NUM (FLASH_PAGE_NUM / 2)
#define FLASH_SWAP_SIZE (FLASH_PAGE_SIZE * FLASH_SWAP_PAGE_NUM)
static inline uint32_t mapAddress(uint8_t aSwapIndex, uint32_t aOffset)
{
uint32_t address;
address = FLASH_DATA_START_ADDR + aOffset;
if (aSwapIndex)
{
address += FLASH_SWAP_SIZE;
}
return address;
}
void otPlatFlashInit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
uint32_t otPlatFlashGetSwapSize(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return FLASH_SWAP_SIZE;
}
void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex)
{
OT_UNUSED_VARIABLE(aInstance);
uint32_t address = mapAddress(aSwapIndex, 0);
for (uint32_t n = 0; n < FLASH_SWAP_PAGE_NUM; n++, address += FLASH_PAGE_SIZE)
{
MSC_ErasePage((uint32_t *)address);
}
}
void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
{
OT_UNUSED_VARIABLE(aInstance);
MSC_WriteWord((uint32_t *)mapAddress(aSwapIndex, aOffset), aData, aSize);
}
void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize)
{
OT_UNUSED_VARIABLE(aInstance);
memcpy(aData, (const uint8_t *)mapAddress(aSwapIndex, aOffset), aSize);
}
#else // Defaults to Silabs nvm3 system
#include "nvm3.h"
#include "nvm3_default.h"
#include <string.h>
#include <openthread/platform/settings.h>
#include "common/code_utils.hpp"
#include "common/logging.hpp"
#define NVM3KEY_DOMAIN_OPENTHREAD 0x20000U
#define NUM_INDEXED_SETTINGS \
OPENTHREAD_CONFIG_MLE_MAX_CHILDREN // Indexed key types are only supported for kKeyChildInfo (=='child table').
#define ENUM_NVM3_KEY_LIST_SIZE 4 // List size used when enumerating nvm3 keys.
static otError addSetting(uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength);
static nvm3_ObjectKey_t makeNvm3ObjKey(uint16_t otSettingsKey, int index);
static otError mapNvm3Error(Ecode_t nvm3Res);
void otPlatSettingsInit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
if (mapNvm3Error(nvm3_open(nvm3_defaultHandle, nvm3_defaultInit)) != OT_ERROR_NONE)
{
otLogDebgPlat("Error initializing nvm3 instance");
}
}
void otPlatSettingsDeinit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
nvm3_close(nvm3_defaultHandle);
}
otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
{
// Searches through all matching nvm3 keys to find the one with the required
// 'index', then reads the nvm3 data into the destination buffer.
// (Repeatedly enumerates a list of matching keys from the nvm3 until the
// required index is found).
OT_UNUSED_VARIABLE(aInstance);
otError err;
uint16_t valueLength = 0;
nvm3_ObjectKey_t nvm3Key = makeNvm3ObjKey(aKey, 0); // The base nvm3 key value.
bool idxFound = false;
int idx = 0;
err = OT_ERROR_NOT_FOUND;
while ((idx <= NUM_INDEXED_SETTINGS) && (!idxFound))
{
// Get the next nvm3 key list.
nvm3_ObjectKey_t keys[ENUM_NVM3_KEY_LIST_SIZE]; // List holds the next set of nvm3 keys.
size_t objCnt = nvm3_enumObjects(nvm3_defaultHandle, keys, ENUM_NVM3_KEY_LIST_SIZE, nvm3Key,
makeNvm3ObjKey(aKey, NUM_INDEXED_SETTINGS));
for (size_t i = 0; i < objCnt; ++i)
{
nvm3Key = keys[i];
if (idx == aIndex)
{
uint32_t objType;
size_t objLen;
err = mapNvm3Error(nvm3_getObjectInfo(nvm3_defaultHandle, nvm3Key, &objType, &objLen));
if (err == OT_ERROR_NONE)
{
valueLength = objLen;
// Only perform read if an input buffer was passed in.
if ((aValue != NULL) && (aValueLength != NULL))
{
// Read all nvm3 obj bytes into a tmp buffer, then copy the required
// number of bytes to the read destination buffer.
uint8_t *buf = malloc(valueLength);
err = mapNvm3Error(nvm3_readData(nvm3_defaultHandle, nvm3Key, buf, valueLength));
if (err == OT_ERROR_NONE)
{
memcpy(aValue, buf, (valueLength < *aValueLength) ? valueLength : *aValueLength);
}
free(buf);
SuccessOrExit(err);
}
}
idxFound = true;
break;
}
++idx;
}
if (objCnt < ENUM_NVM3_KEY_LIST_SIZE)
{
// Stop searching (there are no more matching nvm3 objects).
break;
}
++nvm3Key; // Inc starting value for next nvm3 key list enumeration.
}
exit:
if (aValueLength != NULL)
{
*aValueLength = valueLength; // always return actual nvm3 object length.
}
return err;
}
otError otPlatSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
{
OT_UNUSED_VARIABLE(aInstance);
otError err;
// Delete all nvm3 objects matching the input key (i.e. the 'setting indexes' of the key).
err = otPlatSettingsDelete(aInstance, aKey, -1);
if ((err == OT_ERROR_NONE) || (err == OT_ERROR_NOT_FOUND))
{
// Add new setting object (i.e. 'index0' of the key).
err = addSetting(aKey, aValue, aValueLength);
SuccessOrExit(err);
}
exit:
return err;
}
otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
{
OT_UNUSED_VARIABLE(aInstance);
return addSetting(aKey, aValue, aValueLength);
}
otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex)
{
// Searches through all matching nvm3 keys to find the one with the required
// 'index' (or index = -1 to delete all), then deletes the nvm3 object.
// (Repeatedly enumerates a list of matching keys from the nvm3 until the
// required index is found).
OT_UNUSED_VARIABLE(aInstance);
otError err;
nvm3_ObjectKey_t nvm3Key = makeNvm3ObjKey(aKey, 0); // The base nvm3 key value.
bool idxFound = false;
int idx = 0;
err = OT_ERROR_NOT_FOUND;
while ((idx <= NUM_INDEXED_SETTINGS) && (!idxFound))
{
// Get the next nvm3 key list.
nvm3_ObjectKey_t keys[ENUM_NVM3_KEY_LIST_SIZE]; // List holds the next set of nvm3 keys.
size_t objCnt = nvm3_enumObjects(nvm3_defaultHandle, keys, ENUM_NVM3_KEY_LIST_SIZE, nvm3Key,
makeNvm3ObjKey(aKey, NUM_INDEXED_SETTINGS));
for (size_t i = 0; i < objCnt; ++i)
{
nvm3Key = keys[i];
if ((idx == aIndex) || (aIndex == -1))
{
uint32_t objType;
size_t objLen;
err = mapNvm3Error(nvm3_getObjectInfo(nvm3_defaultHandle, nvm3Key, &objType, &objLen));
if (err == OT_ERROR_NONE)
{
// Delete the nvm3 object.
err = mapNvm3Error(nvm3_deleteObject(nvm3_defaultHandle, nvm3Key));
SuccessOrExit(err);
}
if (aIndex != -1)
{
idxFound = true;
break;
}
}
++idx;
}
if (objCnt < ENUM_NVM3_KEY_LIST_SIZE)
{
// Stop searching (there are no more matching nvm3 objects).
break;
}
++nvm3Key; // Inc starting value for next nvm3 key list enumeration.
}
exit:
return err;
}
void otPlatSettingsWipe(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
// Delete nvm3 objects for all OT Settings keys (and any of their associated 'indexes').
// Note- any OT User nvm3 objects in the OT nvm3 area are NOT be erased.
for (uint16_t aKey = 0; aKey < 8; ++aKey)
{
otPlatSettingsDelete(NULL, aKey, -1);
}
}
// Local functions..
static otError addSetting(uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
{
// Helper function- writes input buffer data to a NEW nvm3 object.
// nvm3 object is created at the first available Key + index.
otError err;
if ((aValueLength == 0) || (aValue == NULL))
{
err = OT_ERROR_INVALID_ARGS;
}
else
{
for (int idx = 0; idx <= NUM_INDEXED_SETTINGS; ++idx)
{
nvm3_ObjectKey_t nvm3Key;
nvm3Key = makeNvm3ObjKey(aKey, idx);
uint32_t objType;
size_t objLen;
err = mapNvm3Error(nvm3_getObjectInfo(nvm3_defaultHandle, nvm3Key, &objType, &objLen));
if (err == OT_ERROR_NOT_FOUND)
{
// Use this index for the new nvm3 object.
// Write the binary data to nvm3 (Creates nvm3 object if required).
err = mapNvm3Error(nvm3_writeData(nvm3_defaultHandle, nvm3Key, aValue, aValueLength));
break;
}
else if (err != OT_ERROR_NONE)
{
break;
}
}
}
return err;
}
static nvm3_ObjectKey_t makeNvm3ObjKey(uint16_t otSettingsKey, int index)
{
return (NVM3KEY_DOMAIN_OPENTHREAD | (otSettingsKey << 8) | (index & 0xFF));
}
static otError mapNvm3Error(Ecode_t nvm3Res)
{
otError err;
switch (nvm3Res)
{
case ECODE_NVM3_OK:
err = OT_ERROR_NONE;
break;
case ECODE_NVM3_ERR_KEY_NOT_FOUND:
err = OT_ERROR_NOT_FOUND;
break;
default:
err = OT_ERROR_FAILED;
break;
}
return err;
}
#endif // OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
-63
View File
@@ -1,63 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file logging.c
* Platform abstraction for the logging
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/logging.h>
#include <utils/logging_rtt.h>
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
void efr32LogInit(void)
{
utilsLogRttInit();
}
void efr32LogDeinit(void)
{
utilsLogRttDeinit();
}
OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
va_list ap;
va_start(ap, aFormat);
utilsLogRttOutput(aLogLevel, aLogRegion, aFormat, ap);
va_end(ap);
}
#endif
-98
View File
@@ -1,98 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for miscellaneous behaviors.
*/
#include <openthread/platform/misc.h>
#include "em_rmu.h"
#include "platform-efr32.h"
static uint32_t sResetCause;
void efr32MiscInit(void)
{
// Read the cause of last reset.
sResetCause = RMU_ResetCauseGet();
// Clear the register, as the causes cumulate over resets.
RMU_ResetCauseClear();
}
void otPlatReset(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
NVIC_SystemReset();
}
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
otPlatResetReason reason;
if (sResetCause & RMU_RSTCAUSE_PORST)
{
reason = OT_PLAT_RESET_REASON_POWER_ON;
}
else if (sResetCause & RMU_RSTCAUSE_SYSREQRST)
{
reason = OT_PLAT_RESET_REASON_SOFTWARE;
}
else if (sResetCause & RMU_RSTCAUSE_WDOGRST)
{
reason = OT_PLAT_RESET_REASON_WATCHDOG;
}
else if (sResetCause & RMU_RSTCAUSE_EXTRST)
{
reason = OT_PLAT_RESET_REASON_EXTERNAL;
}
else if (sResetCause & RMU_RSTCAUSE_LOCKUPRST)
{
reason = OT_PLAT_RESET_REASON_FAULT;
}
else if ((sResetCause & RMU_RSTCAUSE_AVDDBOD) || (sResetCause & RMU_RSTCAUSE_DECBOD) ||
(sResetCause & RMU_RSTCAUSE_DVDDBOD) || (sResetCause & RMU_RSTCAUSE_EM4RST))
{
reason = OT_PLAT_RESET_REASON_ASSERT;
}
else
{
reason = OT_PLAT_RESET_REASON_UNKNOWN;
}
return reason;
}
void otPlatWakeHost(void)
{
// TODO: implement an operation to wake the host from sleep state.
}
@@ -1,44 +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.
*/
#ifndef OPENTHREAD_CORE_EFR32_CONFIG_CHECK_H_
#define OPENTHREAD_CORE_EFR32_CONFIG_CHECK_H_
#include "board_config.h"
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#error "Platform efr32mg12 doesn't support configuration option: OPENTHREAD_CONFIG_TIME_SYNC_ENABLE"
#endif
#ifndef RADIO_CONFIG_915MHZ_OQPSK_SUPPORT
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
#error "Platform efr32mg12 not configured to support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
#endif
#endif
#endif /* OPENTHREAD_CORE_EFR32_CONFIG_CHECK_H_ */
@@ -1,132 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes efr32 compile-time configuration constants
* for OpenThread.
*/
#include "board_config.h"
#include "em_msc.h"
#ifndef OPENTHREAD_CORE_EFR32_CONFIG_H_
#define OPENTHREAD_CORE_EFR32_CONFIG_H_
/**
* @def OPENTHREAD_CONFIG_LOG_OUTPUT
*
* The efr32 platform provides an otPlatLog() function.
*/
#ifndef OPENTHREAD_CONFIG_LOG_OUTPUT /* allow command line override */
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
#endif
/*
* @def OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
*
* Define to 1 if you want to enable physical layer to support OQPSK modulation in 915MHz band.
*
*/
#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT
#define OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT 1
#else
#define OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT 0
#endif
/*
* @def OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT
*
* Define to 1 if you want to enable physical layer to support OQPSK modulation in 2.4GHz band.
*
*/
#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT
#define OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT 1
#else
#define OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT 0
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_INFO
*
* The platform-specific string to insert into the OpenThread version string.
*
*/
#define OPENTHREAD_CONFIG_PLATFORM_INFO "EFR32"
/*
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
*
* Define to 1 if you want to enable software retransmission logic.
*
*/
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
*
* Define to 1 if you want to enable software CSMA-CA backoff logic.
*
*/
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 0
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
*
* Define to 1 if you want to enable software transmission security logic.
*
*/
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 0
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE
*
* Define to 1 if you want to enable software energy scanning logic.
*
*/
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE 0
/**
* @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 0
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif // OPENTHREAD_CORE_EFR32_CONFIG_H_
@@ -1,95 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file defines the frequency band configuration structure for efr32.
*
*/
#ifndef PLATFORM_BAND_H_
#define PLATFORM_BAND_H_
#include <openthread/platform/radio.h>
#include "rail.h"
#include "rail_config.h"
#include "rail_ieee802154.h"
#define RAIL_TX_FIFO_SIZE (OT_RADIO_FRAME_MAX_SIZE + 1)
#define RADIO_SCHEDULER_BACKGROUND_RX_PRIORITY 255
#define RADIO_SCHEDULER_CHANNEL_SCAN_PRIORITY 255
#define RADIO_SCHEDULER_CHANNEL_SLIP_TIME 500000UL
#define RADIO_SCHEDULER_TX_PRIORITY 100
#define RADIO_SCHEDULER_TX_SLIP_TIME 500000UL
#define RADIO_TIMING_CSMA_OVERHEAD_US 500
#define RADIO_TIMING_DEFAULT_BYTETIME_US 32 // only used if RAIL_GetBitRate returns 0
#define RADIO_TIMING_DEFAULT_SYMBOLTIME_US 16 // only used if RAIL_GetSymbolRate returns 0
typedef struct efr32RadioCounters
{
uint64_t mRailPlatTxTriggered;
uint64_t mRailPlatRadioReceiveDoneCbCount;
uint64_t mRailPlatRadioEnergyScanDoneCbCount;
uint64_t mRailPlatRadioTxDoneCbCount;
uint64_t mRailTxStarted;
uint64_t mRailTxStartFailed;
uint64_t mRailEventConfigScheduled;
uint64_t mRailEventConfigUnScheduled;
uint64_t mRailEventPacketSent;
uint64_t mRailEventChannelBusy;
uint64_t mRailEventEnergyScanCompleted;
uint64_t mRailEventCalNeeded;
uint64_t mRailEventPacketReceived;
uint64_t mRailEventNoAck;
uint64_t mRailEventTxAbort;
uint64_t mRailEventSchedulerStatusError;
uint64_t mRailEventsSchedulerStatusTransmitBusy;
uint32_t mRailEventsSchedulerStatusLastStatus;
} efr32RadioCounters;
typedef struct efr32CommonConfig
{
RAIL_Config_t mRailConfig;
#if RADIO_CONFIG_DMP_SUPPORT
RAILSched_Config_t railSchedState;
#endif
uint8_t
mRailTxFifo[RAIL_TX_FIFO_SIZE]; // must be 2 power between 64 and 4096, and bigger than OT_RADIO_FRAME_MAX_SIZE
} efr32CommonConfig;
typedef struct efr32BandConfig
{
const RAIL_ChannelConfig_t *mChannelConfig;
uint8_t mChannelMin;
uint8_t mChannelMax;
} efr32BandConfig;
#endif // PLATFORM_BAND_H_
@@ -1,138 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes the platform-specific initializers.
*
*/
#ifndef PLATFORM_EFR32_H_
#define PLATFORM_EFR32_H_
#include <openthread/instance.h>
#include "em_device.h"
#include "em_system.h"
#include "core_cm4.h"
#include "rail.h"
// Global OpenThread instance structure
extern otInstance *sInstance;
// Global reference to rail handle
extern RAIL_Handle_t gRailHandle;
/**
* This function initializes the alarm service used by OpenThread.
*
*/
void efr32AlarmInit(void);
/**
* This function performs alarm driver processing.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
void efr32AlarmProcess(otInstance *aInstance);
/**
* This function initializes the radio service used by OpenThead.
*
*/
void efr32RadioInit(void);
/**
* This function deinitializes the radio service used by OpenThead.
*
*/
void efr32RadioDeinit(void);
/**
* This function performs radio driver processing.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
void efr32RadioProcess(otInstance *aInstance);
/**
* This function performs UART driver processing.
*
*/
void efr32UartProcess(void);
/**
* Initialization of Misc module.
*
*/
void efr32MiscInit(void);
/**
* Initialization of ADC module for random number generator.
*
*/
void efr32RandomInit(void);
/**
* Initialization of Logger driver.
*
*/
void efr32LogInit(void);
/**
* Deinitialization of Logger driver.
*
*/
void efr32LogDeinit(void);
/**
* Registers the sleep callback handler. The callback is used to check that
* the application has no work pending and that it is safe to put the EFR32
* into a low energy sleep mode.
*
* The callback should return true if it is ok to enter sleep mode. Note
* that the callback itself is run with interrupts disabled and so should
* be kept as short as possible. Anny interrupt including those from timers
* will wake the EFR32 out of sleep mode.
*
* @param[in] aCallback Callback function.
*
*/
void efr32SetSleepCallback(bool (*aCallback)(void));
/**
* Put the EFR32 into a low power mode. Before sleeping it will call a callback
* in the application registered with efr32SetSleepCallback to ensure that there
* is no outstanding work in the application to do.
*/
void efr32Sleep(void);
#endif // PLATFORM_EFR32_H_
File diff suppressed because it is too large Load Diff
@@ -1,14 +0,0 @@
#ifndef __RAIL_CONFIG_H__
#define __RAIL_CONFIG_H__
#include "board_config.h"
#include "rail_types.h"
#include <stdint.h>
#define RADIO_CONFIG_XTAL_FREQUENCY 38400000UL
#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT
extern const RAIL_ChannelConfig_t *channelConfigs[];
#endif
#endif // __RAIL_CONFIG_H__
@@ -1,155 +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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/Makefile.platform.am
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
$(top_builddir)/examples/platforms/efr32mg12/libopenthread-efr32mg12.a:
(cd $(top_builddir)/examples/platforms/efr32mg12/ && $(MAKE) $(AM_MAKEFLAGS) libopenthread-efr32mg12.a )
bin_PROGRAMS = \
$(NULL)
CPPFLAGS_COMMON += \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-DCORTEXM3 \
-DPHY=EMBER_PHY_RAIL \
-DMICRO=EMBER_MICRO_CORTEXM3_EFR32 \
-DCORTEXM3_EFM32_MICRO \
-DPLAT=EMBER_PLATFORM_CORTEXM3 \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg12/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG12_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG12P/Include \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
LDADD_COMMON += \
$(NULL)
LDFLAGS_COMMON += \
$(NULL)
LIBTOOLFLAGS_COMMON += \
$(NULL)
SOURCES_COMMON += \
main.c \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
if OPENTHREAD_ENABLE_EXECUTABLE
bin_PROGRAMS += \
sleepy-demo-ftd \
$(NULL)
endif
sleepy_demo_ftd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
sleepy_demo_ftd_LDADD = \
$(top_builddir)/src/cli/libopenthread-cli-ftd.a \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(NULL)
sleepy_demo_ftd_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
sleepy_demo_ftd_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
sleepy_demo_ftd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_LINKER_MAP
sleepy_demo_ftd_LDFLAGS += -Wl,-Map=sleepy-demo-ftd.map
endif
if OPENTHREAD_BUILD_COVERAGE
CPPFLAGS_COMMON += \
-DOPENTHREAD_ENABLE_COVERAGE \
$(NULL)
CLEANFILES = $(wildcard *.gcda *.gcno)
endif # OPENTHREAD_BUILD_COVERAGE
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,322 +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.
*/
#include "bsp.h"
#include "em_cmu.h"
#include "em_emu.h"
#include "gpiointerrupt.h"
#include "hal-config.h"
#include "hal_common.h"
#include "openthread-system.h"
#include <assert.h>
#include <common/logging.hpp>
#include <openthread-core-config.h>
#include <string.h>
#include <openthread/cli.h>
#include <openthread/config.h>
#include <openthread/dataset_ftd.h>
#include <openthread/diag.h>
#include <openthread/instance.h>
#include <openthread/message.h>
#include <openthread/tasklet.h>
#include <openthread/thread.h>
#include <openthread/udp.h>
#include <openthread/platform/logging.h>
// Constants
#define MULTICAST_ADDR "ff03::1"
#define MULTICAST_PORT 123
#define RECV_PORT 234
#define MTD_MESSAGE "mtd button"
#define FTD_MESSAGE "ftd button"
// Types
typedef struct ButtonArray
{
GPIO_Port_TypeDef port;
unsigned int pin;
} ButtonArray_t;
// Prototypes
void setNetworkConfiguration(otInstance *aInstance);
void handleNetifStateChanged(uint32_t aFlags, void *aContext);
void gpioInit(void (*gpioCallback)(uint8_t pin));
void buttonCallback(uint8_t pin);
void initUdp(void);
void applicationTick(void);
void sFtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
// Variables
static otInstance * instance;
static otUdpSocket sFtdSocket;
static bool sLedOn = false;
static bool sHaveSwitchAddress = false;
static otIp6Address sSwitchAddress;
static bool sFtdButtonPressed = false;
static const ButtonArray_t sButtonArray[BSP_BUTTON_COUNT] = BSP_BUTTON_INIT;
void otTaskletsSignalPending(otInstance *aInstance)
{
(void)aInstance;
}
int main(int argc, char *argv[])
{
otSysInit(argc, argv);
gpioInit(buttonCallback);
instance = otInstanceInitSingle();
assert(instance);
otCliUartInit(instance);
otCliOutputFormat("sleepy-demo-ftd started\r\n");
setNetworkConfiguration(instance);
otSetStateChangedCallback(instance, handleNetifStateChanged, instance);
initUdp();
otIp6SetEnabled(instance, true);
otThreadSetEnabled(instance, true);
while (!otSysPseudoResetWasRequested())
{
otTaskletsProcess(instance);
otSysProcessDrivers(instance);
applicationTick();
}
otInstanceFinalize(instance);
return 0;
}
/*
* Provide, if required an "otPlatLog()" function
*/
#if OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_APP
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aLogRegion);
OT_UNUSED_VARIABLE(aFormat);
va_list ap;
va_start(ap, aFormat);
otCliPlatLogv(aLogLevel, aLogRegion, aFormat, ap);
va_end(ap);
}
#endif
/**
* Override default network settings, such as panid, so the devices can join a network
*/
void setNetworkConfiguration(otInstance *aInstance)
{
static char aNetworkName[] = "SleepyEFR32";
otOperationalDataset aDataset;
memset(&aDataset, 0, sizeof(otOperationalDataset));
/*
* Fields that can be configured in otOperationDataset to override defaults:
* Network Name, Mesh Local Prefix, Extended PAN ID, PAN ID, Delay Timer,
* Channel, Channel Mask Page 0, Network Master Key, PSKc, Security Policy
*/
aDataset.mActiveTimestamp = 1;
aDataset.mComponents.mIsActiveTimestampPresent = true;
/* Set Channel to 15 */
aDataset.mChannel = 15;
aDataset.mComponents.mIsChannelPresent = true;
/* Set Pan ID to 2222 */
aDataset.mPanId = (otPanId)0x2222;
aDataset.mComponents.mIsPanIdPresent = true;
/* Set Extended Pan ID to C0DE1AB5C0DE1AB5 */
uint8_t extPanId[OT_EXT_PAN_ID_SIZE] = {0xC0, 0xDE, 0x1A, 0xB5, 0xC0, 0xDE, 0x1A, 0xB5};
memcpy(aDataset.mExtendedPanId.m8, extPanId, sizeof(aDataset.mExtendedPanId));
aDataset.mComponents.mIsExtendedPanIdPresent = true;
/* Set master key to 1234C0DE1AB51234C0DE1AB51234C0DE */
uint8_t key[OT_MASTER_KEY_SIZE] = {0x12, 0x34, 0xC0, 0xDE, 0x1A, 0xB5, 0x12, 0x34, 0xC0, 0xDE, 0x1A, 0xB5};
memcpy(aDataset.mMasterKey.m8, key, sizeof(aDataset.mMasterKey));
aDataset.mComponents.mIsMasterKeyPresent = true;
/* Set Network Name to SleepyEFR32 */
size_t length = strlen(aNetworkName);
assert(length <= OT_NETWORK_NAME_MAX_SIZE);
memcpy(aDataset.mNetworkName.m8, aNetworkName, length);
aDataset.mComponents.mIsNetworkNamePresent = true;
otDatasetSetActive(aInstance, &aDataset);
}
void handleNetifStateChanged(uint32_t aFlags, void *aContext)
{
if ((aFlags & OT_CHANGED_THREAD_ROLE) != 0)
{
otDeviceRole changedRole = otThreadGetDeviceRole(aContext);
switch (changedRole)
{
case OT_DEVICE_ROLE_LEADER:
otCliOutputFormat("sleepy-demo-ftd changed to leader\r\n");
break;
case OT_DEVICE_ROLE_ROUTER:
otCliOutputFormat("sleepy-demo-ftd changed to router\r\n");
break;
case OT_DEVICE_ROLE_CHILD:
break;
case OT_DEVICE_ROLE_DETACHED:
case OT_DEVICE_ROLE_DISABLED:
break;
}
}
}
void gpioInit(void (*callback)(uint8_t pin))
{
// set up button GPIOs to input with pullups
for (int i = 0; i < BSP_BUTTON_COUNT; i++)
{
GPIO_PinModeSet(sButtonArray[i].port, sButtonArray[i].pin, gpioModeInputPull, 1);
}
// set up interrupt based callback function on falling edge
GPIOINT_Init();
GPIOINT_CallbackRegister(sButtonArray[0].pin, callback);
GPIOINT_CallbackRegister(sButtonArray[1].pin, callback);
GPIO_IntConfig(sButtonArray[0].port, sButtonArray[0].pin, false, true, true);
GPIO_IntConfig(sButtonArray[1].port, sButtonArray[1].pin, false, true, true);
BSP_LedsInit();
BSP_LedClear(0);
BSP_LedClear(1);
}
void initUdp(void)
{
otError error;
otSockAddr sockaddr;
memset(&sockaddr, 0, sizeof(sockaddr));
otIp6AddressFromString(MULTICAST_ADDR, &sockaddr.mAddress);
sockaddr.mPort = MULTICAST_PORT;
error = otUdpOpen(instance, &sFtdSocket, sFtdReceiveCallback, NULL);
if (error != OT_ERROR_NONE)
{
otCliOutputFormat("FTD failed to open udp multicast\r\n");
return;
}
error = otUdpBind(instance, &sFtdSocket, &sockaddr);
if (error != OT_ERROR_NONE)
{
otUdpClose(instance, &sFtdSocket);
otCliOutputFormat("FTD failed to bind udp multicast\r\n");
return;
}
}
void buttonCallback(uint8_t pin)
{
OT_UNUSED_VARIABLE(pin);
sFtdButtonPressed = true;
}
void applicationTick(void)
{
otError error = 0;
otMessageInfo messageInfo;
otMessage * message = NULL;
char * payload = FTD_MESSAGE;
if (sFtdButtonPressed == true)
{
sFtdButtonPressed = false;
if (sHaveSwitchAddress)
{
memset(&messageInfo, 0, sizeof(messageInfo));
memcpy(&messageInfo.mPeerAddr, &sSwitchAddress, sizeof messageInfo.mPeerAddr);
messageInfo.mPeerPort = RECV_PORT;
message = otUdpNewMessage(instance, NULL);
if (message != NULL)
{
error = otMessageAppend(message, payload, (uint16_t)strlen(payload));
if (error == OT_ERROR_NONE)
{
error = otUdpSend(instance, &sFtdSocket, message, &messageInfo);
if (error == OT_ERROR_NONE)
{
return;
}
}
}
if (message != NULL)
{
otMessageFree(message);
}
}
}
}
void sFtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
{
OT_UNUSED_VARIABLE(aContext);
OT_UNUSED_VARIABLE(aMessage);
OT_UNUSED_VARIABLE(aMessageInfo);
uint8_t buf[1500];
int length;
sLedOn = !sLedOn;
if (sLedOn)
{
BSP_LedSet(0);
}
else
{
BSP_LedClear(0);
}
length = otMessageRead(aMessage, otMessageGetOffset(aMessage), buf, sizeof(buf) - 1);
buf[length] = '\0';
otCliOutputFormat("Message Received: %s\r\n", buf);
sHaveSwitchAddress = true;
memcpy(&sSwitchAddress, &aMessageInfo->mPeerAddr, sizeof sSwitchAddress);
}
@@ -1,155 +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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/Makefile.platform.am
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
$(top_builddir)/examples/platforms/efr32mg12/libopenthread-efr32mg12.a:
(cd $(top_builddir)/examples/platforms/efr32mg12/ && $(MAKE) $(AM_MAKEFLAGS) libopenthread-efr32mg12.a )
bin_PROGRAMS = \
$(NULL)
CPPFLAGS_COMMON += \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-DCORTEXM3 \
-DPHY=EMBER_PHY_RAIL \
-DMICRO=EMBER_MICRO_CORTEXM3_EFR32 \
-DCORTEXM3_EFM32_MICRO \
-DPLAT=EMBER_PLATFORM_CORTEXM3 \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg12/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG12_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG12P/Include \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
LDADD_COMMON += \
$(NULL)
LDFLAGS_COMMON += \
$(NULL)
LIBTOOLFLAGS_COMMON += \
$(NULL)
SOURCES_COMMON += \
main.c \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
if OPENTHREAD_ENABLE_EXECUTABLE
bin_PROGRAMS += \
sleepy-demo-mtd \
$(NULL)
endif
sleepy_demo_mtd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
sleepy_demo_mtd_LDADD = \
$(top_builddir)/src/cli/libopenthread-cli-mtd.a \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(NULL)
sleepy_demo_mtd_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
sleepy_demo_mtd_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
sleepy_demo_mtd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_LINKER_MAP
sleepy_demo_mtd_LDFLAGS += -Wl,-Map=sleepy-demo-mtd.map
endif
if OPENTHREAD_BUILD_COVERAGE
CPPFLAGS_COMMON += \
-DOPENTHREAD_ENABLE_COVERAGE \
$(NULL)
CLEANFILES = $(wildcard *.gcda *.gcno)
endif # OPENTHREAD_BUILD_COVERAGE
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,55 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements gcc-specific startup code for the efr32.
*/
__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)
;
}
-269
View File
@@ -1,269 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file includes the platform-specific initializers.
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <assert.h>
#include <string.h>
#include "openthread-system.h"
#include <openthread/platform/uart.h>
#include "common/logging.hpp"
#include "bsp.h"
#include "bsp_init.h"
#include "dmadrv.h"
#include "ecode.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_core.h"
#include "em_emu.h"
#include "em_system.h"
#include "hal-config.h"
#include "hal_common.h"
#include "rail.h"
#include "sl_mpu.h"
#include "sl_sleeptimer.h"
#include "platform-efr32.h"
#if (HAL_FEM_ENABLE)
#include "fem-control.h"
#endif
#define USE_EFR32_LOG (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
void initAntenna(void);
static void boardDisableSpiFlash(void)
{
#if defined(BSP_EXTFLASH_USART) && !defined(HAL_DISABLE_EXTFLASH)
#include "mx25flash_spi.h"
MX25_init();
MX25_DP();
#endif
}
static void boardLowPowerInit(void)
{
boardDisableSpiFlash();
}
static void halInitChipSpecific(void)
{
#if defined(BSP_DK) && !defined(RAIL_IC_SIM_BUILD)
BSP_Init(BSP_INIT_DK_SPI);
#endif
BSP_initDevice();
#if !defined(RAIL_IC_SIM_BUILD)
BSP_initBoard();
#endif
#if HAL_PTI_ENABLE
RAIL_PtiConfig_t railPtiConfig = {
#if HAL_PTI_MODE == HAL_PTI_MODE_SPI
.mode = RAIL_PTI_MODE_SPI,
#elif HAL_PTI_MODE == HAL_PTI_MODE_UART
.mode = RAIL_PTI_MODE_UART,
#elif HAL_PTI_MODE == HAL_PTI_MODE_UART_ONEWIRE
.mode = RAIL_PTI_MODE_UART_ONEWIRE,
#else
.mode = RAIL_PTI_MODE_DISABLED,
#endif
.baud = HAL_PTI_BAUD_RATE,
#ifdef BSP_PTI_DOUT_LOC
.doutLoc = BSP_PTI_DOUT_LOC,
#endif
.doutPort = (uint8_t)BSP_PTI_DOUT_PORT,
.doutPin = BSP_PTI_DOUT_PIN,
#if HAL_PTI_MODE == HAL_PTI_MODE_SPI
#ifdef BSP_PTI_DCLK_LOC
.dclkLoc = BSP_PTI_DCLK_LOC,
#endif
.dclkPort = (uint8_t)BSP_PTI_DCLK_PORT,
.dclkPin = BSP_PTI_DCLK_PIN,
#endif
#if HAL_PTI_MODE != HAL_PTI_MODE_UART_ONEWIRE
#ifdef BSP_PTI_DFRAME_LOC
.dframeLoc = BSP_PTI_DFRAME_LOC,
#endif
.dframePort = (uint8_t)BSP_PTI_DFRAME_PORT,
.dframePin = BSP_PTI_DFRAME_PIN
#endif
};
RAIL_ConfigPti(RAIL_EFR32_HANDLE, &railPtiConfig);
#endif // HAL_PTI_ENABLE
#if !defined(RAIL_IC_SIM_BUILD)
initAntenna();
// Disable any unused peripherals to ensure we enter a low power mode
boardLowPowerInit();
#endif
#if RAIL_DMA_CHANNEL == DMA_CHANNEL_DMADRV
Ecode_t dmaError = DMADRV_Init();
if ((dmaError == ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED) || (dmaError == ECODE_EMDRV_DMADRV_OK))
{
unsigned int channel;
dmaError = DMADRV_AllocateChannel(&channel, NULL);
if (dmaError == ECODE_EMDRV_DMADRV_OK)
{
RAIL_UseDma(channel);
}
}
#elif defined(RAIL_DMA_CHANNEL) && (RAIL_DMA_CHANNEL != DMA_CHANNEL_INVALID)
LDMA_Init_t ldmaInit = LDMA_INIT_DEFAULT;
LDMA_Init(&ldmaInit);
RAIL_UseDma(RAIL_DMA_CHANNEL);
#endif
}
otInstance *sInstance;
static bool (*sCanSleepCallback)(void);
void otSysInit(int argc, char *argv[])
{
OT_UNUSED_VARIABLE(argc);
OT_UNUSED_VARIABLE(argv);
sl_status_t status;
__disable_irq();
#undef FIXED_EXCEPTION
#define FIXED_EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler)
#define EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler, priorityLevel, subpriority) \
NVIC_SetPriority(deviceIrqn, NVIC_EncodePriority(PRIGROUP_POSITION, priorityLevel, subpriority));
#include NVIC_CONFIG
#undef EXCEPTION
NVIC_SetPriorityGrouping(PRIGROUP_POSITION);
CHIP_Init();
halInitChipSpecific();
BSP_Init(BSP_INIT_BCC);
CMU_ClockSelectSet(cmuClock_LFE, cmuSelect_LFRCO);
CMU_ClockEnable(cmuClock_CORELE, true);
CMU_ClockEnable(cmuClock_RTCC, true);
status = sl_sleeptimer_init();
assert(status == SL_STATUS_OK);
#if (HAL_FEM_ENABLE)
initFem();
wakeupFem();
#endif
__enable_irq();
#if USE_EFR32_LOG
efr32LogInit();
#endif
efr32RadioInit();
efr32AlarmInit();
efr32MiscInit();
efr32RandomInit();
}
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void otSysDeinit(void)
{
efr32RadioDeinit();
#if USE_EFR32_LOG
efr32LogDeinit();
#endif
}
void efr32SetSleepCallback(bool (*aCallback)(void))
{
sCanSleepCallback = aCallback;
}
void efr32Sleep(void)
{
bool canDeepSleep = false;
int wakeupProcessTime = 1000;
CORE_DECLARE_IRQ_STATE;
if (RAIL_Sleep(wakeupProcessTime, &canDeepSleep) == RAIL_STATUS_NO_ERROR)
{
if (canDeepSleep)
{
CORE_ENTER_ATOMIC();
if (sCanSleepCallback != NULL && sCanSleepCallback())
{
EMU_EnterEM2(true);
}
CORE_EXIT_ATOMIC();
// TODO OT will handle an interrupt here and it mustn't call any RAIL APIs
while (RAIL_Wake(0) != RAIL_STATUS_NO_ERROR)
{
}
}
else
{
CORE_ENTER_ATOMIC();
if (sCanSleepCallback != NULL && sCanSleepCallback())
{
EMU_EnterEM1();
}
CORE_EXIT_ATOMIC();
}
}
}
void otSysProcessDrivers(otInstance *aInstance)
{
sInstance = aInstance;
// should sleep and wait for interrupts here
efr32UartProcess();
efr32RadioProcess(aInstance);
efr32AlarmProcess(aInstance);
}
__WEAK void otSysEventSignalPending(void)
{
// Intentionally empty
}
-142
View File
@@ -1,142 +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.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = libopenthread-efr32mg13.a
# Do not enable -Wconversion for rail
override CFLAGS := $(filter-out -Wconversion,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS))
# Do not enable -pedantic-errors for rail
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
# Do not enable -Wundef for rail
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
BOARD_LOWERCASE = $(shell echo $(BOARD) | tr A-Z a-z)
BOARD_UPPERCASE = $(shell echo $(BOARD) | tr a-z A-Z)
SDK_SRC_DIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v3.0
libopenthread_efr32mg13_a_CPPFLAGS = \
-DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \
-DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \
-Wno-sign-compare \
-DCORTEXM3 \
-DPHY=EMBER_PHY_RAIL \
-DMICRO=EMBER_MICRO_CORTEXM3_EFR32 \
-DCORTEXM3_EFM32_MICRO \
-DPLAT=EMBER_PLATFORM_CORTEXM3 \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/examples/platforms/efr32mg13/$(BOARD_LOWERCASE) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party/silabs/rail_config \
-I$(SDK_SRC_DIR) \
-I$(SDK_SRC_DIR)/hardware/kit/common/bsp \
-I$(SDK_SRC_DIR)/hardware/kit/common/drivers \
-I$(SDK_SRC_DIR)/hardware/kit/EFR32MG13_$(BOARD_UPPERCASE)/config \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32 \
-I$(SDK_SRC_DIR)/platform/base/hal/micro/cortexm3/efm32/config \
-I$(SDK_SRC_DIR)/platform/common/inc \
-I$(SDK_SRC_DIR)/platform/CMSIS/Include \
-I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG13P/Include \
-I$(SDK_SRC_DIR)/platform/emdrv/common/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/gpiointerrupt/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/uartdrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/ustimer/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/dmadrv/config \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/inc \
-I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config \
-I$(SDK_SRC_DIR)/platform/emlib/inc \
-I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/protocol/ieee802154 \
-I$(SDK_SRC_DIR)/platform/radio/rail_lib/plugin/pa-conversions \
-I$(SDK_SRC_DIR)/platform/service/mpu/inc \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/config \
-I$(SDK_SRC_DIR)/platform/service/sleeptimer/inc \
-I$(SDK_SRC_DIR)/util/plugin/plugin-common/fem-control \
-I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
$(NULL)
PLATFORM_SOURCES = \
alarm.c \
diag.c \
entropy.c \
fem-control.c \
flash.c \
logging.c \
misc.c \
openthread-core-efr32-config.h \
openthread-core-efr32-config-check.h \
platform-efr32.h \
platform-band.h \
radio.c \
rail_config.h \
startup-gcc.c \
system.c \
uart.c \
$(NULL)
noinst_HEADERS = \
platform-efr32.h \
platform-band.h \
$(NULL)
libopenthread_efr32mg13_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_efr32mg13_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") \
$(shell find $(top_builddir)/third_party/jlink/SEGGER_RTT_V640/RTT $(Dash)type f $(Dash)name "*.o")
DIST_SUBDIRS = \
sleepy-demo \
$(NULL)
SUBDIRS = \
sleepy-demo \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
-145
View File
@@ -1,145 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for the alarm.
*
*/
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include "openthread-system.h"
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include "common/logging.hpp"
#include "platform-efr32.h"
#include "utils/code_utils.h"
#include "em_core.h"
#include "rail.h"
#include "sl_sleeptimer.h"
#define XTAL_ACCURACY 200
static sl_sleeptimer_timer_handle_t sl_handle;
static uint32_t sAlarm = 0;
static bool sIsRunning = false;
static void AlarmCallback(sl_sleeptimer_timer_handle_t *aHandle, void *aData)
{
otSysEventSignalPending();
}
void efr32AlarmInit(void)
{
memset(&sl_handle, 0, sizeof sl_handle);
}
uint32_t otPlatAlarmMilliGetNow(void)
{
uint64_t ticks;
uint64_t now;
sl_status_t status;
ticks = sl_sleeptimer_get_tick_count64();
status = sl_sleeptimer_tick64_to_ms(ticks, &now);
assert(status == SL_STATUS_OK);
return (uint32_t)now;
}
uint32_t otPlatTimeGetXtalAccuracy(void)
{
return XTAL_ACCURACY;
}
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
OT_UNUSED_VARIABLE(aInstance);
sl_status_t status;
int32_t remaining;
uint32_t ticks;
sl_sleeptimer_stop_timer(&sl_handle);
sAlarm = aT0 + aDt;
remaining = (int32_t)(sAlarm - otPlatAlarmMilliGetNow());
sIsRunning = true;
if (remaining <= 0)
{
otSysEventSignalPending();
}
else
{
status = sl_sleeptimer_ms32_to_tick(remaining, &ticks);
assert(status == SL_STATUS_OK);
status = sl_sleeptimer_start_timer(&sl_handle, ticks, AlarmCallback, NULL, 0,
SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG);
assert(status == SL_STATUS_OK);
}
}
void otPlatAlarmMilliStop(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
sl_sleeptimer_stop_timer(&sl_handle);
sIsRunning = false;
}
void efr32AlarmProcess(otInstance *aInstance)
{
int32_t remaining;
if (sIsRunning)
{
remaining = (int32_t)(sAlarm - otPlatAlarmMilliGetNow());
if (remaining <= 0)
{
sIsRunning = false;
#if OPENTHREAD_CONFIG_DIAG_ENABLE
if (otPlatDiagModeGet())
{
otPlatDiagAlarmFired(aInstance);
}
else
#endif
{
otPlatAlarmMilliFired(aInstance);
}
}
}
}
@@ -1,79 +0,0 @@
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H
// Include the autogenerated mbedtls configuration file
#include "mbedtls_config_autogen.h"
// <<< Use Configuration Wizard in Context Menu >>>
// <h> TLS/DTLS configuration
// <o MBEDTLS_SSL_CIPHERSUITES> Complete list of ciphersuites to use, in order of preference.
// <i> Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
// <i> Complete list of ciphersuites to use, in order of preference.
// <i> The value of this configuration should be updated for the application needs.
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
// <o MBEDTLS_SSL_MAX_CONTENT_LEN> Maximum TLS/DTLS fragment length in bytes.
// <i> Default: 768
// <i> The size configured here determines the size of each of the two
// <i> internal I/O buffers used in mbedTLS when sending and receiving data.
#define MBEDTLS_SSL_MAX_CONTENT_LEN 768
// <q SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH> Enable support for RFC 6066 max_fragment_length extension in SSL.
// <i> Default: 1
// <i> Enable support for RFC 6066 max_fragment_length extension in SSL.
#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1
// <q SL_MBEDTLS_SSL_EXPORT_KEYS> Enable support for exporting key block and master secret.
// <i> Default: 1
// <i> Enable support for exporting key block and master secret.
// <i> This is required for certain users of TLS, e.g. EAP-TLS.
#define SL_MBEDTLS_SSL_EXPORT_KEYS 1
// <q SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED> Enable the PSK based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the PSK based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 1
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED> Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED> Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 1
// <q SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED> Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
// <i> Default: 0
// <i> Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0
// </h>
// <<< end of configuration section >>>
// Convert CMSIS Markup config defines to mbedTLS specific config defines
#if SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
#endif
#if SL_MBEDTLS_SSL_EXPORT_KEYS
#define MBEDTLS_SSL_EXPORT_KEYS
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#endif
#if SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
#endif
// Custom defines can be placed here before check_config.h is included.
#include "mbedtls/check_config.h"
#endif
-86
View File
@@ -1,86 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for the diagnostics.
*
*/
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/radio.h>
#include "platform-efr32.h"
#if OPENTHREAD_CONFIG_DIAG_ENABLE
/**
* Diagnostics mode variables.
*
*/
static bool sDiagMode = false;
void otPlatDiagModeSet(bool aMode)
{
sDiagMode = aMode;
}
bool otPlatDiagModeGet()
{
return sDiagMode;
}
void otPlatDiagChannelSet(uint8_t aChannel)
{
OT_UNUSED_VARIABLE(aChannel);
}
void otPlatDiagTxPowerSet(int8_t aTxPower)
{
OT_UNUSED_VARIABLE(aTxPower);
}
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aFrame);
OT_UNUSED_VARIABLE(aError);
}
void otPlatDiagAlarmCallback(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
#endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE
-109
View File
@@ -1,109 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements an entropy source based on ADC.
*
*/
#include <openthread/platform/entropy.h>
#include "utils/code_utils.h"
#include "em_adc.h"
#include "em_cmu.h"
enum
{
EFR32_ADC_REF_CLOCK = 7000000,
};
void efr32RandomInit(void)
{
/* Enable ADC Clock */
CMU_ClockEnable(cmuClock_ADC0, true);
ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
/* Initialize the ADC with the required values */
init.timebase = ADC_TimebaseCalc(0);
init.prescale = ADC_PrescaleCalc(EFR32_ADC_REF_CLOCK, 0);
ADC_Init(ADC0, &init);
/* Initialize for single conversion specific to RNG */
singleInit.reference = adcRefVEntropy;
singleInit.diff = true;
singleInit.posSel = adcPosSelVSS;
singleInit.negSel = adcNegSelVSS;
ADC_InitSingle(ADC0, &singleInit);
/* Set VINATT to maximum value and clear FIFO */
ADC0->SINGLECTRLX |= _ADC_SINGLECTRLX_VINATT_MASK;
ADC0->SINGLEFIFOCLEAR = ADC_SINGLEFIFOCLEAR_SINGLEFIFOCLEAR;
}
static uint32_t randomUint32Get(void)
{
uint8_t tmp;
uint32_t random = 0;
for (int i = 0; i < 4; i++)
{
tmp = 0;
for (int j = 0; j < 3; j++)
{
ADC_Start(ADC0, adcStartSingle);
while ((ADC0->IF & ADC_IF_SINGLE) == 0)
;
tmp |= ((ADC_DataSingleGet(ADC0) & 0x07) << (j * 3));
}
random |= (tmp & 0xff) << (i * 8);
}
return random;
}
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
{
otError error = OT_ERROR_NONE;
otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
for (uint16_t length = 0; length < aOutputLength; length++)
{
aOutput[length] = (uint8_t)randomUint32Get();
}
exit:
return error;
}

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