diff --git a/configure.ac b/configure.ac index 5e7ae5036..a6ed3be33 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/examples/Makefile-efr32mg1 b/examples/Makefile-efr32mg1 index e974bcde6..bf8eb4183 100644 --- a/examples/Makefile-efr32mg1 +++ b/examples/Makefile-efr32mg1 @@ -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. diff --git a/examples/Makefile-efr32mg12 b/examples/Makefile-efr32mg12 index edc783f86..4ce21e586 100644 --- a/examples/Makefile-efr32mg12 +++ b/examples/Makefile-efr32mg12 @@ -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. diff --git a/examples/Makefile-efr32mg13 b/examples/Makefile-efr32mg13 index 8dc2a09d7..a8d0f06e0 100644 --- a/examples/Makefile-efr32mg13 +++ b/examples/Makefile-efr32mg13 @@ -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. diff --git a/examples/Makefile-efr32mg21 b/examples/Makefile-efr32mg21 index ccf41fa2d..ba8854d58 100644 --- a/examples/Makefile-efr32mg21 +++ b/examples/Makefile-efr32mg21 @@ -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 diff --git a/examples/platforms/Makefile.am b/examples/platforms/Makefile.am index a479ede7d..750ff2e7b 100644 --- a/examples/platforms/Makefile.am +++ b/examples/platforms/Makefile.am @@ -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 diff --git a/examples/platforms/Makefile.platform.am b/examples/platforms/Makefile.platform.am index 4ced6493c..e0a1a6320 100644 --- a/examples/platforms/Makefile.platform.am +++ b/examples/platforms/Makefile.platform.am @@ -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 diff --git a/examples/platforms/efr32/Makefile.am b/examples/platforms/efr32/Makefile.am new file mode 100644 index 000000000..08ae788e8 --- /dev/null +++ b/examples/platforms/efr32/Makefile.am @@ -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 diff --git a/examples/platforms/efr32mg21/Makefile.platform.am b/examples/platforms/efr32/Makefile.platform.am similarity index 56% rename from examples/platforms/efr32mg21/Makefile.platform.am rename to examples/platforms/efr32/Makefile.platform.am index a7049a595..1d53802c4 100644 --- a/examples/platforms/efr32mg21/Makefile.platform.am +++ b/examples/platforms/efr32/Makefile.platform.am @@ -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 diff --git a/examples/platforms/efr32mg21/Makefile.am b/examples/platforms/efr32/efr32_platform_defs.am similarity index 55% rename from examples/platforms/efr32mg21/Makefile.am rename to examples/platforms/efr32/efr32_platform_defs.am index b629eda02..68d7da63b 100644 --- a/examples/platforms/efr32mg21/Makefile.am +++ b/examples/platforms/efr32/efr32_platform_defs.am @@ -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) + + diff --git a/examples/platforms/efr32/efr32mg1/Makefile.am b/examples/platforms/efr32/efr32mg1/Makefile.am new file mode 100644 index 000000000..873a8843c --- /dev/null +++ b/examples/platforms/efr32/efr32mg1/Makefile.am @@ -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 diff --git a/examples/platforms/efr32mg13/sleepy-demo/Makefile.am b/examples/platforms/efr32/efr32mg1/Makefile.platform.am similarity index 74% rename from examples/platforms/efr32mg13/sleepy-demo/Makefile.am rename to examples/platforms/efr32/efr32mg1/Makefile.platform.am index 9be5713e1..c3977f3d0 100644 --- a/examples/platforms/efr32mg13/sleepy-demo/Makefile.am +++ b/examples/platforms/efr32/efr32mg1/Makefile.platform.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 diff --git a/examples/platforms/efr32mg1/README.md b/examples/platforms/efr32/efr32mg1/README.md similarity index 100% rename from examples/platforms/efr32mg1/README.md rename to examples/platforms/efr32/efr32mg1/README.md diff --git a/examples/platforms/efr32mg12/brd4304a/board_config.h b/examples/platforms/efr32/efr32mg1/brd4151a/board_config.h similarity index 95% rename from examples/platforms/efr32mg12/brd4304a/board_config.h rename to examples/platforms/efr32/efr32mg1/brd4151a/board_config.h index d798d5235..d3381b77c 100644 --- a/examples/platforms/efr32mg12/brd4304a/board_config.h +++ b/examples/platforms/efr32/efr32mg1/brd4151a/board_config.h @@ -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. * */ diff --git a/examples/platforms/efr32mg1/brd4151a/hal-config.h b/examples/platforms/efr32/efr32mg1/brd4151a/hal-config.h similarity index 100% rename from examples/platforms/efr32mg1/brd4151a/hal-config.h rename to examples/platforms/efr32/efr32mg1/brd4151a/hal-config.h diff --git a/examples/platforms/efr32mg1/crypto/mbedtls_config_autogen.h b/examples/platforms/efr32/efr32mg1/crypto/mbedtls_config_autogen.h similarity index 100% rename from examples/platforms/efr32mg1/crypto/mbedtls_config_autogen.h rename to examples/platforms/efr32/efr32mg1/crypto/mbedtls_config_autogen.h diff --git a/examples/platforms/efr32mg1/efr32mg1.ld b/examples/platforms/efr32/efr32mg1/efr32mg1.ld similarity index 100% rename from examples/platforms/efr32mg1/efr32mg1.ld rename to examples/platforms/efr32/efr32mg1/efr32mg1.ld diff --git a/examples/platforms/efr32/efr32mg12/Makefile.am b/examples/platforms/efr32/efr32mg12/Makefile.am new file mode 100644 index 000000000..73cefb5a0 --- /dev/null +++ b/examples/platforms/efr32/efr32mg12/Makefile.am @@ -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 diff --git a/examples/platforms/efr32mg21/sleepy-demo/Makefile.am b/examples/platforms/efr32/efr32mg12/Makefile.platform.am similarity index 72% rename from examples/platforms/efr32mg21/sleepy-demo/Makefile.am rename to examples/platforms/efr32/efr32mg12/Makefile.platform.am index 5404255bf..3b4799aab 100644 --- a/examples/platforms/efr32mg21/sleepy-demo/Makefile.am +++ b/examples/platforms/efr32/efr32mg12/Makefile.platform.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 diff --git a/examples/platforms/efr32mg12/README.md b/examples/platforms/efr32/efr32mg12/README.md similarity index 100% rename from examples/platforms/efr32mg12/README.md rename to examples/platforms/efr32/efr32mg12/README.md diff --git a/examples/platforms/efr32mg12/brd4161a/board_config.h b/examples/platforms/efr32/efr32mg12/brd4161a/board_config.h similarity index 95% rename from examples/platforms/efr32mg12/brd4161a/board_config.h rename to examples/platforms/efr32/efr32mg12/brd4161a/board_config.h index d798d5235..d3381b77c 100644 --- a/examples/platforms/efr32mg12/brd4161a/board_config.h +++ b/examples/platforms/efr32/efr32mg12/brd4161a/board_config.h @@ -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. * */ diff --git a/examples/platforms/efr32mg12/brd4161a/hal-config.h b/examples/platforms/efr32/efr32mg12/brd4161a/hal-config.h similarity index 100% rename from examples/platforms/efr32mg12/brd4161a/hal-config.h rename to examples/platforms/efr32/efr32mg12/brd4161a/hal-config.h diff --git a/examples/platforms/efr32mg12/brd4166a/board_config.h b/examples/platforms/efr32/efr32mg12/brd4166a/board_config.h similarity index 95% rename from examples/platforms/efr32mg12/brd4166a/board_config.h rename to examples/platforms/efr32/efr32mg12/brd4166a/board_config.h index 1f9b93981..6046d0835 100644 --- a/examples/platforms/efr32mg12/brd4166a/board_config.h +++ b/examples/platforms/efr32/efr32mg12/brd4166a/board_config.h @@ -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. * */ diff --git a/examples/platforms/efr32mg12/brd4166a/hal-config.h b/examples/platforms/efr32/efr32mg12/brd4166a/hal-config.h similarity index 100% rename from examples/platforms/efr32mg12/brd4166a/hal-config.h rename to examples/platforms/efr32/efr32mg12/brd4166a/hal-config.h diff --git a/examples/platforms/efr32mg12/brd4170a/board_config.h b/examples/platforms/efr32/efr32mg12/brd4170a/board_config.h similarity index 95% rename from examples/platforms/efr32mg12/brd4170a/board_config.h rename to examples/platforms/efr32/efr32mg12/brd4170a/board_config.h index 2e946b9a6..826a4f271 100644 --- a/examples/platforms/efr32mg12/brd4170a/board_config.h +++ b/examples/platforms/efr32/efr32mg12/brd4170a/board_config.h @@ -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. * */ diff --git a/examples/platforms/efr32mg12/brd4170a/hal-config.h b/examples/platforms/efr32/efr32mg12/brd4170a/hal-config.h similarity index 100% rename from examples/platforms/efr32mg12/brd4170a/hal-config.h rename to examples/platforms/efr32/efr32mg12/brd4170a/hal-config.h diff --git a/examples/platforms/efr32mg1/brd4151a/board_config.h b/examples/platforms/efr32/efr32mg12/brd4304a/board_config.h similarity index 95% rename from examples/platforms/efr32mg1/brd4151a/board_config.h rename to examples/platforms/efr32/efr32mg12/brd4304a/board_config.h index d798d5235..d3381b77c 100644 --- a/examples/platforms/efr32mg1/brd4151a/board_config.h +++ b/examples/platforms/efr32/efr32mg12/brd4304a/board_config.h @@ -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. * */ diff --git a/examples/platforms/efr32mg12/brd4304a/hal-config.h b/examples/platforms/efr32/efr32mg12/brd4304a/hal-config.h similarity index 100% rename from examples/platforms/efr32mg12/brd4304a/hal-config.h rename to examples/platforms/efr32/efr32mg12/brd4304a/hal-config.h diff --git a/examples/platforms/efr32mg12/crypto/mbedtls_config_autogen.h b/examples/platforms/efr32/efr32mg12/crypto/mbedtls_config_autogen.h similarity index 100% rename from examples/platforms/efr32mg12/crypto/mbedtls_config_autogen.h rename to examples/platforms/efr32/efr32mg12/crypto/mbedtls_config_autogen.h diff --git a/examples/platforms/efr32mg12/efr32mg12.ld b/examples/platforms/efr32/efr32mg12/efr32mg12.ld similarity index 100% rename from examples/platforms/efr32mg12/efr32mg12.ld rename to examples/platforms/efr32/efr32mg12/efr32mg12.ld diff --git a/examples/platforms/efr32/efr32mg13/Makefile.am b/examples/platforms/efr32/efr32mg13/Makefile.am new file mode 100644 index 000000000..b50f02913 --- /dev/null +++ b/examples/platforms/efr32/efr32mg13/Makefile.am @@ -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 diff --git a/examples/platforms/efr32mg13/Makefile.platform.am b/examples/platforms/efr32/efr32mg13/Makefile.platform.am similarity index 55% rename from examples/platforms/efr32mg13/Makefile.platform.am rename to examples/platforms/efr32/efr32mg13/Makefile.platform.am index cacef197e..47b48a4b7 100644 --- a/examples/platforms/efr32mg13/Makefile.platform.am +++ b/examples/platforms/efr32/efr32mg13/Makefile.platform.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) diff --git a/examples/platforms/efr32mg13/README.md b/examples/platforms/efr32/efr32mg13/README.md similarity index 100% rename from examples/platforms/efr32mg13/README.md rename to examples/platforms/efr32/efr32mg13/README.md diff --git a/examples/platforms/efr32mg13/brd4168a/board_config.h b/examples/platforms/efr32/efr32mg13/brd4168a/board_config.h similarity index 97% rename from examples/platforms/efr32mg13/brd4168a/board_config.h rename to examples/platforms/efr32/efr32mg13/brd4168a/board_config.h index 8d1a1eccf..dfbe6b0e3 100644 --- a/examples/platforms/efr32mg13/brd4168a/board_config.h +++ b/examples/platforms/efr32/efr32mg13/brd4168a/board_config.h @@ -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. * */ diff --git a/examples/platforms/efr32mg13/brd4168a/hal-config.h b/examples/platforms/efr32/efr32mg13/brd4168a/hal-config.h similarity index 100% rename from examples/platforms/efr32mg13/brd4168a/hal-config.h rename to examples/platforms/efr32/efr32mg13/brd4168a/hal-config.h diff --git a/examples/platforms/efr32mg13/crypto/mbedtls_config_autogen.h b/examples/platforms/efr32/efr32mg13/crypto/mbedtls_config_autogen.h similarity index 100% rename from examples/platforms/efr32mg13/crypto/mbedtls_config_autogen.h rename to examples/platforms/efr32/efr32mg13/crypto/mbedtls_config_autogen.h diff --git a/examples/platforms/efr32mg13/efr32mg13.ld b/examples/platforms/efr32/efr32mg13/efr32mg13.ld similarity index 100% rename from examples/platforms/efr32mg13/efr32mg13.ld rename to examples/platforms/efr32/efr32mg13/efr32mg13.ld diff --git a/examples/platforms/efr32/efr32mg21/Makefile.am b/examples/platforms/efr32/efr32mg21/Makefile.am new file mode 100644 index 000000000..4697d3c2b --- /dev/null +++ b/examples/platforms/efr32/efr32mg21/Makefile.am @@ -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 diff --git a/examples/platforms/efr32/efr32mg21/Makefile.platform.am b/examples/platforms/efr32/efr32mg21/Makefile.platform.am new file mode 100644 index 000000000..f91e03aea --- /dev/null +++ b/examples/platforms/efr32/efr32mg21/Makefile.platform.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) diff --git a/examples/platforms/efr32mg21/README.md b/examples/platforms/efr32/efr32mg21/README.md similarity index 100% rename from examples/platforms/efr32mg21/README.md rename to examples/platforms/efr32/efr32mg21/README.md diff --git a/examples/platforms/efr32/efr32mg21/brd4180a/board_config.h b/examples/platforms/efr32/efr32mg21/brd4180a/board_config.h new file mode 100644 index 000000000..1507a9d1f --- /dev/null +++ b/examples/platforms/efr32/efr32mg21/brd4180a/board_config.h @@ -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__ diff --git a/examples/platforms/efr32mg21/brd4180a/hal-config.h b/examples/platforms/efr32/efr32mg21/brd4180a/hal-config.h similarity index 89% rename from examples/platforms/efr32mg21/brd4180a/hal-config.h rename to examples/platforms/efr32/efr32mg21/brd4180a/hal-config.h index b74f973dd..78e0257a3 100644 --- a/examples/platforms/efr32mg21/brd4180a/hal-config.h +++ b/examples/platforms/efr32/efr32mg21/brd4180a/hal-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] diff --git a/examples/platforms/efr32mg21/crypto/mbedtls_config_autogen.h b/examples/platforms/efr32/efr32mg21/crypto/mbedtls_config_autogen.h similarity index 100% rename from examples/platforms/efr32mg21/crypto/mbedtls_config_autogen.h rename to examples/platforms/efr32/efr32mg21/crypto/mbedtls_config_autogen.h diff --git a/examples/platforms/efr32mg21/efr32mg21.ld b/examples/platforms/efr32/efr32mg21/efr32mg21.ld similarity index 100% rename from examples/platforms/efr32mg21/efr32mg21.ld rename to examples/platforms/efr32/efr32mg21/efr32mg21.ld diff --git a/examples/platforms/efr32mg12/sleepy-demo/Makefile.am b/examples/platforms/efr32/sleepy-demo/Makefile.am similarity index 84% rename from examples/platforms/efr32mg12/sleepy-demo/Makefile.am rename to examples/platforms/efr32/sleepy-demo/Makefile.am index 9be5713e1..0c6f8c5a6 100644 --- a/examples/platforms/efr32mg12/sleepy-demo/Makefile.am +++ b/examples/platforms/efr32/sleepy-demo/Makefile.am @@ -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 diff --git a/examples/platforms/efr32mg12/sleepy-demo/README.md b/examples/platforms/efr32/sleepy-demo/README.md similarity index 92% rename from examples/platforms/efr32mg12/sleepy-demo/README.md rename to examples/platforms/efr32/sleepy-demo/README.md index f38646614..26ad15eb7 100644 --- a/examples/platforms/efr32mg12/sleepy-demo/README.md +++ b/examples/platforms/efr32/sleepy-demo/README.md @@ -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 $ ./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 diff --git a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/Makefile.am b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am similarity index 60% rename from examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/Makefile.am rename to examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am index 7199bac80..141968eae 100644 --- a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/Makefile.am +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.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 @@ -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 \ diff --git a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/main.c b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/main.c similarity index 99% rename from examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/main.c rename to examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/main.c index 7a489b1b9..69762db1b 100644 --- a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/main.c +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/main.c @@ -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); diff --git a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/Makefile.am b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am similarity index 60% rename from examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/Makefile.am rename to examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am index 4579eb3ba..6adedec40 100644 --- a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/Makefile.am +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.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 @@ -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 \ diff --git a/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-mtd/main.c b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/main.c similarity index 100% rename from examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-mtd/main.c rename to examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/main.c diff --git a/examples/platforms/efr32mg12/alarm.c b/examples/platforms/efr32/src/alarm.c similarity index 98% rename from examples/platforms/efr32mg12/alarm.c rename to examples/platforms/efr32/src/alarm.c index 71a39c089..6caa1efee 100644 --- a/examples/platforms/efr32mg12/alarm.c +++ b/examples/platforms/efr32/src/alarm.c @@ -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(); } diff --git a/examples/platforms/efr32mg1/diag.c b/examples/platforms/efr32/src/diag.c similarity index 100% rename from examples/platforms/efr32mg1/diag.c rename to examples/platforms/efr32/src/diag.c diff --git a/examples/platforms/efr32mg21/entropy.c b/examples/platforms/efr32/src/entropy.c similarity index 97% rename from examples/platforms/efr32mg21/entropy.c rename to examples/platforms/efr32/src/entropy.c index cd03c8f87..64b19aadc 100644 --- a/examples/platforms/efr32mg21/entropy.c +++ b/examples/platforms/efr32/src/entropy.c @@ -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 diff --git a/examples/platforms/efr32mg1/fem-control.c b/examples/platforms/efr32/src/fem-control.c similarity index 100% rename from examples/platforms/efr32mg1/fem-control.c rename to examples/platforms/efr32/src/fem-control.c diff --git a/examples/platforms/efr32mg1/flash.c b/examples/platforms/efr32/src/flash.c similarity index 100% rename from examples/platforms/efr32mg1/flash.c rename to examples/platforms/efr32/src/flash.c diff --git a/examples/platforms/efr32mg1/logging.c b/examples/platforms/efr32/src/logging.c similarity index 97% rename from examples/platforms/efr32mg1/logging.c rename to examples/platforms/efr32/src/logging.c index fa0a4dde9..649eb87e0 100644 --- a/examples/platforms/efr32mg1/logging.c +++ b/examples/platforms/efr32/src/logging.c @@ -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 diff --git a/examples/platforms/efr32mg1/crypto/mbedtls_config.h b/examples/platforms/efr32/src/mbedtls_config.h similarity index 91% rename from examples/platforms/efr32mg1/crypto/mbedtls_config.h rename to examples/platforms/efr32/src/mbedtls_config.h index 95f829ffb..c56ab3bb7 100644 --- a/examples/platforms/efr32mg1/crypto/mbedtls_config.h +++ b/examples/platforms/efr32/src/mbedtls_config.h @@ -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 >>> // TLS/DTLS configuration @@ -50,6 +47,11 @@ // Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. #define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 +// Enable hardware acceleration of crypto operations. +// Default: 1 +// Enable hardware acceleration of crypto operations. +#define SL_MBEDTLS_HARDWARE_ACCELERATION_ENABLED 1 + // // <<< 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" diff --git a/examples/platforms/efr32mg21/misc.c b/examples/platforms/efr32/src/misc.c similarity index 76% rename from examples/platforms/efr32mg21/misc.c rename to examples/platforms/efr32/src/misc.c index 66dd766de..e13fe40a4 100644 --- a/examples/platforms/efr32mg21/misc.c +++ b/examples/platforms/efr32/src/misc.c @@ -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; } diff --git a/examples/platforms/efr32mg1/openthread-core-efr32-config-check.h b/examples/platforms/efr32/src/openthread-core-efr32-config-check.h similarity index 89% rename from examples/platforms/efr32mg1/openthread-core-efr32-config-check.h rename to examples/platforms/efr32/src/openthread-core-efr32-config-check.h index cf112c908..fd2ff35c7 100644 --- a/examples/platforms/efr32mg1/openthread-core-efr32-config-check.h +++ b/examples/platforms/efr32/src/openthread-core-efr32-config-check.h @@ -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 diff --git a/examples/platforms/efr32mg1/openthread-core-efr32-config.h b/examples/platforms/efr32/src/openthread-core-efr32-config.h similarity index 97% rename from examples/platforms/efr32mg1/openthread-core-efr32-config.h rename to examples/platforms/efr32/src/openthread-core-efr32-config.h index d1cbde654..eabfcbc43 100644 --- a/examples/platforms/efr32mg1/openthread-core-efr32-config.h +++ b/examples/platforms/efr32/src/openthread-core-efr32-config.h @@ -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 diff --git a/examples/platforms/efr32mg13/platform-band.h b/examples/platforms/efr32/src/platform-band.h similarity index 98% rename from examples/platforms/efr32mg13/platform-band.h rename to examples/platforms/efr32/src/platform-band.h index 7c4d91255..75fff5b33 100644 --- a/examples/platforms/efr32mg13/platform-band.h +++ b/examples/platforms/efr32/src/platform-band.h @@ -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 diff --git a/examples/platforms/efr32mg1/platform-efr32.h b/examples/platforms/efr32/src/platform-efr32.h similarity index 96% rename from examples/platforms/efr32mg1/platform-efr32.h rename to examples/platforms/efr32/src/platform-efr32.h index 5ec48e216..9093b5015 100644 --- a/examples/platforms/efr32mg1/platform-efr32.h +++ b/examples/platforms/efr32/src/platform-efr32.h @@ -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. * diff --git a/examples/platforms/efr32mg1/radio.c b/examples/platforms/efr32/src/radio.c similarity index 92% rename from examples/platforms/efr32mg1/radio.c rename to examples/platforms/efr32/src/radio.c index ac350bc06..2b13c4e8b 100644 --- a/examples/platforms/efr32mg1/radio.c +++ b/examples/platforms/efr32/src/radio.c @@ -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: diff --git a/examples/platforms/efr32mg1/rail_config.h b/examples/platforms/efr32/src/rail_config.h similarity index 100% rename from examples/platforms/efr32mg1/rail_config.h rename to examples/platforms/efr32/src/rail_config.h diff --git a/examples/platforms/efr32mg1/startup-gcc.c b/examples/platforms/efr32/src/startup-gcc.c similarity index 100% rename from examples/platforms/efr32mg1/startup-gcc.c rename to examples/platforms/efr32/src/startup-gcc.c diff --git a/examples/platforms/efr32mg21/system.c b/examples/platforms/efr32/src/system.c similarity index 92% rename from examples/platforms/efr32mg21/system.c rename to examples/platforms/efr32/src/system.c index b8e27ef98..9e3f57a27 100644 --- a/examples/platforms/efr32mg21/system.c +++ b/examples/platforms/efr32/src/system.c @@ -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 { diff --git a/examples/platforms/efr32mg12/uart.c b/examples/platforms/efr32/src/uart.c similarity index 69% rename from examples/platforms/efr32mg12/uart.c rename to examples/platforms/efr32/src/uart.c index f93f75fc6..0ba169fca 100644 --- a/examples/platforms/efr32mg12/uart.c +++ b/examples/platforms/efr32/src/uart.c @@ -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; diff --git a/examples/platforms/efr32mg1/Makefile.am b/examples/platforms/efr32mg1/Makefile.am deleted file mode 100644 index 55c8169dc..000000000 --- a/examples/platforms/efr32mg1/Makefile.am +++ /dev/null @@ -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 diff --git a/examples/platforms/efr32mg1/Makefile.platform.am b/examples/platforms/efr32mg1/Makefile.platform.am deleted file mode 100644 index 247cf0a39..000000000 --- a/examples/platforms/efr32mg1/Makefile.platform.am +++ /dev/null @@ -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) diff --git a/examples/platforms/efr32mg1/alarm.c b/examples/platforms/efr32mg1/alarm.c deleted file mode 100644 index 71a39c089..000000000 --- a/examples/platforms/efr32mg1/alarm.c +++ /dev/null @@ -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 -#include -#include - -#include "openthread-system.h" -#include -#include -#include -#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); - } - } - } -} diff --git a/examples/platforms/efr32mg1/entropy.c b/examples/platforms/efr32mg1/entropy.c deleted file mode 100644 index 2b196bbba..000000000 --- a/examples/platforms/efr32mg1/entropy.c +++ /dev/null @@ -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 - -#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; -} diff --git a/examples/platforms/efr32mg1/misc.c b/examples/platforms/efr32mg1/misc.c deleted file mode 100644 index 4b2076fdc..000000000 --- a/examples/platforms/efr32mg1/misc.c +++ /dev/null @@ -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 - -#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. -} diff --git a/examples/platforms/efr32mg1/platform-band.h b/examples/platforms/efr32mg1/platform-band.h deleted file mode 100644 index 7c4d91255..000000000 --- a/examples/platforms/efr32mg1/platform-band.h +++ /dev/null @@ -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 - -#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_ diff --git a/examples/platforms/efr32mg1/system.c b/examples/platforms/efr32mg1/system.c deleted file mode 100644 index b33c543f7..000000000 --- a/examples/platforms/efr32mg1/system.c +++ /dev/null @@ -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 -#include - -#include -#include - -#include "openthread-system.h" -#include - -#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 -} diff --git a/examples/platforms/efr32mg1/uart.c b/examples/platforms/efr32mg1/uart.c deleted file mode 100644 index f93f75fc6..000000000 --- a/examples/platforms/efr32mg1/uart.c +++ /dev/null @@ -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 - -#include "openthread-system.h" -#include - -#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(); -} diff --git a/examples/platforms/efr32mg12/Makefile.am b/examples/platforms/efr32mg12/Makefile.am deleted file mode 100644 index 770f4b81f..000000000 --- a/examples/platforms/efr32mg12/Makefile.am +++ /dev/null @@ -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 diff --git a/examples/platforms/efr32mg12/Makefile.platform.am b/examples/platforms/efr32mg12/Makefile.platform.am deleted file mode 100644 index 51f14f2fb..000000000 --- a/examples/platforms/efr32mg12/Makefile.platform.am +++ /dev/null @@ -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) diff --git a/examples/platforms/efr32mg12/crypto/mbedtls_config.h b/examples/platforms/efr32mg12/crypto/mbedtls_config.h deleted file mode 100644 index 95f829ffb..000000000 --- a/examples/platforms/efr32mg12/crypto/mbedtls_config.h +++ /dev/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 >>> -// TLS/DTLS configuration - -// Complete list of ciphersuites to use, in order of preference. -// Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 -// Complete list of ciphersuites to use, in order of preference. -// The value of this configuration should be updated for the application needs. -#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 - -// Maximum TLS/DTLS fragment length in bytes. -// Default: 768 -// The size configured here determines the size of each of the two -// internal I/O buffers used in mbedTLS when sending and receiving data. -#define MBEDTLS_SSL_MAX_CONTENT_LEN 768 - -// Enable support for RFC 6066 max_fragment_length extension in SSL. -// Default: 1 -// Enable support for RFC 6066 max_fragment_length extension in SSL. -#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1 - -// Enable support for exporting key block and master secret. -// Default: 1 -// Enable support for exporting key block and master secret. -// This is required for certain users of TLS, e.g. EAP-TLS. -#define SL_MBEDTLS_SSL_EXPORT_KEYS 1 - -// Enable the PSK based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the PSK based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 1 - -// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0 - -// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 1 - -// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 - -// -// <<< 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 diff --git a/examples/platforms/efr32mg12/diag.c b/examples/platforms/efr32mg12/diag.c deleted file mode 100644 index a7c335754..000000000 --- a/examples/platforms/efr32mg12/diag.c +++ /dev/null @@ -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 -#include -#include -#include - -#include -#include -#include - -#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 diff --git a/examples/platforms/efr32mg12/entropy.c b/examples/platforms/efr32mg12/entropy.c deleted file mode 100644 index 2b196bbba..000000000 --- a/examples/platforms/efr32mg12/entropy.c +++ /dev/null @@ -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 - -#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; -} diff --git a/examples/platforms/efr32mg12/fem-control.c b/examples/platforms/efr32mg12/fem-control.c deleted file mode 100644 index f66415c19..000000000 --- a/examples/platforms/efr32mg12/fem-control.c +++ /dev/null @@ -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 diff --git a/examples/platforms/efr32mg12/flash.c b/examples/platforms/efr32mg12/flash.c deleted file mode 100644 index 4f3596974..000000000 --- a/examples/platforms/efr32mg12/flash.c +++ /dev/null @@ -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 -#include - -#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE // Use OT NV system - -#include "em_msc.h" -#include -#include - -#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 -#include -#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 diff --git a/examples/platforms/efr32mg12/logging.c b/examples/platforms/efr32mg12/logging.c deleted file mode 100644 index fa0a4dde9..000000000 --- a/examples/platforms/efr32mg12/logging.c +++ /dev/null @@ -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 -#include -#include -#include - -#include - -#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 diff --git a/examples/platforms/efr32mg12/misc.c b/examples/platforms/efr32mg12/misc.c deleted file mode 100644 index 4b2076fdc..000000000 --- a/examples/platforms/efr32mg12/misc.c +++ /dev/null @@ -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 - -#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. -} diff --git a/examples/platforms/efr32mg12/openthread-core-efr32-config-check.h b/examples/platforms/efr32mg12/openthread-core-efr32-config-check.h deleted file mode 100644 index 2c722a692..000000000 --- a/examples/platforms/efr32mg12/openthread-core-efr32-config-check.h +++ /dev/null @@ -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_ */ diff --git a/examples/platforms/efr32mg12/openthread-core-efr32-config.h b/examples/platforms/efr32mg12/openthread-core-efr32-config.h deleted file mode 100644 index d1cbde654..000000000 --- a/examples/platforms/efr32mg12/openthread-core-efr32-config.h +++ /dev/null @@ -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_ diff --git a/examples/platforms/efr32mg12/platform-band.h b/examples/platforms/efr32mg12/platform-band.h deleted file mode 100644 index 7c4d91255..000000000 --- a/examples/platforms/efr32mg12/platform-band.h +++ /dev/null @@ -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 - -#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_ diff --git a/examples/platforms/efr32mg12/platform-efr32.h b/examples/platforms/efr32mg12/platform-efr32.h deleted file mode 100644 index 5ec48e216..000000000 --- a/examples/platforms/efr32mg12/platform-efr32.h +++ /dev/null @@ -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 - -#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_ diff --git a/examples/platforms/efr32mg12/radio.c b/examples/platforms/efr32mg12/radio.c deleted file mode 100644 index ac350bc06..000000000 --- a/examples/platforms/efr32mg12/radio.c +++ /dev/null @@ -1,1199 +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 radio communication. - * - */ - -#include -#include - -#include - -#include "openthread-system.h" -#include -#include -#include -#include - -#include "common/logging.hpp" -#include "utils/code_utils.h" - -#include "utils/soft_source_match_table.h" - -#include "board_config.h" -#include "em_cmu.h" -#include "em_core.h" -#include "em_system.h" -#include "hal-config.h" -#include "pa_conversions_efr32.h" -#include "platform-band.h" -#include "rail.h" -#include "rail_config.h" -#include "rail_ieee802154.h" - -enum -{ - IEEE802154_MIN_LENGTH = 5, - IEEE802154_MAX_LENGTH = 127, - IEEE802154_ACK_LENGTH = 5, - - // FCF + DSN + dest PANID + dest addr + src PANID + src addr (without security header) - IEEE802154_MAX_MHR_LENGTH = 2 + 1 + 2 + 8 + 2 + 8, - - 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, -}; - -enum -{ - EFR32_RECEIVE_SENSITIVITY = -100, // dBm - EFR32_RSSI_AVERAGING_TIME = 16, // us - EFR32_RSSI_AVERAGING_TIMEOUT = 300, // us -}; - -enum -{ - EFR32_SCHEDULER_SAMPLE_RSSI_PRIORITY = 10, // High priority - EFR32_SCHEDULER_TX_PRIORITY = 10, // High priority - EFR32_SCHEDULER_RX_PRIORITY = 20, // Low priority -}; - -enum -{ -#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT && RADIO_CONFIG_915MHZ_OQPSK_SUPPORT - EFR32_NUM_BAND_CONFIGS = 2, -#else - EFR32_NUM_BAND_CONFIGS = 1, -#endif -}; - -typedef enum -{ - ENERGY_SCAN_STATUS_IDLE, - ENERGY_SCAN_STATUS_IN_PROGRESS, - ENERGY_SCAN_STATUS_COMPLETED -} energyScanStatus; - -typedef enum -{ - ENERGY_SCAN_MODE_SYNC, - ENERGY_SCAN_MODE_ASYNC -} energyScanMode; - -RAIL_Handle_t gRailHandle; - -static volatile bool sTransmitBusy = false; -static bool sPromiscuous = false; -static otRadioState sState = OT_RADIO_STATE_DISABLED; - -enum -{ - ACKED_WITH_FP_MATCH_LENGTH = 1 + IEEE802154_MAX_MHR_LENGTH, // PHR and MHR - ACKED_WITH_FP_SLOTS = 16, // maximum number of Data Request packets in the RX FIFO. Length should be a power of 2. -}; - -typedef struct efr32AckedWithFP -{ - uint8_t mLength; - uint8_t mPacket[ACKED_WITH_FP_MATCH_LENGTH]; -} efr32AckedWithFP; -static bool sIsSrcMatchEnabled = false; -static efr32AckedWithFP sAckedWithFPFifo[ACKED_WITH_FP_SLOTS]; -static uint32_t sAckedWithFPReadIndex; -static volatile uint32_t sAckedWithFPWriteIndex; - -static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH]; -static otRadioFrame sReceiveFrame; -static otError sReceiveError; - -static otRadioFrame sTransmitFrame; -static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH]; -static volatile otError sTransmitError; - -static efr32CommonConfig sCommonConfig; -static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS]; - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT -static efr32RadioCounters sRailDebugCounters; -#endif - -static volatile energyScanStatus sEnergyScanStatus; -static volatile int8_t sEnergyScanResultDbm; -static energyScanMode sEnergyScanMode; - -#define QUARTER_DBM_IN_DBM 4 -#define US_IN_MS 1000 - -static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents); - -static const RAIL_IEEE802154_Config_t sRailIeee802154Config = { - .addresses = NULL, - .ackConfig = - { - .enable = true, - .ackTimeout = 864, - .rxTransitions = - { - .success = RAIL_RF_STATE_RX, - .error = RAIL_RF_STATE_RX, - }, - .txTransitions = - { - .success = RAIL_RF_STATE_RX, - .error = RAIL_RF_STATE_RX, - }, - }, - .timings = - { - .idleToRx = 100, - .txToRx = 192 - 10, - .idleToTx = 100, - .rxToTx = 192, - .rxSearchTimeout = 0, - .txToRxSearchTimeout = 0, - }, - .framesMask = RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES, - .promiscuousMode = false, - .isPanCoordinator = 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 - -static efr32BandConfig *sCurrentBandConfig = NULL; - -static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig) -{ - RAIL_Status_t status; - RAIL_Handle_t handle; - - handle = RAIL_Init(&aCommonConfig->mRailConfig, NULL); - assert(handle != NULL); - - status = RAIL_ConfigCal(handle, RAIL_CAL_ALL); - assert(status == RAIL_STATUS_NO_ERROR); - - status = RAIL_IEEE802154_Init(handle, &sRailIeee802154Config); - assert(status == RAIL_STATUS_NO_ERROR); - - status = RAIL_ConfigEvents(handle, RAIL_EVENTS_ALL, - RAIL_EVENT_RX_ACK_TIMEOUT | // - RAIL_EVENTS_TX_COMPLETION | // - RAIL_EVENT_RX_PACKET_RECEIVED | // - RAIL_EVENT_RSSI_AVERAGE_DONE | // - RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | // - RAIL_EVENT_CAL_NEEDED | // -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - RAIL_EVENT_CONFIG_SCHEDULED | // - RAIL_EVENT_CONFIG_UNSCHEDULED | // -#endif - RAIL_EVENT_SCHEDULER_STATUS // - ); - assert(status == RAIL_STATUS_NO_ERROR); - - uint16_t actualLenth = RAIL_SetTxFifo(handle, aCommonConfig->mRailTxFifo, 0, sizeof(aCommonConfig->mRailTxFifo)); - assert(actualLenth == 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 - if (aBandConfig->mChannelConfig != NULL) - { - uint16_t firstChannel = RAIL_ConfigChannels(gRailHandle, aBandConfig->mChannelConfig, NULL); - assert(firstChannel == aBandConfig->mChannelMin); - - txPowerConfig.mode = RAIL_TX_POWER_MODE_SUBGIG; - } - else - { - 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); - - status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPowerDbm) * 10); - assert(status == RAIL_STATUS_NO_ERROR); -} - -static efr32BandConfig *efr32RadioGetBandConfig(uint8_t aChannel) -{ - efr32BandConfig *config = NULL; - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - if ((sBandConfigs[i].mChannelMin <= aChannel) && (aChannel <= sBandConfigs[i].mChannelMax)) - { - config = &sBandConfigs[i]; - break; - } - } - - return config; -} - -static void efr32ConfigInit(void (*aEventCallback)(RAIL_Handle_t railHandle, RAIL_Events_t events)) -{ - sCommonConfig.mRailConfig.eventsCallback = aEventCallback; - sCommonConfig.mRailConfig.protocol = NULL; // only used by Bluetooth stack -#if RADIO_CONFIG_DMP_SUPPORT - sCommonConfig.mRailConfig.scheduler = &(sCommonConfig.railSchedState); -#else - sCommonConfig.mRailConfig.scheduler = NULL; // only needed for DMP -#endif - - uint8_t index = 0; - -#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT - sBandConfigs[index].mChannelConfig = NULL; - sBandConfigs[index].mChannelMin = OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN; - sBandConfigs[index].mChannelMax = OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX; - - index++; -#endif - -#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT - sBandConfigs[index].mChannelConfig = channelConfigs[0]; - sBandConfigs[index].mChannelMin = OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN; - sBandConfigs[index].mChannelMax = OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX; -#endif - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - memset(&sRailDebugCounters, 0x00, sizeof(efr32RadioCounters)); -#endif - - gRailHandle = efr32RailInit(&sCommonConfig); - assert(gRailHandle != NULL); - efr32RailConfigLoad(&(sBandConfigs[0])); -} - -void efr32RadioInit(void) -{ - RAIL_Status_t status; - - // check if RAIL_TX_FIFO_SIZE is power of two.. - assert((RAIL_TX_FIFO_SIZE & (RAIL_TX_FIFO_SIZE - 1)) == 0); - - // check the limits of the RAIL_TX_FIFO_SIZE. - assert((RAIL_TX_FIFO_SIZE >= 64) || (RAIL_TX_FIFO_SIZE <= 4096)); - - efr32ConfigInit(RAILCb_Generic); - - CMU_ClockEnable(cmuClock_PRS, true); - - status = RAIL_ConfigSleep(gRailHandle, RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED); - assert(status == RAIL_STATUS_NO_ERROR); - - sReceiveFrame.mLength = 0; - sReceiveFrame.mPsdu = sReceivePsdu; - sTransmitFrame.mLength = 0; - sTransmitFrame.mPsdu = sTransmitPsdu; - - sCurrentBandConfig = efr32RadioGetBandConfig(OPENTHREAD_CONFIG_DEFAULT_CHANNEL); - assert(sCurrentBandConfig != NULL); - - memset(sAckedWithFPFifo, 0, sizeof(sAckedWithFPFifo)); - sAckedWithFPWriteIndex = 0; - sAckedWithFPReadIndex = 0; - - efr32RadioSetTxPower(sTxPowerDbm); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = false; - - otLogInfoPlat("Initialized", NULL); -} - -void efr32RadioDeinit(void) -{ - RAIL_Status_t status; - - RAIL_Idle(gRailHandle, RAIL_IDLE_ABORT, true); - status = RAIL_ConfigEvents(gRailHandle, RAIL_EVENTS_ALL, 0); - assert(status == RAIL_STATUS_NO_ERROR); - - sCurrentBandConfig = NULL; -} - -static otError efr32StartEnergyScan(energyScanMode aMode, uint16_t aChannel, RAIL_Time_t aAveragingTimeUs) -{ - RAIL_Status_t status; - otError error = OT_ERROR_NONE; - efr32BandConfig *config = NULL; - - otEXPECT_ACTION(sEnergyScanStatus == ENERGY_SCAN_STATUS_IDLE, error = OT_ERROR_BUSY); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IN_PROGRESS; - sEnergyScanMode = aMode; - - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - - config = efr32RadioGetBandConfig(aChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - if (sCurrentBandConfig != config) - { - efr32RailConfigLoad(config); - sCurrentBandConfig = config; - } - - RAIL_SchedulerInfo_t scanSchedulerInfo = {.priority = RADIO_SCHEDULER_CHANNEL_SCAN_PRIORITY, - .slipTime = RADIO_SCHEDULER_CHANNEL_SLIP_TIME, - .transactionTime = aAveragingTimeUs}; - - status = RAIL_StartAverageRssi(gRailHandle, aChannel, aAveragingTimeUs, &scanSchedulerInfo); - otEXPECT_ACTION(status == RAIL_STATUS_NO_ERROR, error = OT_ERROR_FAILED); - -exit: - return error; -} - -void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) -{ - OT_UNUSED_VARIABLE(aInstance); - - uint64_t eui64; - uint8_t *eui64Ptr = NULL; - - eui64 = SYSTEM_GetUnique(); - eui64Ptr = (uint8_t *)&eui64; - - for (uint8_t i = 0; i < OT_EXT_ADDRESS_SIZE; i++) - { - aIeeeEui64[i] = eui64Ptr[(OT_EXT_ADDRESS_SIZE - 1) - i]; - } -} - -void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("PANID=%X", aPanId); - - utilsSoftSrcMatchSetPanId(aPanId); - - status = RAIL_IEEE802154_SetPanId(gRailHandle, aPanId, 0); - assert(status == RAIL_STATUS_NO_ERROR); -} - -void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("ExtAddr=%X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4], - aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]); - - status = RAIL_IEEE802154_SetLongAddress(gRailHandle, (uint8_t *)aAddress->m8, 0); - assert(status == RAIL_STATUS_NO_ERROR); -} - -void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("ShortAddr=%X", aAddress); - - status = RAIL_IEEE802154_SetShortAddress(gRailHandle, aAddress, 0); - assert(status == RAIL_STATUS_NO_ERROR); -} - -bool otPlatRadioIsEnabled(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return (sState != OT_RADIO_STATE_DISABLED); -} - -otError otPlatRadioEnable(otInstance *aInstance) -{ - otEXPECT(!otPlatRadioIsEnabled(aInstance)); - - otLogInfoPlat("State=OT_RADIO_STATE_SLEEP", NULL); - sState = OT_RADIO_STATE_SLEEP; - -exit: - return OT_ERROR_NONE; -} - -otError otPlatRadioDisable(otInstance *aInstance) -{ - otEXPECT(otPlatRadioIsEnabled(aInstance)); - - otLogInfoPlat("State=OT_RADIO_STATE_DISABLED", NULL); - sState = OT_RADIO_STATE_DISABLED; - -exit: - return OT_ERROR_NONE; -} - -otError otPlatRadioSleep(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - - otEXPECT_ACTION((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED), - error = OT_ERROR_INVALID_STATE); - - otLogInfoPlat("State=OT_RADIO_STATE_SLEEP", NULL); - - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - sState = OT_RADIO_STATE_SLEEP; - -exit: - return error; -} - -otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) -{ - otError error = OT_ERROR_NONE; - RAIL_Status_t status; - efr32BandConfig *config; - - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION(sState != OT_RADIO_STATE_DISABLED, error = OT_ERROR_INVALID_STATE); - - config = efr32RadioGetBandConfig(aChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - if (sCurrentBandConfig != config) - { - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - efr32RailConfigLoad(config); - sCurrentBandConfig = config; - } - - RAIL_SchedulerInfo_t bgRxSchedulerInfo = { - .priority = RADIO_SCHEDULER_BACKGROUND_RX_PRIORITY, - // sliptime/transaction time is not used for bg rx - }; - - status = RAIL_StartRx(gRailHandle, aChannel, &bgRxSchedulerInfo); - otEXPECT_ACTION(status == RAIL_STATUS_NO_ERROR, error = OT_ERROR_FAILED); - - otLogInfoPlat("State=OT_RADIO_STATE_RECEIVE", NULL); - sState = OT_RADIO_STATE_RECEIVE; - sReceiveFrame.mChannel = aChannel; - -exit: - return error; -} - -otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) -{ - otError error = OT_ERROR_NONE; - RAIL_CsmaConfig_t csmaConfig = RAIL_CSMA_CONFIG_802_15_4_2003_2p4_GHz_OQPSK_CSMA; - RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_DEFAULT; - efr32BandConfig * config; - RAIL_Status_t status; - uint8_t frameLength; - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatTxTriggered++; -#endif - - assert(sTransmitBusy == false); - - otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT), - error = OT_ERROR_INVALID_STATE); - - config = efr32RadioGetBandConfig(aFrame->mChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - sState = OT_RADIO_STATE_TRANSMIT; - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = true; - - if (sCurrentBandConfig != config) - { - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - efr32RailConfigLoad(config); - sCurrentBandConfig = config; - } - - frameLength = (uint8_t)aFrame->mLength; - RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true); - RAIL_WriteTxFifo(gRailHandle, aFrame->mPsdu, frameLength - 2, false); - - RAIL_SchedulerInfo_t txSchedulerInfo = { - .priority = RADIO_SCHEDULER_TX_PRIORITY, - .slipTime = RADIO_SCHEDULER_CHANNEL_SLIP_TIME, - .transactionTime = 0, // will be calculated later if DMP is used - }; - - if (aFrame->mPsdu[0] & IEEE802154_ACK_REQUEST) - { - txOptions |= RAIL_TX_OPTION_WAIT_FOR_ACK; - -#if RADIO_CONFIG_DMP_SUPPORT - // time we wait for ACK - if (RAIL_GetSymbolRate(gRailHandle) > 0) - { - txSchedulerInfo.transactionTime += 12 * 1e6 / RAIL_GetSymbolRate(gRailHandle); - } - else - { - txSchedulerInfo.transactionTime += 12 * RADIO_TIMING_DEFAULT_SYMBOLTIME_US; - } -#endif - } - -#if RADIO_CONFIG_DMP_SUPPORT - // time needed for the frame itself - // 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); - } - else - { // assume 250kbps - txSchedulerInfo.transactionTime = (frameLength + 4 + 1 + 1) * RADIO_TIMING_DEFAULT_BYTETIME_US; - } -#endif - - if (aFrame->mInfo.mTxInfo.mCsmaCaEnabled) - { -#if RADIO_CONFIG_DMP_SUPPORT - // time needed for CSMA/CA - txSchedulerInfo.transactionTime += RADIO_TIMING_CSMA_OVERHEAD_US; -#endif - csmaConfig.csmaTries = aFrame->mInfo.mTxInfo.mMaxCsmaBackoffs; - csmaConfig.ccaThreshold = sCcaThresholdDbm; - - status = RAIL_StartCcaCsmaTx(gRailHandle, aFrame->mChannel, txOptions, &csmaConfig, &txSchedulerInfo); - } - else - { - status = RAIL_StartTx(gRailHandle, aFrame->mChannel, txOptions, &txSchedulerInfo); - } - - if (status == RAIL_STATUS_NO_ERROR) - { -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailTxStarted++; -#endif - otPlatRadioTxStarted(aInstance, aFrame); - } - else - { -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailTxStartFailed++; -#endif - sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE; - sTransmitBusy = false; - otSysEventSignalPending(); - } - -exit: - return error; -} - -otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return &sTransmitFrame; -} - -int8_t otPlatRadioGetRssi(otInstance *aInstance) -{ - otError error; - uint32_t start; - int8_t rssi = OT_RADIO_RSSI_INVALID; - - OT_UNUSED_VARIABLE(aInstance); - - error = efr32StartEnergyScan(ENERGY_SCAN_MODE_SYNC, sReceiveFrame.mChannel, EFR32_RSSI_AVERAGING_TIME); - otEXPECT(error == OT_ERROR_NONE); - - start = RAIL_GetTime(); - - // waiting for the event RAIL_EVENT_RSSI_AVERAGE_DONE - while (sEnergyScanStatus == ENERGY_SCAN_STATUS_IN_PROGRESS && - ((RAIL_GetTime() - start) < EFR32_RSSI_AVERAGING_TIMEOUT)) - ; - - if (sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) - { - rssi = sEnergyScanResultDbm; - } - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; -exit: - return rssi; -} - -otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF | OT_RADIO_CAPS_ENERGY_SCAN; -} - -bool otPlatRadioGetPromiscuous(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return sPromiscuous; -} - -void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - sPromiscuous = aEnable; - - status = RAIL_IEEE802154_SetPromiscuousMode(gRailHandle, aEnable); - assert(status == RAIL_STATUS_NO_ERROR); -} - -void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) -{ - OT_UNUSED_VARIABLE(aInstance); - - // set Frame Pending bit for all outgoing ACKs if aEnable is false - sIsSrcMatchEnabled = aEnable; -} - -static bool sAckedWithFPFifoIsFull(void) -{ - return (uint32_t)(sAckedWithFPWriteIndex - sAckedWithFPReadIndex) == otARRAY_LENGTH(sAckedWithFPFifo); -} - -static bool sAckedWithFPFifoIsEmpty(void) -{ - return (uint32_t)(sAckedWithFPWriteIndex - sAckedWithFPReadIndex) == 0; -} - -static efr32AckedWithFP *sAckedWithFPFifoGetWriteSlot(void) -{ - uint32_t idx = sAckedWithFPWriteIndex & (otARRAY_LENGTH(sAckedWithFPFifo) - 1); - return &sAckedWithFPFifo[idx]; -} - -static const efr32AckedWithFP *sAckedWithFPFifoGetReadSlot(void) -{ - uint32_t idx = sAckedWithFPReadIndex & (otARRAY_LENGTH(sAckedWithFPFifo) - 1); - return &sAckedWithFPFifo[idx]; -} - -static void insertIeee802154DataRequestCommand(RAIL_Handle_t aRailHandle) -{ - assert(!sAckedWithFPFifoIsFull()); - efr32AckedWithFP *const slot = sAckedWithFPFifoGetWriteSlot(); - - RAIL_RxPacketInfo_t packetInfo; - - RAIL_GetRxIncomingPacketInfo(aRailHandle, &packetInfo); - assert(packetInfo.packetBytes >= 4); // PHR + FCF + DSN - - if (packetInfo.packetBytes > sizeof(slot->mPacket)) - { - packetInfo.packetBytes = sizeof(slot->mPacket); - if (packetInfo.firstPortionBytes >= sizeof(slot->mPacket)) - { - packetInfo.firstPortionBytes = sizeof(slot->mPacket); - packetInfo.lastPortionData = NULL; - } - } - slot->mLength = packetInfo.packetBytes; - RAIL_CopyRxPacket(slot->mPacket, &packetInfo); - - ++sAckedWithFPWriteIndex; -} - -static bool wasAckedWithFramePending(const uint8_t *aPsdu, uint8_t aPsduLength) -{ - bool ackedWithFramePending = false; - uint16_t fcf = aPsdu[IEEE802154_FCF_OFFSET] | (aPsdu[IEEE802154_FCF_OFFSET + 1] << 8); - - otEXPECT((fcf & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_MAC_COMMAND); - - while (!(ackedWithFramePending || sAckedWithFPFifoIsEmpty())) - { - const efr32AckedWithFP *const slot = sAckedWithFPFifoGetReadSlot(); - if ((slot->mPacket[0] == aPsduLength) && (memcmp(slot->mPacket + 1, aPsdu, slot->mLength - 1) == 0)) - { - ackedWithFramePending = true; - } - ++sAckedWithFPReadIndex; - } - -exit: - return ackedWithFramePending; -} - -static void processNextRxPacket(otInstance *aInstance) -{ - RAIL_RxPacketHandle_t packetHandle = RAIL_RX_PACKET_HANDLE_INVALID; - RAIL_RxPacketInfo_t packetInfo; - RAIL_RxPacketDetails_t packetDetails; - RAIL_Status_t status; - uint16_t length; - - packetHandle = RAIL_GetRxPacketInfo(gRailHandle, RAIL_RX_PACKET_HANDLE_OLDEST, &packetInfo); - - otEXPECT_ACTION(packetHandle != RAIL_RX_PACKET_HANDLE_INVALID && - packetInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS, - packetHandle = RAIL_RX_PACKET_HANDLE_INVALID); - - status = RAIL_GetRxPacketDetailsAlt(gRailHandle, packetHandle, &packetDetails); - otEXPECT(status == RAIL_STATUS_NO_ERROR); - - length = packetInfo.packetBytes + 1; - - // check the length in recv packet info structure; RAIL should take care of this. - assert(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); - - otLogInfoPlat("Received data:%d", length); - - // skip length byte - assert(packetInfo.firstPortionBytes > 0); - packetInfo.firstPortionData++; - packetInfo.firstPortionBytes--; - packetInfo.packetBytes--; - - // read packet - RAIL_CopyRxPacket(sReceiveFrame.mPsdu, &packetInfo); - - status = RAIL_ReleaseRxPacket(gRailHandle, packetHandle); - if (status == RAIL_STATUS_NO_ERROR) - { - packetHandle = RAIL_RX_PACKET_HANDLE_INVALID; - } - - sReceiveFrame.mLength = length; - - if (packetDetails.isAck) - { - assert((length == IEEE802154_ACK_LENGTH) && - (sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_ACK); - - RAIL_YieldRadio(gRailHandle); - sTransmitBusy = false; - - if (sReceiveFrame.mPsdu[IEEE802154_DSN_OFFSET] == sTransmitFrame.mPsdu[IEEE802154_DSN_OFFSET]) - { - sTransmitError = OT_ERROR_NONE; - } - else - { - sTransmitError = OT_ERROR_NO_ACK; - } - } - else - { - // signal MAC layer for each received frame if promiscuous is enabled - // otherwise only signal MAC layer for non-ACK frame - otEXPECT(sPromiscuous || (length != IEEE802154_ACK_LENGTH)); - - sReceiveError = OT_ERROR_NONE; - - sReceiveFrame.mInfo.mRxInfo.mRssi = packetDetails.rssi; - sReceiveFrame.mInfo.mRxInfo.mLqi = packetDetails.lqi; - - // Get the timestamp when the SFD was received - assert(packetDetails.timeReceived.timePosition != RAIL_PACKET_TIME_INVALID); - packetDetails.timeReceived.totalPacketBytes = length + 1; - - status = RAIL_GetRxTimeSyncWordEndAlt(gRailHandle, &packetDetails); - assert(status == RAIL_STATUS_NO_ERROR); - 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); - -#if OPENTHREAD_CONFIG_DIAG_ENABLE - - if (otPlatDiagModeGet()) - { - otPlatDiagRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); - } - else -#endif - { - otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength); - otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioReceiveDoneCbCount++; -#endif - } - } - - otSysEventSignalPending(); - -exit: - - if (packetHandle != RAIL_RX_PACKET_HANDLE_INVALID) - { - RAIL_ReleaseRxPacket(gRailHandle, packetHandle); - } -} - -static void ieee802154DataRequestCommand(RAIL_Handle_t aRailHandle) -{ - RAIL_Status_t status; - - if (sIsSrcMatchEnabled) - { - RAIL_IEEE802154_Address_t sourceAddress; - - status = RAIL_IEEE802154_GetAddress(aRailHandle, &sourceAddress); - assert(status == RAIL_STATUS_NO_ERROR); - - if ((sourceAddress.length == RAIL_IEEE802154_LongAddress && - utilsSoftSrcMatchExtFindEntry((otExtAddress *)sourceAddress.longAddress) >= 0) || - (sourceAddress.length == RAIL_IEEE802154_ShortAddress && - utilsSoftSrcMatchShortFindEntry(sourceAddress.shortAddress) >= 0)) - { - status = RAIL_IEEE802154_SetFramePending(aRailHandle); - assert(status == RAIL_STATUS_NO_ERROR); - insertIeee802154DataRequestCommand(aRailHandle); - } - } - else - { - status = RAIL_IEEE802154_SetFramePending(aRailHandle); - assert(status == RAIL_STATUS_NO_ERROR); - insertIeee802154DataRequestCommand(aRailHandle); - } -} - -static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents) -{ -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - if (aEvents & RAIL_EVENT_CONFIG_SCHEDULED) - { - sRailDebugCounters.mRailEventConfigScheduled++; - } - if (aEvents & RAIL_EVENT_CONFIG_UNSCHEDULED) - { - sRailDebugCounters.mRailEventConfigUnScheduled++; - } -#endif - if (aEvents & RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND) - { - ieee802154DataRequestCommand(aRailHandle); - } - - if (aEvents & RAIL_EVENTS_TX_COMPLETION) - { - if (aEvents & RAIL_EVENT_TX_PACKET_SENT) - { - if ((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = false; - } -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventPacketSent++; -#endif - } - else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventChannelBusy++; -#endif - } - else - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_ABORT; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventTxAbort++; -#endif - } - } - - if (aEvents & RAIL_EVENT_RX_ACK_TIMEOUT) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_NO_ACK; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventNoAck++; -#endif - } - - if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED) - { - RAIL_HoldRxPacket(aRailHandle); -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventPacketReceived++; -#endif - } - - if (aEvents & RAIL_EVENT_CAL_NEEDED) - { - RAIL_Status_t status; - - status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING); - assert(status == RAIL_STATUS_NO_ERROR); - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventCalNeeded++; -#endif - } - - if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE) - { - const int16_t energyScanResultQuarterDbm = RAIL_GetAverageRssi(aRailHandle); - RAIL_YieldRadio(aRailHandle); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_COMPLETED; - - if (energyScanResultQuarterDbm == RAIL_RSSI_INVALID) - { - sEnergyScanResultDbm = OT_RADIO_RSSI_INVALID; - } - else - { - sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM; - } - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioEnergyScanDoneCbCount++; -#endif - } - if (aEvents & RAIL_EVENT_SCHEDULER_STATUS) - { - RAIL_SchedulerStatus_t status = RAIL_GetSchedulerStatus(aRailHandle); - - assert(status != RAIL_SCHEDULER_STATUS_INTERNAL_ERROR); - - if (status == RAIL_SCHEDULER_STATUS_CCA_CSMA_TX_FAIL || status == RAIL_SCHEDULER_STATUS_SINGLE_TX_FAIL || - status == RAIL_SCHEDULER_STATUS_SCHEDULED_TX_FAIL || - (status == RAIL_SCHEDULER_STATUS_SCHEDULE_FAIL && sTransmitBusy) || - (status == RAIL_SCHEDULER_STATUS_EVENT_INTERRUPTED && sTransmitBusy)) - { - sTransmitError = OT_ERROR_ABORT; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventSchedulerStatusError++; -#endif - } - else if (status == RAIL_SCHEDULER_STATUS_AVERAGE_RSSI_FAIL) - { - sEnergyScanStatus = ENERGY_SCAN_STATUS_COMPLETED; - sEnergyScanResultDbm = OT_RADIO_RSSI_INVALID; - } -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - else if (sTransmitBusy) - { - sRailDebugCounters.mRailEventsSchedulerStatusLastStatus = status; - sRailDebugCounters.mRailEventsSchedulerStatusTransmitBusy++; - } -#endif - } - - otSysEventSignalPending(); -} - -otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) -{ - OT_UNUSED_VARIABLE(aInstance); - - return efr32StartEnergyScan(ENERGY_SCAN_MODE_ASYNC, aScanChannel, (RAIL_Time_t)aScanDuration * US_IN_MS); -} - -void efr32RadioProcess(otInstance *aInstance) -{ - // We should process the received packet first. Adding it at the end of this function, - // will delay the stack notification until the next call to efr32RadioProcess() - processNextRxPacket(aInstance); - - if (sState == OT_RADIO_STATE_TRANSMIT && sTransmitBusy == false) - { - if (sTransmitError != OT_ERROR_NONE) - { - otLogDebgPlat("Transmit failed ErrorCode=%d", sTransmitError); - } - - sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_CONFIG_DIAG_ENABLE - if (otPlatDiagModeGet()) - { - otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, sTransmitError); - } - else -#endif - if (((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) || (sTransmitError != OT_ERROR_NONE)) - { - otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, sTransmitError); - } - else - { - otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError); - } - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioTxDoneCbCount++; -#endif - - otSysEventSignalPending(); - } - else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) - { - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; - otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm); - otSysEventSignalPending(); - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventEnergyScanCompleted++; -#endif - } -} - -otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - - otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); - *aPower = sTxPowerDbm; - -exit: - return error; -} - -otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPower) * 10); - assert(status == RAIL_STATUS_NO_ERROR); - - sTxPowerDbm = aPower; - - return OT_ERROR_NONE; -} - -otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - otEXPECT_ACTION(aThreshold != NULL, error = OT_ERROR_INVALID_ARGS); - - *aThreshold = sCcaThresholdDbm; - -exit: - return error; -} - -otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold) -{ - OT_UNUSED_VARIABLE(aInstance); - - sCcaThresholdDbm = aThreshold; - - return OT_ERROR_NONE; -} - -int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return EFR32_RECEIVE_SENSITIVITY; -} - -RAIL_AntennaConfig_t halAntennaConfig; - -void initAntenna(void) -{ -#if (HAL_ANTDIV_ENABLE && defined(BSP_ANTDIV_SEL_PORT) && defined(BSP_ANTDIV_SEL_PIN) && defined(BSP_ANTDIV_SEL_LOC)) - halAntennaConfig.ant0PinEn = true; - halAntennaConfig.ant0Port = (uint8_t)BSP_ANTDIV_SEL_PORT; - halAntennaConfig.ant0Pin = BSP_ANTDIV_SEL_PIN; - halAntennaConfig.ant0Loc = BSP_ANTDIV_SEL_LOC; -#endif -#ifdef _SILICON_LABS_32B_SERIES_2 - halAntennaConfig.defaultPath = BSP_ANTDIV_SEL_LOC; -#endif -#if (HAL_ANTDIV_ENABLE && defined(BSP_ANTDIV_NSEL_PORT) && defined(BSP_ANTDIV_NSEL_PIN) && defined(BSP_ANTDIV_NSEL_LOC)) - halAntennaConfig.ant1PinEn = true; - halAntennaConfig.ant1Port = (uint8_t)BSP_ANTDIV_NSEL_PORT; - halAntennaConfig.ant1Pin = BSP_ANTDIV_NSEL_PIN; - halAntennaConfig.ant1Loc = BSP_ANTDIV_NSEL_LOC; -#endif -#if (HAL_ANTDIV_ENABLE || defined(_SILICON_LABS_32B_SERIES_2)) - (void)RAIL_ConfigAntenna(RAIL_EFR32_HANDLE, &halAntennaConfig); -#endif -} diff --git a/examples/platforms/efr32mg12/rail_config.h b/examples/platforms/efr32mg12/rail_config.h deleted file mode 100644 index 5a62825a9..000000000 --- a/examples/platforms/efr32mg12/rail_config.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __RAIL_CONFIG_H__ -#define __RAIL_CONFIG_H__ - -#include "board_config.h" -#include "rail_types.h" -#include - -#define RADIO_CONFIG_XTAL_FREQUENCY 38400000UL - -#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT -extern const RAIL_ChannelConfig_t *channelConfigs[]; -#endif - -#endif // __RAIL_CONFIG_H__ diff --git a/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/Makefile.am b/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/Makefile.am deleted file mode 100644 index ce90b4bed..000000000 --- a/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/Makefile.am +++ /dev/null @@ -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 diff --git a/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/main.c b/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/main.c deleted file mode 100644 index 7a489b1b9..000000000 --- a/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/main.c +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// 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); -} diff --git a/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-mtd/Makefile.am b/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-mtd/Makefile.am deleted file mode 100644 index 91aba9b59..000000000 --- a/examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-mtd/Makefile.am +++ /dev/null @@ -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 diff --git a/examples/platforms/efr32mg12/startup-gcc.c b/examples/platforms/efr32mg12/startup-gcc.c deleted file mode 100644 index 85c9e2aa5..000000000 --- a/examples/platforms/efr32mg12/startup-gcc.c +++ /dev/null @@ -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) - ; -} diff --git a/examples/platforms/efr32mg12/system.c b/examples/platforms/efr32mg12/system.c deleted file mode 100644 index b33c543f7..000000000 --- a/examples/platforms/efr32mg12/system.c +++ /dev/null @@ -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 -#include - -#include -#include - -#include "openthread-system.h" -#include - -#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 -} diff --git a/examples/platforms/efr32mg13/Makefile.am b/examples/platforms/efr32mg13/Makefile.am deleted file mode 100644 index 4673b9935..000000000 --- a/examples/platforms/efr32mg13/Makefile.am +++ /dev/null @@ -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 diff --git a/examples/platforms/efr32mg13/alarm.c b/examples/platforms/efr32mg13/alarm.c deleted file mode 100644 index 71a39c089..000000000 --- a/examples/platforms/efr32mg13/alarm.c +++ /dev/null @@ -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 -#include -#include - -#include "openthread-system.h" -#include -#include -#include -#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); - } - } - } -} diff --git a/examples/platforms/efr32mg13/crypto/mbedtls_config.h b/examples/platforms/efr32mg13/crypto/mbedtls_config.h deleted file mode 100644 index 95f829ffb..000000000 --- a/examples/platforms/efr32mg13/crypto/mbedtls_config.h +++ /dev/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 >>> -// TLS/DTLS configuration - -// Complete list of ciphersuites to use, in order of preference. -// Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 -// Complete list of ciphersuites to use, in order of preference. -// The value of this configuration should be updated for the application needs. -#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 - -// Maximum TLS/DTLS fragment length in bytes. -// Default: 768 -// The size configured here determines the size of each of the two -// internal I/O buffers used in mbedTLS when sending and receiving data. -#define MBEDTLS_SSL_MAX_CONTENT_LEN 768 - -// Enable support for RFC 6066 max_fragment_length extension in SSL. -// Default: 1 -// Enable support for RFC 6066 max_fragment_length extension in SSL. -#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1 - -// Enable support for exporting key block and master secret. -// Default: 1 -// Enable support for exporting key block and master secret. -// This is required for certain users of TLS, e.g. EAP-TLS. -#define SL_MBEDTLS_SSL_EXPORT_KEYS 1 - -// Enable the PSK based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the PSK based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 1 - -// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0 - -// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 1 - -// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 - -// -// <<< 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 diff --git a/examples/platforms/efr32mg13/diag.c b/examples/platforms/efr32mg13/diag.c deleted file mode 100644 index a7c335754..000000000 --- a/examples/platforms/efr32mg13/diag.c +++ /dev/null @@ -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 -#include -#include -#include - -#include -#include -#include - -#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 diff --git a/examples/platforms/efr32mg13/entropy.c b/examples/platforms/efr32mg13/entropy.c deleted file mode 100644 index 2b196bbba..000000000 --- a/examples/platforms/efr32mg13/entropy.c +++ /dev/null @@ -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 - -#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; -} diff --git a/examples/platforms/efr32mg13/fem-control.c b/examples/platforms/efr32mg13/fem-control.c deleted file mode 100644 index f66415c19..000000000 --- a/examples/platforms/efr32mg13/fem-control.c +++ /dev/null @@ -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 diff --git a/examples/platforms/efr32mg13/flash.c b/examples/platforms/efr32mg13/flash.c deleted file mode 100644 index 4f3596974..000000000 --- a/examples/platforms/efr32mg13/flash.c +++ /dev/null @@ -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 -#include - -#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE // Use OT NV system - -#include "em_msc.h" -#include -#include - -#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 -#include -#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 diff --git a/examples/platforms/efr32mg13/logging.c b/examples/platforms/efr32mg13/logging.c deleted file mode 100644 index fa0a4dde9..000000000 --- a/examples/platforms/efr32mg13/logging.c +++ /dev/null @@ -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 -#include -#include -#include - -#include - -#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 diff --git a/examples/platforms/efr32mg13/misc.c b/examples/platforms/efr32mg13/misc.c deleted file mode 100644 index 4b2076fdc..000000000 --- a/examples/platforms/efr32mg13/misc.c +++ /dev/null @@ -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 - -#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. -} diff --git a/examples/platforms/efr32mg13/openthread-core-efr32-config-check.h b/examples/platforms/efr32mg13/openthread-core-efr32-config-check.h deleted file mode 100644 index a6bfb62f7..000000000 --- a/examples/platforms/efr32mg13/openthread-core-efr32-config-check.h +++ /dev/null @@ -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 efr32mg13 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 efr32mg13 not configured to support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT" -#endif -#endif - -#endif /* OPENTHREAD_CORE_EFR32_CONFIG_CHECK_H_ */ diff --git a/examples/platforms/efr32mg13/openthread-core-efr32-config.h b/examples/platforms/efr32mg13/openthread-core-efr32-config.h deleted file mode 100644 index d1cbde654..000000000 --- a/examples/platforms/efr32mg13/openthread-core-efr32-config.h +++ /dev/null @@ -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_ diff --git a/examples/platforms/efr32mg13/platform-efr32.h b/examples/platforms/efr32mg13/platform-efr32.h deleted file mode 100644 index 5ec48e216..000000000 --- a/examples/platforms/efr32mg13/platform-efr32.h +++ /dev/null @@ -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 - -#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_ diff --git a/examples/platforms/efr32mg13/radio.c b/examples/platforms/efr32mg13/radio.c deleted file mode 100644 index ad7cc4b14..000000000 --- a/examples/platforms/efr32mg13/radio.c +++ /dev/null @@ -1,1199 +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 radio communication. - * - */ - -#include -#include - -#include - -#include "openthread-system.h" -#include -#include -#include -#include - -#include "common/logging.hpp" -#include "utils/code_utils.h" - -#include "utils/soft_source_match_table.h" - -#include "board_config.h" -#include "em_cmu.h" -#include "em_core.h" -#include "em_system.h" -#include "hal-config.h" -#include "pa_conversions_efr32.h" -#include "platform-band.h" -#include "rail.h" -#include "rail_config.h" -#include "rail_ieee802154.h" - -enum -{ - IEEE802154_MIN_LENGTH = 5, - IEEE802154_MAX_LENGTH = 127, - IEEE802154_ACK_LENGTH = 5, - - // FCF + DSN + dest PANID + dest addr + src PANID + src addr (without security header) - IEEE802154_MAX_MHR_LENGTH = 2 + 1 + 2 + 8 + 2 + 8, - - 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, -}; - -enum -{ - EFR32_RECEIVE_SENSITIVITY = -100, // dBm - EFR32_RSSI_AVERAGING_TIME = 16, // us - EFR32_RSSI_AVERAGING_TIMEOUT = 300, // us -}; - -enum -{ - EFR32_SCHEDULER_SAMPLE_RSSI_PRIORITY = 10, // High priority - EFR32_SCHEDULER_TX_PRIORITY = 10, // High priority - EFR32_SCHEDULER_RX_PRIORITY = 20, // Low priority -}; - -enum -{ -#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT && RADIO_CONFIG_915MHZ_OQPSK_SUPPORT - EFR32_NUM_BAND_CONFIGS = 2, -#else - EFR32_NUM_BAND_CONFIGS = 1, -#endif -}; - -typedef enum -{ - ENERGY_SCAN_STATUS_IDLE, - ENERGY_SCAN_STATUS_IN_PROGRESS, - ENERGY_SCAN_STATUS_COMPLETED -} energyScanStatus; - -typedef enum -{ - ENERGY_SCAN_MODE_SYNC, - ENERGY_SCAN_MODE_ASYNC -} energyScanMode; - -RAIL_Handle_t gRailHandle; - -static volatile bool sTransmitBusy = false; -static bool sPromiscuous = false; -static otRadioState sState = OT_RADIO_STATE_DISABLED; - -enum -{ - ACKED_WITH_FP_MATCH_LENGTH = 1 + IEEE802154_MAX_MHR_LENGTH, // PHR and MHR - ACKED_WITH_FP_SLOTS = 16, // maximum number of Data Request packets in the RX FIFO. Length should be a power of 2. -}; - -typedef struct efr32AckedWithFP -{ - uint8_t mLength; - uint8_t mPacket[ACKED_WITH_FP_MATCH_LENGTH]; -} efr32AckedWithFP; -static bool sIsSrcMatchEnabled = false; -static efr32AckedWithFP sAckedWithFPFifo[ACKED_WITH_FP_SLOTS]; -static uint32_t sAckedWithFPReadIndex; -static volatile uint32_t sAckedWithFPWriteIndex; - -static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH]; -static otRadioFrame sReceiveFrame; -static otError sReceiveError; - -static otRadioFrame sTransmitFrame; -static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH]; -static volatile otError sTransmitError; - -static efr32CommonConfig sCommonConfig; -static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS]; - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT -static efr32RadioCounters sRailDebugCounters; -#endif - -static volatile energyScanStatus sEnergyScanStatus; -static volatile int8_t sEnergyScanResultDbm; -static energyScanMode sEnergyScanMode; - -#define QUARTER_DBM_IN_DBM 4 -#define US_IN_MS 1000 - -static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents); - -static const RAIL_IEEE802154_Config_t sRailIeee802154Config = { - .addresses = NULL, - .ackConfig = - { - .enable = true, - .ackTimeout = 864, - .rxTransitions = - { - .success = RAIL_RF_STATE_RX, - .error = RAIL_RF_STATE_RX, - }, - .txTransitions = - { - .success = RAIL_RF_STATE_RX, - .error = RAIL_RF_STATE_RX, - }, - }, - .timings = - { - .idleToRx = 100, - .txToRx = 192 - 10, - .idleToTx = 100, - .rxToTx = 192, - .rxSearchTimeout = 0, - .txToRxSearchTimeout = 0, - }, - .framesMask = RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES, - .promiscuousMode = false, - .isPanCoordinator = 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 - -static efr32BandConfig *sCurrentBandConfig = NULL; - -static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig) -{ - RAIL_Status_t status; - RAIL_Handle_t handle; - - handle = RAIL_Init(&aCommonConfig->mRailConfig, NULL); - assert(handle != NULL); - - status = RAIL_ConfigCal(handle, RAIL_CAL_ALL); - assert(status == RAIL_STATUS_NO_ERROR); - - status = RAIL_IEEE802154_Init(handle, &sRailIeee802154Config); - assert(status == RAIL_STATUS_NO_ERROR); - - status = RAIL_ConfigEvents(handle, RAIL_EVENTS_ALL, - RAIL_EVENT_RX_ACK_TIMEOUT | // - RAIL_EVENTS_TX_COMPLETION | // - RAIL_EVENT_RX_PACKET_RECEIVED | // - RAIL_EVENT_RSSI_AVERAGE_DONE | // - RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | // - RAIL_EVENT_CAL_NEEDED | // -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - RAIL_EVENT_CONFIG_SCHEDULED | // - RAIL_EVENT_CONFIG_UNSCHEDULED | // -#endif - RAIL_EVENT_SCHEDULER_STATUS // - ); - assert(status == RAIL_STATUS_NO_ERROR); - - uint16_t actualLenth = RAIL_SetTxFifo(handle, aCommonConfig->mRailTxFifo, 0, sizeof(aCommonConfig->mRailTxFifo)); - assert(actualLenth == 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, BSP_PA_VOLTAGE, 10}; -#else - RAIL_TxPowerConfig_t txPowerConfig = {RAIL_TX_POWER_MODE_2P4_HP, BSP_PA_VOLTAGE, 10}; -#endif - if (aBandConfig->mChannelConfig != NULL) - { - uint16_t firstChannel = RAIL_ConfigChannels(gRailHandle, aBandConfig->mChannelConfig, NULL); - assert(firstChannel == aBandConfig->mChannelMin); - - txPowerConfig.mode = RAIL_TX_POWER_MODE_SUBGIG; - } - else - { - 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); - - status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPowerDbm) * 10); - assert(status == RAIL_STATUS_NO_ERROR); -} - -static efr32BandConfig *efr32RadioGetBandConfig(uint8_t aChannel) -{ - efr32BandConfig *config = NULL; - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - if ((sBandConfigs[i].mChannelMin <= aChannel) && (aChannel <= sBandConfigs[i].mChannelMax)) - { - config = &sBandConfigs[i]; - break; - } - } - - return config; -} - -static void efr32ConfigInit(void (*aEventCallback)(RAIL_Handle_t railHandle, RAIL_Events_t events)) -{ - sCommonConfig.mRailConfig.eventsCallback = aEventCallback; - sCommonConfig.mRailConfig.protocol = NULL; // only used by Bluetooth stack -#if RADIO_CONFIG_DMP_SUPPORT - sCommonConfig.mRailConfig.scheduler = &(sCommonConfig.railSchedState); -#else - sCommonConfig.mRailConfig.scheduler = NULL; // only needed for DMP -#endif - - uint8_t index = 0; - -#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT - sBandConfigs[index].mChannelConfig = NULL; - sBandConfigs[index].mChannelMin = OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN; - sBandConfigs[index].mChannelMax = OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX; - - index++; -#endif - -#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT - sBandConfigs[index].mChannelConfig = channelConfigs[0]; - sBandConfigs[index].mChannelMin = OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN; - sBandConfigs[index].mChannelMax = OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX; -#endif - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - memset(&sRailDebugCounters, 0x00, sizeof(efr32RadioCounters)); -#endif - - gRailHandle = efr32RailInit(&sCommonConfig); - assert(gRailHandle != NULL); - efr32RailConfigLoad(&(sBandConfigs[0])); -} - -void efr32RadioInit(void) -{ - RAIL_Status_t status; - - // check if RAIL_TX_FIFO_SIZE is power of two.. - assert((RAIL_TX_FIFO_SIZE & (RAIL_TX_FIFO_SIZE - 1)) == 0); - - // check the limits of the RAIL_TX_FIFO_SIZE. - assert((RAIL_TX_FIFO_SIZE >= 64) || (RAIL_TX_FIFO_SIZE <= 4096)); - - efr32ConfigInit(RAILCb_Generic); - - CMU_ClockEnable(cmuClock_PRS, true); - - status = RAIL_ConfigSleep(gRailHandle, RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED); - assert(status == RAIL_STATUS_NO_ERROR); - - sReceiveFrame.mLength = 0; - sReceiveFrame.mPsdu = sReceivePsdu; - sTransmitFrame.mLength = 0; - sTransmitFrame.mPsdu = sTransmitPsdu; - - sCurrentBandConfig = efr32RadioGetBandConfig(OPENTHREAD_CONFIG_DEFAULT_CHANNEL); - assert(sCurrentBandConfig != NULL); - - memset(sAckedWithFPFifo, 0, sizeof(sAckedWithFPFifo)); - sAckedWithFPWriteIndex = 0; - sAckedWithFPReadIndex = 0; - - efr32RadioSetTxPower(sTxPowerDbm); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = false; - - otLogInfoPlat("Initialized", NULL); -} - -void efr32RadioDeinit(void) -{ - RAIL_Status_t status; - - RAIL_Idle(gRailHandle, RAIL_IDLE_ABORT, true); - status = RAIL_ConfigEvents(gRailHandle, RAIL_EVENTS_ALL, 0); - assert(status == RAIL_STATUS_NO_ERROR); - - sCurrentBandConfig = NULL; -} - -static otError efr32StartEnergyScan(energyScanMode aMode, uint16_t aChannel, RAIL_Time_t aAveragingTimeUs) -{ - RAIL_Status_t status; - otError error = OT_ERROR_NONE; - efr32BandConfig *config = NULL; - - otEXPECT_ACTION(sEnergyScanStatus == ENERGY_SCAN_STATUS_IDLE, error = OT_ERROR_BUSY); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IN_PROGRESS; - sEnergyScanMode = aMode; - - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - - config = efr32RadioGetBandConfig(aChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - if (sCurrentBandConfig != config) - { - efr32RailConfigLoad(config); - sCurrentBandConfig = config; - } - - RAIL_SchedulerInfo_t scanSchedulerInfo = {.priority = RADIO_SCHEDULER_CHANNEL_SCAN_PRIORITY, - .slipTime = RADIO_SCHEDULER_CHANNEL_SLIP_TIME, - .transactionTime = aAveragingTimeUs}; - - status = RAIL_StartAverageRssi(gRailHandle, aChannel, aAveragingTimeUs, &scanSchedulerInfo); - otEXPECT_ACTION(status == RAIL_STATUS_NO_ERROR, error = OT_ERROR_FAILED); - -exit: - return error; -} - -void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) -{ - OT_UNUSED_VARIABLE(aInstance); - - uint64_t eui64; - uint8_t *eui64Ptr = NULL; - - eui64 = SYSTEM_GetUnique(); - eui64Ptr = (uint8_t *)&eui64; - - for (uint8_t i = 0; i < OT_EXT_ADDRESS_SIZE; i++) - { - aIeeeEui64[i] = eui64Ptr[(OT_EXT_ADDRESS_SIZE - 1) - i]; - } -} - -void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("PANID=%X", aPanId); - - utilsSoftSrcMatchSetPanId(aPanId); - - status = RAIL_IEEE802154_SetPanId(gRailHandle, aPanId, 0); - assert(status == RAIL_STATUS_NO_ERROR); -} - -void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("ExtAddr=%X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4], - aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]); - - status = RAIL_IEEE802154_SetLongAddress(gRailHandle, (uint8_t *)aAddress->m8, 0); - assert(status == RAIL_STATUS_NO_ERROR); -} - -void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("ShortAddr=%X", aAddress); - - status = RAIL_IEEE802154_SetShortAddress(gRailHandle, aAddress, 0); - assert(status == RAIL_STATUS_NO_ERROR); -} - -bool otPlatRadioIsEnabled(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return (sState != OT_RADIO_STATE_DISABLED); -} - -otError otPlatRadioEnable(otInstance *aInstance) -{ - otEXPECT(!otPlatRadioIsEnabled(aInstance)); - - otLogInfoPlat("State=OT_RADIO_STATE_SLEEP", NULL); - sState = OT_RADIO_STATE_SLEEP; - -exit: - return OT_ERROR_NONE; -} - -otError otPlatRadioDisable(otInstance *aInstance) -{ - otEXPECT(otPlatRadioIsEnabled(aInstance)); - - otLogInfoPlat("State=OT_RADIO_STATE_DISABLED", NULL); - sState = OT_RADIO_STATE_DISABLED; - -exit: - return OT_ERROR_NONE; -} - -otError otPlatRadioSleep(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - - otEXPECT_ACTION((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED), - error = OT_ERROR_INVALID_STATE); - - otLogInfoPlat("State=OT_RADIO_STATE_SLEEP", NULL); - - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - sState = OT_RADIO_STATE_SLEEP; - -exit: - return error; -} - -otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) -{ - otError error = OT_ERROR_NONE; - RAIL_Status_t status; - efr32BandConfig *config; - - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION(sState != OT_RADIO_STATE_DISABLED, error = OT_ERROR_INVALID_STATE); - - config = efr32RadioGetBandConfig(aChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - if (sCurrentBandConfig != config) - { - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - efr32RailConfigLoad(config); - sCurrentBandConfig = config; - } - - RAIL_SchedulerInfo_t bgRxSchedulerInfo = { - .priority = RADIO_SCHEDULER_BACKGROUND_RX_PRIORITY, - // sliptime/transaction time is not used for bg rx - }; - - status = RAIL_StartRx(gRailHandle, aChannel, &bgRxSchedulerInfo); - otEXPECT_ACTION(status == RAIL_STATUS_NO_ERROR, error = OT_ERROR_FAILED); - - otLogInfoPlat("State=OT_RADIO_STATE_RECEIVE", NULL); - sState = OT_RADIO_STATE_RECEIVE; - sReceiveFrame.mChannel = aChannel; - -exit: - return error; -} - -otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) -{ - otError error = OT_ERROR_NONE; - RAIL_CsmaConfig_t csmaConfig = RAIL_CSMA_CONFIG_802_15_4_2003_2p4_GHz_OQPSK_CSMA; - RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_DEFAULT; - efr32BandConfig * config; - RAIL_Status_t status; - uint8_t frameLength; - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatTxTriggered++; -#endif - - assert(sTransmitBusy == false); - - otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT), - error = OT_ERROR_INVALID_STATE); - - config = efr32RadioGetBandConfig(aFrame->mChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - sState = OT_RADIO_STATE_TRANSMIT; - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = true; - - if (sCurrentBandConfig != config) - { - RAIL_Idle(gRailHandle, RAIL_IDLE, true); - efr32RailConfigLoad(config); - sCurrentBandConfig = config; - } - - frameLength = (uint8_t)aFrame->mLength; - RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true); - RAIL_WriteTxFifo(gRailHandle, aFrame->mPsdu, frameLength - 2, false); - - RAIL_SchedulerInfo_t txSchedulerInfo = { - .priority = RADIO_SCHEDULER_TX_PRIORITY, - .slipTime = RADIO_SCHEDULER_CHANNEL_SLIP_TIME, - .transactionTime = 0, // will be calculated later if DMP is used - }; - - if (aFrame->mPsdu[0] & IEEE802154_ACK_REQUEST) - { - txOptions |= RAIL_TX_OPTION_WAIT_FOR_ACK; - -#if RADIO_CONFIG_DMP_SUPPORT - // time we wait for ACK - if (RAIL_GetSymbolRate(gRailHandle) > 0) - { - txSchedulerInfo.transactionTime += 12 * 1e6 / RAIL_GetSymbolRate(gRailHandle); - } - else - { - txSchedulerInfo.transactionTime += 12 * RADIO_TIMING_DEFAULT_SYMBOLTIME_US; - } -#endif - } - -#if RADIO_CONFIG_DMP_SUPPORT - // time needed for the frame itself - // 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); - } - else - { // assume 250kbps - txSchedulerInfo.transactionTime = (frameLength + 4 + 1 + 1) * RADIO_TIMING_DEFAULT_BYTETIME_US; - } -#endif - - if (aFrame->mInfo.mTxInfo.mCsmaCaEnabled) - { -#if RADIO_CONFIG_DMP_SUPPORT - // time needed for CSMA/CA - txSchedulerInfo.transactionTime += RADIO_TIMING_CSMA_OVERHEAD_US; -#endif - csmaConfig.csmaTries = aFrame->mInfo.mTxInfo.mMaxCsmaBackoffs; - csmaConfig.ccaThreshold = sCcaThresholdDbm; - - status = RAIL_StartCcaCsmaTx(gRailHandle, aFrame->mChannel, txOptions, &csmaConfig, &txSchedulerInfo); - } - else - { - status = RAIL_StartTx(gRailHandle, aFrame->mChannel, txOptions, &txSchedulerInfo); - } - - if (status == RAIL_STATUS_NO_ERROR) - { -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailTxStarted++; -#endif - otPlatRadioTxStarted(aInstance, aFrame); - } - else - { -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailTxStartFailed++; -#endif - sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE; - sTransmitBusy = false; - otSysEventSignalPending(); - } - -exit: - return error; -} - -otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return &sTransmitFrame; -} - -int8_t otPlatRadioGetRssi(otInstance *aInstance) -{ - otError error; - uint32_t start; - int8_t rssi = OT_RADIO_RSSI_INVALID; - - OT_UNUSED_VARIABLE(aInstance); - - error = efr32StartEnergyScan(ENERGY_SCAN_MODE_SYNC, sReceiveFrame.mChannel, EFR32_RSSI_AVERAGING_TIME); - otEXPECT(error == OT_ERROR_NONE); - - start = RAIL_GetTime(); - - // waiting for the event RAIL_EVENT_RSSI_AVERAGE_DONE - while (sEnergyScanStatus == ENERGY_SCAN_STATUS_IN_PROGRESS && - ((RAIL_GetTime() - start) < EFR32_RSSI_AVERAGING_TIMEOUT)) - ; - - if (sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) - { - rssi = sEnergyScanResultDbm; - } - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; -exit: - return rssi; -} - -otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF | OT_RADIO_CAPS_ENERGY_SCAN; -} - -bool otPlatRadioGetPromiscuous(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return sPromiscuous; -} - -void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - sPromiscuous = aEnable; - - status = RAIL_IEEE802154_SetPromiscuousMode(gRailHandle, aEnable); - assert(status == RAIL_STATUS_NO_ERROR); -} - -void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) -{ - OT_UNUSED_VARIABLE(aInstance); - - // set Frame Pending bit for all outgoing ACKs if aEnable is false - sIsSrcMatchEnabled = aEnable; -} - -static bool sAckedWithFPFifoIsFull(void) -{ - return (uint32_t)(sAckedWithFPWriteIndex - sAckedWithFPReadIndex) == otARRAY_LENGTH(sAckedWithFPFifo); -} - -static bool sAckedWithFPFifoIsEmpty(void) -{ - return (uint32_t)(sAckedWithFPWriteIndex - sAckedWithFPReadIndex) == 0; -} - -static efr32AckedWithFP *sAckedWithFPFifoGetWriteSlot(void) -{ - uint32_t idx = sAckedWithFPWriteIndex & (otARRAY_LENGTH(sAckedWithFPFifo) - 1); - return &sAckedWithFPFifo[idx]; -} - -static const efr32AckedWithFP *sAckedWithFPFifoGetReadSlot(void) -{ - uint32_t idx = sAckedWithFPReadIndex & (otARRAY_LENGTH(sAckedWithFPFifo) - 1); - return &sAckedWithFPFifo[idx]; -} - -static void insertIeee802154DataRequestCommand(RAIL_Handle_t aRailHandle) -{ - assert(!sAckedWithFPFifoIsFull()); - efr32AckedWithFP *const slot = sAckedWithFPFifoGetWriteSlot(); - - RAIL_RxPacketInfo_t packetInfo; - - RAIL_GetRxIncomingPacketInfo(aRailHandle, &packetInfo); - assert(packetInfo.packetBytes >= 4); // PHR + FCF + DSN - - if (packetInfo.packetBytes > sizeof(slot->mPacket)) - { - packetInfo.packetBytes = sizeof(slot->mPacket); - if (packetInfo.firstPortionBytes >= sizeof(slot->mPacket)) - { - packetInfo.firstPortionBytes = sizeof(slot->mPacket); - packetInfo.lastPortionData = NULL; - } - } - slot->mLength = packetInfo.packetBytes; - RAIL_CopyRxPacket(slot->mPacket, &packetInfo); - - ++sAckedWithFPWriteIndex; -} - -static bool wasAckedWithFramePending(const uint8_t *aPsdu, uint8_t aPsduLength) -{ - bool ackedWithFramePending = false; - uint16_t fcf = aPsdu[IEEE802154_FCF_OFFSET] | (aPsdu[IEEE802154_FCF_OFFSET + 1] << 8); - - otEXPECT((fcf & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_MAC_COMMAND); - - while (!(ackedWithFramePending || sAckedWithFPFifoIsEmpty())) - { - const efr32AckedWithFP *const slot = sAckedWithFPFifoGetReadSlot(); - if ((slot->mPacket[0] == aPsduLength) && (memcmp(slot->mPacket + 1, aPsdu, slot->mLength - 1) == 0)) - { - ackedWithFramePending = true; - } - ++sAckedWithFPReadIndex; - } - -exit: - return ackedWithFramePending; -} - -static void processNextRxPacket(otInstance *aInstance) -{ - RAIL_RxPacketHandle_t packetHandle = RAIL_RX_PACKET_HANDLE_INVALID; - RAIL_RxPacketInfo_t packetInfo; - RAIL_RxPacketDetails_t packetDetails; - RAIL_Status_t status; - uint16_t length; - - packetHandle = RAIL_GetRxPacketInfo(gRailHandle, RAIL_RX_PACKET_HANDLE_OLDEST, &packetInfo); - - otEXPECT_ACTION(packetHandle != RAIL_RX_PACKET_HANDLE_INVALID && - packetInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS, - packetHandle = RAIL_RX_PACKET_HANDLE_INVALID); - - status = RAIL_GetRxPacketDetailsAlt(gRailHandle, packetHandle, &packetDetails); - otEXPECT(status == RAIL_STATUS_NO_ERROR); - - length = packetInfo.packetBytes + 1; - - // check the length in recv packet info structure; RAIL should take care of this. - assert(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); - - otLogInfoPlat("Received data:%d", length); - - // skip length byte - assert(packetInfo.firstPortionBytes > 0); - packetInfo.firstPortionData++; - packetInfo.firstPortionBytes--; - packetInfo.packetBytes--; - - // read packet - RAIL_CopyRxPacket(sReceiveFrame.mPsdu, &packetInfo); - - status = RAIL_ReleaseRxPacket(gRailHandle, packetHandle); - if (status == RAIL_STATUS_NO_ERROR) - { - packetHandle = RAIL_RX_PACKET_HANDLE_INVALID; - } - - sReceiveFrame.mLength = length; - - if (packetDetails.isAck) - { - assert((length == IEEE802154_ACK_LENGTH) && - (sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_ACK); - - RAIL_YieldRadio(gRailHandle); - sTransmitBusy = false; - - if (sReceiveFrame.mPsdu[IEEE802154_DSN_OFFSET] == sTransmitFrame.mPsdu[IEEE802154_DSN_OFFSET]) - { - sTransmitError = OT_ERROR_NONE; - } - else - { - sTransmitError = OT_ERROR_NO_ACK; - } - } - else - { - // signal MAC layer for each received frame if promiscuous is enabled - // otherwise only signal MAC layer for non-ACK frame - otEXPECT(sPromiscuous || (length != IEEE802154_ACK_LENGTH)); - - sReceiveError = OT_ERROR_NONE; - - sReceiveFrame.mInfo.mRxInfo.mRssi = packetDetails.rssi; - sReceiveFrame.mInfo.mRxInfo.mLqi = packetDetails.lqi; - - // Get the timestamp when the SFD was received - assert(packetDetails.timeReceived.timePosition != RAIL_PACKET_TIME_INVALID); - packetDetails.timeReceived.totalPacketBytes = length + 1; - - status = RAIL_GetRxTimeSyncWordEndAlt(gRailHandle, &packetDetails); - assert(status == RAIL_STATUS_NO_ERROR); - 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); - -#if OPENTHREAD_CONFIG_DIAG_ENABLE - - if (otPlatDiagModeGet()) - { - otPlatDiagRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); - } - else -#endif - { - otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength); - otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioReceiveDoneCbCount++; -#endif - } - } - - otSysEventSignalPending(); - -exit: - - if (packetHandle != RAIL_RX_PACKET_HANDLE_INVALID) - { - RAIL_ReleaseRxPacket(gRailHandle, packetHandle); - } -} - -static void ieee802154DataRequestCommand(RAIL_Handle_t aRailHandle) -{ - RAIL_Status_t status; - - if (sIsSrcMatchEnabled) - { - RAIL_IEEE802154_Address_t sourceAddress; - - status = RAIL_IEEE802154_GetAddress(aRailHandle, &sourceAddress); - assert(status == RAIL_STATUS_NO_ERROR); - - if ((sourceAddress.length == RAIL_IEEE802154_LongAddress && - utilsSoftSrcMatchExtFindEntry((otExtAddress *)sourceAddress.longAddress) >= 0) || - (sourceAddress.length == RAIL_IEEE802154_ShortAddress && - utilsSoftSrcMatchShortFindEntry(sourceAddress.shortAddress) >= 0)) - { - status = RAIL_IEEE802154_SetFramePending(aRailHandle); - assert(status == RAIL_STATUS_NO_ERROR); - insertIeee802154DataRequestCommand(aRailHandle); - } - } - else - { - status = RAIL_IEEE802154_SetFramePending(aRailHandle); - assert(status == RAIL_STATUS_NO_ERROR); - insertIeee802154DataRequestCommand(aRailHandle); - } -} - -static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents) -{ -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - if (aEvents & RAIL_EVENT_CONFIG_SCHEDULED) - { - sRailDebugCounters.mRailEventConfigScheduled++; - } - if (aEvents & RAIL_EVENT_CONFIG_UNSCHEDULED) - { - sRailDebugCounters.mRailEventConfigUnScheduled++; - } -#endif - if (aEvents & RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND) - { - ieee802154DataRequestCommand(aRailHandle); - } - - if (aEvents & RAIL_EVENTS_TX_COMPLETION) - { - if (aEvents & RAIL_EVENT_TX_PACKET_SENT) - { - if ((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = false; - } -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventPacketSent++; -#endif - } - else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventChannelBusy++; -#endif - } - else - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_ABORT; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventTxAbort++; -#endif - } - } - - if (aEvents & RAIL_EVENT_RX_ACK_TIMEOUT) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_NO_ACK; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventNoAck++; -#endif - } - - if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED) - { - RAIL_HoldRxPacket(aRailHandle); -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventPacketReceived++; -#endif - } - - if (aEvents & RAIL_EVENT_CAL_NEEDED) - { - RAIL_Status_t status; - - status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING); - assert(status == RAIL_STATUS_NO_ERROR); - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventCalNeeded++; -#endif - } - - if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE) - { - const int16_t energyScanResultQuarterDbm = RAIL_GetAverageRssi(aRailHandle); - RAIL_YieldRadio(aRailHandle); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_COMPLETED; - - if (energyScanResultQuarterDbm == RAIL_RSSI_INVALID) - { - sEnergyScanResultDbm = OT_RADIO_RSSI_INVALID; - } - else - { - sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM; - } - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioEnergyScanDoneCbCount++; -#endif - } - if (aEvents & RAIL_EVENT_SCHEDULER_STATUS) - { - RAIL_SchedulerStatus_t status = RAIL_GetSchedulerStatus(aRailHandle); - - assert(status != RAIL_SCHEDULER_STATUS_INTERNAL_ERROR); - - if (status == RAIL_SCHEDULER_STATUS_CCA_CSMA_TX_FAIL || status == RAIL_SCHEDULER_STATUS_SINGLE_TX_FAIL || - status == RAIL_SCHEDULER_STATUS_SCHEDULED_TX_FAIL || - (status == RAIL_SCHEDULER_STATUS_SCHEDULE_FAIL && sTransmitBusy) || - (status == RAIL_SCHEDULER_STATUS_EVENT_INTERRUPTED && sTransmitBusy)) - { - sTransmitError = OT_ERROR_ABORT; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventSchedulerStatusError++; -#endif - } - else if (status == RAIL_SCHEDULER_STATUS_AVERAGE_RSSI_FAIL) - { - sEnergyScanStatus = ENERGY_SCAN_STATUS_COMPLETED; - sEnergyScanResultDbm = OT_RADIO_RSSI_INVALID; - } -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - else if (sTransmitBusy) - { - sRailDebugCounters.mRailEventsSchedulerStatusLastStatus = status; - sRailDebugCounters.mRailEventsSchedulerStatusTransmitBusy++; - } -#endif - } - - otSysEventSignalPending(); -} - -otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) -{ - OT_UNUSED_VARIABLE(aInstance); - - return efr32StartEnergyScan(ENERGY_SCAN_MODE_ASYNC, aScanChannel, (RAIL_Time_t)aScanDuration * US_IN_MS); -} - -void efr32RadioProcess(otInstance *aInstance) -{ - // We should process the received packet first. Adding it at the end of this function, - // will delay the stack notification until the next call to efr32RadioProcess() - processNextRxPacket(aInstance); - - if (sState == OT_RADIO_STATE_TRANSMIT && sTransmitBusy == false) - { - if (sTransmitError != OT_ERROR_NONE) - { - otLogDebgPlat("Transmit failed ErrorCode=%d", sTransmitError); - } - - sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_CONFIG_DIAG_ENABLE - if (otPlatDiagModeGet()) - { - otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, sTransmitError); - } - else -#endif - if (((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) || (sTransmitError != OT_ERROR_NONE)) - { - otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, sTransmitError); - } - else - { - otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError); - } - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioTxDoneCbCount++; -#endif - - otSysEventSignalPending(); - } - else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) - { - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; - otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm); - otSysEventSignalPending(); - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventEnergyScanCompleted++; -#endif - } -} - -otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - - otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); - *aPower = sTxPowerDbm; - -exit: - return error; -} - -otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPower) * 10); - assert(status == RAIL_STATUS_NO_ERROR); - - sTxPowerDbm = aPower; - - return OT_ERROR_NONE; -} - -otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - otEXPECT_ACTION(aThreshold != NULL, error = OT_ERROR_INVALID_ARGS); - - *aThreshold = sCcaThresholdDbm; - -exit: - return error; -} - -otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold) -{ - OT_UNUSED_VARIABLE(aInstance); - - sCcaThresholdDbm = aThreshold; - - return OT_ERROR_NONE; -} - -int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return EFR32_RECEIVE_SENSITIVITY; -} - -RAIL_AntennaConfig_t halAntennaConfig; - -void initAntenna(void) -{ -#if (HAL_ANTDIV_ENABLE && defined(BSP_ANTDIV_SEL_PORT) && defined(BSP_ANTDIV_SEL_PIN) && defined(BSP_ANTDIV_SEL_LOC)) - halAntennaConfig.ant0PinEn = true; - halAntennaConfig.ant0Port = (uint8_t)BSP_ANTDIV_SEL_PORT; - halAntennaConfig.ant0Pin = BSP_ANTDIV_SEL_PIN; - halAntennaConfig.ant0Loc = BSP_ANTDIV_SEL_LOC; -#endif -#ifdef _SILICON_LABS_32B_SERIES_2 - halAntennaConfig.defaultPath = BSP_ANTDIV_SEL_LOC; -#endif -#if (HAL_ANTDIV_ENABLE && defined(BSP_ANTDIV_NSEL_PORT) && defined(BSP_ANTDIV_NSEL_PIN) && defined(BSP_ANTDIV_NSEL_LOC)) - halAntennaConfig.ant1PinEn = true; - halAntennaConfig.ant1Port = (uint8_t)BSP_ANTDIV_NSEL_PORT; - halAntennaConfig.ant1Pin = BSP_ANTDIV_NSEL_PIN; - halAntennaConfig.ant1Loc = BSP_ANTDIV_NSEL_LOC; -#endif -#if (HAL_ANTDIV_ENABLE || defined(_SILICON_LABS_32B_SERIES_2)) - (void)RAIL_ConfigAntenna(RAIL_EFR32_HANDLE, &halAntennaConfig); -#endif -} diff --git a/examples/platforms/efr32mg13/rail_config.h b/examples/platforms/efr32mg13/rail_config.h deleted file mode 100644 index 5a62825a9..000000000 --- a/examples/platforms/efr32mg13/rail_config.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __RAIL_CONFIG_H__ -#define __RAIL_CONFIG_H__ - -#include "board_config.h" -#include "rail_types.h" -#include - -#define RADIO_CONFIG_XTAL_FREQUENCY 38400000UL - -#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT -extern const RAIL_ChannelConfig_t *channelConfigs[]; -#endif - -#endif // __RAIL_CONFIG_H__ diff --git a/examples/platforms/efr32mg13/sleepy-demo/README.md b/examples/platforms/efr32mg13/sleepy-demo/README.md deleted file mode 100644 index 847f8a016..000000000 --- a/examples/platforms/efr32mg13/sleepy-demo/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# EFR32MG13 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/efr32mg13/README.md](../README.md). - -## 1. Build - -```bash -$ cd -$ ./bootstrap -$ make -f examples/Makefile-efr32mg13 COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 BOARD=BRD4168A -``` - -Convert the resulting executables into S-Record format and append a s37 suffix. - -```bash -$ cd output/efr32mg13/bin -$ arm-none-eabi-objcopy -O srec sleepy-demo-mtd sleepy-demo-mtd.s37 -$ 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/efr32mg13/README.md](../README.md#flash-binaries) - -## 2. Starting nodes - -For demonstration purposes the network settings are hardcoded within the source files. The devices start Thread and form a network within a few seconds of powering on. In a real-life application the devices should implement and go through a commissioning process to create a network and add devices. - -When the sleepy-demo-ftd device is started in the CLI the user shall see: - -``` -sleepy-demo-ftd started -sleepy-demo-ftd changed to leader -``` - -When the sleepy-demo-mtd device starts it joins the pre-configured Thread network before disabling Rx-On-Idle to become a Sleepy-End-Device. - -Use the command "child table" in the FTD console and observe the R flag of the child is 0. - -``` -> child table -| ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|S|D|N| Extended MAC | -+-----+--------+------------+------------+-------+------+-+-+-+-+------------------+ -| 1 | 0x8401 | 240 | 3 | 3 | 3 |0|1|0|0| 8e8582dbd78c243c | - -Done -``` - -## 3. Buttons on the MTD - -Pressing button 0 on the MTD toggles between operating as a Minimal End Device (MED) and a Sleepy End Device (SED) with the RX off when idle. - -Pressing button 1 on the MTD sends a multicast UDP message containing the string "mtd button". The FTD listens on the multicast address and will toggle LED 0 and display a message in the CLI showing "Message Received: mtd button". - -## 4. Buttons on the FTD - -Pressing either button 0 or 1 on the FTD will send a UDP message to the FTD containing the string "ftd button". The MTD must first send a multicast message by pressing the MTD's button 1 so that the FTD knows the address of the MTD to send messages to. - -This will toggle the state of LED0 on the MTD. If the MTD is operating as a sleepy end device then the MTD polls the parent every 5 seconds for messages and will update the LED state on the next poll. - -## 5. Monitoring power consumption of the MTD - -Open the Energy Profiler within Silicon Labs Simplicity Studio. Within the Quick Access menu select Start Energy Capture... and select the MTD device. When operating as a Sleepy End Device with no LEDs on the current should be under 20 microamps with occasional spikes during waking and polling the parent. With the LED on the MTD has a current consumption of approximately 1mA. - -When operating as a Minimal End Device with the Rx on Idle observe that the current is in the order of 10ma. - -With further configuration of GPIOs and peripherals it is possible to reduce the sleepy current consumption further. - -## 6. Notes on sleeping, sleepy callback and interrupts - -To allow the EFR32 to enter sleepy mode the application must register a callback with efr32SetSleepCallback. The return value of callback is used to indicate that the application has no further work to do and that it is safe to go into a low power mode. The callback is called with interrupts disabled so should do the minimum required to check if it can sleep. diff --git a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/Makefile.am b/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/Makefile.am deleted file mode 100644 index 4b77ae195..000000000 --- a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/Makefile.am +++ /dev/null @@ -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/efr32mg13/libopenthread-efr32mg13.a: - (cd $(top_builddir)/examples/platforms/efr32mg13/ && $(MAKE) $(AM_MAKEFLAGS) libopenthread-efr32mg13.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/efr32mg13/$(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/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/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 diff --git a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/Makefile.am b/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/Makefile.am deleted file mode 100644 index f8053bf15..000000000 --- a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/Makefile.am +++ /dev/null @@ -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/efr32mg13/libopenthread-efr32mg13.a: - (cd $(top_builddir)/examples/platforms/efr32mg13/ && $(MAKE) $(AM_MAKEFLAGS) libopenthread-efr32mg13.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/efr32mg13/$(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/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/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 diff --git a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/main.c b/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/main.c deleted file mode 100644 index 6f5112e2b..000000000 --- a/examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/main.c +++ /dev/null @@ -1,373 +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 -#include - -#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 "platform-efr32.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Constants -#define MULTICAST_ADDR "ff03::1" -#define MULTICAST_PORT 123 -#define RECV_PORT 234 -#define SLEEPY_POLL_PERIOD_MS 5000 -#define MTD_MESSAGE "mtd button" -#define FTD_MESSAGE "ftd button" - -// Types -typedef struct ButtonArray -{ - GPIO_Port_TypeDef port; - unsigned int pin; -} ButtonArray_t; - -// Prototypes -bool sleepCb(void); -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 mtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo); - -// Variables -static otInstance * instance; -static otUdpSocket sMtdSocket; -static otSockAddr sMulticastSockAddr; -static const ButtonArray_t sButtonArray[BSP_BUTTON_COUNT] = BSP_BUTTON_INIT; -static bool sButtonPressed = false; -static bool sRxOnIdleButtonPressed = false; -static bool sLedOn = false; -static bool sAllowDeepSleep = false; -static bool sTaskletsPendingSem = true; - -int main(int argc, char *argv[]) -{ - otLinkModeConfig config; - - otSysInit(argc, argv); - gpioInit(buttonCallback); - - instance = otInstanceInitSingle(); - assert(instance); - - otCliUartInit(instance); - - otLinkSetPollPeriod(instance, SLEEPY_POLL_PERIOD_MS); - setNetworkConfiguration(instance); - otSetStateChangedCallback(instance, handleNetifStateChanged, instance); - - config.mRxOnWhenIdle = true; - config.mDeviceType = 0; - config.mNetworkData = 0; - otThreadSetLinkMode(instance, config); - - initUdp(); - otIp6SetEnabled(instance, true); - otThreadSetEnabled(instance, true); - efr32SetSleepCallback(sleepCb); - - while (!otSysPseudoResetWasRequested()) - { - otTaskletsProcess(instance); - otSysProcessDrivers(instance); - - applicationTick(); - - // Put the EFR32 into deep sleep if callback sleepCb permits. - efr32Sleep(); - } - - otInstanceFinalize(instance); - return 0; -} - -/* - * Callback from efr32Sleep to indicate if it is ok to go into sleep mode. - * This runs with interrupts disabled. - */ -bool sleepCb(void) -{ - bool allow; - allow = (sAllowDeepSleep && !sTaskletsPendingSem); - sTaskletsPendingSem = false; - return allow; -} - -void otTaskletsSignalPending(otInstance *aInstance) -{ - (void)aInstance; - sTaskletsPendingSem = true; -} - -/* - * 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) -{ - otLinkModeConfig config; - - if ((aFlags & OT_CHANGED_THREAD_ROLE) != 0) - { - otDeviceRole changedRole = otThreadGetDeviceRole(aContext); - - switch (changedRole) - { - case OT_DEVICE_ROLE_LEADER: - case OT_DEVICE_ROLE_ROUTER: - break; - - case OT_DEVICE_ROLE_CHILD: - config.mRxOnWhenIdle = 0; - config.mDeviceType = 0; - config.mNetworkData = 0; - otThreadSetLinkMode(instance, config); - sAllowDeepSleep = true; - break; - - case OT_DEVICE_ROLE_DETACHED: - case OT_DEVICE_ROLE_DISABLED: - break; - } - } -} - -/* - * 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 - -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(&sMulticastSockAddr, 0, sizeof sMulticastSockAddr); - otIp6AddressFromString(MULTICAST_ADDR, &sMulticastSockAddr.mAddress); - sMulticastSockAddr.mPort = MULTICAST_PORT; - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.mPort = RECV_PORT; - - error = otUdpOpen(instance, &sMtdSocket, mtdReceiveCallback, NULL); - - if (error != OT_ERROR_NONE) - { - return; - } - - error = otUdpBind(instance, &sMtdSocket, &sockaddr); - - if (error != OT_ERROR_NONE) - { - otUdpClose(instance, &sMtdSocket); - return; - } -} - -void buttonCallback(uint8_t pin) -{ - if ((pin & 0x01) == 0x01) - { - sButtonPressed = true; - } - else if ((pin & 0x01) == 0x00) - { - sRxOnIdleButtonPressed = true; - } -} - -void applicationTick(void) -{ - otError error = 0; - otMessageInfo messageInfo; - otMessage * message = NULL; - char * payload = MTD_MESSAGE; - otLinkModeConfig config; - - if (sRxOnIdleButtonPressed == true) - { - sRxOnIdleButtonPressed = false; - sAllowDeepSleep = !sAllowDeepSleep; - config.mRxOnWhenIdle = !sAllowDeepSleep; - config.mDeviceType = 0; - config.mNetworkData = 0; - otThreadSetLinkMode(instance, config); - } - - if (sButtonPressed == true) - { - sButtonPressed = false; - - memset(&messageInfo, 0, sizeof(messageInfo)); - memcpy(&messageInfo.mPeerAddr, &sMulticastSockAddr.mAddress, sizeof messageInfo.mPeerAddr); - messageInfo.mPeerPort = sMulticastSockAddr.mPort; - - message = otUdpNewMessage(instance, NULL); - - if (message != NULL) - { - error = otMessageAppend(message, payload, (uint16_t)strlen(payload)); - - if (error == OT_ERROR_NONE) - { - error = otUdpSend(instance, &sMtdSocket, message, &messageInfo); - - if (error == OT_ERROR_NONE) - { - return; - } - } - } - - if (message != NULL) - { - otMessageFree(message); - } - } -} - -void mtdReceiveCallback(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; - - length = otMessageRead(aMessage, otMessageGetOffset(aMessage), buf, sizeof(buf) - 1); - buf[length] = '\0'; - - if (strcmp((char *)buf, FTD_MESSAGE) == 0) - { - sLedOn = !sLedOn; - - if (sLedOn) - { - BSP_LedSet(0); - } - else - { - BSP_LedClear(0); - } - } -} diff --git a/examples/platforms/efr32mg13/startup-gcc.c b/examples/platforms/efr32mg13/startup-gcc.c deleted file mode 100644 index 85c9e2aa5..000000000 --- a/examples/platforms/efr32mg13/startup-gcc.c +++ /dev/null @@ -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) - ; -} diff --git a/examples/platforms/efr32mg13/system.c b/examples/platforms/efr32mg13/system.c deleted file mode 100644 index b33c543f7..000000000 --- a/examples/platforms/efr32mg13/system.c +++ /dev/null @@ -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 -#include - -#include -#include - -#include "openthread-system.h" -#include - -#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 -} diff --git a/examples/platforms/efr32mg13/uart.c b/examples/platforms/efr32mg13/uart.c deleted file mode 100644 index f93f75fc6..000000000 --- a/examples/platforms/efr32mg13/uart.c +++ /dev/null @@ -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 - -#include "openthread-system.h" -#include - -#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(); -} diff --git a/examples/platforms/efr32mg21/alarm.c b/examples/platforms/efr32mg21/alarm.c deleted file mode 100644 index 40044987c..000000000 --- a/examples/platforms/efr32mg21/alarm.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file implements the OpenThread platform abstraction for the alarm. - * - */ - -#include -#include -#include - -#include "openthread-system.h" -#include -#include -#include -#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); - } - } - } -} diff --git a/examples/platforms/efr32mg21/brd4180a/board_config.h b/examples/platforms/efr32mg21/brd4180a/board_config.h deleted file mode 100644 index 51aa1e1eb..000000000 --- a/examples/platforms/efr32mg21/brd4180a/board_config.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file includes dev borad 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. - -#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__ diff --git a/examples/platforms/efr32mg21/crypto/mbedtls_config.h b/examples/platforms/efr32mg21/crypto/mbedtls_config.h deleted file mode 100644 index 95f829ffb..000000000 --- a/examples/platforms/efr32mg21/crypto/mbedtls_config.h +++ /dev/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 >>> -// TLS/DTLS configuration - -// Complete list of ciphersuites to use, in order of preference. -// Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 -// Complete list of ciphersuites to use, in order of preference. -// The value of this configuration should be updated for the application needs. -#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 - -// Maximum TLS/DTLS fragment length in bytes. -// Default: 768 -// The size configured here determines the size of each of the two -// internal I/O buffers used in mbedTLS when sending and receiving data. -#define MBEDTLS_SSL_MAX_CONTENT_LEN 768 - -// Enable support for RFC 6066 max_fragment_length extension in SSL. -// Default: 1 -// Enable support for RFC 6066 max_fragment_length extension in SSL. -#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1 - -// Enable support for exporting key block and master secret. -// Default: 1 -// Enable support for exporting key block and master secret. -// This is required for certain users of TLS, e.g. EAP-TLS. -#define SL_MBEDTLS_SSL_EXPORT_KEYS 1 - -// Enable the PSK based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the PSK based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 1 - -// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0 - -// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 1 - -// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. -// Default: 0 -// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. -#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 - -// -// <<< 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 diff --git a/examples/platforms/efr32mg21/diag.c b/examples/platforms/efr32mg21/diag.c deleted file mode 100644 index d3fb43b2f..000000000 --- a/examples/platforms/efr32mg21/diag.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file implements the OpenThread platform abstraction for the diagnostics. - * - */ - -#include -#include -#include -#include - -#include -#include -#include - -#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 diff --git a/examples/platforms/efr32mg21/fem-control.c b/examples/platforms/efr32mg21/fem-control.c deleted file mode 100644 index e9093d12b..000000000 --- a/examples/platforms/efr32mg21/fem-control.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "hal-config.h" - -#if (HAL_FEM_ENABLE) -#include "util/plugin/plugin-common/fem-control/fem-control.c" -#endif diff --git a/examples/platforms/efr32mg21/flash.c b/examples/platforms/efr32mg21/flash.c deleted file mode 100644 index 4f3596974..000000000 --- a/examples/platforms/efr32mg21/flash.c +++ /dev/null @@ -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 -#include - -#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE // Use OT NV system - -#include "em_msc.h" -#include -#include - -#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 -#include -#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 diff --git a/examples/platforms/efr32mg21/logging.c b/examples/platforms/efr32mg21/logging.c deleted file mode 100644 index a6fdbbafa..000000000 --- a/examples/platforms/efr32mg21/logging.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file logging.c - * Platform abstraction for the logging - * - */ - -#include -#include -#include -#include - -#include - -#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 diff --git a/examples/platforms/efr32mg21/openthread-core-efr32-config-check.h b/examples/platforms/efr32mg21/openthread-core-efr32-config-check.h deleted file mode 100644 index abae16529..000000000 --- a/examples/platforms/efr32mg21/openthread-core-efr32-config-check.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef OPENTHREAD_CORE_EFR32_CONFIG_CHECK_H_ -#define OPENTHREAD_CORE_EFR32_CONFIG_CHECK_H_ - -#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE -#error "Platform efr32mg21 doesn't support configuration option: OPENTHREAD_CONFIG_TIME_SYNC_ENABLE" -#endif - -#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT -#error "Platform efr32mg21 doesn't support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT" -#endif - -#endif /* OPENTHREAD_CORE_EFR32_CONFIG_CHECK_H_ */ diff --git a/examples/platforms/efr32mg21/openthread-core-efr32-config.h b/examples/platforms/efr32mg21/openthread-core-efr32-config.h deleted file mode 100644 index a4e53d462..000000000 --- a/examples/platforms/efr32mg21/openthread-core-efr32-config.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file includes 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 - * - * We dont support sub-gig frequencies on MG21. - * - */ - -#define OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT 0 - -/* - * @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 1 - -/** - * @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 1 - -/** - * @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 RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM - * - * The number of short source address table entries. - * - */ -#define RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM 6 - -/** - * @def RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM - * - * The number of extended source address table entries. - * - */ -#define RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM 6 - -/** - * @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_ diff --git a/examples/platforms/efr32mg21/platform-band.h b/examples/platforms/efr32mg21/platform-band.h deleted file mode 100644 index fb82093b8..000000000 --- a/examples/platforms/efr32mg21/platform-band.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2018, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file defines the frequency band configuration structure for efr32. - * - */ - -#ifndef PLATFORM_BAND_H_ -#define PLATFORM_BAND_H_ - -#include - -#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 efr32BandConfig -{ - RAIL_Handle_t mRailHandle; - RAIL_Config_t mRailConfig; - RAILSched_Config_t mRailSchedState; - const RAIL_ChannelConfig_t *mChannelConfig; - uint8_t mRailTxFifo[OT_RADIO_FRAME_MAX_SIZE + 1]; - uint8_t mChannelMin; - uint8_t mChannelMax; -} efr32BandConfig; - -#endif // PLATFORM_BAND_H_ diff --git a/examples/platforms/efr32mg21/platform-efr32.h b/examples/platforms/efr32mg21/platform-efr32.h deleted file mode 100644 index 0f62c47aa..000000000 --- a/examples/platforms/efr32mg21/platform-efr32.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file includes the platform-specific initializers. - * - */ - -#ifndef PLATFORM_EFR32_H_ -#define PLATFORM_EFR32_H_ - -#include - -#include "em_device.h" -#include "em_system.h" - -#include "core_cm33.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), void (*aCallbackWake)(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_ diff --git a/examples/platforms/efr32mg21/radio.c b/examples/platforms/efr32mg21/radio.c deleted file mode 100644 index 33047989d..000000000 --- a/examples/platforms/efr32mg21/radio.c +++ /dev/null @@ -1,1075 +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 radio communication. - * - */ - -#include -#include - -#include - -#include "openthread-system.h" -#include -#include -#include - -#include "common/logging.hpp" -#include "utils/code_utils.h" - -#include "utils/soft_source_match_table.h" - -#include "antenna.h" -#include "board_config.h" -#include "em_cmu.h" -#include "em_core.h" -#include "em_system.h" -#include "pa_conversions_efr32.h" -#include "platform-band.h" -#include "rail.h" -#include "rail_config.h" -#include "rail_ieee802154.h" - -enum -{ - IEEE802154_MIN_LENGTH = 5, - IEEE802154_MAX_LENGTH = 127, - IEEE802154_ACK_LENGTH = 5, - IEEE802154_FRAME_TYPE_MASK = 0x7, - IEEE802154_FRAME_TYPE_ACK = 0x2, - IEEE802154_FRAME_PENDING = 1 << 4, - IEEE802154_ACK_REQUEST = 1 << 5, - IEEE802154_DSN_OFFSET = 2, -}; - -enum -{ - EFR32_RECEIVE_SENSITIVITY = -100, // dBm - EFR32_RSSI_AVERAGING_TIME = 16, // us - EFR32_RSSI_AVERAGING_TIMEOUT = 300, // us -}; - -enum -{ - EFR32_SCHEDULER_SAMPLE_RSSI_PRIORITY = 10, // High priority - EFR32_SCHEDULER_TX_PRIORITY = 10, // High priority - EFR32_SCHEDULER_RX_PRIORITY = 20, // Low priority -}; - -enum -{ - EFR32_NUM_BAND_CONFIGS = 1, -}; - -typedef enum -{ - ENERGY_SCAN_STATUS_IDLE, - ENERGY_SCAN_STATUS_IN_PROGRESS, - ENERGY_SCAN_STATUS_COMPLETED -} energyScanStatus; - -typedef enum -{ - ENERGY_SCAN_MODE_SYNC, - ENERGY_SCAN_MODE_ASYNC -} energyScanMode; - -RAIL_Handle_t gRailHandle; - -static volatile bool sTransmitBusy = false; -static bool sPromiscuous = false; -static bool sIsSrcMatchEnabled = false; -static otRadioState sState = OT_RADIO_STATE_DISABLED; - -static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH]; -static otRadioFrame sReceiveFrame; -static otError sReceiveError; - -static otRadioFrame sTransmitFrame; -static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH]; -static volatile otError sTransmitError; - -static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS]; - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT -static efr32RadioCounters sRailDebugCounters; -#endif - -static volatile energyScanStatus sEnergyScanStatus; -static volatile int8_t sEnergyScanResultDbm; -static energyScanMode sEnergyScanMode; - -#define QUARTER_DBM_IN_DBM 4 -#define US_IN_MS 1000 - -static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents); - -static const RAIL_IEEE802154_Config_t sRailIeee802154Config = { - NULL, // addresses - { - // ackConfig - true, // ackConfig.enable - 894, // ackConfig.ackTimeout - { - // ackConfig.rxTransitions - RAIL_RF_STATE_RX, // ackConfig.rxTransitions.success - RAIL_RF_STATE_RX, // ackConfig.rxTransitions.error - }, - { - // ackConfig.txTransitions - RAIL_RF_STATE_RX, // ackConfig.txTransitions.success - RAIL_RF_STATE_RX, // ackConfig.txTransitions.error - }, - }, - { - // timings - 100, // timings.idleToRx - 192 - 10, // timings.txToRx - 100, // timings.idleToTx - 192, // timings.rxToTx - 0, // timings.rxSearchTimeout - 0, // timings.txToRxSearchTimeout - }, - RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES, // framesMask - false, // promiscuousMode - false, // isPanCoordinator -}; - -RAIL_DECLARE_TX_POWER_VBAT_CURVES_ALT; - -static int8_t sTxPowerDbm = OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER; - -static efr32BandConfig *sTxBandConfig = NULL; -static efr32BandConfig *sRxBandConfig = NULL; - -static RAIL_Handle_t efr32RailConfigInit(efr32BandConfig *aBandConfig) -{ - RAIL_Status_t status; - RAIL_Handle_t handle; - RAIL_DataConfig_t railDataConfig = { - TX_PACKET_DATA, - RX_PACKET_DATA, - PACKET_MODE, - PACKET_MODE, - }; - - handle = RAIL_Init(&aBandConfig->mRailConfig, NULL); - assert(handle != NULL); - - status = RAIL_ConfigData(handle, &railDataConfig); - assert(status == RAIL_STATUS_NO_ERROR); - - RAIL_Idle(handle, RAIL_IDLE, true); - - status = RAIL_ConfigCal(handle, RAIL_CAL_ALL); - assert(status == RAIL_STATUS_NO_ERROR); - - if (aBandConfig->mChannelConfig != NULL) - { - RAIL_ConfigChannels(handle, aBandConfig->mChannelConfig, NULL); - } - else - { - status = RAIL_IEEE802154_Config2p4GHzRadio(handle); - assert(status == RAIL_STATUS_NO_ERROR); - } - - status = RAIL_IEEE802154_Init(handle, &sRailIeee802154Config); - assert(status == RAIL_STATUS_NO_ERROR); - - status = RAIL_ConfigEvents(handle, RAIL_EVENTS_ALL, - RAIL_EVENT_RX_ACK_TIMEOUT | // - RAIL_EVENTS_TX_COMPLETION | // - RAIL_EVENT_RX_PACKET_RECEIVED | // - RAIL_EVENT_RSSI_AVERAGE_DONE | // - RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | // - RAIL_EVENT_CAL_NEEDED | // -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - RAIL_EVENT_CONFIG_SCHEDULED | // - RAIL_EVENT_CONFIG_UNSCHEDULED | // -#endif - RAIL_EVENT_SCHEDULER_STATUS // - ); - assert(status == RAIL_STATUS_NO_ERROR); - - uint16_t actualLength = RAIL_SetTxFifo(handle, aBandConfig->mRailTxFifo, 0, sizeof(aBandConfig->mRailTxFifo)); - assert(actualLength == sizeof(aBandConfig->mRailTxFifo)); - - return handle; -} - -static void efr32RadioSetTxPower(RAIL_Handle_t aRailHandle, - const RAIL_ChannelConfig_t *aChannelConfig, - int8_t aPowerDbm) -{ - RAIL_Status_t status; - const RAIL_TxPowerCurvesConfigAlt_t txPowerCurvesConfig = RAIL_DECLARE_TX_POWER_CURVES_CONFIG_ALT; - RAIL_TxPowerConfig_t txPowerConfig = {RAIL_TX_POWER_MODE_2P4_HP, 3300, 10}; - - status = RAIL_InitTxPowerCurvesAlt(&txPowerCurvesConfig); - assert(status == RAIL_STATUS_NO_ERROR); - - status = RAIL_ConfigTxPower(aRailHandle, &txPowerConfig); - assert(status == RAIL_STATUS_NO_ERROR); - - status = RAIL_SetTxPowerDbm(aRailHandle, ((RAIL_TxPower_t)aPowerDbm) * 10); - assert(status == RAIL_STATUS_NO_ERROR); -} - -static efr32BandConfig *efr32RadioGetBandConfig(uint8_t aChannel) -{ - efr32BandConfig *config = NULL; - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - if ((sBandConfigs[i].mChannelMin <= aChannel) && (aChannel <= sBandConfigs[i].mChannelMax)) - { - config = &sBandConfigs[i]; - break; - } - } - - return config; -} - -static void efr32BandConfigInit(void (*aEventCallback)(RAIL_Handle_t railHandle, RAIL_Events_t events)) -{ - uint8_t index = 0; - -#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT - sBandConfigs[index].mRailConfig.eventsCallback = aEventCallback; - sBandConfigs[index].mRailConfig.protocol = NULL; - sBandConfigs[index].mRailConfig.scheduler = &sBandConfigs[index].mRailSchedState; - sBandConfigs[index].mChannelConfig = NULL; - sBandConfigs[index].mChannelMin = OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN; - sBandConfigs[index].mChannelMax = OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX; - - assert((sBandConfigs[index].mRailHandle = efr32RailConfigInit(&sBandConfigs[index])) != NULL); - index++; -#endif -} - -void efr32RadioInit(void) -{ - efr32BandConfigInit(RAILCb_Generic); - - sReceiveFrame.mLength = 0; - sReceiveFrame.mPsdu = sReceivePsdu; - sTransmitFrame.mLength = 0; - sTransmitFrame.mPsdu = sTransmitPsdu; - - sRxBandConfig = efr32RadioGetBandConfig(OPENTHREAD_CONFIG_DEFAULT_CHANNEL); - assert(sRxBandConfig != NULL); - - sTxBandConfig = sRxBandConfig; - efr32RadioSetTxPower(sTxBandConfig->mRailHandle, sTxBandConfig->mChannelConfig, sTxPowerDbm); - - gRailHandle = sTxBandConfig->mRailHandle; // global handle for alarms. - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = false; - - otLogInfoPlat("Initialized", NULL); -} - -void efr32RadioDeinit(void) -{ - RAIL_Status_t status; - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - RAIL_Idle(sBandConfigs[i].mRailHandle, RAIL_IDLE_FORCE_SHUTDOWN_CLEAR_FLAGS, true); - - status = RAIL_IEEE802154_Deinit(sBandConfigs[i].mRailHandle); - assert(status == RAIL_STATUS_NO_ERROR); - - sBandConfigs[i].mRailHandle = NULL; - } - - sTxBandConfig = NULL; - sRxBandConfig = NULL; -} - -static otError efr32StartEnergyScan(energyScanMode aMode, uint16_t aChannel, RAIL_Time_t aAveragingTimeUs) -{ - RAIL_Status_t status; - otError error = OT_ERROR_NONE; - - otEXPECT_ACTION(sEnergyScanStatus == ENERGY_SCAN_STATUS_IDLE, error = OT_ERROR_BUSY); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IN_PROGRESS; - sEnergyScanMode = aMode; - - RAIL_Idle(sRxBandConfig->mRailHandle, RAIL_IDLE, true); - - RAIL_SchedulerInfo_t scanSchedulerInfo = {.priority = RADIO_SCHEDULER_CHANNEL_SCAN_PRIORITY, - .slipTime = RADIO_SCHEDULER_CHANNEL_SLIP_TIME, - .transactionTime = aAveragingTimeUs}; - - status = RAIL_StartAverageRssi(sRxBandConfig->mRailHandle, aChannel, aAveragingTimeUs, &scanSchedulerInfo); - otEXPECT_ACTION(status == RAIL_STATUS_NO_ERROR, error = OT_ERROR_FAILED); - -exit: - return error; -} - -void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) -{ - OT_UNUSED_VARIABLE(aInstance); - - uint64_t eui64; - uint8_t *eui64Ptr = NULL; - - eui64 = SYSTEM_GetUnique(); - eui64Ptr = (uint8_t *)&eui64; - - for (uint8_t i = 0; i < OT_EXT_ADDRESS_SIZE; i++) - { - aIeeeEui64[i] = eui64Ptr[(OT_EXT_ADDRESS_SIZE - 1) - i]; - } -} - -void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("PANID=%X", aPanId); - - utilsSoftSrcMatchSetPanId(aPanId); - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - status = RAIL_IEEE802154_SetPanId(sBandConfigs[i].mRailHandle, aPanId, 0); - assert(status == RAIL_STATUS_NO_ERROR); - } -} - -void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("ExtAddr=%X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4], - aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]); - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - status = RAIL_IEEE802154_SetLongAddress(sBandConfigs[i].mRailHandle, (uint8_t *)aAddress->m8, 0); - assert(status == RAIL_STATUS_NO_ERROR); - } -} - -void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - otLogInfoPlat("ShortAddr=%X", aAddress); - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - status = RAIL_IEEE802154_SetShortAddress(sBandConfigs[i].mRailHandle, aAddress, 0); - assert(status == RAIL_STATUS_NO_ERROR); - } -} - -bool otPlatRadioIsEnabled(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return (sState != OT_RADIO_STATE_DISABLED); -} - -otError otPlatRadioEnable(otInstance *aInstance) -{ - otEXPECT(!otPlatRadioIsEnabled(aInstance)); - - otLogInfoPlat("State=OT_RADIO_STATE_SLEEP", NULL); - sState = OT_RADIO_STATE_SLEEP; - -exit: - return OT_ERROR_NONE; -} - -otError otPlatRadioDisable(otInstance *aInstance) -{ - otEXPECT(otPlatRadioIsEnabled(aInstance)); - - otLogInfoPlat("State=OT_RADIO_STATE_DISABLED", NULL); - sState = OT_RADIO_STATE_DISABLED; - -exit: - return OT_ERROR_NONE; -} - -otError otPlatRadioSleep(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - - otEXPECT_ACTION((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED), - error = OT_ERROR_INVALID_STATE); - - otLogInfoPlat("State=OT_RADIO_STATE_SLEEP", NULL); - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - RAIL_Idle(sBandConfigs[i].mRailHandle, RAIL_IDLE, true); - } - sState = OT_RADIO_STATE_SLEEP; - -exit: - return error; -} - -otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) -{ - otError error = OT_ERROR_NONE; - RAIL_Status_t status; - efr32BandConfig *config; - - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION(sState != OT_RADIO_STATE_DISABLED, error = OT_ERROR_INVALID_STATE); - - config = efr32RadioGetBandConfig(aChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - if (sRxBandConfig != config) - { - RAIL_Idle(sRxBandConfig->mRailHandle, RAIL_IDLE, false); - sRxBandConfig = config; - } - - RAIL_SchedulerInfo_t bgRxSchedulerInfo = { - .priority = RADIO_SCHEDULER_BACKGROUND_RX_PRIORITY, - // sliptime/transaction time is not used for bg rx - }; - - status = RAIL_StartRx(sRxBandConfig->mRailHandle, aChannel, &bgRxSchedulerInfo); - otEXPECT_ACTION(status == RAIL_STATUS_NO_ERROR, error = OT_ERROR_FAILED); - - otLogInfoPlat("State=OT_RADIO_STATE_RECEIVE", NULL); - sState = OT_RADIO_STATE_RECEIVE; - sReceiveFrame.mChannel = aChannel; - -exit: - return error; -} - -otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) -{ - otError error = OT_ERROR_NONE; - RAIL_CsmaConfig_t csmaConfig = RAIL_CSMA_CONFIG_802_15_4_2003_2p4_GHz_OQPSK_CSMA; - RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_NONE; - efr32BandConfig * config; - RAIL_Status_t status; - uint8_t frameLength; - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatTxTriggered++; -#endif - - assert(sTransmitBusy == false); - - otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT), - error = OT_ERROR_INVALID_STATE); - - config = efr32RadioGetBandConfig(aFrame->mChannel); - otEXPECT_ACTION(config != NULL, error = OT_ERROR_INVALID_ARGS); - - sState = OT_RADIO_STATE_TRANSMIT; - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = true; - - if (sTxBandConfig != config) - { - efr32RadioSetTxPower(config->mRailHandle, config->mChannelConfig, sTxPowerDbm); - sTxBandConfig = config; - } - - frameLength = (uint8_t)aFrame->mLength; - RAIL_WriteTxFifo(sTxBandConfig->mRailHandle, &frameLength, sizeof frameLength, true); - RAIL_WriteTxFifo(sTxBandConfig->mRailHandle, aFrame->mPsdu, frameLength - 2, false); - - RAIL_SchedulerInfo_t txSchedulerInfo = { - .priority = RADIO_SCHEDULER_TX_PRIORITY, - .slipTime = RADIO_SCHEDULER_CHANNEL_SLIP_TIME, - .transactionTime = 0, // will be calculated later if DMP is used - }; - - if (aFrame->mPsdu[0] & IEEE802154_ACK_REQUEST) - { - txOptions |= RAIL_TX_OPTION_WAIT_FOR_ACK; - -#if RADIO_CONFIG_DMP_SUPPORT - // time we wait for ACK - if (RAIL_GetSymbolRate(gRailHandle) > 0) - { - txSchedulerInfo.transactionTime += 12 * 1e6 / RAIL_GetSymbolRate(gRailHandle); - } - else - { - txSchedulerInfo.transactionTime += 12 * RADIO_TIMING_DEFAULT_SYMBOLTIME_US; - } -#endif - } - -#if RADIO_CONFIG_DMP_SUPPORT - // time needed for the frame itself - // 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); - } - else - { // assume 250kbps - txSchedulerInfo.transactionTime = (frameLength + 4 + 1 + 1) * RADIO_TIMING_DEFAULT_BYTETIME_US; - } -#endif - - if (aFrame->mInfo.mTxInfo.mCsmaCaEnabled) - { -#if RADIO_CONFIG_DMP_SUPPORT - // time needed for CSMA/CA - txSchedulerInfo.transactionTime += RADIO_TIMING_CSMA_OVERHEAD_US; -#endif - status = - RAIL_StartCcaCsmaTx(sTxBandConfig->mRailHandle, aFrame->mChannel, txOptions, &csmaConfig, &txSchedulerInfo); - } - else - { - status = RAIL_StartTx(sTxBandConfig->mRailHandle, aFrame->mChannel, txOptions, &txSchedulerInfo); - } - - if (status == RAIL_STATUS_NO_ERROR) - { -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailTxStarted++; -#endif - otPlatRadioTxStarted(aInstance, aFrame); - } - else - { -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailTxStartFailed++; -#endif - sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE; - sTransmitBusy = false; - } - -exit: - return error; -} - -otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return &sTransmitFrame; -} - -int8_t otPlatRadioGetRssi(otInstance *aInstance) -{ - otError error; - uint32_t start; - int8_t rssi = OT_RADIO_RSSI_INVALID; - - OT_UNUSED_VARIABLE(aInstance); - - error = efr32StartEnergyScan(ENERGY_SCAN_MODE_SYNC, sReceiveFrame.mChannel, EFR32_RSSI_AVERAGING_TIME); - otEXPECT(error == OT_ERROR_NONE); - - start = RAIL_GetTime(); - - // waiting for the event RAIL_EVENT_RSSI_AVERAGE_DONE - while (sEnergyScanStatus == ENERGY_SCAN_STATUS_IN_PROGRESS && - ((RAIL_GetTime() - start) < EFR32_RSSI_AVERAGING_TIMEOUT)) - ; - - if (sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) - { - rssi = sEnergyScanResultDbm; - } - - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; -exit: - return rssi; -} - -otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF | OT_RADIO_CAPS_ENERGY_SCAN; -} - -bool otPlatRadioGetPromiscuous(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return sPromiscuous; -} - -void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - sPromiscuous = aEnable; - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - status = RAIL_IEEE802154_SetPromiscuousMode(sBandConfigs[i].mRailHandle, aEnable); - assert(status == RAIL_STATUS_NO_ERROR); - } -} - -void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) -{ - OT_UNUSED_VARIABLE(aInstance); - - // set Frame Pending bit for all outgoing ACKs if aEnable is false - sIsSrcMatchEnabled = aEnable; -} - -static void processNextRxPacket(otInstance *aInstance, RAIL_Handle_t aRailHandle) -{ - RAIL_RxPacketHandle_t packetHandle = RAIL_RX_PACKET_HANDLE_INVALID; - RAIL_RxPacketInfo_t packetInfo; - RAIL_RxPacketDetails_t packetDetails; - RAIL_Status_t status; - uint16_t length; - - packetHandle = RAIL_GetRxPacketInfo(aRailHandle, RAIL_RX_PACKET_HANDLE_OLDEST, &packetInfo); - - otEXPECT_ACTION(packetHandle != RAIL_RX_PACKET_HANDLE_INVALID && - packetInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS, - packetHandle = RAIL_RX_PACKET_HANDLE_INVALID); - - packetDetails.timeReceived.timePosition = RAIL_PACKET_TIME_INVALID; - packetDetails.timeReceived.totalPacketBytes = 0; - status = RAIL_GetRxPacketDetails(aRailHandle, packetHandle, &packetDetails); - otEXPECT(status == RAIL_STATUS_NO_ERROR); - - length = packetInfo.packetBytes + 1; - - // check the length in recv packet info structure - otEXPECT(length == packetInfo.firstPortionData[0]); - - // check the length validity of recv packet - otEXPECT(length >= IEEE802154_MIN_LENGTH && length <= IEEE802154_MAX_LENGTH); - - otLogInfoPlat("Received data:%d", length); - - // skip length byte - assert(packetInfo.firstPortionBytes > 0); - packetInfo.firstPortionData++; - packetInfo.firstPortionBytes--; - packetInfo.packetBytes--; - - // read packet - memcpy(sReceiveFrame.mPsdu, packetInfo.firstPortionData, packetInfo.firstPortionBytes); - memcpy(sReceiveFrame.mPsdu + packetInfo.firstPortionBytes, packetInfo.lastPortionData, - packetInfo.packetBytes - packetInfo.firstPortionBytes); - - status = RAIL_ReleaseRxPacket(aRailHandle, packetHandle); - if (status == RAIL_STATUS_NO_ERROR) - { - packetHandle = RAIL_RX_PACKET_HANDLE_INVALID; - } - - sReceiveFrame.mLength = length; - - if (packetDetails.isAck) - { - assert((length == IEEE802154_ACK_LENGTH) && - (sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_ACK); - - RAIL_YieldRadio(gRailHandle); - sTransmitBusy = false; - - if (sReceiveFrame.mPsdu[IEEE802154_DSN_OFFSET] == sTransmitFrame.mPsdu[IEEE802154_DSN_OFFSET]) - { - sTransmitError = OT_ERROR_NONE; - } - else - { - sTransmitError = OT_ERROR_NO_ACK; - } - } - else - { - otEXPECT(length != IEEE802154_ACK_LENGTH); - - sReceiveError = OT_ERROR_NONE; - - sReceiveFrame.mInfo.mRxInfo.mRssi = packetDetails.rssi; - sReceiveFrame.mInfo.mRxInfo.mLqi = packetDetails.lqi; - - // TODO: grab timestamp and handle conversion to msec/usec and RAIL_GetRxTimeSyncWordEndAlt - // sReceiveFrame.mInfo.mRxInfo.mMsec = packetDetails.packetTime; - // sReceiveFrame.mInfo.mRxInfo.mUsec = packetDetails.packetTime; - - // TODO Set this flag only when the packet is really acknowledged with frame pending set. - // See https://github.com/openthread/openthread/pull/3785 - sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true; - -#if OPENTHREAD_CONFIG_DIAG_ENABLE - - if (otPlatDiagModeGet()) - { - otPlatDiagRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); - } - else -#endif - { - // signal MAC layer for each received frame if promiscuous is enabled - // otherwise only signal MAC layer for non-ACK frame - if (sPromiscuous || sReceiveFrame.mLength > IEEE802154_ACK_LENGTH) - { - otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength); - otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioReceiveDoneCbCount++; -#endif - } - } - } - - otSysEventSignalPending(); - -exit: - - if (packetHandle != RAIL_RX_PACKET_HANDLE_INVALID) - { - RAIL_ReleaseRxPacket(aRailHandle, packetHandle); - } -} - -static void ieee802154DataRequestCommand(RAIL_Handle_t aRailHandle) -{ - RAIL_Status_t status; - - if (sIsSrcMatchEnabled) - { - RAIL_IEEE802154_Address_t sourceAddress; - - status = RAIL_IEEE802154_GetAddress(aRailHandle, &sourceAddress); - assert(status == RAIL_STATUS_NO_ERROR); - - if ((sourceAddress.length == RAIL_IEEE802154_LongAddress && - utilsSoftSrcMatchExtFindEntry((otExtAddress *)sourceAddress.longAddress) >= 0) || - (sourceAddress.length == RAIL_IEEE802154_ShortAddress && - utilsSoftSrcMatchShortFindEntry(sourceAddress.shortAddress) >= 0)) - { - status = RAIL_IEEE802154_SetFramePending(aRailHandle); - assert(status == RAIL_STATUS_NO_ERROR); - } - } - else - { - status = RAIL_IEEE802154_SetFramePending(aRailHandle); - assert(status == RAIL_STATUS_NO_ERROR); - } -} - -static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents) -{ -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - if (aEvents & RAIL_EVENT_CONFIG_SCHEDULED) - { - sRailDebugCounters.mRailEventConfigScheduled++; - } - if (aEvents & RAIL_EVENT_CONFIG_UNSCHEDULED) - { - sRailDebugCounters.mRailEventConfigUnScheduled++; - } -#endif - if (aEvents & RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND) - { - ieee802154DataRequestCommand(aRailHandle); - } - if (aEvents & RAIL_EVENTS_TX_COMPLETION) - { - if (aEvents & RAIL_EVENT_TX_PACKET_SENT) - { - if ((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_NONE; - sTransmitBusy = false; - } -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventPacketSent++; -#endif - } - else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventChannelBusy++; -#endif - } - else - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_ABORT; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventTxAbort++; -#endif - } - } - - if (aEvents & RAIL_EVENT_RX_ACK_TIMEOUT) - { - RAIL_YieldRadio(aRailHandle); - sTransmitError = OT_ERROR_NO_ACK; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventNoAck++; -#endif - } - - if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED) - { - RAIL_HoldRxPacket(aRailHandle); -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventPacketReceived++; -#endif - } - - if (aEvents & RAIL_EVENT_CAL_NEEDED) - { - RAIL_Status_t status; - - status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING); - assert(status == RAIL_STATUS_NO_ERROR); - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventCalNeeded++; -#endif - } - - if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE) - { - const int16_t energyScanResultQuarterDbm = RAIL_GetAverageRssi(aRailHandle); - RAIL_YieldRadio(aRailHandle); - - sEnergyScanStatus = ENERGY_SCAN_STATUS_COMPLETED; - - if (energyScanResultQuarterDbm == RAIL_RSSI_INVALID) - { - sEnergyScanResultDbm = OT_RADIO_RSSI_INVALID; - } - else - { - sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM; - } - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioEnergyScanDoneCbCount++; -#endif - } - if (aEvents & RAIL_EVENT_SCHEDULER_STATUS) - { - RAIL_SchedulerStatus_t status = RAIL_GetSchedulerStatus(aRailHandle); - - assert(status != RAIL_SCHEDULER_STATUS_INTERNAL_ERROR); - - if (status == RAIL_SCHEDULER_STATUS_CCA_CSMA_TX_FAIL || status == RAIL_SCHEDULER_STATUS_SINGLE_TX_FAIL || - status == RAIL_SCHEDULER_STATUS_SCHEDULED_TX_FAIL || - (status == RAIL_SCHEDULER_STATUS_SCHEDULE_FAIL && sTransmitBusy) || - (status == RAIL_SCHEDULER_STATUS_EVENT_INTERRUPTED && sTransmitBusy)) - { - sTransmitError = OT_ERROR_ABORT; - sTransmitBusy = false; -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventSchedulerStatusError++; -#endif - } - else if (status == RAIL_SCHEDULER_STATUS_AVERAGE_RSSI_FAIL) - { - sEnergyScanStatus = ENERGY_SCAN_STATUS_COMPLETED; - sEnergyScanResultDbm = OT_RADIO_RSSI_INVALID; - } -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - else if (sTransmitBusy) - { - sRailDebugCounters.mRailEventsSchedulerStatusLastStatus = status; - sRailDebugCounters.mRailEventsSchedulerStatusTransmitBusy++; - } -#endif - } - - otSysEventSignalPending(); -} - -otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) -{ - OT_UNUSED_VARIABLE(aInstance); - - return efr32StartEnergyScan(ENERGY_SCAN_MODE_ASYNC, aScanChannel, (RAIL_Time_t)aScanDuration * US_IN_MS); -} - -void efr32RadioProcess(otInstance *aInstance) -{ - // We should process the received packet first. Adding it at the end of this function, - // will delay the stack notification until the next call to efr32RadioProcess() - processNextRxPacket(aInstance, sRxBandConfig->mRailHandle); - - if (sState == OT_RADIO_STATE_TRANSMIT && sTransmitBusy == false) - { - if (sTransmitError != OT_ERROR_NONE) - { - otLogDebgPlat("Transmit failed ErrorCode=%d", sTransmitError); - } - - sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_CONFIG_DIAG_ENABLE - if (otPlatDiagModeGet()) - { - otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, sTransmitError); - } - else -#endif - if (((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) || (sTransmitError != OT_ERROR_NONE)) - { - otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, sTransmitError); - } - else - { - otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError); - } - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailPlatRadioTxDoneCbCount++; -#endif - - otSysEventSignalPending(); - } - else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) - { - sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; - otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm); - otSysEventSignalPending(); - -#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT - sRailDebugCounters.mRailEventEnergyScanCompleted++; -#endif - } -} - -otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) -{ - OT_UNUSED_VARIABLE(aInstance); - - otError error = OT_ERROR_NONE; - - otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); - *aPower = sTxPowerDbm; - -exit: - return error; -} - -otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) -{ - OT_UNUSED_VARIABLE(aInstance); - - RAIL_Status_t status; - - for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++) - { - status = RAIL_SetTxPowerDbm(sBandConfigs[i].mRailHandle, ((RAIL_TxPower_t)aPower) * 10); - assert(status == RAIL_STATUS_NO_ERROR); - } - - sTxPowerDbm = aPower; - - return OT_ERROR_NONE; -} - -otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold) -{ - OT_UNUSED_VARIABLE(aInstance); - OT_UNUSED_VARIABLE(aThreshold); - - return OT_ERROR_NOT_IMPLEMENTED; -} - -otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold) -{ - OT_UNUSED_VARIABLE(aInstance); - OT_UNUSED_VARIABLE(aThreshold); - - return OT_ERROR_NOT_IMPLEMENTED; -} - -int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) -{ - OT_UNUSED_VARIABLE(aInstance); - - return EFR32_RECEIVE_SENSITIVITY; -} - -RAIL_AntennaConfig_t halAntennaConfig; - -void initAntenna(void) -{ -#if (HAL_ANTDIV_ENABLE && defined(BSP_ANTDIV_SEL_PORT) && defined(BSP_ANTDIV_SEL_PIN) && defined(BSP_ANTDIV_SEL_LOC)) - halAntennaConfig.ant0PinEn = true; - halAntennaConfig.ant0Port = (uint8_t)BSP_ANTDIV_SEL_PORT; - halAntennaConfig.ant0Pin = BSP_ANTDIV_SEL_PIN; - halAntennaConfig.ant0Loc = BSP_ANTDIV_SEL_LOC; -#endif -#ifdef _SILICON_LABS_32B_SERIES_2 - halAntennaConfig.defaultPath = BSP_ANTDIV_SEL_LOC; -#endif -#if (HAL_ANTDIV_ENABLE && defined(BSP_ANTDIV_NSEL_PORT) && defined(BSP_ANTDIV_NSEL_PIN) && defined(BSP_ANTDIV_NSEL_LOC)) - halAntennaConfig.ant1PinEn = true; - halAntennaConfig.ant1Port = (uint8_t)BSP_ANTDIV_NSEL_PORT; - halAntennaConfig.ant1Pin = BSP_ANTDIV_NSEL_PIN; - halAntennaConfig.ant1Loc = BSP_ANTDIV_NSEL_LOC; -#endif -#if (HAL_ANTDIV_ENABLE || defined(_SILICON_LABS_32B_SERIES_2)) - (void)RAIL_ConfigAntenna(RAIL_EFR32_HANDLE, &halAntennaConfig); -#endif -} diff --git a/examples/platforms/efr32mg21/rail_config.h b/examples/platforms/efr32mg21/rail_config.h deleted file mode 100644 index 72c7c0586..000000000 --- a/examples/platforms/efr32mg21/rail_config.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __RAIL_CONFIG_H__ -#define __RAIL_CONFIG_H__ - -#include "board_config.h" -#include "rail_types.h" -#include - -#define RADIO_CONFIG_XTAL_FREQUENCY 38400000UL - -#endif // __RAIL_CONFIG_H__ diff --git a/examples/platforms/efr32mg21/sleepy-demo/README.md b/examples/platforms/efr32mg21/sleepy-demo/README.md deleted file mode 100644 index 462cc9fdd..000000000 --- a/examples/platforms/efr32mg21/sleepy-demo/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# EFR32MG21 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/efr32mg21/README.md](../README.md). - -## 1. Build - -```bash -$ cd -$ ./bootstrap -$ make -f examples/Makefile-efr32mg21 COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 BOARD=BRD4180A -``` - -Convert the resulting executables into S-Record format and append a s37 suffix. - -```bash -$ cd output/efr32mg21/bin -$ arm-none-eabi-objcopy -O srec sleepy-demo-mtd sleepy-demo-mtd.s37 -$ 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/efr32mg21/README.md](../README.md#flash-binaries) - -## 2. Starting nodes - -For demonstration purposes the network settings are hardcoded within the source files. The devices start Thread and form a network within a few seconds of powering on. In a real-life application the devices should implement and go through a commissioning process to create a network and add devices. - -When the sleepy-demo-ftd device is started in the CLI the user shall see: - -``` -sleepy-demo-ftd started -sleepy-demo-ftd changed to leader -``` - -When the sleepy-demo-mtd device starts it joins the pre-configured Thread network before disabling Rx-On-Idle to become a Sleepy-End-Device. - -Use the command "child table" in the FTD console and observe the R flag of the child is 0. - -``` -> child table -| ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|S|D|N| Extended MAC | -+-----+--------+------------+------------+-------+------+-+-+-+-+------------------+ -| 1 | 0x8401 | 240 | 3 | 3 | 3 |0|1|0|0| 8e8582dbd78c243c | - -Done -``` - -## 3. MTD behavior on wake-up - -MTD wakes up every 5 seconds and sends a multicast UDP message containing the string "mtd is awake". The FTD listens on the multicast address and will toggle LED 0 and display a message in the CLI showing "Message Received: mtd is awake". - -## 4. Monitoring power consumption of the MTD - -Open the Energy Profiler within Silicon Labs Simplicity Studio. Within the Quick Access menu select Start Energy Capture... and select the MTD device. When operating as a Sleepy End Device with no LEDs on the current should be under 20-80 microamps with occasional spikes during waking and polling the parent. With the LED on the MTD has a current consumption of approximately 1mA. - -When operating as a Minimal End Device with the Rx on Idle observe that the current is in the order of 10ma. - -With further configuration of GPIOs and peripherals it is possible to reduce the sleepy current consumption further. - -## 5. Notes on sleeping, sleepy callback and interrupts - -To allow the EFR32 to enter sleepy mode the application must register a callback with efr32SetSleepCallback. The return value of callback is used to indicate that the application has no further work to do and that it is safe to go into a low power mode. The callback is called with interrupts disabled so should do the minimum required to check if it can sleep. diff --git a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/main.c b/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/main.c deleted file mode 100644 index e54fe8213..000000000 --- a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/main.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "bsp.h" -#include "em_cmu.h" -#include "em_emu.h" -#include "gpiointerrupt.h" -#include "hal-config-board.h" -#include "hal_common.h" -#include "openthread-system.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// 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); -} diff --git a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/main.c b/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/main.c deleted file mode 100644 index bf510797a..000000000 --- a/examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/main.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "bsp.h" -#include "em_cmu.h" -#include "em_emu.h" -#include "gpiointerrupt.h" -#include "hal-config-board.h" -#include "hal_common.h" -#include "openthread-system.h" -#include "platform-efr32.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Constants -#define MULTICAST_ADDR "ff03::1" -#define MULTICAST_PORT 123 -#define RECV_PORT 234 -#define SLEEPY_POLL_PERIOD_MS 5000 -#define MTD_MESSAGE "mtd is awake" -#define FTD_MESSAGE "ftd button" - -// Types -typedef struct ButtonArray -{ - GPIO_Port_TypeDef port; - unsigned int pin; -} ButtonArray_t; - -// Prototypes -void deviceOutOfSleepCb(void); -bool sleepCb(void); -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 mtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo); - -// Variables -static otInstance * instance; -static otUdpSocket sMtdSocket; -static otSockAddr sMulticastSockAddr; -static const ButtonArray_t sButtonArray[BSP_BUTTON_COUNT] = BSP_BUTTON_INIT; -static bool sButtonPressed = false; -static bool sRxOnIdleButtonPressed = false; -static bool sLedOn = false; -static bool sAllowDeepSleep = false; -static bool sTaskletsPendingSem = true; - -int main(int argc, char *argv[]) -{ - otLinkModeConfig config; - - otSysInit(argc, argv); - gpioInit(buttonCallback); - - instance = otInstanceInitSingle(); - assert(instance); - - otCliUartInit(instance); - - otLinkSetPollPeriod(instance, SLEEPY_POLL_PERIOD_MS); - setNetworkConfiguration(instance); - otSetStateChangedCallback(instance, handleNetifStateChanged, instance); - - config.mRxOnWhenIdle = true; - config.mDeviceType = 0; - config.mNetworkData = 0; - otThreadSetLinkMode(instance, config); - - initUdp(); - otIp6SetEnabled(instance, true); - otThreadSetEnabled(instance, true); - efr32SetSleepCallback(sleepCb, deviceOutOfSleepCb); - - while (!otSysPseudoResetWasRequested()) - { - otTaskletsProcess(instance); - otSysProcessDrivers(instance); - - applicationTick(); - - // Put the EFR32 into deep sleep if callback sleepCb permits. - efr32Sleep(); - } - - otInstanceFinalize(instance); - return 0; -} - -void deviceOutOfSleepCb(void) -{ - static uint32_t udpPacketSendTimer = 0; - - if (udpPacketSendTimer == 0) - { - udpPacketSendTimer = otPlatAlarmMilliGetNow(); - } - - if ((otPlatAlarmMilliGetNow() - udpPacketSendTimer) >= 5000) - { - sButtonPressed = true; - udpPacketSendTimer = 0; - } -} - -/* - * Callback from efr32Sleep to indicate if it is ok to go into sleep mode. - * This runs with interrupts disabled. - */ -bool sleepCb(void) -{ - bool allow; - allow = (sAllowDeepSleep && !sTaskletsPendingSem); - sTaskletsPendingSem = false; - return allow; -} - -void otTaskletsSignalPending(otInstance *aInstance) -{ - (void)aInstance; - sTaskletsPendingSem = true; -} - -/* - * 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) -{ - otLinkModeConfig config; - - if ((aFlags & OT_CHANGED_THREAD_ROLE) != 0) - { - otDeviceRole changedRole = otThreadGetDeviceRole(aContext); - - switch (changedRole) - { - case OT_DEVICE_ROLE_LEADER: - case OT_DEVICE_ROLE_ROUTER: - break; - - case OT_DEVICE_ROLE_CHILD: - config.mRxOnWhenIdle = 0; - config.mDeviceType = 0; - config.mNetworkData = 0; - otThreadSetLinkMode(instance, config); - sAllowDeepSleep = true; - break; - - case OT_DEVICE_ROLE_DETACHED: - case OT_DEVICE_ROLE_DISABLED: - break; - } - } -} - -/* - * 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 - -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(&sMulticastSockAddr, 0, sizeof sMulticastSockAddr); - otIp6AddressFromString(MULTICAST_ADDR, &sMulticastSockAddr.mAddress); - sMulticastSockAddr.mPort = MULTICAST_PORT; - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.mPort = RECV_PORT; - - error = otUdpOpen(instance, &sMtdSocket, mtdReceiveCallback, NULL); - - if (error != OT_ERROR_NONE) - { - return; - } - - error = otUdpBind(instance, &sMtdSocket, &sockaddr); - - if (error != OT_ERROR_NONE) - { - otUdpClose(instance, &sMtdSocket); - return; - } -} - -void buttonCallback(uint8_t pin) -{ - if ((pin & 0x01) == 0x01) - { - sButtonPressed = true; - } - else if ((pin & 0x01) == 0x00) - { - sRxOnIdleButtonPressed = true; - } -} - -void applicationTick(void) -{ - otError error = 0; - otMessageInfo messageInfo; - otMessage * message = NULL; - char * payload = MTD_MESSAGE; - otLinkModeConfig config; - - if (sRxOnIdleButtonPressed == true) - { - sRxOnIdleButtonPressed = false; - sAllowDeepSleep = !sAllowDeepSleep; - config.mRxOnWhenIdle = !sAllowDeepSleep; - config.mDeviceType = 0; - config.mNetworkData = 0; - otThreadSetLinkMode(instance, config); - } - - if (sButtonPressed == true) - { - sButtonPressed = false; - - memset(&messageInfo, 0, sizeof(messageInfo)); - memcpy(&messageInfo.mPeerAddr, &sMulticastSockAddr.mAddress, sizeof messageInfo.mPeerAddr); - messageInfo.mPeerPort = sMulticastSockAddr.mPort; - - message = otUdpNewMessage(instance, NULL); - - if (message != NULL) - { - error = otMessageAppend(message, payload, (uint16_t)strlen(payload)); - - if (error == OT_ERROR_NONE) - { - error = otUdpSend(instance, &sMtdSocket, message, &messageInfo); - - if (error == OT_ERROR_NONE) - { - return; - } - } - } - - if (message != NULL) - { - otMessageFree(message); - } - } -} - -void mtdReceiveCallback(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; - - length = otMessageRead(aMessage, otMessageGetOffset(aMessage), buf, sizeof(buf) - 1); - buf[length] = '\0'; - - if (strcmp((char *)buf, FTD_MESSAGE) == 0) - { - sLedOn = !sLedOn; - - if (sLedOn) - { - BSP_LedSet(0); - } - else - { - BSP_LedClear(0); - } - } -} diff --git a/examples/platforms/efr32mg21/startup-gcc.c b/examples/platforms/efr32mg21/startup-gcc.c deleted file mode 100644 index cf5a60b4c..000000000 --- a/examples/platforms/efr32mg21/startup-gcc.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file implements 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) - ; -} diff --git a/examples/platforms/efr32mg21/uart.c b/examples/platforms/efr32mg21/uart.c deleted file mode 100644 index 9d93a3b37..000000000 --- a/examples/platforms/efr32mg21/uart.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2019, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file implements the OpenThread platform abstraction for UART communication. - * - */ - -#include - -#include "openthread-system.h" -#include - -#include "utils/code_utils.h" - -#include "em_core.h" -#include "uartdrv.h" - -#include "hal-config.h" - -enum -{ - kReceiveFifoSize = 128, -}; - -#define USART_PORT USART0 -#define USART_PORT_RX_IRQn USART0_RX_IRQn - -#define USART_INIT \ - { \ - USART_PORT, /* USART port */ \ - 115200, /* Baud rate */ \ - BSP_SERIAL_APP_TX_PORT, /* USART Tx port number */ \ - BSP_SERIAL_APP_RX_PORT, /* USART Rx port number */ \ - BSP_SERIAL_APP_TX_PIN, /* USART Tx pin number */ \ - BSP_SERIAL_APP_RX_PIN, /* USART Rx pin number */ \ - 0, /* UART instance 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 */ \ - } - -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(); -} diff --git a/examples/platforms/k32w/Makefile.am b/examples/platforms/k32w/Makefile.am index b2f75289f..5dba50544 100755 --- a/examples/platforms/k32w/Makefile.am +++ b/examples/platforms/k32w/Makefile.am @@ -26,7 +26,7 @@ # POSSIBILITY OF SUCH DAMAGE. # -# Use automake includes since we cannot use SUBDIRS feature due to cleanup +# 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 diff --git a/examples/platforms/nrf528xx/Makefile.am b/examples/platforms/nrf528xx/Makefile.am index b227c272c..ac2923a5d 100644 --- a/examples/platforms/nrf528xx/Makefile.am +++ b/examples/platforms/nrf528xx/Makefile.am @@ -26,7 +26,7 @@ # POSSIBILITY OF SUCH DAMAGE. # -# Use automake includes since we cannot use SUBDIRS feature due to cleanup +# 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 diff --git a/third_party/silabs/Makefile.am b/third_party/silabs/Makefile.am index 17f155587..693676ca7 100644 --- a/third_party/silabs/Makefile.am +++ b/third_party/silabs/Makefile.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 @@ -27,6 +27,7 @@ # include $(abs_top_nlbuild_autotools_dir)/automake/pre.am +include $(top_srcdir)/examples/platforms/efr32/efr32_platform_defs.am lib_LIBRARIES = $(NULL) @@ -60,31 +61,15 @@ lib_LIBRARIES += $(NULL) endif -# Do not enable -Wconversion for Silicon Labs SDK sources -override CFLAGS := $(filter-out -Wconversion,$(CFLAGS)) -override CXXFLAGS := $(filter-out -Wconversion,$(CXXFLAGS)) - -# Do not enable -pedantic-errors for Silicon Labs SDK sources -override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) -override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) # Do not enable -Wshadow for Silicon Labs SDK sources override CFLAGS := $(filter-out -Wshadow,$(CFLAGS)) override CXXFLAGS := $(filter-out -Wshadow,$(CXXFLAGS)) -# Do not enable -Wundef for Silicon Labs SDK sources -override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) -override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) - # Do not enable -Wcast-align for Silicon Labs SDK sources override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS)) override CXXFLAGS := $(filter-out -Wcast-align,$(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 - # ============================================================================= SILABS_MBEDTLS_DIR = $(SDK_SRC_DIR)/util/third_party/mbedtls @@ -186,73 +171,15 @@ COMMONCPPFLAGS = -I$(top_srcdir)/src/core \ -I$(top_srcdir)/third_party/silabs/rail_config \ -I$(top_srcdir)/examples/platforms \ + -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) \ - -I$(SDK_SRC_DIR)/hardware/kit/common/bsp \ - -I$(SDK_SRC_DIR)/hardware/kit/common/drivers \ - -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/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/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/configs \ - -I$(SDK_SRC_DIR)/util/third_party/mbedtls/include \ - -I$(SDK_SRC_DIR)/util/third_party/mbedtls/sl_crypto/include \ + $(SILABS_GSDK_CPPFLAGS) \ -Wno-unused-parameter \ -Wno-missing-field-initializers \ $(NULL) -SILABS_EFR32MG1_CPPFLAGS = \ - -I$(SDK_SRC_DIR)/hardware/kit/EFR32MG1_$(BOARD_UPPERCASE)/config \ - -I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG1P/Include \ - -I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config/s1 \ - -I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \ - $(NULL) - -SILABS_EFR32MG12_CPPFLAGS = \ - -I$(SDK_SRC_DIR)/hardware/kit/EFR32MG12_$(BOARD_UPPERCASE)/config \ - -I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG12P/Include \ - -I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config/s1 \ - -I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \ - $(NULL) - -SILABS_EFR32MG13_CPPFLAGS = \ - -I$(SDK_SRC_DIR)/hardware/kit/EFR32MG13_$(BOARD_UPPERCASE)/config \ - -I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG13P/Include \ - -I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config/s1 \ - -I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg1x \ - $(NULL) - -SILABS_EFR32MG21_CPPFLAGS = \ - -I$(SDK_SRC_DIR)/hardware/kit/EFR32MG21_$(BOARD_UPPERCASE)/config \ - -I$(SDK_SRC_DIR)/platform/Device/SiliconLabs/EFR32MG21/Include \ - -I$(SDK_SRC_DIR)/platform/emdrv/nvm3/config/s2 \ - -I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/efr32xg2x \ - $(NULL) - SILABS_COMMON_SOURCES = \ rail_config/rail_config.c \ gecko_sdk_suite/v3.0/hardware/kit/common/bsp/bsp_bcc.c \ @@ -281,6 +208,7 @@ SILABS_COMMON_SOURCES gecko_sdk_suite/v3.0/platform/emlib/src/em_usart.c \ gecko_sdk_suite/v3.0/platform/radio/rail_lib/hal/efr32/hal_efr.c \ gecko_sdk_suite/v3.0/platform/radio/rail_lib/hal/hal_common.c \ + gecko_sdk_suite/v3.0/platform/radio/rail_lib/plugin/pa-conversions/pa_conversions_efr32.c \ gecko_sdk_suite/v3.0/platform/service/mpu/src/sl_mpu.c \ gecko_sdk_suite/v3.0/platform/service/sleeptimer/src/sl_sleeptimer.c \ gecko_sdk_suite/v3.0/platform/service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c \ @@ -316,43 +244,43 @@ SILABS_EFR32MG21_SOURCES $(NULL) libsilabs_efr32mg1_sdk_a_CPPFLAGS = \ - $(COMMONCPPFLAGS) \ $(SILABS_EFR32MG1_CPPFLAGS) \ + $(COMMONCPPFLAGS) \ $(NULL) libsilabs_efr32mg1_sdk_a_SOURCES = \ - $(SILABS_COMMON_SOURCES) \ $(SILABS_EFR32MG1_SOURCES) \ + $(SILABS_COMMON_SOURCES) \ $(NULL) libsilabs_efr32mg12_sdk_a_CPPFLAGS = \ - $(COMMONCPPFLAGS) \ $(SILABS_EFR32MG12_CPPFLAGS) \ + $(COMMONCPPFLAGS) \ $(NULL) libsilabs_efr32mg12_sdk_a_SOURCES = \ - $(SILABS_COMMON_SOURCES) \ $(SILABS_EFR32MG12_SOURCES) \ + $(SILABS_COMMON_SOURCES) \ $(NULL) libsilabs_efr32mg13_sdk_a_CPPFLAGS = \ - $(COMMONCPPFLAGS) \ $(SILABS_EFR32MG13_CPPFLAGS) \ + $(COMMONCPPFLAGS) \ $(NULL) libsilabs_efr32mg13_sdk_a_SOURCES = \ - $(SILABS_COMMON_SOURCES) \ $(SILABS_EFR32MG13_SOURCES) \ + $(SILABS_COMMON_SOURCES) \ $(NULL) libsilabs_efr32mg21_sdk_a_CPPFLAGS = \ - $(COMMONCPPFLAGS) \ $(SILABS_EFR32MG21_CPPFLAGS) \ + $(COMMONCPPFLAGS) \ $(NULL) libsilabs_efr32mg21_sdk_a_SOURCES = \ - $(SILABS_COMMON_SOURCES) \ $(SILABS_EFR32MG21_SOURCES) \ + $(SILABS_COMMON_SOURCES) \ $(NULL) noinst_HEADERS = \