diff --git a/.gitignore b/.gitignore index 5cdd4b63b657a24e4e48861796cfc61da90bf0a6..7a77f47194a8320734b0120c3b05a5bd787e97a6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,7 @@ COOJA.testlog *.jn516x *.native *.nrf52dk -*.openmote-cc2538 +*.openmote *.simplelink *.sky *.firmware @@ -45,7 +45,7 @@ COOJA.testlog !Makefile.jn516x !Makefile.native !Makefile.nrf52dk -!Makefile.openmote-cc2538 +!Makefile.openmote !Makefile.sky !Makefile.cc26x0-cc13x0 !Makefile.zoul diff --git a/.travis.yml b/.travis.yml index 29e853d0e61eeb4ca0981e823d01fb542ad86237..3a94e766fe1f14e10486e529c3338b75780d6437 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ # Setup environment for Docker language: generic services: docker +dist: trusty notifications: email: false @@ -49,7 +50,7 @@ before_install: # The test script for each build script: - - docker run --privileged -v $OUT_OF_TREE_TEST_PATH:/home/user/out-of-tree-tests -v $CNG_HOST_PATH:/home/user/contiki-ng -ti $DOCKER_IMG bash --login -c "make -C tests/??-$TEST_NAME"; + - docker run --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 -v $OUT_OF_TREE_TEST_PATH:/home/user/out-of-tree-tests -v $CNG_HOST_PATH:/home/user/contiki-ng -ti $DOCKER_IMG bash --login -c "make -C tests/??-$TEST_NAME"; # Check outcome of the test - $CNG_HOST_PATH/tests/check-test.sh $CNG_HOST_PATH/tests/??-$TEST_NAME; exit $?; @@ -73,6 +74,7 @@ env: - TEST_NAME='rpl-classic' BUILD_COOJA=true - TEST_NAME='tun-rpl-br' BUILD_COOJA=true - TEST_NAME='coap-lwm2m' + - TEST_NAME='script-base' - TEST_NAME='simulation-base' BUILD_COOJA=true - TEST_NAME='ieee802154' BUILD_COOJA=true - TEST_NAME='compile-nxp-ports' @@ -82,3 +84,4 @@ env: - TEST_NAME='ipv6' BUILD_COOJA=true - TEST_NAME='ipv6-nbr' BUILD_COOJA=true - TEST_NAME='out-of-tree-build' + - TEST_NAME='packet-parsing' diff --git a/Makefile.dir-variables b/Makefile.dir-variables new file mode 100644 index 0000000000000000000000000000000000000000..f67c1f4a7801337626c405ccd3af3318593d03ff --- /dev/null +++ b/Makefile.dir-variables @@ -0,0 +1,67 @@ +### This Makefile creates variables for all Contiki-NG directory locations +### Instead of storing them in the top-level Makefile.include, we store them +### in this separate Makefile here, which is included by Makefile.include +### This allows examples that wish to specify additional MODULES to include +### this Makefile and append to MODULES using the path variables defined here + +# Variables for the various directories under os/ +# Those are sometimes used relative to the top-level dir in which case we don't +# need to prepend $(CONTIKI), as well as relative to the example dir, in which +# case we do. So we define the variables to suit the former case and we will +# prepend $(CONTIKI) explicitly where needed. +CONTIKI_NG_OS_DIR = os +CONTIKI_NG_SYS_DIR = $(CONTIKI_NG_OS_DIR)/sys +CONTIKI_NG_NET_DIR = $(CONTIKI_NG_OS_DIR)/net +CONTIKI_NG_MAC_DIR = $(CONTIKI_NG_NET_DIR)/mac +CONTIKI_NG_ROUTING_DIR = $(CONTIKI_NG_NET_DIR)/routing +CONTIKI_NG_APP_LAYER_DIR = $(CONTIKI_NG_NET_DIR)/app-layer +CONTIKI_NG_SECURITY_DIR = $(CONTIKI_NG_NET_DIR)/security +CONTIKI_NG_DEV_DIR = $(CONTIKI_NG_OS_DIR)/dev +CONTIKI_NG_LIB_DIR = $(CONTIKI_NG_OS_DIR)/lib +CONTIKI_NG_SERVICES_DIR = $(CONTIKI_NG_OS_DIR)/services +CONTIKI_NG_STORAGE_DIR = $(CONTIKI_NG_OS_DIR)/storage + +# Variables for directories under arch +# +# We maintain backwards compatibility with ARCH_PATH, which allows us to +# relocate arch/cpu and arch/platform to an out-of-tree location without +# relocating arch/dev. +# +# $(CONTIKI_NG_RELOC_CPU_DIR) and $(CONTIKI_NG_RELOC_PLATFORM_DIR) will always +# hold the path of the respective dir, relative to the example dir +# +# If ARCH_PATH is _not_ specified, then the cpu/ & platform/ path relative to +# the top-level dir is simply expressed as $(CONTIKI_NG_ARCH_CPU_DIR). This +# allows us to use this variable to append to $(MODULES) +# +# If however ARCH_PATH _is_ specified then paths relative to the top-level +# cannot be expressed since they are always assumed to be under $(CONTIKI) +# while $(ARCH_PATH) is outside it. This means that directories under a +# relocated cpu/ and/or platform/ dir cannot be used as MODULES. This reflects +# old behaviour +ARCH_PATH ?= $(CONTIKI)/arch + +# Potentially relocated CPU/Platform dirs, relative to the example dir +CONTIKI_NG_RELOC_CPU_DIR = $(ARCH_PATH)/cpu +CONTIKI_NG_RELOC_PLATFORM_DIR = $(ARCH_PATH)/platform + +# A variable representing the location of the non-relocated arch/ dir. +# Used to construct variables for: +# * everything under arch/dev and arch/cpu/arm +# * non-relocated arch/cpu and arch/platform +CONTIKI_NG_ARCH_DIR = arch +CONTIKI_NG_ARCH_CPU_DIR = $(CONTIKI_NG_ARCH_DIR)/cpu +CONTIKI_NG_ARCH_PLATFORM_DIR = $(CONTIKI_NG_ARCH_DIR)/platform + +# Arm-related dirs relative to the top-level dir +CONTIKI_NG_ARM_DIR = $(CONTIKI_NG_ARCH_CPU_DIR)/arm +CONTIKI_NG_CORTEX_DIR = $(CONTIKI_NG_ARM_DIR)/cortex-m +CONTIKI_NG_CM3_DIR = $(CONTIKI_NG_CORTEX_DIR)/cm3 +CONTIKI_NG_CM4_DIR = $(CONTIKI_NG_CORTEX_DIR)/cm4 + +# arch/dev is used exclusively as a MODULE so we do not prepend $(CONTIKI) +CONTIKI_NG_DRIVERS_DIR = $(CONTIKI_NG_ARCH_DIR)/dev + +# tools/ is used exclusively to invoke commands therein and is always used in +# conjunction with $(CONTIKI) +CONTIKI_NG_TOOLS_DIR = $(CONTIKI)/tools diff --git a/Makefile.embedded b/Makefile.embedded index e6841926b48325dc408ccb27079c4ff75fb388be..ff948d89b86fc1d07c9ccc2e934700b38411042d 100644 --- a/Makefile.embedded +++ b/Makefile.embedded @@ -38,7 +38,7 @@ login: $(SERIAL_DUMP_BIN) ### ### Targets using tools/motelist ### -CONTIKI_NG_MOTELIST_DIR = $(TOOLS_DIR)/motelist +CONTIKI_NG_MOTELIST_DIR = $(CONTIKI_NG_TOOLS_DIR)/motelist CONTIKI_NG_MOTELIST = python $(CONTIKI_NG_MOTELIST_DIR)/motelist.py .PHONY: motelist-all diff --git a/Makefile.include b/Makefile.include index 6ebea14f4bb6266e8d69b5975bc63af819edca1d..b4224df4caebd28afc5f6cf7861e3395a085230a 100644 --- a/Makefile.include +++ b/Makefile.include @@ -4,6 +4,10 @@ ifndef CONTIKI ${error CONTIKI not defined! You must specify where Contiki resides} endif +### Include a helper Makefile that creates variables for all Contiki-NG path +### locations. +include $(CONTIKI)/Makefile.dir-variables + # Enable Werror by default. To disable from command line, use make WERROR=0. # Setting this option is also important for tests on Cooja motes to check for warnings. WERROR ?= 1 @@ -62,15 +66,17 @@ ifeq ($(WERROR),1) LDFLAGS += $(LDFLAGS_WERROR) endif -MODULES += os os/sys os/dev os/lib os/services +MODULES += $(CONTIKI_NG_OS_DIR) $(CONTIKI_NG_ARCH_DIR) +MODULES += $(CONTIKI_NG_SYS_DIR) $(CONTIKI_NG_LIB_DIR) $(CONTIKI_NG_DEV_DIR) +MODULES += $(CONTIKI_NG_NET_DIR) $(CONTIKI_NG_ROUTING_DIR) +MODULES += $(CONTIKI_NG_MAC_DIR) $(CONTIKI_NG_MAC_DIR)/framer +MODULES += $(CONTIKI_NG_STORAGE_DIR) $(CONTIKI_NG_SERVICES_DIR) # Automatically include project-conf.h if found ifneq ("$(wildcard project-conf.h)","") CFLAGS += -DPROJECT_CONF_PATH=\"project-conf.h\" endif -MODULES += os/net os/net/mac os/net/mac/framer os/net/routing os/storage - define oname ${patsubst %.c,%.o, \ ${patsubst %.S,%.o, \ @@ -86,10 +92,8 @@ uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))) ### Include target makefile (TODO Unsafe?) -# Configurable arch path -ARCH_PATH ?= $(CONTIKI)/arch - -target_makefile := $(wildcard $(ARCH_PATH)/platform/$(TARGET)/Makefile.$(TARGET) ${foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET)}) +target_makefile := $(wildcard $(CONTIKI_NG_RELOC_PLATFORM_DIR)/$(TARGET)/Makefile.$(TARGET) \ + $(foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET))) # Check if the target makefile exists, and create the object directory if necessary. ifeq ($(strip $(target_makefile)),) @@ -154,22 +158,22 @@ MAKE_MAC_OTHER = 4 MAKE_MAC ?= MAKE_MAC_CSMA ifeq ($(MAKE_MAC),MAKE_MAC_NULLMAC) - MODULES+=os/net/mac/nullmac + MODULES += $(CONTIKI_NG_MAC_DIR)/nullmac CFLAGS += -DMAC_CONF_WITH_NULLMAC=1 endif ifeq ($(MAKE_MAC),MAKE_MAC_CSMA) - MODULES += os/net/mac/csma + MODULES += $(CONTIKI_NG_MAC_DIR)/csma CFLAGS += -DMAC_CONF_WITH_CSMA=1 endif ifeq ($(MAKE_MAC),MAKE_MAC_TSCH) - MODULES += os/net/mac/tsch + MODULES += $(CONTIKI_NG_MAC_DIR)/tsch CFLAGS += -DMAC_CONF_WITH_TSCH=1 endif ifeq ($(MAKE_MAC),MAKE_MAC_BLE) - MODULES += os/net/mac/ble + MODULES += $(CONTIKI_NG_MAC_DIR)/ble CFLAGS += -DMAC_CONF_WITH_BLE=1 endif @@ -188,12 +192,12 @@ MAKE_NET ?= MAKE_NET_IPV6 ifeq ($(MAKE_NET),MAKE_NET_NULLNET) CFLAGS += -DNETSTACK_CONF_WITH_NULLNET=1 - MODULES += os/net/nullnet + MODULES += $(CONTIKI_NG_NET_DIR)/nullnet endif ifeq ($(MAKE_NET),MAKE_NET_IPV6) CFLAGS += -DNETSTACK_CONF_WITH_IPV6=1 - MODULES += os/net/ipv6 + MODULES += $(CONTIKI_NG_NET_DIR)/ipv6 endif ifeq ($(MAKE_NET),MAKE_NET_OTHER) @@ -201,7 +205,7 @@ ifeq ($(MAKE_NET),MAKE_NET_OTHER) endif ifeq ($(WITH_IP64),1) - MODULES += os/services/ip64 + MODULES += $(CONTIKI_NG_SERVICES_DIR)/ip64 endif # Configure Routing protocol @@ -218,13 +222,13 @@ endif ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) CFLAGS += -DROUTING_CONF_RPL_CLASSIC=1 - MODULES += os/net/routing/rpl-classic + MODULES += $(CONTIKI_NG_ROUTING_DIR)/rpl-classic else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE) CFLAGS += -DROUTING_CONF_RPL_LITE=1 - MODULES += os/net/routing/rpl-lite + MODULES += $(CONTIKI_NG_ROUTING_DIR)/rpl-lite else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_NULLROUTING) CFLAGS += -DROUTING_CONF_NULLROUTING=1 - MODULES += os/net/routing/nullrouting + MODULES += $(CONTIKI_NG_ROUTING_DIR)/nullrouting endif MODULEDIRS = $(MODULES_REL) ${addprefix $(CONTIKI)/, $(MODULES)} @@ -287,10 +291,9 @@ CONTIKI_TARGET_DIRS_CONCAT = ${addprefix ${dir $(target_makefile)}, \ $(CONTIKI_TARGET_DIRS)} CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \ $(CONTIKI_CPU_DIRS)} -CONTIKI_ARCH_DIRS = ${addprefix $(CONTIKI)/, arch} -SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) $(CONTIKI_ARCH_DIRS) \ - $(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(MODULEDIRS) $(EXTERNALDIRS) +SOURCEDIRS += . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \ + $(CONTIKI_CPU_DIRS_CONCAT) $(MODULEDIRS) $(EXTERNALDIRS) vpath %.c $(SOURCEDIRS) vpath %.S $(SOURCEDIRS) @@ -340,13 +343,13 @@ clean: @echo Target $(TARGET) cleaned distclean: - @for TARG in `ls $(ARCH_PATH)/platform $(TARGETDIRS)`; do \ + @for TARG in `ls $(CONTIKI_NG_RELOC_PLATFORM_DIR) $(TARGETDIRS)`; do \ echo Running: $(MAKE) TARGET=$$TARG clean; \ $(MAKE) TARGET=$$TARG clean; \ done -$(Q)rm -rf $(BUILD_DIR) --include $(ARCH_PATH)/platform/$(TARGET)/Makefile.customrules-$(TARGET) +-include $(CONTIKI_NG_RELOC_PLATFORM_DIR)/$(TARGET)/Makefile.customrules-$(TARGET) ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O $(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) @@ -428,7 +431,7 @@ endif include $(CONTIKI)/Makefile.help targets: - @ls $(ARCH_PATH)/platform $(TARGETDIRS) + @ls $(CONTIKI_NG_RELOC_PLATFORM_DIR) $(TARGETDIRS) boards: ifdef BOARD @@ -450,7 +453,7 @@ savedefines: @echo "saving Makefile.$(TARGET).defines" @echo >Makefile.$(TARGET).defines "DEFINES = $(DEFINES)" -VIEWCONF = $(CONTIKI)/tools/viewconf/viewconf.c +VIEWCONF = $(CONTIKI_NG_TOOLS_DIR)/viewconf/viewconf.c viewconf: @echo "----------------- Make variables: --------------" @echo "##### \"TARGET\": ________________________________ $(TARGET)" diff --git a/Makefile.tools b/Makefile.tools index 81653cde6e0b7a5a90a5e3b3b1588a5b9ef5dd77..c364a7d6f418970bc08924e4dd266afde52a25f2 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -2,8 +2,7 @@ # under the tools/ dir. For those dependencies, we use this makefile here to # recursively invoke the respective build under tools/. -TOOLS_DIR = $(CONTIKI)/tools -SERIAL_IO_TOOL_DIR = $(TOOLS_DIR)/serial-io +SERIAL_IO_TOOL_DIR = $(CONTIKI_NG_TOOLS_DIR)/serial-io SERIAL_IO_TOOL_DEPS = $(addprefix $(SERIAL_IO_TOOL_DIR)/, tools-utils.c tools-utils.h) diff --git a/README.md b/README.md index 99ee570f73b02e6bb76f0650a21c111d61be7951..b81bd910be88ea589cfe0e2597e685489c44e406 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # Contiki-NG: The OS for Next Generation IoT Devices [](https://travis-ci.org/contiki-ng/contiki-ng/branches) +[](https://contiki-ng.readthedocs.io/en/master/?badge=master) [](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md) [](https://github.com/contiki-ng/contiki-ng/releases/latest) [](https://github.com/contiki-ng/contiki-ng/releases/latest) @@ -23,6 +24,7 @@ Find out more: * GitHub repository: https://github.com/contiki-ng/contiki-ng * Documentation: https://github.com/contiki-ng/contiki-ng/wiki * Web site: http://contiki-ng.org +* Nightly testbed runs: https://contiki-ng.github.io/testbed Engage with the community: diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000000000000000000000000000000000..0d64c41956f4d5ab79772d2e9e5aa41e980b5adb --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,21 @@ +# Security Policy + +## Supported Versions + +We will always apply vulnerability fixes on branch `develop` and include them +in the next release. Depending on the severity, we will consider hotfixing +the most recent release too. Older releases will not be hotfixed. + +| Version | Supported | +| ------- | ------------------ | +| branch `develop` | :white_check_mark: | +| [latest release](https://github.com/contiki-ng/contiki-ng/releases/latest) | :question: | +| older releases | :x: | + +## Reporting a Vulnerability + +To report a vulnerability privately please email security@contiki-ng.org + +We will try to confirm or decline your report ASAP by email. For accepted +vulnerability reports we will create an [advisory](https://github.com/contiki-ng/contiki-ng/security/advisories) +and, if you wish, invite you to the discussion. diff --git a/arch/cpu/arm/cortex-m/Makefile.cortex-m b/arch/cpu/arm/cortex-m/Makefile.cortex-m index 3f14ead419419243bdd9e1c4ca6e1eabd1fc2afb..36ff44718e439c594afc0c93c8c1360492019874 100644 --- a/arch/cpu/arm/cortex-m/Makefile.cortex-m +++ b/arch/cpu/arm/cortex-m/Makefile.cortex-m @@ -25,4 +25,4 @@ $(OUT_ELF): $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES) $(TRACE_LD) $(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFLAGS) -o $@ -include $(ARCH_PATH)/cpu/arm/Makefile.arm +include $(CONTIKI)/$(CONTIKI_NG_ARM_DIR)/Makefile.arm diff --git a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 index 35051a0f77d7da809492d0488d70243d2a6e4862..19bd69cab4edfa4b62675a6f42209b5b92e3329f 100644 --- a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 +++ b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 @@ -6,4 +6,4 @@ LDFLAGS += -mcpu=cortex-m3 -nostartfiles TARGET_LIBFILES += -lm -include $(ARCH_PATH)/cpu/arm/cortex-m/Makefile.cortex-m +include $(CONTIKI)/$(CONTIKI_NG_CORTEX_DIR)/Makefile.cortex-m diff --git a/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 b/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 index dc470601ff30a2b0b7504f3f2bd087db9a8c5859..4a50d9724e7db9227c6d0ae79463350ad02397a0 100644 --- a/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 +++ b/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 @@ -4,4 +4,4 @@ CFLAGS += -mcpu=cortex-m4 LDFLAGS += -mcpu=cortex-m4 -include $(ARCH_PATH)/cpu/arm/cortex-m/Makefile.cortex-m +include $(CONTIKI)/$(CONTIKI_NG_CORTEX_DIR)/Makefile.cortex-m diff --git a/arch/cpu/cc2538/Makefile.cc2538 b/arch/cpu/cc2538/Makefile.cc2538 index 85f435320d8f0670b5ed26573be31fac26be467d..592144c519481bd435938a0d3c18c9d6a9dddbfa 100644 --- a/arch/cpu/cc2538/Makefile.cc2538 +++ b/arch/cpu/cc2538/Makefile.cc2538 @@ -52,4 +52,4 @@ $(LDSCRIPT): $(SOURCE_LDSCRIPT) FORCE | $(OBJECTDIR) $(TRACE_CC) $(Q)$(CC) $(LDGENFLAGS) $< | grep -v '^\s*#\s*pragma\>' > $@ -include $(ARCH_PATH)/cpu/arm/cortex-m/cm3/Makefile.cm3 +include $(CONTIKI)/$(CONTIKI_NG_CM3_DIR)/Makefile.cm3 diff --git a/arch/cpu/cc2538/cc2538-conf.h b/arch/cpu/cc2538/cc2538-conf.h index bb92fb7e38aa40b369fc44f0dd9b39417e4518c2..d34c3dee5fe27aa203639a365b3ae65903492606 100644 --- a/arch/cpu/cc2538/cc2538-conf.h +++ b/arch/cpu/cc2538/cc2538-conf.h @@ -263,11 +263,6 @@ #ifndef NETSTACK_CONF_RADIO #define NETSTACK_CONF_RADIO cc2538_rf_driver #endif - -/** - * \brief Maximum packet size - */ -#define cc2538_rf_driver_max_payload_len 125 /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/cpu/cc2538/dev/cc2538-rf.c b/arch/cpu/cc2538/dev/cc2538-rf.c index e1bbfbfd140bc8e30db67f0b3d6fd91e54ff320e..24a3c636f493fe2a1d9a1b0dff4d7e9e03a85ff9 100644 --- a/arch/cpu/cc2538/dev/cc2538-rf.c +++ b/arch/cpu/cc2538/dev/cc2538-rf.c @@ -148,6 +148,13 @@ static radio_result_t get_value(radio_param_t param, radio_value_t *value); #define OUTPUT_POWER_MIN (output_power[OUTPUT_CONFIG_COUNT - 1].power) #define OUTPUT_POWER_MAX (output_power[0].power) /*---------------------------------------------------------------------------*/ +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the FCS. + */ +#define MAX_PAYLOAD_LEN (CC2538_RF_MAX_PACKET_LEN - CHECKSUM_LEN) +/*---------------------------------------------------------------------------*/ PROCESS(cc2538_rf_process, "cc2538 RF driver"); /*---------------------------------------------------------------------------*/ /** @@ -600,7 +607,7 @@ prepare(const void *payload, unsigned short payload_len) { uint8_t i; - if(payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } @@ -665,7 +672,7 @@ transmit(unsigned short transmit_len) LOG_INFO("Transmit\n"); - if(transmit_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(transmit_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } @@ -934,6 +941,9 @@ get_value(radio_param_t param, radio_value_t *value) case RADIO_CONST_DELAY_BEFORE_DETECT: *value = (radio_value_t)CC2538_DELAY_BEFORE_DETECT; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } diff --git a/arch/cpu/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 b/arch/cpu/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 index 19da237ae9da20bcbbee93f20b304b531859660e..f62db1122b72ce979d733e2141558c39a87c29af 100644 --- a/arch/cpu/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 +++ b/arch/cpu/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 @@ -1,4 +1,4 @@ -CPU_ABS_PATH = arch/cpu/cc26x0-cc13x0 +CPU_ABS_PATH = $(CONTIKI_NG_ARCH_CPU_DIR)/cc26x0-cc13x0 TI_XXWARE = $(CONTIKI_CPU)/$(TI_XXWARE_PATH) ifeq (,$(wildcard $(TI_XXWARE)/*)) @@ -57,7 +57,7 @@ ifdef PORT BSL_FLAGS += -p $(PORT) endif -BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py +BSL = $(CONTIKI_NG_TOOLS_DIR)/cc2538-bsl/cc2538-bsl.py ### Always re-build ieee-addr.o in case the command line passes a new NODEID FORCE: @@ -82,7 +82,7 @@ STACK_SIZE = 0 @$(SIZE) -A $< | egrep "data|bss" | awk '{s+=$$2} END {s=s+$(STACK_SIZE); f=$(RAM_SIZE)-s; printf "[RAM] used %6d, free %6d\n",s,f;}' @$(SIZE) -A $< | egrep "text|isr_vector" | awk '{s+=$$2} END {f=$(FLASH_SIZE)-s; printf "[Flash] used %6d, free %6d\n",s,f;}' -include $(ARCH_PATH)/cpu/arm/cortex-m/cm3/Makefile.cm3 +include $(CONTIKI)/$(CONTIKI_NG_CM3_DIR)/Makefile.cm3 ifeq ($(BOARD_SUPPORTS_BSL),1) %.upload: $(OUT_BIN) diff --git a/arch/cpu/cc26x0-cc13x0/cc13xx-cc26xx-conf.h b/arch/cpu/cc26x0-cc13x0/cc13xx-cc26xx-conf.h index 8b8ea38795b2917fe8602879197b0224982dac33..258472d5a112332a71527dd6f3f70bbfabd80696 100644 --- a/arch/cpu/cc26x0-cc13x0/cc13xx-cc26xx-conf.h +++ b/arch/cpu/cc26x0-cc13x0/cc13xx-cc26xx-conf.h @@ -104,14 +104,6 @@ #ifndef AES_128_CONF #define AES_128_CONF cc26xx_aes_128_driver #endif /* AES_128_CONF */ - -/* This is fixed */ -#define ieee_mode_driver_max_payload_len 125 -/* This maybe changed in the future, with software upgrade */ -#define prop_mode_driver_max_payload_len 125 -/* This is not used, but needs to be defined in order to compile */ -#define ble_cc2650_driver_max_payload_len 125 - /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/cpu/cc26x0-cc13x0/dev/contiki-watchdog.c b/arch/cpu/cc26x0-cc13x0/dev/contiki-watchdog.c index f8eb4f666830585a5bf3a9db027b6c2a01beebf8..7602847f3eb323a36158bc5a91c5a99db8fb9ebf 100644 --- a/arch/cpu/cc26x0-cc13x0/dev/contiki-watchdog.c +++ b/arch/cpu/cc26x0-cc13x0/dev/contiki-watchdog.c @@ -49,10 +49,11 @@ #include <stdbool.h> #include <stdint.h> /*---------------------------------------------------------------------------*/ +/* Watchdog timer interval, in milliseconds */ #ifdef CONTIKI_WATCHDOG_CONF_TIMER_TOP #define CONTIKI_WATCHDOG_TIMER_TOP CONTIKI_WATCHDOG_CONF_TIMER_TOP #else -#define CONTIKI_WATCHDOG_TIMER_TOP 0xFFFFF +#define CONTIKI_WATCHDOG_TIMER_TOP 1100 #endif #ifdef CONTIKI_WATCHDOG_CONF_LOCK_CONFIG @@ -61,6 +62,9 @@ #define CONTIKI_WATCHDOG_LOCK_CONFIG 1 #endif +/* Convert timer interval from ms to ticks. Clock runs at 48 MHz / 32 */ +#define WATCHDOG_TIMER_TOP_TICK ((48000 / 32) * CONTIKI_WATCHDOG_TIMER_TOP) + #define LOCK_INTERRUPTS_DISABLED 0x01 #define LOCK_REGISTERS_UNLOCKED 0x02 /*---------------------------------------------------------------------------*/ @@ -107,7 +111,7 @@ lock_config(uint32_t status) void watchdog_init(void) { - ti_lib_watchdog_reload_set(CONTIKI_WATCHDOG_TIMER_TOP); + ti_lib_watchdog_reload_set(WATCHDOG_TIMER_TOP_TICK); lock_config(LOCK_REGISTERS_UNLOCKED); } /*---------------------------------------------------------------------------*/ @@ -131,7 +135,7 @@ watchdog_start(void) void watchdog_periodic(void) { - ti_lib_watchdog_reload_set(CONTIKI_WATCHDOG_TIMER_TOP); + ti_lib_watchdog_reload_set(WATCHDOG_TIMER_TOP_TICK); ti_lib_watchdog_int_clear(); } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc26x0-cc13x0/lpm.c b/arch/cpu/cc26x0-cc13x0/lpm.c index 2337fb24f8f41dcf5a741e44e4ba57525178728c..c5eba45c972a34c1433f1c371c0cdc91284e6c74 100644 --- a/arch/cpu/cc26x0-cc13x0/lpm.c +++ b/arch/cpu/cc26x0-cc13x0/lpm.c @@ -65,12 +65,15 @@ LIST(modules_list); * Don't consider standby mode if the next AON RTC event is scheduled to fire * in less than STANDBY_MIN_DURATION rtimer ticks */ -#define STANDBY_MIN_DURATION (RTIMER_SECOND / 100) /* 10.0 ms */ +#define STANDBY_MIN_DURATION (RTIMER_SECOND / 100) /* 10.0 ms */ /* Wake up this much time earlier before the next rtimer */ -#define SLEEP_GUARD_TIME (RTIMER_SECOND / 1000) /* 1.0 ms */ +#define SLEEP_GUARD_TIME (RTIMER_SECOND / 1000) /* 1.0 ms */ +/* Maximum allowed sleep-time, must be shorter than watchdog timeout */ #define MAX_SLEEP_TIME RTIMER_SECOND + +/* Minimal safe sleep-time */ #define MIN_SAFE_SCHEDULE 8u /*---------------------------------------------------------------------------*/ /* Prototype of a function in clock.c. Called every time we come out of DS */ @@ -382,6 +385,9 @@ lpm_sleep(void) ti_lib_prcm_sleep(); + /* Kick watchdog to ensure a full interval is available after sleep */ + watchdog_periodic(); + ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc26x0-cc13x0/rf-core/ieee-mode.c b/arch/cpu/cc26x0-cc13x0/rf-core/ieee-mode.c index 3b9472f26c1f89acaaf5563edc8ec3a936c24dbe..5dc5fc37a5be8e45376cca4f738603a618248b09 100644 --- a/arch/cpu/cc26x0-cc13x0/rf-core/ieee-mode.c +++ b/arch/cpu/cc26x0-cc13x0/rf-core/ieee-mode.c @@ -181,6 +181,19 @@ static rfc_CMD_IEEE_MOD_FILT_t filter_cmd; */ static uint8_t cmd_ieee_rx_buf[RF_CMD_BUFFER_SIZE] CC_ALIGN(4); /*---------------------------------------------------------------------------*/ +/* + * The number of bytes appended at the end of an outgoing frame as a footer + * Currently fixed at 2 bytes for IEEE 802.15.4 compliance. + */ +#define CHECKSUM_LEN 2 + +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the FCS. + */ +#define MAX_PAYLOAD_LEN (127 - CHECKSUM_LEN) +/*---------------------------------------------------------------------------*/ #define DATA_ENTRY_LENSZ_NONE 0 #define DATA_ENTRY_LENSZ_BYTE 1 #define DATA_ENTRY_LENSZ_WORD 2 /* 2 bytes */ @@ -198,7 +211,7 @@ static uint8_t cmd_ieee_rx_buf[RF_CMD_BUFFER_SIZE] CC_ALIGN(4); #define RX_BUF_DATA_OFFSET (RX_BUF_LENGTH_OFFSET + 1) #define RX_BUF_SIZE (RX_BUF_DATA_OFFSET \ - + NETSTACK_RADIO_MAX_PAYLOAD_LEN \ + + MAX_PAYLOAD_LEN \ + RX_BUF_METADATA_SIZE) /* Four receive buffers entries with room for 1 IEEE802.15.4 frame in each */ @@ -767,7 +780,7 @@ init(void) static int prepare(const void *payload, unsigned short payload_len) { - if(payload_len > TX_BUF_PAYLOAD_LEN || payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > TX_BUF_PAYLOAD_LEN || payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } @@ -786,7 +799,7 @@ transmit(unsigned short transmit_len) rtimer_clock_t t0; volatile rfc_CMD_IEEE_TX_t cmd; - if(transmit_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(transmit_len > MAX_PAYLOAD_LEN) { PRINTF("transmit: too long\n"); return RADIO_TX_ERR; } @@ -1283,6 +1296,9 @@ get_value(radio_param_t param, radio_value_t *value) case RADIO_CONST_DELAY_BEFORE_DETECT: *value = (radio_value_t)RADIO_DELAY_BEFORE_DETECT; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } diff --git a/arch/cpu/cc26x0-cc13x0/rf-core/prop-mode.c b/arch/cpu/cc26x0-cc13x0/rf-core/prop-mode.c index 7bee3ff15cbb254cb8a775f922abfcf9d8e68711..515a8d7bc4ebe5538692c7c753669a7999a52301 100644 --- a/arch/cpu/cc26x0-cc13x0/rf-core/prop-mode.c +++ b/arch/cpu/cc26x0-cc13x0/rf-core/prop-mode.c @@ -156,6 +156,24 @@ static rfc_propRxOutput_t rx_stats; #define DOT_4G_PHR_DW_BIT 0 #endif /*---------------------------------------------------------------------------*/ +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the CRC. + * + * Unlike typical 2.4GHz radio drivers, this driver supports the .15.4g + * 32-bit CRC option. + * + * This radio hardware is perfectly happy to transmit frames longer than 127 + * bytes, which is why it's OK to end up transmitting 125 payload bytes plus + * a 4-byte CRC. + * + * In the future we can change this to support transmission of long frames, + * for example as per .15.4g. the size of the TX and RX buffers would need + * adjusted accordingly. + */ +#define MAX_PAYLOAD_LEN 125 +/*---------------------------------------------------------------------------*/ /* TX power table for the 431-527MHz band */ #ifdef PROP_MODE_CONF_TX_POWER_431_527 #define PROP_MODE_TX_POWER_431_527 PROP_MODE_CONF_TX_POWER_431_527 @@ -217,7 +235,7 @@ static const prop_mode_tx_power_config_t *tx_power_current = &TX_POWER_DRIVER[1] #define ALIGN_TO_4(size) (((size) + 3) & ~3) #define RX_BUF_SIZE ALIGN_TO_4(RX_BUF_DATA_OFFSET \ - + NETSTACK_RADIO_MAX_PAYLOAD_LEN \ + + MAX_PAYLOAD_LEN \ + RX_BUF_METADATA_SIZE) /* @@ -661,7 +679,7 @@ init(void) static int prepare(const void *payload, unsigned short payload_len) { - if(payload_len > TX_BUF_PAYLOAD_LEN || payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > TX_BUF_PAYLOAD_LEN || payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } @@ -680,7 +698,7 @@ transmit(unsigned short transmit_len) /* Length in .15.4g PHY HDR. Includes the CRC but not the HDR itself */ uint16_t total_length; - if(transmit_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(transmit_len > MAX_PAYLOAD_LEN) { PRINTF("transmit: too long\n"); return RADIO_TX_ERR; } @@ -817,10 +835,29 @@ static int read_frame(void *buf, unsigned short buf_len) { rfc_dataEntryGeneral_t *entry = (rfc_dataEntryGeneral_t *)rx_read_entry; - uint8_t *data_ptr = &entry->data; + uint8_t *data_ptr; int len = 0; uint32_t rat_timestamp; + int is_found = 0; + /* Go through all RX buffers and check their status */ + do { + if(entry->status == DATA_ENTRY_STATUS_FINISHED + || entry->status == DATA_ENTRY_STATUS_BUSY) { + is_found = 1; + break; + } + + entry = (rfc_dataEntryGeneral_t *)entry->pNextEntry; + } while(entry != (rfc_dataEntryGeneral_t *)rx_read_entry); + + if(is_found == 0) { + /* No available data */ + return 0; + } + + rx_read_entry = (volatile uint8_t *)entry; + /* wait for entry to become finished */ rtimer_clock_t t0 = RTIMER_NOW(); while(entry->status == DATA_ENTRY_STATUS_BUSY @@ -842,6 +879,7 @@ read_frame(void *buf, unsigned short buf_len) * Payload + RSSI (1 byte) + Timestamp (4 bytes) + Status (1 byte) * This length includes all of those. */ + data_ptr = &entry->data; len = (*(uint16_t *)data_ptr); if(len <= RX_BUF_METADATA_SIZE) { @@ -1234,6 +1272,9 @@ get_value(radio_param_t param, radio_value_t *value) case RADIO_CONST_DELAY_BEFORE_DETECT: *value = (radio_value_t)RADIO_DELAY_BEFORE_DETECT; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } diff --git a/arch/cpu/msp430/Makefile.msp430 b/arch/cpu/msp430/Makefile.msp430 index 7927002b67b265930ff7c8b39ac02ff9b3ce2dcc..198076e95d496f61da5c1cffedf8a4a34f301b16 100644 --- a/arch/cpu/msp430/Makefile.msp430 +++ b/arch/cpu/msp430/Makefile.msp430 @@ -1,6 +1,6 @@ # $Id: Makefile.msp430,v 1.35 2011/01/19 07:30:31 adamdunkels Exp $ -COOJA_PATH ?= $(CONTIKI)/tools/cooja +COOJA_PATH ?= $(CONTIKI_NG_TOOLS_DIR)/cooja ifdef nodeid CFLAGS += -DNODEID=$(nodeid) @@ -11,7 +11,7 @@ CFLAGS += -gstabs+ .SUFFIXES: ### Define the CPU directory -CONTIKI_CPU=$(ARCH_PATH)/cpu/msp430 +CONTIKI_CPU = $(CONTIKI_NG_RELOC_CPU_DIR)/msp430 ### Define the source files we have in the MSP430 port @@ -225,12 +225,3 @@ $(COOJA_PATH)/mspsim/mspsim.jar: $(COOJA_PATH)/mspsim/build.xml %.mspsim-maptable: %.$(TARGET) java -classpath ${COOJA_PATH}/mspsim/mspsim.jar se.sics.mspsim.util.MapTable $(CONTIKI_NG_PROJECT_MAP) - -core-labels.o: core.${TARGET} - ${CONTIKI}/tools/msp430-make-labels core.${TARGET} > core-labels.S - $(AS) -o $@ core-labels.S -# cp core-labels.o app/ - -core-globals.o: core.${TARGET} - ${CONTIKI}/tools/msp430-make-globals core.${TARGET} > core-globals.S - $(AS) -o $@ core-globals.S diff --git a/arch/cpu/msp430/msp430-conf.h b/arch/cpu/msp430/msp430-conf.h index 91ae6ac4df90f8003d888c9f4dd62e5b76eff2d8..a20a213b99ae3c5d1860c2ca0f6fa22e98662c60 100644 --- a/arch/cpu/msp430/msp430-conf.h +++ b/arch/cpu/msp430/msp430-conf.h @@ -55,9 +55,6 @@ #define SLIP_ARCH_CONF_ENABLED 0 #endif #endif - -#define cc2420_driver_max_payload_len 125 - /*---------------------------------------------------------------------------*/ #endif /* MSP430_CONF_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/native/rtimer-arch.c b/arch/cpu/native/rtimer-arch.c index ad081c9f51a5818cbc905ee52f15cd59acfe4afc..f140ae4cc96dc4a9b3b063675b3fc8deccdd3056 100644 --- a/arch/cpu/native/rtimer-arch.c +++ b/arch/cpu/native/rtimer-arch.c @@ -77,13 +77,13 @@ rtimer_arch_schedule(rtimer_clock_t t) struct itimerval val; rtimer_clock_t c; - c = t - (unsigned short)clock_time(); + c = t - clock_time(); val.it_value.tv_sec = c / CLOCK_SECOND; val.it_value.tv_usec = (c % CLOCK_SECOND) * CLOCK_SECOND; - PRINTF("rtimer_arch_schedule time %u %u in %d.%d seconds\n", t, c, val.it_value.tv_sec, - val.it_value.tv_usec); + PRINTF("rtimer_arch_schedule time %"PRIu32 " %"PRIu32 " in %ld.%ld seconds\n", + t, c, (long)val.it_value.tv_sec, (long)val.it_value.tv_usec); val.it_interval.tv_sec = val.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &val, NULL); diff --git a/arch/cpu/nrf52832/Makefile.nrf52832 b/arch/cpu/nrf52832/Makefile.nrf52832 index 102e74486045320eb2cb33f3fd68381710dad0d8..b02f9af2088fc73a39d6f6c1759a11e9ce0aa2f8 100644 --- a/arch/cpu/nrf52832/Makefile.nrf52832 +++ b/arch/cpu/nrf52832/Makefile.nrf52832 @@ -185,7 +185,7 @@ $(OBJECT_DIRECTORY)/%.o: %.s $(TRACE_CC) $(Q)$(CC) $(ASMFLAGS) $(addprefix -I$(NRF52_SDK_ROOT)/, $(INC_PATHS)) -c -o $@ $< -include $(ARCH_PATH)/cpu/arm/cortex-m/cm4/Makefile.cm4 +include $(CONTIKI)/$(CONTIKI_NG_CM4_DIR)/Makefile.cm4 %.jlink: $(OUT_HEX) sed -e 's,#OUTPUT_FILENAME#,$<,' $(CONTIKI_CPU)/flash.jlink > $@ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/Makefile.cc13xx-cc26xx b/arch/cpu/simplelink-cc13xx-cc26xx/Makefile.cc13xx-cc26xx index bb7bf82f59297314e39654d6d6f0d685066fb903..303600bdc2156b6574d4791bcf037366db7e455f 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/Makefile.cc13xx-cc26xx +++ b/arch/cpu/simplelink-cc13xx-cc26xx/Makefile.cc13xx-cc26xx @@ -34,13 +34,8 @@ endif # Also note that the devices name is cc13x2_cc26x2 for all CC13x2/CC26x2 # devices, while the library name is individual for each device family. ifeq ($(SUBFAMILY),cc13x2-cc26x2) - ifeq ($(CC13x2_CC26x2_PRE_RTM),1) - SDK_DEVICES_NAME := cc13x2_cc26x2_v1 - SDK_LIB_NAME := $(DEVICE_FAMILY_LC)_v1 - else - SDK_DEVICES_NAME := cc13x2_cc26x2_v2 - SDK_LIB_NAME := $(DEVICE_FAMILY_LC)_v2 - endif + SDK_DEVICES_NAME := cc13x2_cc26x2 + SDK_LIB_NAME := $(DEVICE_FAMILY_LC) # CC13x0/CC26x0 does not have this, with both its devices name and library # name the same as its own device family name. else @@ -147,3 +142,29 @@ $(OBJECTDIR)/ccfg-conf.o: ccfg-conf.c FORCE | $(OBJECTDIR) # Include the Sub-family Makefile specific for the specified device include $(CONTIKI_CPU)/$(SUBFAMILY)/Makefile.$(SUBFAMILY) + +################################################################################ +### For the .upload make target +PYTHON = python +BSL_FLAGS += -e -w -v + +ifdef PORT + BSL_FLAGS += -p $(PORT) +endif + +BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py + +ifeq ($(BOARD_SUPPORTS_BSL),1) +%.upload: $(OUT_BIN) +ifeq ($(wildcard $(BSL)), ) + @echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?" +else + $(PYTHON) $(BSL) $(BSL_FLAGS) $< +endif +else +%.upload: + @echo "This board cannot be programmed through the ROM bootloader and therefore does not support the .upload target." +endif + +### For the login etc targets +BAUDRATE ?= 115200 diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/cc13x0-cc26x0/Makefile.cc13x0-cc26x0 b/arch/cpu/simplelink-cc13xx-cc26xx/cc13x0-cc26x0/Makefile.cc13x0-cc26x0 index 9be4ad6ab3811f0c34a3fcb392dbd8988e4ef3a5..578fdb2f5831913c14485f905cacac1cbefe3681 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/cc13x0-cc26x0/Makefile.cc13x0-cc26x0 +++ b/arch/cpu/simplelink-cc13xx-cc26xx/cc13x0-cc26x0/Makefile.cc13x0-cc26x0 @@ -8,4 +8,4 @@ TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am3g TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib # CC13x0/CC26x0 is a Cortex-M3 architecture -include $(ARCH_PATH)/cpu/arm/cortex-m/cm3/Makefile.cm3 +include $(CONTIKI)/$(CONTIKI_NG_CM3_DIR)/Makefile.cm3 diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/Makefile.cc13x2-cc26x2 b/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/Makefile.cc13x2-cc26x2 index afe0ae4292ef523377e5942fe1b3629c6e6a933f..9a8ee13d7bec9633c92e4aad76649530a97fe7db 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/Makefile.cc13x2-cc26x2 +++ b/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/Makefile.cc13x2-cc26x2 @@ -8,4 +8,4 @@ TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am4fg TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib # CC13x2/CC26x2 is a Cortex-M4 architecture -include $(ARCH_PATH)/cpu/arm/cortex-m/cm4/Makefile.cm4 +include $(CONTIKI)/$(CONTIKI_NG_CM4_DIR)/Makefile.cm4 diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/cc13x2-cc26x2.lds b/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/cc13x2-cc26x2.lds index dc1a608be47fa06ec395b0f10dd8791de95a1aae..11a490edc07cd2f6ef9683bc168cc39f11926cfc 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/cc13x2-cc26x2.lds +++ b/arch/cpu/simplelink-cc13xx-cc26xx/cc13x2-cc26x2/cc13x2-cc26x2.lds @@ -87,8 +87,13 @@ SECTIONS { DMA_GPT0A_PRI_CTEA = (UDMACC26XX_CONFIG_BASE + 0x90); DMA_SPI1_RX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x100); DMA_SPI1_TX_CTEA = (UDMACC26XX_CONFIG_BASE + 0x110); - DMA_ADC_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x270); - DMA_GPT0A_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x290); + + DMA_SPI0_RX_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x230); + DMA_SPI0_TX_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x240); + DMA_ADC_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x270); + DMA_GPT0A_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x290); + DMA_SPI1_RX_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x300); + DMA_SPI1_TX_ALT_CTEA = (UDMACC26XX_CONFIG_BASE + 0x310); /* * Allocate SPI0, SPI1, ADC, and GPTimer0 DMA descriptors at absolute addresses. @@ -124,6 +129,16 @@ SECTIONS { *(.dmaSpi1TxControlTableEntry) } > REGION_DATA + UDMACC26XX_dmaSpi0RxAltControlTableEntry_is_placed = 0; + .dmaSpi0RxAltControlTableEntry DMA_SPI0_RX_ALT_CTEA (NOLOAD) : AT (DMA_SPI0_RX_ALT_CTEA) { + *(.dmaSpi0RxAltControlTableEntry) + } > REGION_DATA + + UDMACC26XX_dmaSpi0TxAltControlTableEntry_is_placed = 0; + .dmaSpi0TxAltControlTableEntry DMA_SPI0_TX_ALT_CTEA (NOLOAD) : AT (DMA_SPI0_TX_ALT_CTEA) { + *(.dmaSpi0TxAltControlTableEntry) + } > REGION_DATA + UDMACC26XX_dmaADCAltControlTableEntry_is_placed = 0; .dmaADCAltControlTableEntry DMA_ADC_ALT_CTEA (NOLOAD) : AT (DMA_ADC_ALT_CTEA) { *(.dmaADCAltControlTableEntry) @@ -134,6 +149,16 @@ SECTIONS { *(.dmaGPT0AAltControlTableEntry) } > REGION_DATA + UDMACC26XX_dmaSpi1RxAltControlTableEntry_is_placed = 0; + .dmaSpi1RxAltControlTableEntry DMA_SPI1_RX_ALT_CTEA (NOLOAD) : AT (DMA_SPI1_RX_ALT_CTEA) { + *(.dmaSpi1RxAltControlTableEntry) + } > REGION_DATA + + UDMACC26XX_dmaSpi1TxAltControlTableEntry_is_placed = 0; + .dmaSpi1TxAltControlTableEntry DMA_SPI1_TX_ALT_CTEA (NOLOAD) : AT (DMA_SPI1_TX_ALT_CTEA) { + *(.dmaSpi1TxAltControlTableEntry) + } > REGION_DATA + .text : { CREATE_OBJECT_SYMBOLS *(.text) diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/cc13xx-cc26xx-conf.h b/arch/cpu/simplelink-cc13xx-cc26xx/cc13xx-cc26xx-conf.h index 2cfb9f43960ce6b50c740e250bf9f08860bc2171..7cc824ce65bd91923fbbfc3edf07ee77d7124642 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/cc13xx-cc26xx-conf.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/cc13xx-cc26xx-conf.h @@ -91,15 +91,19 @@ #endif /* - * Configure TX power to either default PA or High PA, defaults to - * default PA. + * Configure the TX power for the netstack, specified in dBm. Defaults to + * maximum available TX power setting for the specific PHY. */ -#ifndef RF_CONF_TXPOWER_HIGH_PA -#define RF_CONF_TXPOWER_HIGH_PA 0 +#ifndef RF_CONF_TXPOWER_DBM +#define RF_CONF_TXPOWER_DBM RF_TXPOWER_MAX_DBM #endif -#if (RF_CONF_TXPOWER_HIGH_PA) && !(SUPPORTS_HIGH_PA) -#error "Device does not support High PA" +/* + * Configure the TX power for the BLE beacon, specified in dBm. + * Defaults to maximum available TX power setting for the specific PHY. + */ +#ifndef RF_CONF_BLE_TXPOWER_DBM +#define RF_CONF_BLE_TXPOWER_DBM RF_TXPOWER_MAX_DBM #endif /* @@ -234,10 +238,6 @@ #else #error "Unsupported Device Line defined" #endif /* Unsupported device line */ - -#define prop_mode_driver_max_payload_len 125 -#define ieee_mode_driver_max_payload_len 125 - /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.c b/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.c index 6df55733a1ab3ee30bd419be16d972f9feee3ead..8ab79cb78b4e805ac8b932ecfef71d1f7dddb8fb 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.c @@ -51,6 +51,7 @@ #include DeviceFamily_constructPath(driverlib/systick.h) #include <ti/drivers/dpl/ClockP.h> +#include <ti/drivers/power/PowerCC26XX.h> /*---------------------------------------------------------------------------*/ #include "watchdog-arch.h" /*---------------------------------------------------------------------------*/ @@ -161,17 +162,15 @@ clock_arch_enter_idle(void) /* We are not going to sleep, and hence we don't arm the wakeup clock. */ return false; } - if(timeout == NO_TIMEOUT) { - /* We are going to some low-power mode without arming the wakeup clock. */ - return true; + + /* We are dropping to some low-power mode */ + + /* Arm the wakeup clock with the calculated timeout if there is any */ + if(timeout != NO_TIMEOUT) { + ClockP_setTimeout(H_WAKEUP_CLK, timeout); + ClockP_start(H_WAKEUP_CLK); } - /* - * We are going to some low-power mode. Arm the wakeup clock with the - * calculated. - */ - ClockP_setTimeout(H_WAKEUP_CLK, timeout); - ClockP_start(H_WAKEUP_CLK); return true; } /*---------------------------------------------------------------------------*/ @@ -182,6 +181,22 @@ clock_arch_exit_idle(void) } /*---------------------------------------------------------------------------*/ void +clock_arch_standby_policy(void) +{ + /* + * XXX: Workaround for an observed issue where if SysTick interrupt is not + * disabled when entering/leaving some low-power mode may in very rare + * occasions clobber the CPU and cause a crash. + */ + SysTickIntDisable(); + + /* Drop to some low-power mode */ + PowerCC26XX_standbyPolicy(); + + SysTickIntEnable(); +} +/*---------------------------------------------------------------------------*/ +void clock_init(void) { ClockP_Params clk_params; diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.h b/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.h index 6d0499d5633d55ddd0faec9e3b62f35bce2ac273..3bbb3767b8b2da3b98f4a08704e853ebf159d038 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/dev/clock-arch.h @@ -56,6 +56,11 @@ bool clock_arch_enter_idle(void); */ void clock_arch_exit_idle(void); /*---------------------------------------------------------------------------*/ +/** + * \brief Called by the Power driver when dropping to some low-power state. + */ +void clock_arch_standby_policy(void); +/*---------------------------------------------------------------------------*/ #endif /* CLOCK_ARCH_H_ */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/dev/trng-arch.c b/arch/cpu/simplelink-cc13xx-cc26xx/dev/trng-arch.c index d04410bff41072cc882dc04ad635beecd7c91faa..d93e543bd973c57cc2a4690f4a309aaa74cc11ed 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/dev/trng-arch.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/dev/trng-arch.c @@ -41,19 +41,11 @@ #include "trng-arch.h" /*---------------------------------------------------------------------------*/ +#include <Board.h> + #include <ti/drivers/TRNG.h> #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h> /*---------------------------------------------------------------------------*/ -/* - * Very dirty workaround because the pre-compiled TI drivers library for - * CC13x0/CC26x0 is missing the CryptoKey object file. This can be removed - * when the pre-compiled library includes the missing object file. - */ -#include <ti/devices/DeviceFamily.h> -#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0) -#include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintextCC26XX.c> -#endif -/*---------------------------------------------------------------------------*/ #include <stdint.h> #include <stdbool.h> /*---------------------------------------------------------------------------*/ @@ -71,7 +63,7 @@ trng_rand(uint8_t *entropy_buf, size_t entropy_len, uint32_t timeout_us) trng_params.timeout = timeout_us; } - trng_handle = TRNG_open(0, &trng_params); + trng_handle = TRNG_open(Board_TRNG0, &trng_params); if(!trng_handle) { return false; } diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx b/arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx index b83faf3be2cb7468dc836a6fbd9d804638263252..0d78d3280357416a5c0388148cda13717c9ffaa5 160000 --- a/arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx +++ b/arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx @@ -1 +1 @@ -Subproject commit b83faf3be2cb7468dc836a6fbd9d804638263252 +Subproject commit 0d78d3280357416a5c0388148cda13717c9ffaa5 diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.c index f9902f826f7bd3ac176d50075c59507b76a7758d..d1cb677219cfe8dd96062967ae57623754a6f666 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2018-2019, Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,42 +62,57 @@ RF_Mode rf_ble_mode = .rfePatchFxn = &rf_patch_rfe_ble, }; /*---------------------------------------------------------------------------*/ -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x5F3C /* 5 dBm */ -/*---------------------------------------------------------------------------*/ /* Overrides for CMD_RADIO_SETUP */ uint32_t rf_ble_overrides[] CC_ALIGN(4) = { - /* override_use_patch_ble_1mbps.xml */ - MCE_RFE_OVERRIDE(0,0,0,1,0,0), /* PHY: Use MCE ROM, RFE RAM patch */ - /* override_synth_ble_1mbps.xml */ - HW_REG_OVERRIDE(0x4038,0x0034), /* Synth: Set recommended RTRIM to 4 */ - (uint32_t)0x000784A3, /* Synth: Set Fref to 3.43 MHz */ - HW_REG_OVERRIDE(0x4020,0x7F00), /* Synth: Configure fine calibration setting */ - HW_REG_OVERRIDE(0x4064,0x0040), /* Synth: Configure fine calibration setting */ - (uint32_t)0xB1070503, /* Synth: Configure fine calibration setting */ - (uint32_t)0x05330523, /* Synth: Configure fine calibration setting */ - (uint32_t)0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz */ - (uint32_t)0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz */ - (uint32_t)0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz */ - HW32_ARRAY_OVERRIDE(0x405C,1), /* Synth: Configure PLL bias */ - (uint32_t)0x18000000, /* Synth: Configure PLL bias */ - /* Synth: Configure VCO LDO */ - ADI_REG_OVERRIDE(1,4,0x9F), /* (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference) */ - ADI_HALFREG_OVERRIDE(1,7,0x4,0x4), /* Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1) */ - /* override_phy_ble_1mbps.xml */ - (uint32_t)0x013800C3, /* Tx: Configure symbol shape for BLE frequency deviation requirements */ - HW_REG_OVERRIDE(0x6088, 0x0045), /* Rx: Configure AGC reference level */ - HW_REG_OVERRIDE(0x6084, 0x05FD), /* Rx: Configure AGC gain level */ - (uint32_t)0x00038883, /* Rx: Configure LNA bias current trim offset */ - /* override_frontend_xd.xml */ - (uint32_t)0x00F388A3, /* Rx: Set RSSI offset to adjust reported RSSI by +13 dB */ - /* TX power override */ - ADI_REG_OVERRIDE(0,12,0xF8), /* Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) */ - (uint32_t)0xFFFFFFFF, + // override_use_patch_ble_1mbps.xml + // PHY: Use MCE ROM, RFE RAM patch + MCE_RFE_OVERRIDE(0,0,0,1,0,0), + // override_synth_ble_1mbps.xml + // Synth: Set recommended RTRIM to 4 + HW_REG_OVERRIDE(0x4038,0x0034), + // Synth: Set Fref to 3.43 MHz + (uint32_t)0x000784A3, + // Synth: Configure fine calibration setting + HW_REG_OVERRIDE(0x4020,0x7F00), + // Synth: Configure fine calibration setting + HW_REG_OVERRIDE(0x4064,0x0040), + // Synth: Configure fine calibration setting + (uint32_t)0xB1070503, + // Synth: Configure fine calibration setting + (uint32_t)0x05330523, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xA47E0583, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xEAE00603, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0x00010623, + // Synth: Configure PLL bias + HW32_ARRAY_OVERRIDE(0x405C,1), + // Synth: Configure PLL bias + (uint32_t)0x18000000, + // Synth: Configure VCO LDO (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference) + ADI_REG_OVERRIDE(1,4,0x9F), + // Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1) + ADI_HALFREG_OVERRIDE(1,7,0x4,0x4), + // override_phy_ble_1mbps.xml + // Tx: Configure symbol shape for BLE frequency deviation requirements + (uint32_t)0x013800C3, + // Rx: Configure AGC reference level + HW_REG_OVERRIDE(0x6088, 0x0045), + // Rx: Configure AGC gain level + HW_REG_OVERRIDE(0x6084, 0x05FD), + // Rx: Configure LNA bias current trim offset + (uint32_t)0x00038883, + // override_frontend_xd.xml + // Rx: Set RSSI offset to adjust reported RSSI by +13 dB + (uint32_t)0x00F388A3, +#if RF_TXPOWER_BOOST_MODE + // TX power override + // Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) + ADI_REG_OVERRIDE(0,12,0xF8), +#endif + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */ @@ -119,7 +134,7 @@ rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, + .txPower = 0x5F3C, /* set by driver */ .pRegOverride = rf_ble_overrides, }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.h index 4d94edca8605eb46a9fd8b47482a46e1ad10aab5..f18a8a6ecb221209d261d6fe5d86fc361acd770a 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-settings.h @@ -45,8 +45,5 @@ extern RF_Mode rf_ble_mode; extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup; extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc; /*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ble_overrides[]; -/*---------------------------------------------------------------------------*/ #endif /* BLE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-tx-power.c index a0ae346c5e873eb89c89d0534d9da9e8384a401b..7c0d1152b1c58a9458104a1aed375f2461788d39 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ble-tx-power.c @@ -50,28 +50,28 @@ */ tx_power_table_t rf_ble_tx_power_table_cc1350[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 1, 6) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 1, 6) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 1, 10) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 1, 12) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 1, 14) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 3, 1, 18) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(47, 3, 1, 22) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 0, 1, 45) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 0, 1, 49) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 55) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(44, 0, 1, 63) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(52, 0, 1, 59) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(60, 0, 1, 47) }, + {-21, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 1, 6) }, + {-18, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 1, 6) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 1, 10) }, + {-12, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 1, 12) }, + {-9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 1, 14) }, + {-6, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 3, 1, 18) }, + {-3, RF_TxPowerTable_DEFAULT_PA_ENTRY(47, 3, 1, 22) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 0, 1, 45) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 0, 1, 49) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 55) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(44, 0, 1, 63) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(52, 0, 1, 59) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(60, 0, 1, 47) }, #if RF_TXPOWER_BOOST_MODE - /* This setting requires CCFG_FORCE_VDDR_HH = 1. */ - { 6, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 49) }, - /* This setting requires CCFG_FORCE_VDDR_HH = 1. */ - { 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(46, 0, 1, 59) }, - /* This setting requires CCFG_FORCE_VDDR_HH = 1. */ - { 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(55, 0, 1, 51) }, - /* This setting requires CCFG_FORCE_VDDR_HH = 1. */ - { 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 30) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 49) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(46, 0, 1, 59) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(55, 0, 1, 51) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 30) }, #endif RF_TxPowerTable_TERMINATION_ENTRY }; diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.c index 1537f693ce30e4931aca0b8ad2ce4ffb0fa7c4aa..2524356c393d32523147a5a5c7568be25f05de9b 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.c @@ -63,12 +63,6 @@ RF_Mode rf_ieee_mode = .rfePatchFxn = 0, }; /*---------------------------------------------------------------------------*/ -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x9330 /* 5 dBm */ -/*---------------------------------------------------------------------------*/ /* Overrides for CMD_RADIO_SETUP */ uint32_t rf_ieee_overrides[] CC_ALIGN(4) = { @@ -93,6 +87,11 @@ uint32_t rf_ieee_overrides[] CC_ALIGN(4) = (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB */ (uint32_t)0x000F8883, /* Rx: Configure LNA bias current trim offset */ HW_REG_OVERRIDE(0x50DC,0x002B), /* Rx: Adjust AGC DC filter */ +#if RF_TXPOWER_BOOST_MODE + // TX power override + // Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) + ADI_REG_OVERRIDE(0,12,0xF8), +#endif (uint32_t)0xFFFFFFFF, }; /*---------------------------------------------------------------------------*/ @@ -114,7 +113,7 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, /* 5 dBm default */ + .txPower = 0x9330, /* set by driver */ .pRegOverride = rf_ieee_overrides, }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.h index bc60d70c33f64dd249b7ab27d2384ecfa6eefd69..bf9e907820bee5bbc2bf9bdfb6f16585abb85b97 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-settings.h @@ -55,8 +55,5 @@ extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx; extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx; extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack; /*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ieee_overrides[]; -/*---------------------------------------------------------------------------*/ #endif /* IEEE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-tx-power.c index 2d37ef641f878eec3eb9adf0c0a6c0d6c929db4d..0f733b6aabe9cc5dd750b51ea9980df4681d4d81 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/ieee-tx-power.c @@ -50,19 +50,29 @@ */ tx_power_table_t rf_ieee_tx_power_table_cc1350[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 6) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 6) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) }, + {-21, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 1, 6) }, + {-18, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 1, 6) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 1, 10) }, + {-12, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 1, 12) }, + {-9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 1, 14) }, + {-6, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 3, 1, 18) }, + {-3, RF_TxPowerTable_DEFAULT_PA_ENTRY(47, 3, 1, 22) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 0, 1, 45) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 0, 1, 49) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 55) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(44, 0, 1, 63) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(52, 0, 1, 59) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(60, 0, 1, 47) }, +#if RF_TXPOWER_BOOST_MODE + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(38, 0, 1, 49) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(46, 0, 1, 59) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(55, 0, 1, 51) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 30) }, +#endif RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.c index 3d57fc3a3ba43afc9cf411e8ad40720ff4f4da06..b768c3970e944f1b17a6bdc668d3282065d4c183 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.c @@ -66,101 +66,96 @@ #include "prop-settings.h" /*---------------------------------------------------------------------------*/ /* TI-RTOS RF Mode Object */ -RF_Mode rf_prop_mode = -{ - .rfMode = RF_MODE_MULTIPLE, - .cpePatchFxn = &rf_patch_cpe_genfsk, - .mcePatchFxn = 0, - .rfePatchFxn = &rf_patch_rfe_genfsk, -}; -/*---------------------------------------------------------------------------*/ -#if defined(DEVICE_CC1310) -/* - * CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value - * in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE - * is configured or not. - */ -#if RF_CONF_TXPOWER_BOOST_MODE -#define DEFAULT_TX_POWER 0xA73F /* 14 dBm */ -#else -#define DEFAULT_TX_POWER 0xA63F /* 12.5 dBm (rounded up to 13 dBm) */ -#endif -#endif /* defined(DEVICE_CC1310) */ -/*---------------------------------------------------------------------------*/ -#if defined(DEVICE_CC1350) /* - * CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value - * in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE - * is configured or not. + * CC1310 only supports RF_MODE_PROPRIETARY_SUB_1, and hence we need to + * separate the rfMode setting between CC1310 and CC1350*. */ -#if RF_CONF_TXPOWER_BOOST_MODE -#define DEFAULT_TX_POWER 0xAB3F /* 14 dBm */ -#else -#define DEFAULT_TX_POWER 0xBC2B /* 12 dBm */ -#endif - -#endif /* defined(DEVICE_CC1350) */ - /*---------------------------------------------------------------------------*/ -#if defined(DEVICE_CC1350_4) -/* - * CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value - * in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE - * is configured or not. - */ -#if RF_CONF_TXPOWER_BOOST_MODE -#define DEFAULT_TX_POWER 0x913F /* 15 dBm */ +#if defined(DEVICE_CC1310) +#define RF_PROP_MODE RF_MODE_PROPRIETARY_SUB_1 #else -#define DEFAULT_TX_POWER 0xB83F /* 13.7 dBm (rounded up to 14 dBm) */ +#define RF_PROP_MODE RF_MODE_MULTIPLE #endif -#endif /* defined(DEVICE_CC1350_4) */ +RF_Mode rf_prop_mode = +{ + .rfMode = RF_PROP_MODE, + .cpePatchFxn = &rf_patch_cpe_genfsk, + .mcePatchFxn = 0, + .rfePatchFxn = &rf_patch_rfe_genfsk, +}; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ uint32_t rf_prop_overrides[] CC_ALIGN(4) = { - /* override_use_patch_prop_genfsk.xml */ - MCE_RFE_OVERRIDE(0,4,0,1,0,0), /* PHY: Use MCE ROM bank 4, RFE RAM patch */ - /* override_synth_prop_863_930_div5.xml */ - HW_REG_OVERRIDE(0x4038,0x0037), /* Synth: Set recommended RTRIM to 7 */ - (uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */ - HW_REG_OVERRIDE(0x4020,0x7F00), /* Synth: Configure fine calibration setting */ - HW_REG_OVERRIDE(0x4064,0x0040), /* Synth: Configure fine calibration setting */ - (uint32_t)0xB1070503, /* Synth: Configure fine calibration setting */ - (uint32_t)0x05330523, /* Synth: Configure fine calibration setting */ - (uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */ - (uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */ - /* Synth: Configure VCO LDO */ - ADI_REG_OVERRIDE(1,4,0x9F), /* (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference) */ - ADI_HALFREG_OVERRIDE(1,7,0x4,0x4), /* Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1) */ - (uint32_t)0x02010403, /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */ - (uint32_t)0x00108463, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x04B00243, /* Synth: Increase synth programming timeout (0x04B0 RAT ticks = 300 us) */ - /* override_phy_rx_aaf_bw_0xd.xml */ - /* Rx: Set anti-aliasing filter bandwidth to 0xD */ - ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */ - /* override_phy_gfsk_rx.xml */ - (uint32_t)0x00038883, /* Rx: Set LNA bias current trim offset to 3 */ - HW_REG_OVERRIDE(0x6084,0x35F1), /* Rx: Freeze RSSI on sync found event */ - /* override_phy_gfsk_pa_ramp_agc_reflevel_0x1a.xml */ - /* Tx: Configure PA ramping setting (0x41). */ - HW_REG_OVERRIDE(0x6088,0x411A), /* Rx: Set AGC reference level to 0x1A. */ - HW_REG_OVERRIDE(0x608C,0x8213), /* Tx: Configure PA ramping setting */ - /* override_crc_ieee_802_15_4.xml */ - /* IEEE 802.15.4g: Fix incorrect initialization value for */ - (uint32_t)0x00000943, /* CRC-16 calculation (see TRM section 23.7.5.2.1) */ - /* IEEE 802.15.4g: Fix incorrect initialization value for */ - (uint32_t)0x00000963, /* CRC-16 calculation (see TRM section 23.7.5.2.1) */ + // override_use_patch_prop_genfsk.xml + // PHY: Use MCE ROM bank 4, RFE RAM patch + MCE_RFE_OVERRIDE(0,4,0,1,0,0), + // override_synth_prop_863_930_div5.xml + // Synth: Set recommended RTRIM to 7 + HW_REG_OVERRIDE(0x4038,0x0037), + // Synth: Set Fref to 4 MHz + (uint32_t)0x000684A3, + // Synth: Configure fine calibration setting + HW_REG_OVERRIDE(0x4020,0x7F00), + // Synth: Configure fine calibration setting + HW_REG_OVERRIDE(0x4064,0x0040), + // Synth: Configure fine calibration setting + (uint32_t)0xB1070503, + // Synth: Configure fine calibration setting + (uint32_t)0x05330523, + // Synth: Set loop bandwidth after lock to 20 kHz + (uint32_t)0x0A480583, + // Synth: Set loop bandwidth after lock to 20 kHz + (uint32_t)0x7AB80603, + // Synth: Configure VCO LDO (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference) + ADI_REG_OVERRIDE(1,4,0x9F), + // Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1) + ADI_HALFREG_OVERRIDE(1,7,0x4,0x4), + // Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering + (uint32_t)0x02010403, + // Synth: Configure extra PLL filtering + (uint32_t)0x00108463, + // Synth: Increase synth programming timeout (0x04B0 RAT ticks = 300 us) + (uint32_t)0x04B00243, +#if defined(DEVICE_CC1350_4) + // override_synth_disable_bias_div10.xml + // Synth: Set divider bias to disabled + HW32_ARRAY_OVERRIDE(0x405C,1), + // Synth: Set divider bias to disabled (specific for loDivider=10) + (uint32_t)0x18000280, +#endif + // override_phy_rx_aaf_bw_0xd.xml + // Rx: Set anti-aliasing filter bandwidth to 0xD (in ADI0, set IFAMPCTL3[7:4]=0xD) + ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), + // override_phy_gfsk_rx.xml + // Rx: Set LNA bias current trim offset to 3 + (uint32_t)0x00038883, + // Rx: Freeze RSSI on sync found event + HW_REG_OVERRIDE(0x6084,0x35F1), + // override_phy_gfsk_pa_ramp_agc_reflevel_0x1a.xml + // Tx: Configure PA ramping setting (0x41). Rx: Set AGC reference level to 0x1A. + HW_REG_OVERRIDE(0x6088,0x411A), + // Tx: Configure PA ramping setting + HW_REG_OVERRIDE(0x608C,0x8213), #if defined(DEVICE_CC1350_4) - /* override_phy_rx_rssi_offset_neg2db.xml */ - (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB */ + // override_phy_rx_rssi_offset_neg2db.xml + // Rx: Set RSSI offset to adjust reported RSSI by +5 dB (default: 0), trimmed for external bias and differential configuration + (uint32_t)0x000288A3, #else - /* override_phy_rx_rssi_offset_5db.xml */ - (uint32_t)0x00FB88A3, /* Rx: Set RSSI offset to adjust reported RSSI by +5 dB */ + // override_phy_rx_rssi_offset_5db.xml + // Rx: Set RSSI offset to adjust reported RSSI by +5 dB (default: 0), trimmed for external bias and differential configuration + (uint32_t)0x00FB88A3, #endif - /* TX power override */ + // override_crc_ieee_802_15_4.xml + // IEEE 802.15.4g: Fix incorrect initialization value for CRC-16 calculation (see TRM section 23.7.5.2.1) + (uint32_t)0x00000943, + // IEEE 802.15.4g: Fix incorrect initialization value for CRC-16 calculation (see TRM section 23.7.5.2.1) + (uint32_t)0x00000963, #if RF_CONF_TXPOWER_BOOST_MODE - ADI_REG_OVERRIDE(0,12,0xF8), /* Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) */ + // TX power override + // Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8) + ADI_REG_OVERRIDE(0,12,0xF8), #endif (uint32_t)0xFFFFFFFF, }; @@ -195,7 +190,7 @@ rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, + .txPower = 0xA63F, /* set by driver */ .pRegOverride = rf_prop_overrides, .centerFreq = 0x0364, /* set by driver */ .intFreq = 0x8000, /* set by driver */ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.h index f4f32ad57b85c4fe5af586c71066f78f19854235..f97123027fb820f90ccedb7790b3c2e1eb74e6ba 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-settings.h @@ -44,18 +44,11 @@ /* TI-RTOS RF Mode Object */ extern RF_Mode rf_prop_mode; /*---------------------------------------------------------------------------*/ -/* TX Power Table */ -extern RF_TxPowerTable_Entry rf_prop_tx_power_table[]; -extern const size_t rf_prop_tx_power_table_size; -/*---------------------------------------------------------------------------*/ /* RF Core API commands */ extern rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup; extern rfc_CMD_FS_t rf_cmd_prop_fs; extern rfc_CMD_PROP_TX_ADV_t rf_cmd_prop_tx_adv; extern rfc_CMD_PROP_RX_ADV_t rf_cmd_prop_rx_adv; /*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_prop_overrides[]; -/*---------------------------------------------------------------------------*/ #endif /* PROP_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-tx-power.c index f2293767f71c3749a63ad083f5a69ab07066c1d0..00f208059287b7ca238e96109926003f82f7609e 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x0/prop-tx-power.c @@ -50,25 +50,25 @@ */ tx_power_table_t rf_prop_tx_power_table_cc1310[] = { - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 4) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 1, 0, 0) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY( 3, 3, 0, 8) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 1, 0, 8) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 10) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY( 5, 3, 0, 12) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 3, 0, 12) }, - { 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 14) }, - { 7, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 16) }, - { 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 18) }, - { 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 3, 0, 22) }, - { 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 3, 0, 28) }, - { 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 0, 40) }, - { 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 92) }, - /* The original PA value (12.5 dBm) have been rounded to an integer value. */ - { 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 83) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 4) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 1, 0, 0) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(3, 3, 0, 8) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 1, 0, 8) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 10) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(5, 3, 0, 12) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 12) }, + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(7, 3, 0, 14) }, + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 16) }, + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 18) }, + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 3, 0, 22) }, + {10, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 3, 0, 28) }, + {11, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 0, 40) }, + {12, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 92) }, + // The original PA value (12.5 dBm) has been rounded to an integer value. + {13, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 83) }, #if RF_CONF_TXPOWER_BOOST_MODE - /* This setting requires RF_CONF_TXPOWER_BOOST_MODE = 1. */ - { 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 83) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 83) }, #endif RF_TxPowerTable_TERMINATION_ENTRY }; @@ -82,23 +82,23 @@ tx_power_table_t rf_prop_tx_power_table_cc1310[] = */ tx_power_table_t rf_prop_tx_power_table_cc1350[] = { - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 2) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 3, 3, 0, 9) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 11) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 5, 3, 0, 12) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 3, 0, 14) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 1, 0, 12) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 0, 16) }, - { 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 18) }, - { 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 21) }, - { 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 25) }, - { 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 3, 0, 32) }, - { 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 3, 0, 44) }, - { 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(37, 3, 0, 72) }, - { 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(43, 0, 0, 94) }, -#if RF_CONF_TXPOWER_BOOST_MODE - /* This setting requires RF_CONF_TXPOWER_BOOST_MODE = 1. */ - { 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 85) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(3, 3, 0, 9) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 11) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(5, 3, 0, 12) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 14) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 1, 0, 12) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 16) }, + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 18) }, + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 21) }, + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 25) }, + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 3, 0, 32) }, + {10, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 3, 0, 44) }, + {11, RF_TxPowerTable_DEFAULT_PA_ENTRY(37, 3, 0, 72) }, + {12, RF_TxPowerTable_DEFAULT_PA_ENTRY(43, 0, 0, 94) }, +#if RF_TXPOWER_BOOST_MODE + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 85) }, #endif RF_TxPowerTable_TERMINATION_ENTRY }; @@ -112,25 +112,25 @@ tx_power_table_t rf_prop_tx_power_table_cc1350[] = */ tx_power_table_t rf_prop_tx_power_table_cc1350_4[] = { - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 2) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 3, 0, 7) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 3, 0, 9) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 3, 0, 11) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 3, 0, 12) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 3, 3, 0, 16) }, - { 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 18) }, - { 7, RF_TxPowerTable_DEFAULT_PA_ENTRY( 5, 3, 0, 21) }, - { 8, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 3, 0, 23) }, - { 9, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 0, 28) }, - { 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 35) }, - { 11, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 1, 0, 39) }, - { 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 60) }, - { 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 0, 0, 108) }, - /* The original PA value (13.7 dBm) have been rounded to an integer value. */ - { 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 92) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 7) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 9) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 11) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 12) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(3, 3, 0, 16) }, + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 18) }, + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(5, 3, 0, 21) }, + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 23) }, + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 28) }, + {10, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 35) }, + {11, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 1, 0, 39) }, + {12, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 60) }, + {13, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 0, 0, 108) }, + // The original PA value (13.7 dBm) has been rounded to an integer value. + {14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 92) }, #if RF_CONF_TXPOWER_BOOST_MODE - /* This setting requires RF_CONF_TXPOWER_BOOST_MODE = 1. */ - { 15, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 72) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {15, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 72) }, #endif RF_TxPowerTable_TERMINATION_ENTRY }; diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.c index b43ce21a694b1f354e7835097ac9eedc62360716..babaf3e1a1af0b42e373c8901d26599aa18e44ef 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.c @@ -48,8 +48,6 @@ #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) #include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h) #include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h) #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ @@ -60,71 +58,60 @@ RF_Mode rf_ble_mode = { .rfMode = RF_MODE_AUTO, .cpePatchFxn = &rf_patch_cpe_multi_protocol, - .mcePatchFxn = &rf_patch_mce_bt5, - .rfePatchFxn = &rf_patch_rfe_bt5, + .mcePatchFxn = 0, + .rfePatchFxn = 0, }; /*---------------------------------------------------------------------------*/ -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x941E /* 5 dBm */ -/*---------------------------------------------------------------------------*/ +#if defined(DEVICE_CC1352R) + /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_common[] CC_ALIGN(4) = { - /* override_ble5_setup_override_common.xml */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure synth hardware */ - (uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - (uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */ - /* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0x00038883, /* Rx: Set LNA bias current offset to adjust +3 (default: 0) */ - (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */ - (uint32_t)0x01080263, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0x08E90AA3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0x00068BA3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - /* Bluetooth 5: Set correct total clock accuracy for received AuxPtr */ - (uint32_t)0x0E490C83, /* assuming local sleep clock of 50 ppm */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_common.xml + // DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0x3 (DITHER_EN=0 and IPEAK=3). + (uint32_t)0x00F388D3, + // Bluetooth 5: Set pilot tone length to 20 us Common + HW_REG_OVERRIDE(0x6024,0x2E20), + // Bluetooth 5: Compensate for reduced pilot tone length + (uint32_t)0x01280263, + // Bluetooth 5: Default to no CTE. + HW_REG_OVERRIDE(0x5328,0x0000), + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_1mbps[] CC_ALIGN(4) = { - /* override_ble5_setup_override_1mbps.xml */ - MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch (mode 0), RFE RAM patch (mode 0) */ - HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */ - (uint32_t)0x013302A3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_1mbps.xml + // Bluetooth 5: Set pilot tone length to 20 us + HW_REG_OVERRIDE(0x5320,0x03C0), + // Bluetooth 5: Compensate syncTimeadjust + (uint32_t)0x015302A3, + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_2mbps[] CC_ALIGN(4) = { - /* override_ble5_setup_override_2mbps.xml */ - MCE_RFE_OVERRIDE(1,0,2,1,0,2), /* PHY: Use MCE RAM patch (mode 2), RFE RAM patch (mode 2) */ - HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */ - (uint32_t)0x00D102A3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_2mbps.xml + // Bluetooth 5: Set pilot tone length to 20 us + HW_REG_OVERRIDE(0x5320,0x03C0), + // Bluetooth 5: Compensate syncTimeAdjust + (uint32_t)0x00F102A3, + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_coded[] CC_ALIGN(4) = { - /* override_ble5_setup_override_coded.xml */ - MCE_RFE_OVERRIDE(1,0,1,1,0,1), /* PHY: Use MCE RAM patch (mode 1), RFE RAM patch (mode 1) */ - HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */ - (uint32_t)0x078902A3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_coded.xml + // Bluetooth 5: Set pilot tone length to 20 us + HW_REG_OVERRIDE(0x5320,0x03C0), + // Bluetooth 5: Compensate syncTimeadjust + (uint32_t)0x07A902A3, + // Rx: Set AGC reference level to 0x1B (default: 0x2E) + HW_REG_OVERRIDE(0x609C,0x001B), + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* CMD_BLE5_RADIO_SETUP: Bluetooth 5 Radio Setup Command for all PHYs */ @@ -147,12 +134,127 @@ rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, + .txPower = 0x7217, /* set by driver */ + .pRegOverrideCommon = rf_ble_overrides_common, + .pRegOverride1Mbps = rf_ble_overrides_1mbps, + .pRegOverride2Mbps = rf_ble_overrides_2mbps, + .pRegOverrideCoded = rf_ble_overrides_coded, +}; + +#endif /* defined(DEVICE_CC1352R) */ +/*---------------------------------------------------------------------------*/ +#if defined(DEVICE_CC1352P) + +/* Overrides for CMD_BLE5_RADIO_SETUP_PA */ +uint32_t rf_ble_overrides_common[] CC_ALIGN(4) = +{ + // override_ble5_setup_override_common_hpa.xml + // Bluetooth 5: Reconfigure to 35 us pilot tone length for high output power PA + HW_REG_OVERRIDE(0x6024,0x5B20), + // Bluetooth 5: Compensate for 35 us pilot tone length + (uint32_t)0x01640263, + // Bluetooth 5: Set IPEAK = 3 and DCDC dither off for TX + (uint32_t)0x00F388D3, + // Bluetooth 5: Default to no CTE. + HW_REG_OVERRIDE(0x5328,0x0000), + (uint32_t)0xFFFFFFFF +}; +/*---------------------------------------------------------------------------*/ +/* Overrides for CMD_BLE5_RADIO_SETUP_PA */ +uint32_t rf_ble_overrides_1mbps[] CC_ALIGN(4) = +{ + // override_ble5_setup_override_1mbps_hpa.xml + // Bluetooth 5: Reconfigure pilot tone length for high output power PA + HW_REG_OVERRIDE(0x5320,0x0690), + // Bluetooth 5: Compensate for modified pilot tone length + (uint32_t)0x018F02A3, + (uint32_t)0xFFFFFFFF +}; +/*---------------------------------------------------------------------------*/ +/* Overrides for CMD_BLE5_RADIO_SETUP_PA */ +uint32_t rf_ble_overrides_2mbps[] CC_ALIGN(4) = +{ + // override_ble5_setup_override_2mbps_hpa.xml + // Bluetooth 5: Reconfigure pilot tone length for high output power PA + HW_REG_OVERRIDE(0x5320,0x0690), + // Bluetooth 5: Compensate for modified pilot tone length + (uint32_t)0x012D02A3, + (uint32_t)0xFFFFFFFF +}; +/*---------------------------------------------------------------------------*/ +/* Overrides for CMD_BLE5_RADIO_SETUP_PA */ +uint32_t rf_ble_overrides_coded[] CC_ALIGN(4) = +{ + // override_ble5_setup_override_coded_hpa.xml + // Bluetooth 5: Reconfigure pilot tone length for high output power PA + HW_REG_OVERRIDE(0x5320,0x0690), + // Bluetooth 5: Compensate for modified pilot tone length + (uint32_t)0x07E502A3, + // Bluetooth 5: Set AGC mangnitude target to 0x1B. + HW_REG_OVERRIDE(0x609C,0x001B), + (uint32_t)0xFFFFFFFF +}; +/*---------------------------------------------------------------------------*/ +// Overrides for CMD_BLE5_RADIO_SETUP_PA +uint32_t rf_ble_overrides_tx_std[] = +{ + // The TX Power element should always be the first in the list + TX_STD_POWER_OVERRIDE(0x7217), + // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings + (uint32_t)0x05320703, + // override_txstd_settings.xml + // Bluetooth 5: Set RTIM offset to default for standard PA + (uint32_t)0x00008783, + // Bluetooth 5: Set synth mux to default value for standard PA + (uint32_t)0x050206C3, + (uint32_t)0xFFFFFFFF +}; +/*---------------------------------------------------------------------------*/ +// Overrides for CMD_BLE5_RADIO_SETUP_PA +uint32_t rf_ble_overrides_tx_20[] = +{ + // The TX Power element should always be the first in the list + TX20_POWER_OVERRIDE(0x003F75F5), + // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings + (uint32_t)0x01C20703, + // override_tx20_settings.xml + // Bluetooth 5: Set RTIM offset to 3 for high power PA + (uint32_t)0x00038783, + // Bluetooth 5: Set synth mux for high power PA + (uint32_t)0x010206C3, + (uint32_t)0xFFFFFFFF +}; +/*---------------------------------------------------------------------------*/ +/* CMD_BLE5_RADIO_SETUP_PA: Bluetooth 5 Radio Setup Command for all PHYs */ +rfc_CMD_BLE5_RADIO_SETUP_PA_t rf_ble_cmd_radio_setup = +{ + .commandNo = 0x1820, + .status = IDLE, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = TRIG_NOW, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = COND_NEVER, + .condition.nSkip = 0x0, + .defaultPhy.mainMode = 0x0, + .defaultPhy.coding = 0x0, + .loDivider = 0x00, + .config.frontEndMode = 0x0, /* set by driver */ + .config.biasMode = 0x0, /* set by driver */ + .config.analogCfgMode = 0x0, + .config.bNoFsPowerUp = 0x0, + .txPower = 0x7217, /* set by driver */ .pRegOverrideCommon = rf_ble_overrides_common, .pRegOverride1Mbps = rf_ble_overrides_1mbps, .pRegOverride2Mbps = rf_ble_overrides_2mbps, .pRegOverrideCoded = rf_ble_overrides_coded, + .pRegOverrideTxStd = rf_ble_overrides_tx_std, + .pRegOverrideTx20 = rf_ble_overrides_tx_20, }; + +#endif /* defined(DEVICE_CC1352P) */ /*---------------------------------------------------------------------------*/ /* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */ rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc = diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.h index c5295c868d779d1cd2ce5fa932a3c3815e72aaf7..2d0df72f9fa203c6421c869b84928be378fe40bb 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-settings.h @@ -39,17 +39,15 @@ #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ /* TI-RTOS RF Mode Object */ -extern RF_Mode rf_ble_mode; +extern RF_Mode rf_ble_mode; /*---------------------------------------------------------------------------*/ /* RF Core API commands */ -extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup; -extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc; -/*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ble_overrides_common[]; -extern uint32_t rf_ble_overrides_1mbps[]; -extern uint32_t rf_ble_overrides_2mbps[]; -extern uint32_t rf_ble_overrides_coded[]; +#if defined(DEVICE_CC1312R) || defined(DEVICE_CC1352R) +extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup; +#else +extern rfc_CMD_BLE5_RADIO_SETUP_PA_t rf_ble_cmd_radio_setup; +#endif +extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc; /*---------------------------------------------------------------------------*/ #endif /* BLE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-tx-power.c index 7a87ca5671d73a11ac870ba704b3b54e7aa5b0a8..478a7f8c75793956ca6621233f46a18742a61a6b 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ble-tx-power.c @@ -50,21 +50,16 @@ */ tx_power_table_t rf_ble_tx_power_table_cc1352r[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ @@ -75,50 +70,25 @@ tx_power_table_t rf_ble_tx_power_table_cc1352r[] = * See the Technical Reference Manual for further details about the "txPower" Command field. * The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. */ -tx_power_table_t rf_ble_tx_power_table_cc1352p_dpa[] = +tx_power_table_t rf_ble_tx_power_table_cc1352p[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) }, - RF_TxPowerTable_TERMINATION_ENTRY -}; -/*---------------------------------------------------------------------------*/ -/* - * TX Power table for CC1352P with high PA - * The RF_TxPowerTable_HIGH_PA_ENTRY macro is defined in RF.h and requires the following arguments: - * RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldoTrim) - * See the Technical Reference Manual for further details about the "txPower" Command field. - * The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. - */ -tx_power_table_t rf_ble_tx_power_table_cc1352p_hpa[] = -{ - { 0, RF_TxPowerTable_HIGH_PA_ENTRY(29, 0, 1, 17, 1) }, - { 3, RF_TxPowerTable_HIGH_PA_ENTRY(39, 0, 1, 20, 1) }, - { 6, RF_TxPowerTable_HIGH_PA_ENTRY(46, 0, 1, 26, 7) }, - { 9, RF_TxPowerTable_HIGH_PA_ENTRY(40, 0, 1, 39, 41) }, - { 10, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 65, 5) }, - { 11, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 29, 7) }, - { 12, RF_TxPowerTable_HIGH_PA_ENTRY(19, 2, 1, 16, 25) }, - { 13, RF_TxPowerTable_HIGH_PA_ENTRY(27, 2, 1, 19, 13) }, - { 14, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 19, 27) }, - { 15, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 20, 39) }, - { 16, RF_TxPowerTable_HIGH_PA_ENTRY(34, 2, 1, 26, 23) }, - { 17, RF_TxPowerTable_HIGH_PA_ENTRY(38, 2, 1, 33, 25) }, - { 18, RF_TxPowerTable_HIGH_PA_ENTRY(30, 2, 1, 37, 53) }, - { 19, RF_TxPowerTable_HIGH_PA_ENTRY(36, 2, 1, 57, 59) }, - { 20, RF_TxPowerTable_HIGH_PA_ENTRY(56, 2, 1, 45, 63) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, + {14, RF_TxPowerTable_HIGH_PA_ENTRY(22, 3, 1, 19, 27) }, + {15, RF_TxPowerTable_HIGH_PA_ENTRY(26, 3, 1, 23, 27) }, + {16, RF_TxPowerTable_HIGH_PA_ENTRY(30, 3, 1, 28, 27) }, + {17, RF_TxPowerTable_HIGH_PA_ENTRY(37, 3, 1, 39, 27) }, + {18, RF_TxPowerTable_HIGH_PA_ENTRY(32, 3, 1, 35, 48) }, + {19, RF_TxPowerTable_HIGH_PA_ENTRY(34, 3, 1, 48, 63) }, + {20, RF_TxPowerTable_HIGH_PA_ENTRY(53, 3, 1, 58, 63) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ @@ -132,11 +102,7 @@ tx_power_table_t rf_ble_tx_power_table_empty[] = #define TX_POWER_TABLE rf_ble_tx_power_table_cc1352r #elif defined(DEVICE_CC1352P) -#if RF_TXPOWER_HIGH_PA -#define TX_POWER_TABLE rf_ble_tx_power_table_cc1352p_hpa -#else -#define TX_POWER_TABLE rf_ble_tx_power_table_cc1352p_dpa -#endif +#define TX_POWER_TABLE rf_ble_tx_power_table_cc1352p #else #define TX_POWER_TABLE rf_ble_tx_power_table_empty diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.c index a81a8338586dd989e44ff6e2487984eea24e2779..15becbf9bba038e117215da49ff5c0942c165a9e 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.c @@ -52,7 +52,6 @@ #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) #include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h) #include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h) #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ @@ -63,112 +62,95 @@ RF_Mode rf_ieee_mode = { .rfMode = RF_MODE_AUTO, .cpePatchFxn = &rf_patch_cpe_multi_protocol, - .mcePatchFxn = &rf_patch_mce_ieee_802_15_4, + .mcePatchFxn = 0, .rfePatchFxn = 0, }; /*---------------------------------------------------------------------------*/ #if defined(DEVICE_CC1352R) -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x941E /* 5 dBm */ -/*---------------------------------------------------------------------------*/ + /* Overrides for CMD_RADIO_SETUP */ uint32_t rf_ieee_overrides[] CC_ALIGN(4) = { - /* override_ieee_802_15_4.xml */ - MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure synth hardware */ - (uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - (uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */ - /* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */ - (uint32_t)0xFFFFFFFF, + // override_ieee_802_15_4.xml + // DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0x3 (DITHER_EN=0 and IPEAK=3). + (uint32_t)0x00F388D3, + // Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) + (uint32_t)0x000F8883, + (uint32_t)0xFFFFFFFF +}; +/*---------------------------------------------------------------------------*/ +/* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */ +rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup = +{ + .commandNo = CMD_RADIO_SETUP, + .status = IDLE, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = TRIG_NOW, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = COND_NEVER, + .condition.nSkip = 0x0, + .mode = 0x01, + .loDivider = 0x00, + .config.frontEndMode = 0x0, /* set by driver */ + .config.biasMode = 0x0, /* set by driver */ + .config.analogCfgMode = 0x0, + .config.bNoFsPowerUp = 0x0, + .txPower = 0x7217, /* set by driver */ + .pRegOverride = rf_ieee_overrides, }; #endif /* defined(DEVICE_CC1352R) */ /*---------------------------------------------------------------------------*/ #if defined(DEVICE_CC1352P) -#if RF_CONF_TXPOWER_HIGH_PA -/* - * CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value - * in the .txPower field. For High PA, this must be 0xFFFF. - */ -#define DEFAULT_TX_POWER 0xFFFF /* High PA */ -/*---------------------------------------------------------------------------*/ -/* Overrides for CMD_RADIO_SETUP with high PA */ +/* Overrides for CMD_RADIO_SETUP_PA */ uint32_t rf_ieee_overrides[] CC_ALIGN(4) = { - /* override_ieee_802_15_4.xml */ - MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure synth hardware */ - (uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - (uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */ - /* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */ - /* override_frontend_xd.xml */ - /* TX power override */ - (uint32_t)0xFD6EE02B, /* txHighPA=0x3F5BB8 */ - (uint32_t)0xFFFFFFFF, + // override_ieee_802_15_4.xml + // Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) + (uint32_t)0x000F8883, + // Tx: Set DCDC settings IPEAK=3, dither = off + (uint32_t)0x00F388D3, + (uint32_t)0xFFFFFFFF }; -/*---------------------------------------------------------------------------*/ -#else -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x941E /* 5 dBm */ -/*---------------------------------------------------------------------------*/ -/* Overrides for CMD_RADIO_SETUP with default PA */ -uint32_t rf_ieee_overrides[] CC_ALIGN(4) = + +/* Overrides for CMD_RADIO_SETUP_PA */ +uint32_t rf_ieee_overrides_tx_std[] CC_ALIGN(4) = { - /* override_ieee_802_15_4.xml */ - MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure synth hardware */ - (uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - (uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */ - /* DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */ - (uint32_t)0xFFFFFFFF, + // The TX Power element should always be the first in the list + TX_STD_POWER_OVERRIDE(0x7217), + // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings + (uint32_t)0x05320703, + // override_txstd_settings.xml + // Bluetooth 5: Set RTIM offset to default for standard PA + (uint32_t)0x00008783, + // Bluetooth 5: Set synth mux to default value for standard PA + (uint32_t)0x050206C3, + (uint32_t)0xFFFFFFFF }; -#endif /* RF_CONF_TXPOWER_HIGH_PA */ - -#endif /* defined(DEVICE_CC1352P) */ +/* Overrides for CMD_RADIO_SETUP_PA */ +uint32_t rf_ieee_overrides_tx_20[] CC_ALIGN(4) = +{ + // The TX Power element should always be the first in the list + TX20_POWER_OVERRIDE(0x003F75F5), + // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings + (uint32_t)0x01C20703, + // override_tx20_settings.xml + // Bluetooth 5: Set RTIM offset to 3 for high power PA + (uint32_t)0x00038783, + // Bluetooth 5: Set synth mux for high power PA + (uint32_t)0x010206C3, + (uint32_t)0xFFFFFFFF +}; /*---------------------------------------------------------------------------*/ /* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */ -rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup = +rfc_CMD_RADIO_SETUP_PA_t rf_cmd_ieee_radio_setup = { - .commandNo = CMD_RADIO_SETUP, + .commandNo = 0x0802, .status = IDLE, .pNextOp = 0, .startTime = 0x00000000, @@ -184,9 +166,13 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, /* 5 dBm default */ + .txPower = 0x7217, /* set by driver */ .pRegOverride = rf_ieee_overrides, + .pRegOverrideTxStd = rf_ieee_overrides_tx_std, + .pRegOverrideTx20 = rf_ieee_overrides_tx_20, }; + +#endif /* defined(DEVICE_CC1352P) */ /*---------------------------------------------------------------------------*/ /* CMD_FS: Frequency Synthesizer Programming Command */ rfc_CMD_FS_t rf_cmd_ieee_fs = diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.h index 7019598c8d5842f3c905cac668cc8d27b214c742..5e1a9137c9f372552ac2bbfb367a694eb5738ed8 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-settings.h @@ -42,17 +42,18 @@ #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ /* TI-RTOS RF Mode Object */ -extern RF_Mode rf_ieee_mode; +extern RF_Mode rf_ieee_mode; /*---------------------------------------------------------------------------*/ /* RF Core API commands */ -extern rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup; -extern rfc_CMD_FS_t rf_cmd_ieee_fs; -extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx; -extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx; -extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack; -/*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ieee_overrides[]; +#if defined(DEVICE_CC1312R) || defined(DEVICE_CC1352R) +extern rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup; +#else +extern rfc_CMD_RADIO_SETUP_PA_t rf_cmd_ieee_radio_setup; +#endif +extern rfc_CMD_FS_t rf_cmd_ieee_fs; +extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx; +extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx; +extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack; /*---------------------------------------------------------------------------*/ #endif /* IEEE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-tx-power.c index efd143e9d0bfd9dc202ec4f5676ab2794bc38ffe..67bc13d89d097ea9677ef8197f3b5155be0cc8cf 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/ieee-tx-power.c @@ -41,33 +41,6 @@ /*---------------------------------------------------------------------------*/ #include "rf/tx-power.h" /*---------------------------------------------------------------------------*/ -/* - * TX Power table for CC1312R - * The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments: - * RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient) - * See the Technical Reference Manual for further details about the "txPower" Command field. - * The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. - */ -tx_power_table_t rf_ieee_tx_power_table_cc1312r[] = -{ - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) }, - RF_TxPowerTable_TERMINATION_ENTRY -}; -/*---------------------------------------------------------------------------*/ /* * TX Power table for CC1352R * The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments: @@ -77,75 +50,47 @@ tx_power_table_t rf_ieee_tx_power_table_cc1312r[] = */ tx_power_table_t rf_ieee_tx_power_table_cc1352r[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ /* - * TX Power table for CC1352P with default PA - * The RF_TxPowerTable_DEFAULT_PA_ENTRY macro is defined in RF.h and requires the following arguments: + * TX Power table + * The RF_TxPowerTable_DEFAULT_PA_ENTRY and RF_TxPowerTable_HIGH_PA_ENTRY macro is defined in RF.h. + * The following arguments are required: * RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost coefficient) - * See the Technical Reference Manual for further details about the "txPower" Command field. - * The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. - */ -tx_power_table_t rf_ieee_tx_power_table_cc1352p_dpa[] = -{ - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) }, - RF_TxPowerTable_TERMINATION_ENTRY -}; -/*---------------------------------------------------------------------------*/ -/* - * TX Power table for CC1352P with high PA - * The RF_TxPowerTable_HIGH_PA_ENTRY macro is defined in RF.h and requires the following arguments: * RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldoTrim) * See the Technical Reference Manual for further details about the "txPower" Command field. * The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. */ -tx_power_table_t rf_ieee_tx_power_table_cc1352p_hpa[] = +tx_power_table_t rf_ieee_tx_power_table_cc1352p[] = { - { 0, RF_TxPowerTable_HIGH_PA_ENTRY(29, 0, 1, 17, 1) }, - { 3, RF_TxPowerTable_HIGH_PA_ENTRY(39, 0, 1, 20, 1) }, - { 6, RF_TxPowerTable_HIGH_PA_ENTRY(46, 0, 1, 26, 7) }, - { 9, RF_TxPowerTable_HIGH_PA_ENTRY(40, 0, 1, 39, 41) }, - { 10, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 65, 5) }, - { 11, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 29, 7) }, - { 12, RF_TxPowerTable_HIGH_PA_ENTRY(19, 2, 1, 16, 25) }, - { 13, RF_TxPowerTable_HIGH_PA_ENTRY(27, 2, 1, 19, 13) }, - { 14, RF_TxPowerTable_HIGH_PA_ENTRY(24, 2, 1, 19, 27) }, - { 15, RF_TxPowerTable_HIGH_PA_ENTRY(23, 2, 1, 20, 39) }, - { 16, RF_TxPowerTable_HIGH_PA_ENTRY(34, 2, 1, 26, 23) }, - { 17, RF_TxPowerTable_HIGH_PA_ENTRY(38, 2, 1, 33, 25) }, - { 18, RF_TxPowerTable_HIGH_PA_ENTRY(30, 2, 1, 37, 53) }, - { 19, RF_TxPowerTable_HIGH_PA_ENTRY(36, 2, 1, 57, 59) }, - { 20, RF_TxPowerTable_HIGH_PA_ENTRY(56, 2, 1, 45, 63) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, + {14, RF_TxPowerTable_HIGH_PA_ENTRY(22, 3, 1, 19, 27) }, + {15, RF_TxPowerTable_HIGH_PA_ENTRY(26, 3, 1, 23, 27) }, + {16, RF_TxPowerTable_HIGH_PA_ENTRY(30, 3, 1, 28, 27) }, + {17, RF_TxPowerTable_HIGH_PA_ENTRY(37, 3, 1, 39, 27) }, + {18, RF_TxPowerTable_HIGH_PA_ENTRY(32, 3, 1, 35, 48) }, + {19, RF_TxPowerTable_HIGH_PA_ENTRY(34, 3, 1, 48, 63) }, + {20, RF_TxPowerTable_HIGH_PA_ENTRY(53, 3, 1, 58, 63) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ @@ -158,18 +103,11 @@ tx_power_table_t rf_ieee_ztx_power_table_empty[] = #if (RF_MODE == RF_MODE_2_4_GHZ) /*---------------------------------------------------------------------------*/ /* TX power table, based on which board is used. */ -#if defined(DEVICE_CC1312R) -#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1312r - -#elif defined(DEVICE_CC1352R) +#if defined(DEVICE_CC1352R) #define TX_POWER_TABLE rf_ieee_tx_power_table_cc1352r #elif defined(DEVICE_CC1352P) -#if RF_TXPOWER_HIGH_PA -#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1352p_hpa -#else -#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1352p_dpa -#endif +#define TX_POWER_TABLE rf_ieee_tx_power_table_cc1352p #else #define TX_POWER_TABLE rf_ieee_tx_power_table_empty diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.c index 0f098c5e15fb4b4db7a4523e26b9677dbb2f72ec..f579c9bf4f9e0c7901b7137406faa389e6cdfc89 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.c @@ -28,35 +28,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -/* - * Parameter summary - * Address: 0 - * Address0: 0xAA - * Address1: 0xBB - * Frequency: 915.00000 MHz - * Data Format: Serial mode disable - * Deviation: 25.000 kHz - * pktLen: 30 - * 802.15.4g Mode: 0 - * Select bit order to transmit PSDU octets:: 1 - * Packet Length Config: Variable - * Max Packet Length: 255 - * Packet Length: 20 - * Packet Data: 255 - * RX Filter BW: 98.0 kHz - * Symbol Rate: 50.00000 kBaud - * Sync Word Length: 24 Bits - * For Default PA: - * Enable high output power PA: false - * TX Power: 13.5 dBm (requires define CCFG_FORCE_VDDR_HH = 1 in ccfg.c, - * see CC13xx/CC26xx Technical Reference Manual) - * For High PA: - * Enable high output power PA: true - * TX Power: 20 dBm (requires define CCFG_FORCE_VDDR_HH = 0 in ccfg.c, - * see CC13xx/CC26xx Technical Reference Manual) - * Whitening: Dynamically IEEE 802.15.4g compatible whitener and 16/32-bit CRC - */ -/*---------------------------------------------------------------------------*/ #include "sys/cc.h" /*---------------------------------------------------------------------------*/ #include <ti/devices/DeviceFamily.h> @@ -64,8 +35,6 @@ #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) #include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h) #include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_genfsk.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_genfsk.h) #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ @@ -76,197 +45,132 @@ RF_Mode rf_prop_mode = { .rfMode = RF_MODE_AUTO, .cpePatchFxn = &rf_patch_cpe_multi_protocol, - .mcePatchFxn = &rf_patch_mce_genfsk, - .rfePatchFxn = &rf_patch_rfe_genfsk, + .mcePatchFxn = 0, + .rfePatchFxn = 0, }; /*---------------------------------------------------------------------------*/ #if defined(DEVICE_CC1312R) || defined(DEVICE_CC1352R) -/* - * CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value - * in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE - * is configured or not. - */ -#if RF_CONF_TXPOWER_BOOST_MODE -#define DEFAULT_TX_POWER 0x9F3F /* 14 dBm */ -#else -#define DEFAULT_TX_POWER 0xCC14 /* 12.5 dBm (rounded up to 13 dBm) */ -#endif -/*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP */ uint32_t rf_prop_overrides[] CC_ALIGN(4) = { - /* override_use_patch_prop_genfsk.xml */ - MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch, RFE RAM patch */ - /* override_synth_prop_863_930_div5.xml */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal as synth clock, enable extra PLL filtering */ - (uint32_t)0x00068793, /* Synth: Set minimum RTRIM to 6 */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x180C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - /* Synth: Decrease synth programming time-out by 90 us from default */ - (uint32_t)0x02980243, /* (0x0298 RAT ticks = 166 us) */ - (uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */ - (uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */ - (uint32_t)0x00000623, /* Synth: Set loop bandwidth after lock to 20 kHz */ - /* override_phy_tx_pa_ramp_genfsk_hpa.xml */ - ADI_HALFREG_OVERRIDE(0,16,0x8,0x8), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[3]=1) */ - ADI_HALFREG_OVERRIDE(0,17,0x1,0x1), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4]=1) */ - /* override_phy_rx_frontend_genfsk.xml */ - HW_REG_OVERRIDE(0x609C,0x001A), /* Rx: Set AGC reference level to 0x1A (default: 0x2E) */ - (uint32_t)0x00018883, /* Rx: Set LNA bias current offset to adjust +1 (default: 0) */ - (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */ - /* override_phy_rx_aaf_bw_0xd.xml */ - /* Rx: Set anti-aliasing filter bandwidth to 0xD */ - ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */ -#if RF_CONF_TXPOWER_BOOST_MODE - /* TX power override */ - /* DC/DC regulator: In Tx with 14 dBm PA setting, */ - /* use DCDCCTL5[3:0]=0xF (DITHER_EN=1 and IPEAK=7). */ - (uint32_t)0xFFFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - /* Tx: Set PA trim to max to maximize its output power */ - ADI_REG_OVERRIDE(0,12,0xF8), /* (in ADI0, set PACTL0=0xF8) */ -#else - /* TX power override */ - /* DC/DC regulator: */ - /* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ + // override_prop_common.xml + // DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0x7 (DITHER_EN=0 and IPEAK=7). + (uint32_t)0x00F788D3, + // override_tc106.xml + // Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4:3]=0x3) + ADI_2HALFREG_OVERRIDE(0,16,0x8,0x8,17,0x1,0x1), + // Rx: Set AGC reference level to 0x1A (default: 0x2E) + HW_REG_OVERRIDE(0x609C,0x001A), + // Rx: Set RSSI offset to adjust reported RSSI by -1 dB (default: -2), trimmed for external bias and differential configuration + (uint32_t)0x000188A3, + // Rx: Set anti-aliasing filter bandwidth to 0xD (in ADI0, set IFAMPCTL3[7:4]=0xD) + ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), + // Tx: Set wait time before turning off ramp to 0x1A (default: 0x1F) + HW_REG_OVERRIDE(0x6028,0x001A), +#if RF_TXPOWER_BOOST_MODE + // TX power override + // Tx: Set PA trim to max to maximize its output power (in ADI0, set PACTL0=0xF8) + ADI_REG_OVERRIDE(0,12,0xF8), #endif (uint32_t)0xFFFFFFFF, }; +/*---------------------------------------------------------------------------*/ +/* CMD_PROP_RADIO_DIV_SETUP: Proprietary Mode Radio Setup Command for All Frequency Bands */ +rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup = +{ + .commandNo = CMD_PROP_RADIO_DIV_SETUP, + .status = IDLE, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = TRIG_NOW, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = COND_NEVER, + .condition.nSkip = 0x0, + .modulation.modType = 0x1, + .modulation.deviation = 0x64, + .modulation.deviationStepSz = 0x0, + .symbolRate.preScale = 0xF, + .symbolRate.rateWord = 0x8000, + .symbolRate.decimMode = 0x0, + .rxBw = 0x52, + .preamConf.nPreamBytes = 0x7, + .preamConf.preamMode = 0x0, + .formatConf.nSwBits = 0x18, + .formatConf.bBitReversal = 0x0, + .formatConf.bMsbFirst = 0x1, + .formatConf.fecMode = 0x0, + .formatConf.whitenMode = 0x7, + .config.frontEndMode = 0x0, /* set by driver */ + .config.biasMode = 0x0, /* set by driver */ + .config.analogCfgMode = 0x0, + .config.bNoFsPowerUp = 0x0, + .txPower = 0xCC14, /* set by driver */ + .pRegOverride = rf_prop_overrides, + .centerFreq = 0x0393, /* set by driver */ + .intFreq = 0x8000, /* set by driver */ + .loDivider = 0x05, /* set by driver */ +}; #endif /* defined(DEVICE_CC1312R) || defined(DEVICE_CC1352R) */ /*---------------------------------------------------------------------------*/ #if defined(DEVICE_CC1352P) -#if RF_CONF_TXPOWER_HIGH_PA -/* - * CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value - * in the .txPower field. For High PA, this must be 0xFFFF. - */ -#define DEFAULT_TX_POWER 0xFFFF /* High PA */ - -/*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP with high PA */ uint32_t rf_prop_overrides[] CC_ALIGN(4) = { - /* override_use_patch_prop_genfsk.xml */ - MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch, RFE RAM patch */ - /* override_synth_prop_863_930_div5.xml */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal as synth clock, enable extra PLL filtering */ - (uint32_t)0x00068793, /* Synth: Set minimum RTRIM to 6 */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x180C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - /* Synth: Decrease synth programming time-out by 90 us */ - (uint32_t)0x02980243, /* from default (0x0298 RAT ticks = 166 us) */ - (uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */ - (uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */ - (uint32_t)0x00000623, /* Synth: Set loop bandwidth after lock to 20 kHz */ - /* override_phy_tx_pa_ramp_genfsk_hpa.xml */ - /* Tx: Configure PA ramping, set wait time before turning off */ - HW_REG_OVERRIDE(0x6028,0x002F), /* (0x2F ticks of 16/24 us = 31.3 us). */ - ADI_HALFREG_OVERRIDE(0,16,0x8,0x8), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[3]=1) */ - ADI_HALFREG_OVERRIDE(0,17,0x1,0x1), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4]=1) */ - /* override_phy_rx_frontend_genfsk.xml */ - HW_REG_OVERRIDE(0x609C,0x001A), /* Rx: Set AGC reference level to 0x1A (default: 0x2E) */ - (uint32_t)0x00018883, /* Rx: Set LNA bias current offset to adjust +1 (default: 0) */ - (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */ - /* override_phy_rx_aaf_bw_0xd.xml */ - /* Rx: Set anti-aliasing filter bandwidth to 0xD */ - ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */ - /* TX power override */ - /* DC/DC regulator: */ - /* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0x82A86C2B, /* txHighPA=0x20AA1B */ - (uint32_t)0xFFFFFFFF, + // override_tc706.xml + // Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4:3]=0x3) + ADI_2HALFREG_OVERRIDE(0,16,0x8,0x8,17,0x1,0x1), + // Rx: Set AGC reference level to 0x1A (default: 0x2E) + HW_REG_OVERRIDE(0x609C,0x001A), + // Rx: Set RSSI offset to adjust reported RSSI by -1 dB (default: -2), trimmed for external bias and differential configuration + (uint32_t)0x000188A3, + // Rx: Set anti-aliasing filter bandwidth to 0xD (in ADI0, set IFAMPCTL3[7:4]=0xD) + ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), + // override_prop_common.xml + // DC/DC regulator: In Tx with 14 dBm PA setting, use DCDCCTL5[3:0]=0xF (DITHER_EN=1 and IPEAK=7). In Rx, use default settings. + (uint32_t)0x00F788D3, +#if RF_TXPOWER_BOOST_MODE + // TX power override + // Tx: Set PA trim to max to maximize its output power (in ADI0, set PACTL0=0xF8) + ADI_REG_OVERRIDE(0,12,0xF8), +#endif + (uint32_t)0xFFFFFFFF, }; - -#else /*---------------------------------------------------------------------------*/ -/* - * CMD_PROP_RADIO_DIV_SETUP must be configured with default TX power value - * in the .txPower field. This depends on whether RF_CONF_TXPOWER_BOOST_MODE - * is configured or not. - */ -#if RF_CONF_TXPOWER_BOOST_MODE -#define DEFAULT_TX_POWER 0x013F /* 13.5 dBm (rounded up to 14 dBm) */ -#else -#define DEFAULT_TX_POWER 0x803F /* 12 dBm */ -#endif - +/* Overrides for CMD_PROP_RADIO_DIV_SETUP with defualt PA */ +uint32_t rf_prop_overrides_tx_std[] CC_ALIGN(4) = +{ + // The TX Power element should always be the first in the list + TX_STD_POWER_OVERRIDE(0xB224), + // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings + (uint32_t)0x11310703, + // override_phy_tx_pa_ramp_genfsk_std.xml + // Tx: Configure PA ramping, set wait time before turning off (0x1A ticks of 16/24 us = 17.3 us). + HW_REG_OVERRIDE(0x6028,0x001A), + (uint32_t)0xFFFFFFFF +}; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_PROP_RADIO_DIV_SETUP with defualt PA */ -uint32_t rf_prop_overrides[] CC_ALIGN(4) = +uint32_t rf_prop_overrides_tx_20[] CC_ALIGN(4) = { - /* override_use_patch_prop_genfsk.xml */ - MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch, RFE RAM patch */ - /* override_synth_prop_863_930_div5.xml */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal as synth clock, enable extra PLL filtering */ - (uint32_t)0x00068793, /* Synth: Set minimum RTRIM to 6 */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x000684A3, /* Synth: Set Fref to 4 MHz */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x180C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - /* Synth: Decrease synth programming time-out by 90 us from default */ - (uint32_t)0x02980243, /* (0x0298 RAT ticks = 166 us) */ - (uint32_t)0x0A480583, /* Synth: Set loop bandwidth after lock to 20 kHz */ - (uint32_t)0x7AB80603, /* Synth: Set loop bandwidth after lock to 20 kHz */ - (uint32_t)0x00000623, /* Synth: Set loop bandwidth after lock to 20 kHz */ - /* override_phy_tx_pa_ramp_genfsk_hpa.xml */ - /* Tx: Configure PA ramping, set wait time before turning off */ - HW_REG_OVERRIDE(0x6028,0x002F), /* (0x2F ticks of 16/24 us = 31.3 us). */ - ADI_HALFREG_OVERRIDE(0,16,0x8,0x8), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[3]=1) */ - ADI_HALFREG_OVERRIDE(0,17,0x1,0x1), /* Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4]=1) */ - /* override_phy_rx_frontend_genfsk.xml */ - HW_REG_OVERRIDE(0x609C,0x001A), /* Rx: Set AGC reference level to 0x1A (default: 0x2E) */ - (uint32_t)0x00018883, /* Rx: Set LNA bias current offset to adjust +1 (default: 0) */ - (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */ - /* override_phy_rx_aaf_bw_0xd.xml */ - /* Rx: Set anti-aliasing filter bandwidth to 0xD */ - ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), /* (in ADI0, set IFAMPCTL3[7:4]=0xD) */ -#if RF_CONF_TXPOWER_BOOST_MODE - /* TX power override */ - /* DC/DC regulator: In Tx with 14 dBm PA setting, */ - /* use DCDCCTL5[3:0]=0xF (DITHER_EN=1 and IPEAK=7). */ - (uint32_t)0xFFFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - /* Tx: Set PA trim to max to maximize its output power */ - ADI_REG_OVERRIDE(0,12,0xF8), /* (in ADI0, set PACTL0=0xF8) */ -#else - /* TX power override */ - /* DC/DC regulator: */ - /* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ -#endif - (uint32_t)0xFFFFFFFF, + // The TX Power element should always be the first in the list + TX20_POWER_OVERRIDE(0x001B8ED2), + // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings + (uint32_t)0x11C10703, + // override_phy_tx_pa_ramp_genfsk_hpa.xml + // Tx: Configure PA ramping, set wait time before turning off (0x1F ticks of 16/24 us = 20.3 us). + HW_REG_OVERRIDE(0x6028,0x001F), + (uint32_t)0xFFFFFFFF }; - -#endif /* RF_CONF_TXPOWER_HIGH_PA */ - -#endif /* defined(DEVICE_CC1352P) */ /*---------------------------------------------------------------------------*/ /* CMD_PROP_RADIO_DIV_SETUP: Proprietary Mode Radio Setup Command for All Frequency Bands */ -rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup = +rfc_CMD_PROP_RADIO_DIV_SETUP_PA_t rf_cmd_prop_radio_div_setup = { - .commandNo = CMD_PROP_RADIO_DIV_SETUP, + .commandNo = 0x3807, .status = IDLE, .pNextOp = 0, .startTime = 0x00000000, @@ -294,12 +198,16 @@ rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, + .txPower = 0xB224, /* set by driver */ .pRegOverride = rf_prop_overrides, .centerFreq = 0x0393, /* set by driver */ .intFreq = 0x8000, /* set by driver */ .loDivider = 0x05, /* set by driver */ + .pRegOverrideTxStd = rf_prop_overrides_tx_std, + .pRegOverrideTx20 = rf_prop_overrides_tx_20, }; + +#endif /* defined(DEVICE_CC1352P) */ /*---------------------------------------------------------------------------*/ /* CMD_FS: Frequency Synthesizer Programming Command */ rfc_CMD_FS_t rf_cmd_prop_fs = diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.h index ab13a754a92bdd260ecac85116681b4e9e8953db..b1971eb0d04a28067801f3872fcf733a2d65bae7 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-settings.h @@ -42,16 +42,17 @@ #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ /* TI-RTOS RF Mode Object */ -extern RF_Mode rf_prop_mode; +extern RF_Mode rf_prop_mode; /*---------------------------------------------------------------------------*/ /* RF Core API commands */ -extern rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup; -extern rfc_CMD_FS_t rf_cmd_prop_fs; -extern rfc_CMD_PROP_TX_ADV_t rf_cmd_prop_tx_adv; -extern rfc_CMD_PROP_RX_ADV_t rf_cmd_prop_rx_adv; -/*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_prop_overrides[]; +#if defined(DEVICE_CC1312R) || defined(DEVICE_CC1352R) +extern rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup; +#else +extern rfc_CMD_PROP_RADIO_DIV_SETUP_PA_t rf_cmd_prop_radio_div_setup; +#endif +extern rfc_CMD_FS_t rf_cmd_prop_fs; +extern rfc_CMD_PROP_TX_ADV_t rf_cmd_prop_tx_adv; +extern rfc_CMD_PROP_RX_ADV_t rf_cmd_prop_rx_adv; /*---------------------------------------------------------------------------*/ #endif /* PROP_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-tx-power.c index 8052ac4fb97587c7835e216af4776ea4d65699c9..ca8742ed9cc679fed3ad4aabbd02fbc8b7873570 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc13x2/prop-tx-power.c @@ -50,29 +50,29 @@ */ tx_power_table_t rf_prop_tx_power_table_cc1312r[] = { - { -20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 2) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 4) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 7) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 7) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 9) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 11) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 12) }, - { 6, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 3, 0, 14) }, - { 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 2, 0, 16) }, - { 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 32) }, - { 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 0, 28) }, - { 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 3, 0, 55) }, - { 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 2, 0, 42) }, - { 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 0, 0, 58) }, - /* The original PA value (12.5 dBm) have been rounded to an integer value. */ - { 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 102) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 8) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 9) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 10) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 3, 0, 11) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 14) }, + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 3, 0, 16) }, + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 0, 19) }, + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 3, 0, 22) }, + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 3, 0, 31) }, + {10, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 2, 0, 31) }, + {11, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 2, 0, 51) }, + {12, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 0, 0, 82) }, + // The original PA value (12.5 dBm) has been rounded to an integer value. + {13, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 0, 89) }, #if RF_TXPOWER_BOOST_MODE - /* This setting requires RF_TXPOWER_BOOST_MODE = 1. */ - { 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 79) }, -#endif + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 0) }, +#endif /* RF_TXPOWER_BOOST_MODE */ RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ @@ -85,29 +85,29 @@ tx_power_table_t rf_prop_tx_power_table_cc1312r[] = */ tx_power_table_t rf_prop_tx_power_table_cc1352r[] = { - { -20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 2) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 4) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 7) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 7) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 9) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 11) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 12) }, - { 6, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 3, 0, 14) }, - { 7, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 2, 0, 16) }, - { 8, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 32) }, - { 9, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 3, 0, 28) }, - { 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 3, 0, 55) }, - { 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 2, 0, 42) }, - { 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 0, 0, 58) }, - /* The original PA value (12.5 dBm) have been rounded to an integer value. */ - { 13, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 102) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 8) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 9) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 10) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 3, 0, 11) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 14) }, + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 3, 0, 16) }, + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 0, 19) }, + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 3, 0, 22) }, + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 3, 0, 31) }, + {10, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 2, 0, 31) }, + {11, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 2, 0, 51) }, + {12, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 0, 0, 82) }, + // The original PA value (12.5 dBm) has been rounded to an integer value. + {13, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 0, 89) }, #if RF_TXPOWER_BOOST_MODE - /* This setting requires RF_TXPOWER_BOOST_MODE = 1. */ - { 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 79) }, -#endif + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 0) }, +#endif /* RF_TXPOWER_BOOST_MODE */ RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ @@ -118,51 +118,37 @@ tx_power_table_t rf_prop_tx_power_table_cc1352r[] = * See the Technical Reference Manual for further details about the "txPower" Command field. * The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. */ -tx_power_table_t rf_prop_tx_power_table_cc1352p_dpa[] = +tx_power_table_t rf_prop_tx_power_table_cc1352p[] = { - { -20, RF_TxPowerTable_DEFAULT_PA_ENTRY( 0, 3, 0, 2) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 1, 3, 0, 3) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY( 2, 3, 0, 3) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 3, 0, 6) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 8) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 3, 0, 9) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 9) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 11) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 12) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 14) }, - { 6, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 2, 0, 14) }, - { 7, RF_TxPowerTable_DEFAULT_PA_ENTRY( 4, 1, 0, 16) }, - { 8, RF_TxPowerTable_DEFAULT_PA_ENTRY( 6, 1, 0, 19) }, - { 9, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 1, 0, 25) }, - { 10, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 40) }, - { 11, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 0, 0, 71) }, - { 12, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 0, 64) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 8) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 9) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 10) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 3, 0, 11) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 14) }, + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 3, 0, 16) }, + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 0, 19) }, + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 3, 0, 22) }, + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 3, 0, 31) }, + {10, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 2, 0, 31) }, + {11, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 2, 0, 51) }, + {12, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 0, 0, 82) }, + // The original PA value (12.5 dBm) has been rounded to an integer value. + {13, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 0, 89) }, #if RF_TXPOWER_BOOST_MODE - /* - * This setting requires RF_TXPOWER_BOOST_MODE = 1. - * The original PA value (13.5 dBm) have been rounded to an integer value. - */ - { 14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 0) }, -#endif - RF_TxPowerTable_TERMINATION_ENTRY -}; -/*---------------------------------------------------------------------------*/ -/* - * TX Power table for CC1352P with high PA - * The RF_TxPowerTable_HIGH_PA_ENTRY macro is defined in RF.h and requires the following arguments: - * RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldoTrim) - * See the Technical Reference Manual for further details about the "txPower" Command field. - * The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. - */ -tx_power_table_t rf_prop_tx_power_table_cc1352p_hpa[] = -{ - { 14, RF_TxPowerTable_HIGH_PA_ENTRY( 7, 0, 0, 23, 4) }, - { 15, RF_TxPowerTable_HIGH_PA_ENTRY(10, 0, 0, 26, 4) }, - { 16, RF_TxPowerTable_HIGH_PA_ENTRY(14, 0, 0, 33, 4) }, - { 17, RF_TxPowerTable_HIGH_PA_ENTRY(18, 0, 0, 40, 6) }, - { 18, RF_TxPowerTable_HIGH_PA_ENTRY(24, 0, 0, 51, 8) }, - { 19, RF_TxPowerTable_HIGH_PA_ENTRY(32, 0, 0, 73, 12) }, - { 20, RF_TxPowerTable_HIGH_PA_ENTRY(27, 0, 0, 85, 32) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 0) }, +#endif /* RF_TXPOWER_BOOST_MODE */ + {15, RF_TxPowerTable_HIGH_PA_ENTRY(18, 0, 0, 36, 0) }, + {16, RF_TxPowerTable_HIGH_PA_ENTRY(24, 0, 0, 43, 0) }, + {17, RF_TxPowerTable_HIGH_PA_ENTRY(28, 0, 0, 51, 2) }, + {18, RF_TxPowerTable_HIGH_PA_ENTRY(34, 0, 0, 64, 4) }, + {19, RF_TxPowerTable_HIGH_PA_ENTRY(15, 3, 0, 36, 4) }, + {20, RF_TxPowerTable_HIGH_PA_ENTRY(18, 3, 0, 71, 27) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ @@ -182,11 +168,7 @@ tx_power_table_t rf_prop_tx_power_table_empty[] = #define TX_POWER_TABLE rf_prop_tx_power_table_cc1352r #elif defined(DEVICE_CC1352P) -#if RF_TXPOWER_HIGH_PA -#define TX_POWER_TABLE rf_prop_tx_power_table_cc1352p_hpa -#else -#define TX_POWER_TABLE rf_prop_tx_power_table_cc1352p_dpa -#endif +#define TX_POWER_TABLE rf_prop_tx_power_table_cc1352p #else #define TX_POWER_TABLE rf_prop_tx_power_table_empty diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.c index 9c19021fdfdd2a1a8149c1f3441717a378c115fb..50425a3a1b8bd6d1439504d108a21de2f941f180 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.c @@ -61,39 +61,52 @@ RF_Mode rf_ble_mode = .rfePatchFxn = &rf_patch_rfe_ble, }; /*---------------------------------------------------------------------------*/ -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x9330 /* 5 dBm */ -/*---------------------------------------------------------------------------*/ /* Overrides for CMD_RADIO_SETUP */ uint32_t rf_ble_overrides[] CC_ALIGN(4) = { - /* override_use_patch_ble_1mbps.xml */ - MCE_RFE_OVERRIDE(0,0,0,1,0,0), /* PHY: Use MCE ROM, RFE RAM patch */ - /* override_synth_ble_1mbps.xml */ - HW_REG_OVERRIDE(0x4038,0x0035), /* Synth: Set recommended RTRIM to 5 */ - (uint32_t)0x000784A3, /* Synth: Set Fref to 3.43 MHz */ - (uint32_t)0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz */ - (uint32_t)0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz */ - (uint32_t)0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz */ - HW32_ARRAY_OVERRIDE(0x405C,1), /* Synth: Configure PLL bias */ - (uint32_t)0x1801F800, /* Synth: Configure PLL bias */ - HW32_ARRAY_OVERRIDE(0x402C,1), /* Synth: Configure PLL latency */ - (uint32_t)0x00608402, /* Synth: Configure PLL latency */ - (uint32_t)0x02010403, /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */ - HW32_ARRAY_OVERRIDE(0x4034,1), /* Synth: Configure extra PLL filtering */ - (uint32_t)0x177F0408, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x38000463, /* Synth: Configure extra PLL filtering */ - /* override_phy_ble_1mbps.xml */ - (uint32_t)0x013800C3, /* Tx: Configure symbol shape for BLE frequency deviation requirements */ - HW_REG_OVERRIDE(0x6088, 0x0045), /* Rx: Configure AGC reference level */ - /* Tx: Configure pilot tone length to ensure stable frequency */ - HW_REG_OVERRIDE(0x52AC, 0x0360), /* before start of packet */ - (uint32_t)0x01AD02A3, /* Tx: Compensate timing offset to match new pilot tone setting */ - (uint32_t)0x01680263, /* Tx: Compensate timing offset to match new pilot tone setting */ - (uint32_t)0xFFFFFFFF, + // override_use_patch_ble_1mbps.xml + // PHY: Use MCE ROM, RFE RAM patch + MCE_RFE_OVERRIDE(0,0,0,1,0,0), + // override_synth_ble_1mbps.xml + // Synth: Set recommended RTRIM to 5 + HW_REG_OVERRIDE(0x4038,0x0035), + // Synth: Set Fref to 3.43 MHz + (uint32_t)0x000784A3, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xA47E0583, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xEAE00603, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0x00010623, + // Synth: Configure PLL bias + HW32_ARRAY_OVERRIDE(0x405C,1), + // Synth: Configure PLL bias + (uint32_t)0x1801F800, + // Synth: Configure PLL latency + HW32_ARRAY_OVERRIDE(0x402C,1), + // Synth: Configure PLL latency + (uint32_t)0x00608402, + // Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering + (uint32_t)0x02010403, + // Synth: Configure extra PLL filtering + HW32_ARRAY_OVERRIDE(0x4034,1), + // Synth: Configure extra PLL filtering + (uint32_t)0x177F0408, + // Synth: Configure extra PLL filtering + (uint32_t)0x38000463, + // override_phy_ble_1mbps.xml + // Tx: Configure symbol shape for BLE frequency deviation requirements + (uint32_t)0x013800C3, + // Rx: Configure AGC reference level + HW_REG_OVERRIDE(0x6088, 0x0045), + // Tx: Configure pilot tone length to ensure stable frequency before start of packet + HW_REG_OVERRIDE(0x52AC, 0x0360), + // Tx: Compensate timing offset to match new pilot tone setting + (uint32_t)0x01AD02A3, + // Tx: Compensate timing offset to match new pilot tone setting + (uint32_t)0x01680263, + // override_frontend_id.xml + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */ @@ -115,7 +128,7 @@ rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, + .txPower = 0x9330, /* set by driver */ .pRegOverride = rf_ble_overrides, }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.h index 0679265d6f9dab63d729f353fdc67a7a73b27467..e934d5068bc2b7628384da660b4868d777092ef4 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-settings.h @@ -45,8 +45,5 @@ extern RF_Mode rf_ble_mode; extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup; extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc; /*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ble_overrides[]; -/*---------------------------------------------------------------------------*/ #endif /* BLE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-tx-power.c index 7510df27a870cb04e1bef2e3f613453852f4be7f..20fe39cfc6e290ffe5a11111e03a8187d8fe8d35 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ble-tx-power.c @@ -50,19 +50,19 @@ */ tx_power_table_t rf_ble_tx_power_table_cc2650[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 6) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 6) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) }, + {-21, RF_TxPowerTable_DEFAULT_PA_ENTRY(7, 3, 0, 6) }, + {-18, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 6) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) }, + {-12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) }, + {-9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) }, + {-6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) }, + {-3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.c index 4d860109d707694104302459003e762679049025..206a272c2203f9abc3d60c184187adaba1699926 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.c @@ -57,39 +57,50 @@ RF_Mode rf_ieee_mode = .cpePatchFxn = &rf_patch_cpe_ieee, .mcePatchFxn = 0, .rfePatchFxn = 0, -}; -/*---------------------------------------------------------------------------*/ -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x9330 /* 5 dBm */ -/*---------------------------------------------------------------------------*/ +};/*---------------------------------------------------------------------------*/ /* Overrides for CMD_RADIO_SETUP */ uint32_t rf_ieee_overrides[] CC_ALIGN(4) = { - /* override_synth_ieee_15_4.xml */ - HW_REG_OVERRIDE(0x4038,0x0035), /* Synth: Set recommended RTRIM to 5 */ - (uint32_t)0x000784A3, /* Synth: Set Fref to 3.43 MHz */ - (uint32_t)0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz */ - (uint32_t)0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz */ - (uint32_t)0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz */ - HW32_ARRAY_OVERRIDE(0x405C,1), /* Synth: Configure PLL bias */ - (uint32_t)0x1801F800, /* Synth: Configure PLL bias */ - HW32_ARRAY_OVERRIDE(0x402C,1), /* Synth: Configure PLL latency */ - (uint32_t)0x00608402, /* Synth: Configure PLL latency */ - (uint32_t)0x02010403, /* Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering */ - HW32_ARRAY_OVERRIDE(0x4034,1), /* Synth: Configure extra PLL filtering */ - (uint32_t)0x177F0408, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x38000463, /* Synth: Configure extra PLL filtering */ - /* override_phy_ieee_15_4.xml */ - (uint32_t)0x05000243, /* Synth: Increase synth programming timeout */ - (uint32_t)0x002082C3, /* Rx: Adjust Rx FIFO threshold to avoid overflow */ - /* override_frontend_id.xml */ - (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB */ - (uint32_t)0x000F8883, /* Rx: Configure LNA bias current trim offset */ - HW_REG_OVERRIDE(0x50DC,0x002B), /* Rx: Adjust AGC DC filter */ - (uint32_t)0xFFFFFFFF, + // override_synth_ieee_15_4.xml + // Synth: Set recommended RTRIM to 5 + HW_REG_OVERRIDE(0x4038,0x0035), + // Synth: Set Fref to 3.43 MHz + (uint32_t)0x000784A3, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xA47E0583, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0xEAE00603, + // Synth: Set loop bandwidth after lock to 80 kHz + (uint32_t)0x00010623, + // Synth: Configure PLL bias + HW32_ARRAY_OVERRIDE(0x405C,1), + // Synth: Configure PLL bias + (uint32_t)0x1801F800, + // Synth: Configure PLL latency + HW32_ARRAY_OVERRIDE(0x402C,1), + // Synth: Configure PLL latency + (uint32_t)0x00608402, + // Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering + (uint32_t)0x02010403, + // Synth: Configure extra PLL filtering + HW32_ARRAY_OVERRIDE(0x4034,1), + // Synth: Configure extra PLL filtering + (uint32_t)0x177F0408, + // Synth: Configure extra PLL filtering + (uint32_t)0x38000463, + // override_phy_ieee_15_4.xml + // Synth: Increase synth programming timeout + (uint32_t)0x05000243, + // Rx: Adjust Rx FIFO threshold to avoid overflow + (uint32_t)0x002082C3, + // override_frontend_id.xml + // Rx: Set RSSI offset to adjust reported RSSI by -2 dB + (uint32_t)0x000288A3, + // Rx: Configure LNA bias current trim offset + (uint32_t)0x000F8883, + // Rx: Adjust AGC DC filter + HW_REG_OVERRIDE(0x50DC,0x002B), + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */ @@ -111,7 +122,7 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, /* 5 dBm default */ + .txPower = 0x9330, /* set by driver */ .pRegOverride = rf_ieee_overrides, }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.h index 7019598c8d5842f3c905cac668cc8d27b214c742..d657ac3e720350f5b67d46c1cd9cd5acc3d89d6d 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-settings.h @@ -51,8 +51,5 @@ extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx; extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx; extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack; /*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ieee_overrides[]; -/*---------------------------------------------------------------------------*/ #endif /* IEEE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-tx-power.c index a3a34a8605f3eda9732b6a15eca72eea490f9cb0..44768396ab8f1a75e00da7fc16a6a150a73dfaed 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x0/ieee-tx-power.c @@ -50,19 +50,19 @@ */ tx_power_table_t rf_ieee_tx_power_table_cc2650[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 6) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 6) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) }, + {-21, RF_TxPowerTable_DEFAULT_PA_ENTRY(7, 3, 0, 6) }, + {-18, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 6) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 6) }, + {-12, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 1, 0, 10) }, + {-9, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 1, 12) }, + {-6, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 1, 1, 14) }, + {-3, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 1, 1, 18) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(33, 1, 1, 24) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 0, 0, 33) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 0, 0, 39) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 0, 0, 45) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 1, 73) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(48, 0, 1, 73) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.c index 21ed73201961fa0c2f313edd9c8e0c0e26229449..c8c8c7e110d83772a4d21cd65e0fcae03d1d33ef 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.c @@ -47,8 +47,6 @@ #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) #include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h) #include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h) #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ @@ -59,72 +57,58 @@ RF_Mode rf_ble_mode = { .rfMode = RF_MODE_AUTO, .cpePatchFxn = &rf_patch_cpe_multi_protocol, - .mcePatchFxn = &rf_patch_mce_bt5, - .rfePatchFxn = &rf_patch_rfe_bt5, + .mcePatchFxn = 0, + .rfePatchFxn = 0, }; /*---------------------------------------------------------------------------*/ -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x941E /* 5 dBm */ -/*---------------------------------------------------------------------------*/ /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_common[] CC_ALIGN(4) = { - /* override_ble5_setup_override_common.xml */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure synth hardware */ - (uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - (uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */ - /* DC/DC regulator: */ - /* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0x00038883, /* Rx: Set LNA bias current offset to adjust +3 (default: 0) */ - (uint32_t)0x000288A3, /* Rx: Set RSSI offset to adjust reported RSSI by -2 dB (default: 0) */ - (uint32_t)0x01080263, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0x08E90AA3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0x00068BA3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - /* Bluetooth 5: Set correct total clock accuracy for received AuxPtr */ - (uint32_t)0x0E490C83, /* assuming local sleep clock of 50 ppm */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_common.xml + // DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0x3 (DITHER_EN=0 and IPEAK=3). + (uint32_t)0x00F388D3, + // Bluetooth 5: Set pilot tone length to 20 us Common + HW_REG_OVERRIDE(0x6024,0x2E20), + // Bluetooth 5: Compensate for reduced pilot tone length + (uint32_t)0x01280263, + // Bluetooth 5: Default to no CTE. + HW_REG_OVERRIDE(0x5328,0x0000), + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_1mbps[] CC_ALIGN(4) = { - /* override_ble5_setup_override_1mbps.xml */ - MCE_RFE_OVERRIDE(1,0,0,1,0,0), /* PHY: Use MCE RAM patch (mode 0), RFE RAM patch (mode 0) */ - HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */ - (uint32_t)0x013302A3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_1mbps.xml + // Bluetooth 5: Set pilot tone length to 20 us + HW_REG_OVERRIDE(0x5320,0x03C0), + // Bluetooth 5: Compensate syncTimeadjust + (uint32_t)0x015302A3, + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_2mbps[] CC_ALIGN(4) = { - /* override_ble5_setup_override_2mbps.xml */ - MCE_RFE_OVERRIDE(1,0,2,1,0,2), /* PHY: Use MCE RAM patch (mode 2), RFE RAM patch (mode 2) */ - HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */ - (uint32_t)0x00D102A3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_2mbps.xml + // Bluetooth 5: Set pilot tone length to 20 us + HW_REG_OVERRIDE(0x5320,0x03C0), + // Bluetooth 5: Compensate syncTimeAdjust + (uint32_t)0x00F102A3, + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* Overrides for CMD_BLE5_RADIO_SETUP */ uint32_t rf_ble_overrides_coded[] CC_ALIGN(4) = { - /* override_ble5_setup_override_coded.xml */ - MCE_RFE_OVERRIDE(1,0,1,1,0,1), /* PHY: Use MCE RAM patch (mode 1), RFE RAM patch (mode 1) */ - HW_REG_OVERRIDE(0x5320,0x0240), /* Bluetooth 5: Reduce pilot tone length */ - (uint32_t)0x078902A3, /* Bluetooth 5: Compensate for reduced pilot tone length */ - (uint32_t)0xFFFFFFFF, + // override_ble5_setup_override_coded.xml + // Bluetooth 5: Set pilot tone length to 20 us + HW_REG_OVERRIDE(0x5320,0x03C0), + // Bluetooth 5: Compensate syncTimeadjust + (uint32_t)0x07A902A3, + // Rx: Set AGC reference level to 0x1B (default: 0x2E) + HW_REG_OVERRIDE(0x609C,0x001B), + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* CMD_BLE5_RADIO_SETUP: Bluetooth 5 Radio Setup Command for all PHYs */ @@ -147,7 +131,7 @@ rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, + .txPower = 0x7217, /* set by driver */ .pRegOverrideCommon = rf_ble_overrides_common, .pRegOverride1Mbps = rf_ble_overrides_1mbps, .pRegOverride2Mbps = rf_ble_overrides_2mbps, diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.h index c5295c868d779d1cd2ce5fa932a3c3815e72aaf7..21331a3460fca8697725f6da1fb1dfa2221eff68 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-settings.h @@ -45,11 +45,5 @@ extern RF_Mode rf_ble_mode; extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup; extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc; /*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ble_overrides_common[]; -extern uint32_t rf_ble_overrides_1mbps[]; -extern uint32_t rf_ble_overrides_2mbps[]; -extern uint32_t rf_ble_overrides_coded[]; -/*---------------------------------------------------------------------------*/ #endif /* BLE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-tx-power.c index 368c196371fa9753120e86655c1ba9672c38144e..772e8e7ece5a92a903e739d1ef883f2055c65174 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ble-tx-power.c @@ -50,21 +50,16 @@ */ tx_power_table_t rf_ble_tx_power_table_cc2652r[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY( 7, 3, 0, 3) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY( 9, 3, 0, 3) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY( 8, 2, 0, 6) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 2, 0, 8) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.c index d95ff87ba3390ec216bd8f8c87229dae6e038f55..068d9406b25c20e71084c3dfad2692fad7135684 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2018-2019, Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) #include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h) #include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h) -#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h) #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ @@ -56,37 +55,19 @@ RF_Mode rf_ieee_mode = { .rfMode = RF_MODE_AUTO, .cpePatchFxn = &rf_patch_cpe_multi_protocol, - .mcePatchFxn = &rf_patch_mce_ieee_802_15_4, + .mcePatchFxn = 0, .rfePatchFxn = 0, }; /*---------------------------------------------------------------------------*/ -/* - * CMD_RADIO_SETUP must be configured with default TX power value - * in the .txPower field. - */ -#define DEFAULT_TX_POWER 0x941E /* 5 dBm */ -/*---------------------------------------------------------------------------*/ /* Overrides for CMD_RADIO_SETUP */ uint32_t rf_ieee_overrides[] CC_ALIGN(4) = { - /* override_ieee_802_15_4.xml */ - MCE_RFE_OVERRIDE(1,0,0,0,1,0), /* PHY: Use MCE RAM patch, RFE ROM bank 1 */ - (uint32_t)0x02400403, /* Synth: Use 48 MHz crystal, enable extra PLL filtering */ - (uint32_t)0x001C8473, /* Synth: Configure extra PLL filtering */ - (uint32_t)0x00088433, /* Synth: Configure synth hardware */ - (uint32_t)0x00038793, /* Synth: Set minimum RTRIM to 3 */ - HW32_ARRAY_OVERRIDE(0x4004,1), /* Synth: Configure faster calibration */ - (uint32_t)0x1C0C0618, /* Synth: Configure faster calibration */ - (uint32_t)0xC00401A1, /* Synth: Configure faster calibration */ - (uint32_t)0x00010101, /* Synth: Configure faster calibration */ - (uint32_t)0xC0040141, /* Synth: Configure faster calibration */ - (uint32_t)0x00214AD3, /* Synth: Configure faster calibration */ - (uint32_t)0x02980243, /* Synth: Decrease synth programming time-out (0x0298 RAT ticks = 166 us) */ - /* DC/DC regulator: */ - /* In Tx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0xFCFC08C3, /* In Rx, use DCDCCTL5[3:0]=0xC (DITHER_EN=1 and IPEAK=4). */ - (uint32_t)0x000F8883, /* Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) */ - (uint32_t)0xFFFFFFFF, + // override_ieee_802_15_4.xml + // DC/DC regulator: In Tx, use DCDCCTL5[3:0]=0x3 (DITHER_EN=0 and IPEAK=3). + (uint32_t)0x00F388D3, + // Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) + (uint32_t)0x000F8883, + (uint32_t)0xFFFFFFFF }; /*---------------------------------------------------------------------------*/ /* CMD_RADIO_SETUP: Radio Setup Command for Pre-Defined Schemes */ @@ -108,7 +89,7 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup = .config.biasMode = 0x0, /* set by driver */ .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, - .txPower = DEFAULT_TX_POWER, + .txPower = 0x7217, /* set by driver */ .pRegOverride = rf_ieee_overrides, }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.h index 141a0e4b35d501b6e98237dd692dc91a6f3ef3c6..9ed6cbceab600140e6b22ea2b5b8831eeb7a2e0f 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-settings.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2018-2019, Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,9 +52,6 @@ extern rfc_CMD_IEEE_TX_t rf_cmd_ieee_tx; extern rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx; extern rfc_CMD_IEEE_RX_ACK_t rf_cmd_ieee_rx_ack; /*---------------------------------------------------------------------------*/ -/* RF Core API Overrides */ -extern uint32_t rf_ieee_overrides[]; -/*---------------------------------------------------------------------------*/ #endif /* IEEE_SETTINGS_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-tx-power.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-tx-power.c index fcf3532098ed1d15e5db21208bbab4efe1254925..9ddf0f3b426573b4fdc884edd022b4363d73d1e6 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-tx-power.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf-settings/cc26x2/ieee-tx-power.c @@ -50,21 +50,16 @@ */ tx_power_table_t rf_ieee_tx_power_table_cc2652r[] = { - { -21, RF_TxPowerTable_DEFAULT_PA_ENTRY(7, 3, 0, 3) }, - { -18, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 3) }, - { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 100) }, - { -12, RF_TxPowerTable_DEFAULT_PA_ENTRY(40, 2, 0, 8) }, - { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 2, 0, 11) }, - { -9, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 2, 0, 5) }, - { -6, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 1, 0, 16) }, - { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 1, 0, 17) }, - { -3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 1, 0, 20) }, - { 0, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 26) }, - { 1, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 1, 0, 28) }, - { 2, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 0, 0, 34) }, - { 3, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 0, 0, 42) }, - { 4, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 0, 0, 54) }, - { 5, RF_TxPowerTable_DEFAULT_PA_ENTRY(30, 0, 0, 74) }, + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, RF_TxPowerTable_TERMINATION_ENTRY }; /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf/ieee-mode.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf/ieee-mode.c index d1e71fd46073855a52c7d2c1b941f2bd7def48ca..6f690f57a0b7f57e5a555ef3581bb9ef0e90204e 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf/ieee-mode.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf/ieee-mode.c @@ -61,8 +61,12 @@ * discrepancy between CC13x0 and CC13x2 IEEE support. CC13x0 doesn't provide * RFCore definitions of IEEE commands, and are therefore included locally * from the Contiki build system. CC13x2 includes these normally from driverlib. - * This is taken care of RF settings. */ +#if defined(DeviceFamily_CC13X0) +#include "driverlib/rf_ieee_mailbox.h" +#else +#include DeviceFamily_constructPath(driverlib/rf_ieee_mailbox.h) +#endif #include <ti/drivers/rf/RF.h> /*---------------------------------------------------------------------------*/ @@ -109,6 +113,19 @@ #define STATUS_REJECT_FRAME 0x40 /* bit 6 */ #define STATUS_CRC_FAIL 0x80 /* bit 7 */ /*---------------------------------------------------------------------------*/ +/* + * The number of bytes appended at the end of an outgoing frame as a footer + * Currently fixed at 2 bytes for IEEE 802.15.4 compliance. + */ +#define CHECKSUM_LEN 2 + +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the FCS. + */ +#define MAX_PAYLOAD_LEN (127 - CHECKSUM_LEN) +/*---------------------------------------------------------------------------*/ #define FRAME_FCF_OFFSET 0 #define FRAME_SEQNUM_OFFSET 2 @@ -172,17 +189,24 @@ static ieee_radio_t ieee_radio; /* Global RF Core commands */ static cmd_mod_filt_t cmd_mod_filt; /*---------------------------------------------------------------------------*/ -/* RF Command volatile objects */ -#define cmd_radio_setup (*(volatile rfc_CMD_RADIO_SETUP_t *)&rf_cmd_ieee_radio_setup) -#define cmd_fs (*(volatile rfc_CMD_FS_t *) &rf_cmd_ieee_fs) -#define cmd_tx (*(volatile rfc_CMD_IEEE_TX_t *) &rf_cmd_ieee_tx) -#define cmd_rx (*(volatile rfc_CMD_IEEE_RX_t *) &rf_cmd_ieee_rx) -#define cmd_rx_ack (*(volatile rfc_CMD_IEEE_RX_ACK_t *)&rf_cmd_ieee_rx_ack) +/* Convenience macros for more succinct access of RF commands */ +#define cmd_radio_setup rf_cmd_ieee_radio_setup +#define cmd_fs rf_cmd_ieee_fs +#define cmd_tx rf_cmd_ieee_tx +#define cmd_rx rf_cmd_ieee_rx +#define cmd_rx_ack rf_cmd_ieee_rx_ack + +/* Convenience macros for volatile access with the RF commands */ +#define v_cmd_radio_setup CC_ACCESS_NOW(rfc_CMD_RADIO_SETUP_t, rf_cmd_ieee_radio_setup) +#define v_cmd_fs CC_ACCESS_NOW(rfc_CMD_FS_t, rf_cmd_ieee_fs) +#define v_cmd_tx CC_ACCESS_NOW(rfc_CMD_IEEE_TX_t, rf_cmd_ieee_tx) +#define v_cmd_rx CC_ACCESS_NOW(rfc_CMD_IEEE_RX_t, rf_cmd_ieee_rx) +#define v_cmd_rx_ack CC_ACCESS_NOW(rfc_CMD_IEEE_RX_ACK_t, rf_cmd_ieee_rx_ack) /*---------------------------------------------------------------------------*/ static inline bool rx_is_active(void) { - return cmd_rx.status == ACTIVE; + return v_cmd_rx.status == ACTIVE; } /*---------------------------------------------------------------------------*/ /* Forward declarations of local functions */ @@ -220,9 +244,7 @@ init_rf_params(void) cmd_radio_setup.config.frontEndMode = RF_2_4_GHZ_FRONT_END_MODE; cmd_radio_setup.config.biasMode = RF_2_4_GHZ_BIAS_MODE; - data_queue_t *rx_q = data_queue_init(sizeof(lensz_t)); - - cmd_rx.pRxQ = rx_q; + cmd_rx.pRxQ = data_queue_init(sizeof(lensz_t)); cmd_rx.pOutput = &ieee_radio.rx_stats; #if IEEE_MODE_PROMISCOUS @@ -256,8 +278,8 @@ init_rf_params(void) /* Initialize address filter command */ cmd_mod_filt.commandNo = CMD_IEEE_MOD_FILT; - memcpy(&(cmd_mod_filt.newFrameFiltOpt), &(rf_cmd_ieee_rx.frameFiltOpt), sizeof(rf_cmd_ieee_rx.frameFiltOpt)); - memcpy(&(cmd_mod_filt.newFrameTypes), &(rf_cmd_ieee_rx.frameTypes), sizeof(rf_cmd_ieee_rx.frameTypes)); + memcpy(&(cmd_mod_filt.newFrameFiltOpt), &(cmd_rx.frameFiltOpt), sizeof(cmd_rx.frameFiltOpt)); + memcpy(&(cmd_mod_filt.newFrameTypes), &(cmd_rx.frameTypes), sizeof(cmd_rx.frameTypes)); } /*---------------------------------------------------------------------------*/ static rf_result_t @@ -274,12 +296,12 @@ set_channel(uint8_t channel) * set_channel() to cause a synth calibration, since channel must be in * range 11-26. */ - if(channel == cmd_rx.channel) { + if(channel == v_cmd_rx.channel) { /* We are already calibrated to this channel */ return true; } - cmd_rx.channel = channel; + v_cmd_rx.channel = channel; const uint32_t new_freq = dot_15_4g_freq(channel); const uint16_t freq = (uint16_t)(new_freq / 1000); @@ -288,8 +310,8 @@ set_channel(uint8_t channel) LOG_DBG("Set channel to %d, frequency 0x%04X.0x%04X (%lu)\n", (int)channel, freq, frac, new_freq); - cmd_fs.frequency = freq; - cmd_fs.fractFreq = frac; + v_cmd_fs.frequency = freq; + v_cmd_fs.fractFreq = frac; return netstack_sched_fs(); } @@ -359,6 +381,10 @@ rat_to_timestamp(const uint32_t rat_ticks) static int init(void) { + RF_Params rf_params; + RF_TxPowerTable_Value tx_power_value; + RF_Stat rf_stat; + if(ieee_radio.rf_handle) { LOG_WARN("Radio already initialized\n"); return RF_RESULT_OK; @@ -370,7 +396,6 @@ init(void) init_rf_params(); /* Init RF params and specify non-default params */ - RF_Params rf_params; RF_Params_init(&rf_params); rf_params.nInactivityTimeout = RF_CONF_INACTIVITY_TIMEOUT; @@ -383,8 +408,17 @@ init(void) set_channel(DOT_15_4G_DEFAULT_CHAN); - int8_t max_tx_power = tx_power_max(rf_tx_power_table, rf_tx_power_table_size); - rf_set_tx_power(ieee_radio.rf_handle, rf_tx_power_table, max_tx_power); + tx_power_value = RF_TxPowerTable_findValue(rf_tx_power_table, RF_TXPOWER_DBM); + if(tx_power_value.rawValue != RF_TxPowerTable_INVALID_VALUE) { + rf_stat = RF_setTxPower(ieee_radio.rf_handle, tx_power_value); + if(rf_stat == RF_StatSuccess) { + LOG_INFO("TX power configured to %d dBm\n", RF_TXPOWER_DBM); + } else { + LOG_WARN("Setting TX power to %d dBm failed, stat=0x%02X", RF_TXPOWER_DBM, rf_stat); + } + } else { + LOG_WARN("Unable to find TX power %d dBm in the TX power table\n", RF_TXPOWER_DBM); + } ENERGEST_ON(ENERGEST_TYPE_LISTEN); @@ -402,7 +436,7 @@ init(void) static int prepare(const void *payload, unsigned short payload_len) { - if(payload_len > TX_BUF_SIZE || payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > TX_BUF_SIZE || payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } memcpy(ieee_radio.tx_buf, payload, payload_len); @@ -414,7 +448,7 @@ transmit(unsigned short transmit_len) { rf_result_t res; - if(transmit_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(transmit_len > MAX_PAYLOAD_LEN) { LOG_ERR("Too long\n"); return RADIO_TX_ERR; } @@ -431,20 +465,20 @@ transmit(unsigned short transmit_len) const bool ack_request = (bool)(ieee_radio.tx_buf[FRAME_FCF_OFFSET] & FRAME_ACK_REQUEST); if(ack_request) { /* Yes, turn on chaining */ - cmd_tx.condition.rule = COND_STOP_ON_FALSE; + v_cmd_tx.condition.rule = COND_STOP_ON_FALSE; /* Reset CMD_IEEE_RX_ACK command */ - cmd_rx_ack.status = IDLE; + v_cmd_rx_ack.status = IDLE; /* Sequence number is the third byte in the frame */ - cmd_rx_ack.seqNo = ieee_radio.tx_buf[FRAME_SEQNUM_OFFSET]; + v_cmd_rx_ack.seqNo = ieee_radio.tx_buf[FRAME_SEQNUM_OFFSET]; } else { /* No, turn off chaining */ - cmd_tx.condition.rule = COND_NEVER; + v_cmd_tx.condition.rule = COND_NEVER; } /* Configure TX command */ - cmd_tx.payloadLen = (uint8_t)transmit_len; - cmd_tx.pPayload = ieee_radio.tx_buf; + v_cmd_tx.payloadLen = (uint8_t)transmit_len; + v_cmd_tx.pPayload = ieee_radio.tx_buf; res = netstack_sched_ieee_tx(ack_request); @@ -453,7 +487,7 @@ transmit(unsigned short transmit_len) } if(ack_request) { - switch(cmd_rx_ack.status) { + switch(v_cmd_rx_ack.status) { /* CMD_IEEE_RX_ACK timed out, i.e. never received ACK */ case IEEE_DONE_TIMEOUT: return RADIO_TX_NOACK; /* An ACK was received with either pending data bit set or cleared */ @@ -565,7 +599,7 @@ cca_request(cmd_cca_req_t *cmd_cca_req) /* RX is required to be running in order to do a CCA request */ if(!rx_is_active()) { /* If RX is not pending, i.e. soon to be running, schedule the RX command */ - if(cmd_rx.status != PENDING) { + if(v_cmd_rx.status != PENDING) { res = netstack_sched_rx(false); if(res != RF_RESULT_OK) { LOG_ERR("CCA request failed to schedule RX\n"); @@ -580,7 +614,7 @@ cca_request(cmd_cca_req_t *cmd_cca_req) RTIMER_BUSYWAIT_UNTIL(!rx_is_active(), TIMEOUT_ENTER_RX_WAIT); if(!rx_is_active()) { - LOG_ERR("CCA request failed to turn on RX, RX status=0x%04X\n", cmd_rx.status); + LOG_ERR("CCA request failed to turn on RX, RX status=0x%04X\n", v_cmd_rx.status); return RF_RESULT_ERROR; } } @@ -722,26 +756,26 @@ get_value(radio_param_t param, radio_value_t *value) /* Channel */ case RADIO_PARAM_CHANNEL: - *value = (radio_value_t)cmd_rx.channel; + *value = (radio_value_t)v_cmd_rx.channel; return RADIO_RESULT_OK; /* PAN ID */ case RADIO_PARAM_PAN_ID: - *value = (radio_value_t)cmd_rx.localPanID; + *value = (radio_value_t)v_cmd_rx.localPanID; return RADIO_RESULT_OK; /* 16-bit address */ case RADIO_PARAM_16BIT_ADDR: - *value = (radio_value_t)cmd_rx.localShortAddr; + *value = (radio_value_t)v_cmd_rx.localShortAddr; return RADIO_RESULT_OK; /* RX mode */ case RADIO_PARAM_RX_MODE: *value = 0; - if(cmd_rx.frameFiltOpt.frameFiltEn) { + if(v_cmd_rx.frameFiltOpt.frameFiltEn) { *value |= (radio_value_t)RADIO_RX_MODE_ADDRESS_FILTER; } - if(cmd_rx.frameFiltOpt.autoAckEn) { + if(v_cmd_rx.frameFiltOpt.autoAckEn) { *value |= (radio_value_t)RADIO_RX_MODE_AUTOACK; } if(ieee_radio.poll_mode) { @@ -764,7 +798,7 @@ get_value(radio_param_t param, radio_value_t *value) /* CCA threshold */ case RADIO_PARAM_CCA_THRESHOLD: - *value = cmd_rx.ccaRssiThr; + *value = v_cmd_rx.ccaRssiThr; return RADIO_RESULT_OK; /* RSSI */ @@ -803,6 +837,10 @@ get_value(radio_param_t param, radio_value_t *value) *value = (radio_value_t)ieee_radio.last.corr_lqi; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; + default: return RADIO_RESULT_NOT_SUPPORTED; } @@ -839,7 +877,7 @@ set_value(radio_param_t param, radio_value_t value) /* PAN ID */ case RADIO_PARAM_PAN_ID: - cmd_rx.localPanID = (uint16_t)value; + v_cmd_rx.localPanID = (uint16_t)value; if(!ieee_radio.rf_is_on) { return RADIO_RESULT_OK; } @@ -852,7 +890,7 @@ set_value(radio_param_t param, radio_value_t value) /* 16bit address */ case RADIO_PARAM_16BIT_ADDR: - cmd_rx.localShortAddr = (uint16_t)value; + v_cmd_rx.localShortAddr = (uint16_t)value; if(!ieee_radio.rf_is_on) { return RADIO_RESULT_OK; } @@ -871,21 +909,21 @@ set_value(radio_param_t param, radio_value_t value) return RADIO_RESULT_INVALID_VALUE; } - cmd_rx.frameFiltOpt.frameFiltEn = (value & RADIO_RX_MODE_ADDRESS_FILTER) != 0; - cmd_rx.frameFiltOpt.frameFiltStop = 1; - cmd_rx.frameFiltOpt.autoAckEn = (value & RADIO_RX_MODE_AUTOACK) != 0; - cmd_rx.frameFiltOpt.slottedAckEn = 0; - cmd_rx.frameFiltOpt.autoPendEn = 0; - cmd_rx.frameFiltOpt.defaultPend = 0; - cmd_rx.frameFiltOpt.bPendDataReqOnly = 0; - cmd_rx.frameFiltOpt.bPanCoord = 0; - cmd_rx.frameFiltOpt.bStrictLenFilter = 0; + v_cmd_rx.frameFiltOpt.frameFiltEn = (value & RADIO_RX_MODE_ADDRESS_FILTER) != 0; + v_cmd_rx.frameFiltOpt.frameFiltStop = 1; + v_cmd_rx.frameFiltOpt.autoAckEn = (value & RADIO_RX_MODE_AUTOACK) != 0; + v_cmd_rx.frameFiltOpt.slottedAckEn = 0; + v_cmd_rx.frameFiltOpt.autoPendEn = 0; + v_cmd_rx.frameFiltOpt.defaultPend = 0; + v_cmd_rx.frameFiltOpt.bPendDataReqOnly = 0; + v_cmd_rx.frameFiltOpt.bPanCoord = 0; + v_cmd_rx.frameFiltOpt.bStrictLenFilter = 0; const bool old_poll_mode = ieee_radio.poll_mode; ieee_radio.poll_mode = (value & RADIO_RX_MODE_POLL_MODE) != 0; if(old_poll_mode == ieee_radio.poll_mode) { /* Do not turn the radio off and on, just send an update command */ - memcpy(&cmd_mod_filt.newFrameFiltOpt, &(rf_cmd_ieee_rx.frameFiltOpt), sizeof(rf_cmd_ieee_rx.frameFiltOpt)); + memcpy(&cmd_mod_filt.newFrameFiltOpt, &(cmd_rx.frameFiltOpt), sizeof(cmd_rx.frameFiltOpt)); const RF_Stat stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t *)&cmd_mod_filt); if(stat != RF_StatCmdDoneSuccess) { LOG_ERR("Setting address filter failed, stat=0x%02X\n", stat); @@ -924,7 +962,7 @@ set_value(radio_param_t param, radio_value_t value) /* CCA Threshold */ case RADIO_PARAM_CCA_THRESHOLD: - cmd_rx.ccaRssiThr = (int8_t)value; + v_cmd_rx.ccaRssiThr = (int8_t)value; if(!ieee_radio.rf_is_on) { return RADIO_RESULT_OK; } @@ -950,12 +988,12 @@ get_object(radio_param_t param, void *dest, size_t size) switch(param) { /* 64bit address */ case RADIO_PARAM_64BIT_ADDR: { - const size_t srcSize = sizeof(cmd_rx.localExtAddr); + const size_t srcSize = sizeof(v_cmd_rx.localExtAddr); if(size != srcSize) { return RADIO_RESULT_INVALID_VALUE; } - const uint8_t *pSrc = (uint8_t *)&(cmd_rx.localExtAddr); + const uint8_t *pSrc = (uint8_t *)&(v_cmd_rx.localExtAddr); uint8_t *pDest = dest; for(size_t i = 0; i < srcSize; ++i) { pDest[i] = pSrc[srcSize - 1 - i]; @@ -990,13 +1028,13 @@ set_object(radio_param_t param, const void *src, size_t size) switch(param) { /* 64-bit address */ case RADIO_PARAM_64BIT_ADDR: { - const size_t destSize = sizeof(cmd_rx.localExtAddr); + const size_t destSize = sizeof(v_cmd_rx.localExtAddr); if(size != destSize) { return RADIO_RESULT_INVALID_VALUE; } const uint8_t *pSrc = (const uint8_t *)src; - volatile uint8_t *pDest = (uint8_t *)&(cmd_rx.localExtAddr); + volatile uint8_t *pDest = (uint8_t *)&(v_cmd_rx.localExtAddr); for(size_t i = 0; i < destSize; ++i) { pDest[i] = pSrc[destSize - 1 - i]; } diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf/prop-mode.c b/arch/cpu/simplelink-cc13xx-cc26xx/rf/prop-mode.c index eae5c53b85f71052caae68f802cd5f17cc798032..7192616332e675067fb2ecb4bc3fbbecb5bb90ec 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf/prop-mode.c +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf/prop-mode.c @@ -98,7 +98,9 @@ typedef enum { /*---------------------------------------------------------------------------*/ /* Defines and variables related to the .15.4g PHY HDR */ #define DOT_4G_MAX_FRAME_LEN 2047 -#define DOT_4G_PHR_LEN 2 +#define DOT_4G_PHR_NUM_BYTES 2 +#define DOT_4G_LEN_OFFSET 0xFC +#define DOT_4G_SYNCWORD 0x0055904E /* PHY HDR bits */ #define DOT_4G_PHR_CRC16 0x10 @@ -120,6 +122,24 @@ typedef enum { #define DOT_4G_PHR_DW_BIT 0 #endif /*---------------------------------------------------------------------------*/ +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the CRC. + * + * Unlike typical 2.4GHz radio drivers, this driver supports the .15.4g + * 32-bit CRC option. + * + * This radio hardware is perfectly happy to transmit frames longer than 127 + * bytes, which is why it's OK to end up transmitting 125 payload bytes plus + * a 4-byte CRC. + * + * In the future we can change this to support transmission of long frames, + * for example as per .15.4g. the size of the TX and RX buffers would need + * adjusted accordingly. + */ +#define MAX_PAYLOAD_LEN 125 +/*---------------------------------------------------------------------------*/ /* How long to wait for the RF to enter RX in rf_cmd_ieee_rx */ #define TIMEOUT_ENTER_RX_WAIT (RTIMER_SECOND >> 10) @@ -170,22 +190,28 @@ typedef struct { static prop_radio_t prop_radio; /*---------------------------------------------------------------------------*/ +/* Convenience macros for more succinct access of RF commands */ +#define cmd_radio_setup rf_cmd_prop_radio_div_setup +#define cmd_fs rf_cmd_prop_fs +#define cmd_tx rf_cmd_prop_tx_adv +#define cmd_rx rf_cmd_prop_rx_adv + /* Convenience macros for volatile access with the RF commands */ -#define cmd_radio_setup (*(volatile rfc_CMD_PROP_RADIO_DIV_SETUP_t *)&rf_cmd_prop_radio_div_setup) -#define cmd_fs (*(volatile rfc_CMD_FS_t *) &rf_cmd_prop_fs) -#define cmd_tx (*(volatile rfc_CMD_PROP_TX_ADV_t *) &rf_cmd_prop_tx_adv) -#define cmd_rx (*(volatile rfc_CMD_PROP_RX_ADV_t *) &rf_cmd_prop_rx_adv) +#define v_cmd_radio_setup CC_ACCESS_NOW(rfc_CMD_PROP_RADIO_DIV_SETUP_t, rf_cmd_prop_radio_div_setup) +#define v_cmd_fs CC_ACCESS_NOW(rfc_CMD_FS_t, rf_cmd_prop_fs) +#define v_cmd_tx CC_ACCESS_NOW(rfc_CMD_PROP_TX_ADV_t, rf_cmd_prop_tx_adv) +#define v_cmd_rx CC_ACCESS_NOW(rfc_CMD_PROP_RX_ADV_t, rf_cmd_prop_rx_adv) /*---------------------------------------------------------------------------*/ static inline bool tx_is_active(void) { - return cmd_tx.status == ACTIVE; + return v_cmd_tx.status == ACTIVE; } /*---------------------------------------------------------------------------*/ static inline bool rx_is_active(void) { - return cmd_rx.status == ACTIVE; + return v_cmd_rx.status == ACTIVE; } /*---------------------------------------------------------------------------*/ static int on(void); @@ -199,10 +225,15 @@ init_rf_params(void) cmd_radio_setup.centerFreq = PROP_MODE_CENTER_FREQ; cmd_radio_setup.loDivider = PROP_MODE_LO_DIVIDER; - data_queue_t *data_queue = data_queue_init(sizeof(lensz_t)); + cmd_tx.numHdrBits = DOT_4G_PHR_NUM_BYTES * 8; + cmd_tx.syncWord = DOT_4G_SYNCWORD; - cmd_rx.maxPktLen = DOT_4G_MAX_FRAME_LEN - cmd_rx.lenOffset; - cmd_rx.pQueue = data_queue; + cmd_rx.syncWord0 = DOT_4G_SYNCWORD; + cmd_rx.syncWord1 = 0x00000000; + cmd_rx.maxPktLen = DOT_4G_MAX_FRAME_LEN - DOT_4G_LEN_OFFSET; + cmd_rx.hdrConf.numHdrBits = DOT_4G_PHR_NUM_BYTES * 8; + cmd_rx.lenOffset = DOT_4G_LEN_OFFSET; + cmd_rx.pQueue = data_queue_init(sizeof(lensz_t)); cmd_rx.pOutput = (uint8_t *)&prop_radio.rx_stats; } /*---------------------------------------------------------------------------*/ @@ -216,7 +247,7 @@ get_rssi(void) /* RX is required to be running in order to do a RSSI measurement */ if(!rx_is_active()) { /* If RX is not pending, i.e. soon to be running, schedule the RX command */ - if(cmd_rx.status != PENDING) { + if(v_cmd_rx.status != PENDING) { res = netstack_sched_rx(false); if(res != RF_RESULT_OK) { LOG_ERR("RSSI measurement failed to schedule RX\n"); @@ -231,7 +262,7 @@ get_rssi(void) RTIMER_BUSYWAIT_UNTIL(!rx_is_active(), TIMEOUT_ENTER_RX_WAIT); if(!rx_is_active()) { - LOG_ERR("RSSI measurement failed to turn on RX, RX status=0x%04X\n", cmd_rx.status); + LOG_ERR("RSSI measurement failed to turn on RX, RX status=0x%04X\n", v_cmd_rx.status); return RF_RESULT_ERROR; } } @@ -249,7 +280,7 @@ get_rssi(void) static uint8_t get_channel(void) { - uint32_t freq_khz = cmd_fs.frequency * 1000; + uint32_t freq_khz = v_cmd_fs.frequency * 1000; /* * For some channels, fractFreq * 1000 / 65536 will return 324.99xx. @@ -257,7 +288,7 @@ get_channel(void) * function returning channel - 1 instead of channel. Thus, we do a quick * positive integer round up. */ - freq_khz += (((cmd_fs.fractFreq * 1000) + 65535) / 65536); + freq_khz += (((v_cmd_fs.fractFreq * 1000) + 65535) / 65536); return (uint8_t)((freq_khz - DOT_15_4G_CHAN0_FREQ) / DOT_15_4G_FREQ_SPACING); } @@ -285,8 +316,8 @@ set_channel(uint16_t channel) LOG_DBG("Set channel to %d, frequency 0x%04X.0x%04X (%lu)\n", (int)channel, freq, frac, new_freq); - cmd_fs.frequency = freq; - cmd_fs.fractFreq = frac; + v_cmd_fs.frequency = freq; + v_cmd_fs.fractFreq = frac; res = netstack_sched_fs(); @@ -320,7 +351,7 @@ calculate_lqi(int8_t rssi) static int prepare(const void *payload, unsigned short payload_len) { - if(payload_len > TX_BUF_PAYLOAD_LEN || payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > TX_BUF_PAYLOAD_LEN || payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } @@ -333,7 +364,7 @@ transmit(unsigned short transmit_len) { rf_result_t res; - if(transmit_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(transmit_len > MAX_PAYLOAD_LEN) { LOG_ERR("Too long\n"); return RADIO_TX_ERR; } @@ -358,8 +389,8 @@ transmit(unsigned short transmit_len) /* pktLen: Total number of bytes in the TX buffer, including the header if * one exists, but not including the CRC (which is not present in the buffer) */ - cmd_tx.pktLen = transmit_len + DOT_4G_PHR_LEN; - cmd_tx.pPkt = prop_radio.tx_buf; + v_cmd_tx.pktLen = transmit_len + DOT_4G_PHR_NUM_BYTES; + v_cmd_tx.pPkt = prop_radio.tx_buf; res = netstack_sched_prop_tx(); @@ -607,6 +638,10 @@ get_value(radio_param_t param, radio_value_t *value) *value = (radio_value_t)tx_power_max(rf_tx_power_table, rf_tx_power_table_size); return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; + default: return RADIO_RESULT_NOT_SUPPORTED; } @@ -673,6 +708,10 @@ set_object(radio_param_t param, const void *src, size_t size) static int init(void) { + RF_Params rf_params; + RF_TxPowerTable_Value tx_power_value; + RF_Stat rf_stat; + if(prop_radio.rf_handle) { LOG_WARN("Radio is already initialized\n"); return RF_RESULT_OK; @@ -687,7 +726,6 @@ init(void) init_rf_params(); /* Init RF params and specify non-default params */ - RF_Params rf_params; RF_Params_init(&rf_params); rf_params.nInactivityTimeout = RF_CONF_INACTIVITY_TIMEOUT; @@ -701,6 +739,18 @@ init(void) set_channel(IEEE802154_DEFAULT_CHANNEL); + tx_power_value = RF_TxPowerTable_findValue(rf_tx_power_table, RF_TXPOWER_DBM); + if(tx_power_value.rawValue != RF_TxPowerTable_INVALID_VALUE) { + rf_stat = RF_setTxPower(prop_radio.rf_handle, tx_power_value); + if(rf_stat == RF_StatSuccess) { + LOG_INFO("TX power configured to %d dBm\n", RF_TXPOWER_DBM); + } else { + LOG_WARN("Setting TX power to %d dBm failed, stat=0x%02X", RF_TXPOWER_DBM, rf_stat); + } + } else { + LOG_WARN("Unable to find TX power %d dBm in the TX power table\n", RF_TXPOWER_DBM); + } + ENERGEST_ON(ENERGEST_TYPE_LISTEN); /* Start RF process */ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf/rf.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf/rf.h index 65b2b1543517cd44706d92e580765ce36d323a5b..697105529d43363bd618454f4c41731bd2ea7ea1 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf/rf.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf/rf.h @@ -44,6 +44,18 @@ #ifndef RF_CORE_H_ #define RF_CORE_H_ /*---------------------------------------------------------------------------*/ +#include <ti/drivers/rf/RF.h> +/*---------------------------------------------------------------------------*/ +/* + * \name Abstract values to specify either the minimum or the maximum + * available TX power setting in dBm. + * + * @{ + */ +#define RF_TXPOWER_MIN_DBM RF_TxPowerTable_MIN_DBM +#define RF_TXPOWER_MAX_DBM RF_TxPowerTable_MAX_DBM +/** @} */ +/*---------------------------------------------------------------------------*/ /** * \name Different modes the RF can operate on, denoted by which frequency * band said mode operates on. Currently supports the following modes: diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf/settings.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf/settings.h index 1d20fce91e1e1376e64dd605e71a01375d4de78d..a28042f56c99440f17865cb44aa14540b271ce06 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf/settings.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf/settings.h @@ -95,9 +95,9 @@ #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2) #define ble_mode rf_ble_mode -#define ble_cmd_radio_setup rf_ble_cmd_radio_setup +#define ble_cmd_radio_setup rf_ble_cmd_ble5_radio_setup #define ble_adv_par rf_ble_adv_par -#define ble_cmd_adv_nc rf_ble_cmd_ble_adv_nc +#define ble_cmd_adv_nc rf_ble_cmd_ble5_adv_nc #endif /* DeviceFamily_PARENT */ diff --git a/arch/cpu/simplelink-cc13xx-cc26xx/rf/tx-power.h b/arch/cpu/simplelink-cc13xx-cc26xx/rf/tx-power.h index 91bab7d6bc4bab2d3d936ebb8fbf4617c07a69f8..198da347a4b51eec46cdc6c84884fc32a23abbb4 100644 --- a/arch/cpu/simplelink-cc13xx-cc26xx/rf/tx-power.h +++ b/arch/cpu/simplelink-cc13xx-cc26xx/rf/tx-power.h @@ -52,7 +52,8 @@ #include <stddef.h> #include <stdbool.h> /*---------------------------------------------------------------------------*/ -#define RF_TXPOWER_HIGH_PA RF_CONF_TXPOWER_HIGH_PA +#define RF_TXPOWER_DBM RF_CONF_TXPOWER_DBM +#define RF_BLE_TXPOWER_DBM RF_CONF_BLE_TXPOWER_DBM #define RF_TXPOWER_BOOST_MODE RF_CONF_TXPOWER_BOOST_MODE /*---------------------------------------------------------------------------*/ typedef RF_TxPowerTable_Entry tx_power_table_t; diff --git a/arch/dev/cc1200/cc1200-conf.h b/arch/dev/cc1200/cc1200-conf.h index 646fb04ba9abf6fae7a247122ff6665a0e1614ae..bca5a0f78b00b0c836803e44576f5b1259352416 100644 --- a/arch/dev/cc1200/cc1200-conf.h +++ b/arch/dev/cc1200/cc1200-conf.h @@ -72,8 +72,6 @@ #else #define CC1200_MAX_PAYLOAD_LEN 125 #endif - -#define cc1200_driver_max_payload_len CC1200_MAX_PAYLOAD_LEN /*---------------------------------------------------------------------------*/ /* * The RX watchdog is used to check whether the radio is in RX mode at regular diff --git a/arch/dev/cc1200/cc1200.c b/arch/dev/cc1200/cc1200.c index 50babb93d29818a909e7442f97f32ee7c44e1f9a..f350b6b7d599e40a18c9cc82861a7b5f0451c6fa 100644 --- a/arch/dev/cc1200/cc1200.c +++ b/arch/dev/cc1200/cc1200.c @@ -1334,6 +1334,10 @@ get_value(radio_param_t param, radio_value_t *value) *value = (radio_value_t)CC1200_RF_CFG.delay_before_detect; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)CC1200_MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; + default: return RADIO_RESULT_NOT_SUPPORTED; diff --git a/arch/dev/cc2420/cc2420.c b/arch/dev/cc2420/cc2420.c index d462a15314aeef08b63ffdc3ad550f278f0728e2..1b6c46af0caf66cbe9fd97aa1e8b0a1645258515 100644 --- a/arch/dev/cc2420/cc2420.c +++ b/arch/dev/cc2420/cc2420.c @@ -103,6 +103,13 @@ volatile uint16_t cc2420_sfd_start_time; volatile uint16_t cc2420_sfd_end_time; static volatile uint16_t last_packet_timestamp; + +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the FCS. + */ +#define MAX_PAYLOAD_LEN (127 - CHECKSUM_LEN) /*---------------------------------------------------------------------------*/ PROCESS(cc2420_process, "CC2420 driver"); /*---------------------------------------------------------------------------*/ @@ -224,6 +231,9 @@ get_value(radio_param_t param, radio_value_t *value) case RADIO_CONST_TXPOWER_MAX: *value = OUTPUT_POWER_MAX; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } @@ -666,7 +676,7 @@ cc2420_transmit(unsigned short payload_len) { int i; - if(payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } @@ -736,7 +746,7 @@ cc2420_prepare(const void *payload, unsigned short payload_len) { uint8_t total_len; - if(payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } diff --git a/arch/platform/cc2538dk/Makefile.cc2538dk b/arch/platform/cc2538dk/Makefile.cc2538dk index bdbc7598f95919c4c99ebeae6a04fa01242e72c1..7aa6c9a5a84b779b8c87708a1642b84637fb3b18 100644 --- a/arch/platform/cc2538dk/Makefile.cc2538dk +++ b/arch/platform/cc2538dk/Makefile.cc2538dk @@ -14,10 +14,10 @@ CONTIKI_TARGET_SOURCEFILES += board-buttons.c als-sensor.c CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) ### Define the CPU directory -CONTIKI_CPU=$(ARCH_PATH)/cpu/cc2538 +CONTIKI_CPU = $(CONTIKI_NG_RELOC_CPU_DIR)/cc2538 include $(CONTIKI_CPU)/Makefile.cc2538 -MODULES += os/storage/cfs +MODULES += $(CONTIKI_NG_STORAGE_DIR)/cfs PYTHON = python BSL_FLAGS += -e -w -v @@ -26,7 +26,7 @@ ifdef PORT BSL_FLAGS += -p $(PORT) endif -BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py +BSL = $(CONTIKI_NG_TOOLS_DIR)/cc2538-bsl/cc2538-bsl.py %.upload: $(OUT_BIN) $(OUT_ELF) ifeq ($(wildcard $(BSL)), ) diff --git a/arch/platform/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 b/arch/platform/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 index 622445dd448a5ff19960763900f915b91c220924..340540e3f9ca11f9f2409b49369b287429bafc90 100644 --- a/arch/platform/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 +++ b/arch/platform/cc26x0-cc13x0/Makefile.cc26x0-cc13x0 @@ -11,7 +11,7 @@ BOARDS = srf06/cc26x0 srf06/cc13x0 launchpad/cc2640r2 launchpad/cc2650 launchpad CONTIKI_TARGET_DIRS += . ### Include the board-specific makefile -PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET) +PLATFORM_ROOT_DIR = $(CONTIKI_NG_RELOC_PLATFORM_DIR)/$(TARGET) -include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(notdir $(BOARD)) CONTIKI_TARGET_SOURCEFILES += platform.c leds-arch.c @@ -24,6 +24,6 @@ SMALL ?= 0 ### Define the CPU directory and pull in the correct CPU makefile. This will ### be defined by one of the makefiles included above and it can be either -### Makefile.cc26xx or Makefile.cc13xx -CONTIKI_CPU=$(ARCH_PATH)/cpu/cc26x0-cc13x0 +### Makefile.cc26x0 or Makefile.cc13x0 +CONTIKI_CPU = $(CONTIKI_NG_RELOC_CPU_DIR)/cc26x0-cc13x0 include $(CONTIKI_CPU)/Makefile.$(CPU_FAMILY) diff --git a/arch/platform/cooja/Makefile.cooja b/arch/platform/cooja/Makefile.cooja index 023fe3d9a3674ab173777c0f7a0ab5bf63a3c824..3c6c616d63df983ed4cbe6738bbe45854b687571 100644 --- a/arch/platform/cooja/Makefile.cooja +++ b/arch/platform/cooja/Makefile.cooja @@ -11,6 +11,8 @@ ifndef CONTIKI $(error CONTIKI not defined!) endif +COOJA_DIR = $(CONTIKI_NG_TOOLS_DIR)/cooja + ### Assuming simulator quickstart if no JNI library name set from Cooja ifndef LIBNAME QUICKSTART=1 @@ -20,15 +22,15 @@ endif ifdef QUICKSTART # Create COOJA JAR rule -$(CONTIKI)/tools/cooja/dist/cooja.jar: +$(COOJA_DIR)/dist/cooja.jar: @echo "Creating COOJA Java archive..." - (cd $(CONTIKI)/tools/cooja && ant jar) + (cd $(COOJA_DIR) && ant jar) # Quickstart rule ifneq ($(MAKECMDGOALS),clean) .PHONY: $(MAKECMDGOALS) .PRECIOUS: $(MAKECMDGOALS) -$(MAKECMDGOALS): $(CONTIKI)/tools/cooja/dist/cooja.jar +$(MAKECMDGOALS): $(COOJA_DIR)/dist/cooja.jar java -mx512m -jar $< -quickstart='$(firstword $(MAKECMDGOALS))' -contiki='$(CONTIKI)' endif @@ -41,7 +43,6 @@ JNILIB = $(BUILD_DIR_BOARD)/$(LIBNAME).$(TARGET) CONTIKI_APP_OBJ = $(CONTIKI_APP).o ### COOJA platform sources -COOJA = $(ARCH_PATH)/platform/$(TARGET) CONTIKI_TARGET_DIRS = . dev lib sys cfs net # (COOJA_SOURCEDIRS contains additional sources dirs set from simulator) @@ -49,12 +50,12 @@ vpath %.c $(COOJA_SOURCEDIRS) COOJA_BASE = simEnvChange.c cooja_mt.c cooja_mtarch.c rtimer-arch.c slip.c watchdog.c int-master.c -COOJA_INTFS = beep.c button-sensor.c ip.c leds-arch.c moteid.c \ +COOJA_INTFS = beep.c ip.c leds-arch.c moteid.c \ pir-sensor.c rs232.c vib-sensor.c \ clock.c cooja-log.c cfs-cooja.c cooja-radio.c \ eeprom.c slip-arch.c -COOJA_CORE = random.c sensors.c leds.c +COOJA_CORE = random.c sensors.c leds.c gpio-hal-arch.c buttons.c # (COOJA_SOURCEFILES contains additional sources set from simulator) CONTIKI_TARGET_SOURCEFILES = \ @@ -66,9 +67,6 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) CLEAN += COOJA.log -### Define the CPU directory -CONTIKI_CPU=$(ARCH_PATH)/cpu/x86 - ### Compiler arguments #CC = gcc CFLAGSNO = $(EXTRA_CC_ARGS) -Wall -g -I/usr/local/include -DCLASSNAME=$(CLASSNAME) diff --git a/arch/platform/cooja/contiki-conf.h b/arch/platform/cooja/contiki-conf.h index ce5bc6b4c0305d33b947de4630bc631970fa41e9..10ee534f3cbeefabea25808b52c47152aaccc50c 100644 --- a/arch/platform/cooja/contiki-conf.h +++ b/arch/platform/cooja/contiki-conf.h @@ -48,7 +48,7 @@ #define COOJA 1 -#define LEDS_CONF_LEGACY_API 1 +#define ASSERT_CONF_RETURNS 1 #ifndef EEPROM_CONF_SIZE #define EEPROM_CONF_SIZE 1024 @@ -75,8 +75,6 @@ /* Radio setup */ #define NETSTACK_CONF_RADIO cooja_radio_driver -#define cooja_radio_driver_max_payload_len 125 - /* Default network config */ #if NETSTACK_CONF_WITH_IPV6 @@ -143,4 +141,27 @@ typedef unsigned long clock_time_t; #define PLATFORM_CONF_SUPPORTS_STACK_CHECK 0 +/*---------------------------------------------------------------------------*/ +/* Support for the new GPIO HAL */ +#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h" +#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 1 +#define GPIO_HAL_CONF_PORT_PIN_NUMBERING 0 +#define GPIO_HAL_CONF_PIN_COUNT 4 + +/* Virtual LED pins 0, 1, 2 (Green, Red, Yellow) */ +#define COOJA_LED_GREEN_PIN 0 +#define COOJA_LED_RED_PIN 1 +#define COOJA_LED_YELLOW_PIN 2 + +/* Virtual button on pin 3 */ +#define COOJA_BTN_PIN 3 + +#define BUTTON_HAL_CONF_DEBOUNCE_DURATION 0 +/*---------------------------------------------------------------------------*/ +/* Virtual LED colors */ +#define LEDS_CONF_COUNT 3 +#define LEDS_CONF_GREEEN 1 +#define LEDS_CONF_RED 2 +#define LEDS_CONF_YELLOW 4 +/*---------------------------------------------------------------------------*/ #endif /* CONTIKI_CONF_H_ */ diff --git a/arch/platform/cooja/dev/button-sensor.c b/arch/platform/cooja/dev/button-sensor.c deleted file mode 100644 index 90f2dd26cdf6b98c4b3eeb80e0f3491ef346d0c6..0000000000000000000000000000000000000000 --- a/arch/platform/cooja/dev/button-sensor.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * 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 Institute 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 INSTITUTE 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 INSTITUTE 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 "lib/sensors.h" -#include "dev/button-sensor.h" -#include "lib/simEnvChange.h" - -const struct simInterface button_interface; -const struct sensors_sensor button_sensor; -static struct timer debouncetimer; - -// COOJA variables -char simButtonChanged; -char simButtonIsDown; -char simButtonIsActive; -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return simButtonIsDown || !timer_expired(&debouncetimer); -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - if(type == SENSORS_ACTIVE) { - simButtonIsActive = c; - return 1; - } else if(type == SENSORS_HW_INIT) { - simButtonIsActive = 1; - timer_set(&debouncetimer, 0); - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - return (type == SENSORS_ACTIVE) ? simButtonIsActive : 0; -} -/*---------------------------------------------------------------------------*/ -static void -doInterfaceActionsBeforeTick(void) -{ - // Check if button value has changed - if(simButtonChanged && simButtonIsActive && simButtonIsDown) { - if(timer_expired(&debouncetimer)) { - timer_set(&debouncetimer, CLOCK_SECOND / 10); - sensors_changed(&button_sensor); - } - } - simButtonChanged = 0; -} -/*---------------------------------------------------------------------------*/ -static void -doInterfaceActionsAfterTick(void) -{ -} -/*---------------------------------------------------------------------------*/ - -SIM_INTERFACE(button_interface, - doInterfaceActionsBeforeTick, - doInterfaceActionsAfterTick); - -SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, - value, configure, status); diff --git a/arch/platform/cooja/dev/button-sensor.h b/arch/platform/cooja/dev/button-sensor.h deleted file mode 100644 index 1f1fb0fbc49a5a2d94851d5f226de0ff0533fd7d..0000000000000000000000000000000000000000 --- a/arch/platform/cooja/dev/button-sensor.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * 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 Institute 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 INSTITUTE 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 INSTITUTE 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 BUTTON_SENSOR_H_ -#define BUTTON_SENSOR_H_ - -#include "lib/sensors.h" - -extern const struct sensors_sensor button_sensor; - -#define BUTTON_SENSOR "Button" - -#endif /* BUTTON_SENSOR_H_ */ diff --git a/arch/platform/cooja/dev/buttons.c b/arch/platform/cooja/dev/buttons.c new file mode 100644 index 0000000000000000000000000000000000000000..b309e26fbcc2517e534f8ded495414881139129f --- /dev/null +++ b/arch/platform/cooja/dev/buttons.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2019, George Oikonomou - http://www.spd.gr + * 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 "contiki.h" +#include "dev/button-hal.h" +#include "lib/simEnvChange.h" + +#include <stdint.h> +#include <string.h> +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "Cooja Button" +#define LOG_LEVEL LOG_LEVEL_NONE +/*---------------------------------------------------------------------------*/ +/* Variables required by the Cooja button interface */ +char simButtonChanged; +char simButtonIsDown; +char simButtonIsActive = 1; +const struct simInterface button_interface; +/*---------------------------------------------------------------------------*/ +/* The cooja virtual button on pin COOJA_BTN_PIN, active low */ +BUTTON_HAL_BUTTON(button_user, "User button", COOJA_BTN_PIN, + GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_ZERO, true); +/*---------------------------------------------------------------------------*/ +BUTTON_HAL_BUTTONS(&button_user); +/*---------------------------------------------------------------------------*/ +static void +doInterfaceActionsBeforeTick(void) +{ + if(simButtonChanged) { + LOG_DBG("Cooja button changed. simButtonIsDown=%u, ", simButtonIsDown); + /* + * First check what the simulator wants us to do: press or release. Based + * on that, set the correct state for COOJA_BTN_PIN. + */ + if(simButtonIsDown) { + /* The button is active low, so clear the pin when pressed */ + LOG_DBG_("clearing pin"); + gpio_hal_arch_no_port_clear_pin(COOJA_BTN_PIN); + } else { + LOG_DBG_("setting pin"); + gpio_hal_arch_no_port_set_pin(COOJA_BTN_PIN); + } + + /* + * Subsequently, simply raise a virtual edge event on the pin, but only if + * the interrupt is "enabled" + */ + if(gpio_hal_arch_no_port_pin_cfg_get(COOJA_BTN_PIN) & GPIO_HAL_PIN_CFG_INT_ENABLE) { + LOG_DBG_(", triggering edge event"); + gpio_hal_event_handler(gpio_hal_pin_to_mask(COOJA_BTN_PIN)); + } + LOG_DBG_("\n"); + } + + simButtonChanged = 0; +} +/*---------------------------------------------------------------------------*/ +static void +doInterfaceActionsAfterTick(void) +{ +} +/*---------------------------------------------------------------------------*/ +SIM_INTERFACE(button_interface, + doInterfaceActionsBeforeTick, + doInterfaceActionsAfterTick); +/*---------------------------------------------------------------------------*/ +/* + * Everything below needed to satisfy Cooja build dependency, which can be + * removed when we change Cooja to no longer expect a button_sensor symbol + */ +#include "lib/sensors.h" +#include "dev/button-sensor.h" +/*---------------------------------------------------------------------------*/ +static int +value(int type) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +configure(int type, int c) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +status(int type) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, value, configure, status); diff --git a/arch/platform/cooja/dev/cooja-radio.c b/arch/platform/cooja/dev/cooja-radio.c index f6daec31689235c88fbb9b96f02a4ade337dc40f..6468b7e049fdb3cd617f9d0d1fc01fe4339bb536 100644 --- a/arch/platform/cooja/dev/cooja-radio.c +++ b/arch/platform/cooja/dev/cooja-radio.c @@ -42,7 +42,17 @@ #include "dev/radio.h" #include "dev/cooja-radio.h" -#define COOJA_RADIO_BUFSIZE cooja_radio_driver_max_payload_len +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the FCS. + */ +#ifdef COOJA_RADIO_CONF_BUFSIZE +#define COOJA_RADIO_BUFSIZE COOJA_RADIO_CONF_BUFSIZE +#else +#define COOJA_RADIO_BUFSIZE 125 +#endif + #define CCA_SS_THRESHOLD -95 const struct simInterface radio_interface; @@ -337,6 +347,9 @@ get_value(radio_param_t param, radio_value_t *value) /* return a fixed value depending on the channel */ *value = -90 + simRadioChannel - 11; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)COOJA_RADIO_BUFSIZE; + return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } diff --git a/arch/platform/cooja/dev/gpio-hal-arch.c b/arch/platform/cooja/dev/gpio-hal-arch.c new file mode 100644 index 0000000000000000000000000000000000000000..2c77bede8dfefeea694386c91273cc30ff39c4d4 --- /dev/null +++ b/arch/platform/cooja/dev/gpio-hal-arch.c @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2019, George Oikonomou - http://www.spd.gr + * 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 "contiki.h" +#include "dev/gpio-hal.h" + +#include <string.h> +#include <stdint.h> +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "GPIO arch" +#define LOG_LEVEL LOG_LEVEL_NONE +/*---------------------------------------------------------------------------*/ +static gpio_hal_pin_cfg_t pin_cfg[GPIO_HAL_PIN_COUNT]; +static uint8_t pin_state[GPIO_HAL_PIN_COUNT]; +/*---------------------------------------------------------------------------*/ +/* + * Callbacks used to notify other modules (e.g. leds_arch) that the state of + * a pin has changed. Mainly used for output pins, since input pins can always + * simply generate a virtual interrupt + */ +static void (*pin_callbacks[GPIO_HAL_PIN_COUNT])(void); +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_register_pin_callback(gpio_hal_pin_t pin, + gpio_hal_arch_pin_callback cb) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + return; + } + pin_callbacks[pin] = cb; +} +/*---------------------------------------------------------------------------*/ +static void +set_pin_state(gpio_hal_pin_t pin, uint8_t state) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + return; + } + pin_state[pin] = state; + + if(pin_callbacks[pin] != NULL) { + pin_callbacks[pin](); + } +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_init(void) +{ + memset(pin_cfg, 0, sizeof(pin_cfg)); + memset(pin_state, 0, sizeof(pin_state)); + memset(pin_callbacks, 0, sizeof(pin_callbacks)); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_interrupt_enable(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + pin_cfg[pin] |= GPIO_HAL_PIN_CFG_INT_ENABLE; + + LOG_DBG("Pin %u: Enabled interrupt\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_interrupt_disable(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + pin_cfg[pin] &= ~GPIO_HAL_PIN_CFG_INT_ENABLE; + + LOG_DBG("Pin %u: Disabled interrupt\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + pin_cfg[pin] = cfg; + LOG_DBG("Pin %u: Set config=0x%02x\n", pin, pin_cfg[pin]); +} +/*---------------------------------------------------------------------------*/ +gpio_hal_pin_cfg_t +gpio_hal_arch_no_port_pin_cfg_get(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return 0; + } + + LOG_DBG("Pin %u: Config=0x%02x\n", pin, pin_cfg[pin]); + return pin_cfg[pin]; +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_pin_set_input(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + LOG_DBG("Pin %u: Set input\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_pin_set_output(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return; + } + + LOG_DBG("Pin %u: Set output\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_set_pin(gpio_hal_pin_t pin) +{ + set_pin_state(pin, 1); + LOG_DBG("Pin %u: Set\n", pin); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_clear_pin(gpio_hal_pin_t pin) +{ + set_pin_state(pin, 0); + LOG_DBG("Pin %u: Clear\n", pin); +} +/*---------------------------------------------------------------------------*/ +uint8_t +gpio_hal_arch_no_port_read_pin(gpio_hal_pin_t pin) +{ + if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); + return 0; + } + + LOG_DBG("Pin %u: Read=%u\n", pin, pin_state[pin]); + return pin_state[pin]; +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_write_pin(gpio_hal_pin_t pin, uint8_t value) +{ + set_pin_state(pin, value); + LOG_DBG("Pin %u: Write=%u\n", pin, pin_state[pin]); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_set_pins(gpio_hal_pin_mask_t pins) +{ + gpio_hal_pin_t pin; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + if(pins & (1 << pin)) { + set_pin_state(pin, 1); + } + } + + LOG_DBG("Set pins 0x%08" PRIx32 "\n", pins); +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_clear_pins(gpio_hal_pin_mask_t pins) +{ + gpio_hal_pin_t pin; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + if(pins & (1 << pin)) { + set_pin_state(pin, 0); + } + } + + LOG_DBG("Clear pins 0x%08" PRIx32 "\n", pins); +} +/*---------------------------------------------------------------------------*/ +gpio_hal_pin_mask_t +gpio_hal_arch_no_port_read_pins(gpio_hal_pin_mask_t pins) +{ + gpio_hal_pin_t pin; + gpio_hal_pin_mask_t state = 0; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + state |= (pin_state[pin] << pin); + } + + LOG_DBG("Read pins 0x%08" PRIx32 "\n", state); + return state; +} +/*---------------------------------------------------------------------------*/ +void +gpio_hal_arch_no_port_write_pins(gpio_hal_pin_mask_t pins, + gpio_hal_pin_mask_t value) +{ + gpio_hal_pin_t pin; + + for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) { + if(pins & (1 << pin)) { + set_pin_state(pin, (value & (1 << pin)) == 0 ? 0 : 1); + } + } + + LOG_DBG("Write pins 0x%08" PRIx32 "->0x%08" PRIx32 "\n", pins, value); +} +/*---------------------------------------------------------------------------*/ diff --git a/arch/platform/cooja/dev/gpio-hal-arch.h b/arch/platform/cooja/dev/gpio-hal-arch.h new file mode 100644 index 0000000000000000000000000000000000000000..ae88aed1f31ba8c3d5be79bddc3d57ddc68e037b --- /dev/null +++ b/arch/platform/cooja/dev/gpio-hal-arch.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019, George Oikonomou - http://www.spd.gr + * 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 GPIO_HAL_ARCH_H_ +#define GPIO_HAL_ARCH_H_ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" + +#include <stdint.h> +/*---------------------------------------------------------------------------*/ +typedef void (*gpio_hal_arch_pin_callback)(void); + +void gpio_hal_arch_register_pin_callback(gpio_hal_pin_t pin, + gpio_hal_arch_pin_callback cb); +/*---------------------------------------------------------------------------*/ +#endif /* GPIO_HAL_ARCH_H_ */ +/*---------------------------------------------------------------------------*/ diff --git a/arch/platform/cooja/dev/leds-arch.c b/arch/platform/cooja/dev/leds-arch.c index b65df294567e019b8bacf07b649446632e67bc94..307b7f0dd7b128cf70a8fc5dabc10ddad58d80b2 100644 --- a/arch/platform/cooja/dev/leds-arch.c +++ b/arch/platform/cooja/dev/leds-arch.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2006, Swedish Institute of Computer Science. + * Copyright (c) 2019, George Oikonomou - http://www.spd.gr * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,28 +28,26 @@ * SUCH DAMAGE. * */ - +/*-----------------------------------------------------------------------------------*/ #include "dev/leds.h" #include "lib/simEnvChange.h" - -const struct simInterface leds_interface; - -// COOJA variables -leds_mask_t simLedsValue; - /*-----------------------------------------------------------------------------------*/ -void leds_arch_init() { - simLedsValue = 0; -} +/* Variables required by the Cooja button interface */ +leds_mask_t simLedsValue = 0; +const struct simInterface leds_interface; /*-----------------------------------------------------------------------------------*/ -leds_mask_t leds_arch_get() { - return simLedsValue; +static void +led_change_cb(void) +{ + simLedsValue = leds_get(); } /*-----------------------------------------------------------------------------------*/ -void leds_arch_set(leds_mask_t leds) { - if(leds != simLedsValue) { - simLedsValue = leds; - } +void leds_arch_init() { + simLedsValue = 0; + + gpio_hal_arch_register_pin_callback(COOJA_LED_GREEN_PIN, led_change_cb); + gpio_hal_arch_register_pin_callback(COOJA_LED_RED_PIN, led_change_cb); + gpio_hal_arch_register_pin_callback(COOJA_LED_YELLOW_PIN, led_change_cb); } /*-----------------------------------------------------------------------------------*/ static void @@ -61,7 +60,22 @@ doInterfaceActionsAfterTick(void) { } /*-----------------------------------------------------------------------------------*/ - SIM_INTERFACE(leds_interface, - doInterfaceActionsBeforeTick, - doInterfaceActionsAfterTick); + doInterfaceActionsBeforeTick, + doInterfaceActionsAfterTick); +/*---------------------------------------------------------------------------*/ +const leds_t leds_arch_leds[] = { + { + .pin = COOJA_LED_GREEN_PIN, + .negative_logic = false + }, + { + .pin = COOJA_LED_RED_PIN, + .negative_logic = false + }, + { + .pin = COOJA_LED_YELLOW_PIN, + .negative_logic = false + }, +}; +/*---------------------------------------------------------------------------*/ diff --git a/arch/platform/cooja/platform.c b/arch/platform/cooja/platform.c index 591abe67ef26fa520521f820b5e172de51fa925c..de9583a1dbb4f8f24dfe789f68094eb77a39b967 100644 --- a/arch/platform/cooja/platform.c +++ b/arch/platform/cooja/platform.c @@ -65,6 +65,8 @@ #include "dev/pir-sensor.h" #include "dev/vib-sensor.h" #include "dev/moteid.h" +#include "dev/button-hal.h" +#include "dev/gpio-hal.h" #include "sys/node-id.h" #include "services/rpl-border-router/rpl-border-router.h" @@ -128,7 +130,9 @@ long referenceVar; */ static struct cooja_mt_thread rtimer_thread; static struct cooja_mt_thread process_run_thread; - +/*---------------------------------------------------------------------------*/ +/* Needed since the new LEDs API does not provide this prototype */ +void leds_arch_init(void); /*---------------------------------------------------------------------------*/ static void rtimer_thread_loop(void *data) @@ -166,6 +170,8 @@ set_lladdr(void) void platform_init_stage_one() { + gpio_hal_init(); + leds_arch_init(); return; } /*---------------------------------------------------------------------------*/ @@ -173,6 +179,7 @@ void platform_init_stage_two() { set_lladdr(); + button_hal_init(); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/platform/jn516x/Makefile.jn516x b/arch/platform/jn516x/Makefile.jn516x index 051c336fb4dfc591403c7074410e511ecf67f228..7ed9d16e3f73f0f80b41647943600bc739c823c0 100644 --- a/arch/platform/jn516x/Makefile.jn516x +++ b/arch/platform/jn516x/Makefile.jn516x @@ -21,13 +21,21 @@ DISABLE_LTO ?= 1 # can be set to SW or HW DEBUG ?= None +JN516X_TOOLS_DIR = $(CONTIKI_NG_TOOLS_DIR)/jn516x + ifeq ($(HOST_OS),Windows) SDK_BASE_DIR ?= C:/NXP/bstudio_nxp/sdk/JN-SW-4163 FLASH_PROGRAMMER ?= ${SDK_BASE_DIR}/Tools/flashprogrammer/FlashCLI.exe else # Assume Linux SDK_BASE_DIR ?= /usr/jn516x-sdk/JN-SW-4163 - FLASH_PROGRAMMER ?= $(CONTIKI)/tools/jn516x/JennicModuleProgrammer + FLASH_PROGRAMMER ?= $(JN516X_TOOLS_DIR)/JennicModuleProgrammer +endif + +ifeq (,$(wildcard $(SDK_BASE_DIR)/*)) + $(warning $(SDK_BASE_DIR) does not exist or is empty) + $(warning Review the value of SDK_BASE_DIR) + $(error Impossible to build for the jn516x platform) endif ############################################################################### diff --git a/arch/platform/jn516x/contiki-conf.h b/arch/platform/jn516x/contiki-conf.h index e161fd8537147fc34719ddfd61942f8b55bbf8d4..e4d741400e141e623e0726ee373576d50d177d9a 100644 --- a/arch/platform/jn516x/contiki-conf.h +++ b/arch/platform/jn516x/contiki-conf.h @@ -45,8 +45,6 @@ #define NETSTACK_CONF_RADIO micromac_radio_driver #endif /* NETSTACK_CONF_RADIO */ -#define micromac_radio_driver_max_payload_len 125 - /* Platform-specific (H/W) CCM* implementation */ #ifndef CCM_STAR_CONF #define CCM_STAR_CONF ccm_star_driver_jn516x diff --git a/arch/platform/jn516x/dev/micromac-radio.c b/arch/platform/jn516x/dev/micromac-radio.c index 5f22122d30bb74f9afdee545867a7c594d538bde..174c5a78bdecaea89c19675e5ba42046a8579230 100644 --- a/arch/platform/jn516x/dev/micromac-radio.c +++ b/arch/platform/jn516x/dev/micromac-radio.c @@ -81,6 +81,13 @@ #define CHECKSUM_LEN 2 +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * transmission or will deliver to the MAC layer after reception. Includes + * the MAC header and payload, but not the FCS. + */ +#define MAX_PAYLOAD_LEN (127 - CHECKSUM_LEN) + /* Max packet duration: 5 + 127 + 2 bytes, 32us per byte */ #define MAX_PACKET_DURATION US_TO_RTIMERTICKS((127 + 2) * 32 + RADIO_DELAY_BEFORE_TX) /* Max ACK duration: 5 + 3 + 2 bytes */ @@ -350,7 +357,7 @@ transmit(unsigned short payload_len) if(tx_in_progress) { return RADIO_TX_COLLISION; } - if(payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN) { + if(payload_len > MAX_PAYLOAD_LEN) { return RADIO_TX_ERR; } @@ -420,7 +427,7 @@ prepare(const void *payload, unsigned short payload_len) if(tx_in_progress) { return 1; } - if(payload_len > NETSTACK_RADIO_MAX_PAYLOAD_LEN || payload == NULL) { + if(payload_len > MAX_PAYLOAD_LEN || payload == NULL) { return 1; } #if MICROMAC_RADIO_MAC @@ -978,6 +985,9 @@ get_value(radio_param_t param, radio_value_t *value) case RADIO_CONST_TXPOWER_MAX: *value = OUTPUT_POWER_MAX; return RADIO_RESULT_OK; + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } diff --git a/arch/platform/native/Makefile.native b/arch/platform/native/Makefile.native index 51681284ecd8e091a40ce61f33143d9dcd51b2df..cd6613c3a8210c0830bbf39c708a409695387fdf 100644 --- a/arch/platform/native/Makefile.native +++ b/arch/platform/native/Makefile.native @@ -28,5 +28,5 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) MAKE_MAC ?= MAKE_MAC_NULLMAC ### Define the CPU directory -CONTIKI_CPU=$(ARCH_PATH)/cpu/native -include $(ARCH_PATH)/cpu/native/Makefile.native +CONTIKI_CPU = $(CONTIKI_NG_RELOC_CPU_DIR)/native +include $(CONTIKI_CPU)/Makefile.native diff --git a/arch/platform/native/contiki-conf.h b/arch/platform/native/contiki-conf.h index 15198d8cc0a49eee2c220a593f02251c7e27b374..e8177d7b2ef26ba86965345091d7de174c9eb05d 100644 --- a/arch/platform/native/contiki-conf.h +++ b/arch/platform/native/contiki-conf.h @@ -76,9 +76,6 @@ typedef unsigned int uip_stats_t; #define NETSTACK_CONF_RADIO nullradio_driver #endif /* NETSTACK_CONF_RADIO */ -/* for nullradio, allow unlimited packet size */ -#define nullradio_driver_max_payload_len ((unsigned short)-1) - #define NETSTACK_CONF_LINUXRADIO_DEV "wpan0" /* configure network size and density */ diff --git a/arch/platform/nrf52dk/Makefile.nrf52dk b/arch/platform/nrf52dk/Makefile.nrf52dk index ff554b35c9775761843c044865612ec1d68b2623..5968321406d49120a382032f952fd254d5060c53 100644 --- a/arch/platform/nrf52dk/Makefile.nrf52dk +++ b/arch/platform/nrf52dk/Makefile.nrf52dk @@ -3,7 +3,7 @@ ifndef CONTIKI endif ### Include the board-specific makefile -PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET) +PLATFORM_ROOT_DIR = $(CONTIKI_NG_RELOC_PLATFORM_DIR)/$(TARGET) CONTIKI_TARGET_DIRS += . dev config CONTIKI_SOURCEFILES += platform.c leds-arch.c nrf52dk-sensors.c button-sensor.c temperature-sensor.c @@ -21,5 +21,5 @@ endif SMALL ?= 0 ### Define the CPU directory and pull in the correct CPU makefile. -CONTIKI_CPU=$(ARCH_PATH)/cpu/nrf52832 +CONTIKI_CPU = $(CONTIKI_NG_RELOC_CPU_DIR)/nrf52832 include $(CONTIKI_CPU)/Makefile.nrf52832 diff --git a/arch/platform/openmote-cc2538/Makefile.openmote-cc2538 b/arch/platform/openmote/Makefile.openmote similarity index 66% rename from arch/platform/openmote-cc2538/Makefile.openmote-cc2538 rename to arch/platform/openmote/Makefile.openmote index f720a9ae8bae758e9e418859741eedcba0cbf525..0279e401a6062ae30930e6ca42bf630cb3fecec8 100644 --- a/arch/platform/openmote-cc2538/Makefile.openmote-cc2538 +++ b/arch/platform/openmote/Makefile.openmote @@ -1,17 +1,19 @@ -# openmote-cc2538 platform makefile - -### Allow the OpenMote-CC2538 platform to support different CC2538 chip revisions -ifeq ($(findstring REV_A1,$(BOARD_REVISION)),REV_A1) - CFLAGS+=-DCC2538_DEV_CONF=CC2538_DEV_CC2538SF23 -endif +# openmote platform makefile ifndef CONTIKI $(error CONTIKI not defined! You must specify where CONTIKI resides!) endif +### If no board is specified the default option is the openmote-cc2538 +BOARD ?= openmote-cc2538 +BOARDS = openmote-cc2538 openmote-b + ### Configure the build for the board and pull in board-specific sources -CONTIKI_TARGET_DIRS += . dev -PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET) +CONTIKI_TARGET_DIRS += . dev $(BOARD) +PLATFORM_ROOT_DIR = $(CONTIKI_NG_RELOC_PLATFORM_DIR)/$(TARGET) + +### Include the board dir if one exists +-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(BOARD) ### Include CONTIKI_TARGET_SOURCEFILES += platform.c board.c @@ -21,19 +23,19 @@ CONTIKI_TARGET_SOURCEFILES += antenna.c adxl346.c max44009.c sht21.c tps62730.c CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) ### Define the CPU directory -CONTIKI_CPU=$(ARCH_PATH)/cpu/cc2538 +CONTIKI_CPU=$(CONTIKI_NG_RELOC_CPU_DIR)/cc2538 include $(CONTIKI_CPU)/Makefile.cc2538 -MODULES += os/storage/cfs +MODULES += $(CONTIKI_NG_STORAGE_DIR)/cfs PYTHON = python -BSL_FLAGS += -e --bootloader-invert-lines -w -v -b 450000 +BSL_FLAGS += -e -w -v -b 450000 ifdef PORT BSL_FLAGS += -p $(PORT) endif -BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py +BSL = $(CONTIKI_NG_TOOLS_DIR)/cc2538-bsl/cc2538-bsl.py %.upload: $(OUT_BIN) $(OUT_ELF) ifeq ($(wildcard $(BSL)), ) diff --git a/arch/platform/openmote-cc2538/contiki-conf.h b/arch/platform/openmote/contiki-conf.h similarity index 89% rename from arch/platform/openmote-cc2538/contiki-conf.h rename to arch/platform/openmote/contiki-conf.h index daa20306581bb32ae83562b57140548859ac4945..aa90b700f2f2c8fbfb3af36fcf83c178661c264c 100644 --- a/arch/platform/openmote-cc2538/contiki-conf.h +++ b/arch/platform/openmote/contiki-conf.h @@ -31,19 +31,14 @@ */ /*---------------------------------------------------------------------------*/ /** - * \addtogroup openmote-cc2538 + * \addtogroup openmote-platform * @{ * - * \defgroup openmote-cc2538-platforms OpenMote-CC2538 platform - * - * The OpenMote-CC2538 platform was designed at UC Berkeley in 2013 and - * is comercialized by OpenMote Technologies since 2014. It is the first - * commercial platform based on the powerful TI CC2538 SoC. It uses a - * XBee form-factor to ease prototyping. + * \defgroup openmote-boards OpenMote boards * @{ * * \file - * Configuration for the OpenMote-CC2538 platform + * Configuration for the OpenMote platform */ #ifndef CONTIKI_CONF_H_ #define CONTIKI_CONF_H_ @@ -59,6 +54,19 @@ /*---------------------------------------------------------------------------*/ #include "cc2538-def.h" /*---------------------------------------------------------------------------*/ +/** + * \name CC2538 System Control configuration + * + * @{ + */ +#ifndef SYS_CTRL_CONF_OSC32K_USE_XTAL +#define SYS_CTRL_CONF_OSC32K_USE_XTAL 1 /**< Use the on-board 32.768-kHz crystal */ +#endif +/** @} */ +/*---------------------------------------------------------------------------*/ +/* board.h assumes that basic configuration is done */ +#include "board.h" +/*---------------------------------------------------------------------------*/ /** * \name Serial Boot Loader Backdoor configuration * @@ -77,19 +85,6 @@ #endif /** @} */ /*---------------------------------------------------------------------------*/ -/** - * \name CC2538 System Control configuration - * - * @{ - */ -#ifndef SYS_CTRL_CONF_OSC32K_USE_XTAL -#define SYS_CTRL_CONF_OSC32K_USE_XTAL 1 /**< Use the on-board 32.768-kHz crystal */ -#endif -/** @} */ -/*---------------------------------------------------------------------------*/ -/* board.h assumes that basic configuration is done */ -#include "board.h" -/*---------------------------------------------------------------------------*/ /* Include CPU-related configuration */ #include "cc2538-conf.h" /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/openmote-cc2538/dev/adxl346.c b/arch/platform/openmote/dev/adxl346.c similarity index 100% rename from arch/platform/openmote-cc2538/dev/adxl346.c rename to arch/platform/openmote/dev/adxl346.c diff --git a/arch/platform/openmote-cc2538/dev/adxl346.h b/arch/platform/openmote/dev/adxl346.h similarity index 100% rename from arch/platform/openmote-cc2538/dev/adxl346.h rename to arch/platform/openmote/dev/adxl346.h diff --git a/arch/platform/openmote-cc2538/dev/antenna.c b/arch/platform/openmote/dev/antenna.c similarity index 83% rename from arch/platform/openmote-cc2538/dev/antenna.c rename to arch/platform/openmote/dev/antenna.c index 4018ddeb3b19bcbd609342c5add357a5b0c53da1..ca0384f4bd1a0ea70b209d96f0d0ef7c1badc2c4 100644 --- a/arch/platform/openmote-cc2538/dev/antenna.c +++ b/arch/platform/openmote/dev/antenna.c @@ -48,16 +48,12 @@ #include "dev/gpio.h" #include "dev/antenna.h" /*---------------------------------------------------------------------------*/ -#define BSP_RADIO_BASE GPIO_PORT_TO_BASE(GPIO_D_NUM) -#define BSP_RADIO_INT GPIO_PIN_MASK(5) -#define BSP_RADIO_EXT GPIO_PIN_MASK(4) -/*---------------------------------------------------------------------------*/ void antenna_init(void) { /* Configure the ANT1 and ANT2 GPIO as output */ - GPIO_SET_OUTPUT(BSP_RADIO_BASE, BSP_RADIO_INT); - GPIO_SET_OUTPUT(BSP_RADIO_BASE, BSP_RADIO_EXT); + GPIO_SET_OUTPUT(ANTENNA_BSP_RADIO_BASE, ANTENNA_BSP_RADIO_INT); + GPIO_SET_OUTPUT(ANTENNA_BSP_RADIO_BASE, ANTENNA_BSP_RADIO_EXT); /* Select external antenna by default. */ antenna_external(); @@ -66,15 +62,15 @@ antenna_init(void) void antenna_external(void) { - GPIO_WRITE_PIN(BSP_RADIO_BASE, BSP_RADIO_INT, 0); - GPIO_WRITE_PIN(BSP_RADIO_BASE, BSP_RADIO_EXT, 1); + GPIO_WRITE_PIN(ANTENNA_BSP_RADIO_BASE, ANTENNA_BSP_RADIO_INT, 0); + GPIO_WRITE_PIN(ANTENNA_BSP_RADIO_BASE, ANTENNA_BSP_RADIO_EXT, 1); } /*---------------------------------------------------------------------------*/ void antenna_internal(void) { - GPIO_WRITE_PIN(BSP_RADIO_BASE, BSP_RADIO_EXT, 0); - GPIO_WRITE_PIN(BSP_RADIO_BASE, BSP_RADIO_INT, 1); + GPIO_WRITE_PIN(ANTENNA_BSP_RADIO_BASE, ANTENNA_BSP_RADIO_EXT, 0); + GPIO_WRITE_PIN(ANTENNA_BSP_RADIO_BASE, ANTENNA_BSP_RADIO_INT, 1); } /*---------------------------------------------------------------------------*/ /** diff --git a/arch/platform/openmote-cc2538/dev/antenna.h b/arch/platform/openmote/dev/antenna.h similarity index 100% rename from arch/platform/openmote-cc2538/dev/antenna.h rename to arch/platform/openmote/dev/antenna.h diff --git a/arch/platform/openmote-cc2538/dev/max44009.c b/arch/platform/openmote/dev/max44009.c similarity index 100% rename from arch/platform/openmote-cc2538/dev/max44009.c rename to arch/platform/openmote/dev/max44009.c diff --git a/arch/platform/openmote-cc2538/dev/max44009.h b/arch/platform/openmote/dev/max44009.h similarity index 100% rename from arch/platform/openmote-cc2538/dev/max44009.h rename to arch/platform/openmote/dev/max44009.h diff --git a/arch/platform/openmote-cc2538/dev/openmote-sensors.c b/arch/platform/openmote/dev/openmote-sensors.c similarity index 100% rename from arch/platform/openmote-cc2538/dev/openmote-sensors.c rename to arch/platform/openmote/dev/openmote-sensors.c diff --git a/arch/platform/openmote-cc2538/dev/openmote-sensors.h b/arch/platform/openmote/dev/openmote-sensors.h similarity index 100% rename from arch/platform/openmote-cc2538/dev/openmote-sensors.h rename to arch/platform/openmote/dev/openmote-sensors.h diff --git a/arch/platform/openmote-cc2538/dev/sht21.c b/arch/platform/openmote/dev/sht21.c similarity index 100% rename from arch/platform/openmote-cc2538/dev/sht21.c rename to arch/platform/openmote/dev/sht21.c diff --git a/arch/platform/openmote-cc2538/dev/sht21.h b/arch/platform/openmote/dev/sht21.h similarity index 100% rename from arch/platform/openmote-cc2538/dev/sht21.h rename to arch/platform/openmote/dev/sht21.h diff --git a/arch/platform/openmote-cc2538/dev/tps62730.c b/arch/platform/openmote/dev/tps62730.c similarity index 100% rename from arch/platform/openmote-cc2538/dev/tps62730.c rename to arch/platform/openmote/dev/tps62730.c diff --git a/arch/platform/openmote-cc2538/dev/tps62730.h b/arch/platform/openmote/dev/tps62730.h similarity index 100% rename from arch/platform/openmote-cc2538/dev/tps62730.h rename to arch/platform/openmote/dev/tps62730.h diff --git a/arch/platform/openmote/doxygen-group.txt b/arch/platform/openmote/doxygen-group.txt new file mode 100644 index 0000000000000000000000000000000000000000..fddd8a4d9d1f302d9517a5cacee5f22917c59a8b --- /dev/null +++ b/arch/platform/openmote/doxygen-group.txt @@ -0,0 +1,10 @@ +/** + * \defgroup openmote-platform Openmote-based platform + * The OpenMote platform is based on the CC2538 by Texas Instruments + * based on an ARM Cortex-M3 core and a IEEE 802.15.4 radio. + * + * The OpenMote platform was designed at UC Berkeley in 2013 and + * is comercialized by OpenMote Technologies since 2014. It is the first + * commercial platform based on the TI CC2538 SoC. + * \ingroup cc2538-platforms + */ diff --git a/arch/platform/openmote/openmote-b/board-buttons.c b/arch/platform/openmote/openmote-b/board-buttons.c new file mode 100644 index 0000000000000000000000000000000000000000..dfe27327c1f986632f41c79894263358b6290d94 --- /dev/null +++ b/arch/platform/openmote/openmote-b/board-buttons.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017, George Oikonomou - http://www.spd.gr + * 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. + */ +/*---------------------------------------------------------------------------*/ +/** + * \addtogroup openmote-b + * @{ + * + * \defgroup openmote-b-buttons OpenMote-B user button + * + * Generic module controlling the user button on the OpenMote-B + * @{ + * + * \file + * Defines the OpenMote-B user button for use with the button HAL + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/button-hal.h" +/*---------------------------------------------------------------------------*/ +BUTTON_HAL_BUTTON(button_user, "User button", \ + GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_USER_PORT, BUTTON_USER_PIN), \ + GPIO_HAL_PIN_CFG_EDGE_FALLING, BUTTON_HAL_ID_USER_BUTTON, true); +/*---------------------------------------------------------------------------*/ +BUTTON_HAL_BUTTONS(&button_user); +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ diff --git a/arch/platform/openmote/openmote-b/board.c b/arch/platform/openmote/openmote-b/board.c new file mode 100644 index 0000000000000000000000000000000000000000..7bc4ace896782dc383bee693adbcda5bdc356773 --- /dev/null +++ b/arch/platform/openmote/openmote-b/board.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ + * 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. + * + * This file is part of the Contiki operating system. + * + */ +/*---------------------------------------------------------------------------*/ +/** + * \addtogroup openmote-b + * @{ + * + * \file + * Board-initialisation for the OpenMote-B platform + */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/antenna.h" +#include <stdint.h> +#include <string.h> +/*---------------------------------------------------------------------------*/ +static void +configure_unused_pins(void) +{ + /* FIXME */ +} +/*---------------------------------------------------------------------------*/ +void +board_init() +{ + antenna_init(); + configure_unused_pins(); +} +/*---------------------------------------------------------------------------*/ +/** + * @} + */ diff --git a/arch/platform/openmote/openmote-b/board.h b/arch/platform/openmote/openmote-b/board.h new file mode 100644 index 0000000000000000000000000000000000000000..b37030a3f71f131cb3eec2c60b408890afa58cc6 --- /dev/null +++ b/arch/platform/openmote/openmote-b/board.h @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ + * 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. + * + * This file is part of the Contiki operating system. + * + */ +/* -------------------------------------------------------------------------- */ +/** + * \addtogroup openmote-boards + * @{ + * + * \defgroup openmote-b OpenMote-B + * OpenMote-B is a new board by OpenMote Technologies, released in 2018. + * @{ + * + * \file + * This file provides connectivity information on LEDs, Buttons, UART and + * other OpenMote-B peripherals. + * + * This file can be used as the basis to configure other platforms using the + * cc2538 SoC. + * + * \note Do not include this file directly. It gets included by contiki-conf + * after all relevant directives have been set. + */ + +#ifndef BOARD_H_ +#define BOARD_H_ +/*---------------------------------------------------------------------------*/ +#include "dev/gpio.h" +#include "dev/nvic.h" +/*---------------------------------------------------------------------------*/ +/** + * \name Serial Boot Loader Backdoor configuration + * + * @{ + */ +#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN +#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN 7 /**< Pin PA7 activates the boot loader */ +#endif + +#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH +#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH 0 /**< A logic low level activates the boot loader */ +#endif +/** @} */ +/*---------------------------------------------------------------------------*/ +/** \name OpenMote-B LED configuration + * + * LEDs on the OpenMote-B are connected as follows: + * - LED1 (Red) -> PC4 + * - LED2 (Yellow) -> PC6 + * - LED3 (Green) -> PC7 + * - LED4 (Orange) -> PC5 + * + * @{ + */ +/*---------------------------------------------------------------------------*/ +#define LEDS_ARCH_L1_PORT GPIO_C_NUM +#define LEDS_ARCH_L1_PIN 4 +#define LEDS_ARCH_L2_PORT GPIO_C_NUM +#define LEDS_ARCH_L2_PIN 6 +#define LEDS_ARCH_L3_PORT GPIO_C_NUM +#define LEDS_ARCH_L3_PIN 7 +#define LEDS_ARCH_L4_PORT GPIO_C_NUM +#define LEDS_ARCH_L4_PIN 5 + +#define LEDS_CONF_RED 1 +#define LEDS_CONF_YELLOW 2 +#define LEDS_CONF_GREEN 4 +#define LEDS_CONF_ORANGE 8 + +#define LEDS_CONF_COUNT 4 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** \name USB configuration + * + * The USB pullup is to be enabled by an external resistor, as it is not mapped + * to a GPIO. + * @{ + */ +#ifdef USB_PULLUP_PORT +#undef USB_PULLUP_PORT +#endif +#ifdef USB_PULLUP_PIN +#undef USB_PULLUP_PIN +#endif +/** @} */ +/*---------------------------------------------------------------------------*/ +/** \name UART configuration + * + * On the OpenMote-B, the UART is connected to the + * following ports/pins + * - RX: PA0 + * - TX: PA1 + * + * We configure the port to use UART0. + * @{ + */ +#define UART0_RX_PORT GPIO_A_NUM +#define UART0_RX_PIN 0 +#define UART0_TX_PORT GPIO_A_NUM +#define UART0_TX_PIN 1 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** \name OpenMote-B Button configuration + * + * Buttons on the OpenMote-B are connected as follows: + * - BUTTON_USER -> PD5 + * @{ + */ +/** BUTTON_USER -> PD5 */ +#define BUTTON_USER_PORT GPIO_D_NUM +#define BUTTON_USER_PIN 5 +#define BUTTON_USER_VECTOR GPIO_D_IRQn +/* Notify various examples that we have Buttons */ +#define PLATFORM_HAS_BUTTON 1 +#define PLATFORM_SUPPORTS_BUTTON_HAL 1 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name SPI (SSI0) configuration + * + * These values configure which CC2538 pins to use for the SPI (SSI0) lines. + * @{ + */ +#define SPI_CLK_PORT GPIO_A_NUM +#define SPI_CLK_PIN 2 +#define SPI_MOSI_PORT GPIO_A_NUM +#define SPI_MOSI_PIN 5 +#define SPI_MISO_PORT GPIO_A_NUM +#define SPI_MISO_PIN 4 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name SPI (SSI1) configuration + * + * These values configure which CC2538 pins to use for the SPI (SSI1) lines. + * The SSI1 is currently not used. + * @{ + */ +#define SPI1_CLK_PORT GPIO_C_NUM +#define SPI1_CLK_PIN 4 +#define SPI1_TX_PORT GPIO_C_NUM +#define SPI1_TX_PIN 5 +#define SPI1_RX_PORT GPIO_C_NUM +#define SPI1_RX_PIN 6 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name I2C configuration + * + * These values configure which CC2538 pins to use for the I2C lines. + * @{ + */ +#define I2C_SCL_PORT GPIO_B_NUM +#define I2C_SCL_PIN 5 +#define I2C_SDA_PORT GPIO_B_NUM +#define I2C_SDA_PIN 4 +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name OpenMote-B antenna switch configuration + * + * @{ + */ +#define ANTENNA_BSP_RADIO_BASE GPIO_PORT_TO_BASE(GPIO_D_NUM) +#define ANTENNA_BSP_RADIO_INT GPIO_PIN_MASK(3) +#define ANTENNA_BSP_RADIO_EXT GPIO_PIN_MASK(4) +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name CC2538 TSCH configuration + * + * @{ + */ +#define RADIO_PHY_OVERHEAD CC2538_PHY_OVERHEAD +#define RADIO_BYTE_AIR_TIME CC2538_BYTE_AIR_TIME +#define RADIO_DELAY_BEFORE_TX CC2538_DELAY_BEFORE_TX +#define RADIO_DELAY_BEFORE_RX CC2538_DELAY_BEFORE_RX +#define RADIO_DELAY_BEFORE_DETECT CC2538_DELAY_BEFORE_DETECT +/** @} */ +/*---------------------------------------------------------------------------*/ +/** + * \name Device string used on startup + * @{ + */ +#define BOARD_STRING "OpenMote-B" +/** @} */ +/*---------------------------------------------------------------------------*/ +#endif /* BOARD_H_ */ +/*---------------------------------------------------------------------------*/ +/** + * @} + * @} + */ diff --git a/arch/platform/openmote/openmote-b/leds-arch.c b/arch/platform/openmote/openmote-b/leds-arch.c new file mode 100644 index 0000000000000000000000000000000000000000..ca4dba69bcb39a2ee138fa6b72ae4f8b76631083 --- /dev/null +++ b/arch/platform/openmote/openmote-b/leds-arch.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * 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 "contiki.h" +#include "dev/leds.h" +#include "dev/gpio-hal.h" + +#include <stdbool.h> +/*---------------------------------------------------------------------------*/ +const leds_t leds_arch_leds[] = { + { + .pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L1_PORT, LEDS_ARCH_L1_PIN), + .negative_logic = true + }, + { + .pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L2_PORT, LEDS_ARCH_L2_PIN), + .negative_logic = true + }, + { + .pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L3_PORT, LEDS_ARCH_L3_PIN), + .negative_logic = true + }, + { + .pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L4_PORT, LEDS_ARCH_L4_PIN), + .negative_logic = true + }, +}; +/*---------------------------------------------------------------------------*/ diff --git a/arch/platform/openmote/openmote-cc2538/Makefile.openmote-cc2538 b/arch/platform/openmote/openmote-cc2538/Makefile.openmote-cc2538 new file mode 100644 index 0000000000000000000000000000000000000000..b39f89fb6ec15d8fbf1f07a523d639878e230f8c --- /dev/null +++ b/arch/platform/openmote/openmote-cc2538/Makefile.openmote-cc2538 @@ -0,0 +1,6 @@ +### Allow the OpenMote-CC2538 platform to support different CC2538 chip revisions +ifeq ($(findstring REV_A1,$(BOARD_REVISION)),REV_A1) + CFLAGS += -DCC2538_DEV_CONF=CC2538_DEV_CC2538SF23 +endif + +BSL_FLAGS += --bootloader-invert-lines diff --git a/arch/platform/openmote-cc2538/dev/board-buttons.c b/arch/platform/openmote/openmote-cc2538/board-buttons.c similarity index 100% rename from arch/platform/openmote-cc2538/dev/board-buttons.c rename to arch/platform/openmote/openmote-cc2538/board-buttons.c diff --git a/arch/platform/openmote-cc2538/board.c b/arch/platform/openmote/openmote-cc2538/board.c similarity index 100% rename from arch/platform/openmote-cc2538/board.c rename to arch/platform/openmote/openmote-cc2538/board.c diff --git a/arch/platform/openmote-cc2538/board.h b/arch/platform/openmote/openmote-cc2538/board.h similarity index 91% rename from arch/platform/openmote-cc2538/board.h rename to arch/platform/openmote/openmote-cc2538/board.h index 6e2a15e4633c7f85db33285c5e71e48660866a62..be27088efdcba7c80a0acad815b732babf48f218 100644 --- a/arch/platform/openmote-cc2538/board.h +++ b/arch/platform/openmote/openmote-cc2538/board.h @@ -32,7 +32,14 @@ */ /* -------------------------------------------------------------------------- */ /** - * \addtogroup openmote-cc2538 + * \addtogroup openmote-boards + * @{ + * + * \defgroup openmote-cc2538 OpenMote-CC2538 + * The OpenMote-CC2538 board was designed at UC Berkeley in 2013 and + * is comercialized by OpenMote Technologies since 2014. It is the first + * commercial platform based on the powerful TI CC2538 SoC. It uses a + * XBee form-factor to ease prototyping. * @{ * * \file @@ -174,6 +181,16 @@ #define I2C_SDA_PIN 4 /** @} */ /*---------------------------------------------------------------------------*/ +/** + * \name OpenMote-CC2538 antenna switch configuration + * + * @{ + */ +#define ANTENNA_BSP_RADIO_BASE GPIO_PORT_TO_BASE(GPIO_D_NUM) +#define ANTENNA_BSP_RADIO_INT GPIO_PIN_MASK(5) +#define ANTENNA_BSP_RADIO_EXT GPIO_PIN_MASK(4) +/** @} */ +/*---------------------------------------------------------------------------*/ /** * \name CC2538 TSCH configuration * @@ -196,5 +213,6 @@ #endif /* BOARD_H_ */ /*---------------------------------------------------------------------------*/ /** + * @} * @} */ diff --git a/arch/platform/openmote-cc2538/dev/leds-arch.c b/arch/platform/openmote/openmote-cc2538/leds-arch.c similarity index 100% rename from arch/platform/openmote-cc2538/dev/leds-arch.c rename to arch/platform/openmote/openmote-cc2538/leds-arch.c diff --git a/arch/platform/openmote-cc2538/platform.c b/arch/platform/openmote/platform.c similarity index 93% rename from arch/platform/openmote-cc2538/platform.c rename to arch/platform/openmote/platform.c index 4656d233249f0bfe060c849c3af865f13db24a86..9731103c6b752d5a15eaab2765ae4261ed244212 100644 --- a/arch/platform/openmote-cc2538/platform.c +++ b/arch/platform/openmote/platform.c @@ -32,17 +32,11 @@ */ /*---------------------------------------------------------------------------*/ /** - * \addtogroup cc2538-platforms - * @{ - * - * \defgroup openmote-cc2538 OpenMote-CC2538 platform - * - * The OpenMote-CC2538 is based on the CC2538, the new platform by Texas Instruments - * based on an ARM Cortex-M3 core and a IEEE 802.15.4 radio. + * \addtogroup openmote-platform * @{ * * \file - * Main module for the OpenMote-CC2538 platform + * Main module for the OpenMote platform */ /*---------------------------------------------------------------------------*/ #include "contiki.h" @@ -75,7 +69,7 @@ /*---------------------------------------------------------------------------*/ /* Log configuration */ #include "sys/log.h" -#define LOG_MODULE "OpenMote CC2538" +#define LOG_MODULE "OpenMote" #define LOG_LEVEL LOG_LEVEL_MAIN /*---------------------------------------------------------------------------*/ /** @@ -190,6 +184,5 @@ platform_idle() } /*---------------------------------------------------------------------------*/ /** - * @} * @} */ diff --git a/arch/platform/simplelink/Makefile.simplelink b/arch/platform/simplelink/Makefile.simplelink index acb613d6e113263ecd04d57dffbe63aa57ec9260..9b810db9f4a682a874a2cfb48aee744cd77f23bf 100644 --- a/arch/platform/simplelink/Makefile.simplelink +++ b/arch/platform/simplelink/Makefile.simplelink @@ -17,7 +17,7 @@ SIMPLELINK_FAMILIES := cc13xx-cc26xx # Given a SimpleLink family as argument, check if it has the Board file. # If so, return itself; else, return empty string. -verify_family = $(shell [ -d $(CONTIKI)/arch/platform/simplelink/$(1)/$(BOARD) ] && echo $(1)) +verify_family = $(shell [ -d $(CONTIKI_NG_RELOC_PLATFORM_DIR)/simplelink/$(1)/$(BOARD) ] && echo $(1)) # Test each supported SimpleLink family and see if it contains the specified Board. # Throw an error if it isn't found. @@ -35,7 +35,7 @@ endif # Remove any excess whitespace. FAMILY := $(strip $(FAMILY)) -FAMILY_PATH := $(realpath $(CONTIKI)/arch/platform/simplelink/$(FAMILY)) +FAMILY_PATH := $(realpath $(CONTIKI_NG_RELOC_PLATFORM_DIR)/simplelink/$(FAMILY)) CLEAN += *.simplelink # Include the Simplelink Family specific Makefile diff --git a/arch/platform/simplelink/cc13xx-cc26xx/Makefile.cc13xx-cc26xx b/arch/platform/simplelink/cc13xx-cc26xx/Makefile.cc13xx-cc26xx index 39a3fc5048b5ff9da9531db53ef2e30c98fc676a..90f3179a2d4a109a3ae6f458d344944258f48fb9 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/Makefile.cc13xx-cc26xx +++ b/arch/platform/simplelink/cc13xx-cc26xx/Makefile.cc13xx-cc26xx @@ -16,6 +16,7 @@ BOARDS = $(foreach BOARD, $(BOARD_PLATFORMS), \ BOARD_PATH := $(FAMILY_PATH)/$(BOARD) include $(BOARD_PATH)/Makefile.$(notdir $(BOARD)) +DEVICE_LC := $(shell echo "$(DEVICE)" | tr A-Z a-z) DEVICE_FAMILY_LC := $(shell echo "$(DEVICE_FAMILY)" | tr A-Z a-z) # Add to the source dirs @@ -51,11 +52,9 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) CPU_FAMILY = cc13xx-cc26xx # Define the CPU directory and pull in the correct CPU Makefile -CONTIKI_CPU := $(realpath $(ARCH_PATH)/cpu/simplelink-$(CPU_FAMILY)) +CONTIKI_CPU := $(realpath $(CONTIKI_NG_RELOC_CPU_DIR)/simplelink-$(CPU_FAMILY)) include $(CONTIKI_CPU)/Makefile.$(CPU_FAMILY) -MODULES += os/net os/net/mac os/net/mac/framer - ################################################################################ # Display all supported Boards for the given SimpleLink Family simplelink_boards: diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/Board.h index 88999fe6fa762723b8a099e12068c58fea567a86..1a38ec1f3542279bb636d34af6fed01d8607b60d 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,19 +33,17 @@ #ifndef __BOARD_H #define __BOARD_H -#define Board_CC1310_LAUNCHXL -#define BOARD_STRING "TI CC1310 LaunchPad" - -#define RF_CONF_FRONT_END_MODE RF_FRONT_END_MODE_DIFFERENTIAL -#define RF_CONF_BIAS_MODE RF_BIAS_MODE_EXTERNAL - #ifdef __cplusplus extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1310_LAUNCHXL.h" -#define Board_initGeneral() CC1310_LAUNCHXL_initGeneral() +#define Board_CC1310_LAUNCHXL +#define BOARD_STRING "TI CC1310 LaunchPad" + +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1310_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1310_LAUNCHXL_wakeUpExtFlash() @@ -59,6 +57,13 @@ extern "C" { #define Board_ADCBUF0CHANNEL1 CC1310_LAUNCHXL_ADCBUF0CHANNEL1 #define Board_CRYPTO0 CC1310_LAUNCHXL_CRYPTO0 +#define Board_AESCCM0 CC1310_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC1310_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC1310_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC1310_LAUNCHXL_AESCTR0 +#define Board_AESECB0 CC1310_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC1310_LAUNCHXL_AESCTRDRBG0 +#define Board_TRNG0 CC1310_LAUNCHXL_TRNG0 #define Board_DIO0 CC1310_LAUNCHXL_DIO0 #define Board_DIO1 CC1310_LAUNCHXL_DIO1 @@ -92,6 +97,13 @@ extern "C" { #define Board_I2C0 CC1310_LAUNCHXL_I2C0 #define Board_I2C_TMP CC1310_LAUNCHXL_I2C0 +#define Board_I2S0 CC1310_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC1310_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC1310_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC1310_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC1310_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC1310_LAUNCHXL_I2S_WCLK + #define Board_NVSINTERNAL CC1310_LAUNCHXL_NVSCC26XX0 #define Board_NVSEXTERNAL CC1310_LAUNCHXL_NVSSPI25X0 @@ -139,10 +151,6 @@ extern "C" { #define Board_WATCHDOG0 CC1310_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.c index b5db4e61d36e821b26c47f0b8d6ae6eae43a1cab..7975925c0460eabda706d17a853551bec96ba4d8 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,8 +82,6 @@ const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC1310_LAUNCHXL_ADCBUFCOUNT] = { .intPriority = ~0, .swiPriority = 0, .adcChannelLut = ADCBufCC26XX_adcChannelLut, - .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER0A, - .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A, } }; @@ -247,6 +245,170 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC1310_LAUNCHXL_CRYPTOCOUNT] = { } }; +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC1310_LAUNCHXL_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1310_LAUNCHXL_AESCCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCCM_Config AESCCM_config[CC1310_LAUNCHXL_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC1310_LAUNCHXL_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC1310_LAUNCHXL_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC1310_LAUNCHXL_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1310_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1310_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1310_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1310_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1310_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1310_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1310_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1310_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1310_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1310_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1310_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1310_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1310_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1310_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1310_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1310_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1310_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1310_LAUNCHXL_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC1310_LAUNCHXL_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1310_LAUNCHXL_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC1310_LAUNCHXL_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC1310_LAUNCHXL_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC1310_LAUNCHXL_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC1310_LAUNCHXL_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1310_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1310_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1310_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1310_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1310_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1310_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1310_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1310_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1310_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1310_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1310_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1310_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1310_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -370,6 +532,34 @@ const uint_least8_t I2C_count = CC1310_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1310_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1310_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC1310_LAUNCHXL_I2S_ADI, + .pinSD0 = CC1310_LAUNCHXL_I2S_ADO, + .pinSCK = CC1310_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC1310_LAUNCHXL_I2S_MCLK, + .pinWS = CC1310_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1310_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1310_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1310_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1310_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -458,6 +648,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -498,8 +689,8 @@ const PIN_Config BoardGpioInitTable[] = { CC1310_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1310_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ @@ -517,10 +708,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -568,7 +760,7 @@ const uint_least8_t PWM_count = CC1310_LAUNCHXL_PWMCOUNT; const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ .globalCallback = NULL, /* No board specific callback */ .globalEventMask = 0 /* No events subscribed to */ }; @@ -679,29 +871,6 @@ const uint_least8_t SPI_count = CC1310_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC1310_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1310_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1310_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -818,3 +987,11 @@ void CC1310_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1310_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.h index f2c1638d77624dd28b39ded5af1a5af652425f92..39932ad4c834b5c76911722093eb990807932c22 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,6 +98,13 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1310_LAUNCHXL_I2C0_SCL0 IOID_4 #define CC1310_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1310_LAUNCHXL_I2S_ADO IOID_25 +#define CC1310_LAUNCHXL_I2S_ADI IOID_26 +#define CC1310_LAUNCHXL_I2S_BCLK IOID_27 +#define CC1310_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC1310_LAUNCHXL_I2S_WCLK IOID_28 + /* LEDs */ #define CC1310_LAUNCHXL_PIN_LED_ON 1 #define CC1310_LAUNCHXL_PIN_LED_OFF 0 @@ -123,7 +130,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1310_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ #define CC1310_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ #define CC1310_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1310_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC1310_LAUNCHXL_SPI0_CSN IOID_11 #define CC1310_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1310_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1310_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -216,6 +223,76 @@ typedef enum CC1310_LAUNCHXL_CryptoName { CC1310_LAUNCHXL_CRYPTOCOUNT } CC1310_LAUNCHXL_CryptoName; +/*! + * @def CC1310_LAUNCHXL_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC1310_LAUNCHXL_AESCCMName { + CC1310_LAUNCHXL_AESCCM0 = 0, + + CC1310_LAUNCHXL_AESCCMCOUNT +} CC1310_LAUNCHXL_AESCCMName; + +/*! + * @def CC1310_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1310_LAUNCHXL_AESGCMName { + CC1310_LAUNCHXL_AESGCM0 = 0, + + CC1310_LAUNCHXL_AESGCMCOUNT +} CC1310_LAUNCHXL_AESGCMName; + +/*! + * @def CC1310_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1310_LAUNCHXL_AESCBCName { + CC1310_LAUNCHXL_AESCBC0 = 0, + + CC1310_LAUNCHXL_AESCBCCOUNT +} CC1310_LAUNCHXL_AESCBCName; + +/*! + * @def CC1310_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1310_LAUNCHXL_AESCTRName { + CC1310_LAUNCHXL_AESCTR0 = 0, + + CC1310_LAUNCHXL_AESCTRCOUNT +} CC1310_LAUNCHXL_AESCTRName; + +/*! + * @def CC1310_LAUNCHXL_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC1310_LAUNCHXL_AESECBName { + CC1310_LAUNCHXL_AESECB0 = 0, + + CC1310_LAUNCHXL_AESECBCOUNT +} CC1310_LAUNCHXL_AESECBName; + +/*! + * @def CC1310_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1310_LAUNCHXL_AESCTRDRBGName { + CC1310_LAUNCHXL_AESCTRDRBG0 = 0, + + CC1310_LAUNCHXL_AESCTRDRBGCOUNT +} CC1310_LAUNCHXL_AESCTRDRBGName; + +/*! + * @def CC1310_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1310_LAUNCHXL_TRNGName { + CC1310_LAUNCHXL_TRNG0 = 0, + + CC1310_LAUNCHXL_TRNGCOUNT +} CC1310_LAUNCHXL_TRNGName; + /*! * @def CC1310_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -274,6 +351,16 @@ typedef enum CC1310_LAUNCHXL_I2CName { CC1310_LAUNCHXL_I2CCOUNT } CC1310_LAUNCHXL_I2CName; +/*! + * @def CC1310_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1310_LAUNCHXL_I2SName { + CC1310_LAUNCHXL_I2S0 = 0, + + CC1310_LAUNCHXL_I2SCOUNT +} CC1310_LAUNCHXL_I2SName; + /*! * @def CC1310_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -331,16 +418,6 @@ typedef enum CC1310_LAUNCHXL_SPIName { CC1310_LAUNCHXL_SPICOUNT } CC1310_LAUNCHXL_SPIName; -/*! - * @def CC1310_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1310_LAUNCHXL_TRNGName { - CC1310_LAUNCHXL_TRNG0 = 0, - - CC1310_LAUNCHXL_TRNGCOUNT -} CC1310_LAUNCHXL_TRNGName; - /*! * @def CC1310_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL_fxns.c index 6918918bb6926c6c6045db78acac8d6e85f307f4..f2dd4157ec8ea2d25c42e68dc4f5284ceafc645b 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1310/CC1310_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,8 @@ #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/Board.h index a230c764e3edf36d551396a7eecf054e05b1c441..977bb5fa25c2b62bc01f1025af1d78bbfba8298b 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1312R1_LAUNCHXL.h" #define Board_CC1312R1_LAUNCHXL #define BOARD_STRING "TI CC1312R1 LaunchPad" -#define Board_initGeneral() CC1312R1_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1312R1_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1312R1_LAUNCHXL_wakeUpExtFlash() @@ -59,8 +60,13 @@ extern "C" { #define Board_ECDSA0 CC1312R1_LAUNCHXL_ECDSA0 #define Board_ECJPAKE0 CC1312R1_LAUNCHXL_ECJPAKE0 #define Board_AESCCM0 CC1312R1_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC1312R1_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC1312R1_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC1312R1_LAUNCHXL_AESCTR0 #define Board_AESECB0 CC1312R1_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC1312R1_LAUNCHXL_AESCTRDRBG0 #define Board_SHA20 CC1312R1_LAUNCHXL_SHA20 +#define Board_TRNG0 CC1312R1_LAUNCHXL_TRNG0 #define Board_DIO0 CC1312R1_LAUNCHXL_DIO0 #define Board_DIO1 CC1312R1_LAUNCHXL_DIO1 @@ -94,6 +100,13 @@ extern "C" { #define Board_I2C0 CC1312R1_LAUNCHXL_I2C0 #define Board_I2C_TMP CC1312R1_LAUNCHXL_I2C0 +#define Board_I2S0 CC1312R1_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC1312R1_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC1312R1_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC1312R1_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC1312R1_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC1312R1_LAUNCHXL_I2S_WCLK + #define Board_NVSINTERNAL CC1312R1_LAUNCHXL_NVSCC26XX0 #define Board_NVSEXTERNAL CC1312R1_LAUNCHXL_NVSSPI25X0 @@ -142,10 +155,6 @@ extern "C" { #define Board_WATCHDOG0 CC1312R1_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.c index a51bba632ba14d363b9162200cef41d77f61b938..85bdbd1f5e6650e3fb97a1ec9e13bc4017ed18bf 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -234,7 +234,6 @@ ECDHCC26X2_Object ecdhCC26X2Objects[CC1312R1_LAUNCHXL_ECDHCOUNT]; const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECDHCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -258,7 +257,6 @@ ECDSACC26X2_Object ecdsaCC26X2Objects[CC1312R1_LAUNCHXL_ECDSACOUNT]; const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECDSACOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -282,7 +280,6 @@ ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CC1312R1_LAUNCHXL_ECJPAKECOUNT]; const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECJPAKECOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -307,7 +304,6 @@ SHA2CC26X2_Object sha2CC26X2Objects[CC1312R1_LAUNCHXL_SHA2COUNT]; const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CC1312R1_LAUNCHXL_SHA2COUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -331,7 +327,6 @@ AESCCMCC26XX_Object aesccmCC26XXObjects[CC1312R1_LAUNCHXL_AESCCMCOUNT]; const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESCCMCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -344,6 +339,76 @@ const AESCCM_Config AESCCM_config[CC1312R1_LAUNCHXL_AESCCMCOUNT] = { const uint_least8_t AESCCM_count = CC1312R1_LAUNCHXL_AESCCMCOUNT; + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1312R1_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1312R1_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1312R1_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1312R1_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1312R1_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1312R1_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1312R1_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1312R1_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1312R1_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1312R1_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1312R1_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1312R1_LAUNCHXL_AESCTRCOUNT; + /* * =============================== AESECB =============================== */ @@ -355,7 +420,6 @@ AESECBCC26XX_Object aesecbCC26XXObjects[CC1312R1_LAUNCHXL_AESECBCOUNT]; const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESECBCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -368,6 +432,54 @@ const AESECB_Config AESECB_config[CC1312R1_LAUNCHXL_AESECBCOUNT] = { const uint_least8_t AESECB_count = CC1312R1_LAUNCHXL_AESECBCOUNT; +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1312R1_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1312R1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1312R1_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1312R1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1312R1_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1312R1_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1312R1_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1312R1_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1312R1_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1312R1_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1312R1_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1312R1_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1312R1_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -491,6 +603,34 @@ const uint_least8_t I2C_count = CC1312R1_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1312R1_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1312R1_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC1312R1_LAUNCHXL_I2S_ADI, + .pinSD0 = CC1312R1_LAUNCHXL_I2S_ADO, + .pinSCK = CC1312R1_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC1312R1_LAUNCHXL_I2S_MCLK, + .pinWS = CC1312R1_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1312R1_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1312R1_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1312R1_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1312R1_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -579,6 +719,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1312R1_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -619,8 +760,8 @@ const PIN_Config BoardGpioInitTable[] = { CC1312R1_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1312R1_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1312R1_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1312R1_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1312R1_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1312R1_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1312R1_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1312R1_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC1312R1_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC1312R1_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ @@ -638,10 +779,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26X2.h> +#include "clock-arch.h" const PowerCC26X2_Config PowerCC26X2_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -689,7 +831,7 @@ const uint_least8_t PWM_count = CC1312R1_LAUNCHXL_PWMCOUNT; const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ .globalCallback = NULL, /* No board specific callback */ .globalEventMask = 0 /* No events subscribed to */ }; @@ -731,18 +873,18 @@ const uint_least8_t SD_count = CC1312R1_LAUNCHXL_SDCOUNT; * =============================== SPI DMA =============================== */ #include <ti/drivers/SPI.h> -#include <ti/drivers/spi/SPICC26XXDMA.h> +#include <ti/drivers/spi/SPICC26X2DMA.h> #if TI_SPI_CONF_ENABLE -SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1312R1_LAUNCHXL_SPICOUNT]; +SPICC26X2DMA_Object spiCC26X2DMAObjects[CC1312R1_LAUNCHXL_SPICOUNT]; /* * NOTE: The SPI instances below can be used by the SD driver to communicate * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF * to satisfy the SDSPI driver requirement. */ -const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1312R1_LAUNCHXL_SPICOUNT] = { +const SPICC26X2DMA_HWAttrs spiCC26X2DMAHWAttrs[CC1312R1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { .baseAddr = SSI0_BASE, @@ -782,16 +924,16 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1312R1_LAUNCHXL_SPICOUNT] = { const SPI_Config SPI_config[CC1312R1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1312R1_LAUNCHXL_SPI0], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1312R1_LAUNCHXL_SPI0] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1312R1_LAUNCHXL_SPI0], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1312R1_LAUNCHXL_SPI0] }, #endif #if TI_SPI_CONF_SPI1_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1312R1_LAUNCHXL_SPI1], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1312R1_LAUNCHXL_SPI1] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1312R1_LAUNCHXL_SPI1], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1312R1_LAUNCHXL_SPI1] }, #endif }; @@ -800,29 +942,6 @@ const uint_least8_t SPI_count = CC1312R1_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X2.h> - -TRNGCC26X2_Object trngCC26X2Object[CC1312R1_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X2_HWAttrs trngCC26X2HWAttrs[CC1312R1_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X2Object[0], &trngCC26X2HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1312R1_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -854,6 +973,24 @@ const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UARTCOUNT] = { .errorFxn = NULL }, #endif +#if TI_UART_CONF_UART1_ENABLE + { + .baseAddr = UART1_BASE, + .powerMngrId = PowerCC26X2_PERIPH_UART1, + .intNum = INT_UART1_COMB, + .intPriority = ~0, + .swiPriority = 0, + .txPin = CC1312R1_LAUNCHXL_UART1_TX, + .rxPin = CC1312R1_LAUNCHXL_UART1_RX, + .ctsPin = PIN_UNASSIGNED, + .rtsPin = PIN_UNASSIGNED, + .ringBufPtr = uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART1], + .ringBufSize = sizeof(uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART1]), + .txIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_1_8, + .rxIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_4_8, + .errorFxn = NULL + }, +#endif }; const UART_Config UART_config[CC1312R1_LAUNCHXL_UARTCOUNT] = { @@ -864,6 +1001,13 @@ const UART_Config UART_config[CC1312R1_LAUNCHXL_UARTCOUNT] = { .hwAttrs = &uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UART0] }, #endif +#if TI_UART_CONF_UART1_ENABLE + { + .fxnTablePtr = &UARTCC26XX_fxnTable, + .object = &uartCC26XXObjects[CC1312R1_LAUNCHXL_UART1], + .hwAttrs = &uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UART1] + }, +#endif }; const uint_least8_t UART_count = CC1312R1_LAUNCHXL_UARTCOUNT; @@ -939,3 +1083,11 @@ void CC1312R1_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1312R1_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.h index 0295dc0b484cd5861c3ee172e6e1e02f65800fa0..53f8b2ed32aa8d2db178e18b6ac4d2702838856a 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,6 +98,13 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1312R1_LAUNCHXL_I2C0_SCL0 IOID_4 #define CC1312R1_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1312R1_LAUNCHXL_I2S_ADO IOID_25 +#define CC1312R1_LAUNCHXL_I2S_ADI IOID_26 +#define CC1312R1_LAUNCHXL_I2S_BCLK IOID_27 +#define CC1312R1_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC1312R1_LAUNCHXL_I2S_WCLK IOID_28 + /* LEDs */ #define CC1312R1_LAUNCHXL_PIN_LED_ON 1 #define CC1312R1_LAUNCHXL_PIN_LED_OFF 0 @@ -123,7 +130,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1312R1_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ #define CC1312R1_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ #define CC1312R1_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1312R1_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC1312R1_LAUNCHXL_SPI0_CSN IOID_11 #define CC1312R1_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1312R1_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1312R1_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -255,6 +262,36 @@ typedef enum CC1312R1_LAUNCHXL_AESCCMName { CC1312R1_LAUNCHXL_AESCCMCOUNT } CC1312R1_LAUNCHXL_AESCCMName; +/*! + * @def CC1312R1_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1312R1_LAUNCHXL_AESGCMName { + CC1312R1_LAUNCHXL_AESGCM0 = 0, + + CC1312R1_LAUNCHXL_AESGCMCOUNT +} CC1312R1_LAUNCHXL_AESGCMName; + +/*! + * @def CC1312R1_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1312R1_LAUNCHXL_AESCBCName { + CC1312R1_LAUNCHXL_AESCBC0 = 0, + + CC1312R1_LAUNCHXL_AESCBCCOUNT +} CC1312R1_LAUNCHXL_AESCBCName; + +/*! + * @def CC1312R1_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1312R1_LAUNCHXL_AESCTRName { + CC1312R1_LAUNCHXL_AESCTR0 = 0, + + CC1312R1_LAUNCHXL_AESCTRCOUNT +} CC1312R1_LAUNCHXL_AESCTRName; + /*! * @def CC1312R1_LAUNCHXL_AESECBName * @brief Enum of AESECB names @@ -265,6 +302,16 @@ typedef enum CC1312R1_LAUNCHXL_AESECBName { CC1312R1_LAUNCHXL_AESECBCOUNT } CC1312R1_LAUNCHXL_AESECBName; +/*! + * @def CC1312R1_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1312R1_LAUNCHXL_AESCTRDRBGName { + CC1312R1_LAUNCHXL_AESCTRDRBG0 = 0, + + CC1312R1_LAUNCHXL_AESCTRDRBGCOUNT +} CC1312R1_LAUNCHXL_AESCTRDRBGName; + /*! * @def CC1312R1_LAUNCHXL_SHA2Name * @brief Enum of SHA2 names @@ -275,6 +322,16 @@ typedef enum CC1312R1_LAUNCHXL_SHA2Name { CC1312R1_LAUNCHXL_SHA2COUNT } CC1312R1_LAUNCHXL_SHA2Name; +/*! + * @def CC1312R1_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1312R1_LAUNCHXL_TRNGName { + CC1312R1_LAUNCHXL_TRNG0 = 0, + + CC1312R1_LAUNCHXL_TRNGCOUNT +} CC1312R1_LAUNCHXL_TRNGName; + /*! * @def CC1312R1_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -333,6 +390,16 @@ typedef enum CC1312R1_LAUNCHXL_I2CName { CC1312R1_LAUNCHXL_I2CCOUNT } CC1312R1_LAUNCHXL_I2CName; +/*! + * @def CC1312R1_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1312R1_LAUNCHXL_I2SName { + CC1312R1_LAUNCHXL_I2S0 = 0, + + CC1312R1_LAUNCHXL_I2SCOUNT +} CC1312R1_LAUNCHXL_I2SName; + /*! * @def CC1312R1_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -390,16 +457,6 @@ typedef enum CC1312R1_LAUNCHXL_SPIName { CC1312R1_LAUNCHXL_SPICOUNT } CC1312R1_LAUNCHXL_SPIName; -/*! - * @def CC1312R1_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1312R1_LAUNCHXL_TRNGName { - CC1312R1_LAUNCHXL_TRNG0 = 0, - - CC1312R1_LAUNCHXL_TRNGCOUNT -} CC1312R1_LAUNCHXL_TRNGName; - /*! * @def CC1312R1_LAUNCHXL_UARTName * @brief Enum of UARTs @@ -408,6 +465,9 @@ typedef enum CC1312R1_LAUNCHXL_UARTName { #if TI_UART_CONF_UART0_ENABLE CC1312R1_LAUNCHXL_UART0 = 0, #endif +#if TI_UART_CONF_UART1_ENABLE + CC1312R1_LAUNCHXL_UART1, +#endif CC1312R1_LAUNCHXL_UARTCOUNT } CC1312R1_LAUNCHXL_UARTName; diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL_fxns.c index 0a28583d48659cac02030e033e8bf66aa39dd0cd..918a9b6e8665b85eb6b8072aa3252e5d61fe70c1 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1312r1/CC1312R1_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,8 +44,11 @@ #include DeviceFamily_constructPath(driverlib/cpu.h) #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC1312R1_LAUNCHXL_sendExtFlashByte ======== */ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Board.h index 4b8fbe5c0ec5b1d8b05d1a5256f787cec42691bd..47e53fc62444ad426a35f834d692adba61002ae9 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1350_LAUNCHXL_433.h" #define Board_CC1350_LAUNCHXL_433 #define BOARD_STRING "TI CC1350-433 LaunchPad" -#define Board_initGeneral() CC1350_LAUNCHXL_433_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1350_LAUNCHXL_433_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1350_LAUNCHXL_433_wakeUpExtFlash() @@ -56,6 +57,13 @@ extern "C" { #define Board_ADCBUF0CHANNEL1 CC1350_LAUNCHXL_433_ADCBUF0CHANNEL1 #define Board_CRYPTO0 CC1350_LAUNCHXL_433_CRYPTO0 +#define Board_AESCCM0 CC1350_LAUNCHXL_433_AESCCM0 +#define Board_AESGCM0 CC1350_LAUNCHXL_433_AESGCM0 +#define Board_AESCBC0 CC1350_LAUNCHXL_433_AESCBC0 +#define Board_AESCTR0 CC1350_LAUNCHXL_433_AESCTR0 +#define Board_AESECB0 CC1350_LAUNCHXL_433_AESECB0 +#define Board_AESCTRDRBG0 CC1350_LAUNCHXL_433_AESCTRDRBG0 +#define Board_TRNG0 CC1350_LAUNCHXL_433_TRNG0 #define Board_DIO0 CC1350_LAUNCHXL_433_DIO0 #define Board_DIO1_RFSW CC1350_LAUNCHXL_433_DIO1_RF_SUB1GHZ @@ -109,6 +117,13 @@ extern "C" { #define Board_I2C0 CC1350_LAUNCHXL_433_I2C0 #define Board_I2C_TMP CC1350_LAUNCHXL_433_I2C0 +#define Board_I2S0 CC1350_LAUNCHXL_433_I2S0 +#define Board_I2S_ADO CC1350_LAUNCHXL_433_I2S_ADO +#define Board_I2S_ADI CC1350_LAUNCHXL_433_I2S_ADI +#define Board_I2S_BCLK CC1350_LAUNCHXL_433_I2S_BCLK +#define Board_I2S_MCLK CC1350_LAUNCHXL_433_I2S_MCLK +#define Board_I2S_WCLK CC1350_LAUNCHXL_433_I2S_WCLK + #define Board_PIN_BUTTON0 CC1350_LAUNCHXL_433_PIN_BTN1 #define Board_PIN_BUTTON1 CC1350_LAUNCHXL_433_PIN_BTN2 #define Board_PIN_BTN1 CC1350_LAUNCHXL_433_PIN_BTN1 @@ -153,10 +168,6 @@ extern "C" { #define Board_WATCHDOG0 CC1350_LAUNCHXL_433_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.c index aa690dff419333ad3b7203e29d689e71fb534dd7..67ebe2b60bf2683050870b804d37b13fea5c08e8 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,8 +82,6 @@ const ADCBufCC26XX_HWAttrs adcBufCC26XXHWAttrs[CC1350_LAUNCHXL_433_ADCBUFCOUNT] .intPriority = ~0, .swiPriority = 0, .adcChannelLut = ADCBufCC26XX_adcChannelLut, - .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER0A, - .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A, } }; @@ -246,6 +244,170 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC1350_LAUNCHXL_433_CRYPTOCOUNT] = }, }; +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC1350_LAUNCHXL_433_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESCCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCCM_Config AESCCM_config[CC1350_LAUNCHXL_433_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC1350_LAUNCHXL_433_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC1350_LAUNCHXL_433_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1350_LAUNCHXL_433_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1350_LAUNCHXL_433_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1350_LAUNCHXL_433_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1350_LAUNCHXL_433_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1350_LAUNCHXL_433_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1350_LAUNCHXL_433_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1350_LAUNCHXL_433_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1350_LAUNCHXL_433_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1350_LAUNCHXL_433_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1350_LAUNCHXL_433_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1350_LAUNCHXL_433_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1350_LAUNCHXL_433_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC1350_LAUNCHXL_433_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC1350_LAUNCHXL_433_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC1350_LAUNCHXL_433_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC1350_LAUNCHXL_433_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC1350_LAUNCHXL_433_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1350_LAUNCHXL_433_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1350_LAUNCHXL_433_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1350_LAUNCHXL_433_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1350_LAUNCHXL_433_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1350_LAUNCHXL_433_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1350_LAUNCHXL_433_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1350_LAUNCHXL_433_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1350_LAUNCHXL_433_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1350_LAUNCHXL_433_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1350_LAUNCHXL_433_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1350_LAUNCHXL_433_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1350_LAUNCHXL_433_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1350_LAUNCHXL_433_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -365,6 +527,34 @@ const uint_least8_t I2C_count = CC1350_LAUNCHXL_433_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1350_LAUNCHXL_433_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1350_LAUNCHXL_433_I2SCOUNT] = { + { + .pinSD1 = CC1350_LAUNCHXL_433_I2S_ADI, + .pinSD0 = CC1350_LAUNCHXL_433_I2S_ADO, + .pinSCK = CC1350_LAUNCHXL_433_I2S_BCLK, + .pinMCLK = CC1350_LAUNCHXL_433_I2S_MCLK, + .pinWS = CC1350_LAUNCHXL_433_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1350_LAUNCHXL_433_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1350_LAUNCHXL_433_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1350_LAUNCHXL_433_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1350_LAUNCHXL_433_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -453,6 +643,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1350_LAUNCHXL_433_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -493,8 +684,8 @@ const PIN_Config BoardGpioInitTable[] = { CC1350_LAUNCHXL_433_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1350_LAUNCHXL_433_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1350_LAUNCHXL_433_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1350_LAUNCHXL_433_UART_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1350_LAUNCHXL_433_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1350_LAUNCHXL_433_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1350_LAUNCHXL_433_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1350_LAUNCHXL_433_DIO1_RF_SUB1GHZ | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* RF SW Switch defaults to 2.4 GHz path*/ CC1350_LAUNCHXL_433_DIO30_RF_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* External RF Switch is powered off by default */ CC1350_LAUNCHXL_433_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ @@ -513,10 +704,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -573,7 +765,7 @@ extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ /* Register the board specific callback */ .globalCallback = &rfDriverCallback, @@ -687,29 +879,6 @@ const uint_least8_t SPI_count = CC1350_LAUNCHXL_433_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC1350_LAUNCHXL_433_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1350_LAUNCHXL_433_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1350_LAUNCHXL_433_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -826,3 +995,11 @@ void CC1350_LAUNCHXL_433_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1350_LAUNCHXL_433_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.h index 5377700d5d567f983d4e93d68c6f6c5037403f5a..b27cf0781928bc3eec73a3a9e40b051e0538528e 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,6 +100,12 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350_LAUNCHXL_433_I2C0_SCL0 IOID_4 #define CC1350_LAUNCHXL_433_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1350_LAUNCHXL_433_I2S_ADO IOID_25 +#define CC1350_LAUNCHXL_433_I2S_ADI IOID_26 +#define CC1350_LAUNCHXL_433_I2S_BCLK IOID_27 +#define CC1350_LAUNCHXL_433_I2S_MCLK PIN_UNASSIGNED +#define CC1350_LAUNCHXL_433_I2S_WCLK IOID_28 /* LEDs */ #define CC1350_LAUNCHXL_433_PIN_LED_ON 1 @@ -126,7 +132,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350_LAUNCHXL_433_SPI0_MISO IOID_8 /* RF1.20 */ #define CC1350_LAUNCHXL_433_SPI0_MOSI IOID_9 /* RF1.18 */ #define CC1350_LAUNCHXL_433_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1350_LAUNCHXL_433_SPI0_CSN PIN_UNASSIGNED +#define CC1350_LAUNCHXL_433_SPI0_CSN IOID_11 #define CC1350_LAUNCHXL_433_SPI1_MISO PIN_UNASSIGNED #define CC1350_LAUNCHXL_433_SPI1_MOSI PIN_UNASSIGNED #define CC1350_LAUNCHXL_433_SPI1_CLK PIN_UNASSIGNED @@ -219,6 +225,76 @@ typedef enum CC1350_LAUNCHXL_433_CryptoName { CC1350_LAUNCHXL_433_CRYPTOCOUNT } CC1350_LAUNCHXL_433_CryptoName; +/*! + * @def CC1350_LAUNCHXL_433_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC1350_LAUNCHXL_433_AESCCMName { + CC1350_LAUNCHXL_433_AESCCM0 = 0, + + CC1350_LAUNCHXL_433_AESCCMCOUNT +} CC1350_LAUNCHXL_433_AESCCMName; + +/*! + * @def CC1350_LAUNCHXL_433_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1350_LAUNCHXL_433_AESGCMName { + CC1350_LAUNCHXL_433_AESGCM0 = 0, + + CC1350_LAUNCHXL_433_AESGCMCOUNT +} CC1350_LAUNCHXL_433_AESGCMName; + +/*! + * @def CC1350_LAUNCHXL_433_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1350_LAUNCHXL_433_AESCBCName { + CC1350_LAUNCHXL_433_AESCBC0 = 0, + + CC1350_LAUNCHXL_433_AESCBCCOUNT +} CC1350_LAUNCHXL_433_AESCBCName; + +/*! + * @def CC1350_LAUNCHXL_433_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1350_LAUNCHXL_433_AESCTRName { + CC1350_LAUNCHXL_433_AESCTR0 = 0, + + CC1350_LAUNCHXL_433_AESCTRCOUNT +} CC1350_LAUNCHXL_433_AESCTRName; + +/*! + * @def CC1350_LAUNCHXL_433_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC1350_LAUNCHXL_433_AESECBName { + CC1350_LAUNCHXL_433_AESECB0 = 0, + + CC1350_LAUNCHXL_433_AESECBCOUNT +} CC1350_LAUNCHXL_433_AESECBName; + +/*! + * @def CC1350_LAUNCHXL_433_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1350_LAUNCHXL_433_AESCTRDRBGName { + CC1350_LAUNCHXL_433_AESCTRDRBG0 = 0, + + CC1350_LAUNCHXL_433_AESCTRDRBGCOUNT +} CC1350_LAUNCHXL_433_AESCTRDRBGName; + +/*! + * @def CC1350_LAUNCHXL_433_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1350_LAUNCHXL_433_TRNGName { + CC1350_LAUNCHXL_433_TRNG0 = 0, + + CC1350_LAUNCHXL_433_TRNGCOUNT +} CC1350_LAUNCHXL_433_TRNGName; + /*! * @def CC1350_LAUNCHXL_433_GPIOName * @brief Enum of GPIO names @@ -275,6 +351,16 @@ typedef enum CC1350_LAUNCHXL_433_I2CName { CC1350_LAUNCHXL_433_I2CCOUNT } CC1350_LAUNCHXL_433_I2CName; +/*! + * @def CC1350_LAUNCHXL_433_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1350_LAUNCHXL_433_I2SName { + CC1350_LAUNCHXL_433_I2S0 = 0, + + CC1350_LAUNCHXL_433_I2SCOUNT +} CC1350_LAUNCHXL_433_I2SName; + /*! * @def CC1350_LAUNCHXL_433_NVSName * @brief Enum of NVS names @@ -328,16 +414,6 @@ typedef enum CC1350_LAUNCHXL_433_SPIName { CC1350_LAUNCHXL_433_SPICOUNT } CC1350_LAUNCHXL_433_SPIName; -/*! - * @def CC1350_LAUNCHXL_433_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1350_LAUNCHXL_433_TRNGName { - CC1350_LAUNCHXL_433_TRNG0 = 0, - - CC1350_LAUNCHXL_433_TRNGCOUNT -} CC1350_LAUNCHXL_433_TRNGName; - /*! * @def CC1350_LAUNCHXL_433_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433_fxns.c index 92e349480f1a383a53ec7414f141dea6bb48eda6..5f5907bf11c7361a6bea8e768bd2eda38cfa62d9 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/CC1350_LAUNCHXL_433_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,8 @@ #include <ti/drivers/rf/RF.h> #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" @@ -165,13 +167,7 @@ void Board_initHook() #if defined(Board_RF_SUB1GHZ) /* - * Mask to be used to determine the effective value of the setup command's - * loDivider field. - */ -#define LODIVIDER_MASK 0x7F - -/* - * ======== rfDriverCallback ======== + * ======== CC1350_LAUNCHXL_433_rfDriverCallback ======== * This is an implementation for the CC1350 LaunchPad which uses a * single signal for antenna switching. */ @@ -194,7 +190,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) switch (setupCommand->common.commandNo) { case (CMD_RADIO_SETUP): case (CMD_BLE5_RADIO_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->common.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->common.loDivider; /* Sub-1 GHz, requires antenna switch high. */ if ((loDivider != 0) && (loDivider != 2)) { @@ -202,7 +198,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) } break; case (CMD_PROP_RADIO_DIV_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->prop_div.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->prop_div.loDivider; /* Sub-1 GHz, requires antenna switch high. */ if ((loDivider != 0) && (loDivider != 2)) { diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Makefile.cc1350-4 b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Makefile.cc1350-4 index 8ea92347b914b9834bb2f75642d5593f24c8bdc5..e017541b6867e965f0c56d33b2dd1a8fb4a45fb1 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Makefile.cc1350-4 +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350-4/Makefile.cc1350-4 @@ -4,7 +4,7 @@ SUBFAMILY = cc13x0-cc26x0 DEVICE_FAMILY = CC13X0 DEVICE_LINE = CC13XX -DEVICE = CC1350_4 +DEVICE = CC1350 BOARD_SOURCEFILES += CC1350_LAUNCHXL_433.c CC1350_LAUNCHXL_433_fxns.c diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/Board.h index 97ff04a5972c2a35a33305bec1a3e677a66791c5..314333214d65566db8e6e35ee673a21339d7e02d 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1350_LAUNCHXL.h" #define Board_CC1350_LAUNCHXL #define BOARD_STRING "TI CC1350 LaunchPad" -#define Board_initGeneral() CC1350_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1350_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1350_LAUNCHXL_wakeUpExtFlash() @@ -56,6 +57,13 @@ extern "C" { #define Board_ADCBUF0CHANNEL1 CC1350_LAUNCHXL_ADCBUF0CHANNEL1 #define Board_CRYPTO0 CC1350_LAUNCHXL_CRYPTO0 +#define Board_AESCCM0 CC1350_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC1350_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC1350_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC1350_LAUNCHXL_AESCTR0 +#define Board_AESECB0 CC1350_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC1350_LAUNCHXL_AESCTRDRBG0 +#define Board_TRNG0 CC1350_LAUNCHXL_TRNG0 #define Board_DIO0 CC1350_LAUNCHXL_DIO0 #define Board_DIO1_RFSW CC1350_LAUNCHXL_DIO1_RF_SUB1GHZ @@ -109,6 +117,13 @@ extern "C" { #define Board_I2C0 CC1350_LAUNCHXL_I2C0 #define Board_I2C_TMP CC1350_LAUNCHXL_I2C0 +#define Board_I2S0 CC1350_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC1350_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC1350_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC1350_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC1350_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC1350_LAUNCHXL_I2S_WCLK + #define Board_PIN_BUTTON0 CC1350_LAUNCHXL_PIN_BTN1 #define Board_PIN_BUTTON1 CC1350_LAUNCHXL_PIN_BTN2 #define Board_PIN_BTN1 CC1350_LAUNCHXL_PIN_BTN1 @@ -153,10 +168,6 @@ extern "C" { #define Board_WATCHDOG0 CC1350_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.c index ff7f473516c76fdd6735e77b5b76436382b729e6..fa235667350fc94075b4c9d439a48c33a2eef797 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ #include <ti/drivers/ADCBuf.h> #include <ti/drivers/adcbuf/ADCBufCC26XX.h> -static ADCBufCC26XX_Object adcBufCC26XXobjects[CC1350_LAUNCHXL_ADCBUFCOUNT]; +ADCBufCC26XX_Object adcBufCC26xxObjects[CC1350_LAUNCHXL_ADCBUFCOUNT]; /* * This table converts a virtual adc channel into a dio and internal analogue @@ -77,22 +77,19 @@ const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[CC1350_LAUNCHXL {PIN_UNASSIGNED, ADC_COMPB_IN_VSS}, }; -const ADCBufCC26XX_HWAttrs adcBufCC26XXHWAttrs[CC1350_LAUNCHXL_ADCBUFCOUNT] = { +const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC1350_LAUNCHXL_ADCBUFCOUNT] = { { .intPriority = ~0, .swiPriority = 0, .adcChannelLut = ADCBufCC26XX_adcChannelLut, - .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER0A, - .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A, } }; const ADCBuf_Config ADCBuf_config[CC1350_LAUNCHXL_ADCBUFCOUNT] = { { &ADCBufCC26XX_fxnTable, - &adcBufCC26XXobjects[CC1350_LAUNCHXL_ADCBUF0], - //NULL, - &adcBufCC26XXHWAttrs[CC1350_LAUNCHXL_ADCBUF0] + &adcBufCC26xxObjects[CC1350_LAUNCHXL_ADCBUF0], + &adcBufCC26xxHWAttrs[CC1350_LAUNCHXL_ADCBUF0] }, }; @@ -104,7 +101,7 @@ const uint_least8_t ADCBuf_count = CC1350_LAUNCHXL_ADCBUFCOUNT; #include <ti/drivers/ADC.h> #include <ti/drivers/adc/ADCCC26XX.h> -static ADCCC26XX_Object adcCC26xxObjects[CC1350_LAUNCHXL_ADCCOUNT]; +ADCCC26XX_Object adcCC26xxObjects[CC1350_LAUNCHXL_ADCCOUNT]; const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADCCOUNT] = { { @@ -247,6 +244,170 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC1350_LAUNCHXL_CRYPTOCOUNT] = { }, }; +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC1350_LAUNCHXL_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1350_LAUNCHXL_AESCCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCCM_Config AESCCM_config[CC1350_LAUNCHXL_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC1350_LAUNCHXL_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC1350_LAUNCHXL_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC1350_LAUNCHXL_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1350_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1350_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1350_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1350_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1350_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1350_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1350_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1350_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1350_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1350_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1350_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1350_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1350_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1350_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1350_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1350_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1350_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1350_LAUNCHXL_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC1350_LAUNCHXL_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1350_LAUNCHXL_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC1350_LAUNCHXL_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC1350_LAUNCHXL_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC1350_LAUNCHXL_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC1350_LAUNCHXL_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1350_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1350_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1350_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1350_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1350_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1350_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1350_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1350_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1350_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1350_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1350_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1350_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1350_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -370,6 +531,34 @@ const uint_least8_t I2C_count = CC1350_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1350_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1350_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC1350_LAUNCHXL_I2S_ADI, + .pinSD0 = CC1350_LAUNCHXL_I2S_ADO, + .pinSCK = CC1350_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC1350_LAUNCHXL_I2S_MCLK, + .pinWS = CC1350_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1350_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1350_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1350_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1350_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -458,6 +647,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1350_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -498,8 +688,8 @@ const PIN_Config BoardGpioInitTable[] = { CC1350_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1350_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1350_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1350_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1350_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1350_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1350_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1350_LAUNCHXL_DIO1_RF_SUB1GHZ | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* RF SW Switch defaults to 2.4 GHz path*/ CC1350_LAUNCHXL_DIO30_RF_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* External RF Switch is powered off by default */ CC1350_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ @@ -518,10 +708,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -578,7 +769,7 @@ extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ /* Register the board specific callback */ .globalCallback = &rfDriverCallback, @@ -692,29 +883,6 @@ const uint_least8_t SPI_count = CC1350_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC1350_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1350_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1350_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -831,3 +999,11 @@ void CC1350_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1350_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.h index 9167a15c32a581866e0f18f67fe8e0392777c390..c6e55551487e9e5495feba09a1964aa41885de12 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,7 +91,6 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350_LAUNCHXL_PIN_BTN1 IOID_13 #define CC1350_LAUNCHXL_PIN_BTN2 IOID_14 - /* GPIO */ #define CC1350_LAUNCHXL_GPIO_LED_ON 1 #define CC1350_LAUNCHXL_GPIO_LED_OFF 0 @@ -100,6 +99,12 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350_LAUNCHXL_I2C0_SCL0 IOID_4 #define CC1350_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1350_LAUNCHXL_I2S_ADO IOID_25 +#define CC1350_LAUNCHXL_I2S_ADI IOID_26 +#define CC1350_LAUNCHXL_I2S_BCLK IOID_27 +#define CC1350_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC1350_LAUNCHXL_I2S_WCLK IOID_28 /* LEDs */ #define CC1350_LAUNCHXL_PIN_LED_ON 1 @@ -126,7 +131,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ #define CC1350_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ #define CC1350_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1350_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC1350_LAUNCHXL_SPI0_CSN IOID_11 #define CC1350_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1350_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1350_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -219,6 +224,76 @@ typedef enum CC1350_LAUNCHXL_CryptoName { CC1350_LAUNCHXL_CRYPTOCOUNT } CC1350_LAUNCHXL_CryptoName; +/*! + * @def CC1350_LAUNCHXL_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC1350_LAUNCHXL_AESCCMName { + CC1350_LAUNCHXL_AESCCM0 = 0, + + CC1350_LAUNCHXL_AESCCMCOUNT +} CC1350_LAUNCHXL_AESCCMName; + +/*! + * @def CC1350_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1350_LAUNCHXL_AESGCMName { + CC1350_LAUNCHXL_AESGCM0 = 0, + + CC1350_LAUNCHXL_AESGCMCOUNT +} CC1350_LAUNCHXL_AESGCMName; + +/*! + * @def CC1350_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1350_LAUNCHXL_AESCBCName { + CC1350_LAUNCHXL_AESCBC0 = 0, + + CC1350_LAUNCHXL_AESCBCCOUNT +} CC1350_LAUNCHXL_AESCBCName; + +/*! + * @def CC1350_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1350_LAUNCHXL_AESCTRName { + CC1350_LAUNCHXL_AESCTR0 = 0, + + CC1350_LAUNCHXL_AESCTRCOUNT +} CC1350_LAUNCHXL_AESCTRName; + +/*! + * @def CC1350_LAUNCHXL_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC1350_LAUNCHXL_AESECBName { + CC1350_LAUNCHXL_AESECB0 = 0, + + CC1350_LAUNCHXL_AESECBCOUNT +} CC1350_LAUNCHXL_AESECBName; + +/*! + * @def CC1350_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1350_LAUNCHXL_AESCTRDRBGName { + CC1350_LAUNCHXL_AESCTRDRBG0 = 0, + + CC1350_LAUNCHXL_AESCTRDRBGCOUNT +} CC1350_LAUNCHXL_AESCTRDRBGName; + +/*! + * @def CC1350_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1350_LAUNCHXL_TRNGName { + CC1350_LAUNCHXL_TRNG0 = 0, + + CC1350_LAUNCHXL_TRNGCOUNT +} CC1350_LAUNCHXL_TRNGName; + /*! * @def CC1350_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -277,6 +352,16 @@ typedef enum CC1350_LAUNCHXL_I2CName { CC1350_LAUNCHXL_I2CCOUNT } CC1350_LAUNCHXL_I2CName; +/*! + * @def CC1350_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1350_LAUNCHXL_I2SName { + CC1350_LAUNCHXL_I2S0 = 0, + + CC1350_LAUNCHXL_I2SCOUNT +} CC1350_LAUNCHXL_I2SName; + /*! * @def CC1350_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -334,16 +419,6 @@ typedef enum CC1350_LAUNCHXL_SPIName { CC1350_LAUNCHXL_SPICOUNT } CC1350_LAUNCHXL_SPIName; -/*! - * @def CC1350_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1350_LAUNCHXL_TRNGName { - CC1350_LAUNCHXL_TRNG0 = 0, - - CC1350_LAUNCHXL_TRNGCOUNT -} CC1350_LAUNCHXL_TRNGName; - /*! * @def CC1350_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL_fxns.c index 56de7c562c42f419950680f79dbd9ae30b49bb9f..0a16f6f553306c324bd18cc6ac6a70084fc24987 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1350/CC1350_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,8 @@ #include <ti/drivers/rf/RF.h> #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" @@ -167,13 +169,7 @@ void Board_initHook() #if defined(Board_RF_SUB1GHZ) /* - * Mask to be used to determine the effective value of the setup command's - * loDivider field. - */ -#define LODIVIDER_MASK 0x7F - -/* - * ======== rfDriverCallback ======== + * ======== CC1350_LAUNCHXL_rfDriverCallback ======== * This is an implementation for the CC1350 launchpad which uses a * single signal for antenna switching. */ @@ -196,7 +192,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) switch (setupCommand->common.commandNo) { case (CMD_RADIO_SETUP): case (CMD_BLE5_RADIO_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->common.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->common.loDivider; /* Sub-1 GHz, requires antenna switch high. */ if ((loDivider != 0) && (loDivider != 2)) { @@ -204,7 +200,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) } break; case (CMD_PROP_RADIO_DIV_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->prop_div.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->prop_div.loDivider; /* Sub-1 GHz, requires antenna switch high. */ if ((loDivider != 0) && (loDivider != 2)) { diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/Board.h index 40f76e18b7e2df3a6ebb6063fdad8ba608a880d4..75d8e2bc61028772db13c534ae88027ec3770238 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1352P_2_LAUNCHXL.h" #define Board_CC1352P_2_LAUNCHXL #define BOARD_STRING "TI CC1352P-2 LaunchPad" -#define Board_initGeneral() CC1352P_2_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1352P_2_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1352P_2_LAUNCHXL_wakeUpExtFlash() @@ -60,8 +61,13 @@ extern "C" { #define Board_ECDSA0 CC1352P_2_LAUNCHXL_ECDSA0 #define Board_ECJPAKE0 CC1352P_2_LAUNCHXL_ECJPAKE0 #define Board_AESCCM0 CC1352P_2_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC1352P_2_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC1352P_2_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC1352P_2_LAUNCHXL_AESCTR0 #define Board_AESECB0 CC1352P_2_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC1352P_2_LAUNCHXL_AESCTRDRBG0 #define Board_SHA20 CC1352P_2_LAUNCHXL_SHA20 +#define Board_TRNG0 CC1352P_2_LAUNCHXL_TRNG0 #define Board_DIO12 CC1352P_2_LAUNCHXL_DIO12 #define Board_DIO15 CC1352P_2_LAUNCHXL_DIO15 @@ -112,6 +118,13 @@ extern "C" { #define Board_I2C0 CC1352P_2_LAUNCHXL_I2C0 #define Board_I2C_TMP Board_I2C0 +#define Board_I2S0 CC1352P_2_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC1352P_2_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC1352P_2_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC1352P_2_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC1352P_2_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC1352P_2_LAUNCHXL_I2S_WCLK + #define Board_NVSINTERNAL CC1352P_2_LAUNCHXL_NVSCC26XX0 #define Board_NVSEXTERNAL CC1352P_2_LAUNCHXL_NVSSPI25X0 @@ -160,10 +173,6 @@ extern "C" { #define Board_WATCHDOG0 CC1352P_2_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.c index c2717cc70f6598200d1ba5c6abd2ca127ca27c5e..b76c037a2a1acfd392e874289a88a26a1ebd0623 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -200,7 +200,6 @@ ECDHCC26X2_Object ecdhCC26X2Objects[CC1352P_2_LAUNCHXL_ECDHCOUNT]; const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CC1352P_2_LAUNCHXL_ECDHCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -224,7 +223,6 @@ ECDSACC26X2_Object ecdsaCC26X2Objects[CC1352P_2_LAUNCHXL_ECDSACOUNT]; const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CC1352P_2_LAUNCHXL_ECDSACOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -248,7 +246,6 @@ ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CC1352P_2_LAUNCHXL_ECJPAKECOUNT]; const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CC1352P_2_LAUNCHXL_ECJPAKECOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -273,7 +270,6 @@ SHA2CC26X2_Object sha2CC26X2Objects[CC1352P_2_LAUNCHXL_SHA2COUNT]; const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CC1352P_2_LAUNCHXL_SHA2COUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -297,7 +293,6 @@ AESCCMCC26XX_Object aesccmCC26XXObjects[CC1352P_2_LAUNCHXL_AESCCMCOUNT]; const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESCCMCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -310,6 +305,75 @@ const AESCCM_Config AESCCM_config[CC1352P_2_LAUNCHXL_AESCCMCOUNT] = { const uint_least8_t AESCCM_count = CC1352P_2_LAUNCHXL_AESCCMCOUNT; +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1352P_2_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1352P_2_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1352P_2_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1352P_2_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1352P_2_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1352P_2_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1352P_2_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1352P_2_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1352P_2_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1352P_2_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1352P_2_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1352P_2_LAUNCHXL_AESCTRCOUNT; + /* * =============================== AESECB =============================== */ @@ -321,7 +385,6 @@ AESECBCC26XX_Object aesecbCC26XXObjects[CC1352P_2_LAUNCHXL_AESECBCOUNT]; const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1352P_2_LAUNCHXL_AESECBCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -334,6 +397,54 @@ const AESECB_Config AESECB_config[CC1352P_2_LAUNCHXL_AESECBCOUNT] = { const uint_least8_t AESECB_count = CC1352P_2_LAUNCHXL_AESECBCOUNT; +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1352P_2_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1352P_2_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1352P_2_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1352P_2_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1352P_2_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1352P_2_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1352P_2_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1352P_2_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1352P_2_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1352P_2_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1352P_2_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1352P_2_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1352P_2_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -457,6 +568,34 @@ const uint_least8_t I2C_count = CC1352P_2_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1352P_2_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1352P_2_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC1352P_2_LAUNCHXL_I2S_ADI, + .pinSD0 = CC1352P_2_LAUNCHXL_I2S_ADO, + .pinSCK = CC1352P_2_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC1352P_2_LAUNCHXL_I2S_MCLK, + .pinWS = CC1352P_2_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1352P_2_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1352P_2_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1352P_2_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1352P_2_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -545,6 +684,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1352P_2_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -585,8 +725,8 @@ const PIN_Config BoardGpioInitTable[] = { CC1352P_2_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352P_2_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352P_2_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1352P_2_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1352P_2_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1352P_2_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1352P_2_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1352P_2_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC1352P_2_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC1352P_2_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ @@ -606,10 +746,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26X2.h> +#include "clock-arch.h" const PowerCC26X2_Config PowerCC26X2_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -666,7 +807,7 @@ extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void* arg) const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ /* Register the board specific callback */ .globalCallback = &rfDriverCallback, @@ -712,18 +853,18 @@ const uint_least8_t SD_count = CC1352P_2_LAUNCHXL_SDCOUNT; * =============================== SPI DMA =============================== */ #include <ti/drivers/SPI.h> -#include <ti/drivers/spi/SPICC26XXDMA.h> +#include <ti/drivers/spi/SPICC26X2DMA.h> #if TI_SPI_CONF_ENABLE -SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1352P_2_LAUNCHXL_SPICOUNT]; +SPICC26X2DMA_Object spiCC26X2DMAObjects[CC1352P_2_LAUNCHXL_SPICOUNT]; /* * NOTE: The SPI instances below can be used by the SD driver to communicate * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF * to satisfy the SDSPI driver requirement. */ -const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352P_2_LAUNCHXL_SPICOUNT] = { +const SPICC26X2DMA_HWAttrs spiCC26X2DMAHWAttrs[CC1352P_2_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { .baseAddr = SSI0_BASE, @@ -763,16 +904,16 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352P_2_LAUNCHXL_SPICOUNT] = const SPI_Config SPI_config[CC1352P_2_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352P_2_LAUNCHXL_SPI0], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352P_2_LAUNCHXL_SPI0] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352P_2_LAUNCHXL_SPI0], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352P_2_LAUNCHXL_SPI0] }, #endif #if TI_SPI_CONF_SPI1_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352P_2_LAUNCHXL_SPI1], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352P_2_LAUNCHXL_SPI1] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352P_2_LAUNCHXL_SPI1], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352P_2_LAUNCHXL_SPI1] }, #endif }; @@ -781,29 +922,6 @@ const uint_least8_t SPI_count = CC1352P_2_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X2.h> - -TRNGCC26X2_Object trngCC26X2Object[CC1352P_2_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X2_HWAttrs trngCC26X2HWAttrs[CC1352P_2_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X2Object[0], &trngCC26X2HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1352P_2_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -947,3 +1065,11 @@ void CC1352P_2_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1352P_2_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.h index a3defe8457402f8401f626d15b2cbe2091c4d3e0..55a92fc48780208b2e427b604f7ae9965f4303c0 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,9 +98,16 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352P_2_LAUNCHXL_GPIO_LED_OFF 0 /* I2C */ -#define CC1352P_2_LAUNCHXL_I2C0_SCL0 IOID_22 +#define CC1352P_2_LAUNCHXL_I2C0_SCL0 IOID_21 #define CC1352P_2_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1352P_2_LAUNCHXL_I2S_ADO IOID_25 +#define CC1352P_2_LAUNCHXL_I2S_ADI IOID_26 +#define CC1352P_2_LAUNCHXL_I2S_BCLK IOID_27 +#define CC1352P_2_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC1352P_2_LAUNCHXL_I2S_WCLK IOID_28 + /* LEDs */ #define CC1352P_2_LAUNCHXL_PIN_LED_ON 1 #define CC1352P_2_LAUNCHXL_PIN_LED_OFF 0 @@ -123,10 +130,10 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352P_2_LAUNCHXL_FLASH_CS_OFF 1 /* SPI Board */ -#define CC1352P_2_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ -#define CC1352P_2_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ -#define CC1352P_2_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1352P_2_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC1352P_2_LAUNCHXL_SPI0_MISO IOID_8 +#define CC1352P_2_LAUNCHXL_SPI0_MOSI IOID_9 +#define CC1352P_2_LAUNCHXL_SPI0_CLK IOID_10 +#define CC1352P_2_LAUNCHXL_SPI0_CSN IOID_11 #define CC1352P_2_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1352P_2_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1352P_2_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -264,6 +271,36 @@ typedef enum CC1352P_2_LAUNCHXL_AESCCMName { CC1352P_2_LAUNCHXL_AESCCMCOUNT } CC1352P_2_LAUNCHXL_AESCCMName; +/*! + * @def CC1352P_2_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1352P_2_LAUNCHXL_AESGCMName { + CC1352P_2_LAUNCHXL_AESGCM0 = 0, + + CC1352P_2_LAUNCHXL_AESGCMCOUNT +} CC1352P_2_LAUNCHXL_AESGCMName; + +/*! + * @def CC1352P_2_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1352P_2_LAUNCHXL_AESCBCName { + CC1352P_2_LAUNCHXL_AESCBC0 = 0, + + CC1352P_2_LAUNCHXL_AESCBCCOUNT +} CC1352P_2_LAUNCHXL_AESCBCName; + +/*! + * @def CC1352P_2_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1352P_2_LAUNCHXL_AESCTRName { + CC1352P_2_LAUNCHXL_AESCTR0 = 0, + + CC1352P_2_LAUNCHXL_AESCTRCOUNT +} CC1352P_2_LAUNCHXL_AESCTRName; + /*! * @def CC1352P_2_LAUNCHXL_AESECBName * @brief Enum of AESECB names @@ -274,6 +311,16 @@ typedef enum CC1352P_2_LAUNCHXL_AESECBName { CC1352P_2_LAUNCHXL_AESECBCOUNT } CC1352P_2_LAUNCHXL_AESECBName; +/*! + * @def CC1352P_2_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1352P_2_LAUNCHXL_AESCTRDRBGName { + CC1352P_2_LAUNCHXL_AESCTRDRBG0 = 0, + + CC1352P_2_LAUNCHXL_AESCTRDRBGCOUNT +} CC1352P_2_LAUNCHXL_AESCTRDRBGName; + /*! * @def CC1352P_2_LAUNCHXL_SHA2Name * @brief Enum of SHA2 names @@ -284,6 +331,16 @@ typedef enum CC1352P_2_LAUNCHXL_SHA2Name { CC1352P_2_LAUNCHXL_SHA2COUNT } CC1352P_2_LAUNCHXL_SHA2Name; +/*! + * @def CC1352P_2_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1352P_2_LAUNCHXL_TRNGName { + CC1352P_2_LAUNCHXL_TRNG0 = 0, + + CC1352P_2_LAUNCHXL_TRNGCOUNT +} CC1352P_2_LAUNCHXL_TRNGName; + /*! * @def CC1352P_2_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -342,6 +399,16 @@ typedef enum CC1352P_2_LAUNCHXL_I2CName { CC1352P_2_LAUNCHXL_I2CCOUNT } CC1352P_2_LAUNCHXL_I2CName; +/*! + * @def CC1352P_2_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1352P_2_LAUNCHXL_I2SName { + CC1352P_2_LAUNCHXL_I2S0 = 0, + + CC1352P_2_LAUNCHXL_I2SCOUNT +} CC1352P_2_LAUNCHXL_I2SName; + /*! * @def CC1352P_2_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -399,16 +466,6 @@ typedef enum CC1352P_2_LAUNCHXL_SPIName { CC1352P_2_LAUNCHXL_SPICOUNT } CC1352P_2_LAUNCHXL_SPIName; -/*! - * @def CC1352P_2_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1352P_2_LAUNCHXL_TRNGName { - CC1352P_2_LAUNCHXL_TRNG0 = 0, - - CC1352P_2_LAUNCHXL_TRNGCOUNT -} CC1352P_2_LAUNCHXL_TRNGName; - /*! * @def CC1352P_2_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL_fxns.c index 57f545360af5c12198aaee5fad02153e643834af..e729a457e6c959fe7628f220312a8ddad7faebb1 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-2/CC1352P_2_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,8 +46,11 @@ #include <ti/drivers/rf/RF.h> #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC1352P_2_LAUNCHXL_sendExtFlashByte ======== */ @@ -152,12 +155,6 @@ void CC1352P_2_LAUNCHXL_shutDownExtFlash(void) */ #if defined(Board_RF_SUB1GHZ) -/* - * Mask to be used to determine the effective value of the setup command's - * loDivider field. - */ -#define LODIVIDER_MASK 0x7F - /* * ======== Antenna switching ======== */ @@ -176,7 +173,7 @@ void initAntennaSwitch() } /* - * ======== CC1352P1_LAUNCHXL_rfDriverCallback ======== + * ======== CC1352P_2_LAUNCHXL_rfDriverCallback ======== * Sets up the antenna switch depending on the current PHY configuration. * Truth table: * @@ -208,7 +205,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) switch (setupCommand->common.commandNo) { case (CMD_RADIO_SETUP): case (CMD_BLE5_RADIO_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->common.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->common.loDivider; /* Sub-1GHz front-end. */ if (loDivider != 0) { @@ -216,7 +213,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) } break; case (CMD_PROP_RADIO_DIV_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->prop_div.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->prop_div.loDivider; /* Sub-1GHz front-end. */ if (loDivider != 0) { diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/Board.h index de9bc8e9d2b1c0885acc76af77715a34eb50e598..a684f7a03880a6d552df4174eda3156d4cc79225 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1352P_4_LAUNCHXL.h" #define Board_CC1352P_4_LAUNCHXL #define BOARD_STRING "TI CC1352P-4 LaunchPad" -#define Board_initGeneral() CC1352P_4_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1352P_4_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1352P_4_LAUNCHXL_wakeUpExtFlash() @@ -60,8 +61,13 @@ extern "C" { #define Board_ECDSA0 CC1352P_4_LAUNCHXL_ECDSA0 #define Board_ECJPAKE0 CC1352P_4_LAUNCHXL_ECJPAKE0 #define Board_AESCCM0 CC1352P_4_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC1352P_4_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC1352P_4_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC1352P_4_LAUNCHXL_AESCTR0 #define Board_AESECB0 CC1352P_4_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC1352P_4_LAUNCHXL_AESCTRDRBG0 #define Board_SHA20 CC1352P_4_LAUNCHXL_SHA20 +#define Board_TRNG0 CC1352P_4_LAUNCHXL_TRNG0 #define Board_DIO12 CC1352P_4_LAUNCHXL_DIO12 #define Board_DIO15 CC1352P_4_LAUNCHXL_DIO15 @@ -112,6 +118,13 @@ extern "C" { #define Board_I2C0 CC1352P_4_LAUNCHXL_I2C0 #define Board_I2C_TMP Board_I2C0 +#define Board_I2S0 CC1352P_4_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC1352P_4_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC1352P_4_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC1352P_4_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC1352P_4_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC1352P_4_LAUNCHXL_I2S_WCLK + #define Board_NVSINTERNAL CC1352P_4_LAUNCHXL_NVSCC26XX0 #define Board_NVSEXTERNAL CC1352P_4_LAUNCHXL_NVSSPI25X0 @@ -160,10 +173,6 @@ extern "C" { #define Board_WATCHDOG0 CC1352P_4_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.c index bd4f43032fc10c03f7c76109fa0da16b52d512dc..2ee295ad9d61db205e421bbc128f2aadf4cf4ebe 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -200,7 +200,6 @@ ECDHCC26X2_Object ecdhCC26X2Objects[CC1352P_4_LAUNCHXL_ECDHCOUNT]; const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CC1352P_4_LAUNCHXL_ECDHCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -224,7 +223,6 @@ ECDSACC26X2_Object ecdsaCC26X2Objects[CC1352P_4_LAUNCHXL_ECDSACOUNT]; const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CC1352P_4_LAUNCHXL_ECDSACOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -248,7 +246,6 @@ ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CC1352P_4_LAUNCHXL_ECJPAKECOUNT]; const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CC1352P_4_LAUNCHXL_ECJPAKECOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -273,7 +270,6 @@ SHA2CC26X2_Object sha2CC26X2Objects[CC1352P_4_LAUNCHXL_SHA2COUNT]; const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CC1352P_4_LAUNCHXL_SHA2COUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -297,7 +293,6 @@ AESCCMCC26XX_Object aesccmCC26XXObjects[CC1352P_4_LAUNCHXL_AESCCMCOUNT]; const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESCCMCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -310,6 +305,75 @@ const AESCCM_Config AESCCM_config[CC1352P_4_LAUNCHXL_AESCCMCOUNT] = { const uint_least8_t AESCCM_count = CC1352P_4_LAUNCHXL_AESCCMCOUNT; +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1352P_4_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1352P_4_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1352P_4_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1352P_4_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1352P_4_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1352P_4_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1352P_4_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1352P_4_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1352P_4_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1352P_4_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1352P_4_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1352P_4_LAUNCHXL_AESCTRCOUNT; + /* * =============================== AESECB =============================== */ @@ -321,7 +385,6 @@ AESECBCC26XX_Object aesecbCC26XXObjects[CC1352P_4_LAUNCHXL_AESECBCOUNT]; const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1352P_4_LAUNCHXL_AESECBCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -334,6 +397,54 @@ const AESECB_Config AESECB_config[CC1352P_4_LAUNCHXL_AESECBCOUNT] = { const uint_least8_t AESECB_count = CC1352P_4_LAUNCHXL_AESECBCOUNT; +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1352P_4_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1352P_4_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1352P_4_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1352P_4_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1352P_4_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1352P_4_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1352P_4_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1352P_4_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1352P_4_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1352P_4_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1352P_4_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1352P_4_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1352P_4_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -457,6 +568,34 @@ const uint_least8_t I2C_count = CC1352P_4_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1352P_4_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1352P_4_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC1352P_4_LAUNCHXL_I2S_ADI, + .pinSD0 = CC1352P_4_LAUNCHXL_I2S_ADO, + .pinSCK = CC1352P_4_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC1352P_4_LAUNCHXL_I2S_MCLK, + .pinWS = CC1352P_4_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1352P_4_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1352P_4_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1352P_4_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1352P_4_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -545,6 +684,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1352P_4_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -585,8 +725,8 @@ const PIN_Config BoardGpioInitTable[] = { CC1352P_4_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352P_4_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352P_4_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1352P_4_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1352P_4_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1352P_4_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1352P_4_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1352P_4_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC1352P_4_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC1352P_4_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ @@ -606,10 +746,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26X2.h> +#include "clock-arch.h" const PowerCC26X2_Config PowerCC26X2_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -666,7 +807,7 @@ extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void* arg) const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ /* Register the board specific callback */ .globalCallback = &rfDriverCallback, @@ -712,18 +853,18 @@ const uint_least8_t SD_count = CC1352P_4_LAUNCHXL_SDCOUNT; * =============================== SPI DMA =============================== */ #include <ti/drivers/SPI.h> -#include <ti/drivers/spi/SPICC26XXDMA.h> - -SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1352P_4_LAUNCHXL_SPICOUNT]; +#include <ti/drivers/spi/SPICC26X2DMA.h> #if TI_SPI_CONF_ENABLE +SPICC26X2DMA_Object spiCC26X2DMAObjects[CC1352P_4_LAUNCHXL_SPICOUNT]; + /* * NOTE: The SPI instances below can be used by the SD driver to communicate * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF * to satisfy the SDSPI driver requirement. */ -const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352P_4_LAUNCHXL_SPICOUNT] = { +const SPICC26X2DMA_HWAttrs spiCC26X2DMAHWAttrs[CC1352P_4_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { .baseAddr = SSI0_BASE, @@ -763,16 +904,16 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352P_4_LAUNCHXL_SPICOUNT] = const SPI_Config SPI_config[CC1352P_4_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352P_4_LAUNCHXL_SPI0], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352P_4_LAUNCHXL_SPI0] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352P_4_LAUNCHXL_SPI0], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352P_4_LAUNCHXL_SPI0] }, #endif #if TI_SPI_CONF_SPI1_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352P_4_LAUNCHXL_SPI1], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352P_4_LAUNCHXL_SPI1] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352P_4_LAUNCHXL_SPI1], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352P_4_LAUNCHXL_SPI1] }, #endif }; @@ -781,29 +922,6 @@ const uint_least8_t SPI_count = CC1352P_4_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X2.h> - -TRNGCC26X2_Object trngCC26X2Object[CC1352P_4_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X2_HWAttrs trngCC26X2HWAttrs[CC1352P_4_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X2Object[0], &trngCC26X2HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1352P_4_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -947,3 +1065,11 @@ void CC1352P_4_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1352P_4_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.h index d33d50847467fd768280c554086cdbe84d347b58..3500ddfcfa900fa5ad6deee6da7410416fcf332c 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,6 +101,13 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352P_4_LAUNCHXL_I2C0_SCL0 IOID_21 #define CC1352P_4_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1352P_4_LAUNCHXL_I2S_ADO IOID_25 +#define CC1352P_4_LAUNCHXL_I2S_ADI IOID_26 +#define CC1352P_4_LAUNCHXL_I2S_BCLK IOID_27 +#define CC1352P_4_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC1352P_4_LAUNCHXL_I2S_WCLK IOID_28 + /* LEDs */ #define CC1352P_4_LAUNCHXL_PIN_LED_ON 1 #define CC1352P_4_LAUNCHXL_PIN_LED_OFF 0 @@ -123,10 +130,10 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352P_4_LAUNCHXL_FLASH_CS_OFF 1 /* SPI Board */ -#define CC1352P_4_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ -#define CC1352P_4_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ -#define CC1352P_4_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1352P_4_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC1352P_4_LAUNCHXL_SPI0_MISO IOID_8 +#define CC1352P_4_LAUNCHXL_SPI0_MOSI IOID_9 +#define CC1352P_4_LAUNCHXL_SPI0_CLK IOID_10 +#define CC1352P_4_LAUNCHXL_SPI0_CSN IOID_11 #define CC1352P_4_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1352P_4_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1352P_4_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -135,7 +142,7 @@ extern const PIN_Config BoardGpioInitTable[]; /* UART Board */ #define CC1352P_4_LAUNCHXL_UART0_RX IOID_12 /* RXD */ #define CC1352P_4_LAUNCHXL_UART0_TX IOID_13 /* TXD */ -#define CC1352P_4_LAUNCHXL_UART0_CTS PIN_UNASSIGNED /* CTS */ +#define CC1352P_4_LAUNCHXL_UART0_CTS IOID_19 /* CTS */ #define CC1352P_4_LAUNCHXL_UART0_RTS IOID_18 /* RTS */ #define CC1352P_4_LAUNCHXL_UART1_RX PIN_UNASSIGNED #define CC1352P_4_LAUNCHXL_UART1_TX PIN_UNASSIGNED @@ -264,6 +271,36 @@ typedef enum CC1352P_4_LAUNCHXL_AESCCMName { CC1352P_4_LAUNCHXL_AESCCMCOUNT } CC1352P_4_LAUNCHXL_AESCCMName; +/*! + * @def CC1352P_4_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1352P_4_LAUNCHXL_AESGCMName { + CC1352P_4_LAUNCHXL_AESGCM0 = 0, + + CC1352P_4_LAUNCHXL_AESGCMCOUNT +} CC1352P_4_LAUNCHXL_AESGCMName; + +/*! + * @def CC1352P_4_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1352P_4_LAUNCHXL_AESCBCName { + CC1352P_4_LAUNCHXL_AESCBC0 = 0, + + CC1352P_4_LAUNCHXL_AESCBCCOUNT +} CC1352P_4_LAUNCHXL_AESCBCName; + +/*! + * @def CC1352P_4_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1352P_4_LAUNCHXL_AESCTRName { + CC1352P_4_LAUNCHXL_AESCTR0 = 0, + + CC1352P_4_LAUNCHXL_AESCTRCOUNT +} CC1352P_4_LAUNCHXL_AESCTRName; + /*! * @def CC1352P_4_LAUNCHXL_AESECBName * @brief Enum of AESECB names @@ -274,6 +311,16 @@ typedef enum CC1352P_4_LAUNCHXL_AESECBName { CC1352P_4_LAUNCHXL_AESECBCOUNT } CC1352P_4_LAUNCHXL_AESECBName; +/*! + * @def CC1352P_4_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1352P_4_LAUNCHXL_AESCTRDRBGName { + CC1352P_4_LAUNCHXL_AESCTRDRBG0 = 0, + + CC1352P_4_LAUNCHXL_AESCTRDRBGCOUNT +} CC1352P_4_LAUNCHXL_AESCTRDRBGName; + /*! * @def CC1352P_4_LAUNCHXL_SHA2Name * @brief Enum of SHA2 names @@ -284,6 +331,16 @@ typedef enum CC1352P_4_LAUNCHXL_SHA2Name { CC1352P_4_LAUNCHXL_SHA2COUNT } CC1352P_4_LAUNCHXL_SHA2Name; +/*! + * @def CC1352P_4_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1352P_4_LAUNCHXL_TRNGName { + CC1352P_4_LAUNCHXL_TRNG0 = 0, + + CC1352P_4_LAUNCHXL_TRNGCOUNT +} CC1352P_4_LAUNCHXL_TRNGName; + /*! * @def CC1352P_4_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -342,6 +399,16 @@ typedef enum CC1352P_4_LAUNCHXL_I2CName { CC1352P_4_LAUNCHXL_I2CCOUNT } CC1352P_4_LAUNCHXL_I2CName; +/*! + * @def CC1352P_4_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1352P_4_LAUNCHXL_I2SName { + CC1352P_4_LAUNCHXL_I2S0 = 0, + + CC1352P_4_LAUNCHXL_I2SCOUNT +} CC1352P_4_LAUNCHXL_I2SName; + /*! * @def CC1352P_4_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -399,16 +466,6 @@ typedef enum CC1352P_4_LAUNCHXL_SPIName { CC1352P_4_LAUNCHXL_SPICOUNT } CC1352P_4_LAUNCHXL_SPIName; -/*! - * @def CC1352P_4_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1352P_4_LAUNCHXL_TRNGName { - CC1352P_4_LAUNCHXL_TRNG0 = 0, - - CC1352P_4_LAUNCHXL_TRNGCOUNT -} CC1352P_4_LAUNCHXL_TRNGName; - /*! * @def CC1352P_4_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL_fxns.c index eea9c3b33ea0a82328202e0adf605188f098a4a6..86126fad9a8f61fee876b7e2df18299fecd57edd 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p-4/CC1352P_4_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,8 +46,11 @@ #include <ti/drivers/rf/RF.h> #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC1352P_4_LAUNCHXL_sendExtFlashByte ======== */ @@ -152,12 +155,6 @@ void CC1352P_4_LAUNCHXL_shutDownExtFlash(void) */ #if defined(Board_RF_SUB1GHZ) -/* - * Mask to be used to determine the effective value of the setup command's - * loDivider field. - */ -#define LODIVIDER_MASK 0x7F - /* * ======== Antenna switching ======== */ @@ -176,7 +173,7 @@ void initAntennaSwitch() } /* - * ======== CC1352P1_LAUNCHXL_rfDriverCallback ======== + * ======== CC1352P_4_LAUNCHXL_rfDriverCallback ======== * Sets up the antenna switch depending on the current PHY configuration. * Truth table: * @@ -208,7 +205,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) switch (setupCommand->common.commandNo) { case (CMD_RADIO_SETUP): case (CMD_BLE5_RADIO_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->common.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->common.loDivider; /* Sub-1GHz front-end. */ if (loDivider != 0) { @@ -216,7 +213,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) } break; case (CMD_PROP_RADIO_DIV_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->prop_div.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->prop_div.loDivider; /* Sub-1GHz front-end. */ if (loDivider != 0) { diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/Board.h index db07b3a0d1d0bc390ad844b4dc21655d55ee8f3a..c12d7512aac6a9ef8d662de34b539e6a9bf8a721 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1352P1_LAUNCHXL.h" #define Board_CC1352P1_LAUNCHXL #define BOARD_STRING "TI CC1352P1 LaunchPad" -#define Board_initGeneral() CC1352P1_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1352P1_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1352P1_LAUNCHXL_wakeUpExtFlash() @@ -60,8 +61,13 @@ extern "C" { #define Board_ECDSA0 CC1352P1_LAUNCHXL_ECDSA0 #define Board_ECJPAKE0 CC1352P1_LAUNCHXL_ECJPAKE0 #define Board_AESCCM0 CC1352P1_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC1352P1_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC1352P1_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC1352P1_LAUNCHXL_AESCTR0 #define Board_AESECB0 CC1352P1_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC1352P1_LAUNCHXL_AESCTRDRBG0 #define Board_SHA20 CC1352P1_LAUNCHXL_SHA20 +#define Board_TRNG0 CC1352P1_LAUNCHXL_TRNG0 #define Board_DIO12 CC1352P1_LAUNCHXL_DIO12 #define Board_DIO15 CC1352P1_LAUNCHXL_DIO15 @@ -112,6 +118,13 @@ extern "C" { #define Board_I2C0 CC1352P1_LAUNCHXL_I2C0 #define Board_I2C_TMP Board_I2C0 +#define Board_I2S0 CC1352P1_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC1352P1_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC1352P1_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC1352P1_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC1352P1_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC1352P1_LAUNCHXL_I2S_WCLK + #define Board_NVSINTERNAL CC1352P1_LAUNCHXL_NVSCC26XX0 #define Board_NVSEXTERNAL CC1352P1_LAUNCHXL_NVSSPI25X0 @@ -160,10 +173,6 @@ extern "C" { #define Board_WATCHDOG0 CC1352P1_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.c index cff74bc036101c9197c637ae9b40e72f6ef89260..28d55e976c30e8a1bf7a93a2085663e59958fa2b 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -200,7 +200,6 @@ ECDHCC26X2_Object ecdhCC26X2Objects[CC1352P1_LAUNCHXL_ECDHCOUNT]; const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CC1352P1_LAUNCHXL_ECDHCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -224,7 +223,6 @@ ECDSACC26X2_Object ecdsaCC26X2Objects[CC1352P1_LAUNCHXL_ECDSACOUNT]; const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CC1352P1_LAUNCHXL_ECDSACOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -248,7 +246,6 @@ ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CC1352P1_LAUNCHXL_ECJPAKECOUNT]; const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CC1352P1_LAUNCHXL_ECJPAKECOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -273,7 +270,6 @@ SHA2CC26X2_Object sha2CC26X2Objects[CC1352P1_LAUNCHXL_SHA2COUNT]; const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CC1352P1_LAUNCHXL_SHA2COUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -297,7 +293,6 @@ AESCCMCC26XX_Object aesccmCC26XXObjects[CC1352P1_LAUNCHXL_AESCCMCOUNT]; const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESCCMCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -310,6 +305,75 @@ const AESCCM_Config AESCCM_config[CC1352P1_LAUNCHXL_AESCCMCOUNT] = { const uint_least8_t AESCCM_count = CC1352P1_LAUNCHXL_AESCCMCOUNT; +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1352P1_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1352P1_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1352P1_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1352P1_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1352P1_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1352P1_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1352P1_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1352P1_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1352P1_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1352P1_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1352P1_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1352P1_LAUNCHXL_AESCTRCOUNT; + /* * =============================== AESECB =============================== */ @@ -321,7 +385,6 @@ AESECBCC26XX_Object aesecbCC26XXObjects[CC1352P1_LAUNCHXL_AESECBCOUNT]; const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1352P1_LAUNCHXL_AESECBCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -334,6 +397,54 @@ const AESECB_Config AESECB_config[CC1352P1_LAUNCHXL_AESECBCOUNT] = { const uint_least8_t AESECB_count = CC1352P1_LAUNCHXL_AESECBCOUNT; +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1352P1_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1352P1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1352P1_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1352P1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1352P1_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1352P1_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1352P1_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1352P1_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1352P1_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1352P1_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1352P1_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1352P1_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1352P1_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -363,8 +474,17 @@ GPIO_PinConfig gpioPinConfigs[] = { /* SPI Flash CSN */ GPIOCC26XX_DIO_20 | GPIO_DO_NOT_CONFIG, - /* SD CS */ - GPIOCC26XX_DIO_19 | GPIO_DO_NOT_CONFIG, + /* SD CS + * On CC1352P LaunchPads, the default LaunchPad header for SD CS is not + * connected. DIO_14 is mapped to the alternate SD CS pin on the SHARP128 + * BoosterPack. To enable the alternate SD CS BoosterPack pin, you need to + * remove the SHARP128 R16 and solder it onto the unpopulated R17 instead. + * When using the SD CS in this manner, BTN-2 is unavaillable since they + * both map to DIO_14. + * Alternatively, you can jumper wire the following on the LaunchPad: + * J1.8 to DIO14 + */ + GPIOCC26XX_DIO_14 | GPIO_DO_NOT_CONFIG, }; /* @@ -457,6 +577,34 @@ const uint_least8_t I2C_count = CC1352P1_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1352P1_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1352P1_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC1352P1_LAUNCHXL_I2S_ADI, + .pinSD0 = CC1352P1_LAUNCHXL_I2S_ADO, + .pinSCK = CC1352P1_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC1352P1_LAUNCHXL_I2S_MCLK, + .pinWS = CC1352P1_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1352P1_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1352P1_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1352P1_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1352P1_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -545,6 +693,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1352P1_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -585,8 +734,8 @@ const PIN_Config BoardGpioInitTable[] = { CC1352P1_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352P1_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352P1_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1352P1_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1352P1_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1352P1_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1352P1_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1352P1_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC1352P1_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC1352P1_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ @@ -606,10 +755,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26X2.h> +#include "clock-arch.h" const PowerCC26X2_Config PowerCC26X2_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -666,7 +816,7 @@ extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void* arg) const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ /* Register the board specific callback */ .globalCallback = &rfDriverCallback, @@ -692,7 +842,7 @@ SDSPI_Object sdspiObjects[CC1352P1_LAUNCHXL_SDCOUNT]; const SDSPI_HWAttrs sdspiHWAttrs[CC1352P1_LAUNCHXL_SDCOUNT] = { { .spiIndex = CC1352P1_LAUNCHXL_SPI0, - .spiCsGpioIndex = CC1352P1_LAUNCHXL_GPIO_DIO_19 + .spiCsGpioIndex = CC1352P1_LAUNCHXL_SDSPI_CS } }; @@ -712,18 +862,18 @@ const uint_least8_t SD_count = CC1352P1_LAUNCHXL_SDCOUNT; * =============================== SPI DMA =============================== */ #include <ti/drivers/SPI.h> -#include <ti/drivers/spi/SPICC26XXDMA.h> +#include <ti/drivers/spi/SPICC26X2DMA.h> #if TI_SPI_CONF_ENABLE -SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1352P1_LAUNCHXL_SPICOUNT]; +SPICC26X2DMA_Object spiCC26X2DMAObjects[CC1352P1_LAUNCHXL_SPICOUNT]; /* * NOTE: The SPI instances below can be used by the SD driver to communicate * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF * to satisfy the SDSPI driver requirement. */ -const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352P1_LAUNCHXL_SPICOUNT] = { +const SPICC26X2DMA_HWAttrs spiCC26X2DMAHWAttrs[CC1352P1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { .baseAddr = SSI0_BASE, @@ -763,16 +913,16 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352P1_LAUNCHXL_SPICOUNT] = { const SPI_Config SPI_config[CC1352P1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352P1_LAUNCHXL_SPI0], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352P1_LAUNCHXL_SPI0] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352P1_LAUNCHXL_SPI0], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352P1_LAUNCHXL_SPI0] }, #endif #if TI_SPI_CONF_SPI1_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352P1_LAUNCHXL_SPI1], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352P1_LAUNCHXL_SPI1] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352P1_LAUNCHXL_SPI1], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352P1_LAUNCHXL_SPI1] }, #endif }; @@ -781,29 +931,6 @@ const uint_least8_t SPI_count = CC1352P1_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X2.h> - -TRNGCC26X2_Object trngCC26X2Object[CC1352P1_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X2_HWAttrs trngCC26X2HWAttrs[CC1352P1_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X2Object[0], &trngCC26X2HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1352P1_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -947,3 +1074,11 @@ void CC1352P1_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1352P1_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.h index 067a3ea87436104c4494dc9cbbe61fe2ddf5d3f3..b59f7f72b193f84fcdd6764515f91168febe9d4d 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,9 +98,16 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352P1_LAUNCHXL_GPIO_LED_OFF 0 /* I2C */ -#define CC1352P1_LAUNCHXL_I2C0_SCL0 IOID_22 +#define CC1352P1_LAUNCHXL_I2C0_SCL0 IOID_21 #define CC1352P1_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1352P1_LAUNCHXL_I2S_ADO IOID_25 +#define CC1352P1_LAUNCHXL_I2S_ADI IOID_26 +#define CC1352P1_LAUNCHXL_I2S_BCLK IOID_27 +#define CC1352P1_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC1352P1_LAUNCHXL_I2S_WCLK IOID_28 + /* LEDs */ #define CC1352P1_LAUNCHXL_PIN_LED_ON 1 #define CC1352P1_LAUNCHXL_PIN_LED_OFF 0 @@ -123,10 +130,10 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352P1_LAUNCHXL_FLASH_CS_OFF 1 /* SPI Board */ -#define CC1352P1_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ -#define CC1352P1_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ -#define CC1352P1_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1352P1_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC1352P1_LAUNCHXL_SPI0_MISO IOID_8 +#define CC1352P1_LAUNCHXL_SPI0_MOSI IOID_9 +#define CC1352P1_LAUNCHXL_SPI0_CLK IOID_10 +#define CC1352P1_LAUNCHXL_SPI0_CSN IOID_11 #define CC1352P1_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1352P1_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1352P1_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -200,8 +207,6 @@ typedef enum CC1352P1_LAUNCHXL_ADCBuf0ChannelName { CC1352P1_LAUNCHXL_ADCBUF0CHANNEL2, CC1352P1_LAUNCHXL_ADCBUF0CHANNEL3, CC1352P1_LAUNCHXL_ADCBUF0CHANNEL4, - CC1352P1_LAUNCHXL_ADCBUF0CHANNEL5, - CC1352P1_LAUNCHXL_ADCBUF0CHANNEL6, CC1352P1_LAUNCHXL_ADCBUF0CHANNELVDDS, CC1352P1_LAUNCHXL_ADCBUF0CHANNELDCOUPL, CC1352P1_LAUNCHXL_ADCBUF0CHANNELVSS, @@ -219,8 +224,6 @@ typedef enum CC1352P1_LAUNCHXL_ADCName { CC1352P1_LAUNCHXL_ADC2, CC1352P1_LAUNCHXL_ADC3, CC1352P1_LAUNCHXL_ADC4, - CC1352P1_LAUNCHXL_ADC5, - CC1352P1_LAUNCHXL_ADC6, CC1352P1_LAUNCHXL_ADCDCOUPL, CC1352P1_LAUNCHXL_ADCVSS, CC1352P1_LAUNCHXL_ADCVDDS, @@ -268,6 +271,36 @@ typedef enum CC1352P1_LAUNCHXL_AESCCMName { CC1352P1_LAUNCHXL_AESCCMCOUNT } CC1352P1_LAUNCHXL_AESCCMName; +/*! + * @def CC1352P1_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1352P1_LAUNCHXL_AESGCMName { + CC1352P1_LAUNCHXL_AESGCM0 = 0, + + CC1352P1_LAUNCHXL_AESGCMCOUNT +} CC1352P1_LAUNCHXL_AESGCMName; + +/*! + * @def CC1352P1_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1352P1_LAUNCHXL_AESCBCName { + CC1352P1_LAUNCHXL_AESCBC0 = 0, + + CC1352P1_LAUNCHXL_AESCBCCOUNT +} CC1352P1_LAUNCHXL_AESCBCName; + +/*! + * @def CC1352P1_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1352P1_LAUNCHXL_AESCTRName { + CC1352P1_LAUNCHXL_AESCTR0 = 0, + + CC1352P1_LAUNCHXL_AESCTRCOUNT +} CC1352P1_LAUNCHXL_AESCTRName; + /*! * @def CC1352P1_LAUNCHXL_AESECBName * @brief Enum of AESECB names @@ -278,6 +311,16 @@ typedef enum CC1352P1_LAUNCHXL_AESECBName { CC1352P1_LAUNCHXL_AESECBCOUNT } CC1352P1_LAUNCHXL_AESECBName; +/*! + * @def CC1352P1_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1352P1_LAUNCHXL_AESCTRDRBGName { + CC1352P1_LAUNCHXL_AESCTRDRBG0 = 0, + + CC1352P1_LAUNCHXL_AESCTRDRBGCOUNT +} CC1352P1_LAUNCHXL_AESCTRDRBGName; + /*! * @def CC1352P1_LAUNCHXL_SHA2Name * @brief Enum of SHA2 names @@ -288,6 +331,16 @@ typedef enum CC1352P1_LAUNCHXL_SHA2Name { CC1352P1_LAUNCHXL_SHA2COUNT } CC1352P1_LAUNCHXL_SHA2Name; +/*! + * @def CC1352P1_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1352P1_LAUNCHXL_TRNGName { + CC1352P1_LAUNCHXL_TRNG0 = 0, + + CC1352P1_LAUNCHXL_TRNGCOUNT +} CC1352P1_LAUNCHXL_TRNGName; + /*! * @def CC1352P1_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -300,7 +353,7 @@ typedef enum CC1352P1_LAUNCHXL_GPIOName { CC1352P1_LAUNCHXL_GPIO_LED_GREEN, CC1352P1_LAUNCHXL_GPIO_LED_RED, CC1352P1_LAUNCHXL_GPIO_SPI_FLASH_CS, - CC1352P1_LAUNCHXL_GPIO_SDSPI_CS, + CC1352P1_LAUNCHXL_SDSPI_CS, CC1352P1_LAUNCHXL_GPIOCOUNT } CC1352P1_LAUNCHXL_GPIOName; @@ -346,6 +399,16 @@ typedef enum CC1352P1_LAUNCHXL_I2CName { CC1352P1_LAUNCHXL_I2CCOUNT } CC1352P1_LAUNCHXL_I2CName; +/*! + * @def CC1352P1_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1352P1_LAUNCHXL_I2SName { + CC1352P1_LAUNCHXL_I2S0 = 0, + + CC1352P1_LAUNCHXL_I2SCOUNT +} CC1352P1_LAUNCHXL_I2SName; + /*! * @def CC1352P1_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -403,16 +466,6 @@ typedef enum CC1352P1_LAUNCHXL_SPIName { CC1352P1_LAUNCHXL_SPICOUNT } CC1352P1_LAUNCHXL_SPIName; -/*! - * @def CC1352P1_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1352P1_LAUNCHXL_TRNGName { - CC1352P1_LAUNCHXL_TRNG0 = 0, - - CC1352P1_LAUNCHXL_TRNGCOUNT -} CC1352P1_LAUNCHXL_TRNGName; - /*! * @def CC1352P1_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL_fxns.c index 795f60106290be0e5e7df99c03f8867003117694..dd6303c837854f8a1700e7b52ae15e1a63495f3c 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352p1/CC1352P1_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,8 +46,11 @@ #include <ti/drivers/rf/RF.h> #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC1352P1_LAUNCHXL_sendExtFlashByte ======== */ @@ -152,12 +155,6 @@ void CC1352P1_LAUNCHXL_shutDownExtFlash(void) */ #if defined(Board_RF_SUB1GHZ) -/* - * Mask to be used to determine the effective value of the setup command's - * loDivider field. - */ -#define LODIVIDER_MASK 0x7F - /* * ======== Antenna switching ======== */ @@ -208,7 +205,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) switch (setupCommand->common.commandNo) { case (CMD_RADIO_SETUP): case (CMD_BLE5_RADIO_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->common.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->common.loDivider; /* Sub-1GHz front-end. */ if (loDivider != 0) { @@ -216,7 +213,7 @@ void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) } break; case (CMD_PROP_RADIO_DIV_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->prop_div.loDivider; + loDivider = RF_LODIVIDER_MASK & setupCommand->prop_div.loDivider; /* Sub-1GHz front-end. */ if (loDivider != 0) { diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/Board.h index 83b27069a5d5b6038a052acacf75e76e7d5b212b..0dd959a364f4da3f57a05538cf65376d6df4d3f2 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1352R1_LAUNCHXL.h" #define Board_CC1352R1_LAUNCHXL #define BOARD_STRING "TI CC1352R1 LaunchPad" -#define Board_initGeneral() CC1352R1_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1352R1_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1352R1_LAUNCHXL_wakeUpExtFlash() @@ -59,8 +60,13 @@ extern "C" { #define Board_ECDSA0 CC1352R1_LAUNCHXL_ECDSA0 #define Board_ECJPAKE0 CC1352R1_LAUNCHXL_ECJPAKE0 #define Board_AESCCM0 CC1352R1_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC1352R1_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC1352R1_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC1352R1_LAUNCHXL_AESCTR0 #define Board_AESECB0 CC1352R1_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC1352R1_LAUNCHXL_AESCTRDRBG0 #define Board_SHA20 CC1352R1_LAUNCHXL_SHA20 +#define Board_TRNG0 CC1352R1_LAUNCHXL_TRNG0 #define Board_DIO12 CC1352R1_LAUNCHXL_DIO12 #define Board_DIO15 CC1352R1_LAUNCHXL_DIO15 @@ -76,7 +82,6 @@ extern "C" { #define Board_DIO27_ANALOG CC1352R1_LAUNCHXL_DIO27_ANALOG #define Board_DIO28_ANALOG CC1352R1_LAUNCHXL_DIO28_ANALOG #define Board_DIO29_ANALOG CC1352R1_LAUNCHXL_DIO29_ANALOG -#define Board_DIO30_RFSW CC1352R1_LAUNCHXL_DIO30_RF_SUB1GHZ /* * Board_RF_SUB1GHZ is the name generated by SysConfig. Define it @@ -108,6 +113,13 @@ extern "C" { #define Board_I2C0 CC1352R1_LAUNCHXL_I2C0 #define Board_I2C_TMP Board_I2C0 +#define Board_I2S0 CC1352R1_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC1352R1_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC1352R1_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC1352R1_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC1352R1_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC1352R1_LAUNCHXL_I2S_WCLK + #define Board_NVSINTERNAL CC1352R1_LAUNCHXL_NVSCC26XX0 #define Board_NVSEXTERNAL CC1352R1_LAUNCHXL_NVSSPI25X0 @@ -156,10 +168,6 @@ extern "C" { #define Board_WATCHDOG0 CC1352R1_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.c index f3d002206e1db089110a68e3af7fd1c316026102..9a6b944c0aef0a90b04a8bbd404f98c39c1858d9 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -222,7 +222,6 @@ ECDHCC26X2_Object ecdhCC26X2Objects[CC1352R1_LAUNCHXL_ECDHCOUNT]; const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CC1352R1_LAUNCHXL_ECDHCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -246,7 +245,6 @@ ECDSACC26X2_Object ecdsaCC26X2Objects[CC1352R1_LAUNCHXL_ECDSACOUNT]; const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CC1352R1_LAUNCHXL_ECDSACOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -270,7 +268,6 @@ ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CC1352R1_LAUNCHXL_ECJPAKECOUNT]; const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CC1352R1_LAUNCHXL_ECJPAKECOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -295,7 +292,6 @@ SHA2CC26X2_Object sha2CC26X2Objects[CC1352R1_LAUNCHXL_SHA2COUNT]; const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CC1352R1_LAUNCHXL_SHA2COUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -319,7 +315,6 @@ AESCCMCC26XX_Object aesccmCC26XXObjects[CC1352R1_LAUNCHXL_AESCCMCOUNT]; const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESCCMCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -332,6 +327,75 @@ const AESCCM_Config AESCCM_config[CC1352R1_LAUNCHXL_AESCCMCOUNT] = { const uint_least8_t AESCCM_count = CC1352R1_LAUNCHXL_AESCCMCOUNT; +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1352R1_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1352R1_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1352R1_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1352R1_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1352R1_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1352R1_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1352R1_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1352R1_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1352R1_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1352R1_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1352R1_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1352R1_LAUNCHXL_AESCTRCOUNT; + /* * =============================== AESECB =============================== */ @@ -343,7 +407,6 @@ AESECBCC26XX_Object aesecbCC26XXObjects[CC1352R1_LAUNCHXL_AESECBCOUNT]; const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1352R1_LAUNCHXL_AESECBCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -356,6 +419,54 @@ const AESECB_Config AESECB_config[CC1352R1_LAUNCHXL_AESECBCOUNT] = { const uint_least8_t AESECB_count = CC1352R1_LAUNCHXL_AESECBCOUNT; +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1352R1_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1352R1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1352R1_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1352R1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1352R1_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1352R1_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1352R1_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1352R1_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1352R1_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1352R1_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1352R1_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1352R1_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1352R1_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -479,6 +590,34 @@ const uint_least8_t I2C_count = CC1352R1_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1352R1_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1352R1_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC1352R1_LAUNCHXL_I2S_ADI, + .pinSD0 = CC1352R1_LAUNCHXL_I2S_ADO, + .pinSCK = CC1352R1_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC1352R1_LAUNCHXL_I2S_MCLK, + .pinWS = CC1352R1_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1352R1_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1352R1_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1352R1_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1352R1_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -567,6 +706,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1352R1_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -607,12 +747,11 @@ const PIN_Config BoardGpioInitTable[] = { CC1352R1_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352R1_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1352R1_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1352R1_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ - CC1352R1_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ + CC1352R1_LAUNCHXL_UART0_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ + CC1352R1_LAUNCHXL_UART0_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC1352R1_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC1352R1_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC1352R1_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ - CC1352R1_LAUNCHXL_DIO30_RF_SUB1GHZ | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* RF SW Switch defaults to 2.4GHz path */ PIN_TERMINATE }; @@ -626,10 +765,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26X2.h> +#include "clock-arch.h" const PowerCC26X2_Config PowerCC26X2_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -674,25 +814,12 @@ const uint_least8_t PWM_count = CC1352R1_LAUNCHXL_PWMCOUNT; */ #include <ti/drivers/rf/RF.h> -/* - * Board-specific callback function to set the correct antenna path. - * - * This function is called by the RF driver on global driver events. - * It contains a default implementation to set the correct antenna path. - * This function is defined in the file CC1352R1_LAUNCHXL_fxns.c - */ -extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg); - const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ - - /* Register the board specific callback */ - .globalCallback = &rfDriverCallback, - - /* Subscribe the callback to both events */ - .globalEventMask = RF_GlobalEventRadioSetup | RF_GlobalEventRadioPowerDown + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ + .globalCallback = NULL, /* No board specific callback */ + .globalEventMask = 0 /* No events subscribed to */ }; /* @@ -732,18 +859,18 @@ const uint_least8_t SD_count = CC1352R1_LAUNCHXL_SDCOUNT; * =============================== SPI DMA =============================== */ #include <ti/drivers/SPI.h> -#include <ti/drivers/spi/SPICC26XXDMA.h> +#include <ti/drivers/spi/SPICC26X2DMA.h> #if TI_SPI_CONF_ENABLE -SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1352R1_LAUNCHXL_SPICOUNT]; +SPICC26X2DMA_Object spiCC26X2DMAObjects[CC1352R1_LAUNCHXL_SPICOUNT]; /* * NOTE: The SPI instances below can be used by the SD driver to communicate * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF * to satisfy the SDSPI driver requirement. */ -const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352R1_LAUNCHXL_SPICOUNT] = { +const SPICC26X2DMA_HWAttrs spiCC26X2DMAHWAttrs[CC1352R1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { .baseAddr = SSI0_BASE, @@ -783,16 +910,16 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1352R1_LAUNCHXL_SPICOUNT] = { const SPI_Config SPI_config[CC1352R1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352R1_LAUNCHXL_SPI0], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352R1_LAUNCHXL_SPI0] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352R1_LAUNCHXL_SPI0], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352R1_LAUNCHXL_SPI0] }, #endif #if TI_SPI_CONF_SPI1_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC1352R1_LAUNCHXL_SPI1], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC1352R1_LAUNCHXL_SPI1] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC1352R1_LAUNCHXL_SPI1], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC1352R1_LAUNCHXL_SPI1] }, #endif }; @@ -801,29 +928,6 @@ const uint_least8_t SPI_count = CC1352R1_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X2.h> - -TRNGCC26X2_Object trngCC26X2Object[CC1352R1_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X2_HWAttrs trngCC26X2HWAttrs[CC1352R1_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X2Object[0], &trngCC26X2HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1352R1_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -967,3 +1071,11 @@ void CC1352R1_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1352R1_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.h index b6362cf9f53a9c65d1f658832aaffba34e25a763..4e2739a4e9edf059aa4adea41e0f749698d67b84 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -78,9 +78,6 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352R1_LAUNCHXL_DIO28_ANALOG IOID_28 #define CC1352R1_LAUNCHXL_DIO29_ANALOG IOID_29 -/* Antenna switch */ -#define CC1352R1_LAUNCHXL_DIO30_RF_SUB1GHZ IOID_30 - /* Digital IOs */ #define CC1352R1_LAUNCHXL_DIO12 IOID_12 #define CC1352R1_LAUNCHXL_DIO15 IOID_15 @@ -88,6 +85,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352R1_LAUNCHXL_DIO17_TDI IOID_17 #define CC1352R1_LAUNCHXL_DIO21 IOID_21 #define CC1352R1_LAUNCHXL_DIO22 IOID_22 +#define CC1352R1_LAUNCHXL_DIO30 IOID_30 /* Discrete Inputs */ #define CC1352R1_LAUNCHXL_PIN_BTN1 IOID_15 @@ -101,6 +99,12 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352R1_LAUNCHXL_I2C0_SCL0 IOID_4 #define CC1352R1_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC1352R1_LAUNCHXL_I2S_ADO IOID_25 +#define CC1352R1_LAUNCHXL_I2S_ADI IOID_26 +#define CC1352R1_LAUNCHXL_I2S_BCLK IOID_27 +#define CC1352R1_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC1352R1_LAUNCHXL_I2S_WCLK IOID_28 /* LEDs */ #define CC1352R1_LAUNCHXL_PIN_LED_ON 1 @@ -127,7 +131,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1352R1_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ #define CC1352R1_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ #define CC1352R1_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC1352R1_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC1352R1_LAUNCHXL_SPI0_CSN IOID_11 #define CC1352R1_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC1352R1_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC1352R1_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -259,6 +263,36 @@ typedef enum CC1352R1_LAUNCHXL_AESCCMName { CC1352R1_LAUNCHXL_AESCCMCOUNT } CC1352R1_LAUNCHXL_AESCCMName; +/*! + * @def CC1352R1_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1352R1_LAUNCHXL_AESGCMName { + CC1352R1_LAUNCHXL_AESGCM0 = 0, + + CC1352R1_LAUNCHXL_AESGCMCOUNT +} CC1352R1_LAUNCHXL_AESGCMName; + +/*! + * @def CC1352R1_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1352R1_LAUNCHXL_AESCBCName { + CC1352R1_LAUNCHXL_AESCBC0 = 0, + + CC1352R1_LAUNCHXL_AESCBCCOUNT +} CC1352R1_LAUNCHXL_AESCBCName; + +/*! + * @def CC1352R1_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1352R1_LAUNCHXL_AESCTRName { + CC1352R1_LAUNCHXL_AESCTR0 = 0, + + CC1352R1_LAUNCHXL_AESCTRCOUNT +} CC1352R1_LAUNCHXL_AESCTRName; + /*! * @def CC1352R1_LAUNCHXL_AESECBName * @brief Enum of AESECB names @@ -269,6 +303,16 @@ typedef enum CC1352R1_LAUNCHXL_AESECBName { CC1352R1_LAUNCHXL_AESECBCOUNT } CC1352R1_LAUNCHXL_AESECBName; +/*! + * @def CC1352R1_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1352R1_LAUNCHXL_AESCTRDRBGName { + CC1352R1_LAUNCHXL_AESCTRDRBG0 = 0, + + CC1352R1_LAUNCHXL_AESCTRDRBGCOUNT +} CC1352R1_LAUNCHXL_AESCTRDRBGName; + /*! * @def CC1352R1_LAUNCHXL_SHA2Name * @brief Enum of SHA2 names @@ -279,6 +323,16 @@ typedef enum CC1352R1_LAUNCHXL_SHA2Name { CC1352R1_LAUNCHXL_SHA2COUNT } CC1352R1_LAUNCHXL_SHA2Name; +/*! + * @def CC1352R1_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1352R1_LAUNCHXL_TRNGName { + CC1352R1_LAUNCHXL_TRNG0 = 0, + + CC1352R1_LAUNCHXL_TRNGCOUNT +} CC1352R1_LAUNCHXL_TRNGName; + /*! * @def CC1352R1_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -337,6 +391,26 @@ typedef enum CC1352R1_LAUNCHXL_I2CName { CC1352R1_LAUNCHXL_I2CCOUNT } CC1352R1_LAUNCHXL_I2CName; +/*! + * @def CC1352R1_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1352R1_LAUNCHXL_I2SName { + CC1352R1_LAUNCHXL_I2S0 = 0, + + CC1352R1_LAUNCHXL_I2SCOUNT +} CC1352R1_LAUNCHXL_I2SName; + +/*! + * @def CC1352R1_LAUNCHXL_PDMName + * @brief Enum of I2S names + */ +typedef enum CC1352R1_LAUNCHXL_PDMCOUNT { + CC1352R1_LAUNCHXL_PDM0 = 0, + + CC1352R1_LAUNCHXL_PDMCOUNT +} CC1352R1_LAUNCHXL_PDMName; + /*! * @def CC1352R1_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -394,16 +468,6 @@ typedef enum CC1352R1_LAUNCHXL_SPIName { CC1352R1_LAUNCHXL_SPICOUNT } CC1352R1_LAUNCHXL_SPIName; -/*! - * @def CC1352R1_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1352R1_LAUNCHXL_TRNGName { - CC1352R1_LAUNCHXL_TRNG0 = 0, - - CC1352R1_LAUNCHXL_TRNGCOUNT -} CC1352R1_LAUNCHXL_TRNGName; - /*! * @def CC1352R1_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL_fxns.c index 79d97d7b634ab0d08c316bcb5d13f0b812c6349f..c84b113f4960f695a5ce799de03c2027db40a589 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc1352r1/CC1352R1_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,8 +46,11 @@ #include <ti/drivers/rf/RF.h> #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC1352R1_LAUNCHXL_sendExtFlashByte ======== */ @@ -156,70 +159,3 @@ void Board_initHook() { CC1352R1_LAUNCHXL_shutDownExtFlash(); } - -/* - * For the SysConfig generated Board.h file, Board_RF_SUB1GHZ will not be - * defined unless the RF module is added to the configuration. Therefore, - * we don't include this code if Board_RF_SUB1GHZ is not defined. - */ -#if defined(Board_RF_SUB1GHZ) - -/* - * Mask to be used to determine the effective value of the setup command's - * loDivider field. - */ -#define LODIVIDER_MASK 0x7F - -/* - * ======== rfDriverCallback ======== - * This is an implementation for the CC1352R launchpad which uses a - * single signal for antenna switching. - */ -void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) -{ - /* Decode input arguments. */ - (void)client; - RF_RadioSetup* setupCommand = (RF_RadioSetup*)arg; - - /* Local variable. */ - bool sub1GHz = false; - uint8_t loDivider = 0; - - if (events & RF_GlobalEventRadioSetup) { - /* Decision about the frequency band shall be made based on the - loDivider field. */ - switch (setupCommand->common.commandNo) { - case (CMD_RADIO_SETUP): - case (CMD_BLE5_RADIO_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->common.loDivider; - - /* Sub-1GHz front-end. */ - if (loDivider != 0) { - sub1GHz = true; - } - break; - case (CMD_PROP_RADIO_DIV_SETUP): - loDivider = LODIVIDER_MASK & setupCommand->prop_div.loDivider; - - /* Sub-1GHz front-end. */ - if (loDivider != 0) { - sub1GHz = true; - } - break; - default:break; - } - - /* Select the correct antenna. */ - if (sub1GHz) { - PINCC26XX_setOutputValue(Board_RF_SUB1GHZ, 1); - } - else { - PINCC26XX_setOutputValue(Board_RF_SUB1GHZ, 0); - } - } - else if (events & RF_GlobalEventRadioPowerDown) { - /* Set the antenna to 2.4 GHz as default. */ - PINCC26XX_setOutputValue(Board_RF_SUB1GHZ, 0); - } -} -#endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/Board.h index 577ce04223290afc9027f9fb66d416d846f3b7ad..ba4b1bae8804eddec76a24f6ed5fc90fe4d2921d 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC2650_LAUNCHXL.h" #define Board_CC2650_LAUNCHXL #define BOARD_STRING "TI CC2650 LaunchPad" -#define Board_initGeneral() CC2650_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC2650_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC2650_LAUNCHXL_wakeUpExtFlash() @@ -56,9 +57,16 @@ extern "C" { #define Board_ADCBUF0CHANNEL1 CC2650_LAUNCHXL_ADCBUF0CHANNEL1 #define Board_CRYPTO0 CC2650_LAUNCHXL_CRYPTO0 +#define Board_AESCCM0 CC2650_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC2650_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC2650_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC2650_LAUNCHXL_AESCTR0 +#define Board_AESECB0 CC2650_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC2650_LAUNCHXL_AESCTRDRBG0 +#define Board_TRNG0 CC2650_LAUNCHXL_TRNG0 #define Board_DIO0 CC2650_LAUNCHXL_DIO0 -#define Board_DIO1_RFSW CC2650_LAUNCHXL_DIO1_RFSW +#define Board_DIO1 CC2650_LAUNCHXL_DIO1 #define Board_DIO12 CC2650_LAUNCHXL_DIO12 #define Board_DIO15 CC2650_LAUNCHXL_DIO15 #define Board_DIO16_TDO CC2650_LAUNCHXL_DIO16_TDO @@ -95,11 +103,18 @@ extern "C" { #define Board_GPTIMER3A CC2650_LAUNCHXL_GPTIMER3A #define Board_GPTIMER3B CC2650_LAUNCHXL_GPTIMER3B +#define Board_NVSINTERNAL CC2650_LAUNCHXL_NVSCC26XX0 +#define Board_NVSEXTERNAL CC2650_LAUNCHXL_NVSSPI25X0 + #define Board_I2C0 CC2650_LAUNCHXL_I2C0 #define Board_I2C_TMP CC2650_LAUNCHXL_I2C0 -#define Board_NVSINTERNAL CC2650_LAUNCHXL_NVSCC26XX0 -#define Board_NVSEXTERNAL CC2650_LAUNCHXL_NVSSPI25X0 +#define Board_I2S0 CC2650_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC2650_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC2650_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC2650_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC2650_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC2650_LAUNCHXL_I2S_WCLK #define Board_PIN_BUTTON0 CC2650_LAUNCHXL_PIN_BTN1 #define Board_PIN_BUTTON1 CC2650_LAUNCHXL_PIN_BTN2 @@ -133,8 +148,8 @@ extern "C" { #define Board_SPI1_CLK CC2650_LAUNCHXL_SPI1_CLK #define Board_SPI1_CSN CC2650_LAUNCHXL_SPI1_CSN #define Board_SPI_FLASH_CS CC2650_LAUNCHXL_SPI_FLASH_CS -#define Board_FLASH_CS_ON 0 -#define Board_FLASH_CS_OFF 1 +#define Board_FLASH_CS_ON (0) +#define Board_FLASH_CS_OFF (1) #define Board_SPI_MASTER CC2650_LAUNCHXL_SPI0 #define Board_SPI_SLAVE CC2650_LAUNCHXL_SPI0 @@ -145,10 +160,6 @@ extern "C" { #define Board_WATCHDOG0 CC2650_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.c index 02fd96471bb64aa4ad25ec5afb76d7617a5486c4..a25d5215d013f52fd10dd36ced7336d8d03d4567 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, Texas Instruments Incorporated + * Copyright (c) 2016-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ */ /* - * ====================== CC2650_LAUNCHXL.c =================================== + * ============================ CC2650_LAUNCHXL.c ============================ * This file is responsible for setting up the board specific items for the * CC2650_LAUNCHXL board. */ @@ -54,7 +54,7 @@ #include <ti/drivers/ADCBuf.h> #include <ti/drivers/adcbuf/ADCBufCC26XX.h> -ADCBufCC26XX_Object adcBufCC26xxObjects[CC2650_LAUNCHXL_ADCBUFCOUNT]; +ADCBufCC26XX_Object adcBufCC26XXobjects[CC2650_LAUNCHXL_ADCBUFCOUNT]; /* * This table converts a virtual adc channel into a dio and internal analogue @@ -77,21 +77,19 @@ const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[CC2650_LAUNCHXL {PIN_UNASSIGNED, ADC_COMPB_IN_VSS}, }; -const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC2650_LAUNCHXL_ADCBUFCOUNT] = { +const ADCBufCC26XX_HWAttrs adcBufCC26XXHWAttrs[CC2650_LAUNCHXL_ADCBUFCOUNT] = { { .intPriority = ~0, .swiPriority = 0, .adcChannelLut = ADCBufCC26XX_adcChannelLut, - .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER0A, - .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A, } }; const ADCBuf_Config ADCBuf_config[CC2650_LAUNCHXL_ADCBUFCOUNT] = { { &ADCBufCC26XX_fxnTable, - &adcBufCC26xxObjects[CC2650_LAUNCHXL_ADCBUF0], - &adcBufCC26xxHWAttrs[CC2650_LAUNCHXL_ADCBUF0] + &adcBufCC26XXobjects[CC2650_LAUNCHXL_ADCBUF0], + &adcBufCC26XXHWAttrs[CC2650_LAUNCHXL_ADCBUF0] }, }; @@ -246,6 +244,170 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC2650_LAUNCHXL_CRYPTOCOUNT] = { }, }; +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC2650_LAUNCHXL_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC2650_LAUNCHXL_AESCCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCCM_Config AESCCM_config[CC2650_LAUNCHXL_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC2650_LAUNCHXL_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC2650_LAUNCHXL_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC2650_LAUNCHXL_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC2650_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC2650_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC2650_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC2650_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC2650_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC2650_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC2650_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC2650_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC2650_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC2650_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC2650_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC2650_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC2650_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC2650_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC2650_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC2650_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC2650_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC2650_LAUNCHXL_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC2650_LAUNCHXL_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC2650_LAUNCHXL_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC2650_LAUNCHXL_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC2650_LAUNCHXL_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC2650_LAUNCHXL_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC2650_LAUNCHXL_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC2650_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC2650_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC2650_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC2650_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC2650_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC2650_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC2650_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC2650_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC2650_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC2650_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC2650_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC2650_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC2650_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -257,7 +419,7 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC2650_LAUNCHXL_CRYPTOCOUNT] = { * NOTE: The order of the pin configurations must coincide with what was * defined in CC2650_LAUNCHXL.h * NOTE: Pins not used for interrupts should be placed at the end of the - * array. Callback entries can be omitted from callbacks array to + * array. Callback entries can be omitted from callbacks array to * reduce memory usage. */ GPIO_PinConfig gpioPinConfigs[] = { @@ -282,23 +444,23 @@ GPIO_PinConfig gpioPinConfigs[] = { /* * Array of callback function pointers * NOTE: The order of the pin configurations must coincide with what was - * defined in CC2650_LAUNCH.h + * defined in CC2650_LAUNCHXL.h * NOTE: Pins not used for interrupts can be omitted from callbacks array to * reduce memory usage (if placed at end of gpioPinConfigs array). */ GPIO_CallbackFxn gpioCallbackFunctions[] = { - NULL, /* Button 0 */ - NULL, /* Button 1 */ + NULL, /* Button 0 */ + NULL, /* Button 1 */ NULL, /* CC2650_LAUNCHXL_SPI_MASTER_READY */ NULL, /* CC2650_LAUNCHXL_SPI_SLAVE_READY */ }; const GPIOCC26XX_Config GPIOCC26XX_config = { - .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs, - .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions, - .numberOfPinConfigs = CC2650_LAUNCHXL_GPIOCOUNT, - .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn), - .intPriority = (~0) + .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs, + .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions, + .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig), + .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn), + .intPriority = (~0) }; /* @@ -369,6 +531,34 @@ const uint_least8_t I2C_count = CC2650_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC2650_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC2650_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC2650_LAUNCHXL_I2S_ADI, + .pinSD0 = CC2650_LAUNCHXL_I2S_ADO, + .pinSCK = CC2650_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC2650_LAUNCHXL_I2S_MCLK, + .pinWS = CC2650_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC2650_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC2650_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC2650_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC2650_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -457,10 +647,11 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC2650_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; -#endif /* Board_EXCLUDE_NVS_EXTERNAL_FLASH */ +#endif /* TI_NVS_CONF_NVS_EXTERNAL_ENABLE */ /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */ const NVS_Config NVS_config[CC2650_LAUNCHXL_NVSCOUNT] = { @@ -497,7 +688,7 @@ const PIN_Config BoardGpioInitTable[] = { CC2650_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC2650_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC2650_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC2650_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */ + CC2650_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ CC2650_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ CC2650_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC2650_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ @@ -516,10 +707,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -567,7 +759,7 @@ const uint_least8_t PWM_count = CC2650_LAUNCHXL_PWMCOUNT; const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ .globalCallback = NULL, /* No board specific callback */ .globalEventMask = 0 /* No events subscribed to */ }; @@ -678,29 +870,6 @@ const uint_least8_t SPI_count = CC2650_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC2650_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC2650_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC2650_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -819,3 +988,11 @@ void CC2650_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC2650_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.h index 8c440aa9d61376a5285b937ad6694bcb4375c610..cff8eaba4e098f30f574cf46d027878cbc82b358 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650_LAUNCHXL /* Mapping of pins to board signals using general board aliases - * <board signal alias> <pin mapping> + * <board signal alias> <pin mapping> <comments> */ /* Analog Capable DIOs */ @@ -78,7 +78,7 @@ extern const PIN_Config BoardGpioInitTable[]; /* Digital IOs */ #define CC2650_LAUNCHXL_DIO0 IOID_0 -#define CC2650_LAUNCHXL_DIO1_RFSW IOID_1 +#define CC2650_LAUNCHXL_DIO1 IOID_1 #define CC2650_LAUNCHXL_DIO12 IOID_12 #define CC2650_LAUNCHXL_DIO15 IOID_15 #define CC2650_LAUNCHXL_DIO16_TDO IOID_16 @@ -98,6 +98,13 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650_LAUNCHXL_I2C0_SCL0 IOID_4 #define CC2650_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC2650_LAUNCHXL_I2S_ADO IOID_25 +#define CC2650_LAUNCHXL_I2S_ADI IOID_26 +#define CC2650_LAUNCHXL_I2S_BCLK IOID_27 +#define CC2650_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC2650_LAUNCHXL_I2S_WCLK IOID_28 + /* LEDs */ #define CC2650_LAUNCHXL_PIN_LED_ON 1 #define CC2650_LAUNCHXL_PIN_LED_OFF 0 @@ -123,7 +130,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ #define CC2650_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ #define CC2650_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC2650_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC2650_LAUNCHXL_SPI0_CSN IOID_11 #define CC2650_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC2650_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC2650_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -158,7 +165,7 @@ void CC2650_LAUNCHXL_wakeUpExtFlash(void); /*! * @def CC2650_LAUNCHXL_ADCBufName - * @brief Enum of ADCs + * @brief Enum of ADCBufs */ typedef enum CC2650_LAUNCHXL_ADCBufName { CC2650_LAUNCHXL_ADCBUF0 = 0, @@ -216,6 +223,76 @@ typedef enum CC2650_LAUNCHXL_CryptoName { CC2650_LAUNCHXL_CRYPTOCOUNT } CC2650_LAUNCHXL_CryptoName; +/*! + * @def CC2650_LAUNCHXL_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC2650_LAUNCHXL_AESCCMName { + CC2650_LAUNCHXL_AESCCM0 = 0, + + CC2650_LAUNCHXL_AESCCMCOUNT +} CC2650_LAUNCHXL_AESCCMName; + +/*! + * @def CC2650_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC2650_LAUNCHXL_AESGCMName { + CC2650_LAUNCHXL_AESGCM0 = 0, + + CC2650_LAUNCHXL_AESGCMCOUNT +} CC2650_LAUNCHXL_AESGCMName; + +/*! + * @def CC2650_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC2650_LAUNCHXL_AESCBCName { + CC2650_LAUNCHXL_AESCBC0 = 0, + + CC2650_LAUNCHXL_AESCBCCOUNT +} CC2650_LAUNCHXL_AESCBCName; + +/*! + * @def CC2650_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC2650_LAUNCHXL_AESCTRName { + CC2650_LAUNCHXL_AESCTR0 = 0, + + CC2650_LAUNCHXL_AESCTRCOUNT +} CC2650_LAUNCHXL_AESCTRName; + +/*! + * @def CC2650_LAUNCHXL_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC2650_LAUNCHXL_AESECBName { + CC2650_LAUNCHXL_AESECB0 = 0, + + CC2650_LAUNCHXL_AESECBCOUNT +} CC2650_LAUNCHXL_AESECBName; + +/*! + * @def CC2650_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC2650_LAUNCHXL_AESCTRDRBGName { + CC2650_LAUNCHXL_AESCTRDRBG0 = 0, + + CC2650_LAUNCHXL_AESCTRDRBGCOUNT +} CC2650_LAUNCHXL_AESCTRDRBGName; + +/*! + * @def CC2650_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC2650_LAUNCHXL_TRNGName { + CC2650_LAUNCHXL_TRNG0 = 0, + + CC2650_LAUNCHXL_TRNGCOUNT +} CC2650_LAUNCHXL_TRNGName; + /*! * @def CC2650_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -274,6 +351,16 @@ typedef enum CC2650_LAUNCHXL_I2CName { CC2650_LAUNCHXL_I2CCOUNT } CC2650_LAUNCHXL_I2CName; +/*! + * @def CC2650_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC2650_LAUNCHXL_I2SName { + CC2650_LAUNCHXL_I2S0 = 0, + + CC2650_LAUNCHXL_I2SCOUNT +} CC2650_LAUNCHXL_I2SName; + /*! * @def CC2650_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -331,16 +418,6 @@ typedef enum CC2650_LAUNCHXL_SPIName { CC2650_LAUNCHXL_SPICOUNT } CC2650_LAUNCHXL_SPIName; -/*! - * @def CC2650_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC2650_LAUNCHXL_TRNGName { - CC2650_LAUNCHXL_TRNG0 = 0, - - CC2650_LAUNCHXL_TRNGCOUNT -} CC2650_LAUNCHXL_TRNGName; - /*! * @def CC2650_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL_fxns.c index f471e33d6bf2e01892c88f7b0026eb9460eec5fe..eac51b87191249b78e26ff2cb9c4d280f6eea7fa 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc2650/CC2650_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ */ /* - * ======== CC2650_LAUNCHXL_fxns.c ======== + * =================== CC2650_LAUNCHXL_fxns.c ============================ * This file contains the board-specific initialization functions. */ @@ -45,8 +45,11 @@ #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC2650_LAUNCHXL_sendExtFlashByte ======== */ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/Board.h index ddf5e4946bd62f3ad93f64cbd623aef1ac4385ba..249196b707abd8fdc7c87a657ebb31621403cb7b 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC26X2R1_LAUNCHXL.h" #define Board_CC26X2R1_LAUNCHXL #define BOARD_STRING "TI CC26x2R1 LaunchPad" -#define Board_initGeneral() CC26X2R1_LAUNCHXL_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC26X2R1_LAUNCHXL_shutDownExtFlash() #define Board_wakeUpExtFlash() CC26X2R1_LAUNCHXL_wakeUpExtFlash() @@ -59,8 +60,13 @@ extern "C" { #define Board_ECDSA0 CC26X2R1_LAUNCHXL_ECDSA0 #define Board_ECJPAKE0 CC26X2R1_LAUNCHXL_ECJPAKE0 #define Board_AESCCM0 CC26X2R1_LAUNCHXL_AESCCM0 +#define Board_AESGCM0 CC26X2R1_LAUNCHXL_AESGCM0 +#define Board_AESCBC0 CC26X2R1_LAUNCHXL_AESCBC0 +#define Board_AESCTR0 CC26X2R1_LAUNCHXL_AESCTR0 #define Board_AESECB0 CC26X2R1_LAUNCHXL_AESECB0 +#define Board_AESCTRDRBG0 CC26X2R1_LAUNCHXL_AESCTRDRBG0 #define Board_SHA20 CC26X2R1_LAUNCHXL_SHA20 +#define Board_TRNG0 CC26X2R1_LAUNCHXL_TRNG0 #define Board_DIO0 CC26X2R1_LAUNCHXL_DIO0 #define Board_DIO1_RFSW CC26X2R1_LAUNCHXL_DIO1_RFSW @@ -104,6 +110,12 @@ extern "C" { #define Board_I2C0 CC26X2R1_LAUNCHXL_I2C0 #define Board_I2C_TMP Board_I2C0 +#define Board_I2S0 CC26X2R1_LAUNCHXL_I2S0 +#define Board_I2S_ADO CC26X2R1_LAUNCHXL_I2S_ADO +#define Board_I2S_ADI CC26X2R1_LAUNCHXL_I2S_ADI +#define Board_I2S_BCLK CC26X2R1_LAUNCHXL_I2S_BCLK +#define Board_I2S_MCLK CC26X2R1_LAUNCHXL_I2S_MCLK +#define Board_I2S_WCLK CC26X2R1_LAUNCHXL_I2S_WCLK #define Board_NVSINTERNAL CC26X2R1_LAUNCHXL_NVSCC26XX0 #define Board_NVSEXTERNAL CC26X2R1_LAUNCHXL_NVSSPI25X0 @@ -152,10 +164,6 @@ extern "C" { #define Board_WATCHDOG0 CC26X2R1_LAUNCHXL_WATCHDOG0 -/* Board specific I2C addresses */ -#define Board_TMP_ADDR (0x40) -#define Board_SENSORS_BP_TMP_ADDR Board_TMP_ADDR - #ifdef __cplusplus } #endif diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.c index 854d1d2ba22dbbe152cfbc19678fbabe6bb2fab1..31b903506f5943369b661f071d239136a837b06a 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, Texas Instruments Incorporated + * Copyright (c) 2016-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -234,7 +234,6 @@ ECDHCC26X2_Object ecdhCC26X2Objects[CC26X2R1_LAUNCHXL_ECDHCOUNT]; const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CC26X2R1_LAUNCHXL_ECDHCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -258,7 +257,6 @@ ECDSACC26X2_Object ecdsaCC26X2Objects[CC26X2R1_LAUNCHXL_ECDSACOUNT]; const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CC26X2R1_LAUNCHXL_ECDSACOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -282,7 +280,6 @@ ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CC26X2R1_LAUNCHXL_ECJPAKECOUNT]; const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CC26X2R1_LAUNCHXL_ECJPAKECOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -306,7 +303,6 @@ SHA2CC26X2_Object sha2CC26X2Objects[CC26X2R1_LAUNCHXL_SHA2COUNT]; const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CC26X2R1_LAUNCHXL_SHA2COUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -330,7 +326,6 @@ AESCCMCC26XX_Object aesccmCC26XXObjects[CC26X2R1_LAUNCHXL_AESCCMCOUNT]; const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESCCMCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -343,6 +338,75 @@ const AESCCM_Config AESCCM_config[CC26X2R1_LAUNCHXL_AESCCMCOUNT] = { const uint_least8_t AESCCM_count = CC26X2R1_LAUNCHXL_AESCCMCOUNT; +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC26X2R1_LAUNCHXL_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC26X2R1_LAUNCHXL_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC26X2R1_LAUNCHXL_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC26X2R1_LAUNCHXL_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC26X2R1_LAUNCHXL_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC26X2R1_LAUNCHXL_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC26X2R1_LAUNCHXL_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC26X2R1_LAUNCHXL_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC26X2R1_LAUNCHXL_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC26X2R1_LAUNCHXL_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC26X2R1_LAUNCHXL_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC26X2R1_LAUNCHXL_AESCTRCOUNT; + /* * =============================== AESECB =============================== */ @@ -354,7 +418,6 @@ AESECBCC26XX_Object aesecbCC26XXObjects[CC26X2R1_LAUNCHXL_AESECBCOUNT]; const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC26X2R1_LAUNCHXL_AESECBCOUNT] = { { .intPriority = ~0, - .swiPriority = 0, } }; @@ -367,6 +430,54 @@ const AESECB_Config AESECB_config[CC26X2R1_LAUNCHXL_AESECBCOUNT] = { const uint_least8_t AESECB_count = CC26X2R1_LAUNCHXL_AESECBCOUNT; +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC26X2R1_LAUNCHXL_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC26X2R1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC26X2R1_LAUNCHXL_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC26X2R1_LAUNCHXL_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC26X2R1_LAUNCHXL_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC26X2R1_LAUNCHXL_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC26X2R1_LAUNCHXL_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC26X2R1_LAUNCHXL_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC26X2R1_LAUNCHXL_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC26X2R1_LAUNCHXL_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC26X2R1_LAUNCHXL_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC26X2R1_LAUNCHXL_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC26X2R1_LAUNCHXL_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -490,6 +601,34 @@ const uint_least8_t I2C_count = CC26X2R1_LAUNCHXL_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC26X2R1_LAUNCHXL_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC26X2R1_LAUNCHXL_I2SCOUNT] = { + { + .pinSD1 = CC26X2R1_LAUNCHXL_I2S_ADI, + .pinSD0 = CC26X2R1_LAUNCHXL_I2S_ADO, + .pinSCK = CC26X2R1_LAUNCHXL_I2S_BCLK, + .pinMCLK = CC26X2R1_LAUNCHXL_I2S_MCLK, + .pinWS = CC26X2R1_LAUNCHXL_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC26X2R1_LAUNCHXL_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC26X2R1_LAUNCHXL_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC26X2R1_LAUNCHXL_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC26X2R1_LAUNCHXL_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -578,6 +717,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC26X2R1_LAUNCHXL_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -637,10 +777,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26X2.h> +#include "clock-arch.h" const PowerCC26X2_Config PowerCC26X2_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -688,7 +829,7 @@ const uint_least8_t PWM_count = CC26X2R1_LAUNCHXL_PWMCOUNT; const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { .hwiPriority = ~0, /* Lowest HWI priority */ .swiPriority = 0, /* Lowest SWI priority */ - .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */ + .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in standby */ .globalCallback = NULL, /* No board specific callback */ .globalEventMask = 0 /* No events subscribed to */ }; @@ -730,18 +871,18 @@ const uint_least8_t SD_count = CC26X2R1_LAUNCHXL_SDCOUNT; * =============================== SPI DMA =============================== */ #include <ti/drivers/SPI.h> -#include <ti/drivers/spi/SPICC26XXDMA.h> +#include <ti/drivers/spi/SPICC26X2DMA.h> #if TI_SPI_CONF_ENABLE -SPICC26XXDMA_Object spiCC26XXDMAObjects[CC26X2R1_LAUNCHXL_SPICOUNT]; +SPICC26X2DMA_Object spiCC26X2DMAObjects[CC26X2R1_LAUNCHXL_SPICOUNT]; /* * NOTE: The SPI instances below can be used by the SD driver to communicate * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF * to satisfy the SDSPI driver requirement. */ -const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC26X2R1_LAUNCHXL_SPICOUNT] = { +const SPICC26X2DMA_HWAttrs spiCC26X2DMAHWAttrs[CC26X2R1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { .baseAddr = SSI0_BASE, @@ -781,16 +922,16 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC26X2R1_LAUNCHXL_SPICOUNT] = { const SPI_Config SPI_config[CC26X2R1_LAUNCHXL_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC26X2R1_LAUNCHXL_SPI0], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC26X2R1_LAUNCHXL_SPI0] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC26X2R1_LAUNCHXL_SPI0], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC26X2R1_LAUNCHXL_SPI0] }, #endif #if TI_SPI_CONF_SPI1_ENABLE { - .fxnTablePtr = &SPICC26XXDMA_fxnTable, - .object = &spiCC26XXDMAObjects[CC26X2R1_LAUNCHXL_SPI1], - .hwAttrs = &spiCC26XXDMAHWAttrs[CC26X2R1_LAUNCHXL_SPI1] + .fxnTablePtr = &SPICC26X2DMA_fxnTable, + .object = &spiCC26X2DMAObjects[CC26X2R1_LAUNCHXL_SPI1], + .hwAttrs = &spiCC26X2DMAHWAttrs[CC26X2R1_LAUNCHXL_SPI1] }, #endif }; @@ -799,29 +940,6 @@ const uint_least8_t SPI_count = CC26X2R1_LAUNCHXL_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X2.h> - -TRNGCC26X2_Object trngCC26X2Object[CC26X2R1_LAUNCHXL_TRNGCOUNT]; - -const TRNGCC26X2_HWAttrs trngCC26X2HWAttrs[CC26X2R1_LAUNCHXL_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X2Object[0], &trngCC26X2HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC26X2R1_LAUNCHXL_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -965,3 +1083,11 @@ void CC26X2R1_LAUNCHXL_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC26X2R1_LAUNCHXL_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.h index 840d937e77e414063b2e4532153ea07a08c75bc9..d69ac54283bf9541bc6fdf7f3f1e3bd92da8a96e 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,6 +101,13 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC26X2R1_LAUNCHXL_I2C0_SCL0 IOID_4 #define CC26X2R1_LAUNCHXL_I2C0_SDA0 IOID_5 +/* I2S */ +#define CC26X2R1_LAUNCHXL_I2S_ADO IOID_0 +#define CC26X2R1_LAUNCHXL_I2S_ADI IOID_1 +#define CC26X2R1_LAUNCHXL_I2S_BCLK IOID_30 +#define CC26X2R1_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED +#define CC26X2R1_LAUNCHXL_I2S_WCLK IOID_29 + /* LEDs */ #define CC26X2R1_LAUNCHXL_PIN_LED_ON 1 #define CC26X2R1_LAUNCHXL_PIN_LED_OFF 0 @@ -126,7 +133,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC26X2R1_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */ #define CC26X2R1_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */ #define CC26X2R1_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */ -#define CC26X2R1_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED +#define CC26X2R1_LAUNCHXL_SPI0_CSN IOID_11 #define CC26X2R1_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED #define CC26X2R1_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED #define CC26X2R1_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED @@ -261,6 +268,36 @@ typedef enum CC26X2R1_LAUNCHXL_AESCCMName { CC26X2R1_LAUNCHXL_AESCCMCOUNT } CC26X2R1_LAUNCHXL_AESCCMName; +/*! + * @def CC26X2R1_LAUNCHXL_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC26X2R1_LAUNCHXL_AESGCMName { + CC26X2R1_LAUNCHXL_AESGCM0 = 0, + + CC26X2R1_LAUNCHXL_AESGCMCOUNT +} CC26X2R1_LAUNCHXL_AESGCMName; + +/*! + * @def CC26X2R1_LAUNCHXL_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC26X2R1_LAUNCHXL_AESCBCName { + CC26X2R1_LAUNCHXL_AESCBC0 = 0, + + CC26X2R1_LAUNCHXL_AESCBCCOUNT +} CC26X2R1_LAUNCHXL_AESCBCName; + +/*! + * @def CC26X2R1_LAUNCHXL_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC26X2R1_LAUNCHXL_AESCTRName { + CC26X2R1_LAUNCHXL_AESCTR0 = 0, + + CC26X2R1_LAUNCHXL_AESCTRCOUNT +} CC26X2R1_LAUNCHXL_AESCTRName; + /*! * @def CC26X2R1_LAUNCHXL_AESECBName * @brief Enum of AESECB names @@ -271,6 +308,16 @@ typedef enum CC26X2R1_LAUNCHXL_AESECBName { CC26X2R1_LAUNCHXL_AESECBCOUNT } CC26X2R1_LAUNCHXL_AESECBName; +/*! + * @def CC26X2R1_LAUNCHXL_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC26X2R1_LAUNCHXL_AESCTRDRBGName { + CC26X2R1_LAUNCHXL_AESCTRDRBG0 = 0, + + CC26X2R1_LAUNCHXL_AESCTRDRBGCOUNT +} CC26X2R1_LAUNCHXL_AESCTRDRBGName; + /*! * @def CC26X2R1_LAUNCHXL_SHA2Name * @brief Enum of SHA2 names @@ -281,6 +328,16 @@ typedef enum CC26X2R1_LAUNCHXL_SHA2Name { CC26X2R1_LAUNCHXL_SHA2COUNT } CC26X2R1_LAUNCHXL_SHA2Name; +/*! + * @def CC26X2R1_LAUNCHXL_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC26X2R1_LAUNCHXL_TRNGName { + CC26X2R1_LAUNCHXL_TRNG0 = 0, + + CC26X2R1_LAUNCHXL_TRNGCOUNT +} CC26X2R1_LAUNCHXL_TRNGName; + /*! * @def CC26X2R1_LAUNCHXL_GPIOName * @brief Enum of GPIO names @@ -339,6 +396,16 @@ typedef enum CC26X2R1_LAUNCHXL_I2CName { CC26X2R1_LAUNCHXL_I2CCOUNT } CC26X2R1_LAUNCHXL_I2CName; +/*! + * @def CC26X2R1_LAUNCHXL_I2SName + * @brief Enum of I2S names + */ +typedef enum CC26X2R1_LAUNCHXL_I2SName { + CC26X2R1_LAUNCHXL_I2S0 = 0, + + CC26X2R1_LAUNCHXL_I2SCOUNT +} CC26X2R1_LAUNCHXL_I2SName; + /*! * @def CC26X2R1_LAUNCHXL_NVSName * @brief Enum of NVS names @@ -396,16 +463,6 @@ typedef enum CC26X2R1_LAUNCHXL_SPIName { CC26X2R1_LAUNCHXL_SPICOUNT } CC26X2R1_LAUNCHXL_SPIName; -/*! - * @def CC26X2R1_LAUNCHXL_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC26X2R1_LAUNCHXL_TRNGName { - CC26X2R1_LAUNCHXL_TRNG0 = 0, - - CC26X2R1_LAUNCHXL_TRNGCOUNT -} CC26X2R1_LAUNCHXL_TRNGName; - /*! * @def CC26X2R1_LAUNCHXL_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL_fxns.c index 606339f2d3a0d021bb71984f44a2bfb3a90e8353..10a81252b8f3c28bcb7fc7c74780f6125d0e6aee 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/cc26x2r1/CC26X2R1_LAUNCHXL_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,8 +45,11 @@ #include <ti/drivers/pin/PINCC26XX.h> +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC26X2R1_LAUNCHXL_sendExtFlashByte ======== */ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/Board.h index e32e74fc12dc36ce914e1be55c34464aca5fa4c7..3abea6cc84e47b8e1ffac84fdf76480968247206 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,27 +37,53 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1350STK.h" #define Board_CC1350STK #define BOARD_STRING "TI CC1350 SensorTag" -#define Board_initGeneral() CC1350STK_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1350STK_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1350STK_wakeUpExtFlash() /* These #defines allow us to reuse TI-RTOS across other device families */ +#define Board_ADC0 CC1350STK_ADC0 +#define Board_ADC1 CC1350STK_ADC1 -#define Board_BUZZER CC1350STK_BUZZER -#define Board_BUZZER_ON CC1350STK_LED_ON -#define Board_BUZZER_OFF CC1350STK_LED_OFF +#define Board_ADCBUF0 CC1350STK_ADCBUF0 +#define Board_ADCBUF0CHANNEL0 CC1350STK_ADCBUF0CHANNEL0 +#define Board_ADCBUF0CHANNEL1 CC1350STK_ADCBUF0CHANNEL1 #define Board_CRYPTO0 CC1350STK_CRYPTO0 +#define Board_AESCCM0 CC1350STK_AESCCM0 +#define Board_AESGCM0 CC1350STK_AESGCM0 +#define Board_AESCBC0 CC1350STK_AESCBC0 +#define Board_AESCTR0 CC1350STK_AESCTR0 +#define Board_AESECB0 CC1350STK_AESECB0 +#define Board_AESCTRDRBG0 CC1350STK_AESCTRDRBG0 +#define Board_TRNG0 CC1350STK_TRNG0 + +#define Board_DIO16_TDO CC1350STK_DIO16_TDO +#define Board_DIO17_TDI CC1350STK_DIO17_TDI +#define Board_DIO22 CC1350STK_DIO22 + +#define Board_DIO23_ANALOG CC1350STK_DIO23_ANALOG +#define Board_DIO24_ANALOG CC1350STK_DIO24_ANALOG +#define Board_DIO25_ANALOG CC1350STK_DIO25_ANALOG +#define Board_DIO26_ANALOG CC1350STK_DIO26_ANALOG +#define Board_DIO27_ANALOG CC1350STK_DIO27_ANALOG +#define Board_DIO28_ANALOG CC1350STK_DIO28_ANALOG +#define Board_DIO29_ANALOG CC1350STK_DIO29_ANALOG +#define Board_DIO30_ANALOG CC1350STK_DIO30_ANALOG #define Board_GPIO_BUTTON0 CC1350STK_GPIO_S1 #define Board_GPIO_BUTTON1 CC1350STK_GPIO_S2 -#define Board_GPIO_LED0 CC1350STK_GPIO_LED0 -#define Board_GPIO_LED1 CC1350STK_GPIO_LED0 +#define Board_GPIO_BTN1 CC1350STK_GPIO_S1 +#define Board_GPIO_BTN2 CC1350STK_GPIO_S2 +#define Board_GPIO_LED0 CC1350STK_GPIO_LED_RED +#define Board_GPIO_LED1 CC1350STK_GPIO_LED_RED +#define Board_GPIO_RLED CC1350STK_GPIO_LED_RED #define Board_GPIO_LED_ON CC1350STK_GPIO_LED_ON #define Board_GPIO_LED_OFF CC1350STK_GPIO_LED_OFF @@ -70,15 +96,28 @@ extern "C" { #define Board_GPTIMER3A CC1350STK_GPTIMER3A #define Board_GPTIMER3B CC1350STK_GPTIMER3B +#define Board_NVSINTERNAL CC1350STK_NVSCC26XX0 +#define Board_NVSEXTERNAL CC1350STK_NVSSPI25X0 + #define Board_I2C0 CC1350STK_I2C0 -#define Board_I2C0_SDA1 CC1350STK_I2C0_SDA1 -#define Board_I2C0_SCL1 CC1350STK_I2C0_SCL1 -#define Board_I2C_TMP CC1350STK_I2C0 + +#define Board_PIN_BUTTON0 CC1350STK_PIN_BTN1 +#define Board_PIN_BUTTON1 CC1350STK_PIN_BTN2 +#define Board_PIN_BTN1 CC1350STK_PIN_BTN1 +#define Board_PIN_BTN2 CC1350STK_PIN_BTN2 +#define Board_PIN_LED0 CC1350STK_PIN_RLED +#define Board_PIN_LED1 CC1350STK_PIN_RLED +#define Board_PIN_LED2 CC1350STK_PIN_RLED +#define Board_PIN_RLED CC1350STK_PIN_RLED #define Board_KEY_LEFT CC1350STK_KEY_LEFT #define Board_KEY_RIGHT CC1350STK_KEY_RIGHT #define Board_RELAY CC1350STK_RELAY +#define Board_BUZZER CC1350STK_BUZZER +#define Board_BUZZER_ON CC1350STK_LED_ON +#define Board_BUZZER_OFF CC1350STK_LED_OFF + #define Board_MIC_POWER CC1350STK_MIC_POWER #define Board_MIC_POWER_OM CC1350STK_MIC_POWER_ON #define Board_MIC_POWER_OFF CC1350STK_MIC_POWER_OFF @@ -90,18 +129,12 @@ extern "C" { #define Board_TMP_RDY CC1350STK_TMP_RDY -#define Board_NVSINTERNAL CC1350STK_NVSCC26XX0 -#define Board_NVSEXTERNAL CC1350STK_NVSSPI25X0 - -#define Board_PDM0 CC2650STK_PDM0 - -#define Board_PIN_BUTTON0 CC1350STK_KEY_LEFT -#define Board_PIN_BUTTON1 CC1350STK_KEY_RIGHT -#define Board_PIN_BTN1 CC1350STK_KEY_LEFT -#define Board_PIN_BTN2 CC1350STK_KEY_RIGHT -#define Board_PIN_LED0 CC1350STK_PIN_LED1 -#define Board_PIN_LED1 CC1350STK_PIN_LED1 -#define Board_PIN_LED2 CC1350STK_PIN_LED1 +#define Board_I2S0 CC1350STK_I2S0 +#define Board_I2S_ADO CC1350STK_I2S_ADO +#define Board_I2S_ADI CC1350STK_I2S_ADI +#define Board_I2S_BCLK CC1350STK_I2S_BCLK +#define Board_I2S_MCLK CC1350STK_I2S_MCLK +#define Board_I2S_WCLK CC1350STK_I2S_WCLK #define Board_PWM0 CC1350STK_PWM0 #define Board_PWM1 CC1350STK_PWM0 @@ -123,8 +156,8 @@ extern "C" { #define Board_SPI1_CLK CC1350STK_SPI1_CLK #define Board_SPI1_CSN CC1350STK_SPI1_CSN #define Board_SPI_FLASH_CS CC1350STK_SPI_FLASH_CS -#define Board_FLASH_CS_ON CC1350STK_FLASH_CS_ON -#define Board_FLASH_CS_OFF CC1350STK_FLASH_CS_OFF +#define Board_FLASH_CS_ON (0) +#define Board_FLASH_CS_OFF (1) #define Board_UART0 CC1350STK_UART0 diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.c index de15954f0d9248a1d1608f633098853a823589ae..3bdfb38484b86e0e46cfdd799401cdc6e5db951d 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, Texas Instruments Incorporated + * Copyright (c) 2016-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ */ /* - * ====================== CC1350STK.c ========================================= + * ============================ CC1350STK.c ============================ * This file is responsible for setting up the board specific items for the * CC1350STK board. */ @@ -51,6 +51,179 @@ #include "CC1350STK.h" +/* + * =============================== ADCBuf =============================== + */ +#include <ti/drivers/ADCBuf.h> +#include <ti/drivers/adcbuf/ADCBufCC26XX.h> + +ADCBufCC26XX_Object adcBufCC26XXobjects[CC1350STK_ADCBUFCOUNT]; + +/* + * This table converts a virtual adc channel into a dio and internal analogue + * input signal. This table is necessary for the functioning of the adcBuf + * driver. Comment out unused entries to save flash. Dio and internal signal + * pairs are hardwired. Do not remap them in the table. You may reorder entire + * entries. The mapping of dio and internal signals is package dependent. + */ +const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[CC1350STK_ADCBUF0CHANNELCOUNT] = { + {CC1350STK_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7}, + {CC1350STK_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6}, + {CC1350STK_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5}, + {CC1350STK_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4}, + {CC1350STK_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3}, + {CC1350STK_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2}, + {CC1350STK_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1}, + {CC1350STK_DIO30_ANALOG, ADC_COMPB_IN_AUXIO0}, + {PIN_UNASSIGNED, ADC_COMPB_IN_VDDS}, + {PIN_UNASSIGNED, ADC_COMPB_IN_DCOUPL}, + {PIN_UNASSIGNED, ADC_COMPB_IN_VSS}, +}; + +const ADCBufCC26XX_HWAttrs adcBufCC26XXHWAttrs[CC1350STK_ADCBUFCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .adcChannelLut = ADCBufCC26XX_adcChannelLut, + } +}; + +const ADCBuf_Config ADCBuf_config[CC1350STK_ADCBUFCOUNT] = { + { + &ADCBufCC26XX_fxnTable, + &adcBufCC26XXobjects[CC1350STK_ADCBUF0], + &adcBufCC26XXHWAttrs[CC1350STK_ADCBUF0] + }, +}; + +const uint_least8_t ADCBuf_count = CC1350STK_ADCBUFCOUNT; + +/* + * =============================== ADC =============================== + */ +#include <ti/drivers/ADC.h> +#include <ti/drivers/adc/ADCCC26XX.h> + +ADCCC26XX_Object adcCC26xxObjects[CC1350STK_ADCCOUNT]; + +const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1350STK_ADCCOUNT] = { + { + .adcDIO = CC1350STK_DIO23_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO7, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC1350STK_DIO24_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO6, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC1350STK_DIO25_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO5, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC1350STK_DIO26_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO4, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC1350STK_DIO27_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO3, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC1350STK_DIO28_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO2, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC1350STK_DIO29_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO1, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC1350STK_DIO30_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO0, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = PIN_UNASSIGNED, + .adcCompBInput = ADC_COMPB_IN_DCOUPL, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = PIN_UNASSIGNED, + .adcCompBInput = ADC_COMPB_IN_VSS, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = PIN_UNASSIGNED, + .adcCompBInput = ADC_COMPB_IN_VDDS, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + } +}; + +const ADC_Config ADC_config[CC1350STK_ADCCOUNT] = { + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC0], &adcCC26xxHWAttrs[CC1350STK_ADC0]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC1], &adcCC26xxHWAttrs[CC1350STK_ADC1]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC2], &adcCC26xxHWAttrs[CC1350STK_ADC2]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC3], &adcCC26xxHWAttrs[CC1350STK_ADC3]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC4], &adcCC26xxHWAttrs[CC1350STK_ADC4]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC5], &adcCC26xxHWAttrs[CC1350STK_ADC5]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC6], &adcCC26xxHWAttrs[CC1350STK_ADC6]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADC7], &adcCC26xxHWAttrs[CC1350STK_ADC7]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADCDCOUPL], &adcCC26xxHWAttrs[CC1350STK_ADCDCOUPL]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADCVSS], &adcCC26xxHWAttrs[CC1350STK_ADCVSS]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350STK_ADCVDDS], &adcCC26xxHWAttrs[CC1350STK_ADCVDDS]}, +}; + +const uint_least8_t ADC_count = CC1350STK_ADCCOUNT; + /* * =============================== Crypto =============================== */ @@ -71,9 +244,173 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC1350STK_CRYPTOCOUNT] = { { .object = &cryptoCC26XXObjects[CC1350STK_CRYPTO0], .hwAttrs = &cryptoCC26XXHWAttrs[CC1350STK_CRYPTO0] + }, +}; + +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC1350STK_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1350STK_AESCCMCOUNT] = { + { + .intPriority = ~0, } }; +const AESCCM_Config AESCCM_config[CC1350STK_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC1350STK_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC1350STK_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC1350STK_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1350STK_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1350STK_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1350STK_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1350STK_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1350STK_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1350STK_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1350STK_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1350STK_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1350STK_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1350STK_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1350STK_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1350STK_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1350STK_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1350STK_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1350STK_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1350STK_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1350STK_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1350STK_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC1350STK_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1350STK_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC1350STK_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC1350STK_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC1350STK_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC1350STK_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1350STK_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1350STK_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1350STK_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1350STK_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1350STK_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1350STK_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1350STK_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1350STK_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1350STK_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1350STK_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1350STK_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1350STK_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1350STK_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -188,6 +525,34 @@ const uint_least8_t I2C_count = CC1350STK_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1350STK_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1350STK_I2SCOUNT] = { + { + .pinSD1 = CC1350STK_I2S_ADI, + .pinSD0 = CC1350STK_I2S_ADO, + .pinSCK = CC1350STK_I2S_BCLK, + .pinMCLK = CC1350STK_I2S_MCLK, + .pinWS = CC1350STK_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1350STK_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1350STK_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1350STK_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1350STK_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -240,10 +605,10 @@ static char flashBuf[REGIONSIZE]; #endif -/* Allocate objects for NVS and NVS SPI */ +/* Allocate objects for NVS Internal Regions */ NVSCC26XX_Object nvsCC26xxObjects[1]; -/* Hardware attributes for NVS */ +/* Hardware attributes for NVS Internal Regions */ const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = { { .regionBase = (void *)flashBuf, @@ -256,14 +621,15 @@ const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = { #if TI_NVS_CONF_NVS_EXTERNAL_ENABLE #define SPISECTORSIZE 0x1000 -#define SPIREGIONSIZE (SECTORSIZE * 32) +#define SPIREGIONSIZE (SPISECTORSIZE * 32) #define VERIFYBUFSIZE 64 static uint8_t verifyBuf[VERIFYBUFSIZE]; +/* Allocate objects for NVS External Regions */ NVSSPI25X_Object nvsSPI25XObjects[1]; -/* Hardware attributes for NVS SPI */ +/* Hardware attributes for NVS External Regions */ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { { .regionBaseOffset = 0, @@ -275,6 +641,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC1350STK_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -302,49 +669,6 @@ const uint_least8_t NVS_count = CC1350STK_NVSCOUNT; #endif /* TI_NVS_CONF_ENABLE */ -/* - * =============================== PDM =============================== -*/ -#include <ti/drivers/pdm/PDMCC26XX.h> -#include <ti/drivers/pdm/PDMCC26XX_util.h> - -PDMCC26XX_Object pdmCC26XXObjects[CC1350STK_PDMCOUNT]; -PDMCC26XX_I2S_Object pdmCC26XXI2SObjects[CC1350STK_PDMCOUNT]; - -const PDMCC26XX_HWAttrs pdmCC26XXHWAttrs[CC1350STK_PDMCOUNT] = { - { - .micPower = CC1350STK_MIC_POWER, - .taskPriority = 2 - } -}; - -const PDMCC26XX_Config PDMCC26XX_config[CC1350STK_PDMCOUNT] = { - { - .object = &pdmCC26XXObjects[CC1350STK_PDM0], - .hwAttrs = &pdmCC26XXHWAttrs[CC1350STK_PDM0] - } -}; - -const PDMCC26XX_I2S_HWAttrs pdmC26XXI2SHWAttrs[CC1350STK_PDMCOUNT] = { - { - .baseAddr = I2S0_BASE, - .intNum = INT_I2S_IRQ, - .powerMngrId = PowerCC26XX_PERIPH_I2S, - .intPriority = ~0, - .mclkPin = PIN_UNASSIGNED, - .bclkPin = CC1350STK_AUDIO_CLK, - .wclkPin = PIN_UNASSIGNED, - .ad0Pin = CC1350STK_AUDIO_DI, - } -}; - -const PDMCC26XX_I2S_Config PDMCC26XX_I2S_config[CC1350STK_PDMCOUNT] = { - { - .object = &pdmCC26XXI2SObjects[CC1350STK_PDM0], - .hwAttrs = &pdmC26XXI2SHWAttrs[CC1350STK_PDM0] - } -}; - /* * =============================== PIN =============================== */ @@ -353,31 +677,21 @@ const PDMCC26XX_I2S_Config PDMCC26XX_I2S_config[CC1350STK_PDMCOUNT] = { const PIN_Config BoardGpioInitTable[] = { - CC1350STK_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */ - CC1350STK_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ - CC1350STK_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ - CC1350STK_RELAY | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Relay is active high */ - CC1350STK_MPU_INT | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_NEGEDGE | PIN_HYSTERESIS, /* MPU_INT is active low */ - CC1350STK_TMP_RDY | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* TMP_RDY is active high */ - CC1350STK_BUZZER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Buzzer initially off */ - CC1350STK_MPU_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* MPU initially on */ - CC1350STK_MIC_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* MIC initially off */ + CC1350STK_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */ + CC1350STK_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ + CC1350STK_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1350STK_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC1350STK_SPI_DEVPK_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* DevPack chip select */ - CC1350STK_AUDIO_DI | PIN_INPUT_EN | PIN_PULLDOWN, /* Audio DI */ - CC1350STK_AUDIODO | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* Audio data out */ - CC1350STK_AUDIO_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC1350STK_DP2 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC1350STK_DP1 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC1350STK_DP0 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC1350STK_DP3 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ CC1350STK_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* DevPack */ CC1350STK_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC1350STK_DEVPK_ID | PIN_INPUT_EN | PIN_NOPULL, /* Device pack ID - external PU */ CC1350STK_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC1350STK_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC1350STK_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ - + CC1350STK_RELAY | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Relay is active high */ + CC1350STK_MPU_INT | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_NEGEDGE | PIN_HYSTERESIS, /* MPU_INT is active low */ + CC1350STK_TMP_RDY | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* TMP_RDY is active high */ + CC1350STK_BUZZER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Buzzer initially off */ + CC1350STK_MPU_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* MPU initially on */ + CC1350STK_MIC_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* MIC initially off */ PIN_TERMINATE }; @@ -389,9 +703,13 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { /* * =============================== Power =============================== */ +#include <ti/drivers/Power.h> +#include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" + const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -454,6 +772,11 @@ const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1350STK_SPICOUNT]; +/* + * NOTE: The SPI instances below can be used by the SD driver to communicate + * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF + * to satisfy the SDSPI driver requirement. + */ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1350STK_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { @@ -462,7 +785,7 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1350STK_SPICOUNT] = { .intPriority = ~0, .swiPriority = 0, .powerMngrId = PowerCC26XX_PERIPH_SSI0, - .defaultTxBufValue = 0, + .defaultTxBufValue = 0xFF, .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX, .txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX, .mosiPin = CC1350STK_SPI0_MOSI, @@ -479,7 +802,7 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1350STK_SPICOUNT] = { .intPriority = ~0, .swiPriority = 0, .powerMngrId = PowerCC26XX_PERIPH_SSI1, - .defaultTxBufValue = 0, + .defaultTxBufValue = 0xFF, .rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX, .txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX, .mosiPin = CC1350STK_SPI1_MOSI, @@ -512,29 +835,6 @@ const uint_least8_t SPI_count = CC1350STK_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC1350STK_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1350STK_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1350STK_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -643,7 +943,7 @@ void CC1350STK_initGeneral(void) { Power_init(); - if ( PIN_init(BoardGpioInitTable) != PIN_SUCCESS) { + if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) { /* Error with PIN_init */ while (1); } @@ -651,3 +951,11 @@ void CC1350STK_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1350STK_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.h index 2347876b1da16da6ddd3c7cd267187f0d824d221..a2a3d54a56e1ee83149f121952b7a1632d5ec7cd 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,7 @@ /** ============================================================================ * @file CC1350STK.h * - * @brief CC1350STK Board Specific header file. + * @brief CC1350 SensorTag Board Specific header file. * * The CC1350STK header file should be included in an application as * follows: @@ -62,15 +62,23 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350STK /* Mapping of pins to board signals using general board aliases - * <board signal alias> <pin mapping> + * <board signal alias> <pin mapping> <comments> */ +/* Analog Capable DIOs */ +#define CC1350STK_DIO23_ANALOG IOID_23 +#define CC1350STK_DIO24_ANALOG IOID_24 +#define CC1350STK_DIO25_ANALOG IOID_25 +#define CC1350STK_DIO26_ANALOG IOID_26 +#define CC1350STK_DIO27_ANALOG IOID_27 +#define CC1350STK_DIO28_ANALOG IOID_28 +#define CC1350STK_DIO29_ANALOG IOID_29 +#define CC1350STK_DIO30_ANALOG IOID_30 + /* Audio */ #define CC1350STK_MIC_POWER IOID_13 #define CC1350STK_MIC_POWER_ON 1 #define CC1350STK_MIC_POWER_OFF 0 -#define CC1350STK_AUDIO_DI IOID_2 -#define CC1350STK_AUDIO_CLK IOID_3 /* Buzzer */ #define CC1350STK_BUZZER IOID_21 @@ -78,26 +86,26 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350STK_BUZZER_OFF 0 /* DevPack */ -#define CC1350STK_AUDIOFS_TDO IOID_16 -#define CC1350STK_AUDIODO IOID_22 -#define CC1350STK_DP2 IOID_23 -#define CC1350STK_DP1 IOID_24 #define CC1350STK_DP0 IOID_25 +#define CC1350STK_DP1 IOID_24 +#define CC1350STK_DP2 IOID_23 #define CC1350STK_DP3 IOID_27 #define CC1350STK_DP4_UARTRX IOID_28 #define CC1350STK_DP5_UARTTX IOID_29 -#define CC1350STK_DEVPK_ID IOID_30 -#define CC1350STK_SPI_DEVPK_CS IOID_20 - -/* Discrete Outputs */ -#define CC1350STK_PIN_LED1 IOID_10 -#define CC1350STK_LED_ON 1 -#define CC1350STK_LED_OFF 0 - +#define CC1350STK_DP6_ADO IOID_22 +#define CC1350STK_DP7_BCLK IOID_3 +#define CC1350STK_DP8_TDI IOID_17 +#define CC1350STK_DP9_MISO IOID_18 +#define CC1350STK_DP10_MOSI IOID_19 +#define CC1350STK_DP11_CSN IOID_20 +#define CC1350STK_DP12_WCLK IOID_16 +#define CC1350STK_DP_ID IOID_30 /* Discrete Inputs */ -#define CC1350STK_KEY_LEFT IOID_15 -#define CC1350STK_KEY_RIGHT IOID_4 +#define CC1350STK_PIN_BTN1 IOID_4 +#define CC1350STK_PIN_BTN2 IOID_15 +#define CC1350STK_KEY_LEFT CC1350STK_PIN_BTN2 +#define CC1350STK_KEY_RIGHT CC1350STK_PIN_BTN1 #define CC1350STK_RELAY IOID_1 /* GPIO */ @@ -105,10 +113,22 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350STK_GPIO_LED_OFF 0 /* I2C */ -#define CC1350STK_I2C0_SDA0 IOID_5 #define CC1350STK_I2C0_SCL0 IOID_6 -#define CC1350STK_I2C0_SDA1 IOID_8 +#define CC1350STK_I2C0_SDA0 IOID_5 #define CC1350STK_I2C0_SCL1 IOID_9 +#define CC1350STK_I2C0_SDA1 IOID_8 + +/* I2S */ +#define CC1350STK_I2S_ADO IOID_22 +#define CC1350STK_I2S_ADI IOID_2 +#define CC1350STK_I2S_BCLK IOID_3 +#define CC1350STK_I2S_MCLK PIN_UNASSIGNED +#define CC1350STK_I2S_WCLK IOID_16 + +/* LEDs */ +#define CC1350STK_PIN_LED_ON 1 +#define CC1350STK_PIN_LED_OFF 0 +#define CC1350STK_PIN_RLED IOID_10 /* LED-Audio DevPack */ #define CC1350STK_DEVPK_LIGHT_BLUE IOID_23 @@ -121,9 +141,9 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350STK_MPU_POWER_ON 1 #define CC1350STK_MPU_POWER_OFF 0 -/* PWM */ -#define CC1350STK_PWMPIN0 CC1350STK_PIN_LED1 -#define CC1350STK_PWMPIN1 CC1350STK_PIN_LED1 +/* PWM Outputs */ +#define CC1350STK_PWMPIN0 CC1350STK_PIN_RLED +#define CC1350STK_PWMPIN1 PIN_UNASSIGNED #define CC1350STK_PWMPIN2 PIN_UNASSIGNED #define CC1350STK_PWMPIN3 PIN_UNASSIGNED #define CC1350STK_PWMPIN4 PIN_UNASSIGNED @@ -144,7 +164,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350STK_SPI0_MISO IOID_18 #define CC1350STK_SPI0_MOSI IOID_19 #define CC1350STK_SPI0_CLK IOID_17 -#define CC1350STK_SPI0_CSN PIN_UNASSIGNED +#define CC1350STK_SPI0_CSN IOID_20 #define CC1350STK_SPI1_MISO PIN_UNASSIGNED #define CC1350STK_SPI1_MOSI PIN_UNASSIGNED #define CC1350STK_SPI1_CLK PIN_UNASSIGNED @@ -175,6 +195,56 @@ void CC1350STK_shutDownExtFlash(void); */ void CC1350STK_wakeUpExtFlash(void); +/*! + * @def CC1350STK_ADCBufName + * @brief Enum of ADCBufs + */ +typedef enum CC1350STK_ADCBufName { + CC1350STK_ADCBUF0 = 0, + + CC1350STK_ADCBUFCOUNT +} CC1350STK_ADCBufName; + +/*! + * @def CC1350STK_ADCBuf0ChannelName + * @brief Enum of ADCBuf channels + */ +typedef enum CC1350STK_ADCBuf0ChannelName { + CC1350STK_ADCBUF0CHANNEL0 = 0, + CC1350STK_ADCBUF0CHANNEL1, + CC1350STK_ADCBUF0CHANNEL2, + CC1350STK_ADCBUF0CHANNEL3, + CC1350STK_ADCBUF0CHANNEL4, + CC1350STK_ADCBUF0CHANNEL5, + CC1350STK_ADCBUF0CHANNEL6, + CC1350STK_ADCBUF0CHANNEL7, + CC1350STK_ADCBUF0CHANNELVDDS, + CC1350STK_ADCBUF0CHANNELDCOUPL, + CC1350STK_ADCBUF0CHANNELVSS, + + CC1350STK_ADCBUF0CHANNELCOUNT +} CC1350STK_ADCBuf0ChannelName; + +/*! + * @def CC1350STK_ADCName + * @brief Enum of ADCs + */ +typedef enum CC1350STK_ADCName { + CC1350STK_ADC0 = 0, + CC1350STK_ADC1, + CC1350STK_ADC2, + CC1350STK_ADC3, + CC1350STK_ADC4, + CC1350STK_ADC5, + CC1350STK_ADC6, + CC1350STK_ADC7, + CC1350STK_ADCDCOUPL, + CC1350STK_ADCVSS, + CC1350STK_ADCVDDS, + + CC1350STK_ADCCOUNT +} CC1350STK_ADCName; + /*! * @def CC1350STK_CryptoName * @brief Enum of Crypto names @@ -185,6 +255,76 @@ typedef enum CC1350STK_CryptoName { CC1350STK_CRYPTOCOUNT } CC1350STK_CryptoName; +/*! + * @def CC1350STK_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC1350STK_AESCCMName { + CC1350STK_AESCCM0 = 0, + + CC1350STK_AESCCMCOUNT +} CC1350STK_AESCCMName; + +/*! + * @def CC1350STK_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1350STK_AESGCMName { + CC1350STK_AESGCM0 = 0, + + CC1350STK_AESGCMCOUNT +} CC1350STK_AESGCMName; + +/*! + * @def CC1350STK_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1350STK_AESCBCName { + CC1350STK_AESCBC0 = 0, + + CC1350STK_AESCBCCOUNT +} CC1350STK_AESCBCName; + +/*! + * @def CC1350STK_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1350STK_AESCTRName { + CC1350STK_AESCTR0 = 0, + + CC1350STK_AESCTRCOUNT +} CC1350STK_AESCTRName; + +/*! + * @def CC1350STK_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC1350STK_AESECBName { + CC1350STK_AESECB0 = 0, + + CC1350STK_AESECBCOUNT +} CC1350STK_AESECBName; + +/*! + * @def CC1350STK_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1350STK_AESCTRDRBGName { + CC1350STK_AESCTRDRBG0 = 0, + + CC1350STK_AESCTRDRBGCOUNT +} CC1350STK_AESCTRDRBGName; + +/*! + * @def CC1350STK_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1350STK_TRNGName { + CC1350STK_TRNG0 = 0, + + CC1350STK_TRNGCOUNT +} CC1350STK_TRNGName; + /*! * @def CC1350STK_GPIOName * @brief Enum of GPIO names @@ -200,7 +340,7 @@ typedef enum CC1350STK_GPIOName { /*! * @def CC1350STK_GPTimerName - * @brief Enum of GPTimers parts + * @brief Enum of GPTimer parts */ typedef enum CC1350STK_GPTimerName { CC1350STK_GPTIMER0A = 0, @@ -240,6 +380,16 @@ typedef enum CC1350STK_I2CName { CC1350STK_I2CCOUNT } CC1350STK_I2CName; +/*! + * @def CC1350STK_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1350STK_I2SName { + CC1350STK_I2S0 = 0, + + CC1350STK_I2SCOUNT +} CC1350STK_I2SName; + /*! * @def CC1350STK_NVSName * @brief Enum of NVS names @@ -255,16 +405,6 @@ typedef enum CC1350STK_NVSName { CC1350STK_NVSCOUNT } CC1350STK_NVSName; -/*! - * @def CC1350STK_PDMName - * @brief Enum of PDM names - */ -typedef enum CC1350STK_PDMName { - CC1350STK_PDM0 = 0, - - CC1350STK_PDMCOUNT -} CC1350STK_PDMName; - /*! * @def CC1350STK_PWMName * @brief Enum of PWM outputs @@ -297,16 +437,6 @@ typedef enum CC1350STK_SPIName { CC1350STK_SPICOUNT } CC1350STK_SPIName; -/*! - * @def CC1350STK_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1350STK_TRNGName { - CC1350STK_TRNG0 = 0, - - CC1350STK_TRNGCOUNT -} CC1350STK_TRNGName; - /*! * @def CC1350STK_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK_fxns.c index dd20cb301cf04b1ba8c9647041bc19c2bbe63c50..086c19fd1c061065f36fc36437b1eafe248e7b30 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc1350/CC1350STK_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,8 +42,11 @@ #include DeviceFamily_constructPath(driverlib/ioc.h) #include DeviceFamily_constructPath(driverlib/cpu.h) +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC1350STK_sendExtFlashByte ======== */ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/Board.h index 8425de45426e47e432b31159cc4ddfac70fde056..fa39f5fee9da9c003af8ab842439704726bc5fa6 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,27 +37,54 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC2650STK.h" #define Board_CC2650STK #define BOARD_STRING "TI CC2650 SensorTag" -#define Board_initGeneral() CC2650STK_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC2650STK_shutDownExtFlash() #define Board_wakeUpExtFlash() CC2650STK_wakeUpExtFlash() /* These #defines allow us to reuse TI-RTOS across other device families */ +#define Board_ADC0 CC2650STK_ADC0 +#define Board_ADC1 CC2650STK_ADC1 -#define Board_BUZZER CC2650STK_BUZZER -#define Board_BUZZER_ON CC2650STK_LED_ON -#define Board_BUZZER_OFF CC2650STK_LED_OFF +#define Board_ADCBUF0 CC2650STK_ADCBUF0 +#define Board_ADCBUF0CHANNEL0 CC2650STK_ADCBUF0CHANNEL0 +#define Board_ADCBUF0CHANNEL1 CC2650STK_ADCBUF0CHANNEL1 #define Board_CRYPTO0 CC2650STK_CRYPTO0 +#define Board_AESCCM0 CC2650STK_AESCCM0 +#define Board_AESGCM0 CC2650STK_AESGCM0 +#define Board_AESCBC0 CC2650STK_AESCBC0 +#define Board_AESCTR0 CC2650STK_AESCTR0 +#define Board_AESECB0 CC2650STK_AESECB0 +#define Board_AESCTRDRBG0 CC2650STK_AESCTRDRBG0 +#define Board_TRNG0 CC2650STK_TRNG0 + +#define Board_DIO16_TDO CC2650STK_DIO16_TDO +#define Board_DIO17_TDI CC2650STK_DIO17_TDI +#define Board_DIO22 CC2650STK_DIO22 + +#define Board_DIO23_ANALOG CC2650STK_DIO23_ANALOG +#define Board_DIO24_ANALOG CC2650STK_DIO24_ANALOG +#define Board_DIO25_ANALOG CC2650STK_DIO25_ANALOG +#define Board_DIO26_ANALOG CC2650STK_DIO26_ANALOG +#define Board_DIO27_ANALOG CC2650STK_DIO27_ANALOG +#define Board_DIO28_ANALOG CC2650STK_DIO28_ANALOG +#define Board_DIO29_ANALOG CC2650STK_DIO29_ANALOG +#define Board_DIO30_ANALOG CC2650STK_DIO30_ANALOG #define Board_GPIO_BUTTON0 CC2650STK_GPIO_S1 #define Board_GPIO_BUTTON1 CC2650STK_GPIO_S2 -#define Board_GPIO_LED0 CC2650STK_GPIO_LED0 -#define Board_GPIO_LED1 CC2650STK_GPIO_LED0 +#define Board_GPIO_BTN1 CC2650STK_GPIO_S1 +#define Board_GPIO_BTN2 CC2650STK_GPIO_S2 +#define Board_GPIO_LED0 CC2650STK_GPIO_LED_RED +#define Board_GPIO_LED1 CC2650STK_GPIO_LED_GREEN +#define Board_GPIO_RLED CC2650STK_GPIO_LED_RED +#define Board_GPIO_GLED CC2650STK_GPIO_LED_GREEN #define Board_GPIO_LED_ON CC2650STK_GPIO_LED_ON #define Board_GPIO_LED_OFF CC2650STK_GPIO_LED_OFF @@ -70,15 +97,29 @@ extern "C" { #define Board_GPTIMER3A CC2650STK_GPTIMER3A #define Board_GPTIMER3B CC2650STK_GPTIMER3B +#define Board_NVSINTERNAL CC2650STK_NVSCC26XX0 +#define Board_NVSEXTERNAL CC2650STK_NVSSPI25X0 + #define Board_I2C0 CC2650STK_I2C0 -#define Board_I2C0_SDA1 CC2650STK_I2C0_SDA1 -#define Board_I2C0_SCL1 CC2650STK_I2C0_SCL1 -#define Board_I2C_TMP CC2650STK_I2C0 + +#define Board_PIN_BUTTON0 CC2650STK_PIN_BTN1 +#define Board_PIN_BUTTON1 CC2650STK_PIN_BTN2 +#define Board_PIN_BTN1 CC2650STK_PIN_BTN1 +#define Board_PIN_BTN2 CC2650STK_PIN_BTN2 +#define Board_PIN_LED0 CC2650STK_PIN_RLED +#define Board_PIN_LED1 CC2650STK_PIN_GLED +#define Board_PIN_LED2 CC2650STK_PIN_RLED +#define Board_PIN_RLED CC2650STK_PIN_RLED +#define Board_PIN_GLED CC2650STK_PIN_GLED #define Board_KEY_LEFT CC2650STK_KEY_LEFT #define Board_KEY_RIGHT CC2650STK_KEY_RIGHT #define Board_RELAY CC2650STK_RELAY +#define Board_BUZZER CC2650STK_BUZZER +#define Board_BUZZER_ON CC2650STK_LED_ON +#define Board_BUZZER_OFF CC2650STK_LED_OFF + #define Board_MIC_POWER CC2650STK_MIC_POWER #define Board_MIC_POWER_OM CC2650STK_MIC_POWER_ON #define Board_MIC_POWER_OFF CC2650STK_MIC_POWER_OFF @@ -90,18 +131,12 @@ extern "C" { #define Board_TMP_RDY CC2650STK_TMP_RDY -#define Board_NVSINTERNAL CC2650STK_NVSCC26XX0 -#define Board_NVSEXTERNAL CC2650STK_NVSSPI25X0 - -#define Board_PDM0 CC2650STK_PDM0 - -#define Board_PIN_BUTTON0 CC2650STK_KEY_LEFT -#define Board_PIN_BUTTON1 CC2650STK_KEY_RIGHT -#define Board_PIN_BTN1 CC2650STK_KEY_LEFT -#define Board_PIN_BTN2 CC2650STK_KEY_RIGHT -#define Board_PIN_LED0 CC2650STK_PIN_LED0 -#define Board_PIN_LED1 CC2650STK_PIN_LED1 -#define Board_PIN_LED2 CC2650STK_PIN_LED1 +#define Board_I2S0 CC2650STK_I2S0 +#define Board_I2S_ADO CC2650STK_I2S_ADO +#define Board_I2S_ADI CC2650STK_I2S_ADI +#define Board_I2S_BCLK CC2650STK_I2S_BCLK +#define Board_I2S_MCLK CC2650STK_I2S_MCLK +#define Board_I2S_WCLK CC2650STK_I2S_WCLK #define Board_PWM0 CC2650STK_PWM0 #define Board_PWM1 CC2650STK_PWM0 @@ -123,8 +158,8 @@ extern "C" { #define Board_SPI1_CLK CC2650STK_SPI1_CLK #define Board_SPI1_CSN CC2650STK_SPI1_CSN #define Board_SPI_FLASH_CS CC2650STK_SPI_FLASH_CS -#define Board_FLASH_CS_ON CC2650STK_FLASH_CS_ON -#define Board_FLASH_CS_OFF CC2650STK_FLASH_CS_OFF +#define Board_FLASH_CS_ON (0) +#define Board_FLASH_CS_OFF (1) #define Board_UART0 CC2650STK_UART0 diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.c index 7b16c58eed317f2c09ecde348a5a7d87d09d2a38..25730aedad17e89451ff58256fc1bc8e7e328d84 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, Texas Instruments Incorporated + * Copyright (c) 2016-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,179 @@ #include "CC2650STK.h" +/* + * =============================== ADCBuf =============================== + */ +#include <ti/drivers/ADCBuf.h> +#include <ti/drivers/adcbuf/ADCBufCC26XX.h> + +ADCBufCC26XX_Object adcBufCC26XXobjects[CC2650STK_ADCBUFCOUNT]; + +/* + * This table converts a virtual adc channel into a dio and internal analogue + * input signal. This table is necessary for the functioning of the adcBuf + * driver. Comment out unused entries to save flash. Dio and internal signal + * pairs are hardwired. Do not remap them in the table. You may reorder entire + * entries. The mapping of dio and internal signals is package dependent. + */ +const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[CC2650STK_ADCBUF0CHANNELCOUNT] = { + {CC2650STK_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7}, + {CC2650STK_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6}, + {CC2650STK_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5}, + {CC2650STK_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4}, + {CC2650STK_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3}, + {CC2650STK_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2}, + {CC2650STK_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1}, + {CC2650STK_DIO30_ANALOG, ADC_COMPB_IN_AUXIO0}, + {PIN_UNASSIGNED, ADC_COMPB_IN_VDDS}, + {PIN_UNASSIGNED, ADC_COMPB_IN_DCOUPL}, + {PIN_UNASSIGNED, ADC_COMPB_IN_VSS}, +}; + +const ADCBufCC26XX_HWAttrs adcBufCC26XXHWAttrs[CC2650STK_ADCBUFCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .adcChannelLut = ADCBufCC26XX_adcChannelLut, + } +}; + +const ADCBuf_Config ADCBuf_config[CC2650STK_ADCBUFCOUNT] = { + { + &ADCBufCC26XX_fxnTable, + &adcBufCC26XXobjects[CC2650STK_ADCBUF0], + &adcBufCC26XXHWAttrs[CC2650STK_ADCBUF0] + }, +}; + +const uint_least8_t ADCBuf_count = CC2650STK_ADCBUFCOUNT; + +/* + * =============================== ADC =============================== + */ +#include <ti/drivers/ADC.h> +#include <ti/drivers/adc/ADCCC26XX.h> + +ADCCC26XX_Object adcCC26xxObjects[CC2650STK_ADCCOUNT]; + +const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650STK_ADCCOUNT] = { + { + .adcDIO = CC2650STK_DIO23_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO7, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC2650STK_DIO24_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO6, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC2650STK_DIO25_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO5, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC2650STK_DIO26_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO4, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC2650STK_DIO27_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO3, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC2650STK_DIO28_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO2, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC2650STK_DIO29_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO1, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = CC2650STK_DIO30_ANALOG, + .adcCompBInput = ADC_COMPB_IN_AUXIO0, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = PIN_UNASSIGNED, + .adcCompBInput = ADC_COMPB_IN_DCOUPL, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = PIN_UNASSIGNED, + .adcCompBInput = ADC_COMPB_IN_VSS, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + }, + { + .adcDIO = PIN_UNASSIGNED, + .adcCompBInput = ADC_COMPB_IN_VDDS, + .refSource = ADCCC26XX_FIXED_REFERENCE, + .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, + .inputScalingEnabled = true, + .triggerSource = ADCCC26XX_TRIGGER_MANUAL, + .returnAdjustedVal = false + } +}; + +const ADC_Config ADC_config[CC2650STK_ADCCOUNT] = { + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC0], &adcCC26xxHWAttrs[CC2650STK_ADC0]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC1], &adcCC26xxHWAttrs[CC2650STK_ADC1]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC2], &adcCC26xxHWAttrs[CC2650STK_ADC2]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC3], &adcCC26xxHWAttrs[CC2650STK_ADC3]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC4], &adcCC26xxHWAttrs[CC2650STK_ADC4]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC5], &adcCC26xxHWAttrs[CC2650STK_ADC5]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC6], &adcCC26xxHWAttrs[CC2650STK_ADC6]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADC7], &adcCC26xxHWAttrs[CC2650STK_ADC7]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADCDCOUPL], &adcCC26xxHWAttrs[CC2650STK_ADCDCOUPL]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADCVSS], &adcCC26xxHWAttrs[CC2650STK_ADCVSS]}, + {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650STK_ADCVDDS], &adcCC26xxHWAttrs[CC2650STK_ADCVDDS]}, +}; + +const uint_least8_t ADC_count = CC2650STK_ADCCOUNT; + /* * =============================== Crypto =============================== */ @@ -74,6 +247,170 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC2650STK_CRYPTOCOUNT] = { } }; +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC2650STK_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC2650STK_AESCCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCCM_Config AESCCM_config[CC2650STK_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC2650STK_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC2650STK_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC2650STK_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC2650STK_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC2650STK_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC2650STK_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC2650STK_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC2650STK_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC2650STK_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC2650STK_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC2650STK_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC2650STK_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC2650STK_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC2650STK_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC2650STK_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC2650STK_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC2650STK_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC2650STK_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC2650STK_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC2650STK_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC2650STK_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC2650STK_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC2650STK_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC2650STK_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC2650STK_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC2650STK_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC2650STK_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC2650STK_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC2650STK_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC2650STK_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC2650STK_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC2650STK_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC2650STK_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC2650STK_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC2650STK_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC2650STK_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC2650STK_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC2650STK_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC2650STK_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC2650STK_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -188,6 +525,34 @@ const uint_least8_t I2C_count = CC2650STK_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC2650STK_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC2650STK_I2SCOUNT] = { + { + .pinSD1 = CC2650STK_I2S_ADI, + .pinSD0 = CC2650STK_I2S_ADO, + .pinSCK = CC2650STK_I2S_BCLK, + .pinMCLK = CC2650STK_I2S_MCLK, + .pinWS = CC2650STK_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC2650STK_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC2650STK_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC2650STK_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC2650STK_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -240,9 +605,10 @@ static char flashBuf[REGIONSIZE]; #endif +/* Allocate objects for NVS Internal Regions */ NVSCC26XX_Object nvsCC26xxObjects[1]; -/* Hardware attributes for NVS */ +/* Hardware attributes for NVS Internal Regions */ const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = { { .regionBase = (void *)flashBuf, @@ -260,10 +626,10 @@ const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = { static uint8_t verifyBuf[VERIFYBUFSIZE]; -/* Allocate objects for NVS and NVS SPI */ +/* Allocate objects for NVS External Regions */ NVSSPI25X_Object nvsSPI25XObjects[1]; -/* Hardware attributes for NVS SPI */ +/* Hardware attributes for NVS External Regions */ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { { .regionBaseOffset = 0, @@ -275,6 +641,7 @@ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { .spiIndex = 0, .spiBitRate = 4000000, .spiCsnGpioIndex = CC2650STK_GPIO_SPI_FLASH_CS, + .statusPollDelayUs = 100, }, }; @@ -302,49 +669,6 @@ const uint_least8_t NVS_count = CC2650STK_NVSCOUNT; #endif /* TI_NVS_CONF_ENABLE */ -/* - * =============================== PDM =============================== -*/ -#include <ti/drivers/pdm/PDMCC26XX.h> -#include <ti/drivers/pdm/PDMCC26XX_util.h> - -PDMCC26XX_Object pdmCC26XXObjects[CC2650STK_PDMCOUNT]; -PDMCC26XX_I2S_Object pdmCC26XXI2SObjects[CC2650STK_PDMCOUNT]; - -const PDMCC26XX_HWAttrs pdmCC26XXHWAttrs[CC2650STK_PDMCOUNT] = { - { - .micPower = CC2650STK_MIC_POWER, - .taskPriority = 2 - } -}; - -const PDMCC26XX_Config PDMCC26XX_config[CC2650STK_PDMCOUNT] = { - { - .object = &pdmCC26XXObjects[CC2650STK_PDM0], - .hwAttrs = &pdmCC26XXHWAttrs[CC2650STK_PDM0] - } -}; - -const PDMCC26XX_I2S_HWAttrs pdmC26XXI2SHWAttrs[CC2650STK_PDMCOUNT] = { - { - .baseAddr = I2S0_BASE, - .intNum = INT_I2S_IRQ, - .powerMngrId = PowerCC26XX_PERIPH_I2S, - .intPriority = ~0, - .mclkPin = PIN_UNASSIGNED, - .bclkPin = CC2650STK_AUDIO_CLK, - .wclkPin = PIN_UNASSIGNED, - .ad0Pin = CC2650STK_AUDIO_DI, - } -}; - -const PDMCC26XX_I2S_Config PDMCC26XX_I2S_config[CC2650STK_PDMCOUNT] = { - { - .object = &pdmCC26XXI2SObjects[CC2650STK_PDM0], - .hwAttrs = &pdmC26XXI2SHWAttrs[CC2650STK_PDM0] - } -}; - /* * =============================== PIN =============================== */ @@ -353,31 +677,22 @@ const PDMCC26XX_I2S_Config PDMCC26XX_I2S_config[CC2650STK_PDMCOUNT] = { const PIN_Config BoardGpioInitTable[] = { - CC2650STK_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */ - CC2650STK_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ - CC2650STK_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ - CC2650STK_RELAY | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Relay is active high */ - CC2650STK_MPU_INT | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_NEGEDGE | PIN_HYSTERESIS, /* MPU_INT is active low */ - CC2650STK_TMP_RDY | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* TMP_RDY is active high */ - CC2650STK_BUZZER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Buzzer initially off */ - CC2650STK_MPU_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* MPU initially on */ - CC2650STK_MIC_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* MIC initially off */ + CC2650STK_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */ + CC2650STK_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */ + CC2650STK_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ + CC2650STK_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC2650STK_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ - CC2650STK_SPI_DEVPK_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* DevPack chip select */ - CC2650STK_AUDIO_DI | PIN_INPUT_EN | PIN_PULLDOWN, /* Audio DI */ - CC2650STK_AUDIODO | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* Audio data out */ - CC2650STK_AUDIO_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC2650STK_DP2 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC2650STK_DP1 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC2650STK_DP0 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC2650STK_DP3 | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ CC2650STK_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* DevPack */ CC2650STK_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* DevPack */ - CC2650STK_DEVPK_ID | PIN_INPUT_EN | PIN_NOPULL, /* Device pack ID - external PU */ CC2650STK_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */ CC2650STK_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */ CC2650STK_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */ - + CC2650STK_RELAY | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Relay is active high */ + CC2650STK_MPU_INT | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_NEGEDGE | PIN_HYSTERESIS, /* MPU_INT is active low */ + CC2650STK_TMP_RDY | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* TMP_RDY is active high */ + CC2650STK_BUZZER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Buzzer initially off */ + CC2650STK_MPU_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* MPU initially on */ + CC2650STK_MIC_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* MIC initially off */ PIN_TERMINATE }; @@ -389,9 +704,13 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { /* * =============================== Power =============================== */ +#include <ti/drivers/Power.h> +#include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" + const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -454,6 +773,11 @@ const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { SPICC26XXDMA_Object spiCC26XXDMAObjects[CC2650STK_SPICOUNT]; +/* + * NOTE: The SPI instances below can be used by the SD driver to communicate + * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF + * to satisfy the SDSPI driver requirement. + */ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC2650STK_SPICOUNT] = { #if TI_SPI_CONF_SPI0_ENABLE { @@ -462,7 +786,7 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC2650STK_SPICOUNT] = { .intPriority = ~0, .swiPriority = 0, .powerMngrId = PowerCC26XX_PERIPH_SSI0, - .defaultTxBufValue = 0, + .defaultTxBufValue = 0xFF, .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX, .txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX, .mosiPin = CC2650STK_SPI0_MOSI, @@ -479,7 +803,7 @@ const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC2650STK_SPICOUNT] = { .intPriority = ~0, .swiPriority = 0, .powerMngrId = PowerCC26XX_PERIPH_SSI1, - .defaultTxBufValue = 0, + .defaultTxBufValue = 0xFF, .rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX, .txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX, .mosiPin = CC2650STK_SPI1_MOSI, @@ -512,29 +836,6 @@ const uint_least8_t SPI_count = CC2650STK_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC2650STK_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC2650STK_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC2650STK_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -643,7 +944,7 @@ void CC2650STK_initGeneral(void) { Power_init(); - if ( PIN_init(BoardGpioInitTable) != PIN_SUCCESS) { + if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) { /* Error with PIN_init */ while (1); } @@ -651,3 +952,11 @@ void CC2650STK_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC2650STK_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.h index 17533f6cd5d63e2924803ad08fa216d6735f1daf..0f85207bb78182490b01d183d97b1a4054caa9ad 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,7 @@ /** ============================================================================ * @file CC2650STK.h * - * @brief CC2650STK Board Specific header file. + * @brief CC2650 SensorTag Board Specific header file. * * The CC2650STK header file should be included in an application as * follows: @@ -62,15 +62,23 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650STK /* Mapping of pins to board signals using general board aliases - * <board signal alias> <pin mapping> + * <board signal alias> <pin mapping> <comments> */ +/* Analog Capable DIOs */ +#define CC2650STK_DIO23_ANALOG IOID_23 +#define CC2650STK_DIO24_ANALOG IOID_24 +#define CC2650STK_DIO25_ANALOG IOID_25 +#define CC2650STK_DIO26_ANALOG IOID_26 +#define CC2650STK_DIO27_ANALOG IOID_27 +#define CC2650STK_DIO28_ANALOG IOID_28 +#define CC2650STK_DIO29_ANALOG IOID_29 +#define CC2650STK_DIO30_ANALOG IOID_30 + /* Audio */ #define CC2650STK_MIC_POWER IOID_13 #define CC2650STK_MIC_POWER_ON 1 #define CC2650STK_MIC_POWER_OFF 0 -#define CC2650STK_AUDIO_DI IOID_2 -#define CC2650STK_AUDIO_CLK IOID_11 /* Buzzer */ #define CC2650STK_BUZZER IOID_21 @@ -78,27 +86,26 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650STK_BUZZER_OFF 0 /* DevPack */ -#define CC2650STK_AUDIOFS_TDO IOID_16 -#define CC2650STK_AUDIODO IOID_22 -#define CC2650STK_DP2 IOID_23 -#define CC2650STK_DP1 IOID_24 #define CC2650STK_DP0 IOID_25 +#define CC2650STK_DP1 IOID_24 +#define CC2650STK_DP2 IOID_23 #define CC2650STK_DP3 IOID_27 #define CC2650STK_DP4_UARTRX IOID_28 #define CC2650STK_DP5_UARTTX IOID_29 -#define CC2650STK_DEVPK_ID IOID_30 -#define CC2650STK_SPI_DEVPK_CS IOID_20 - -/* Discrete Outputs */ -#define CC2650STK_PIN_LED0 IOID_10 -#define CC2650STK_PIN_LED1 IOID_15 -#define CC2650STK_LED_ON 1 -#define CC2650STK_LED_OFF 0 - +#define CC2650STK_DP6_ADO IOID_22 +#define CC2650STK_DP7_BCLK IOID_3 +#define CC2650STK_DP8_TDI IOID_17 +#define CC2650STK_DP9_MISO IOID_18 +#define CC2650STK_DP10_MOSI IOID_19 +#define CC2650STK_DP11_CSN IOID_20 +#define CC2650STK_DP12_WCLK IOID_16 +#define CC2650STK_DP_ID IOID_30 /* Discrete Inputs */ -#define CC2650STK_KEY_LEFT IOID_0 -#define CC2650STK_KEY_RIGHT IOID_4 +#define CC2650STK_PIN_BTN1 IOID_4 +#define CC2650STK_PIN_BTN2 IOID_0 +#define CC2650STK_KEY_LEFT CC2650STK_PIN_BTN2 +#define CC2650STK_KEY_RIGHT CC2650STK_PIN_BTN1 #define CC2650STK_RELAY IOID_3 /* GPIO */ @@ -106,10 +113,23 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650STK_GPIO_LED_OFF 0 /* I2C */ -#define CC2650STK_I2C0_SDA0 IOID_5 #define CC2650STK_I2C0_SCL0 IOID_6 -#define CC2650STK_I2C0_SDA1 IOID_8 +#define CC2650STK_I2C0_SDA0 IOID_5 #define CC2650STK_I2C0_SCL1 IOID_9 +#define CC2650STK_I2C0_SDA1 IOID_8 + +/* I2S */ +#define CC2650STK_I2S_ADO IOID_22 +#define CC2650STK_I2S_ADI IOID_2 +#define CC2650STK_I2S_BCLK IOID_3 +#define CC2650STK_I2S_MCLK PIN_UNASSIGNED +#define CC2650STK_I2S_WCLK IOID_16 + +/* LEDs */ +#define CC2650STK_PIN_LED_ON 1 +#define CC2650STK_PIN_LED_OFF 0 +#define CC2650STK_PIN_RLED IOID_10 +#define CC2650STK_PIN_GLED IOID_15 /* LED-Audio DevPack */ #define CC2650STK_DEVPK_LIGHT_BLUE IOID_23 @@ -123,8 +143,8 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650STK_MPU_POWER_OFF 0 /* PWM */ -#define CC2650STK_PWMPIN0 CC2650STK_PIN_LED1 -#define CC2650STK_PWMPIN1 CC2650STK_PIN_LED1 +#define CC2650STK_PWMPIN0 CC2650STK_PIN_RLED +#define CC2650STK_PWMPIN1 CC2650STK_PIN_GLED #define CC2650STK_PWMPIN2 PIN_UNASSIGNED #define CC2650STK_PWMPIN3 PIN_UNASSIGNED #define CC2650STK_PWMPIN4 PIN_UNASSIGNED @@ -145,7 +165,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650STK_SPI0_MISO IOID_18 #define CC2650STK_SPI0_MOSI IOID_19 #define CC2650STK_SPI0_CLK IOID_17 -#define CC2650STK_SPI0_CSN PIN_UNASSIGNED +#define CC2650STK_SPI0_CSN IOID_20 #define CC2650STK_SPI1_MISO PIN_UNASSIGNED #define CC2650STK_SPI1_MOSI PIN_UNASSIGNED #define CC2650STK_SPI1_CLK PIN_UNASSIGNED @@ -176,6 +196,56 @@ void CC2650STK_shutDownExtFlash(void); */ void CC2650STK_wakeUpExtFlash(void); +/*! + * @def CC2650STK_ADCBufName + * @brief Enum of ADCBufs + */ +typedef enum CC2650STK_ADCBufName { + CC2650STK_ADCBUF0 = 0, + + CC2650STK_ADCBUFCOUNT +} CC2650STK_ADCBufName; + +/*! + * @def CC2650STK_ADCBuf0ChannelName + * @brief Enum of ADCBuf channels + */ +typedef enum CC2650STK_ADCBuf0ChannelName { + CC2650STK_ADCBUF0CHANNEL0 = 0, + CC2650STK_ADCBUF0CHANNEL1, + CC2650STK_ADCBUF0CHANNEL2, + CC2650STK_ADCBUF0CHANNEL3, + CC2650STK_ADCBUF0CHANNEL4, + CC2650STK_ADCBUF0CHANNEL5, + CC2650STK_ADCBUF0CHANNEL6, + CC2650STK_ADCBUF0CHANNEL7, + CC2650STK_ADCBUF0CHANNELVDDS, + CC2650STK_ADCBUF0CHANNELDCOUPL, + CC2650STK_ADCBUF0CHANNELVSS, + + CC2650STK_ADCBUF0CHANNELCOUNT +} CC2650STK_ADCBuf0ChannelName; + +/*! + * @def CC2650STK_ADCName + * @brief Enum of ADCs + */ +typedef enum CC2650STK_ADCName { + CC2650STK_ADC0 = 0, + CC2650STK_ADC1, + CC2650STK_ADC2, + CC2650STK_ADC3, + CC2650STK_ADC4, + CC2650STK_ADC5, + CC2650STK_ADC6, + CC2650STK_ADC7, + CC2650STK_ADCDCOUPL, + CC2650STK_ADCVSS, + CC2650STK_ADCVDDS, + + CC2650STK_ADCCOUNT +} CC2650STK_ADCName; + /*! * @def CC2650STK_CryptoName * @brief Enum of Crypto names @@ -186,6 +256,76 @@ typedef enum CC2650STK_CryptoName { CC2650STK_CRYPTOCOUNT } CC2650STK_CryptoName; +/*! + * @def CC2650STK_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC2650STK_AESCCMName { + CC2650STK_AESCCM0 = 0, + + CC2650STK_AESCCMCOUNT +} CC2650STK_AESCCMName; + +/*! + * @def CC2650STK_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC2650STK_AESGCMName { + CC2650STK_AESGCM0 = 0, + + CC2650STK_AESGCMCOUNT +} CC2650STK_AESGCMName; + +/*! + * @def CC2650STK_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC2650STK_AESCBCName { + CC2650STK_AESCBC0 = 0, + + CC2650STK_AESCBCCOUNT +} CC2650STK_AESCBCName; + +/*! + * @def CC2650STK_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC2650STK_AESCTRName { + CC2650STK_AESCTR0 = 0, + + CC2650STK_AESCTRCOUNT +} CC2650STK_AESCTRName; + +/*! + * @def CC2650STK_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC2650STK_AESECBName { + CC2650STK_AESECB0 = 0, + + CC2650STK_AESECBCOUNT +} CC2650STK_AESECBName; + +/*! + * @def CC2650STK_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC2650STK_AESCTRDRBGName { + CC2650STK_AESCTRDRBG0 = 0, + + CC2650STK_AESCTRDRBGCOUNT +} CC2650STK_AESCTRDRBGName; + +/*! + * @def CC2650STK_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC2650STK_TRNGName { + CC2650STK_TRNG0 = 0, + + CC2650STK_TRNGCOUNT +} CC2650STK_TRNGName; + /*! * @def CC2650STK_GPIOName * @brief Enum of GPIO names @@ -201,7 +341,7 @@ typedef enum CC2650STK_GPIOName { /*! * @def CC2650STK_GPTimerName - * @brief Enum of GPTimers parts + * @brief Enum of GPTimer parts */ typedef enum CC2650STK_GPTimerName { CC2650STK_GPTIMER0A = 0, @@ -241,6 +381,16 @@ typedef enum CC2650STK_I2CName { CC2650STK_I2CCOUNT } CC2650STK_I2CName; +/*! + * @def CC2650STK_I2SName + * @brief Enum of I2S names + */ +typedef enum CC2650STK_I2SName { + CC2650STK_I2S0 = 0, + + CC2650STK_I2SCOUNT +} CC2650STK_I2SName; + /*! * @def CC2650STK_NVSName * @brief Enum of NVS names @@ -256,16 +406,6 @@ typedef enum CC2650STK_NVSName { CC2650STK_NVSCOUNT } CC2650STK_NVSName; -/*! - * @def CC2650STK_PDMName - * @brief Enum of PDM names - */ -typedef enum CC2650STK_PDMName { - CC2650STK_PDM0 = 0, - - CC2650STK_PDMCOUNT -} CC2650STK_PDMName; - /*! * @def CC2650STK_PWMName * @brief Enum of PWM outputs @@ -298,16 +438,6 @@ typedef enum CC2650STK_SPIName { CC2650STK_SPICOUNT } CC2650STK_SPIName; -/*! - * @def CC2650STK_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC2650STK_TRNGName { - CC2650STK_TRNG0 = 0, - - CC2650STK_TRNGCOUNT -} CC2650STK_TRNGName; - /*! * @def CC2650STK_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK_fxns.c index 3312a170202d865db142673a12e1f27effd4b571..6ea7542728a1a01acaf27f8648cbc23af078aff9 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/cc2650/CC2650STK_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,8 +42,11 @@ #include DeviceFamily_constructPath(driverlib/ioc.h) #include DeviceFamily_constructPath(driverlib/cpu.h) +#include <ti/drivers/Board.h> + #include "Board.h" + /* * ======== CC2650STK_sendExtFlashByte ======== */ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/Board.h index 48d232e54c6d8e52a3c804d4fbe5c7285c02f0aa..8072fbd20538be17646a89910e4390d5057c1d1e 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/Board.h @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC1350DK_7XD.h" #define Board_CC1350DK_7XD #define BOARD_STRING "TI SmartRF06EB + CC13x0 EM" -#define Board_initGeneral() CC1350DK_7XD_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC1350DK_7XD_shutDownExtFlash() #define Board_wakeUpExtFlash() CC1350DK_7XD_wakeUpExtFlash() @@ -58,6 +59,13 @@ extern "C" { #define Board_ADCBUF0CHANNEL1 CC1350DK_7XD_ADCBUF0CHANNELADCALS #define Board_CRYPTO0 CC1350DK_7XD_CRYPTO0 +#define Board_AESCCM0 CC1350DK_7XD_AESCCM0 +#define Board_AESGCM0 CC1350DK_7XD_AESGCM0 +#define Board_AESCBC0 CC1350DK_7XD_AESCBC0 +#define Board_AESCTR0 CC1350DK_7XD_AESCTR0 +#define Board_AESECB0 CC1350DK_7XD_AESECB0 +#define Board_AESCTRDRBG0 CC1350DK_7XD_AESCTRDRBG0 +#define Board_TRNG0 CC1350DK_7XD_TRNG0 #define Board_DIO0 CC1350DK_7XD_DIO0 #define Board_DIO1_RFSW CC1350DK_7XD_DIO1_RFSW @@ -100,6 +108,13 @@ extern "C" { #define Board_I2C0 CC1350DK_7XD_I2C0 +#define Board_I2S0 CC1350DK_7XD_I2S0 +#define Board_I2S_ADO CC1350DK_7XD_I2S_ADO +#define Board_I2S_ADI CC1350DK_7XD_I2S_ADI +#define Board_I2S_BCLK CC1350DK_7XD_I2S_BCLK +#define Board_I2S_MCLK CC1350DK_7XD_I2S_MCLK +#define Board_I2S_WCLK CC1350DK_7XD_I2S_WCLK + #define Board_NVSINTERNAL CC1350DK_7XD_NVSCC26XX0 #define Board_KEY_SELECT CC1350DK_7XD_PIN_KEY_SELECT diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.c b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.c index 2040a75829af020e3c84e911cb13b14a6f16d865..5702fbc6b8c900bd4f6dda9079917e857205d9a6 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, Texas Instruments Incorporated + * Copyright (c) 2016-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,8 +75,6 @@ const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC1350DK_7XD_ADCBUFCOUNT] = { .intPriority = ~0, .swiPriority = 0, .adcChannelLut = ADCBufCC26XX_adcChannelLut, - .gpTimerUnit = CC1350DK_7XD_GPTIMER0A, - .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A, } }; @@ -169,6 +167,170 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC1350DK_7XD_CRYPTOCOUNT] = { }, }; +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC1350DK_7XD_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1350DK_7XD_AESCCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCCM_Config AESCCM_config[CC1350DK_7XD_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC1350DK_7XD_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC1350DK_7XD_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC1350DK_7XD_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC1350DK_7XD_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC1350DK_7XD_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC1350DK_7XD_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC1350DK_7XD_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC1350DK_7XD_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC1350DK_7XD_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC1350DK_7XD_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC1350DK_7XD_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC1350DK_7XD_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC1350DK_7XD_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC1350DK_7XD_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC1350DK_7XD_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC1350DK_7XD_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC1350DK_7XD_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC1350DK_7XD_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC1350DK_7XD_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC1350DK_7XD_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC1350DK_7XD_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC1350DK_7XD_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1350DK_7XD_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC1350DK_7XD_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC1350DK_7XD_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC1350DK_7XD_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC1350DK_7XD_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC1350DK_7XD_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC1350DK_7XD_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC1350DK_7XD_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC1350DK_7XD_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC1350DK_7XD_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC1350DK_7XD_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC1350DK_7XD_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC1350DK_7XD_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC1350DK_7XD_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC1350DK_7XD_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC1350DK_7XD_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC1350DK_7XD_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC1350DK_7XD_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -210,7 +372,7 @@ GPIO_PinConfig gpioPinConfigs[] = { /* * Array of callback function pointers * NOTE: The order of the pin configurations must coincide with what was - * defined in CC2650_LAUNCH.h + * defined in CC1350DK_7XD.h * NOTE: Pins not used for interrupts can be omitted from callbacks array to * reduce memory usage (if placed at end of gpioPinConfigs array). */ @@ -297,6 +459,34 @@ const uint_least8_t I2C_count = CC1350DK_7XD_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC1350DK_7XD_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC1350DK_7XD_I2SCOUNT] = { + { + .pinSD1 = CC1350DK_7XD_I2S_ADI, + .pinSD0 = CC1350DK_7XD_I2S_ADO, + .pinSCK = CC1350DK_7XD_I2S_BCLK, + .pinMCLK = CC1350DK_7XD_I2S_MCLK, + .pinWS = CC1350DK_7XD_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC1350DK_7XD_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC1350DK_7XD_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC1350DK_7XD_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC1350DK_7XD_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -393,7 +583,7 @@ const PIN_Config BoardGpioInitTable[] = { CC1350DK_7XD_PIN_KEY_DOWN | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1350DK_7XD_PIN_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC1350DK_7XD_PIN_KEY_UP | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ - CC1350DK_7XD_SDCARD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ + CC1350DK_7XD_SPI_SDCARD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ CC1350DK_7XD_ACC_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ CC1350DK_7XD_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ CC1350DK_7XD_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ @@ -414,10 +604,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -487,7 +678,7 @@ SDSPI_Object sdspiObjects[CC1350DK_7XD_SDCOUNT]; const SDSPI_HWAttrs sdspiHWAttrs[CC1350DK_7XD_SDCOUNT] = { { .spiIndex = CC1350DK_7XD_SPI0, - .spiCsGpioIndex = CC1350DK_7XD_SDCARD_CS + .spiCsGpioIndex = CC1350DK_7XD_SDSPI_CS } }; @@ -576,29 +767,6 @@ const uint_least8_t SPI_count = CC1350DK_7XD_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC1350DK_7XD_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1350DK_7XD_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC1350DK_7XD_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -717,3 +885,11 @@ void CC1350DK_7XD_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC1350DK_7XD_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.h b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.h index 4c705abe57bb83a075ce0c7cb4a5664126ad0e27..8ea9e5a87aa65e3d9f67ca2232ccf9cac87d2fe5 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350DK_7XD /* Mapping of pins to board signals using general board aliases - * <board signal alias> <pin mapping> + * <board signal alias> <pin mapping> <comments> */ /* Analog Capable DIOs */ @@ -101,6 +101,13 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350DK_7XD_I2C0_SCL0 PIN_UNASSIGNED #define CC1350DK_7XD_I2C0_SDA0 PIN_UNASSIGNED +/* I2S */ +#define CC1350DK_7XD_I2S_ADO PIN_UNASSIGNED +#define CC1350DK_7XD_I2S_ADI PIN_UNASSIGNED +#define CC1350DK_7XD_I2S_BCLK PIN_UNASSIGNED +#define CC1350DK_7XD_I2S_MCLK PIN_UNASSIGNED +#define CC1350DK_7XD_I2S_WCLK PIN_UNASSIGNED + /* LEDs */ #define CC1350DK_7XD_PIN_LED_ON 1 #define CC1350DK_7XD_PIN_LED_OFF 0 @@ -112,8 +119,8 @@ extern const PIN_Config BoardGpioInitTable[]; /* PWM Outputs */ #define CC1350DK_7XD_PWMPIN0 CC1350DK_7XD_PIN_LED1 #define CC1350DK_7XD_PWMPIN1 CC1350DK_7XD_PIN_LED2 -#define CC1350DK_7XD_PWMPIN2 PIN_UNASSIGNED -#define CC1350DK_7XD_PWMPIN3 PIN_UNASSIGNED +#define CC1350DK_7XD_PWMPIN2 CC1350DK_7XD_PIN_LED3 +#define CC1350DK_7XD_PWMPIN3 CC1350DK_7XD_PIN_LED4 #define CC1350DK_7XD_PWMPIN4 PIN_UNASSIGNED #define CC1350DK_7XD_PWMPIN5 PIN_UNASSIGNED #define CC1350DK_7XD_PWMPIN6 PIN_UNASSIGNED @@ -136,7 +143,9 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC1350DK_7XD_UART_RTS IOID_21 /* SD Card */ -#define CC1350DK_7XD_SDCARD_CS IOID_30 +#define CC1350DK_7XD_SPI_SDCARD_CS IOID_30 +#define CC1350DK_7XD_SDCARD_CS_ON 0 +#define CC1350DK_7XD_SDCARD_CS_OFF 1 /* Ambient Light Sensor */ #define CC1350DK_7XD_ALS_OUT IOID_23 @@ -169,7 +178,7 @@ void CC1350DK_7XD_wakeUpExtFlash(void); /*! * @def CC1350DK_7XD_ADCBufName - * @brief Enum of ADCs + * @brief Enum of ADCBufs */ typedef enum CC1350DK_7XD_ADCBufName { CC1350DK_7XD_ADCBUF0 = 0, @@ -213,6 +222,76 @@ typedef enum CC1350DK_7XD_CryptoName { CC1350DK_7XD_CRYPTOCOUNT } CC1350DK_7XD_CryptoName; +/*! + * @def CC1350DK_7XD_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC1350DK_7XD_AESCCMName { + CC1350DK_7XD_AESCCM0 = 0, + + CC1350DK_7XD_AESCCMCOUNT +} CC1350DK_7XD_AESCCMName; + +/*! + * @def CC1350DK_7XD_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC1350DK_7XD_AESGCMName { + CC1350DK_7XD_AESGCM0 = 0, + + CC1350DK_7XD_AESGCMCOUNT +} CC1350DK_7XD_AESGCMName; + +/*! + * @def CC1350DK_7XD_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC1350DK_7XD_AESCBCName { + CC1350DK_7XD_AESCBC0 = 0, + + CC1350DK_7XD_AESCBCCOUNT +} CC1350DK_7XD_AESCBCName; + +/*! + * @def CC1350DK_7XD_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC1350DK_7XD_AESCTRName { + CC1350DK_7XD_AESCTR0 = 0, + + CC1350DK_7XD_AESCTRCOUNT +} CC1350DK_7XD_AESCTRName; + +/*! + * @def CC1350DK_7XD_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC1350DK_7XD_AESECBName { + CC1350DK_7XD_AESECB0 = 0, + + CC1350DK_7XD_AESECBCOUNT +} CC1350DK_7XD_AESECBName; + +/*! + * @def CC1350DK_7XD_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC1350DK_7XD_AESCTRDRBGName { + CC1350DK_7XD_AESCTRDRBG0 = 0, + + CC1350DK_7XD_AESCTRDRBGCOUNT +} CC1350DK_7XD_AESCTRDRBGName; + +/*! + * @def CC1350DK_7XD_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC1350DK_7XD_TRNGName { + CC1350DK_7XD_TRNG0 = 0, + + CC1350DK_7XD_TRNGCOUNT +} CC1350DK_7XD_TRNGName; + /*! * @def CC1350DK_7XD_GPIOName * @brief Enum of GPIO names @@ -229,7 +308,7 @@ typedef enum CC1350DK_7XD_GPIOName { CC1350DK_7XD_GPIO_LED2, CC1350DK_7XD_GPIO_LED3, CC1350DK_7XD_GPIO_LED4, - CC1350DK_7XD_GPIO_SDCARD_CS, + CC1350DK_7XD_SDSPI_CS, CC1350DK_7XD_GPIO_ACC_CS, CC1350DK_7XD_GPIOCOUNT @@ -277,6 +356,16 @@ typedef enum CC1350DK_7XD_I2CName { CC1350DK_7XD_I2CCOUNT } CC1350DK_7XD_I2CName; +/*! + * @def CC1350DK_7XD_I2SName + * @brief Enum of I2S names + */ +typedef enum CC1350DK_7XD_I2SName { + CC1350DK_7XD_I2S0 = 0, + + CC1350DK_7XD_I2SCOUNT +} CC1350DK_7XD_I2SName; + /*! * @def CC1350DK_7XD_NVSName * @brief Enum of NVS names @@ -331,16 +420,6 @@ typedef enum CC1350DK_7XD_SPIName { CC1350DK_7XD_SPICOUNT } CC1350DK_7XD_SPIName; -/*! - * @def CC1350DK_7XD_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC1350DK_7XD_TRNGName { - CC1350DK_7XD_TRNG0 = 0, - - CC1350DK_7XD_TRNGCOUNT -} CC1350DK_7XD_TRNGName; - /*! * @def CC1350DK_7XD_UARTName * @brief Enum of UARTs diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD_fxns.c index b7983730a320ad0f3958d450b4f2c19b264497b7..e6f1d7bc766e234b65f6755d9f7f7a6c0848bd80 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc13x0/CC1350DK_7XD_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/Board.h b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/Board.h index d90291418346de9a8977cdb5b3d86eaca9028774..9f2bf370ed7ad96c7323b435e2bef65379746dda 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/Board.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/Board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,12 +37,13 @@ extern "C" { #endif +#include <ti/drivers/Board.h> #include "CC2650DK_7ID.h" #define Board_CC2650DK_7ID #define BOARD_STRING "TI SmartRF06EB + CC26x0 EM" -#define Board_initGeneral() CC2650DK_7ID_initGeneral() +#define Board_initGeneral() Board_init() /* deprecated */ #define Board_shutDownExtFlash() CC2650DK_7ID_shutDownExtFlash() #define Board_wakeUpExtFlash() CC2650DK_7ID_wakeUpExtFlash() @@ -58,6 +59,13 @@ extern "C" { #define Board_ADCBUF0CHANNEL1 CC2650DK_7ID_ADCBUF0CHANNELADCALS #define Board_CRYPTO0 CC2650DK_7ID_CRYPTO0 +#define Board_AESCCM0 CC2650DK_7ID_AESCCM0 +#define Board_AESGCM0 CC2650DK_7ID_AESGCM0 +#define Board_AESCBC0 CC2650DK_7ID_AESCBC0 +#define Board_AESCTR0 CC2650DK_7ID_AESCTR0 +#define Board_AESECB0 CC2650DK_7ID_AESECB0 +#define Board_AESCTRDRBG0 CC2650DK_7ID_AESCTRDRBG0 +#define Board_TRNG0 CC2650DK_7ID_TRNG0 #define Board_DIO0 CC2650DK_7ID_DIO0 #define Board_DIO1_RFSW CC2650DK_7ID_DIO1_RFSW @@ -100,6 +108,13 @@ extern "C" { #define Board_I2C0 CC2650DK_7ID_I2C0 +#define Board_I2S0 CC2650DK_7ID_I2S0 +#define Board_I2S_ADO CC2650DK_7ID_I2S_ADO +#define Board_I2S_ADI CC2650DK_7ID_I2S_ADI +#define Board_I2S_BCLK CC2650DK_7ID_I2S_BCLK +#define Board_I2S_MCLK CC2650DK_7ID_I2S_MCLK +#define Board_I2S_WCLK CC2650DK_7ID_I2S_WCLK + #define Board_NVSINTERNAL CC2650DK_7ID_NVSCC26XX0 #define Board_KEY_SELECT CC2650DK_7ID_PIN_KEY_SELECT diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.c b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.c index 4d0115d3800125fa6bcad096ad8d57de91876abe..49f8e93f69c5c21666de2b446e1ea72442cb59f3 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, Texas Instruments Incorporated + * Copyright (c) 2016-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,8 +75,6 @@ const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC2650DK_7ID_ADCBUFCOUNT] = { .intPriority = ~0, .swiPriority = 0, .adcChannelLut = ADCBufCC26XX_adcChannelLut, - .gpTimerUnit = CC2650DK_7ID_GPTIMER0A, - .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A, } }; @@ -169,6 +167,170 @@ const CryptoCC26XX_Config CryptoCC26XX_config[CC2650DK_7ID_CRYPTOCOUNT] = { }, }; +/* + * =============================== AESCCM =============================== + */ +#include <ti/drivers/AESCCM.h> +#include <ti/drivers/aesccm/AESCCMCC26XX.h> + +AESCCMCC26XX_Object aesccmCC26XXObjects[CC2650DK_7ID_AESCCMCOUNT]; + +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC2650DK_7ID_AESCCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCCM_Config AESCCM_config[CC2650DK_7ID_AESCCMCOUNT] = { + { + .object = &aesccmCC26XXObjects[CC2650DK_7ID_AESCCM0], + .hwAttrs = &aesccmCC26XXHWAttrs[CC2650DK_7ID_AESCCM0] + }, +}; + +const uint_least8_t AESCCM_count = CC2650DK_7ID_AESCCMCOUNT; + + +/* + * =============================== AESGCM =============================== + */ +#include <ti/drivers/AESGCM.h> +#include <ti/drivers/aesgcm/AESGCMCC26XX.h> + +AESGCMCC26XX_Object aesgcmCC26XXObjects[CC2650DK_7ID_AESGCMCOUNT]; + +const AESGCMCC26XX_HWAttrs aesgcmCC26XXHWAttrs[CC2650DK_7ID_AESGCMCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESGCM_Config AESGCM_config[CC2650DK_7ID_AESGCMCOUNT] = { + { + .object = &aesgcmCC26XXObjects[CC2650DK_7ID_AESGCM0], + .hwAttrs = &aesgcmCC26XXHWAttrs[CC2650DK_7ID_AESGCM0] + }, +}; + +const uint_least8_t AESGCM_count = CC2650DK_7ID_AESGCMCOUNT; + +/* + * =============================== AESCBC =============================== + */ +#include <ti/drivers/AESCBC.h> +#include <ti/drivers/aescbc/AESCBCCC26XX.h> + +AESCBCCC26XX_Object aescbcCC26XXObjects[CC2650DK_7ID_AESCBCCOUNT]; + +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CC2650DK_7ID_AESCBCCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCBC_Config AESCBC_config[CC2650DK_7ID_AESCBCCOUNT] = { + { + .object = &aescbcCC26XXObjects[CC2650DK_7ID_AESCBC0], + .hwAttrs = &aescbcCC26XXHWAttrs[CC2650DK_7ID_AESCBC0] + }, +}; + +const uint_least8_t AESCBC_count = CC2650DK_7ID_AESCBCCOUNT; + +/* + * =============================== AESCTR =============================== + */ +#include <ti/drivers/AESCTR.h> +#include <ti/drivers/aesctr/AESCTRCC26XX.h> + +AESCTRCC26XX_Object aesctrCC26XXObjects[CC2650DK_7ID_AESCTRCOUNT]; + +const AESCTRCC26XX_HWAttrs aesctrCC26XXHWAttrs[CC2650DK_7ID_AESCTRCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESCTR_Config AESCTR_config[CC2650DK_7ID_AESCTRCOUNT] = { + { + .object = &aesctrCC26XXObjects[CC2650DK_7ID_AESCTR0], + .hwAttrs = &aesctrCC26XXHWAttrs[CC2650DK_7ID_AESCTR0] + }, +}; + +const uint_least8_t AESCTR_count = CC2650DK_7ID_AESCTRCOUNT; + +/* + * =============================== AESECB =============================== + */ +#include <ti/drivers/AESECB.h> +#include <ti/drivers/aesecb/AESECBCC26XX.h> + +AESECBCC26XX_Object aesecbCC26XXObjects[CC2650DK_7ID_AESECBCOUNT]; + +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC2650DK_7ID_AESECBCOUNT] = { + { + .intPriority = ~0, + } +}; + +const AESECB_Config AESECB_config[CC2650DK_7ID_AESECBCOUNT] = { + { + .object = &aesecbCC26XXObjects[CC2650DK_7ID_AESECB0], + .hwAttrs = &aesecbCC26XXHWAttrs[CC2650DK_7ID_AESECB0] + }, +}; + +const uint_least8_t AESECB_count = CC2650DK_7ID_AESECBCOUNT; + +/* + * =============================== AESCTRDRBG =============================== + */ +#include <ti/drivers/AESCTRDRBG.h> +#include <ti/drivers/aesctrdrbg/AESCTRDRBGXX.h> + +AESCTRDRBGXX_Object aesctrdrbgXXObjects[CC2650DK_7ID_AESCTRDRBGCOUNT]; + +const AESCTRDRBGXX_HWAttrs aesctrdrbgXXHWAttrs[CC2650DK_7ID_AESCTRDRBGCOUNT] = { + { + .aesctrIndex = CC2650DK_7ID_AESCTR0, + } +}; + +const AESCTRDRBG_Config AESCTRDRBG_config[CC2650DK_7ID_AESCTRDRBGCOUNT] = { + { + .object = &aesctrdrbgXXObjects[CC2650DK_7ID_AESCTRDRBG0], + .hwAttrs = &aesctrdrbgXXHWAttrs[CC2650DK_7ID_AESCTRDRBG0] + }, +}; + +const uint_least8_t AESCTRDRBG_count = CC2650DK_7ID_AESCTRDRBGCOUNT; + +/* + * =============================== TRNG =============================== + */ +#include <ti/drivers/TRNG.h> +#include <ti/drivers/trng/TRNGCC26XX.h> + +TRNGCC26XX_Object trngCC26XXObjects[CC2650DK_7ID_TRNGCOUNT]; + +const TRNGCC26XX_HWAttrs trngCC26X2HWAttrs[CC2650DK_7ID_TRNGCOUNT] = { + { + .intPriority = ~0, + .swiPriority = 0, + .samplesPerCycle = 240000, + } +}; + +const TRNG_Config TRNG_config[CC2650DK_7ID_TRNGCOUNT] = { + { + .object = &trngCC26XXObjects[CC2650DK_7ID_TRNG0], + .hwAttrs = &trngCC26X2HWAttrs[CC2650DK_7ID_TRNG0] + }, +}; + +const uint_least8_t TRNG_count = CC2650DK_7ID_TRNGCOUNT; + /* * =============================== GPIO =============================== */ @@ -297,6 +459,34 @@ const uint_least8_t I2C_count = CC2650DK_7ID_I2CCOUNT; #endif /* TI_I2C_CONF_ENABLE */ +/* + * =============================== I2S =============================== +*/ +#include <ti/drivers/I2S.h> +#include <ti/drivers/i2s/I2SCC26XX.h> + +I2SCC26XX_Object i2sCC26XXObjects[CC2650DK_7ID_I2SCOUNT]; + +const I2SCC26XX_HWAttrs i2sCC26XXHWAttrs[CC2650DK_7ID_I2SCOUNT] = { + { + .pinSD1 = CC2650DK_7ID_I2S_ADI, + .pinSD0 = CC2650DK_7ID_I2S_ADO, + .pinSCK = CC2650DK_7ID_I2S_BCLK, + .pinMCLK = CC2650DK_7ID_I2S_MCLK, + .pinWS = CC2650DK_7ID_I2S_WCLK, + .intPriority = ~0, + } +}; + +const I2S_Config I2S_config[CC2650DK_7ID_I2SCOUNT] = { + { + .object = &i2sCC26XXObjects[CC2650DK_7ID_I2S0], + .hwAttrs = &i2sCC26XXHWAttrs[CC2650DK_7ID_I2S0] + }, +}; + +const uint_least8_t I2S_count = CC2650DK_7ID_I2SCOUNT; + /* * =============================== NVS =============================== */ @@ -394,7 +584,7 @@ const PIN_Config BoardGpioInitTable[] = { CC2650DK_7ID_PIN_KEY_DOWN | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC2650DK_7ID_PIN_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ CC2650DK_7ID_PIN_KEY_UP | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */ - CC2650DK_7ID_SDCARD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ + CC2650DK_7ID_SPI_SDCARD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ CC2650DK_7ID_ACC_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */ CC2650DK_7ID_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */ CC2650DK_7ID_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */ @@ -415,10 +605,11 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { */ #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> +#include "clock-arch.h" const PowerCC26XX_Config PowerCC26XX_config = { .policyInitFxn = NULL, - .policyFxn = &PowerCC26XX_standbyPolicy, + .policyFxn = &clock_arch_standby_policy, .calibrateFxn = &PowerCC26XX_calibrate, .enablePolicy = true, .calibrateRCOSC_LF = true, @@ -488,7 +679,7 @@ SDSPI_Object sdspiObjects[CC2650DK_7ID_SDCOUNT]; const SDSPI_HWAttrs sdspiHWAttrs[CC2650DK_7ID_SDCOUNT] = { { .spiIndex = CC2650DK_7ID_SPI0, - .spiCsGpioIndex = CC2650DK_7ID_SDCARD_CS + .spiCsGpioIndex = CC2650DK_7ID_SDSPI_CS } }; @@ -577,29 +768,6 @@ const uint_least8_t SPI_count = CC2650DK_7ID_SPICOUNT; #endif /* TI_SPI_CONF_ENABLE */ - -/* - * =============================== TRNG =============================== - */ -#include <ti/drivers/TRNG.h> -#include <ti/drivers/trng/TRNGCC26X0.h> - -TRNGCC26X0_Object trngCC26X0Object[CC2650DK_7ID_TRNGCOUNT]; - -const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC2650DK_7ID_TRNGCOUNT] = { - { - .swiPriority = 0, - .intPriority = ~0, - } -}; - -const TRNG_Config TRNG_config[] = { - { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] }, -}; - -const uint8_t TRNG_count = CC2650DK_7ID_TRNGCOUNT; - - /* * =============================== UART =============================== */ @@ -718,3 +886,11 @@ void CC2650DK_7ID_initGeneral(void) /* Perform board-specific initialization */ Board_initHook(); } + +/* + * ======== Board_init ======== + */ +void Board_init(void) +{ + CC2650DK_7ID_initGeneral(); +} diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.h b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.h index 21bae0eedb6cc0c3b856a2a2d880c6586fc30e57..faf2ea13228cac3c65724e7f98cdae2c3e76796f 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650DK_7ID /* Mapping of pins to board signals using general board aliases - * <board signal alias> <pin mapping> + * <board signal alias> <pin mapping> <comments> */ /* Analog Capable DIOs */ @@ -101,6 +101,13 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650DK_7ID_I2C0_SCL0 PIN_UNASSIGNED #define CC2650DK_7ID_I2C0_SDA0 PIN_UNASSIGNED +/* I2S */ +#define CC2650DK_7ID_I2S_ADO PIN_UNASSIGNED +#define CC2650DK_7ID_I2S_ADI PIN_UNASSIGNED +#define CC2650DK_7ID_I2S_BCLK PIN_UNASSIGNED +#define CC2650DK_7ID_I2S_MCLK PIN_UNASSIGNED +#define CC2650DK_7ID_I2S_WCLK PIN_UNASSIGNED + /* LEDs */ #define CC2650DK_7ID_PIN_LED_ON 1 #define CC2650DK_7ID_PIN_LED_OFF 0 @@ -112,8 +119,8 @@ extern const PIN_Config BoardGpioInitTable[]; /* PWM Outputs */ #define CC2650DK_7ID_PWMPIN0 CC2650DK_7ID_PIN_LED1 #define CC2650DK_7ID_PWMPIN1 CC2650DK_7ID_PIN_LED2 -#define CC2650DK_7ID_PWMPIN2 PIN_UNASSIGNED -#define CC2650DK_7ID_PWMPIN3 PIN_UNASSIGNED +#define CC2650DK_7ID_PWMPIN2 CC2650DK_7ID_PIN_LED3 +#define CC2650DK_7ID_PWMPIN3 CC2650DK_7ID_PIN_LED4 #define CC2650DK_7ID_PWMPIN4 PIN_UNASSIGNED #define CC2650DK_7ID_PWMPIN5 PIN_UNASSIGNED #define CC2650DK_7ID_PWMPIN6 PIN_UNASSIGNED @@ -136,7 +143,9 @@ extern const PIN_Config BoardGpioInitTable[]; #define CC2650DK_7ID_UART_RTS IOID_21 /* SD Card */ -#define CC2650DK_7ID_SDCARD_CS IOID_30 +#define CC2650DK_7ID_SPI_SDCARD_CS IOID_30 +#define CC2650DK_7ID_SDCARD_CS_ON 0 +#define CC2650DK_7ID_SDCARD_CS_OFF 1 /* Ambient Light Sensor */ #define CC2650DK_7ID_ALS_OUT IOID_23 @@ -169,7 +178,7 @@ void CC2650DK_7ID_wakeUpExtFlash(void); /*! * @def CC2650DK_7ID_ADCBufName - * @brief Enum of ADCs + * @brief Enum of ADCBufs */ typedef enum CC2650DK_7ID_ADCBufName { CC2650DK_7ID_ADCBUF0 = 0, @@ -213,6 +222,76 @@ typedef enum CC2650DK_7ID_CryptoName { CC2650DK_7ID_CRYPTOCOUNT } CC2650DK_7ID_CryptoName; +/*! + * @def CC2650DK_7ID_AESCCMName + * @brief Enum of AESCCM names + */ +typedef enum CC2650DK_7ID_AESCCMName { + CC2650DK_7ID_AESCCM0 = 0, + + CC2650DK_7ID_AESCCMCOUNT +} CC2650DK_7ID_AESCCMName; + +/*! + * @def CC2650DK_7ID_AESGCMName + * @brief Enum of AESGCM names + */ +typedef enum CC2650DK_7ID_AESGCMName { + CC2650DK_7ID_AESGCM0 = 0, + + CC2650DK_7ID_AESGCMCOUNT +} CC2650DK_7ID_AESGCMName; + +/*! + * @def CC2650DK_7ID_AESCBCName + * @brief Enum of AESCBC names + */ +typedef enum CC2650DK_7ID_AESCBCName { + CC2650DK_7ID_AESCBC0 = 0, + + CC2650DK_7ID_AESCBCCOUNT +} CC2650DK_7ID_AESCBCName; + +/*! + * @def CC2650DK_7ID_AESCTRName + * @brief Enum of AESCTR names + */ +typedef enum CC2650DK_7ID_AESCTRName { + CC2650DK_7ID_AESCTR0 = 0, + + CC2650DK_7ID_AESCTRCOUNT +} CC2650DK_7ID_AESCTRName; + +/*! + * @def CC2650DK_7ID_AESECBName + * @brief Enum of AESECB names + */ +typedef enum CC2650DK_7ID_AESECBName { + CC2650DK_7ID_AESECB0 = 0, + + CC2650DK_7ID_AESECBCOUNT +} CC2650DK_7ID_AESECBName; + +/*! + * @def CC2650DK_7ID_AESCTRDRBGName + * @brief Enum of AESCTRDRBG names + */ +typedef enum CC2650DK_7ID_AESCTRDRBGName { + CC2650DK_7ID_AESCTRDRBG0 = 0, + + CC2650DK_7ID_AESCTRDRBGCOUNT +} CC2650DK_7ID_AESCTRDRBGName; + +/*! + * @def CC2650DK_7ID_TRNGName + * @brief Enum of TRNG names + */ +typedef enum CC2650DK_7ID_TRNGName { + CC2650DK_7ID_TRNG0 = 0, + + CC2650DK_7ID_TRNGCOUNT +} CC2650DK_7ID_TRNGName; + /*! * @def CC2650DK_7ID_GPIOName * @brief Enum of GPIO names @@ -229,7 +308,7 @@ typedef enum CC2650DK_7ID_GPIOName { CC2650DK_7ID_GPIO_LED2, CC2650DK_7ID_GPIO_LED3, CC2650DK_7ID_GPIO_LED4, - CC2650DK_7ID_GPIO_SDCARD_CS, + CC2650DK_7ID_SDSPI_CS, CC2650DK_7ID_GPIO_ACC_CS, CC2650DK_7ID_GPIOCOUNT @@ -277,6 +356,16 @@ typedef enum CC2650DK_7ID_I2CName { CC2650DK_7ID_I2CCOUNT } CC2650DK_7ID_I2CName; +/*! + * @def CC2650DK_7ID_I2SName + * @brief Enum of I2S names + */ +typedef enum CC2650DK_7ID_I2SName { + CC2650DK_7ID_I2S0 = 0, + + CC2650DK_7ID_I2SCOUNT +} CC2650DK_7ID_I2SName; + /*! * @def CC2650DK_7ID_NVSName * @brief Enum of NVS names @@ -316,16 +405,6 @@ typedef enum CC2650DK_7ID_SDName { CC2650DK_7ID_SDCOUNT } CC2650DK_7ID_SDName; -/*! - * @def CC2650DK_7ID_TRNGName - * @brief Enum of TRNGs - */ -typedef enum CC2650DK_7ID_TRNGName { - CC2650DK_7ID_TRNG0 = 0, - - CC2650DK_7ID_TRNGCOUNT -} CC2650DK_7ID_TRNGName; - /*! * @def CC2650DK_7ID_SPIName * @brief Enum of SPI names diff --git a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID_fxns.c b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID_fxns.c index aa6a6c60ef476be62e3bd4f60ebd6d298831bc02..f3f68dd73e4c2ef1288cbe6bd6f3b0db14242104 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID_fxns.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/srf06/cc26x0/CC2650DK_7ID_fxns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Texas Instruments Incorporated + * Copyright (c) 2018-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/arch/platform/sky/Makefile.common b/arch/platform/sky/Makefile.common index b72f92ed80dcf2f05884bde5310e53c81da6d761..0a4934e1c3ae922552c71c2aaabc018145447d20 100644 --- a/arch/platform/sky/Makefile.common +++ b/arch/platform/sky/Makefile.common @@ -18,8 +18,7 @@ endif CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) MCU=msp430f1611 -include $(ARCH_PATH)/cpu/msp430/Makefile.msp430 - +include $(CONTIKI_NG_RELOC_CPU_DIR)/msp430/Makefile.msp430 ifdef IAR LDFLAGSNO += -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f1611.xcl" @@ -31,17 +30,17 @@ NUMPAR=20 # Check if we are running under Windows ifeq ($(HOST_OS),Windows) USBDEVPREFIX=/dev/com - SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-windows - MOTELIST = $(CONTIKI)/tools/sky/motelist-windows + SERIALDUMP = $(CONTIKI_NG_TOOLS_DIR)/sky/serialdump-windows + MOTELIST = $(CONTIKI_NG_TOOLS_DIR)/sky/motelist-windows TMOTE_BSL_FILE = tmote-bsl - TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE).exe),1,0) + TMOTE_BSL=$(if $(wildcard $(CONTIKI_NG_TOOLS_DIR)/sky/$(TMOTE_BSL_FILE).exe),1,0) ifeq ($(TMOTE_BSL), 1) NUMPAR = 1 - BSL = $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE) + BSL = $(CONTIKI_NG_TOOLS_DIR)/sky/$(TMOTE_BSL_FILE) MOTES = $(shell $(MOTELIST) | grep COM | \ cut -f 4 -d \ ) else - BSL = $(CONTIKI)/tools/sky/msp430-bsl-windows --telosb + BSL = $(CONTIKI_NG_TOOLS_DIR)/sky/msp430-bsl-windows --telosb BSL_FILETYPE = -I MOTES = $(shell $(MOTELIST) | grep COM | \ cut -f 4 -d \ | \ @@ -54,15 +53,15 @@ else ifeq ($(HOST_OS),Darwin) ifndef MOTELIST USBDEVPREFIX= - MOTELIST = $(CONTIKI)/tools/sky/motelist-macos + MOTELIST = $(CONTIKI_NG_TOOLS_DIR)/sky/motelist-macos TMOTE_BSL_FILE = tmote-bsl-linux - TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)),1,0) + TMOTE_BSL=$(if $(wildcard $(CONTIKI_NG_TOOLS_DIR)/sky/$(TMOTE_BSL_FILE)),1,0) ifeq ($(TMOTE_BSL), 1) - PATH := $(PATH):$(CONTIKI)/tools/sky - BSL = $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE) + PATH := $(PATH):$(CONTIKI_NG_TOOLS_DIR)/sky + BSL = $(CONTIKI_NG_TOOLS_DIR)/sky/$(TMOTE_BSL_FILE) NUMPAR = 1 else - BSL = $(CONTIKI)/tools/sky/msp430-bsl-linux --telosb + BSL = $(CONTIKI_NG_TOOLS_DIR)/sky/msp430-bsl-linux --telosb BSL_FILETYPE = -I endif MOTES = $(shell $(MOTELIST) 2>&- | grep usbserial | \ @@ -74,15 +73,15 @@ else # Else we assume Linux ifndef MOTELIST USBDEVPREFIX= - MOTELIST = $(CONTIKI)/tools/sky/motelist-linux + MOTELIST = $(CONTIKI_NG_TOOLS_DIR)/sky/motelist-linux TMOTE_BSL_FILE = tmote-bsl-linux - TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)),1,0) + TMOTE_BSL=$(if $(wildcard $(CONTIKI_NG_TOOLS_DIR)/sky/$(TMOTE_BSL_FILE)),1,0) ifeq ($(TMOTE_BSL), 1) - PATH := $(PATH):$(CONTIKI)/tools/sky - BSL = $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE) + PATH := $(PATH):$(CONTIKI_NG_TOOLS_DIR)/sky + BSL = $(CONTIKI_NG_TOOLS_DIR)/sky/$(TMOTE_BSL_FILE) NUMPAR = 1 else - BSL = $(CONTIKI)/tools/sky/msp430-bsl-linux --telosb + BSL = $(CONTIKI_NG_TOOLS_DIR)/sky/msp430-bsl-linux --telosb BSL_FILETYPE = -I endif ifdef MOTEIDS @@ -150,24 +149,18 @@ sky-r.%: $(BSL) -c $(subst _,/,$*) -r sizeplot: - msp430-size $(OBJECTDIR)/*.o | $(CONTIKI)/tools/sky/check-size > size-data - gnuplot $(CONTIKI)/tools/sky/plot-size + msp430-size $(OBJECTDIR)/*.o | $(CONTIKI_NG_TOOLS_DIR)/sky/check-size > size-data + gnuplot $(CONTIKI_NG_TOOLS_DIR)/sky/plot-size gv size.pdf winslip: ifdef INTERFACE - $(CONTIKI)/tools/wpcapslip/wpcapslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) $(INTERFACE) 172.16.0.0 255.255.0.0 + $(CONTIKI_NG_TOOLS_DIR)/wpcapslip/wpcapslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) $(INTERFACE) 172.16.0.0 255.255.0.0 else @echo "Usage: \"$(MAKE) $@ INTERFACE=<the IP address of a local network interface>\"" @echo "Use the \"ipconfig\" command to find out the IP addresses of the local interfaces" endif -linslip: $(CONTIKI)/tools/tunslip - $(CONTIKI)/tools/tunslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) 172.16.0.0 255.255.0.0 - -$(CONTIKI)/tools/tunslip: - (cd $(CONTIKI)/tools; $(MAKE) tunslip) - ifdef MOTE PORT = $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) else diff --git a/arch/platform/sky/Makefile.sky b/arch/platform/sky/Makefile.sky index ec232408572c633d17e0f64887ac0c22871e7422..4dfaf25d3938cb4d8bf88b0062645abf26751109 100644 --- a/arch/platform/sky/Makefile.sky +++ b/arch/platform/sky/Makefile.sky @@ -4,6 +4,7 @@ CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c \ sht11.c sht11-sensor.c light-sensor.c battery-sensor.c \ button-sensor.c -include $(ARCH_PATH)/platform/sky/Makefile.common +include $(CONTIKI_NG_RELOC_PLATFORM_DIR)/sky/Makefile.common -MODULES += arch/dev/cc2420 arch/dev/sht11 arch/dev/ds2411 os/storage/cfs +MODULES += $(CONTIKI_NG_DRIVERS_DIR)/cc2420 $(CONTIKI_NG_DRIVERS_DIR)/sht11 +MODULES += $(CONTIKI_NG_DRIVERS_DIR)/ds2411 $(CONTIKI_NG_STORAGE_DIR)/cfs diff --git a/arch/platform/z1/Makefile.common b/arch/platform/z1/Makefile.common index 42172022bb2d7de83e5072e14aef390d2957d743..d2fd891c1d80a04da9b60c926bafd8f8d5b5ed15 100644 --- a/arch/platform/z1/Makefile.common +++ b/arch/platform/z1/Makefile.common @@ -31,8 +31,7 @@ endif CFLAGS += -g -include $(ARCH_PATH)/cpu/msp430/Makefile.msp430 - +include $(CONTIKI_NG_RELOC_CPU_DIR)/msp430/Makefile.msp430 NUMPAR=20 IHEXFILE=tmpimage.ihex @@ -40,9 +39,9 @@ IHEXFILE=tmpimage.ihex ifeq ($(HOST_OS),Darwin) ifndef MOTELIST USBDEVPREFIX= - SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux - MOTELIST = $(CONTIKI)/tools/zolertia/motelist-zolertia-macos - BSL = $(CONTIKI)/tools/zolertia/z1-bsl-nopic --z1 + SERIALDUMP = $(CONTIKI_NG_TOOLS_DIR)/sky/serialdump-linux + MOTELIST = $(CONTIKI_NG_TOOLS_DIR)/zolertia/motelist-zolertia-macos + BSL = $(CONTIKI_NG_TOOLS_DIR)/zolertia/z1-bsl-nopic --z1 BSL_FILETYPE = -I MOTES = $(shell $(MOTELIST) -b z1 -c 2>&- | \ cut -f 2 -d ,) @@ -59,9 +58,9 @@ else # If we are not running under Mac, we assume Linux ifndef MOTELIST USBDEVPREFIX= - SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux - MOTELIST = $(CONTIKI)/tools/zolertia/motelist-zolertia - BSL = $(CONTIKI)/tools/zolertia/z1-bsl-nopic --z1 + SERIALDUMP = $(CONTIKI_NG_TOOLS_DIR)/sky/serialdump-linux + MOTELIST = $(CONTIKI_NG_TOOLS_DIR)/zolertia/motelist-zolertia + BSL = $(CONTIKI_NG_TOOLS_DIR)/zolertia/z1-bsl-nopic --z1 BSL_FILETYPE = -I MOTES = $(shell $(MOTELIST) -b z1 -c 2>&- | \ cut -f 2 -d , | \ @@ -120,24 +119,18 @@ z1-r.%: $(BSL) -c $(subst -,/,$*) -r sizeplot: - msp430-size $(OBJECTDIR)/*.o | $(CONTIKI)/tools/sky/check-size > size-data + msp430-size $(OBJECTDIR)/*.o | $(CONTIKI_NG_TOOLS_DIR)/sky/check-size > size-data gnuplot $(CONTIKI)/tools/sky/plot-size gv size.pdf winslip: ifdef INTERFACE - $(CONTIKI)/tools/wpcapslip/wpcapslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) $(INTERFACE) 172.16.0.0 255.255.0.0 + $(CONTIKI_NG_TOOLS_DIR)/wpcapslip/wpcapslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) $(INTERFACE) 172.16.0.0 255.255.0.0 else @echo "Usage: \"$(MAKE) $@ INTERFACE=<the IP address of a local network interface>\"" @echo "Use the \"ipconfig\" command to find out the IP addresses of the local interfaces" endif -linslip: $(CONTIKI)/tools/tunslip - $(CONTIKI)/tools/tunslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) 172.16.0.0 255.255.0.0 - -$(CONTIKI)/tools/tunslip: - (cd $(CONTIKI)/tools; $(MAKE) tunslip) - ifdef MOTE PORT = $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) else diff --git a/arch/platform/z1/Makefile.z1 b/arch/platform/z1/Makefile.z1 index aeff61bf2e3a22052834c006fa4b7dd52c56c767..1dfcedb235096061ca72212b0ead5f0cf677883e 100644 --- a/arch/platform/z1/Makefile.z1 +++ b/arch/platform/z1/Makefile.z1 @@ -2,10 +2,10 @@ CONTIKI_TARGET_SOURCEFILES += contiki-z1-platform.c -include $(ARCH_PATH)/platform/z1/Makefile.common +include $(CONTIKI_NG_RELOC_PLATFORM_DIR)/z1/Makefile.common ifeq ($(ZOLERTIA_Z1SP),1) -include $(ARCH_PATH)/platform/z1/Makefile.z1sp +include $(CONTIKI_NG_RELOC_PLATFORM_DIR)/z1/Makefile.z1sp endif MODULES += arch/dev/cc2420 os/storage/cfs diff --git a/arch/platform/zoul/Makefile.zoul b/arch/platform/zoul/Makefile.zoul index d5bb3df15e40b1e030d4b857d736f439a396671e..65a71cbe4040726c71913375a21d54f7969f0948 100644 --- a/arch/platform/zoul/Makefile.zoul +++ b/arch/platform/zoul/Makefile.zoul @@ -25,7 +25,7 @@ CFLAGS += -DDATE="\"`date +"%02u %02d %02m %02y %02H %02M %02S"`\"" ### Configure the build for the board and pull in board-specific sources CONTIKI_TARGET_DIRS += . dev CONTIKI_TARGET_DIRS += $(BOARD) -PLATFORM_ROOT_DIR = $(ARCH_PATH)/platform/$(TARGET) +PLATFORM_ROOT_DIR = $(CONTIKI_NG_RELOC_PLATFORM_DIR)/$(TARGET) ### Include the board dir if one exists -include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(BOARD) @@ -39,14 +39,15 @@ CONTIKI_TARGET_SOURCEFILES += $(BOARD_SOURCEFILES) CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) ### Define the CPU directory -CONTIKI_CPU=$(ARCH_PATH)/cpu/cc2538 +CONTIKI_CPU = $(CONTIKI_NG_RELOC_CPU_DIR)/cc2538 include $(CONTIKI_CPU)/Makefile.cc2538 -MODULES += arch/dev/cc1200 arch/dev/rgb-led os/storage/cfs +MODULES += $(CONTIKI_NG_DRIVERS_DIR)/cc1200 $(CONTIKI_NG_DRIVERS_DIR)/rgb-led +MODULES += $(CONTIKI_NG_STORAGE_DIR)/cfs -BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py +BSL = $(CONTIKI_NG_TOOLS_DIR)/cc2538-bsl/cc2538-bsl.py -MOTES := $(shell python $(TOOLS_DIR)/motelist/motelist.py --omit-header \ +MOTES := $(shell python $(CONTIKI_NG_TOOLS_DIR)/motelist/motelist.py --omit-header \ | grep $(MOTELIST_ZOLERTIA) | cut -f1 -d " ") ### If PORT is defined, override to keep backward compatibility diff --git a/arch/platform/zoul/contiki-conf.h b/arch/platform/zoul/contiki-conf.h index a4c455d865a3d91119768ab70e4599d984f76d70..2ba1b2e60fd5b161600cdd0fdfa1b6006a169495 100644 --- a/arch/platform/zoul/contiki-conf.h +++ b/arch/platform/zoul/contiki-conf.h @@ -113,18 +113,22 @@ uint16_t *radio_tsch_timeslot_timing(void); * * @{ */ -/* Configure CSMA for when it's selected */ +#ifndef ZOUL_CONF_USE_CC1200_RADIO +#define ZOUL_CONF_USE_CC1200_RADIO 0 +#endif -#if CC1200_CONF_SUBGHZ_50KBPS_MODE -#define NETSTACK_CONF_RADIO cc1200_driver -#define CC1200_CONF_RF_CFG cc1200_802154g_863_870_fsk_50kbps -#define ANTENNA_SW_SELECT_DEF_CONF ANTENNA_SW_SELECT_SUBGHZ -#define CC1200_CONF_USE_GPIO2 0 -#define CC1200_CONF_USE_RX_WATCHDOG 0 +#if ZOUL_CONF_USE_CC1200_RADIO +#define NETSTACK_CONF_RADIO cc1200_driver +#define ANTENNA_SW_SELECT_DEF_CONF ANTENNA_SW_SELECT_SUBGHZ +#define CC1200_CONF_USE_GPIO2 0 +#define CC1200_CONF_USE_RX_WATCHDOG 0 -#define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 200) -#define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1500) +#define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 200) +#define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1500) +#ifndef CC1200_CONF_RF_CFG +#define CC1200_CONF_RF_CFG cc1200_802154g_863_870_fsk_50kbps +#endif #endif /* This can be overriden to use the cc1200_driver instead */ diff --git a/arch/platform/zoul/dev/mmc-arch.c b/arch/platform/zoul/dev/mmc-arch.c index f1eca8d322cc8a045279a16559a99abd0f02468d..4d8c1a1085c8a09e0d8997bddf76771fc28da0c2 100644 --- a/arch/platform/zoul/dev/mmc-arch.c +++ b/arch/platform/zoul/dev/mmc-arch.c @@ -123,7 +123,7 @@ mmc_arch_spi_xfer(uint8_t dev, const void *tx_buf, size_t tx_cnt, SPIX_BUF(USD_SPI_INSTANCE) = *tx_buf_u8++; tx_cnt--; } else { - SPIX_BUF(USD_SPI_INSTANCE) = 0; + SPIX_BUF(USD_SPI_INSTANCE) = 0xff; } SPIX_WAITFOREOTx(USD_SPI_INSTANCE); SPIX_WAITFOREORx(USD_SPI_INSTANCE); diff --git a/arch/platform/zoul/orion/Makefile.orion b/arch/platform/zoul/orion/Makefile.orion index b7313afc0c9dd375c6e351dbc3d4f34406316095..2fda0a721972e8d30dd9f7c01619fccc9bfc4a17 100644 --- a/arch/platform/zoul/orion/Makefile.orion +++ b/arch/platform/zoul/orion/Makefile.orion @@ -1,5 +1,5 @@ MOTELIST_ZOLERTIA := Orion -MODULES += arch/dev/enc28j60 +MODULES += $(CONTIKI_NG_DRIVERS_DIR)/enc28j60 CC2538_ENC28J60_ARCH ?= gpio ifeq ($(WITH_IP64),1) CFLAGS += -DUIP_FALLBACK_INTERFACE=ip64_uip_fallback_interface diff --git a/arch/platform/zoul/remote-reva/Makefile.remote-reva b/arch/platform/zoul/remote-reva/Makefile.remote-reva index ec4095265147bcac00b2e13909107e09b7cf4093..1bf37d39a89d99df291ac83df7c1265cc148202c 100644 --- a/arch/platform/zoul/remote-reva/Makefile.remote-reva +++ b/arch/platform/zoul/remote-reva/Makefile.remote-reva @@ -1,4 +1,6 @@ MOTELIST_ZOLERTIA := RE-Mote BOARD_SOURCEFILES += board.c antenna-sw.c mmc-arch.c rtcc.c power-mgmt.c -MODULES += os/lib/fs/fat os/lib/fs/fat/option arch/platform/zoul/fs/fat arch/dev/disk/mmc +MODULES += $(CONTIKI_NG_LIB_DIR)/fs/fat $(CONTIKI_NG_LIB_DIR)/fs/fat/option +MODULES += $(CONTIKI_NG_ARCH_PLATFORM_DIR)/$(TARGET)/fs/fat +MODULES += $(CONTIKI_NG_DRIVERS_DIR)/disk/mmc diff --git a/arch/platform/zoul/remote-revb/Makefile.remote-revb b/arch/platform/zoul/remote-revb/Makefile.remote-revb index ec4095265147bcac00b2e13909107e09b7cf4093..1bf37d39a89d99df291ac83df7c1265cc148202c 100644 --- a/arch/platform/zoul/remote-revb/Makefile.remote-revb +++ b/arch/platform/zoul/remote-revb/Makefile.remote-revb @@ -1,4 +1,6 @@ MOTELIST_ZOLERTIA := RE-Mote BOARD_SOURCEFILES += board.c antenna-sw.c mmc-arch.c rtcc.c power-mgmt.c -MODULES += os/lib/fs/fat os/lib/fs/fat/option arch/platform/zoul/fs/fat arch/dev/disk/mmc +MODULES += $(CONTIKI_NG_LIB_DIR)/fs/fat $(CONTIKI_NG_LIB_DIR)/fs/fat/option +MODULES += $(CONTIKI_NG_ARCH_PLATFORM_DIR)/$(TARGET)/fs/fat +MODULES += $(CONTIKI_NG_DRIVERS_DIR)/disk/mmc diff --git a/examples/6tisch/6p-packet/Makefile b/examples/6tisch/6p-packet/Makefile index 707a024852763f9615993e989e09960cd004781e..895a03b864e3d24c3b2cb48d277651268753655b 100644 --- a/examples/6tisch/6p-packet/Makefile +++ b/examples/6tisch/6p-packet/Makefile @@ -7,7 +7,9 @@ CONTIKI = ../../../ MAKE_MAC = MAKE_MAC_TSCH MAKE_ROUTING = MAKE_ROUTING_NULLROUTING -MODULES += os/net/mac/tsch/sixtop + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_MAC_DIR)/tsch/sixtop all: $(CONTIKI_PROJECT) include $(CONTIKI)/Makefile.include diff --git a/examples/6tisch/channel-selection-demo/Makefile b/examples/6tisch/channel-selection-demo/Makefile index e3c4288f652cef1c57334a062e773ee8ba9072bd..b84dfd83f2620d44379fb06def5d814ac9cc2acf 100644 --- a/examples/6tisch/channel-selection-demo/Makefile +++ b/examples/6tisch/channel-selection-demo/Makefile @@ -6,8 +6,10 @@ CONTIKI=../../.. PLATFORMS_EXCLUDE = sky z1 nrf52dk native BOARDS_EXCLUDE = srf06/cc13x0 launchpad/cc1310 launchpad/cc1350 sensortag/cc2650 sensortag/cc1350 +include $(CONTIKI)/Makefile.dir-variables + # The channel selection library -MODULES += os/services/tsch-cs +MODULES += $(CONTIKI_NG_SERVICES_DIR)/tsch-cs # force Orchestra from command line MAKE_WITH_ORCHESTRA ?= 0 @@ -17,10 +19,10 @@ MAKE_WITH_SECURITY ?= 0 MAKE_WITH_PERIODIC_ROUTES_PRINT ?= 0 MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/services/shell +MODULES += $(CONTIKI_NG_SERVICES_DIR)/shell ifeq ($(MAKE_WITH_ORCHESTRA),1) -MODULES += os/services/orchestra +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra endif ifeq ($(MAKE_WITH_SECURITY),1) diff --git a/examples/6tisch/etsi-plugtest-2017/Makefile b/examples/6tisch/etsi-plugtest-2017/Makefile index 6b1a23a4cfeeccfea18fdcc22ec26fe6c6901586..29fb0999ab412b2d2271f3448e8b924df8541d00 100644 --- a/examples/6tisch/etsi-plugtest-2017/Makefile +++ b/examples/6tisch/etsi-plugtest-2017/Makefile @@ -9,8 +9,11 @@ ifeq ($(MAKE_WITH_SECURITY),1) CFLAGS += -DWITH_SECURITY=1 endif -MODULES += os/services/shell -MODULES += os/net/mac/tsch/sixtop +CONTIKI =../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/shell +MODULES += $(CONTIKI_NG_MAC_DIR)/tsch/sixtop PROJECT_SOURCEFILES += sf-plugtest.c CFLAGS += -Wno-nonnull-compare @@ -22,5 +25,4 @@ endif MAKE_MAC = MAKE_MAC_TSCH -CONTIKI =../../.. include $(CONTIKI)/Makefile.include diff --git a/examples/6tisch/simple-node/Makefile b/examples/6tisch/simple-node/Makefile index 06a83ebdda2ad92a1f218cfe9f62f9de17c090bc..0446ed48a7174b17ffc8689b09dbcd2fc8ae7b07 100644 --- a/examples/6tisch/simple-node/Makefile +++ b/examples/6tisch/simple-node/Makefile @@ -13,10 +13,12 @@ MAKE_WITH_SECURITY ?= 0 MAKE_WITH_PERIODIC_ROUTES_PRINT ?= 0 MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/services/shell + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/shell ifeq ($(MAKE_WITH_ORCHESTRA),1) -MODULES += os/services/orchestra +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra endif ifeq ($(MAKE_WITH_SECURITY),1) diff --git a/examples/6tisch/sixtop/Makefile b/examples/6tisch/sixtop/Makefile index 1e6f0ef5fa0a49bb282546f3e6833c7bcba1814d..fb9d0a94911b1a76bf07fbbe94c1afd9a0ae98c9 100644 --- a/examples/6tisch/sixtop/Makefile +++ b/examples/6tisch/sixtop/Makefile @@ -9,7 +9,9 @@ CONTIKI=../../.. MAKE_WITH_SECURITY ?= 0 # force Security from command line MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/net/mac/tsch/sixtop + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_MAC_DIR)/tsch/sixtop ifeq ($(MAKE_WITH_SECURITY),1) CFLAGS += -DWITH_SECURITY=1 diff --git a/examples/6tisch/timesync-demo/Makefile b/examples/6tisch/timesync-demo/Makefile index 85c29659fc2ddcefdb082c2ee7869458256c8f78..146bd72e26bfe9d862c3de975489f4ba6220f211 100644 --- a/examples/6tisch/timesync-demo/Makefile +++ b/examples/6tisch/timesync-demo/Makefile @@ -11,10 +11,12 @@ MAKE_WITH_ORCHESTRA ?= 0 MAKE_WITH_SECURITY ?= 0 MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/services/shell + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/shell ifeq ($(MAKE_WITH_ORCHESTRA),1) -MODULES += os/services/orchestra +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra endif ifeq ($(MAKE_WITH_SECURITY),1) diff --git a/examples/6tisch/tsch-stats/Makefile b/examples/6tisch/tsch-stats/Makefile index 156c0d526769eb6fdabe24ccd01955d8c64c21fc..31c09dbf9e28e9fea85a34da4e861effb24020df 100644 --- a/examples/6tisch/tsch-stats/Makefile +++ b/examples/6tisch/tsch-stats/Makefile @@ -14,10 +14,12 @@ MAKE_WITH_SECURITY ?= 0 MAKE_WITH_PERIODIC_ROUTES_PRINT ?= 0 MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/services/shell + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/shell ifeq ($(MAKE_WITH_ORCHESTRA),1) -MODULES += os/services/orchestra +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra endif ifeq ($(MAKE_WITH_SECURITY),1) diff --git a/examples/benchmarks/rpl-req-resp/Makefile b/examples/benchmarks/rpl-req-resp/Makefile index dadd7a2d7caad2978da388a74837458e590450db..214820286ba7b591bf37c16f24c2b093da0f131f 100644 --- a/examples/benchmarks/rpl-req-resp/Makefile +++ b/examples/benchmarks/rpl-req-resp/Makefile @@ -5,8 +5,12 @@ PLATFORMS_EXCLUDE = sky z1 nrf52dk native simplelink BOARDS_EXCLUDE = srf06/cc13x0 launchpad/cc1310 launchpad/cc1350 sensortag/cc2650 sensortag/cc1350 MODULES_REL += ../testbeds -MODULES += os/services/deployment -MODULES += os/services/simple-energest + +CONTIKI = ../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/deployment +MODULES += $(CONTIKI_NG_SERVICES_DIR)/simple-energest CONFIG?=CONFIG_TSCH_OPTIMS @@ -14,16 +18,19 @@ ifeq ($(CONFIG),CONFIG_CSMA) MAKE_MAC = MAKE_MAC_CSMA else ifeq ($(CONFIG),CONFIG_TSCH) MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/services/orchestra +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra else ifeq ($(CONFIG),CONFIG_TSCH_OPTIMS) MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/services/orchestra +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra CFLAGS += -DCONFIG_OPTIMS=1 else ifeq ($(CONFIG),CONFIG_TSCH_OPTIMS2) MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/services/orchestra +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra CFLAGS += -DCONFIG_OPTIMS=2 +else ifeq ($(CONFIG),CONFIG_TSCH_OPTIMS3) +MAKE_MAC = MAKE_MAC_TSCH +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra +CFLAGS += -DCONFIG_OPTIMS=3 endif -CONTIKI = ../../.. include $(CONTIKI)/Makefile.include diff --git a/examples/benchmarks/rpl-req-resp/project-conf.h b/examples/benchmarks/rpl-req-resp/project-conf.h index 1140bb9e5089a5806f2c8ffa2f17c6b31e82f19e..de235b5259daf668eb515ae1b69c8491c8c14ccf 100644 --- a/examples/benchmarks/rpl-req-resp/project-conf.h +++ b/examples/benchmarks/rpl-req-resp/project-conf.h @@ -29,7 +29,7 @@ #define TSCH_CONF_RX_WAIT 1000 #define ORCHESTRA_CONF_UNICAST_PERIOD 7 -#if CONFIG_OPTIMS == 2 +#if CONFIG_OPTIMS >= 2 /* Five nines reliability paper used the config below */ #define RPL_CONF_DIO_INTERVAL_MIN 14 /* 2^14 ms = 16.384 s */ @@ -39,10 +39,19 @@ /* Five nines reliability paper used the config below */ #define TSCH_CONF_KEEPALIVE_TIMEOUT (20 * CLOCK_SECOND) #define TSCH_CONF_MAX_KEEPALIVE_TIMEOUT (60 * CLOCK_SECOND) -//#define TSCH_CONF_EB_PERIOD (16 * CLOCK_SECOND) -//#define TSCH_CONF_MAX_EB_PERIOD (50 * CLOCK_SECOND) -#endif -#endif +#endif /* CONFIG_OPTIMS >= 2 */ + +#if CONFIG_OPTIMS < 3 + +/* For optims1 and optims2, configure Orchestra unicast slotframe with only + * one choffset, for consistency with earlier version. Optims3 runs with the + * defaults, that is, with multiple choffsets on the unicast slotframe. */ +#define ORCHESTRA_CONF_UNICAST_MIN_CHANNEL_OFFSET 2 +#define ORCHESTRA_CONF_UNICAST_MAX_CHANNEL_OFFSET 2 + +#endif /* CONFIG_OPTIMS >= 3 */ + +#endif /* CONFIG_OPTIMS >= 1 */ #endif /* PROJECT_CONF_H_ */ diff --git a/examples/coap/coap-example-client/Makefile b/examples/coap/coap-example-client/Makefile index 21c9649e7d10480b9d930751cbcada94e571d083..80af8d74eaafdf0f31c4b187e9df02f8d2f3f4aa 100644 --- a/examples/coap/coap-example-client/Makefile +++ b/examples/coap/coap-example-client/Makefile @@ -5,8 +5,10 @@ all: $(CONTIKI_PROJECT) # Do not try to build on Sky because of code size limitation PLATFORMS_EXCLUDE = sky z1 +CONTIKI=../../.. + # Include the CoAP implementation -MODULES += os/net/app-layer/coap +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap -CONTIKI=../../.. include $(CONTIKI)/Makefile.include diff --git a/examples/coap/coap-example-client/coap-example-client.c b/examples/coap/coap-example-client/coap-example-client.c index 6452830931b7928e69f9c03dedb559128fbdcf84..e9b0c4d0cc9bebcdd166e90b535ee29a0f324c3c 100644 --- a/examples/coap/coap-example-client/coap-example-client.c +++ b/examples/coap/coap-example-client/coap-example-client.c @@ -79,6 +79,11 @@ client_chunk_handler(coap_message_t *response) { const uint8_t *chunk; + if(response == NULL) { + puts("Request timed out"); + return; + } + int len = coap_get_payload(response, &chunk); printf("|%.*s", len, (char *)chunk); diff --git a/examples/coap/coap-example-server/Makefile b/examples/coap/coap-example-server/Makefile index 1647568cbf0039ebd038ea666ec01f4dd0d5c1d9..a6b45218398d1f390ae57114e7b7a0395eac20a5 100644 --- a/examples/coap/coap-example-server/Makefile +++ b/examples/coap/coap-example-server/Makefile @@ -4,11 +4,13 @@ all: $(CONTIKI_PROJECT) # Do not try to build on Sky because of code size limitation PLATFORMS_EXCLUDE = sky z1 -# Include the CoAP implementation -MODULES += os/net/app-layer/coap - # Include CoAP resources MODULES_REL += ./resources CONTIKI=../../.. + +# Include the CoAP implementation +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap + include $(CONTIKI)/Makefile.include diff --git a/examples/coap/coap-plugtest-server/Makefile b/examples/coap/coap-plugtest-server/Makefile index ee3bc511b7ee3f9413e572fa338cddf7d73fbfb3..7e38814cba209e9a79059f0b0e8608bde4be3794 100644 --- a/examples/coap/coap-plugtest-server/Makefile +++ b/examples/coap/coap-plugtest-server/Makefile @@ -4,11 +4,13 @@ all: $(CONTIKI_PROJECT) # Only intended for native PLATFORMS_ONLY = native -# Include the CoAP implementation -MODULES += os/net/app-layer/coap - # Include CoAP resources MODULES_REL += ./resources CONTIKI=../../.. + +# Include the CoAP implementation +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap + include $(CONTIKI)/Makefile.include diff --git a/examples/dev/button-hal/Makefile b/examples/dev/button-hal/Makefile index 263e9ec6586e3906b8f9b3d4bc12a98e521fb533..9f265b649e6cdcc044fa98e9b12663c1d72b37e6 100644 --- a/examples/dev/button-hal/Makefile +++ b/examples/dev/button-hal/Makefile @@ -3,6 +3,7 @@ CONTIKI = ../../.. all: $(CONTIKI_PROJECT) -PLATFORMS_ONLY = cc26x0-cc13x0 cc2538dk openmote-cc2538 zoul native simplelink +PLATFORMS_ONLY += cc26x0-cc13x0 cc2538dk openmote zoul simplelink +PLATFORMS_ONLY += cooja native include $(CONTIKI)/Makefile.include diff --git a/examples/dev/gpio-hal/Makefile b/examples/dev/gpio-hal/Makefile index 234388c090efd51e0f83ff5d811d98f7022cc7b8..1e375c8c289d9bad9ef2c6055e4407de0a424b15 100644 --- a/examples/dev/gpio-hal/Makefile +++ b/examples/dev/gpio-hal/Makefile @@ -1,7 +1,8 @@ CONTIKI_PROJECT = gpio-hal-example CONTIKI = ../../.. -PLATFORMS_ONLY = cc26x0-cc13x0 cc2538dk openmote-cc2538 zoul native simplelink +PLATFORMS_ONLY += cc26x0-cc13x0 cc2538dk openmote zoul simplelink +PLATFORMS_ONLY += cooja native include $(CONTIKI)/Makefile.identify-target diff --git a/examples/dev/gpio-hal/cooja/pins.c b/examples/dev/gpio-hal/cooja/pins.c new file mode 100644 index 0000000000000000000000000000000000000000..55522c52fa4899e841bc0d2128a9dd87319471ec --- /dev/null +++ b/examples/dev/gpio-hal/cooja/pins.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017, George Oikonomou - http://www.spd.gr + * 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 "contiki.h" +#include "dev/gpio-hal.h" +/*---------------------------------------------------------------------------*/ +/* + * Virtual LEDs in the cooja platform are connected as follows: + * - LED1 (Green) -> port 0 + * - LED2 (Red) -> port 1 + * - LED3 (Yellow) -> port 2 + */ +gpio_hal_pin_t out_pin1 = COOJA_LED_GREEN_PIN; +gpio_hal_pin_t out_pin2 = COOJA_LED_RED_PIN; +gpio_hal_pin_t out_pin3 = COOJA_LED_YELLOW_PIN; +/*---------------------------------------------------------------------------*/ +/* Virtual Button pin: port 3 */ +gpio_hal_pin_t btn_pin = COOJA_BTN_PIN; +/*---------------------------------------------------------------------------*/ diff --git a/examples/dev/gpio-hal/openmote-cc2538/pins.c b/examples/dev/gpio-hal/openmote/pins.c similarity index 93% rename from examples/dev/gpio-hal/openmote-cc2538/pins.c rename to examples/dev/gpio-hal/openmote/pins.c index 340aff15c5b65ff0bcdebb036187f975e45a854a..ec23eb1767a7941832667932ff10af395b1418aa 100644 --- a/examples/dev/gpio-hal/openmote-cc2538/pins.c +++ b/examples/dev/gpio-hal/openmote/pins.c @@ -43,6 +43,11 @@ gpio_hal_pin_t out_pin1 = 20; gpio_hal_pin_t out_pin2 = 22; gpio_hal_pin_t out_pin3 = 23; /*---------------------------------------------------------------------------*/ +#ifdef CONTIKI_BOARD_OPENMOTE_B +/* Button pin: PD5 */ +gpio_hal_pin_t btn_pin = 29; +#else /* CONTIKI_BOARD_OPENMOTE_B */ /* Button pin: PC3 */ gpio_hal_pin_t btn_pin = 19; +#endif /* CONTIKI_BOARD_OPENMOTE_B */ /*---------------------------------------------------------------------------*/ diff --git a/examples/libs/deployment/Makefile b/examples/libs/deployment/Makefile index 5ad17e22d70d840d16c89474dd6d7abcbd054f5a..3bc0a5a38e3af3e35c7b5898c96057441284aed3 100644 --- a/examples/libs/deployment/Makefile +++ b/examples/libs/deployment/Makefile @@ -1,7 +1,9 @@ CONTIKI_PROJECT = node all: $(CONTIKI_PROJECT) -MODULES += os/services/deployment - CONTIKI = ../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/deployment + include $(CONTIKI)/Makefile.include diff --git a/examples/libs/shell/Makefile b/examples/libs/shell/Makefile index 7be7dd18edfc23b98a1b9af318112cb7c4797c7c..16adbbacbec9d5275501e643767d03e056fa7a53 100644 --- a/examples/libs/shell/Makefile +++ b/examples/libs/shell/Makefile @@ -1,9 +1,11 @@ CONTIKI_PROJECT = example all: $(CONTIKI_PROJECT) -MODULES += os/services/shell CONTIKI = ../../.. +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/shell + PLATFORMS_EXCLUDE = sky include $(CONTIKI)/Makefile.include diff --git a/examples/libs/simple-energest/Makefile b/examples/libs/simple-energest/Makefile index 056aa5c434efeb118d7ea1d6fea5087d22cc6c89..21c8eb86f6792baebf3f8f7fc2acc23e7e5ee5a2 100644 --- a/examples/libs/simple-energest/Makefile +++ b/examples/libs/simple-energest/Makefile @@ -1,6 +1,9 @@ CONTIKI_PROJECT = example all: $(CONTIKI_PROJECT) -MODULES += os/services/simple-energest CONTIKI = ../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/simple-energest + include $(CONTIKI)/Makefile.include diff --git a/examples/lwm2m-ipso-objects/Makefile b/examples/lwm2m-ipso-objects/Makefile index a8d461859cc197ac401c8c631d4a73373e44e33e..f1d8423e493312ef57691f2925a8d1b37a0b99bf 100644 --- a/examples/lwm2m-ipso-objects/Makefile +++ b/examples/lwm2m-ipso-objects/Makefile @@ -6,11 +6,13 @@ PLATFORMS_EXCLUDE = sky z1 all: $(CONTIKI_PROJECT) -MODULES += os/net/app-layer/coap -MODULES += os/services/lwm2m -MODULES += os/services/ipso-objects - CONTIKI=../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap +MODULES += $(CONTIKI_NG_SERVICES_DIR)/lwm2m +MODULES += $(CONTIKI_NG_SERVICES_DIR)/ipso-objects + include $(CONTIKI)/Makefile.identify-target MODULES_REL += $(TARGET) diff --git a/examples/lwm2m-ipso-objects/example-server.c b/examples/lwm2m-ipso-objects/example-server.c index 98e1fef9afca486ed2260842fe76cbc7e1271e77..b571468f4d9717ea761cf102a4622d7e844c04dc 100644 --- a/examples/lwm2m-ipso-objects/example-server.c +++ b/examples/lwm2m-ipso-objects/example-server.c @@ -172,6 +172,12 @@ client_chunk_handler(coap_message_t *response) { const uint8_t *chunk; unsigned int format; + + if(response == NULL) { + PRINTF("\nRequest timed out\n"); + return; + } + int len = coap_get_payload(response, &chunk); coap_get_header_content_format(response, &format); diff --git a/examples/mqtt-client/Makefile b/examples/mqtt-client/Makefile index 29b3267e16efed7a410619be22c4262e5b36da4a..15d48770117eef232502795053ce08cc9a47dfaf 100644 --- a/examples/mqtt-client/Makefile +++ b/examples/mqtt-client/Makefile @@ -1,13 +1,15 @@ CONTIKI_PROJECT = mqtt-client all: $(CONTIKI_PROJECT) -MODULES += os/net/app-layer/mqtt - CONTIKI = ../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/mqtt + -include $(CONTIKI)/Makefile.identify-target MODULES_REL += arch/platform/$(TARGET) -PLATFORMS_ONLY = cc26x0-cc13x0 cc2538dk openmote-cc2538 zoul native simplelink +PLATFORMS_ONLY = cc26x0-cc13x0 cc2538dk openmote zoul native simplelink include $(CONTIKI)/Makefile.include diff --git a/examples/mqtt-client/arch/platform/openmote-cc2538/Makefile.openmote-cc2538 b/examples/mqtt-client/arch/platform/openmote/Makefile.openmote similarity index 100% rename from examples/mqtt-client/arch/platform/openmote-cc2538/Makefile.openmote-cc2538 rename to examples/mqtt-client/arch/platform/openmote/Makefile.openmote diff --git a/examples/mqtt-client/arch/platform/openmote-cc2538/module-macros.h b/examples/mqtt-client/arch/platform/openmote/module-macros.h similarity index 100% rename from examples/mqtt-client/arch/platform/openmote-cc2538/module-macros.h rename to examples/mqtt-client/arch/platform/openmote/module-macros.h diff --git a/examples/mqtt-client/arch/platform/openmote-cc2538/mqtt-client-extensions.c b/examples/mqtt-client/arch/platform/openmote/mqtt-client-extensions.c similarity index 100% rename from examples/mqtt-client/arch/platform/openmote-cc2538/mqtt-client-extensions.c rename to examples/mqtt-client/arch/platform/openmote/mqtt-client-extensions.c diff --git a/examples/mqtt-client/mqtt-client.c b/examples/mqtt-client/mqtt-client.c index 35e669e245b9f77f7187a075f4dcf49fe977036d..d725e46b967f3170f1576ce19d3ebaa4b94c95d0 100644 --- a/examples/mqtt-client/mqtt-client.c +++ b/examples/mqtt-client/mqtt-client.c @@ -351,7 +351,17 @@ mqtt_event(struct mqtt_connection *m, mqtt_event_t event, void *data) break; } case MQTT_EVENT_SUBACK: { +#if MQTT_311 + mqtt_suback_event_t *suback_event = (mqtt_suback_event_t *)data; + + if(suback_event->success) { + LOG_DBG("Application is subscribed to topic successfully\n"); + } else { + LOG_DBG("Application failed to subscribe to topic (ret code %x)\n", suback_event->return_code); + } +#else LOG_DBG("Application is subscribed to topic successfully\n"); +#endif break; } case MQTT_EVENT_UNSUBACK: { @@ -572,7 +582,8 @@ connect_to_broker(void) { /* Connect to MQTT server */ mqtt_connect(&conn, conf.broker_ip, conf.broker_port, - (conf.pub_interval * 3) / CLOCK_SECOND); + (conf.pub_interval * 3) / CLOCK_SECOND, + MQTT_CLEAN_SESSION_ON); state = STATE_CONNECTING; } diff --git a/examples/multicast/Makefile b/examples/multicast/Makefile index 3e8a88d4a056e4d0d5bc55829623ed10405a1690..9fe5db4ae981269ad6fd7dab367b63a4b30c394a 100644 --- a/examples/multicast/Makefile +++ b/examples/multicast/Makefile @@ -11,7 +11,8 @@ CONTIKI = ../.. include $(CONTIKI)/Makefile.identify-target MODULES_REL += $(TARGET) -MODULES += os/net/ipv6/multicast +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_NET_DIR)/ipv6/multicast MAKE_ROUTING = MAKE_ROUTING_RPL_CLASSIC include $(CONTIKI)/Makefile.include diff --git a/examples/multicast/multicast.csc b/examples/multicast/multicast.csc index d59708d54543fe976e3d1e8d1a4d8aa0dd2dceb5..f2da518fd9f35a929445ce6221f44450c395d731 100644 --- a/examples/multicast/multicast.csc +++ b/examples/multicast/multicast.csc @@ -7,12 +7,12 @@ <project EXPORT="discard">[APPS_DIR]/powertracker</project> <simulation> <title>Example of a uIPv6 network with multicast support</title> - <randomseed>123456</randomseed> + <randomseed>generated</randomseed> <motedelay_us>1000000</motedelay_us> <radiomedium> org.contikios.cooja.radiomediums.UDGM <transmitting_range>50.0</transmitting_range> - <interference_range>50.0</interference_range> + <interference_range>100.0</interference_range> <success_ratio_tx>1.0</success_ratio_tx> <success_ratio_rx>1.0</success_ratio_rx> </radiomedium> @@ -20,209 +20,441 @@ <logoutput>40000</logoutput> </events> <motetype> - org.contikios.cooja.mspmote.SkyMoteType - <identifier>sky1</identifier> - <description>root</description> - <source EXPORT="discard">[CONTIKI_DIR]/examples/multicast/root.c</source> - <commands EXPORT="discard">make root.sky TARGET=sky</commands> - <firmware EXPORT="copy">[CONTIKI_DIR]/examples/multicast/root.sky</firmware> + org.contikios.cooja.contikimote.ContikiMoteType + <identifier>mtype653</identifier> + <description>root/sender</description> + <source>[CONTIKI_DIR]/examples/multicast/root.c</source> + <commands>make -j root.cooja TARGET=cooja</commands> <moteinterface>org.contikios.cooja.interfaces.Position</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface> <moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface> - <moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface> <moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface> <moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface> + <symbols>false</symbols> </motetype> <motetype> - org.contikios.cooja.mspmote.SkyMoteType - <identifier>sky2</identifier> - <description>intermediate</description> - <source EXPORT="discard">[CONTIKI_DIR]/examples/multicast/intermediate.c</source> - <commands EXPORT="discard">make intermediate.sky TARGET=sky</commands> - <firmware EXPORT="copy">[CONTIKI_DIR]/examples/multicast/intermediate.sky</firmware> + org.contikios.cooja.contikimote.ContikiMoteType + <identifier>mtype444</identifier> + <description>intermediate/forwarder</description> + <source>[CONTIKI_DIR]/examples/multicast/intermediate.c</source> + <commands>make -j intermediate.cooja TARGET=cooja</commands> <moteinterface>org.contikios.cooja.interfaces.Position</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface> <moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface> - <moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface> <moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface> <moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface> + <symbols>false</symbols> </motetype> <motetype> - org.contikios.cooja.mspmote.SkyMoteType - <identifier>sky3</identifier> - <description>sink</description> - <source EXPORT="discard">[CONTIKI_DIR]/examples/multicast/sink.c</source> - <commands EXPORT="discard">make sink.sky TARGET=sky</commands> - <firmware EXPORT="copy">[CONTIKI_DIR]/examples/multicast/sink.sky</firmware> + org.contikios.cooja.contikimote.ContikiMoteType + <identifier>mtype278</identifier> + <description>sink/receiver</description> + <source>[CONTIKI_DIR]/examples/multicast/sink.c</source> + <commands>make -j sink.cooja TARGET=cooja</commands> <moteinterface>org.contikios.cooja.interfaces.Position</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface> <moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface> - <moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface> <moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface> <moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface> - <moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface> + <symbols>false</symbols> </motetype> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>5.995813174969022</x> - <y>34.43129455447824</y> + <x>55.22591754225785</x> + <y>49.650716709765916</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>1</id> </interface_config> - <motetype_identifier>sky1</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype653</motetype_identifier> </mote> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>40.70237155931961</x> - <y>16.396742420332068</y> + <x>38.61687123267503</x> + <y>79.70810681904891</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>2</id> </interface_config> - <motetype_identifier>sky2</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype444</motetype_identifier> </mote> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>100.3720728044051</x> - <y>70.93197095432518</y> + <x>114.02148096681616</x> + <y>27.15919564417576</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>3</id> </interface_config> - <motetype_identifier>sky3</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype444</motetype_identifier> </mote> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>81.7376718406712</x> - <y>28.854291358797</y> + <x>3.296257703255435</x> + <y>98.34240450382686</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>4</id> </interface_config> - <motetype_identifier>sky3</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype444</motetype_identifier> </mote> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>-26.161520836433183</x> - <y>8.116006415286686</y> + <x>38.63600816625843</x> + <y>9.493266395947245</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>5</id> </interface_config> - <motetype_identifier>sky3</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype444</motetype_identifier> </mote> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>-34.57705675553882</x> - <y>92.87247531485058</y> + <x>95.6217069936666</x> + <y>58.8510979161732</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>6</id> </interface_config> - <motetype_identifier>sky3</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype444</motetype_identifier> </mote> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>39.86312587077661</x> - <y>59.603125741056246</y> + <x>65.91501437505903</x> + <y>49.341975078118125</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>7</id> </interface_config> - <motetype_identifier>sky2</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> </mote> <mote> - <breakpoints /> <interface_config> org.contikios.cooja.interfaces.Position - <x>1.4345607604759194</x> - <y>75.2481773153879</y> + <x>49.33272870326012</x> + <y>64.62796208484475</y> <z>0.0</z> </interface_config> <interface_config> - org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.contikimote.interfaces.ContikiMoteID <id>8</id> </interface_config> - <motetype_identifier>sky2</motetype_identifier> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>7.577029591852192</x> + <y>58.32276910078554</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>9</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>24.15611158750555</x> + <y>2.2657265420587915</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>10</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>77.97815620016003</x> + <y>21.550964613014166</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>11</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>97.57674352590605</x> + <y>49.9075248755968</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>12</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>99.79572657766474</x> + <y>6.744192624617192</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>13</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>83.61512379219572</x> + <y>89.40117376262259</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>14</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>40.15604829080403</x> + <y>102.64288212010037</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>15</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>120.59450799379478</x> + <y>79.76195329512228</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>16</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype278</motetype_identifier> </mote> </simulation> <plugin> org.contikios.cooja.plugins.SimControl - <width>318</width> - <z>0</z> - <height>192</height> - <location_x>0</location_x> + <width>280</width> + <z>3</z> + <height>160</height> + <location_x>400</location_x> <location_y>0</location_y> </plugin> <plugin> org.contikios.cooja.plugins.Visualizer <plugin_config> + <moterelations>true</moterelations> <skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin> - <skin>org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin> <skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin> - <skin>org.contikios.cooja.plugins.skins.AddressVisualizerSkin</skin> - <viewport>3.914959956760176 0.0 0.0 3.914959956760176 300.2075734071477 -15.682931033747009</viewport> + <skin>org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin> + <viewport>2.654674204085605 0.0 0.0 2.654674204085605 38.27981273545236 41.95909489561165</viewport> </plugin_config> - <width>869</width> - <z>3</z> - <height>441</height> - <location_x>320</location_x> - <location_y>3</location_y> + <width>400</width> + <z>2</z> + <height>400</height> + <location_x>1</location_x> + <location_y>1</location_y> </plugin> <plugin> org.contikios.cooja.plugins.LogListener @@ -231,26 +463,41 @@ <formatted_time /> <coloring /> </plugin_config> - <width>1281</width> - <z>2</z> - <height>213</height> - <location_x>-1</location_x> - <location_y>714</location_y> + <width>823</width> + <z>1</z> + <height>240</height> + <location_x>400</location_x> + <location_y>160</location_y> </plugin> <plugin> - org.contikios.cooja.plugins.RadioLogger + org.contikios.cooja.plugins.TimeLine <plugin_config> - <split>117</split> - <formatted_time /> - <showdups>false</showdups> - <hidenodests>false</hidenodests> - <analyzers name="6lowpan-pcap" /> + <mote>0</mote> + <mote>1</mote> + <mote>2</mote> + <mote>3</mote> + <mote>4</mote> + <mote>5</mote> + <mote>6</mote> + <mote>7</mote> + <mote>8</mote> + <mote>9</mote> + <mote>10</mote> + <mote>11</mote> + <mote>12</mote> + <mote>13</mote> + <mote>14</mote> + <mote>15</mote> + <showRadioRXTX /> + <showRadioHW /> + <showLEDs /> + <zoomfactor>500.0</zoomfactor> </plugin_config> - <width>1280</width> - <z>1</z> - <height>268</height> - <location_x>0</location_x> - <location_y>445</location_y> + <width>1223</width> + <z>0</z> + <height>166</height> + <location_x>2</location_x> + <location_y>411</location_y> </plugin> </simconf> diff --git a/examples/platform-specific/cc2538-common/Makefile b/examples/platform-specific/cc2538-common/Makefile index c55c65eafba5fe747887f5bb1b96fad077c4da99..e728e7dc198f8c277b4a412649eecd0f3d52e568 100644 --- a/examples/platform-specific/cc2538-common/Makefile +++ b/examples/platform-specific/cc2538-common/Makefile @@ -2,7 +2,7 @@ CONTIKI_PROJECT = test-pwm timer-test test-uart all: $(CONTIKI_PROJECT) -PLATFORMS_ONLY = cc2538dk openmote-cc2538 zoul +PLATFORMS_ONLY = cc2538dk openmote zoul CONTIKI = ../../.. include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/cc2538-common/crypto/Makefile b/examples/platform-specific/cc2538-common/crypto/Makefile index 2191d44f04ed127ec6c19ed8dbe1bf6226194880..37bdffe8a6bf1c50f6ea03f388709d795278b5f8 100644 --- a/examples/platform-specific/cc2538-common/crypto/Makefile +++ b/examples/platform-specific/cc2538-common/crypto/Makefile @@ -3,7 +3,7 @@ CONTIKI_PROJECT += sha256-test all: $(CONTIKI_PROJECT) -PLATFORMS_ONLY = cc2538dk openmote-cc2538 zoul +PLATFORMS_ONLY = cc2538dk openmote zoul CONTIKI = ../../../.. include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/cc2538-common/pka/Makefile b/examples/platform-specific/cc2538-common/pka/Makefile index 01ba6fe6219e8656553ae35cd1a81700ec7b27c6..c101e4e8e638549660a58d51d445542adaf4e0cc 100644 --- a/examples/platform-specific/cc2538-common/pka/Makefile +++ b/examples/platform-specific/cc2538-common/pka/Makefile @@ -2,7 +2,7 @@ CONTIKI_PROJECT = ecc-ecdh ecc-sign ecc-verify all: $(CONTIKI_PROJECT) -PLATFORMS_ONLY = cc2538dk openmote-cc2538 zoul +PLATFORMS_ONLY = cc2538dk openmote zoul CONTIKI = ../../../.. include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/Makefile b/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/Makefile index 6d70a3a2407df13e9bf09446198f814fdb0a8a1d..6c7293b12ed31d339cdae868635e7f57c34ed779 100644 --- a/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/Makefile +++ b/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/Makefile @@ -13,9 +13,9 @@ ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) PROJECT_SOURCEFILES += cetic-6lbr-client.c endif -# REST Engine shall use Erbium CoAP implementation -MODULES += os/net/app-layer/mqtt -MODULES += os/net/app-layer/coap - CONTIKI=../../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/mqtt $(CONTIKI_NG_APP_LAYER_DIR)/coap + include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/mqtt-client.c b/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/mqtt-client.c index 0250de322ea76cb8a6cecb03e1819e6fd694af27..df3445ba18fac97ceabe9bb7dea3b0c72fb57400 100644 --- a/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/mqtt-client.c +++ b/examples/platform-specific/cc26x0-cc13x0/cc26x0-web-demo/mqtt-client.c @@ -469,7 +469,17 @@ mqtt_event(struct mqtt_connection *m, mqtt_event_t event, void *data) break; } case MQTT_EVENT_SUBACK: { +#if MQTT_311 + mqtt_suback_event_t *suback_event = (mqtt_suback_event_t *)data; + + if(suback_event->success) { + DBG("APP - Application is subscribed to topic successfully\n"); + } else { + DBG("APP - Application failed to subscribe to topic (ret code %x)\n", suback_event->return_code); + } +#else DBG("APP - Application is subscribed to topic successfully\n"); +#endif break; } case MQTT_EVENT_UNSUBACK: { @@ -699,7 +709,8 @@ connect_to_broker(void) /* Connect to MQTT server */ mqtt_status_t conn_attempt_result = mqtt_connect(&conn, conf->broker_ip, conf->broker_port, - conf->pub_interval * 3); + conf->pub_interval * 3, + MQTT_CLEAN_SESSION_ON); if(conn_attempt_result == MQTT_STATUS_OK) { state = MQTT_CLIENT_STATE_CONNECTING; diff --git a/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/Makefile b/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/Makefile index d62dff3e3908718b149b1f63369de6bfcc605c40..73b0a8f0a6206b4771c667793c3dffa6c3829f00 100644 --- a/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/Makefile +++ b/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/Makefile @@ -4,7 +4,9 @@ PLATFORMS_ONLY = cc26x0-cc13x0 all: $(CONTIKI_PROJECT) -MODULES += os/net/app-layer/coap - CONTIKI = ../../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap + include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/project-conf.h b/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/project-conf.h index 0f8467a685577ad28d67a55ee369df1a898cfdcf..5477d1b1794d79ec4be40b13aaaf33e6ce8a5362 100644 --- a/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/project-conf.h +++ b/examples/platform-specific/cc26x0-cc13x0/very-sleepy-demo/project-conf.h @@ -40,7 +40,6 @@ /*---------------------------------------------------------------------------*/ /* For very sleepy operation */ #define RF_BLE_CONF_ENABLED 0 -#define UIP_DS6_CONF_PERIOD CLOCK_SECOND #define UIP_CONF_TCP 0 #define RPL_CONF_LEAF_ONLY 1 diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile index d0437d869f0282f443cc7159717cf50096a44f54..8789a63671f8b86ce6ce0baa5574021cbf9f759b 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile @@ -9,9 +9,11 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/lib/json -MODULES_REL += .. -MODULES += os/net/app-layer/coap +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_LIB_DIR)/json +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap + +MODULES_REL += .. include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile index 3670d12c45ac101aff289d8c756e79d4c3030614..65fc1d9709fca78beb7fe300907653cf41f94b4e 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile @@ -9,9 +9,11 @@ JN516x_WITH_DR1175 = 1 CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/lib/json -MODULES_REL += .. -MODULES += os/net/app-layer/coap +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_LIB_DIR)/json +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap + +MODULES_REL += .. include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile index b2286e272b774ff12ae93c954d014346e0955eb6..e5bb3d170ce9838e3c37931e93111956ae2e42b4 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile @@ -9,9 +9,11 @@ JN516x_WITH_DR1199 = 1 CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/lib/json -MODULES_REL += .. -MODULES += os/net/app-layer/coap +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_LIB_DIR)/json +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap + +MODULES_REL += .. include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile index 2880a76dedb9500eb50509d8476d5d24b8413e22..37b7bae2a5121d136ff8bbf0520ec8ffc39d5cba 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile @@ -9,8 +9,9 @@ CONTIKI=../../../../../.. MODULES_REL += .. MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/net/app-layer/coap -MODULES += os/services/orchestra os/lib/json +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra $(CONTIKI_NG_LIB_DIR)/json all: $(CONTIKI_PROJECT) diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile index d19228f4dd9ad80c318af391faeec6a8e46b252d..8cce3c1b25568e507eab83729ac9b7f71c873ea2 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile @@ -10,8 +10,9 @@ CONTIKI=../../../../../.. MODULES_REL += .. MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/net/app-layer/coap -MODULES += os/services/orchestra os/lib/json +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra $(CONTIKI_NG_LIB_DIR)/json all: $(CONTIKI_PROJECT) diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile index 22c5ee2164792f73f3f9367ca9fc99516c70cea9..88090b343708d45eab37cc1be31b915c778101fa 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile @@ -11,8 +11,9 @@ CONTIKI=../../../../.. MODULES_REL += .. MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/net/app-layer/coap -MODULES += os/services/orchestra os/lib/json +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap +MODULES += $(CONTIKI_NG_SERVICES_DIR)/orchestra $(CONTIKI_NG_LIB_DIR)/json all: $(CONTIKI_PROJECT) diff --git a/examples/platform-specific/nrf52dk/coap-demo/coap-client/Makefile b/examples/platform-specific/nrf52dk/coap-demo/coap-client/Makefile index b7a5ff778242706643b2ed438552f1c42ed52209..5c05a1c6e4e7a5d5349640e68c928b713afa7044 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/coap-client/Makefile +++ b/examples/platform-specific/nrf52dk/coap-demo/coap-client/Makefile @@ -19,7 +19,8 @@ CFLAGS += -DCOAP_OBSERVE_CLIENT=1 MODULES_REL += ./resources # REST Engine shall use Erbium CoAP implementation -MODULES += os/net/app-layer/coap +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap MAKE_ROUTING = MAKE_ROUTING_NULLROUTING diff --git a/examples/platform-specific/nrf52dk/coap-demo/coap-server/Makefile b/examples/platform-specific/nrf52dk/coap-demo/coap-server/Makefile index 0202f0e929706d3ac1d956ac71f874c710b15c96..acc1cb259a19f754675fbdce45efbc9a1948ea55 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/coap-server/Makefile +++ b/examples/platform-specific/nrf52dk/coap-demo/coap-server/Makefile @@ -13,7 +13,8 @@ PROJECTDIRS += $(REST_RESOURCES_DIR) PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) # REST Engine shall use Erbium CoAP implementation -MODULES += os/net/app-layer/coap +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/coap MAKE_ROUTING = MAKE_ROUTING_NULLROUTING diff --git a/examples/platform-specific/nrf52dk/mqtt-demo/Makefile b/examples/platform-specific/nrf52dk/mqtt-demo/Makefile index dc3e23e67d86fb7b9ec89187048fa7bf5d82cbf5..7afd817e7183076979c702bdba955add30d6a077 100644 --- a/examples/platform-specific/nrf52dk/mqtt-demo/Makefile +++ b/examples/platform-specific/nrf52dk/mqtt-demo/Makefile @@ -5,7 +5,9 @@ PLATFORMS_ONLY = nrf52dk MAKE_ROUTING = MAKE_ROUTING_NULLROUTING -MODULES += os/net/app-layer/mqtt - CONTIKI=../../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/mqtt + include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/nrf52dk/mqtt-demo/mqtt-demo.c b/examples/platform-specific/nrf52dk/mqtt-demo/mqtt-demo.c index 6fa071617f6e82f16a96d8639d9149af12742299..07e1ffc59635dc212440912a8936e9ea6cfbf141 100644 --- a/examples/platform-specific/nrf52dk/mqtt-demo/mqtt-demo.c +++ b/examples/platform-specific/nrf52dk/mqtt-demo/mqtt-demo.c @@ -305,7 +305,17 @@ mqtt_event(struct mqtt_connection *m, mqtt_event_t event, void *data) break; } case MQTT_EVENT_SUBACK: { +#if MQTT_311 + mqtt_suback_event_t *suback_event = (mqtt_suback_event_t *)data; + + if(suback_event->success) { + DBG("APP - Application is subscribed to topic successfully\n"); + } else { + DBG("APP - Application failed to subscribe to topic (ret code %x)\n", suback_event->return_code); + } +#else DBG("APP - Application is subscribed to topic successfully\n"); +#endif break; } case MQTT_EVENT_UNSUBACK: { @@ -512,7 +522,7 @@ connect_to_broker(void) { /* Connect to MQTT server */ mqtt_connect(&conn, conf.broker_ip, conf.broker_port, - conf.pub_interval * 3); + conf.pub_interval * 3, MQTT_CLEAN_SESSION_ON); state = STATE_CONNECTING; } diff --git a/examples/platform-specific/zoul/Makefile b/examples/platform-specific/zoul/Makefile index 1f29bda4cada99850e2c3656f2883bc7eb6612ba..470ffe30f6b1168d471403726cf51425606c3015 100644 --- a/examples/platform-specific/zoul/Makefile +++ b/examples/platform-specific/zoul/Makefile @@ -11,11 +11,13 @@ CONTIKI_TARGET_SOURCEFILES += adc-sensors.c weather-meter.c grove-gyro.c CONTIKI_TARGET_SOURCEFILES += rgb-bl-lcd.c pm10-sensor.c iaq.c zonik.c relay.c CONTIKI_TARGET_SOURCEFILES += dht22.c servo.c ac-dimmer.c bme280-arch.c -MODULES += arch/dev/bme280 - all: $(CONTIKI_PROJECT) PLATFORMS_ONLY = zoul CONTIKI = ../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_DRIVERS_DIR)/bme280 + include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/zoul/orion/client/Makefile b/examples/platform-specific/zoul/orion/client/Makefile index 22354dc98ef8e5048dadf81fb99de6cb068b6782..ec03def7e844452cc66670f09275efce6bc725e6 100644 --- a/examples/platform-specific/zoul/orion/client/Makefile +++ b/examples/platform-specific/zoul/orion/client/Makefile @@ -3,12 +3,14 @@ all: $(CONTIKI_PROJECT) BOARD = orion -MODULES += os/net/app-layer/http-socket - WITH_IP64 = 1 PLATFORMS_ONLY = zoul BOARDS_ONLY = orion CONTIKI = ../../../../.. + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/http-socket + include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 8d210dd3c5e91b850879e8a6ffbf8e16aef9d7d2..88a0859a4602068250f31a07dc0314785c406602 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -6,7 +6,8 @@ CONTIKI = ../.. PLATFORMS_EXCLUDE = nrf52dk z1 # Include RPL BR module -MODULES += os/services/rpl-border-router +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/rpl-border-router # Include webserver module MODULES_REL += webserver # Include optional target-specific module diff --git a/examples/sensniff/Makefile b/examples/sensniff/Makefile index f931aed775f6cef2c6926863ce4853fbd0327658..29862e705c2753230954efa1804c6d537fe3ce7d 100644 --- a/examples/sensniff/Makefile +++ b/examples/sensniff/Makefile @@ -1,7 +1,7 @@ CONTIKI_PROJECT = sensniff CONTIKI = ../.. -PLATFORMS_ONLY = cc2538dk openmote-cc2538 z1 zoul cc26x0-cc13x0 jn516x simplelink +PLATFORMS_ONLY = cc2538dk openmote z1 zoul cc26x0-cc13x0 jn516x simplelink PROJECT_SOURCEFILES += sensniff-mac.c netstack.c MODULES_REL += pool $(TARGET) diff --git a/examples/sensniff/openmote-cc2538/target-conf.h b/examples/sensniff/openmote/target-conf.h similarity index 100% rename from examples/sensniff/openmote-cc2538/target-conf.h rename to examples/sensniff/openmote/target-conf.h diff --git a/examples/slip-radio/Makefile b/examples/slip-radio/Makefile index 877b109f111ec711b0eb139b688c478d1fee9d13..c5e30d5c2450e875692f4f347adf58bc342672b3 100644 --- a/examples/slip-radio/Makefile +++ b/examples/slip-radio/Makefile @@ -1,6 +1,5 @@ CONTIKI_PROJECT=slip-radio all: $(CONTIKI_PROJECT) -MODULES += os/services/slip-cmd # slip-radio is only intended for platforms with SLIP support PLATFORMS_EXCLUDE = native nrf52dk @@ -8,6 +7,9 @@ PLATFORMS_EXCLUDE = native nrf52dk CONTIKI=../.. include $(CONTIKI)/Makefile.identify-target +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_SERVICES_DIR)/slip-cmd + MODULES_REL += $(TARGET) PROJECT_SOURCEFILES += slip-net.c diff --git a/examples/snmp-server/Makefile b/examples/snmp-server/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..c2e7b8952dcf472b7c5308be56fb66aa66b62c72 --- /dev/null +++ b/examples/snmp-server/Makefile @@ -0,0 +1,10 @@ +CONTIKI_PROJECT = snmp-server +all: $(CONTIKI_PROJECT) + +MODULES += os/net/app-layer/snmp + +MODULES_REL += ./resources + +CONTIKI = ../.. + +include $(CONTIKI)/Makefile.include diff --git a/examples/snmp-server/project-conf.h b/examples/snmp-server/project-conf.h new file mode 100644 index 0000000000000000000000000000000000000000..724e89485b19ec1a39881e4e87162fede1d2bf0b --- /dev/null +++ b/examples/snmp-server/project-conf.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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. + */ +/*---------------------------------------------------------------------------*/ + +#define LOG_CONF_LEVEL_SNMP LOG_LEVEL_DBG diff --git a/examples/snmp-server/resources/snmp-SNMP-MIB-2-System.c b/examples/snmp-server/resources/snmp-SNMP-MIB-2-System.c new file mode 100644 index 0000000000000000000000000000000000000000..f87d2bd2f07c7937279c6ca4e8a99d43dca56183 --- /dev/null +++ b/examples/snmp-server/resources/snmp-SNMP-MIB-2-System.c @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 "snmp-api.h" + +/*---------------------------------------------------------------------------*/ +static void +sysDescr_handler(snmp_varbind_t *varbind, uint32_t *oid); + +MIB_RESOURCE(sysDescr, sysDescr_handler, 1, 3, 6, 1, 2, 1, 1, 1, 0); + +static void +sysDescr_handler(snmp_varbind_t *varbind, uint32_t *oid) +{ + snmp_api_set_string(varbind, oid, CONTIKI_VERSION_STRING); +} +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +static void +sysObjectID_handler(snmp_varbind_t *varbind, uint32_t *oid); + +MIB_RESOURCE(sysObjectID, sysObjectID_handler, 1, 3, 6, 1, 2, 1, 1, 2, 0); + +static void +sysObjectID_handler(snmp_varbind_t *varbind, uint32_t *oid) +{ + OID(sysObjectID_oid, 1, 3, 6, 1, 4, 1, 54352); + snmp_api_set_oid(varbind, oid, sysObjectID_oid); +} +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +static void +sysUpTime_handler(snmp_varbind_t *varbind, uint32_t *oid); + +MIB_RESOURCE(sysUpTime, sysUpTime_handler, 1, 3, 6, 1, 2, 1, 1, 3, 0); + +static void +sysUpTime_handler(snmp_varbind_t *varbind, uint32_t *oid) +{ + snmp_api_set_time_ticks(varbind, oid, clock_seconds() * 100); +} +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +static void +sysContact_handler(snmp_varbind_t *varbind, uint32_t *oid); + +MIB_RESOURCE(sysContact, sysContact_handler, 1, 3, 6, 1, 2, 1, 1, 4, 0); + +static void +sysContact_handler(snmp_varbind_t *varbind, uint32_t *oid) +{ + snmp_api_set_string(varbind, oid, "Contiki-NG, https://github.com/contiki-ng/contiki-ng"); +} +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +static void +sysName_handler(snmp_varbind_t *varbind, uint32_t *oid); + +MIB_RESOURCE(sysName, sysName_handler, 1, 3, 6, 1, 2, 1, 1, 5, 0); + +static void +sysName_handler(snmp_varbind_t *varbind, uint32_t *oid) +{ + snmp_api_set_string(varbind, oid, "Contiki-NG - "CONTIKI_TARGET_STRING); +} +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +static void +sysLocation_handler(snmp_varbind_t *varbind, uint32_t *oid); + +MIB_RESOURCE(sysLocation, sysLocation_handler, 1, 3, 6, 1, 2, 1, 1, 6, 0); + +static void +sysLocation_handler(snmp_varbind_t *varbind, uint32_t *oid) +{ + snmp_api_set_string(varbind, oid, ""); +} +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +static void +sysServices_handler(snmp_varbind_t *varbind, uint32_t *oid); + +MIB_RESOURCE(sysServices, sysServices_handler, 1, 3, 6, 1, 2, 1, 1, 7, 0); + +static void +sysServices_handler(snmp_varbind_t *varbind, uint32_t *oid) +{ + snmp_api_set_time_ticks(varbind, oid, clock_seconds() * 100); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/snmp-server/snmp-server.c b/examples/snmp-server/snmp-server.c new file mode 100644 index 0000000000000000000000000000000000000000..dbc638f05e5e307d30e2fc7eefe552d340a0c764 --- /dev/null +++ b/examples/snmp-server/snmp-server.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 "contiki.h" +#include "snmp-api.h" + +/*---------------------------------------------------------------------------*/ +PROCESS_NAME(snmp_server_process); +AUTOSTART_PROCESSES(&snmp_server_process); +/*---------------------------------------------------------------------------*/ + +extern snmp_mib_resource_t + sysDescr, + sysObjectID, + sysUpTime, + sysContact, + sysName, + sysLocation, + sysServices; + +/*---------------------------------------------------------------------------*/ + +PROCESS(snmp_server_process, "SNMP Server"); + +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(snmp_server_process, ev, data) +{ + + PROCESS_BEGIN(); + + snmp_api_add_resource(&sysDescr); + snmp_api_add_resource(&sysObjectID); + snmp_api_add_resource(&sysUpTime); + snmp_api_add_resource(&sysContact); + snmp_api_add_resource(&sysName); + snmp_api_add_resource(&sysLocation); + snmp_api_add_resource(&sysServices); + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/storage/antelope-shell/Makefile b/examples/storage/antelope-shell/Makefile index 5eff3dcd3e9b59cea2892cf91aec654d2ecadbbb..1b101835ed7087f9173907d1f2ef7ad69ab7e2b8 100644 --- a/examples/storage/antelope-shell/Makefile +++ b/examples/storage/antelope-shell/Makefile @@ -1,6 +1,8 @@ CONTIKI = ../../.. -MODULES += os/storage/antelope os/services/unit-test +include $(CONTIKI)/Makefile.dir-variables + +MODULES += $(CONTIKI_NG_STORAGE_DIR)/antelope $(CONTIKI_NG_SERVICES_DIR)/unit-test # does not fit on Sky PLATFORMS_ONLY= cc2538dk zoul diff --git a/examples/storage/cfs-coffee/Makefile b/examples/storage/cfs-coffee/Makefile index b6d22f5ac78acb4eb8542f87998eacb77ffaa363..cd05fa75602b8df75328dc9e7df88b0cbe652995 100644 --- a/examples/storage/cfs-coffee/Makefile +++ b/examples/storage/cfs-coffee/Makefile @@ -2,8 +2,9 @@ CONTIKI = ../../.. PLATFORMS_ONLY= cc2538dk zoul sky -MODULES += os/services/unit-test -MODULES += os/storage/cfs +include $(CONTIKI)/Makefile.dir-variables + +MODULES += $(CONTIKI_NG_STORAGE_DIR)/cfs $(CONTIKI_NG_SERVICES_DIR)/unit-test CONTIKI_PROJECT = test-cfs test-coffee example-coffee all: $(CONTIKI_PROJECT) diff --git a/examples/storage/cfs-coffee/README.md b/examples/storage/cfs-coffee/README.md index 640124d5629e246000b995178d86eabf8a704637..71c4a56a48eaed0a1833e5d3aacb21fc535eb81b 100644 --- a/examples/storage/cfs-coffee/README.md +++ b/examples/storage/cfs-coffee/README.md @@ -21,7 +21,7 @@ Supported Hardware (tested or known to work) * wismote * avr-raven * cc2538dk -* openmote-cc2538 +* openmote * zoul * TI cc26x0-cc13x0 - sensortag diff --git a/examples/websocket/Makefile b/examples/websocket/Makefile index d0b38d95d27cb9f8a18805947e632cd57b1b0787..9c8d095e2f59f6ac04932c17edcae1fdf8cfc114 100644 --- a/examples/websocket/Makefile +++ b/examples/websocket/Makefile @@ -1,7 +1,9 @@ CONTIKI_PROJECT = http-example websocket-example all: $(CONTIKI_PROJECT) CONTIKI=../.. -MODULES += os/net/app-layer/http-socket + +include $(CONTIKI)/Makefile.dir-variables +MODULES += $(CONTIKI_NG_APP_LAYER_DIR)/http-socket PLATFORMS_EXCLUDE = sky z1 diff --git a/examples/websocket/http-example.c b/examples/websocket/http-example.c index 2891bff88c9320f79c6841213549f2978ecc6acb..d937df90cc1e7519c79da35e19924f5a0077eb13 100644 --- a/examples/websocket/http-example.c +++ b/examples/websocket/http-example.c @@ -27,8 +27,15 @@ callback(struct http_socket *s, void *ptr, } else if(e == HTTP_SOCKET_CLOSED) { printf("HTTP socket closed, %d bytes received\n", bytes_received); } else if(e == HTTP_SOCKET_DATA) { + int i; bytes_received += datalen; - printf("HTTP socket received %d bytes of data\n", datalen); + printf("HTTP socket received %d bytes of data expects:%d\n", datalen, + (int) s->header.content_length); + printf("------------------------\n"); + for(i = 0; i < datalen; i++) { + printf("%c", data[i]); + } + printf("\n------------------------\n"); } } /*---------------------------------------------------------------------------*/ @@ -48,7 +55,7 @@ PROCESS_THREAD(http_example_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); http_socket_init(&s); - http_socket_get(&s, "http://www.contiki-os.org/", 0, 0, + http_socket_get(&s, "http://www.contiki-ng.org", 0, 0, callback, NULL); etimer_set(&et, CLOCK_SECOND); diff --git a/os/contiki-main.c b/os/contiki-main.c index 43e3017464a74e73a60b443a992a3f484d66042a..dbeb26e521d72a69a1adfd256b052c954824b0a5 100644 --- a/os/contiki-main.c +++ b/os/contiki-main.c @@ -50,6 +50,7 @@ #include "net/queuebuf.h" #include "net/app-layer/coap/coap-engine.h" +#include "net/app-layer/snmp/snmp.h" #include "services/rpl-border-router/rpl-border-router.h" #include "services/orchestra/orchestra.h" #include "services/shell/serial-shell.h" @@ -147,6 +148,11 @@ main(void) LOG_DBG("With CoAP\n"); #endif /* BUILD_WITH_SHELL */ +#if BUILD_WITH_SNMP + snmp_init(); + LOG_DBG("With SNMP\n"); +#endif /* BUILD_WITH_SNMP */ + #if BUILD_WITH_SIMPLE_ENERGEST simple_energest_init(); #endif /* BUILD_WITH_SIMPLE_ENERGEST */ diff --git a/os/contiki-net.h b/os/contiki-net.h index 6384c51ef9222055aee22073f40637c2a633f075..462245cdd6a898c6920fb71f4e0d6861155b46d8 100644 --- a/os/contiki-net.h +++ b/os/contiki-net.h @@ -46,11 +46,7 @@ #include "net/ipv6/uip-icmp6.h" #include "net/ipv6/uip-ds6.h" - -#include "net/ipv6/resolv.h" - #include "net/ipv6/psock.h" - #include "net/ipv6/udp-socket.h" #include "net/ipv6/tcp-socket.h" diff --git a/os/dev/nullradio.c b/os/dev/nullradio.c index 7f17d5638a3f5a4431b83565d6cc7b73f6cbad3e..6dbe1956b8613962c187dd809552f07c66811d50 100644 --- a/os/dev/nullradio.c +++ b/os/dev/nullradio.c @@ -1,6 +1,10 @@ #include "dev/nullradio.h" - - +/*---------------------------------------------------------------------------*/ +/* + * The maximum number of bytes this driver can accept from the MAC layer for + * "transmission". + */ +#define MAX_PAYLOAD_LEN ((unsigned short) - 1) /*---------------------------------------------------------------------------*/ static int init(void) @@ -66,7 +70,17 @@ off(void) static radio_result_t get_value(radio_param_t param, radio_value_t *value) { - return RADIO_RESULT_NOT_SUPPORTED; + if(!value) { + return RADIO_RESULT_INVALID_VALUE; + } + + switch(param) { + case RADIO_CONST_MAX_PAYLOAD_LEN: + *value = (radio_value_t)MAX_PAYLOAD_LEN; + return RADIO_RESULT_OK; + default: + return RADIO_RESULT_NOT_SUPPORTED; + } } /*---------------------------------------------------------------------------*/ static radio_result_t diff --git a/os/dev/radio.h b/os/dev/radio.h index 4cb266608ad80d97ab1931c16959d612faf7ca2d..53445acb4e273f1c8aaaf48db7470cf9bfee1810 100644 --- a/os/dev/radio.h +++ b/os/dev/radio.h @@ -206,6 +206,27 @@ enum { /* The delay in usec between the end of SFD reception for an incoming frame * and the radio API starting to return receiving_packet() != 0 */ RADIO_CONST_DELAY_BEFORE_DETECT, + + /* + * The maximum payload the radio driver is able to handle. + * + * This includes the MAC header and MAC payload, but not any tail bytes + * added automatically by the radio. For example, in the typical case of + * .15.4 operation at 2.4GHz, this will be 125 bytes (127 bytes minus the + * FCS / CRC16). + * + * This is the maximum number of bytes that: + * - The MAC layer will ask the radio driver to transmit. + * This corresponds to the payload_len argument of the prepare() and + * send() and the transmit_len argument of transmit(). + * - The radio driver will deliver to the MAC layer after frame reception. + * The buf_len of the read function will typically be greater than or + * equal to this value. + * + * Supporting this constant in the radio driver's get_value function is + * mandatory. + */ + RADIO_CONST_MAX_PAYLOAD_LEN, }; /* Radio power modes */ diff --git a/os/dev/serial-line.c b/os/dev/serial-line.c index 80ff5510bcb4cfa3412e94d637f80a389c57fccf..643a845a9e91d881b3b625977d8779ca99447940 100644 --- a/os/dev/serial-line.c +++ b/os/dev/serial-line.c @@ -45,13 +45,12 @@ #error Change SERIAL_LINE_CONF_BUFSIZE in contiki-conf.h. #endif -#ifndef IGNORE_CHAR -#define IGNORE_CHAR(c) (c == 0x0d) -#endif - #ifndef END #define END 0x0a #endif +#ifndef END2 +#define END2 0x0d +#endif static struct ringbuf rxbuf; static uint8_t rxbuf_data[BUFSIZE]; @@ -66,10 +65,6 @@ serial_line_input_byte(unsigned char c) { static uint8_t overflow = 0; /* Buffer overflow: ignore until END */ - if(IGNORE_CHAR(c)) { - return 0; - } - if(!overflow) { /* Add character */ if(ringbuf_put(&rxbuf, c) == 0) { @@ -79,7 +74,7 @@ serial_line_input_byte(unsigned char c) } else { /* Buffer overflowed: * Only (try to) add terminator characters, otherwise skip */ - if(c == END && ringbuf_put(&rxbuf, c) != 0) { + if((c == END || c == END2) && ringbuf_put(&rxbuf, c) != 0) { overflow = 0; } } @@ -107,7 +102,7 @@ PROCESS_THREAD(serial_line_process, ev, data) /* Buffer empty, wait for poll */ PROCESS_YIELD(); } else { - if(c != END) { + if((c != END && c != END2)) { if(ptr < BUFSIZE-1) { buf[ptr++] = (uint8_t)c; } else { diff --git a/os/lib/assert.c b/os/lib/assert.c index 8268f15e1e13a5eed4fa8b80adb3b71ca0311f16..34720b00b100528fcf289979b064946fb63fb994 100644 --- a/os/lib/assert.c +++ b/os/lib/assert.c @@ -27,6 +27,7 @@ * SUCH DAMAGE. * */ +#include "lib/assert.h" #include <stdio.h> @@ -34,8 +35,10 @@ void _xassert(const char *file, int lineno) { printf("Assertion failed: file %s, line %d.\n", file, lineno); - /* - * loop for a while; - * call _reset_vector__(); - */ + +#if !ASSERT_RETURNS + printf("The firmware will stop running\n"); + printf("A watchdog timer may restart this device\n"); + while(1); +#endif } diff --git a/os/lib/assert.h b/os/lib/assert.h index 3689a8b1dcac18451b32fcddfcc55956062f790b..ca6b0a4c5fe50bddb1988640db29f895f991f7a7 100644 --- a/os/lib/assert.h +++ b/os/lib/assert.h @@ -31,13 +31,25 @@ #ifndef ASSERT_H_ #define ASSERT_H_ +#include "sys/cc.h" + +#ifdef ASSERT_CONF_RETURNS +#define ASSERT_RETURNS ASSERT_CONF_RETURNS +#else +#define ASSERT_RETURNS 0 +#endif + #undef assert #ifdef NDEBUG #define assert(e) ((void)0) #else #define assert(e) ((e) ? (void)0 : _xassert(__FILE__, __LINE__)) +#if ASSERT_RETURNS void _xassert(const char *, int); -#endif +#else +void _xassert(const char *, int) CC_NORETURN; +#endif /* ASSERT_RETURNS */ +#endif /* NDEBUG */ #ifndef CTASSERT /* Allow lint to override */ #define CTASSERT(x) _CTASSERT(x, __LINE__) diff --git a/os/lib/heapmem.c b/os/lib/heapmem.c index 7a90f1357bd6a8ae56a70bdbd892eb7fd097ae62..7ec53cebd6b900796db06decdb787e13ea8a00f7 100644 --- a/os/lib/heapmem.c +++ b/os/lib/heapmem.c @@ -58,6 +58,8 @@ #include "heapmem.h" +#include "sys/cc.h" + /* The HEAPMEM_CONF_ARENA_SIZE parameter determines the size of the space that will be statically allocated in this module. */ #ifdef HEAPMEM_CONF_ARENA_SIZE @@ -143,7 +145,7 @@ typedef struct chunk { /* All allocated space is located within an "heap", which is statically allocated with a pre-configured size. */ -static char heap_base[HEAPMEM_ARENA_SIZE]; +static char heap_base[HEAPMEM_ARENA_SIZE] CC_ALIGN(HEAPMEM_ALIGNMENT); static size_t heap_usage; static chunk_t *first_chunk = (chunk_t *)heap_base; diff --git a/os/lib/memb.c b/os/lib/memb.c index b4056dd9faa3fadb205712070adc903b77662d4e..bab88c5a51bed3c9732a99bd12498c55ce0561d2 100644 --- a/os/lib/memb.c +++ b/os/lib/memb.c @@ -51,7 +51,7 @@ void memb_init(struct memb *m) { - memset(m->count, 0, m->num); + memset(m->used, 0, m->num); memset(m->mem, 0, m->size * m->num); } /*---------------------------------------------------------------------------*/ @@ -61,11 +61,10 @@ memb_alloc(struct memb *m) int i; for(i = 0; i < m->num; ++i) { - if(m->count[i] == 0) { - /* If this block was unused, we increase the reference count to - indicate that it now is used and return a pointer to the - memory block. */ - ++(m->count[i]); + if(m->used[i] == false) { + /* If this block was unused, we set the used flag on + and return a pointer to the memory block. */ + m->used[i] = true; return (void *)((char *)m->mem + (i * m->size)); } } @@ -75,7 +74,7 @@ memb_alloc(struct memb *m) return NULL; } /*---------------------------------------------------------------------------*/ -char +int memb_free(struct memb *m, void *ptr) { int i; @@ -85,15 +84,13 @@ memb_free(struct memb *m, void *ptr) which the pointer "ptr" points to. */ ptr2 = (char *)m->mem; for(i = 0; i < m->num; ++i) { - if(ptr2 == (char *)ptr) { - /* We've found to block to which "ptr" points so we decrease the - reference count and return the new value of it. */ - if(m->count[i] > 0) { - /* Make sure that we don't deallocate free memory. */ - --(m->count[i]); - } - return m->count[i]; + /* We've found the block to which "ptr" points, so we check the allocation + status to detect the double-free error and free the block. */ + if (m->used[i] == false) + return -1; + m->used[i] = false; + return 0; } ptr2 += m->size; } @@ -114,7 +111,7 @@ memb_numfree(struct memb *m) int num_free = 0; for(i = 0; i < m->num; ++i) { - if(m->count[i] == 0) { + if(m->used[i] == false) { ++num_free; } } diff --git a/os/lib/memb.h b/os/lib/memb.h index ffc55508556c9ab06a113d696e397054e8e64f7c..8cb59526846fba5687fbfde1aa0c30acab82009c 100644 --- a/os/lib/memb.h +++ b/os/lib/memb.h @@ -63,6 +63,7 @@ #ifndef MEMB_H_ #define MEMB_H_ +#include <stdbool.h> #include "sys/cc.h" /** @@ -87,30 +88,30 @@ MEMB(connections, struct connection, 16); * */ #define MEMB(name, structure, num) \ - static char CC_CONCAT(name,_memb_count)[num]; \ + static bool CC_CONCAT(name,_memb_used)[num]; \ static structure CC_CONCAT(name,_memb_mem)[num]; \ static struct memb name = {sizeof(structure), num, \ - CC_CONCAT(name,_memb_count), \ + CC_CONCAT(name,_memb_used), \ (void *)CC_CONCAT(name,_memb_mem)} struct memb { unsigned short size; unsigned short num; - char *count; + bool *used; void *mem; }; /** * Initialize a memory block that was declared with MEMB(). * - * \param m A memory block previously declared with MEMB(). + * \param m A set of memory blocks previously declared with MEMB(). */ void memb_init(struct memb *m); /** * Allocate a memory block from a block of memory declared with MEMB(). * - * \param m A memory block previously declared with MEMB(). + * \param m A set of memory blocks previously declared with MEMB(). */ void *memb_alloc(struct memb *m); @@ -118,18 +119,34 @@ void *memb_alloc(struct memb *m); * Deallocate a memory block from a memory block previously declared * with MEMB(). * - * \param m m A memory block previously declared with MEMB(). + * \param m m A set of memory blocks previously declared with MEMB(). * * \param ptr A pointer to the memory block that is to be deallocated. * - * \return The new reference count for the memory block (should be 0 - * if successfully deallocated) or -1 if the pointer "ptr" did not - * point to a legal memory block. + * \return error code, should be 0 if successfully deallocated or -1 if the + * pointer "ptr" did not point to a legal memory block. */ -char memb_free(struct memb *m, void *ptr); +int memb_free(struct memb *m, void *ptr); +/** + * Check if a given address is within a memory area previously + * declared with MEMB(). + * + * \param m m A set of memory blocks previously declared with MEMB(). + * + * \param ptr A pointer to the address to check + * + * \return 1 if the address is part of the memory block; otherwise 0 + */ int memb_inmemb(struct memb *m, void *ptr); +/** + * Count free memory blocks + * + * \param m m A set of memory blocks previously declared with MEMB(). + * + * \return the number of free (available) memory blocks + */ int memb_numfree(struct memb *m); /** @} */ diff --git a/os/net/app-layer/coap/coap-blocking-api.c b/os/net/app-layer/coap/coap-blocking-api.c index 9fd691d741bd101222796a27b3b7beaddc7abd10..34948ead5936aceff4e3a76b8e89edadef7e5717 100644 --- a/os/net/app-layer/coap/coap-blocking-api.c +++ b/os/net/app-layer/coap/coap-blocking-api.c @@ -108,6 +108,7 @@ PT_THREAD(coap_blocking_request if(!state->response) { LOG_WARN("Server not responding\n"); state->status = COAP_REQUEST_STATUS_TIMEOUT; + request_callback(NULL); /* Call the callback with NULL to signal timeout */ PT_EXIT(&blocking_state->pt); } diff --git a/os/net/app-layer/coap/coap-conf.h b/os/net/app-layer/coap/coap-conf.h index 5b610dca337035378f4f7e7b0c5c95df10554420..168a0a9e04e43272db3ca44aa8c9e969935f0749 100644 --- a/os/net/app-layer/coap/coap-conf.h +++ b/os/net/app-layer/coap/coap-conf.h @@ -105,5 +105,12 @@ #define COAP_OBSERVE_REFRESH_INTERVAL 20 #endif /* COAP_OBSERVE_REFRESH_INTERVAL */ +/* Maximal length of observable URL */ +#ifdef COAP_CONF_OBSERVER_URL_LEN +#define COAP_OBSERVER_URL_LEN COAP_CONF_OBSERVER_URL_LEN +#else +#define COAP_OBSERVER_URL_LEN 20 +#endif + #endif /* COAP_CONF_H_ */ /** @} */ diff --git a/os/net/app-layer/coap/coap-observe.h b/os/net/app-layer/coap/coap-observe.h index 93898f954dc080d0071d040e56a04e74935dcbcb..28ea954cba96ab2b7cde300e224a12156204a996 100644 --- a/os/net/app-layer/coap/coap-observe.h +++ b/os/net/app-layer/coap/coap-observe.h @@ -48,8 +48,6 @@ #include "coap-transactions.h" #include "coap-engine.h" -#define COAP_OBSERVER_URL_LEN 20 - typedef struct coap_observer { struct coap_observer *next; /* for LIST */ diff --git a/os/net/app-layer/http-socket/Makefile.http-socket b/os/net/app-layer/http-socket/Makefile.http-socket new file mode 100644 index 0000000000000000000000000000000000000000..32b8a213b41301f7754b58a6d9b25566f42f73c8 --- /dev/null +++ b/os/net/app-layer/http-socket/Makefile.http-socket @@ -0,0 +1 @@ +MODULES += os/services/resolv \ No newline at end of file diff --git a/os/net/app-layer/http-socket/http-socket.c b/os/net/app-layer/http-socket/http-socket.c index dfcf9e2a4d04ce5dc07d1a656b2643e7894fd942..b91d13a41af9ea4422477bfcaf52cf896af7480c 100644 --- a/os/net/app-layer/http-socket/http-socket.c +++ b/os/net/app-layer/http-socket/http-socket.c @@ -30,6 +30,7 @@ */ #include "contiki-net.h" #include "ipv6/ip64-addr.h" +#include "resolv.h" #include "http-socket.h" #include <ctype.h> diff --git a/os/net/app-layer/http-socket/module-macros.h b/os/net/app-layer/http-socket/module-macros.h new file mode 100644 index 0000000000000000000000000000000000000000..52a5c878e016a8ecd7ae43d08cbf6631db4adfa1 --- /dev/null +++ b/os/net/app-layer/http-socket/module-macros.h @@ -0,0 +1 @@ +#define BUILD_WITH_HTTP_SOCKET 1 diff --git a/os/net/app-layer/http-socket/websocket-http-client.c b/os/net/app-layer/http-socket/websocket-http-client.c index a6cb4a8bde1c675eeb969eed4bec7bbcb844fe67..441e44e64bb7a0705d5d0220277f51e16673fb6d 100644 --- a/os/net/app-layer/http-socket/websocket-http-client.c +++ b/os/net/app-layer/http-socket/websocket-http-client.c @@ -31,7 +31,7 @@ #include "websocket-http-client.h" #include "net/ipv6/uiplib.h" -#include "net/ipv6/resolv.h" +#include "resolv.h" #include "ipv6/ip64-addr.h" @@ -41,7 +41,7 @@ /* Log configuration */ #include "sys/log.h" #define LOG_MODULE "Websocket" -#define LOG_LEVEL LOG_LEVEL_IPV6 +#define LOG_LEVEL LOG_LEVEL_NONE enum { STATE_WAITING_FOR_HEADER, diff --git a/os/net/app-layer/http-socket/websocket.c b/os/net/app-layer/http-socket/websocket.c index 04c6ba506ced961521672cab71bdaf1d66eb8557..08b836fbf559d778c12c88d1eabf3e0909816530 100644 --- a/os/net/app-layer/http-socket/websocket.c +++ b/os/net/app-layer/http-socket/websocket.c @@ -34,7 +34,7 @@ #include <string.h> #include "contiki-net.h" - +#include "resolv.h" #include "websocket.h" /* Log configuration */ diff --git a/os/net/app-layer/mqtt/mqtt.c b/os/net/app-layer/mqtt/mqtt.c index 47ffc6a7ae315c29485df81cb4adc71ea5a79e30..2dad5ce0c75fa9c42763f6185866cb249b04047c 100644 --- a/os/net/app-layer/mqtt/mqtt.c +++ b/os/net/app-layer/mqtt/mqtt.c @@ -114,9 +114,51 @@ typedef enum { MQTT_VHDR_CONN_REJECTED_UNAVAILABLE, MQTT_VHDR_CONN_REJECTED_BAD_USER_PASS, MQTT_VHDR_CONN_REJECTED_UNAUTHORIZED, -} mqtt_vhdr_connack_fields_t; +} mqtt_vhdr_connack_ret_code_t; + +typedef enum { + MQTT_VHDR_CONNACK_SESSION_PRESENT = 0x1 +} mqtt_vhdr_connack_flags_t; + +/*---------------------------------------------------------------------------*/ +#if MQTT_311 +typedef enum { + MQTT_SUBACK_RET_QOS_0 = 0x00, + MQTT_SUBACK_RET_QOS_1 = 0x01, + MQTT_SUBACK_RET_QOS_2 = 0x02, + MQTT_SUBACK_RET_FAIL = 0x08, +} mqtt_suback_ret_code_t; +#endif /*---------------------------------------------------------------------------*/ -#define MQTT_CONNECT_VHDR_FLAGS_SIZE 12 +#if MQTT_31 +/* Len MSB(0) + * Len LSB(6) + * 'M' + * 'Q' + * 'I' + * 's' + * 'd' + * 'p' + * Protocol Level (3) + * Connect Flags + * Keep Alive MSB + * Keep Alive LSB + */ +#define MQTT_CONNECT_VHDR_SIZE 12 +#else +/* Len MSB(0) + * Len LSB(4) + * 'M' + * 'Q' + * 'T' + * 'T' + * Protocol Level (4) + * Connect Flags + * Keep Alive MSB + * Keep Alive LSB + */ +#define MQTT_CONNECT_VHDR_SIZE 10 +#endif #define MQTT_STRING_LEN_SIZE 2 #define MQTT_MID_SIZE 2 @@ -389,7 +431,7 @@ PT_THREAD(connect_pt(struct pt *pt, struct mqtt_connection *conn)) /* Set up FHDR */ conn->out_packet.fhdr = MQTT_FHDR_MSG_TYPE_CONNECT; conn->out_packet.remaining_length = 0; - conn->out_packet.remaining_length += MQTT_CONNECT_VHDR_FLAGS_SIZE; + conn->out_packet.remaining_length += MQTT_CONNECT_VHDR_SIZE; conn->out_packet.remaining_length += MQTT_STRING_LENGTH(&conn->client_id); conn->out_packet.remaining_length += MQTT_STRING_LENGTH(&conn->credentials.username); conn->out_packet.remaining_length += MQTT_STRING_LENGTH(&conn->credentials.password); @@ -410,8 +452,8 @@ PT_THREAD(connect_pt(struct pt *pt, struct mqtt_connection *conn)) conn->out_packet.remaining_length_enc, conn->out_packet.remaining_length_enc_bytes); PT_MQTT_WRITE_BYTE(conn, 0); - PT_MQTT_WRITE_BYTE(conn, 6); - PT_MQTT_WRITE_BYTES(conn, (uint8_t *)MQTT_PROTOCOL_NAME, 6); + PT_MQTT_WRITE_BYTE(conn, strlen(MQTT_PROTOCOL_NAME)); + PT_MQTT_WRITE_BYTES(conn, (uint8_t *)MQTT_PROTOCOL_NAME, strlen(MQTT_PROTOCOL_NAME)); PT_MQTT_WRITE_BYTE(conn, MQTT_PROTOCOL_VERSION); PT_MQTT_WRITE_BYTE(conn, conn->connect_vhdr_flags); PT_MQTT_WRITE_BYTE(conn, (conn->keep_alive >> 8)); @@ -659,6 +701,11 @@ PT_THREAD(publish_pt(struct pt *pt, struct mqtt_connection *conn)) PT_EXIT(pt); } + /* The DUP flag MUST be set to 0 for all QoS 0 messages */ + if(conn->out_packet.qos == MQTT_QOS_LEVEL_0) { + conn->out_packet.fhdr &= ~MQTT_FHDR_DUP_FLAG; + } + /* Write Fixed Header */ PT_MQTT_WRITE_BYTE(conn, conn->out_packet.fhdr); PT_MQTT_WRITE_BYTES(conn, (uint8_t *)conn->out_packet.remaining_length_enc, @@ -672,6 +719,7 @@ PT_THREAD(publish_pt(struct pt *pt, struct mqtt_connection *conn)) PT_MQTT_WRITE_BYTE(conn, (conn->out_packet.mid >> 8)); PT_MQTT_WRITE_BYTE(conn, (conn->out_packet.mid & 0x00FF)); } + /* Write Payload */ PT_MQTT_WRITE_BYTES(conn, conn->out_packet.payload, @@ -747,6 +795,8 @@ PT_THREAD(pingreq_pt(struct pt *pt, struct mqtt_connection *conn)) static void handle_connack(struct mqtt_connection *conn) { + mqtt_connack_event_t connack_event; + DBG("MQTT - Got CONNACK\n"); if(conn->in_packet.payload[1] != 0) { @@ -761,12 +811,16 @@ handle_connack(struct mqtt_connection *conn) conn->out_packet.qos_state = MQTT_QOS_STATE_GOT_ACK; +#if MQTT_PROTOCOL_VERSION >= MQTT_PROTOCOL_VERSION_3_1_1 + connack_event.session_present = conn->in_packet.payload[0] & MQTT_VHDR_CONNACK_SESSION_PRESENT; +#endif + ctimer_set(&conn->keep_alive_timer, conn->keep_alive * CLOCK_SECOND, keep_alive_callback, conn); /* Always reset packet before callback since it might be used directly */ conn->state = MQTT_CONN_STATE_CONNECTED_TO_BROKER; - call_event(conn, MQTT_EVENT_CONNECTED, NULL); + call_event(conn, MQTT_EVENT_CONNECTED, &connack_event); } /*---------------------------------------------------------------------------*/ static void @@ -778,7 +832,7 @@ handle_pingresp(struct mqtt_connection *conn) static void handle_suback(struct mqtt_connection *conn) { - struct mqtt_suback_event suback_event; + mqtt_suback_event_t suback_event; DBG("MQTT - Got SUBACK\n"); @@ -792,9 +846,33 @@ handle_suback(struct mqtt_connection *conn) suback_event.mid = (conn->in_packet.payload[0] << 8) | (conn->in_packet.payload[1]); - suback_event.qos_level = conn->in_packet.payload[2]; conn->in_packet.mid = suback_event.mid; +#if MQTT_311 + suback_event.success = 0; + + switch(conn->in_packet.payload[2]) { + case MQTT_SUBACK_RET_FAIL: + PRINTF("MQTT - Error, SUBSCRIBE failed with SUBACK return code '%x'", conn->in_packet.payload[2]); + break; + + case MQTT_SUBACK_RET_QOS_0: + case MQTT_SUBACK_RET_QOS_1: + case MQTT_SUBACK_RET_QOS_2: + suback_event.qos_level = conn->in_packet.payload[2] & 0x03; + suback_event.success = 1; + break; + + default: + PRINTF("MQTT - Error, Unrecognised SUBACK return code '%x'", conn->in_packet.payload[2]); + break; + } + + suback_event.return_code = conn->in_packet.payload[2]; +#else + suback_event.qos_level = conn->in_packet.payload[2]; +#endif + if(conn->in_packet.mid != conn->out_packet.mid) { DBG("MQTT - Warning, got SUBACK with none matching MID. Currently there is" "no support for several concurrent SUBSCRIBE messages.\n"); @@ -833,12 +911,20 @@ handle_puback(struct mqtt_connection *conn) call_event(conn, MQTT_EVENT_PUBACK, &conn->in_packet.mid); } /*---------------------------------------------------------------------------*/ -static void +static mqtt_pub_status_t handle_publish(struct mqtt_connection *conn) { DBG("MQTT - Got PUBLISH, called once per manageable chunk of message.\n"); DBG("MQTT - Handling publish on topic '%s'\n", conn->in_publish_msg.topic); +#if MQTT_PROTOCOL_VERSION >= MQTT_PROTOCOL_VERSION_3_1_1 + if(strlen(conn->in_publish_msg.topic) < conn->in_packet.topic_len) { + DBG("NULL detected in received PUBLISH topic\n"); + mqtt_disconnect(conn); + return MQTT_PUBLISH_ERR; + } +#endif + DBG("MQTT - This chunk is %i bytes\n", conn->in_packet.payload_pos); if(((conn->in_packet.fhdr & 0x09) >> 1) > 0) { @@ -860,6 +946,8 @@ handle_publish(struct mqtt_connection *conn) DBG("MQTT - (handle_publish) resetting packet.\n"); reset_packet(&conn->in_packet); } + + return MQTT_PUBLISH_OK; } /*---------------------------------------------------------------------------*/ static void @@ -928,6 +1016,7 @@ tcp_input(struct tcp_socket *s, uint32_t pos = 0; uint32_t copy_bytes = 0; uint8_t byte; + mqtt_pub_status_t pub_status; if(input_data_len == 0) { return 0; @@ -1035,10 +1124,14 @@ tcp_input(struct tcp_socket *s, conn->in_publish_msg.payload_chunk_length = MQTT_INPUT_BUFF_SIZE; conn->in_publish_msg.payload_left -= MQTT_INPUT_BUFF_SIZE; - handle_publish(conn); + pub_status = handle_publish(conn); conn->in_publish_msg.payload_chunk = conn->in_packet.payload; conn->in_packet.payload_pos = 0; + + if(pub_status != MQTT_PUBLISH_OK) { + return 0; + } } if(pos >= input_data_len && @@ -1065,7 +1158,7 @@ tcp_input(struct tcp_socket *s, conn->in_publish_msg.payload_chunk = conn->in_packet.payload; conn->in_publish_msg.payload_chunk_length = conn->in_packet.payload_pos; conn->in_publish_msg.payload_left = 0; - handle_publish(conn); + (void) handle_publish(conn); break; case MQTT_FHDR_MSG_TYPE_PUBACK: handle_puback(conn); @@ -1295,9 +1388,11 @@ mqtt_register(struct mqtt_connection *conn, struct process *app_process, char *client_id, mqtt_event_callback_t event_callback, uint16_t max_segment_size) { +#if MQTT_31 || !MQTT_SRV_SUPPORTS_EMPTY_CLIENT_ID if(strlen(client_id) < 1) { return MQTT_STATUS_INVALID_ARGS_ERROR; } +#endif /* Set defaults - Set all to zero to begin with */ memset(conn, 0, sizeof(struct mqtt_connection)); @@ -1323,7 +1418,7 @@ mqtt_register(struct mqtt_connection *conn, struct process *app_process, */ mqtt_status_t mqtt_connect(struct mqtt_connection *conn, char *host, uint16_t port, - uint16_t keep_alive) + uint16_t keep_alive, uint8_t clean_session) { uip_ip6addr_t ip6addr; uip_ipaddr_t *ipaddr; @@ -1339,7 +1434,11 @@ mqtt_connect(struct mqtt_connection *conn, char *host, uint16_t port, conn->server_port = port; conn->out_buffer_ptr = conn->out_buffer; conn->out_packet.qos_state = MQTT_QOS_STATE_NO_ACK; - conn->connect_vhdr_flags |= MQTT_VHDR_CLEAN_SESSION_FLAG; + + /* If the Client supplies a zero-byte ClientId, the Client MUST also set CleanSession to 1 */ + if(clean_session || (conn->client_id.length == 0)) { + conn->connect_vhdr_flags |= MQTT_VHDR_CLEAN_SESSION_FLAG; + } /* convert the string IPv6 address to a numeric IPv6 address */ if(uiplib_ip6addrconv(host, &ip6addr) == 0) { diff --git a/os/net/app-layer/mqtt/mqtt.h b/os/net/app-layer/mqtt/mqtt.h index 6b7e8a3ed9e465cca8fdd6cc5945ec4b717e8cc0..836f3a4d5e9bea1fd2eb6fb0bce14fed80e0958d 100644 --- a/os/net/app-layer/mqtt/mqtt.h +++ b/os/net/app-layer/mqtt/mqtt.h @@ -101,6 +101,24 @@ #include <string.h> /*---------------------------------------------------------------------------*/ /* Protocol constants */ +#define MQTT_PROTOCOL_VERSION_3_1 3 +#define MQTT_PROTOCOL_VERSION_3_1_1 4 +#define MQTT_PROTOCOL_VERSION_5 5 + +#ifdef MQTT_CONF_VERSION +#define MQTT_PROTOCOL_VERSION MQTT_CONF_VERSION +#else +#define MQTT_PROTOCOL_VERSION MQTT_PROTOCOL_VERSION_3_1 +#endif + +#if MQTT_PROTOCOL_VERSION == MQTT_PROTOCOL_VERSION_5 +#define MQTT_5 1 +#elif MQTT_PROTOCOL_VERSION == MQTT_PROTOCOL_VERSION_3_1_1 +#define MQTT_311 1 +#elif MQTT_PROTOCOL_VERSION == MQTT_PROTOCOL_VERSION_3_1 +#define MQTT_31 1 +#endif + #define MQTT_CLIENT_ID_MAX_LEN 23 /* Size of the underlying TCP buffers */ @@ -113,9 +131,23 @@ #define MQTT_FHDR_SIZE 1 #define MQTT_MAX_REMAINING_LENGTH_BYTES 4 -#define MQTT_PROTOCOL_VERSION 3 +#if MQTT_31 #define MQTT_PROTOCOL_NAME "MQIsdp" +#else +#define MQTT_PROTOCOL_NAME "MQTT" +#endif + #define MQTT_TOPIC_MAX_LENGTH 128 + +#if MQTT_PROTOCOL_VERSION >= MQTT_PROTOCOL_VERSION_3_1_1 +#ifdef MQTT_CONF_SUPPORTS_EMPTY_CLIENT_ID +#define MQTT_SRV_SUPPORTS_EMPTY_CLIENT_ID MQTT_CONF_SUPPORTS_EMPTY_CLIENT_ID +#else +#define MQTT_SRV_SUPPORTS_EMPTY_CLIENT_ID 0 +#endif /* MQTT_CONF_SUPPORTS_EMPTY_CLIENT_ID */ +#else +#define MQTT_SRV_SUPPORTS_EMPTY_CLIENT_ID 0 +#endif /*---------------------------------------------------------------------------*/ /* * Debug configuration, this is similar but not exactly like the Debugging @@ -139,6 +171,11 @@ typedef enum { MQTT_RETAIN_ON, } mqtt_retain_t; +typedef enum { + MQTT_CLEAN_SESSION_OFF, + MQTT_CLEAN_SESSION_ON, +} mqtt_clean_session_t; + /** * \brief MQTT engine events */ @@ -184,6 +221,11 @@ typedef enum { /* Expand for QoS 2 */ } mqtt_qos_state_t; + +typedef enum { + MQTT_PUBLISH_OK, + MQTT_PUBLISH_ERR, +} mqtt_pub_status_t; /*---------------------------------------------------------------------------*/ /* * This is the state of the connection itself. @@ -217,10 +259,18 @@ struct mqtt_string { * * This could be part of a union of event data structures. */ -struct mqtt_suback_event { +typedef struct { uint16_t mid; mqtt_qos_level_t qos_level; -}; +#if MQTT_311 + uint8_t return_code; + uint8_t success; +#endif +} mqtt_suback_event_t; + +typedef struct { + uint8_t session_present; +} mqtt_connack_event_t; /* This is the MQTT message that is exposed to the end user. */ struct mqtt_message { @@ -389,6 +439,8 @@ mqtt_status_t mqtt_register(struct mqtt_connection *conn, * \param keep_alive Keep alive timer in seconds. Used by broker to handle * client disc. Defines the maximum time interval between two messages * from the client. Shall be min 1.5 x report interval. + * \param clean_session Request a new session and discard pending messages with + * QoS > 0, as well as client subscriptions * \return MQTT_STATUS_OK or an error status * * This function connects to a MQTT broker. @@ -396,7 +448,8 @@ mqtt_status_t mqtt_register(struct mqtt_connection *conn, mqtt_status_t mqtt_connect(struct mqtt_connection *conn, char *host, uint16_t port, - uint16_t keep_alive); + uint16_t keep_alive, + uint8_t clean_session); /*---------------------------------------------------------------------------*/ /** * \brief Disconnects from a MQTT broker. diff --git a/os/net/app-layer/snmp/module-macros.h b/os/net/app-layer/snmp/module-macros.h new file mode 100644 index 0000000000000000000000000000000000000000..8396775a76e63231d9991910d14ca3d863a3e694 --- /dev/null +++ b/os/net/app-layer/snmp/module-macros.h @@ -0,0 +1 @@ +#define BUILD_WITH_SNMP 1 diff --git a/os/net/app-layer/snmp/snmp-api.c b/os/net/app-layer/snmp/snmp-api.c new file mode 100644 index 0000000000000000000000000000000000000000..50d252df01812b66c38993c74f620efa9e9d5ef2 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-api.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +#include "contiki.h" + +#include "snmp-api.h" + +#include "snmp-message.h" +#include "snmp-ber.h" +#include "snmp-oid.h" + +static void +snmp_api_replace_oid(snmp_varbind_t *varbind, uint32_t *oid) +{ + uint8_t i; + + i = 0; + while(oid[i] != ((uint32_t)-1)) { + varbind->oid[i] = oid[i]; + i++; + } + varbind->oid[i] = ((uint32_t)-1); +} +/*---------------------------------------------------------------------------*/ +void +snmp_api_set_string(snmp_varbind_t *varbind, uint32_t *oid, char *string) +{ + + snmp_api_replace_oid(varbind, oid); + varbind->value_type = BER_DATA_TYPE_OCTET_STRING; + varbind->value.string.string = string; + varbind->value.string.length = strlen(string); +} +/*---------------------------------------------------------------------------*/ +void +snmp_api_set_time_ticks(snmp_varbind_t *varbind, uint32_t *oid, uint32_t integer) +{ + + snmp_api_replace_oid(varbind, oid); + varbind->value_type = SNMP_DATA_TYPE_TIME_TICKS; + varbind->value.integer = integer; +} +/*---------------------------------------------------------------------------*/ +void +snmp_api_set_oid(snmp_varbind_t *varbind, uint32_t *oid, uint32_t *ret_oid) +{ + + snmp_api_replace_oid(varbind, oid); + varbind->value_type = BER_DATA_TYPE_OID; + varbind->value.oid = ret_oid; +} +/*---------------------------------------------------------------------------*/ +void +snmp_api_add_resource(snmp_mib_resource_t *new_resource) +{ + return snmp_mib_add(new_resource); +} diff --git a/os/net/app-layer/snmp/snmp-api.h b/os/net/app-layer/snmp/snmp-api.h new file mode 100644 index 0000000000000000000000000000000000000000..a82704f946fdaafddf8b7ce4d42de446709c3499 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-api.h @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * The public API for the Contiki-NG SNMP implementation + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup snmp + * @{ + */ + +#ifndef SNMP_API_H_ +#define SNMP_API_H_ + +#include "snmp.h" +#include "snmp-mib.h" + +/** + * \defgroup SNMPAPI This is the SNMP Public API + * @{ + * + * This group contains all the functions that can be used outside the OS level. + * The function outside this header can be changed without notice + */ + +/** + * @brief The MIB resource handler typedef + * + * @param varbind The varbind that is being changed + * @param oid The oid from the resource + */ +typedef void (*snmp_mib_resource_handler_t)(snmp_varbind_t *varbind, uint32_t *oid); + +/** + * @brief The MIB Resource struct + */ +typedef struct snmp_mib_resource_s snmp_mib_resource_t; + +/** + * @brief Initializes statically an oid with the "null" terminator + * + * @remarks This should be used inside handlers when declaring an oid + * + * @param name A name for the oid + * @param ... The Oid (comma-separeted) + */ +#define OID(name, ...) \ + static uint32_t name[] = { __VA_ARGS__, -1 }; + +/** + * @brief Declare a MIB resource + * + * @param name A name for the MIB resource + * @param handler The handler function for this resource + * @param ... The OID (comma-separated) + */ +#define MIB_RESOURCE(name, handler, ...) \ + uint32_t name##_oid[] = { __VA_ARGS__, -1 }; \ + snmp_mib_resource_t name = { NULL, name##_oid, handler }; + +/** + * @brief Function to set a varbind with a string + * + * This function should be used inside a handler to set the varbind correctly + * + * @param varbind The varbind from the handler + * @param oid The oid from the handler + * @param string The string + */ +void +snmp_api_set_string(snmp_varbind_t *varbind, uint32_t *oid, char *string); + +/** + * @brief Function to set a varbind with a time tick + * + * This function should be used inside a handler to set the varbind correctly + * + * @param varbind The varbind from the handler + * @param oid The oid from the handler + * @param integer The time tick value + */ +void +snmp_api_set_time_ticks(snmp_varbind_t *varbind, uint32_t *oid, uint32_t integer); + +/** + * @brief Function to set a varbind with a oid + * + * This function should be used inside a handler to set the varbind correctly + * + * @param varbind The varbind from the handler + * @param oid The oid from the handler + * @param ret_oid The oid value + */ +void +snmp_api_set_oid(snmp_varbind_t *varbind, uint32_t *oid, uint32_t *ret_oid); + +/** + * @brief Function to add a new resource + * + * @param new_resource The resource + */ +void +snmp_api_add_resource(snmp_mib_resource_t *new_resource); + +/** @}*/ + +#endif /* SNMP_API_H_ */ +/** @} */ diff --git a/os/net/app-layer/snmp/snmp-ber.c b/os/net/app-layer/snmp/snmp-ber.c new file mode 100644 index 0000000000000000000000000000000000000000..f5c520d0cf34affae3abb98e0e08ac5cf0091c8a --- /dev/null +++ b/os/net/app-layer/snmp/snmp-ber.c @@ -0,0 +1,274 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +#include "contiki.h" + +#include "snmp.h" +#include "snmp-ber.h" + +#define LOG_MODULE "SNMP [ber]" +#define LOG_LEVEL LOG_LEVEL_SNMP + +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_encode_type(unsigned char *out, uint32_t *out_len, uint8_t type) +{ + *out-- = type; + (*out_len)++; + return out; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_encode_length(unsigned char *out, uint32_t *out_len, uint8_t length) +{ + *out-- = length; + (*out_len)++; + return out; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_encode_integer(unsigned char *out, uint32_t *out_len, uint32_t number) +{ + uint32_t original_out_len; + + original_out_len = *out_len; + do { + (*out_len)++; + *out-- = (uint8_t)(number & 0xFF); + number >>= 8; + } while(number); + + out = snmp_ber_encode_length(out, out_len, ((*out_len - original_out_len) & 0xFF)); + out = snmp_ber_encode_type(out, out_len, BER_DATA_TYPE_INTEGER); + + return out; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_encode_unsigned_integer(unsigned char *out, uint32_t *out_len, uint8_t type, uint32_t number) +{ + uint32_t original_out_len; + + original_out_len = *out_len; + do { + (*out_len)++; + *out-- = (uint8_t)(number & 0xFF); + number >>= 8; + } while(number); + + out = snmp_ber_encode_length(out, out_len, ((*out_len - original_out_len) & 0xFF)); + out = snmp_ber_encode_type(out, out_len, type); + + return out; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_encode_string_len(unsigned char *out, uint32_t *out_len, const char *str, uint32_t length) +{ + uint32_t i; + + str += length - 1; + for(i = 0; i < length; ++i) { + (*out_len)++; + *out-- = (uint8_t)*str--; + } + + out = snmp_ber_encode_length(out, out_len, length); + out = snmp_ber_encode_type(out, out_len, BER_DATA_TYPE_OCTET_STRING); + + return out; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_encode_null(unsigned char *out, uint32_t *out_len, uint8_t type) +{ + (*out_len)++; + *out-- = 0x00; + out = snmp_ber_encode_type(out, out_len, type); + + return out; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_decode_type(unsigned char *buff, uint32_t *buff_len, uint8_t *type) +{ + *type = *buff++; + (*buff_len)--; + + return buff; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_decode_length(unsigned char *buff, uint32_t *buff_len, uint8_t *length) +{ + *length = *buff++; + (*buff_len)--; + + return buff; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_decode_integer(unsigned char *buf, uint32_t *buff_len, uint32_t *num) +{ + uint8_t i, len, type; + + buf = snmp_ber_decode_type(buf, buff_len, &type); + + if(type != BER_DATA_TYPE_INTEGER) { + /* + * Sanity check + * Invalid type in buffer + */ + return NULL; + } + + buf = snmp_ber_decode_length(buf, buff_len, &len); + + if(len > 4) { + /* + * Sanity check + * It will not fit in the uint32_t + */ + return NULL; + } + + *num = (uint32_t)(*buf++ & 0xFF); + (*buff_len)--; + for(i = 1; i < len; ++i) { + *num <<= 8; + *num |= (uint8_t)(*buf++ & 0xFF); + (*buff_len)--; + } + + return buf; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_decode_unsigned_integer(unsigned char *buf, uint32_t *buff_len, uint8_t expected_type, uint32_t *num) +{ + uint8_t i, len, type; + + buf = snmp_ber_decode_type(buf, buff_len, &type); + + if(type != expected_type) { + /* + * Sanity check + * Invalid type in buffer + */ + return NULL; + } + + buf = snmp_ber_decode_length(buf, buff_len, &len); + + if(len > 4) { + /* + * Sanity check + * It will not fit in the uint32_t + */ + return NULL; + } + + *num = (uint32_t)(*buf++ & 0xFF); + (*buff_len)--; + for(i = 1; i < len; ++i) { + *num <<= 8; + *num |= (uint8_t)(*buf++ & 0xFF); + (*buff_len)--; + } + + return buf; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_decode_string_len_buffer(unsigned char *buf, uint32_t *buff_len, const char **str, uint32_t *length) +{ + uint8_t type, i, length_bytes; + + buf = snmp_ber_decode_type(buf, buff_len, &type); + + if(type != BER_DATA_TYPE_OCTET_STRING) { + /* + * Sanity check + * Invalid type in buffer + */ + return NULL; + } + + if((*buf & 0x80) == 0) { + *length = (uint32_t)*buf++; + (*buff_len)--; + } else { + + length_bytes = (uint8_t)(*buf++ & 0x7F); + (*buff_len)--; + if(length_bytes > 4) { + /* + * Sanity check + * It will not fit in the uint32_t + */ + return NULL; + } + + *length = (uint32_t)*buf++; + (*buff_len)--; + for(i = 1; i < length_bytes; ++i) { + *length <<= 8; + *length |= *buf++; + (*buff_len)--; + } + } + + *str = (const char *)buf; + *buff_len -= *length; + + return buf + *length; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_ber_decode_null(unsigned char *buf, uint32_t *buff_len) +{ + buf++; + (*buff_len)--; + + buf++; + (*buff_len)--; + + return buf; +} +/*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/snmp/snmp-ber.h b/os/net/app-layer/snmp/snmp-ber.h new file mode 100644 index 0000000000000000000000000000000000000000..9111276dec6343de912db802dee1ec57187ef387 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-ber.h @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup snmp + * @{ + */ + +#ifndef SNMP_BER_H_ +#define SNMP_BER_H_ + +#define BER_DATA_TYPE_INTEGER 0x02 +#define BER_DATA_TYPE_OCTET_STRING 0x04 +#define BER_DATA_TYPE_NULL 0x05 +#define BER_DATA_TYPE_OID 0x06 +#define BER_DATA_TYPE_SEQUENCE 0x30 + +/** + * @brief Encodes a type + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param type A type + * + * @return NULL if error or the next entry in the buffer + */ +unsigned char * +snmp_ber_encode_type(unsigned char *out, uint32_t *out_len, uint8_t type); + +/** + * @brief Encodes the length + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param length A length + * + * @return NULL if error or the next entry in the buffer + */ +unsigned char * +snmp_ber_encode_length(unsigned char *out, uint32_t *out_len, uint8_t length); + +/** + * @brief Encodes an integer + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param integer A integer + * + * @return NULL if error or the next entry in the buffer + */ +unsigned char * +snmp_ber_encode_integer(unsigned char *out, uint32_t *out_len, uint32_t integer); + +/** + * @brief Encodes an unsigned integer + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param type A type that represents an unsigned integer + * @param number A number + * + * @return NULL if error or the next entry in the buffer + */ +unsigned char * +snmp_ber_encode_unsigned_integer(unsigned char *out, uint32_t *out_len, uint8_t type, uint32_t number); + +/** + * @brief Encodes a string + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param str A string + * @param length The string length + * + * @return NULL if error or the next entry in the buffer + */ +unsigned char * +snmp_ber_encode_string_len(unsigned char *out, uint32_t *out_len, const char *str, uint32_t length); + +/** + * @brief Encodes a null + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param type A type + * + * @return NULL if error or the next entry in the buffer + */ +unsigned char * +snmp_ber_encode_null(unsigned char *out, uint32_t *out_len, uint8_t type); + +/** + * @brief Decodes a type + * + * @param buff A pointer to the beginning of the buffer + * @param buff_len A pointer to the buffer length + * @param type A pointer to the type + * + * @return NULL if error or the first entry after the oid in the buffer + */ +unsigned char * +snmp_ber_decode_type(unsigned char *buff, uint32_t *buff_len, uint8_t *type); + +/** + * @brief Decodes a length + * + * @param buff A pointer to the beginning of the buffer + * @param buff_len A pointer to the buffer length + * @param length A pointer to the length + * + * @return NULL if error or the first entry after the oid in the buffer + */ +unsigned char * +snmp_ber_decode_length(unsigned char *buff, uint32_t *buff_len, uint8_t *length); + +/** + * @brief Decodes an integer + * + * @param buff A pointer to the beginning of the buffer + * @param buff_len A pointer to the buffer length + * @param integer A pointer to the integer + * + * @return NULL if error or the first entry after the oid in the buffer + */ +unsigned char * +snmp_ber_decode_integer(unsigned char *buff, uint32_t *buff_len, uint32_t *integer); + +/** + * @brief Decodes an unsigned number + * + * @param buff A pointer to the beginning of the buffer + * @param buff_len A pointer to the buffer length + * @param expected_type The expected type that represents an unsingned integer + * @param number A pointer to the number + * + * @return NULL if error or the first entry after the oid in the buffer + */ +unsigned char * +snmp_ber_decode_unsigned_integer(unsigned char *buff, uint32_t *buff_len, uint8_t expected_type, uint32_t *number); + +/** + * @brief Decodes a string + * + * @param buff A pointer to the beginning of the buffer + * @param buff_len A pointer to the buffer length + * @param str A pointer to the string + * @param length A pointer to the string length + * + * @return NULL if error or the first entry after the oid in the buffer + */ +unsigned char * +snmp_ber_decode_string_len_buffer(unsigned char *buff, uint32_t *buff_len, const char **str, uint32_t *length); + +/** + * @brief Decodes a null + * + * @param buff A pointer to the beginning of the buffer + * @param buff_len A pointer to the buffer length + * + * @return NULL if error or the first entry after the oid in the buffer + */ +unsigned char * +snmp_ber_decode_null(unsigned char *buff, uint32_t *buff_len); + +#endif /* SNMP_BER_H_ */ +/** @} */ diff --git a/os/net/app-layer/snmp/snmp-conf.h b/os/net/app-layer/snmp/snmp-conf.h new file mode 100644 index 0000000000000000000000000000000000000000..c8a11ddadfb70115b3a60620904f35c2712aef96 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-conf.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * SNMP Configurable Macros + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup snmp + * @{ + */ + +#ifndef SNMP_CONF_H_ +#define SNMP_CONF_H_ + +/** + * \defgroup SNMPConfs SNMP Configurable Defines + * @{ + */ + +#ifdef SNMP_CONF_COMMUNITY +/** + * \brief Configurable SNMP Community + */ +#define SNMP_COMMUNITY SNMP_CONF_COMMUNITY +#else +/** + * \brief Default SNMP Community + */ +#define SNMP_COMMUNITY "public" +#endif + +#ifdef SNMP_CONF_MSG_OID_MAX_LEN +/** + * \brief Configurable maximum number of IDs in one OID + */ +#define SNMP_MSG_OID_MAX_LEN SNMP_CONF_MSG_OID_MAX_LEN +#else +/** + * \brief Default maximum number of IDs in one OID + */ +#define SNMP_MSG_OID_MAX_LEN 16 +#endif + +#ifdef SNMP_CONF_MAX_NR_VALUES +/** + * \brief Configurable maximum number of OIDs in one response + */ +#define SNMP_MAX_NR_VALUES SNMP_CONF_MAX_NR_VALUES +#else +/** + * \brief Default maximum number of OIDs in one response + */ +#define SNMP_MAX_NR_VALUES 2 +#endif + +#ifdef SNMP_CONF_MAX_PACKET_SIZE +/** + * \brief Configurable maximum size of the packet in bytes + */ +#define SNMP_MAX_PACKET_SIZE SNMP_CONF_MAX_PACKET_SIZE +#else +/** + * \brief Default maximum size of the packet in bytes + */ +#define SNMP_MAX_PACKET_SIZE 512 +#endif + +#ifdef SNMP_CONF_PORT +/** + * \brief Configurable SNMP port + */ +#define SNMP_PORT SNMP_CONF_PORT +#else +/** + * \brief Default SNMP port + */ +#define SNMP_PORT 161 +#endif + +/*@}*/ + +#endif /* SNMP_CONF_H_ */ +/** @} */ diff --git a/os/net/app-layer/snmp/snmp-engine.c b/os/net/app-layer/snmp/snmp-engine.c new file mode 100644 index 0000000000000000000000000000000000000000..22694046654ab791a67b72a76c05f29bd7290ec7 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-engine.c @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +#include "contiki.h" + +#include "snmp-engine.h" +#include "snmp-message.h" +#include "snmp-mib.h" +#include "snmp-oid.h" + +#define LOG_MODULE "SNMP [engine]" +#define LOG_LEVEL LOG_LEVEL_SNMP + +/*---------------------------------------------------------------------------*/ +int +snmp_engine_get(snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t varbinds_length) +{ + snmp_mib_resource_t *resource; + uint32_t i; + + for(i = 0; i < varbinds_length; i++) { + resource = snmp_mib_find(varbinds[i].oid); + if(!resource) { + switch(header->version) { + case SNMP_VERSION_1: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + /* + * Varbinds are 1 indexed + */ + header->error_index_max_repetitions.error_index = i + 1; + break; + case SNMP_VERSION_2C: + (&varbinds[i])->value_type = SNMP_DATA_TYPE_NO_SUCH_INSTANCE; + break; + default: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + header->error_index_max_repetitions.error_index = 0; + } + } else { + resource->handler(&varbinds[i], resource->oid); + } + } + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +snmp_engine_get_next(snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t varbinds_length) +{ + snmp_mib_resource_t *resource; + uint32_t i; + + for(i = 0; i < varbinds_length; i++) { + resource = snmp_mib_find_next(varbinds[i].oid); + if(!resource) { + switch(header->version) { + case SNMP_VERSION_1: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + /* + * Varbinds are 1 indexed + */ + header->error_index_max_repetitions.error_index = i + 1; + break; + case SNMP_VERSION_2C: + (&varbinds[i])->value_type = SNMP_DATA_TYPE_END_OF_MIB_VIEW; + break; + default: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + header->error_index_max_repetitions.error_index = 0; + } + } else { + resource->handler(&varbinds[i], resource->oid); + } + } + + return 0; +} +/*---------------------------------------------------------------------------*/ +int +snmp_engine_get_bulk(snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t *varbinds_length) +{ + snmp_mib_resource_t *resource; + uint32_t i, j, original_varbinds_length; + uint32_t oid[SNMP_MAX_NR_VALUES][SNMP_MSG_OID_MAX_LEN]; + uint8_t repeater; + + /* + * A local copy of the requested oids must be kept since + * the varbinds are modified on the fly + */ + original_varbinds_length = *varbinds_length; + for(i = 0; i < original_varbinds_length; i++) { + snmp_oid_copy(oid[i], varbinds[i].oid); + } + + *varbinds_length = 0; + for(i = 0; i < original_varbinds_length; i++) { + if(i >= header->error_status_non_repeaters.non_repeaters) { + break; + } + + resource = snmp_mib_find_next(oid[i]); + if(!resource) { + switch(header->version) { + case SNMP_VERSION_1: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + /* + * Varbinds are 1 indexed + */ + header->error_index_max_repetitions.error_index = i + 1; + break; + case SNMP_VERSION_2C: + (&varbinds[i])->value_type = SNMP_DATA_TYPE_END_OF_MIB_VIEW; + break; + default: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + header->error_index_max_repetitions.error_index = 0; + } + } else { + if(*varbinds_length < SNMP_MAX_NR_VALUES) { + resource->handler(&varbinds[*varbinds_length], resource->oid); + (*varbinds_length)++; + } + } + } + + for(i = 0; i < header->error_index_max_repetitions.max_repetitions; i++) { + repeater = 0; + for(j = header->error_status_non_repeaters.non_repeaters; j < original_varbinds_length; j++) { + resource = snmp_mib_find_next(oid[j]); + if(!resource) { + switch(header->version) { + case SNMP_VERSION_1: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + /* + * Varbinds are 1 indexed + */ + header->error_index_max_repetitions.error_index = *varbinds_length + 1; + break; + case SNMP_VERSION_2C: + if(*varbinds_length < SNMP_MAX_NR_VALUES) { + (&varbinds[*varbinds_length])->value_type = SNMP_DATA_TYPE_END_OF_MIB_VIEW; + snmp_oid_copy((&varbinds[*varbinds_length])->oid, oid[j]); + (*varbinds_length)++; + } + break; + default: + header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME; + header->error_index_max_repetitions.error_index = 0; + } + } else { + if(*varbinds_length < SNMP_MAX_NR_VALUES) { + resource->handler(&varbinds[*varbinds_length], resource->oid); + (*varbinds_length)++; + snmp_oid_copy(oid[j], resource->oid); + repeater++; + } + } + } + if(repeater == 0) { + break; + } + } + + return 0; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_engine(unsigned char *buff, uint32_t buff_len, unsigned char *out, uint32_t *out_len) +{ + static snmp_header_t header; + static snmp_varbind_t varbinds[SNMP_MAX_NR_VALUES]; + static uint32_t varbind_length; + + buff = snmp_message_decode(buff, buff_len, &header, varbinds, &varbind_length); + if(buff == NULL) { + return NULL; + } + + if(header.version != SNMP_VERSION_1) { + if(strncmp(header.community.community, SNMP_COMMUNITY, header.community.length)) { + LOG_ERR("Request with invalid community\n"); + return NULL; + } + } + + /* + * Now handle the SNMP requests depending on their type + */ + switch(header.pdu_type) { + case SNMP_DATA_TYPE_PDU_GET_REQUEST: + if(snmp_engine_get(&header, varbinds, varbind_length) == -1) { + return NULL; + } + break; + + case SNMP_DATA_TYPE_PDU_GET_NEXT_REQUEST: + if(snmp_engine_get_next(&header, varbinds, varbind_length) == -1) { + return NULL; + } + break; + + case SNMP_DATA_TYPE_PDU_GET_BULK: + if(snmp_engine_get_bulk(&header, varbinds, &varbind_length) == -1) { + return NULL; + } + break; + + default: + LOG_ERR("Invalid request type"); + return NULL; + } + + header.pdu_type = SNMP_DATA_TYPE_PDU_GET_RESPONSE; + out = snmp_message_encode(out, out_len, &header, varbinds, varbind_length); + + return ++out; +} diff --git a/os/net/app-layer/snmp/snmp-engine.h b/os/net/app-layer/snmp/snmp-engine.h new file mode 100644 index 0000000000000000000000000000000000000000..d6bc7978e138f186dde79009fa2edfbcef717178 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-engine.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup snmp + * @{ + */ + +#ifndef SNMP_ENGINE_H_ +#define SNMP_ENGINE_H_ + +#include "snmp.h" + +/** + * @brief Process the SNMP packet and prepares the response + * + * @param buff A pointer to the beginning of the packet buffer + * @param buff_len The packet length + * @param out A pointer to the end of the response buffer + * @param out_len A pointer to the length of the response buffer + * + * @return NULL in case of fail or the first element in the response buffer + */ +unsigned char * +snmp_engine(unsigned char *buff, uint32_t buff_len, unsigned char *out, uint32_t *out_len); + +#endif /* SNMP_ENGINE_H_ */ + +/** @} */ diff --git a/os/net/app-layer/snmp/snmp-message.c b/os/net/app-layer/snmp/snmp-message.c new file mode 100644 index 0000000000000000000000000000000000000000..dd32743c1733d4a3d6caee372eae6d1e64e2e7ce --- /dev/null +++ b/os/net/app-layer/snmp/snmp-message.c @@ -0,0 +1,280 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +#include "contiki.h" + +#include "snmp-message.h" +#include "snmp-ber.h" +#include "snmp-oid.h" + +#define LOG_MODULE "SNMP [message]" +#define LOG_LEVEL LOG_LEVEL_SNMP + +unsigned char * +snmp_message_encode(unsigned char *out, uint32_t *out_len, snmp_header_t *header, + snmp_varbind_t *varbinds, uint32_t varbind_num) +{ + snmp_varbind_t *varbind; + uint32_t original_out_len, last_out_len; + int8_t i; + + original_out_len = *out_len; + for(i = varbind_num - 1; i >= 0; i--) { + varbind = &varbinds[i]; + + last_out_len = *out_len; + + switch(varbind->value_type) { + case BER_DATA_TYPE_INTEGER: + out = snmp_ber_encode_integer(out, out_len, varbind->value.integer); + break; + case SNMP_DATA_TYPE_TIME_TICKS: + out = snmp_ber_encode_unsigned_integer(out, out_len, varbind->value_type, varbind->value.integer); + break; + case BER_DATA_TYPE_OCTET_STRING: + out = snmp_ber_encode_string_len(out, out_len, varbind->value.string.string, varbind->value.string.length); + break; + case BER_DATA_TYPE_OID: + out = snmp_oid_encode_oid(out, out_len, varbind->value.oid); + break; + case BER_DATA_TYPE_NULL: + case SNMP_DATA_TYPE_NO_SUCH_INSTANCE: + case SNMP_DATA_TYPE_END_OF_MIB_VIEW: + out = snmp_ber_encode_null(out, out_len, varbind->value_type); + break; + default: + return NULL; + } + + out = snmp_oid_encode_oid(out, out_len, varbind->oid); + out = snmp_ber_encode_length(out, out_len, ((*out_len - last_out_len) & 0xFF)); + out = snmp_ber_encode_type(out, out_len, BER_DATA_TYPE_SEQUENCE); + } + + out = snmp_ber_encode_length(out, out_len, ((*out_len - original_out_len) & 0xFF)); + out = snmp_ber_encode_type(out, out_len, BER_DATA_TYPE_SEQUENCE); + + if(header->pdu_type == SNMP_DATA_TYPE_PDU_GET_BULK) { + out = snmp_ber_encode_integer(out, out_len, header->error_index_max_repetitions.max_repetitions); + out = snmp_ber_encode_integer(out, out_len, header->error_status_non_repeaters.non_repeaters); + } else { + out = snmp_ber_encode_integer(out, out_len, header->error_index_max_repetitions.error_index); + out = snmp_ber_encode_integer(out, out_len, header->error_status_non_repeaters.error_status); + } + out = snmp_ber_encode_integer(out, out_len, header->request_id); + + out = snmp_ber_encode_length(out, out_len, ((*out_len - original_out_len) & 0xFF)); + out = snmp_ber_encode_type(out, out_len, header->pdu_type); + + out = snmp_ber_encode_string_len(out, out_len, header->community.community, header->community.length); + out = snmp_ber_encode_integer(out, out_len, header->version); + + out = snmp_ber_encode_length(out, out_len, ((*out_len - original_out_len) & 0xFF)); + out = snmp_ber_encode_type(out, out_len, BER_DATA_TYPE_SEQUENCE); + + return out; +} +uint8_t * +snmp_message_decode(uint8_t *buf, uint32_t buf_len, snmp_header_t *header, + snmp_varbind_t *varbinds, uint32_t *varbind_num) +{ + uint8_t type, len; + uint32_t i, oid_len; + + buf = snmp_ber_decode_type(buf, &buf_len, &type); + if(buf == NULL) { + LOG_DBG("Could not decode type\n"); + return NULL; + } + + if(type != BER_DATA_TYPE_SEQUENCE) { + LOG_DBG("Invalid type\n"); + return NULL; + } + + buf = snmp_ber_decode_length(buf, &buf_len, &len); + if(buf == NULL) { + LOG_DBG("Could not decode length\n"); + return NULL; + } + + buf = snmp_ber_decode_integer(buf, &buf_len, &header->version); + if(buf == NULL) { + LOG_DBG("Could not decode version\n"); + return NULL; + } + + buf = snmp_ber_decode_string_len_buffer(buf, &buf_len, &header->community.community, &header->community.length); + if(buf == NULL) { + LOG_DBG("Could not decode community\n"); + return NULL; + } + + if(header->version != SNMP_VERSION_1 && + header->version != SNMP_VERSION_2C) { + LOG_DBG("Invalid version\n"); + return NULL; + } + + buf = snmp_ber_decode_type(buf, &buf_len, &type); + if(buf == NULL) { + LOG_DBG("Could not decode type\n"); + return NULL; + } + + header->pdu_type = type; + if(header->pdu_type != SNMP_DATA_TYPE_PDU_GET_REQUEST && + header->pdu_type != SNMP_DATA_TYPE_PDU_GET_NEXT_REQUEST && + header->pdu_type != SNMP_DATA_TYPE_PDU_GET_RESPONSE && + header->pdu_type != SNMP_DATA_TYPE_PDU_SET_REQUEST && + header->pdu_type != SNMP_DATA_TYPE_PDU_GET_BULK) { + LOG_DBG("Invalid pdu type\n"); + return NULL; + } + + buf = snmp_ber_decode_length(buf, &buf_len, &len); + if(buf == NULL) { + LOG_DBG("Could not decode length\n"); + return NULL; + } + + buf = snmp_ber_decode_integer(buf, &buf_len, &header->request_id); + if(buf == NULL) { + LOG_DBG("Could not decode request id\n"); + return NULL; + } + + if(header->pdu_type == SNMP_DATA_TYPE_PDU_GET_BULK) { + buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_status_non_repeaters.non_repeaters); + if(buf == NULL) { + LOG_DBG("Could not decode error status\n"); + return NULL; + } + + buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_index_max_repetitions.max_repetitions); + if(buf == NULL) { + LOG_DBG("Could not decode error index\n"); + return NULL; + } + } else { + buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_status_non_repeaters.error_status); + if(buf == NULL) { + LOG_DBG("Could not decode error status\n"); + return NULL; + } + + buf = snmp_ber_decode_integer(buf, &buf_len, &header->error_index_max_repetitions.error_index); + if(buf == NULL) { + LOG_DBG("Could not decode error index\n"); + return NULL; + } + } + + buf = snmp_ber_decode_type(buf, &buf_len, &type); + if(buf == NULL) { + LOG_DBG("Could not decode type\n"); + return NULL; + } + + if(type != BER_DATA_TYPE_SEQUENCE) { + LOG_DBG("Invalid type\n"); + return NULL; + } + + buf = snmp_ber_decode_length(buf, &buf_len, &len); + if(buf == NULL) { + LOG_DBG("Could not decode length\n"); + return NULL; + } + + for(i = 0; buf_len > 0; ++i) { + + buf = snmp_ber_decode_type(buf, &buf_len, &type); + if(buf == NULL) { + LOG_DBG("Could not decode type\n"); + return NULL; + } + + if(type != BER_DATA_TYPE_SEQUENCE) { + LOG_DBG("Invalid (%X) type\n", type); + return NULL; + } + + buf = snmp_ber_decode_length(buf, &buf_len, &len); + if(buf == NULL) { + LOG_DBG("Could not decode length\n"); + return NULL; + } + + buf = snmp_oid_decode_oid(buf, &buf_len, varbinds[i].oid, &oid_len); + if(buf == NULL) { + LOG_DBG("Could not decode oid\n"); + return NULL; + } + + varbinds[i].value_type = *buf; + + switch(varbinds[i].value_type) { + case BER_DATA_TYPE_INTEGER: + buf = snmp_ber_decode_integer(buf, &buf_len, &varbinds[i].value.integer); + break; + case SNMP_DATA_TYPE_TIME_TICKS: + buf = snmp_ber_decode_unsigned_integer(buf, &buf_len, varbinds[i].value_type, &varbinds[i].value.integer); + break; + case BER_DATA_TYPE_OCTET_STRING: + buf = snmp_ber_decode_string_len_buffer(buf, &buf_len, &varbinds[i].value.string.string, &varbinds[i].value.string.length); + break; + case BER_DATA_TYPE_NULL: + buf = snmp_ber_decode_null(buf, &buf_len); + break; + default: + LOG_DBG("Invalid varbind type\n"); + return NULL; + } + + if(buf == NULL) { + LOG_DBG("Could varbind type\n"); + return NULL; + } + } + + *varbind_num = i; + + return buf; +} diff --git a/os/net/app-layer/snmp/snmp-message.h b/os/net/app-layer/snmp/snmp-message.h new file mode 100644 index 0000000000000000000000000000000000000000..26436b9b7c8f0265c796d7f92fbfdc08e773bc91 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-message.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup snmp + * @{ + */ + +#ifndef SNMP_MESSAGE_H_ +#define SNMP_MESSAGE_H_ + +#include "snmp.h" + +#define SNMP_DATA_TYPE_TIME_TICKS 0x43 +#define SNMP_DATA_TYPE_NO_SUCH_INSTANCE 0x81 +#define SNMP_DATA_TYPE_END_OF_MIB_VIEW 0x82 + +#define SNMP_DATA_TYPE_PDU_GET_REQUEST 0xA0 +#define SNMP_DATA_TYPE_PDU_GET_NEXT_REQUEST 0xA1 +#define SNMP_DATA_TYPE_PDU_GET_RESPONSE 0xA2 +#define SNMP_DATA_TYPE_PDU_SET_REQUEST 0xA3 +#define SNMP_DATA_TYPE_PDU_TRAP 0xA4 +#define SNMP_DATA_TYPE_PDU_GET_BULK 0xA5 + +/** + * @brief Encodes a SNMP message + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param header The SNMP header struct + * @param varbinds The varbinds array + * @param varbinds_length The number of varbinds + * + * @return + */ +unsigned char * +snmp_message_encode(unsigned char *out, uint32_t *out_len, snmp_header_t *header, + snmp_varbind_t *varbinds, uint32_t varbinds_length); +/** + * @brief + * + * @param buf A pointer to the beginning of the buffer + * @param buf_len A pointer to the buffer length + * @param header The SNMP header struct + * @param varbinds The varbinds array + * @param varbinds_length A pointer to the number of varbinds + * + * @return + */ +uint8_t * +snmp_message_decode(uint8_t *buf, uint32_t buf_len, snmp_header_t *header, + snmp_varbind_t *varbinds, uint32_t *varbinds_length); + +#endif /* SNMP_MESSAGE_H_ */ + +/** @} */ diff --git a/os/net/app-layer/snmp/snmp-mib.c b/os/net/app-layer/snmp/snmp-mib.c new file mode 100644 index 0000000000000000000000000000000000000000..fae834af141afe0d5f8c245de7c9f9a53ca5eade --- /dev/null +++ b/os/net/app-layer/snmp/snmp-mib.c @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +#include "contiki.h" + +#include "snmp-mib.h" +#include "snmp-oid.h" +#include "lib/list.h" + +#define LOG_MODULE "SNMP [mib]" +#define LOG_LEVEL LOG_LEVEL_SNMP + +LIST(snmp_mib); + +snmp_mib_resource_t * +snmp_mib_find(uint32_t *oid) +{ + snmp_mib_resource_t *resource; + + resource = NULL; + for(resource = list_head(snmp_mib); + resource; resource = resource->next) { + + if(!snmp_oid_cmp_oid(oid, resource->oid)) { + return resource; + } + } + + return NULL; +} +snmp_mib_resource_t * +snmp_mib_find_next(uint32_t *oid) +{ + snmp_mib_resource_t *resource; + + resource = NULL; + for(resource = list_head(snmp_mib); + resource; resource = resource->next) { + + if(snmp_oid_cmp_oid(resource->oid, oid) > 0) { + return resource; + } + } + + return NULL; +} +void +snmp_mib_add(snmp_mib_resource_t *new_resource) +{ + snmp_mib_resource_t *resource; + + for(resource = list_head(snmp_mib); + resource; resource = resource->next) { + + if(snmp_oid_cmp_oid(resource->oid, new_resource->oid) > 0) { + break; + } + } + if(resource == NULL) { + list_add(snmp_mib, new_resource); + } else { + list_insert(snmp_mib, new_resource, resource); + } + +#if LOG_LEVEL == LOG_LEVEL_DBG + /* + * We print the entire resource table + */ + LOG_DBG("Table after insert.\n"); + for(resource = list_head(snmp_mib); + resource; resource = resource->next) { + + snmp_oid_print(resource->oid); + } +#endif /* LOG_LEVEL == LOG_LEVEL_DBG */ +} +void +snmp_mib_init(void) +{ + list_init(snmp_mib); +} diff --git a/os/net/app-layer/snmp/snmp-mib.h b/os/net/app-layer/snmp/snmp-mib.h new file mode 100644 index 0000000000000000000000000000000000000000..84115156a0eac33416c925d2d4348cdde4a7c50f --- /dev/null +++ b/os/net/app-layer/snmp/snmp-mib.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup snmp + * @{ + */ + +#ifndef SNMP_MIB_H_ +#define SNMP_MIB_H_ + +#include "snmp.h" + +/** + * @brief The MIB resource handler typedef + * + * @param varbind The varbind that is being changed + * @param oid The oid from the resource + */ +typedef void (*snmp_mib_resource_handler_t)(snmp_varbind_t *varbind, uint32_t *oid); + +/** + * @brief The MIB Resource struct + */ +typedef struct snmp_mib_resource_s { + /** + * @brief A pointer to the next element in the linked list + * + * @remarks This MUST be the first element in the struct + */ + struct snmp_mib_resource_s *next; + /** + * @brief A array that represents the OID + * + * @remarks This array is "null" terminated. In this case the -1 is used. + */ + uint32_t *oid; + /** + * @brief The function handler that is called for this resource + */ + snmp_mib_resource_handler_t handler; +} snmp_mib_resource_t; + +/** + * @brief Finds the MIB Resource for this OID + * + * @param oid The OID + * + * @return In case of success a pointer to the resouce or NULL in case of fail + */ +snmp_mib_resource_t * +snmp_mib_find(uint32_t *oid); + +/** + * @brief Finds the next MIB Resource after this OID + * + * @param oid The OID + * + * @return In case of success a pointer to the resouce or NULL in case of fail + */ +snmp_mib_resource_t * +snmp_mib_find_next(uint32_t *oid); + +/** + * @brief Adds a resource into the linked list + * + * @param resource The resource + */ +void +snmp_mib_add(snmp_mib_resource_t *resource); + +/** + * @brief Initialize the MIB resources list + */ +void +snmp_mib_init(void); + +#endif /* SNMP_MIB_H_ */ +/** @} */ diff --git a/os/net/app-layer/snmp/snmp-oid.c b/os/net/app-layer/snmp/snmp-oid.c new file mode 100644 index 0000000000000000000000000000000000000000..29e4a2637c5b50b133c9117d972f6a5f1c605228 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-oid.c @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +#include "contiki.h" + +#include "snmp-oid.h" +#include "snmp-ber.h" + +#define LOG_MODULE "SNMP [oid]" +#define LOG_LEVEL LOG_LEVEL_SNMP + +/*---------------------------------------------------------------------------*/ +int +snmp_oid_cmp_oid(uint32_t *oid1, uint32_t *oid2) +{ + uint8_t i; + + i = 0; + while(oid1[i] != ((uint32_t)-1) && + oid2[i] != ((uint32_t)-1)) { + if(oid1[i] != oid2[i]) { + if(oid1[i] < oid2[i]) { + return -1; + } + return 1; + } + i++; + } + + if(oid1[i] == ((uint32_t)-1) && + oid2[i] != ((uint32_t)-1)) { + return -1; + } + + if(oid1[i] != ((uint32_t)-1) && + oid2[i] == ((uint32_t)-1)) { + return 1; + } + + return 0; +} +/*---------------------------------------------------------------------------*/ +unsigned char * +snmp_oid_encode_oid(unsigned char *out, uint32_t *out_len, uint32_t *oid) +{ + uint32_t original_out_len; + uint32_t *oid_start = oid; + uint32_t num; + + original_out_len = *out_len; + while(*oid != ((uint32_t)-1)) { + ++oid; + } + --oid; + + while(oid != oid_start) { + num = *oid; + (*out_len)++; + *out-- = (uint8_t)(num & 0x7F); + num >>= 7; + + while(num) { + (*out_len)++; + *out-- = (uint8_t)((num & 0x7F) | 0x80); + num >>= 7; + } + --oid; + } + + num = *(out + 1) + 40 * *oid; + (*out_len)--; + out++; + (*out_len)++; + *out-- = (uint8_t)(num & 0x7F); + num >>= 7; + + while(num) { + (*out_len)++; + *out-- = (uint8_t)((num & 0x7F) | 0x80); + num >>= 7; + } + + out = snmp_ber_encode_length(out, out_len, ((*out_len - original_out_len) & 0xFF)); + out = snmp_ber_encode_type(out, out_len, SNMP_DATA_TYPE_OBJECT); + + return out; +} +/*---------------------------------------------------------------------------*/ +uint8_t * +snmp_oid_decode_oid(uint8_t *buf, uint32_t *buff_len, uint32_t *oid, uint32_t *oid_len) +{ + uint32_t *start; + uint8_t *buf_end, type; + uint8_t len; + div_t first; + + start = oid; + + buf = snmp_ber_decode_type(buf, buff_len, &type); + if(buf == NULL) { + return NULL; + } + + if(type != SNMP_DATA_TYPE_OBJECT) { + return NULL; + } + + buf = snmp_ber_decode_length(buf, buff_len, &len); + if(buf == NULL) { + return NULL; + } + + buf_end = buf + len; + + (*buff_len)--; + first = div(*buf++, 40); + *oid++ = (uint32_t)first.quot; + *oid++ = (uint32_t)first.rem; + + while(buf != buf_end) { + --(*oid_len); + if(*oid_len == 0) { + return NULL; + } + + int i; + + *oid = (uint32_t)(*buf & 0x7F); + for(i = 0; i < 4; i++) { + (*buff_len)--; + if((*buf++ & 0x80) == 0) { + break; + } + + *oid <<= 7; + *oid |= (*buf & 0x7F); + } + + ++oid; + } + + *oid++ = ((uint32_t)-1); + *oid_len = (uint32_t)(oid - start); + + return buf; +} +/*---------------------------------------------------------------------------*/ +void +snmp_oid_copy(uint32_t *dst, uint32_t *src) +{ + uint8_t i; + + i = 0; + while(src[i] != ((uint32_t)-1)) { + dst[i] = src[i]; + i++; + } + /* + * Copy the "null" terminator + */ + dst[i] = src[i]; +} +/*---------------------------------------------------------------------------*/ +#if LOG_LEVEL == LOG_LEVEL_DBG +void +snmp_oid_print(uint32_t *oid) +{ + uint8_t i; + + i = 0; + LOG_DBG("{"); + while(oid[i] != ((uint32_t)-1)) { + LOG_DBG_("%lu", (unsigned long)oid[i]); + i++; + if(oid[i] != ((uint32_t)-1)) { + LOG_DBG_("."); + } + } + LOG_DBG_("}\n"); +} +#endif /* LOG_LEVEL == LOG_LEVEL_DBG */ diff --git a/os/net/app-layer/snmp/snmp-oid.h b/os/net/app-layer/snmp/snmp-oid.h new file mode 100644 index 0000000000000000000000000000000000000000..1da2d16d2a9f02abbfa1844372a6e200c6adbbf2 --- /dev/null +++ b/os/net/app-layer/snmp/snmp-oid.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup snmp + * @{ + */ + +#ifndef SNMP_OID_H_ +#define SNMP_OID_H_ + +#include "snmp.h" + +#define SNMP_DATA_TYPE_OBJECT 0x06 + +/** + * @brief Compares to oids + * + * @param oid1 First Oid + * @param oid2 Second Oid + * + * @return < 0 if oid1 < oid2, > 0 if oid1 > oid2 and 0 if they are equal + */ +int +snmp_oid_cmp_oid(uint32_t *oid1, uint32_t *oid2); + +/** + * @brief Encodes a Oid + * + * @param out A pointer to the end of the buffer + * @param out_len A pointer to the buffer length + * @param oid The Oid + * + * @return NULL if error or the next entry in the buffer + */ +unsigned char * +snmp_oid_encode_oid(unsigned char *out, uint32_t *out_len, uint32_t *oid); + +/** + * @brief Decodes a Oid + * + * @param buf A pointer to the beginning of the buffer + * @param buf_len A pointer to the buffer length + * @param oid A pointer to the oid array + * @param oid_len A pointer to the oid length + * + * @return NULL if error or the first entry after the oid in the buffer + */ +unsigned char * +snmp_oid_decode_oid(unsigned char *buf, uint32_t *buf_len, uint32_t *oid, uint32_t *oid_len); + +/** + * @brief Copies a Oid + * + * @param dst A pointer to the destination array + * @param src A pointer to the source array + */ +void +snmp_oid_copy(uint32_t *dst, uint32_t *src); + +#if LOG_LEVEL == LOG_LEVEL_DBG +/** + * @brief Prints a oid + * + * @param oid A oid + */ +void +snmp_oid_print(uint32_t *oid); +#endif /* LOG_LEVEL == LOG_LEVEL_DBG */ + +#endif /* SNMP_OID_H_ */ +/** @} */ diff --git a/os/net/app-layer/snmp/snmp.c b/os/net/app-layer/snmp/snmp.c new file mode 100644 index 0000000000000000000000000000000000000000..a721129fc5c9eb8381497bce649250af46a92ef6 --- /dev/null +++ b/os/net/app-layer/snmp/snmp.c @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +#include "contiki.h" + +#include "snmp.h" +#include "snmp-mib.h" +#include "snmp-engine.h" + +#define LOG_MODULE "SNMP" +#define LOG_LEVEL LOG_LEVEL_SNMP + +/*---------------------------------------------------------------------------*/ +#define SNMP_SERVER_PORT UIP_HTONS(SNMP_PORT) +PROCESS(snmp_process, "SNMP Process"); + +static struct uip_udp_conn *snmp_udp_conn = NULL; + +/*---------------------------------------------------------------------------*/ +static void +snmp_process_data(void) +{ + static unsigned char packet[SNMP_MAX_PACKET_SIZE]; + unsigned char *packet_end; + static uint32_t packet_len; + + packet_end = packet + sizeof(packet) - 1; + packet_len = 0; + + LOG_DBG("receiving UDP datagram from ["); + LOG_DBG_6ADDR(&UIP_IP_BUF->srcipaddr); + LOG_DBG_("]:%u", uip_ntohs(UIP_UDP_BUF->srcport)); + LOG_DBG_(" Length: %u\n", uip_datalen()); + + /* + * Handle the request + */ + if((packet_end = snmp_engine(uip_appdata, uip_datalen(), packet_end, &packet_len)) == NULL) { + LOG_DBG("Error while handling the request\n"); + } else { + LOG_DBG("Sending response\n"); + /* + * Send the response + */ + uip_udp_packet_sendto(snmp_udp_conn, packet_end, packet_len, &UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport); + } +} +/*---------------------------------------------------------------------------*/ +void +snmp_init() +{ + snmp_mib_init(); + process_start(&snmp_process, NULL); +} +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(snmp_process, ev, data) +{ + PROCESS_BEGIN(); + + /* new connection with remote host */ + snmp_udp_conn = udp_new(NULL, 0, NULL); + udp_bind(snmp_udp_conn, SNMP_SERVER_PORT); + LOG_DBG("Listening on port %u\n", uip_ntohs(snmp_udp_conn->lport)); + + while(1) { + PROCESS_YIELD(); + + if(ev == tcpip_event) { + if(uip_newdata()) { + snmp_process_data(); + } + } + } /* while (1) */ + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/os/net/app-layer/snmp/snmp.h b/os/net/app-layer/snmp/snmp.h new file mode 100644 index 0000000000000000000000000000000000000000..f6c4be0667f002bdce94072cfd0c2e424a639c00 --- /dev/null +++ b/os/net/app-layer/snmp/snmp.h @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br> + * 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 + * An implementation of the Simple Network Management Protocol (RFC 3411-3418) + * \author + * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br + */ + +/** + * \addtogroup apps + * @{ + * + * \defgroup snmp SNMP (Simple Network Management Protocol) + * @{ + * + * This is an implementation of the Simple Network Management Protocol + */ + +#ifndef SNMP_H_ +#define SNMP_H_ + +#include "contiki.h" +#include "contiki-net.h" + +#include "sys/log.h" + +#include "snmp-conf.h" + +#include <stdlib.h> +#include <stdint.h> + +/** + * \defgroup SNMPDefine SNMP Defines + * @{ + */ + +/** + * @brief SNMP Version 1 code + */ +#define SNMP_VERSION_1 0 +/** + * @brief SNMP Version 2c code + */ +#define SNMP_VERSION_2C 1 + +/** + * @brief SNMP No Such Name error code + */ +#define SNMP_STATUS_NO_SUCH_NAME 2 + +/** @} */ + +/** + * \defgroup SNMPStructs SNMP Structs + * @{ + */ + +/** + * @brief The SNMP header struct + */ +typedef struct snmp_header_s { + /** + * @brief SNMP Version + */ + uint32_t version; + /** + * @brief Struct to wrap the community + */ + struct snmp_msg_community { + /** + * @brief A pointer to the community + * + * @remarks This pointer refers to the beginning of the string in the packet + */ + const char *community; + /** + * @brief The string length + * + * @remarks Do not use strlen on the community pointer since it is not null terminated + */ + uint32_t length; + } community; + /** + * @brief The PDU type + */ + uint8_t pdu_type; + /** + * @brief The request ID + */ + uint32_t request_id; + /** + * @brief Union to hold the error status or the non repeaters + * + * @remarks A union was used since these values cannot co-exist + */ + union error_status_non_repeaters_u { + /** + * @brief The error status + */ + uint32_t error_status; + /** + * @brief The non repeaters + */ + uint32_t non_repeaters; + } error_status_non_repeaters; + /** + * @brief Union to hold the error index or the max repetitions + * + * @remarks A union was used since these values cannot co-exist + */ + union error_index_max_repetitions_u { + /** + * @brief The error index + */ + uint32_t error_index; + /** + * @brief The max repetitions + */ + uint32_t max_repetitions; + } error_index_max_repetitions; +} snmp_header_t; + +/** + * @brief The varbind struct + */ +typedef struct snmp_varbind_s { + /** + * @brief The OID + * + * @remarks The length is configurable + */ + uint32_t oid[SNMP_MSG_OID_MAX_LEN]; + /** + * @brief The type in this varbind + */ + uint8_t value_type; + /** + * @brief A union to represent the value in this varbind + * + * @remarks A union is used since the varbind can only have one value of one type + */ + union snmp_varbind_val_u { + /** + * @brief The integer value + */ + uint32_t integer; + /** + * @brief A struct that contains the string + */ + struct snmp_varbind_string_s { + /** + * @brief A pointer to the string value from this varbind + * + * @remarks This pointer points to a string that cannot be changed + */ + const char *string; + /** + * @brief The string length + * + * @remarks Do not use strlen on the string since it might not be null terminated + */ + uint32_t length; + } string; + /** + * @brief A pointer to the beggining of a oid array + */ + uint32_t *oid; + } value; +} snmp_varbind_t; + +/** @}*/ + +/** + * \defgroup SNMPFunctions SNMP Functions + * @{ + */ + +/** + * @brief Initializes the SNMP engine + */ +void +snmp_init(); + +/** @}*/ + +#endif /* SNMP_H_ */ +/** @} */ +/** @} */ diff --git a/os/net/ipv6/ip64-addr.c b/os/net/ipv6/ip64-addr.c index b472ee81bb6ec667411b54686c37e1843c828c60..340c0d85a28fe772e7d318b46b160df2d6102e79 100644 --- a/os/net/ipv6/ip64-addr.c +++ b/os/net/ipv6/ip64-addr.c @@ -34,9 +34,26 @@ #include <stdio.h> #include <string.h> -#define printf(...) +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "IPv6" +#define LOG_LEVEL LOG_LEVEL_NONE +/* + * By defult we do use the well-known-prefix for the IP64 address prefix, see + * RFC6052, https://tools.ietf.org/html/rfc6052#section-2.1 . + * To make use of ::ffff:<IPv4> define IP64_NAT64_USE_WELL_KNOWN_PREFIX to zero. + */ +#ifndef IP64_NAT64_USE_WELL_KNOWN_PREFIX +#define IP64_NAT64_USE_WELL_KNOWN_PREFIX 1 +#endif /* IP64_NAT64_USE_WELL_KNOWN_PREFIX */ + +#if IP64_NAT64_USE_WELL_KNOWN_PREFIX +static uip_ip6addr_t ip64_prefix = {{ 0, 0x64, 0xff, 0x9b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; +#else static uip_ip6addr_t ip64_prefix = {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 0, 0, 0}}; +#endif /* IP64_NAT64_USE_WELL_KNOWN_PREFIX */ + static uint8_t ip64_prefix_len = 96; /*---------------------------------------------------------------------------*/ @@ -65,9 +82,11 @@ ip64_addr_4to6(const uip_ip4addr_t *ipv4addr, ipv6addr->u8[13] = ipv4addr->u8[1]; ipv6addr->u8[14] = ipv4addr->u8[2]; ipv6addr->u8[15] = ipv4addr->u8[3]; - printf("ip64_addr_4to6: IPv6-encoded IPv4 address %d.%d.%d.%d\n", - ipv4addr->u8[0], ipv4addr->u8[1], - ipv4addr->u8[2], ipv4addr->u8[3]); + LOG_DBG("ip64_addr_4to6: IPv6-encoded IPv4 address %d.%d.%d.%d => ", + ipv4addr->u8[0], ipv4addr->u8[1], + ipv4addr->u8[2], ipv4addr->u8[3]); + LOG_DBG_6ADDR(ipv6addr); + LOG_DBG("\n"); /* Conversion succeeded, we return non-zero. */ return 1; @@ -87,9 +106,11 @@ ip64_addr_6to4(const uip_ip6addr_t *ipv6addr, ipv4addr->u8[2] = ipv6addr->u8[14]; ipv4addr->u8[3] = ipv6addr->u8[15]; - printf("ip64_addr_6to4: IPv6-encoded IPv4 address %d.%d.%d.%d\n", - ipv4addr->u8[0], ipv4addr->u8[1], - ipv4addr->u8[2], ipv4addr->u8[3]); + LOG_DBG("ip64_addr_6to4: IPv6-encoded IPv4 address %d.%d.%d.%d <=", + ipv4addr->u8[0], ipv4addr->u8[1], + ipv4addr->u8[2], ipv4addr->u8[3]); + LOG_DBG_6ADDR(ipv6addr); + LOG_DBG("\n"); /* Conversion succeeded, we return non-zero. */ return 1; diff --git a/os/net/ipv6/multicast/mpl.c b/os/net/ipv6/multicast/mpl.c index 1879d821692381078aeee7edb50a977e6d73157e..f6263ba088a625b6db43640b197374dd9ec845c4 100644 --- a/os/net/ipv6/multicast/mpl.c +++ b/os/net/ipv6/multicast/mpl.c @@ -509,7 +509,7 @@ buffer_reclaim(void) * We've already worked out what this new value is. */ if(largest != NULL) { - reclaim = list_pop(locssptr->min_seq); + reclaim = list_pop(largest->min_seq); largest->min_seqno = list_item_next(reclaim) == NULL ? reclaim->seq : ((struct mpl_msg *)list_item_next(reclaim))->seq; largest->count--; trickle_timer_stop(&reclaim->tt); @@ -759,6 +759,7 @@ icmp_out(struct mpl_domain *dom) uint8_t vector[32]; uint8_t vec_size; uint8_t vec_len; + uint8_t cur_seq; uint16_t payload_len; uip_ds6_addr_t *addr; size_t seed_info_len; @@ -824,13 +825,22 @@ icmp_out(struct mpl_domain *dom) /* Populate the seed info message vector */ memset(vector, 0, sizeof(vector)); vec_len = 0; - locmmptr = list_head(locssptr->min_seq); - while(locmmptr != NULL) { + cur_seq = 0; + LOG_INFO("\nBuffer for seed: "); + LOG_INFO_SEED(locssptr->seed_id); + LOG_INFO_("\n"); + for(locmmptr = list_head(locssptr->min_seq); locmmptr != NULL; locmmptr = list_item_next(locmmptr)) { + LOG_INFO("%d -- %x\n", locmmptr->seq, locmmptr->data[locmmptr->size - 1]); + cur_seq = SEQ_VAL_ADD(locssptr->min_seqno, vec_len); if(locmmptr->seq == SEQ_VAL_ADD(locssptr->min_seqno, vec_len)) { BIT_VECTOR_SET_BIT(vector, vec_len); - locmmptr = list_item_next(locmmptr); + vec_len++; + } else { + /* Insert enough zeros to get to the next message */ + vec_len += locmmptr->seq - cur_seq; + BIT_VECTOR_SET_BIT(vector, vec_len); + vec_len++; } - vec_len++; } /* Convert vector length from bits to bytes */ diff --git a/os/net/ipv6/sicslowpan.c b/os/net/ipv6/sicslowpan.c index d61d44bafa3937792d6d4a9a7188b44904857a46..6f6f7132e2c0dd0a232d740249d73a8a7427c1ae 100644 --- a/os/net/ipv6/sicslowpan.c +++ b/os/net/ipv6/sicslowpan.c @@ -231,6 +231,11 @@ static uint16_t my_tag; #define SICSLOWPAN_FRAGMENT_SIZE (127 - 2 - 15) #endif +/* Check the selected fragment size, since we use 8-bit integers to handle it. */ +#if SICSLOWPAN_FRAGMENT_SIZE > 255 +#error Too large SICSLOWPAN_FRAGMENT_SIZE set. +#endif + /* Assuming that the worst growth for uncompression is 38 bytes */ #define SICSLOWPAN_FIRST_FRAGMENT_SIZE (SICSLOWPAN_FRAGMENT_SIZE + 38) @@ -306,16 +311,25 @@ static int store_fragment(uint8_t index, uint8_t offset) { int i; + int len; + + len = packetbuf_datalen() - packetbuf_hdr_len; + + if(len < 0 || len > SICSLOWPAN_FRAGMENT_SIZE) { + /* Unacceptable fragment size. */ + return -1; + } + for(i = 0; i < SICSLOWPAN_FRAGMENT_BUFFERS; i++) { if(frag_buf[i].len == 0) { - /* copy over the data from packetbuf into the fragment buffer and store offset and len */ + /* copy over the data from packetbuf into the fragment buffer, + and store offset and len */ frag_buf[i].offset = offset; /* frag offset */ - frag_buf[i].len = packetbuf_datalen() - packetbuf_hdr_len; + frag_buf[i].len = len; frag_buf[i].index = index; - memcpy(frag_buf[i].data, packetbuf_ptr + packetbuf_hdr_len, - packetbuf_datalen() - packetbuf_hdr_len); + memcpy(frag_buf[i].data, packetbuf_ptr + packetbuf_hdr_len, len); /* return the length of the stored fragment */ - return frag_buf[i].len; + return len; } } /* failed */ @@ -396,23 +410,43 @@ add_fragment(uint16_t tag, uint16_t frag_size, uint8_t offset) /*---------------------------------------------------------------------------*/ /* Copy all the fragments that are associated with a specific context into uip */ -static void +static bool copy_frags2uip(int context) { int i; + /* Check length fields before proceeding. */ + if(frag_info[context].len < frag_info[context].first_frag_len || + frag_info[context].len > sizeof(uip_buf)) { + LOG_WARN("input: invalid total size of fragments\n"); + clear_fragments(context); + return false; + } + /* Copy from the fragment context info buffer first */ memcpy((uint8_t *)UIP_IP_BUF, (uint8_t *)frag_info[context].first_frag, frag_info[context].first_frag_len); + + /* Ensure that no previous data is used for reassembly in case of missing fragments. */ + memset((uint8_t *)UIP_IP_BUF + frag_info[context].first_frag_len, 0, + frag_info[context].len - frag_info[context].first_frag_len); + for(i = 0; i < SICSLOWPAN_FRAGMENT_BUFFERS; i++) { /* And also copy all matching fragments */ if(frag_buf[i].len > 0 && frag_buf[i].index == context) { + if((frag_buf[i].offset << 3) + frag_buf[i].len > sizeof(uip_buf)) { + LOG_WARN("input: invalid fragment offset\n"); + clear_fragments(context); + return false; + } memcpy((uint8_t *)UIP_IP_BUF + (uint16_t)(frag_buf[i].offset << 3), (uint8_t *)frag_buf[i].data, frag_buf[i].len); } } /* deallocate all the fragments for this context */ clear_fragments(context); + + return true; } #endif /* SICSLOWPAN_CONF_FRAG */ @@ -1233,6 +1267,10 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len) exthdr->len = (2 + len) / 8 - 1; exthdr->next = next; last_nextheader = &exthdr->next; + if(ip_len == 0 && (uint8_t *)exthdr - uip_buf + 2 + len > sizeof(uip_buf)) { + LOG_DBG("uncompression: ext header points beyond uip buffer boundary\n"); + return; + } memcpy((uint8_t*)exthdr + 2, hc06_ptr, len); hc06_ptr += len; uncomp_hdr_len += (exthdr->len + 1) * 8; @@ -1397,7 +1435,7 @@ digest_6lorh_hdr(void) * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * \endverbatim */ - #if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6 +#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6 static void compress_hdr_ipv6(linkaddr_t *link_destaddr) { @@ -1729,11 +1767,17 @@ output(const linkaddr_t *localdest) return 0; #endif /* SICSLOWPAN_CONF_FRAG */ } else { - /* * The packet does not need to be fragmented * copy "payload" and send */ + + if(uip_len < uncomp_hdr_len) { + LOG_ERR("output: uip_len is smaller than uncomp_hdr_len (%d < %d)", + (int)uip_len, (int)uncomp_hdr_len); + return 0; + } + memcpy(packetbuf_ptr + packetbuf_hdr_len, (uint8_t *)UIP_IP_BUF + uncomp_hdr_len, uip_len - uncomp_hdr_len); packetbuf_set_datalen(uip_len - uncomp_hdr_len + packetbuf_hdr_len); @@ -1875,7 +1919,8 @@ input(void) } /* Process next dispatch and headers */ - if((PACKETBUF_6LO_PTR[PACKETBUF_6LO_DISPATCH] & SICSLOWPAN_DISPATCH_IPHC_MASK) == SICSLOWPAN_DISPATCH_IPHC) { + if(SICSLOWPAN_COMPRESSION > SICSLOWPAN_COMPRESSION_IPV6 && + (PACKETBUF_6LO_PTR[PACKETBUF_6LO_DISPATCH] & SICSLOWPAN_DISPATCH_IPHC_MASK) == SICSLOWPAN_DISPATCH_IPHC) { LOG_DBG("uncompression: IPHC dispatch\n"); uncompress_hdr_iphc(buffer, frag_size); } else if(PACKETBUF_6LO_PTR[PACKETBUF_6LO_DISPATCH] == SICSLOWPAN_DISPATCH_IPV6) { @@ -1889,7 +1934,7 @@ input(void) packetbuf_hdr_len += UIP_IPH_LEN; uncomp_hdr_len += UIP_IPH_LEN; } else { - LOG_ERR("uncompression: unknown dispatch: 0x%02x\n", + LOG_ERR("uncompression: unknown dispatch: 0x%02x, or IPHC disabled\n", PACKETBUF_6LO_PTR[PACKETBUF_6LO_DISPATCH] & SICSLOWPAN_DISPATCH_IPHC_MASK); return; } @@ -1922,10 +1967,16 @@ input(void) int req_size = uncomp_hdr_len + (uint16_t)(frag_offset << 3) + packetbuf_payload_len; if(req_size > sizeof(uip_buf)) { +#if SICSLOWPAN_CONF_FRAG LOG_ERR( - "input: packet dropped, minimum required IP_BUF size: %d+%d+%d=%d (current size: %u)\n", + "input: packet and fragment context %u dropped, minimum required IP_BUF size: %d+%d+%d=%d (current size: %u)\n", + frag_context, uncomp_hdr_len, (uint16_t)(frag_offset << 3), packetbuf_payload_len, req_size, (unsigned)sizeof(uip_buf)); + /* Discard all fragments for this contex, as reassembling this particular fragment would + * cause an overflow in uipbuf */ + clear_fragments(frag_context); +#endif /* SICSLOWPAN_CONF_FRAG */ return; } } @@ -1950,7 +2001,9 @@ input(void) if(last_fragment != 0) { frag_info[frag_context].reassembled_len = frag_size; /* copy to uip */ - copy_frags2uip(frag_context); + if(!copy_frags2uip(frag_context)) { + return; + } } } diff --git a/os/net/ipv6/sicslowpan.h b/os/net/ipv6/sicslowpan.h index 46cf6cc05a4ff5c4d2341346f59b2894be56a62c..2221e42071b24cf4a24e00b3279384f28d559efe 100644 --- a/os/net/ipv6/sicslowpan.h +++ b/os/net/ipv6/sicslowpan.h @@ -66,6 +66,8 @@ /** * \name 6lowpan compressions + * \note These are assumed to be in order - so that no compression is 0, then more and more + * compressed version follow. E.g. they can be used for comparing: if x > COMPRESSION_IPV6 ... * @{ */ #define SICSLOWPAN_COMPRESSION_IPV6 0 /* No compression */ diff --git a/os/net/ipv6/tcp-socket.c b/os/net/ipv6/tcp-socket.c index b2ec304a5a693c52b9c8ab01dd8b19dc17680dec..3a12bacbfbbf65f1c09e3da03c0e349747485513 100644 --- a/os/net/ipv6/tcp-socket.c +++ b/os/net/ipv6/tcp-socket.c @@ -76,9 +76,9 @@ acked(struct tcp_socket *s) outputbuf_lastsent */ if(s->output_data_send_nxt > 0) { - memcpy(&s->output_data_ptr[0], - &s->output_data_ptr[s->output_data_send_nxt], - s->output_data_maxlen - s->output_data_send_nxt); + memmove(&s->output_data_ptr[0], + &s->output_data_ptr[s->output_data_send_nxt], + s->output_data_maxlen - s->output_data_send_nxt); } if(s->output_data_len < s->output_data_send_nxt) { PRINTF("tcp: acked assertion failed s->output_data_len (%d) < s->output_data_send_nxt (%d)\n", @@ -350,7 +350,7 @@ tcp_socket_send(struct tcp_socket *s, len = MIN(datalen, s->output_data_maxlen - s->output_data_len); - memcpy(&s->output_data_ptr[s->output_data_len], data, len); + memmove(&s->output_data_ptr[s->output_data_len], data, len); s->output_data_len += len; if(s->output_senddata_len == 0) { diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index 16176e6e2cba49a0a794803ef45f18af2152e1b6..aad8ba2875c3f60c9a934900a004a018d4bd0d7d 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -455,8 +455,9 @@ static void output_fallback(void) { #ifdef UIP_FALLBACK_INTERFACE + uip_last_proto = *((uint8_t *)UIP_IP_BUF + 40); LOG_INFO("fallback: removing ext hdrs & setting proto %d %d\n", - uip_ext_len, *((uint8_t *)UIP_IP_BUF + 40)); + uip_ext_len, uip_last_proto); uip_remove_ext_hdr(); /* Inform the other end that the destination is not reachable. If it's * not informed routes might get lost unexpectedly until there's a need diff --git a/os/net/ipv6/uip-ds6.h b/os/net/ipv6/uip-ds6.h index 0edc1fd6d42d32c62c6f70ab07096c8dc9fbc18f..afc6a6bb3b2539bed25edca5eec6c81b7ad6c49b 100644 --- a/os/net/ipv6/uip-ds6.h +++ b/os/net/ipv6/uip-ds6.h @@ -165,7 +165,7 @@ /** \brief General DS6 definitions */ /** Period for uip-ds6 periodic task*/ #ifndef UIP_DS6_CONF_PERIOD -#define UIP_DS6_PERIOD (CLOCK_SECOND/10) +#define UIP_DS6_PERIOD (60 * CLOCK_SECOND) #else #define UIP_DS6_PERIOD UIP_DS6_CONF_PERIOD #endif diff --git a/os/net/ipv6/uip-icmp6.c b/os/net/ipv6/uip-icmp6.c index e04d66165c6bdc82cd17ff31bcebf893369e7228..786385dac8ee832a60df56c1b6f725562734bfb3 100644 --- a/os/net/ipv6/uip-icmp6.c +++ b/os/net/ipv6/uip-icmp6.c @@ -283,7 +283,7 @@ echo_reply_input(void) n = list_item_next(n)) { if(n->callback != NULL) { n->callback(&sender, ttl, - (uint8_t *)&UIP_ICMP_BUF[sizeof(struct uip_icmp_hdr)], + (uint8_t *)UIP_ICMP_PAYLOAD, uip_len - sizeof(struct uip_icmp_hdr) - UIP_IPH_LEN); } } diff --git a/os/net/ipv6/uip-nameserver.c b/os/net/ipv6/uip-nameserver.c index 755b33992d378d9af241d36e84efe3b101eef9a0..3951300f987d9552910db7d0ea053c503fdfdadc 100644 --- a/os/net/ipv6/uip-nameserver.c +++ b/os/net/ipv6/uip-nameserver.c @@ -46,8 +46,12 @@ #include "lib/list.h" #include "lib/memb.h" - #include <string.h> + +#include "sys/log.h" +#define LOG_MODULE "IPv6" +#define LOG_LEVEL LOG_LEVEL_NONE + /** \brief Nameserver record */ typedef struct uip_nameserver_record { struct uip_nameserver_record *next; @@ -94,6 +98,11 @@ init(void) void uip_nameserver_update(const uip_ipaddr_t *nameserver, uint32_t lifetime) { + LOG_DBG("Nameserver update:"); + LOG_DBG_6ADDR(nameserver); + LOG_DBG("\n"); + + #if UIP_NAMESERVER_POOL_SIZE > 1 register uip_nameserver_record *e; diff --git a/os/net/link-stats.c b/os/net/link-stats.c index c11365b9a2abbe2100a5a6224195c1907e74e00f..b762652c7157a61ea9c88977d86101878d26ee76 100644 --- a/os/net/link-stats.c +++ b/os/net/link-stats.c @@ -225,6 +225,9 @@ link_stats_input_callback(const linkaddr_t *lladdr) #else /* LINK_STATS_INIT_ETX_FROM_RSSI */ stats->etx = ETX_DEFAULT * ETX_DIVISOR; #endif /* LINK_STATS_INIT_ETX_FROM_RSSI */ +#if LINK_STATS_PACKET_COUNTERS + stats->cnt_current.num_packets_rx = 1; +#endif } return; } diff --git a/os/net/mac/csma/csma.c b/os/net/mac/csma/csma.c index 87aa6a1afe4e65ab7ea2dadb1d70a72cac6d35a8..3b20d9b988059a2a84c663c4de616c4a8a6d9587 100644 --- a/os/net/mac/csma/csma.c +++ b/os/net/mac/csma/csma.c @@ -135,6 +135,13 @@ off(void) static void init(void) { + radio_value_t radio_max_payload_len; + + /* Check that the radio can correctly report its max supported payload */ + if(NETSTACK_RADIO.get_value(RADIO_CONST_MAX_PAYLOAD_LEN, &radio_max_payload_len) != RADIO_RESULT_OK) { + LOG_ERR("! radio does not support getting RADIO_CONST_MAX_PAYLOAD_LEN. Abort init.\n"); + return; + } #if LLSEC802154_USES_AUX_HEADER #ifdef CSMA_LLSEC_DEFAULT_KEY0 @@ -150,17 +157,29 @@ static int max_payload(void) { int framer_hdrlen; + radio_value_t max_radio_payload_len; + radio_result_t res; init_sec(); framer_hdrlen = NETSTACK_FRAMER.length(); + res = NETSTACK_RADIO.get_value(RADIO_CONST_MAX_PAYLOAD_LEN, + &max_radio_payload_len); + + if(res == RADIO_RESULT_NOT_SUPPORTED) { + LOG_ERR("Failed to retrieve max radio driver payload length\n"); + return 0; + } + if(framer_hdrlen < 0) { /* Framing failed, we assume the maximum header length */ framer_hdrlen = CSMA_MAC_MAX_HEADER; } - return CSMA_MAC_LEN - framer_hdrlen; + return MIN(max_radio_payload_len, PACKETBUF_SIZE) + - framer_hdrlen + - LLSEC802154_PACKETBUF_MIC_LEN(); } /*---------------------------------------------------------------------------*/ const struct mac_driver csma_driver = { diff --git a/os/net/mac/csma/csma.h b/os/net/mac/csma/csma.h index a2664ef0436703f8c244bad5d2688d4ae01d4e27..58c072ef2c0c65e396358a0bb3ea0dc0ddf55ef8 100644 --- a/os/net/mac/csma/csma.h +++ b/os/net/mac/csma/csma.h @@ -74,13 +74,6 @@ #define CSMA_ACK_LEN 3 -/* Default MAC len for 802.15.4 classic */ -#ifdef CSMA_MAC_CONF_LEN -#define CSMA_MAC_LEN CSMA_MAC_CONF_LEN -#else -#define CSMA_MAC_LEN MIN(NETSTACK_RADIO_MAX_PAYLOAD_LEN, PACKETBUF_SIZE) -#endif - /* just a default - with LLSEC, etc */ #define CSMA_MAC_MAX_HEADER 21 diff --git a/os/net/mac/llsec802154.h b/os/net/mac/llsec802154.h index e808fef7a016a1323d545f487b365a22f04a1297..84e8396e765dd4cd8864366f048402f88561fdcd 100644 --- a/os/net/mac/llsec802154.h +++ b/os/net/mac/llsec802154.h @@ -60,8 +60,6 @@ #define LLSEC802154_ENABLED 0 #endif /* LLSEC802154_CONF_ENABLED */ -#define LLSEC802154_MIC_LEN(sec_lvl) (2 << (sec_lvl & 3)) - #ifdef LLSEC802154_CONF_USES_EXPLICIT_KEYS #define LLSEC802154_USES_EXPLICIT_KEYS LLSEC802154_CONF_USES_EXPLICIT_KEYS #else /* LLSEC802154_CONF_USES_EXPLICIT_KEYS */ @@ -88,6 +86,14 @@ #define LLSEC802154_HTONL(n) (((uint32_t)UIP_HTONS(n) << 16) | UIP_HTONS((uint32_t)(n) >> 16)) #endif /* UIP_CONF_BYTE_ORDER == UIP_LITTLE_ENDIAN */ +#define LLSEC802154_MIC_LEN(sec_lvl) (2 << (sec_lvl & 3)) + +#if LLSEC802154_USES_AUX_HEADER +#define LLSEC802154_PACKETBUF_MIC_LEN() LLSEC802154_MIC_LEN(packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL)) +#else +#define LLSEC802154_PACKETBUF_MIC_LEN() 0 +#endif + #endif /* LLSEC802154_H_ */ /** @} */ diff --git a/os/net/mac/tsch/tsch-adaptive-timesync.c b/os/net/mac/tsch/tsch-adaptive-timesync.c index 2745abca21c1e06b293d018b000fd06346a53eef..a1c38479f02fb8ef7b6d239149be891e6345f567 100644 --- a/os/net/mac/tsch/tsch-adaptive-timesync.c +++ b/os/net/mac/tsch/tsch-adaptive-timesync.c @@ -58,6 +58,8 @@ static int32_t compensated_ticks; static uint8_t timesync_entry_count; /* Since last learning of the drift; may be more than time since last timesync */ static uint32_t asn_since_last_learning; +/* The last neighbor used for timesync */ +struct tsch_neighbor *last_timesource_neighbor; /* Units in which drift is stored: ppm * 256 */ #define TSCH_DRIFT_UNIT (1000L * 1000 * 256) @@ -123,11 +125,8 @@ tsch_timesync_update(struct tsch_neighbor *n, uint16_t time_delta_asn, int32_t d * or the timedelta is not too small, as smaller timedelta * means proportionally larger measurement error. */ if(last_timesource_neighbor != n) { + tsch_adaptive_timesync_reset(); last_timesource_neighbor = n; - drift_ppm = 0; - timesync_entry_count = 0; - compensated_ticks = 0; - asn_since_last_learning = 0; } else { asn_since_last_learning += time_delta_asn; if(asn_since_last_learning >= 4 * TSCH_SLOTS_PER_SECOND) { @@ -193,6 +192,16 @@ tsch_timesync_adaptive_compensate(rtimer_clock_t time_delta_ticks) return result; } /*---------------------------------------------------------------------------*/ +void +tsch_adaptive_timesync_reset(void) +{ + last_timesource_neighbor = NULL; + drift_ppm = 0; + timesync_entry_count = 0; + compensated_ticks = 0; + asn_since_last_learning = 0; +} +/*---------------------------------------------------------------------------*/ #else /* TSCH_ADAPTIVE_TIMESYNC */ /*---------------------------------------------------------------------------*/ void @@ -205,6 +214,10 @@ tsch_timesync_adaptive_compensate(rtimer_clock_t delta_ticks) { return 0; } +void +tsch_adaptive_timesync_reset(void) +{ +} /*---------------------------------------------------------------------------*/ #endif /* TSCH_ADAPTIVE_TIMESYNC */ /** @} */ diff --git a/os/net/mac/tsch/tsch-adaptive-timesync.h b/os/net/mac/tsch/tsch-adaptive-timesync.h index c4ca20b7bff82bfaee9491041fc06fe6afa08e44..d7bdb12503563207a2f667ef63624e2a5121ee4c 100644 --- a/os/net/mac/tsch/tsch-adaptive-timesync.h +++ b/os/net/mac/tsch/tsch-adaptive-timesync.h @@ -44,11 +44,6 @@ #include "contiki.h" -/***** External Variables *****/ - -/** \brief The neighbor last used as our time source */ -extern struct tsch_neighbor *last_timesource_neighbor; - /********** Functions *********/ /** @@ -72,5 +67,11 @@ int32_t tsch_timesync_adaptive_compensate(rtimer_clock_t delta_ticks); */ long int tsch_adaptive_timesync_get_drift_ppm(void); +/** + * \brief Reset the status of the module + */ +void tsch_adaptive_timesync_reset(void); + + #endif /* __TSCH_ADAPTIVE_TIMESYNC_H__ */ /** @} */ diff --git a/os/net/mac/tsch/tsch-const.h b/os/net/mac/tsch/tsch-const.h index f07508a098db506d92603aa094f1e9ceeb223141..00efa015934d9120d11ffee4e668b30ec74114d2 100644 --- a/os/net/mac/tsch/tsch-const.h +++ b/os/net/mac/tsch/tsch-const.h @@ -67,8 +67,8 @@ /* 1 channel, sequence length 1 */ #define TSCH_HOPPING_SEQUENCE_1_1 (uint8_t[]){ 20 } -/* Max TSCH packet lenght - last bytes are CRC in default 802.15.4 packets */ -#define TSCH_PACKET_MAX_LEN MIN(NETSTACK_RADIO_MAX_PAYLOAD_LEN, PACKETBUF_SIZE) +/* Max TSCH packet length equal to the length of the packet buffer */ +#define TSCH_PACKET_MAX_LEN PACKETBUF_SIZE /* The jitter to remove in ticks. * This should be the sum of measurement errors on Tx and Rx nodes. diff --git a/os/net/mac/tsch/tsch-packet.c b/os/net/mac/tsch/tsch-packet.c index 133e9a6688af7afa206aa99f47730fa89d8f472a..893aa7e8c76c1bfbcbce261e04b89a24f94d6b4d 100644 --- a/os/net/mac/tsch/tsch-packet.c +++ b/os/net/mac/tsch/tsch-packet.c @@ -74,11 +74,11 @@ static struct packetbuf_attr eackbuf_attrs[PACKETBUF_NUM_ATTRS]; #define IEEE802154_FRAME_PENDING_BIT_OFFSET 4 /*---------------------------------------------------------------------------*/ -static int +void tsch_packet_eackbuf_set_attr(uint8_t type, const packetbuf_attr_t val) { eackbuf_attrs[type].val = val; - return 1; + return; } /*---------------------------------------------------------------------------*/ /* Return the value of a specified attribute */ @@ -124,14 +124,7 @@ tsch_packet_create_eack(uint8_t *buf, uint16_t buf_len, #endif #if LLSEC802154_ENABLED - if(tsch_is_pan_secured) { - tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, - TSCH_SECURITY_KEY_SEC_LEVEL_ACK); - tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, - FRAME802154_1_BYTE_KEY_ID_MODE); - tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, - TSCH_SECURITY_KEY_INDEX_ACK); - } + tsch_security_set_packetbuf_attr(FRAME802154_ACKFRAME); #endif /* LLSEC802154_ENABLED */ framer_802154_setup_params(tsch_packet_eackbuf_attr, 0, ¶ms); @@ -356,14 +349,7 @@ tsch_packet_create_eb(uint8_t *hdr_len, uint8_t *tsch_sync_ie_offset) packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &tsch_eb_address); #if LLSEC802154_ENABLED - if(tsch_is_pan_secured) { - packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, - TSCH_SECURITY_KEY_SEC_LEVEL_EB); - packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, - FRAME802154_1_BYTE_KEY_ID_MODE); - packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, - TSCH_SECURITY_KEY_INDEX_EB); - } + tsch_security_set_packetbuf_attr(FRAME802154_BEACONFRAME); #endif /* LLSEC802154_ENABLED */ if(NETSTACK_FRAMER.create() < 0) { diff --git a/os/net/mac/tsch/tsch-packet.h b/os/net/mac/tsch/tsch-packet.h index cdf7c7bed0111ac6127acaa18a9724d53e06b718..9f110344b717cb38c33dc59a299e1d18b1eea6b1 100644 --- a/os/net/mac/tsch/tsch-packet.h +++ b/os/net/mac/tsch/tsch-packet.h @@ -114,6 +114,19 @@ void tsch_packet_set_frame_pending(uint8_t *buf, int buf_size); * \return The value of the frame pending bit, 1 or 0 */ int tsch_packet_get_frame_pending(uint8_t *buf, int buf_size); +/** + * \brief Set a packet attribute for the current eack. We not use standard + * packetbuf for eacks because these are generated from interrupt context. + * \param type The attribute identifier + * \param val The attribute value + */ +void tsch_packet_eackbuf_set_attr(uint8_t type, const packetbuf_attr_t val); +/** + * \brief Return the value of a specified attribute + * \param type The attribute identifier + * \return The attribute value + */ +packetbuf_attr_t tsch_packet_eackbuf_attr(uint8_t type); #endif /* __TSCH_PACKET_H__ */ /** @} */ diff --git a/os/net/mac/tsch/tsch-queue.c b/os/net/mac/tsch/tsch-queue.c index f586ac90ed5c57f91ebf09d0cb24887f40294690..650f000d46e1660ad832c5324a70a2efc8a42c0f 100644 --- a/os/net/mac/tsch/tsch-queue.c +++ b/os/net/mac/tsch/tsch-queue.c @@ -233,6 +233,16 @@ tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions, struct tsch_neighbor *n = NULL; int16_t put_index = -1; struct tsch_packet *p = NULL; + +#ifdef TSCH_CALLBACK_PACKET_READY + /* The scheduler provides a callback which sets the timeslot and other attributes */ + if(TSCH_CALLBACK_PACKET_READY() < 0) { + /* No scheduled slots for the packet available; drop it early to save queue space. */ + LOG_DBG("tsch_queue_add_packet(): rejected by the scheduler\n"); + return NULL; + } +#endif + if(!tsch_is_locked()) { n = tsch_queue_add_nbr(addr); if(n != NULL) { @@ -241,9 +251,6 @@ tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions, p = memb_alloc(&packet_memb); if(p != NULL) { /* Enqueue packet */ -#ifdef TSCH_CALLBACK_PACKET_READY - TSCH_CALLBACK_PACKET_READY(); -#endif p->qb = queuebuf_new_from_packetbuf(); if(p->qb != NULL) { p->sent = sent; @@ -265,7 +272,7 @@ tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions, } } LOG_ERR("! add packet failed: %u %p %d %p %p\n", tsch_is_locked(), n, put_index, p, p ? p->qb : NULL); - return 0; + return NULL; } /*---------------------------------------------------------------------------*/ /* Returns the number of packets currently in any TSCH queue */ diff --git a/os/net/mac/tsch/tsch-schedule.c b/os/net/mac/tsch/tsch-schedule.c index 3785cacb24e52e2b2b3e76a0530407498be10c55..41d4d5d080114227bd121608af9c35243f32c63a 100644 --- a/os/net/mac/tsch/tsch-schedule.c +++ b/os/net/mac/tsch/tsch-schedule.c @@ -224,9 +224,6 @@ tsch_schedule_add_link(struct tsch_slotframe *slotframe, if(timeslot > (slotframe->size.val - 1)) { LOG_ERR("! add_link invalid timeslot: %u\n", timeslot); return NULL; - } else if(channel_offset > 15) { - LOG_ERR("! add_link invalid channel_offset: %u\n", channel_offset); - return NULL; } /* Start with removing the link currently installed at this timeslot (needed diff --git a/os/net/mac/tsch/tsch-security.c b/os/net/mac/tsch/tsch-security.c index 12f0de6d51798811b5061f2cfde451209c0d5a84..8d128427043e3c12ad5d887b4dfa1cf35d3376c1 100644 --- a/os/net/mac/tsch/tsch-security.c +++ b/os/net/mac/tsch/tsch-security.c @@ -271,4 +271,33 @@ tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, int datalen, return 1; } } +/*---------------------------------------------------------------------------*/ +void +tsch_security_set_packetbuf_attr(uint8_t frame_type) +{ +#if LLSEC802154_ENABLED + if(tsch_is_pan_secured) { + /* Set security level, key id and index */ + switch(frame_type) { + case FRAME802154_ACKFRAME: + /* For ACKs, we set attriburtes via tsch_packet_eackbuf_set_attr, as classic + * interrupts can not be used from interrupt context. */ + tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, TSCH_SECURITY_KEY_SEC_LEVEL_ACK); + tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, FRAME802154_1_BYTE_KEY_ID_MODE); + tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, TSCH_SECURITY_KEY_INDEX_ACK); + break; + case FRAME802154_BEACONFRAME: + packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, TSCH_SECURITY_KEY_SEC_LEVEL_EB); + packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, FRAME802154_1_BYTE_KEY_ID_MODE); + packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, TSCH_SECURITY_KEY_INDEX_EB); + break; + default: + packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, TSCH_SECURITY_KEY_SEC_LEVEL_OTHER); + packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, FRAME802154_1_BYTE_KEY_ID_MODE); + packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, TSCH_SECURITY_KEY_INDEX_OTHER); + break; + } + } +#endif /* LLSEC802154_ENABLED */ +} /** @} */ diff --git a/os/net/mac/tsch/tsch-security.h b/os/net/mac/tsch/tsch-security.h index 4320d3a70adf65182a5aca9c9d69d473bc99e3f2..3777a9e0c56d9abc41c514bc2832741574ead7fa 100644 --- a/os/net/mac/tsch/tsch-security.h +++ b/os/net/mac/tsch/tsch-security.h @@ -140,5 +140,11 @@ unsigned int tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, const linkaddr_t *sender, struct tsch_asn_t *asn); +/** + * \brief Set packetbuf (or eackbuf) attributes depending on a given frame type + * \param frame_type The frame type (FRAME802154_BEACONFRAME etc.) + */ +void tsch_security_set_packetbuf_attr(uint8_t frame_type); + #endif /* __TSCH_SECURITY_H__ */ /** @} */ diff --git a/os/net/mac/tsch/tsch-slot-operation.c b/os/net/mac/tsch/tsch-slot-operation.c index a34b10fab5745e430e6fa0a436606cf8ff47639f..ba237c8d6b191cec85e17c81f5373440faa6b3c7 100644 --- a/os/net/mac/tsch/tsch-slot-operation.c +++ b/os/net/mac/tsch/tsch-slot-operation.c @@ -143,9 +143,6 @@ static int32_t drift_correction = 0; /* Is drift correction used? (Can be true even if drift_correction == 0) */ static uint8_t is_drift_correction_used; -/* The neighbor last used as our time source */ -struct tsch_neighbor *last_timesource_neighbor = NULL; - /* Used from tsch_slot_operation and sub-protothreads */ static rtimer_clock_t volatile current_slot_start; @@ -241,10 +238,20 @@ tsch_release_lock(void) /* Return channel from ASN and channel offset */ uint8_t -tsch_calculate_channel(struct tsch_asn_t *asn, uint8_t channel_offset) +tsch_calculate_channel(struct tsch_asn_t *asn, uint16_t channel_offset, struct tsch_packet *p) { - uint16_t index_of_0 = TSCH_ASN_MOD(*asn, tsch_hopping_sequence_length); - uint16_t index_of_offset = (index_of_0 + channel_offset) % tsch_hopping_sequence_length.val; + uint16_t index_of_0, index_of_offset; +#if TSCH_WITH_LINK_SELECTOR + if(p != NULL) { + uint16_t packet_channel_offset = queuebuf_attr(p->qb, PACKETBUF_ATTR_TSCH_CHANNEL_OFFSET); + if(packet_channel_offset != 0xffff) { + /* The schedule specifies a channel offset for this one; use it */ + channel_offset = packet_channel_offset; + } + } +#endif + index_of_0 = TSCH_ASN_MOD(*asn, tsch_hopping_sequence_length); + index_of_offset = (index_of_0 + channel_offset) % tsch_hopping_sequence_length.val; return tsch_hopping_sequence[index_of_offset]; } @@ -480,8 +487,8 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) static uint8_t packet_len; /* packet seqno */ static uint8_t seqno; - /* is this a broadcast packet? (wait for ack?) */ - static uint8_t is_broadcast; + /* wait for ack? */ + static uint8_t do_wait_for_ack; static rtimer_clock_t tx_start_time; /* Did we set the frame pending bit to request an extra burst link? */ static int burst_link_requested; @@ -493,11 +500,11 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) /* get payload */ packet = queuebuf_dataptr(current_packet->qb); packet_len = queuebuf_datalen(current_packet->qb); - /* is this a broadcast packet? (wait for ack?) */ - is_broadcast = current_neighbor->is_broadcast; + /* if is this a broadcast packet, don't wait for ack */ + do_wait_for_ack = !current_neighbor->is_broadcast; /* Unicast. More packets in queue for the neighbor? */ burst_link_requested = 0; - if(!is_broadcast + if(do_wait_for_ack && tsch_current_burst_count + 1 < TSCH_BURST_MAX_LEN && tsch_queue_packet_count(¤t_neighbor->addr) > 1) { burst_link_requested = 1; @@ -562,7 +569,7 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) tsch_radio_off(TSCH_RADIO_CMD_OFF_WITHIN_TIMESLOT); if(mac_tx_status == RADIO_TX_OK) { - if(!is_broadcast) { + if(do_wait_for_ack) { uint8_t ackbuf[TSCH_PACKET_MAX_LEN]; int ack_len; rtimer_clock_t ack_start_time; @@ -653,7 +660,7 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) /* Keep track of sync time */ last_sync_asn = tsch_current_asn; tsch_last_sync_time = clock_time(); - tsch_schedule_keepalive(); + tsch_schedule_keepalive(0); } mac_tx_status = MAC_TX_OK; @@ -921,7 +928,7 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t)) is_drift_correction_used = 1; sync_count++; tsch_timesync_update(n, since_last_timesync, -estimated_drift); - tsch_schedule_keepalive(); + tsch_schedule_keepalive(0); } /* Add current input to ringbuf */ @@ -1017,7 +1024,8 @@ PT_THREAD(tsch_slot_operation(struct rtimer *t, void *ptr)) burst_link_scheduled = 0; } else { /* Hop channel */ - tsch_current_channel = tsch_calculate_channel(&tsch_current_asn, current_link->channel_offset); + tsch_current_channel = tsch_calculate_channel(&tsch_current_asn, + current_link->channel_offset, current_packet); } NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, tsch_current_channel); /* Turn the radio on already here if configured so; necessary for radios with slow startup */ @@ -1062,7 +1070,6 @@ PT_THREAD(tsch_slot_operation(struct rtimer *t, void *ptr)) "! leaving the network, last sync %u", (unsigned)TSCH_ASN_DIFF(tsch_current_asn, last_sync_asn)); ); - last_timesource_neighbor = NULL; tsch_disassociate(); } else { /* backup of drift correction for printing debug messages */ diff --git a/os/net/mac/tsch/tsch-slot-operation.h b/os/net/mac/tsch/tsch-slot-operation.h index 22547a2c91b3bd861970f43b9014bb4f55bb1844..b3f68fad4ca2e9929a849344fe4ce99ac2054ab8 100644 --- a/os/net/mac/tsch/tsch-slot-operation.h +++ b/os/net/mac/tsch/tsch-slot-operation.h @@ -67,10 +67,11 @@ extern int tsch_current_burst_count; * The offset to the ASN and performs a hopping sequence lookup. * * \param asn A given ASN - * \param channel_offset A given channel offset + * \param channel_offset Link's channel offset + * \param p Packet that can override the link's channel offset * \return The resulting channel */ -uint8_t tsch_calculate_channel(struct tsch_asn_t *asn, uint8_t channel_offset); +uint8_t tsch_calculate_channel(struct tsch_asn_t *asn, uint16_t channel_offset, struct tsch_packet *p); /** * Checks if the TSCH lock is set. Accesses to global structures outside of * interrupts must be done through the lock, unless the sturcutre has diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index 7256c30a2926eece29f8bf73d238fdfb3f272fc6..596f1fa0e553914bee4c005c5ebc37de71d60b4d 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -71,15 +71,6 @@ #define LOG_MODULE "TSCH" #define LOG_LEVEL LOG_LEVEL_MAC -/* Use to collect link statistics even on Keep-Alive, even though they were - * not sent from an upper layer and don't have a valid packet_sent callback */ -#ifndef TSCH_LINK_NEIGHBOR_CALLBACK -#if NETSTACK_CONF_WITH_IPV6 -void uip_ds6_link_neighbor_callback(int status, int numtx); -#define TSCH_LINK_NEIGHBOR_CALLBACK(dest, status, num) uip_ds6_link_neighbor_callback(status, num) -#endif /* NETSTACK_CONF_WITH_IPV6 */ -#endif /* TSCH_LINK_NEIGHBOR_CALLBACK */ - /* The address of the last node we received an EB from (other than our time source). * Used for recovery */ static linkaddr_t last_eb_nbr_addr; @@ -142,6 +133,15 @@ static clock_time_t tsch_current_eb_period; /* Current period for keepalive output */ static clock_time_t tsch_current_ka_timeout; +/* For scheduling keepalive messages */ +enum tsch_keepalive_status { + KEEPALIVE_SCHEDULING_UNCHANGED, + KEEPALIVE_SCHEDULE_OR_STOP, + KEEPALIVE_SEND_IMMEDIATELY, +}; +/* Should we send or schedule a keepalive? */ +static volatile enum tsch_keepalive_status keepalive_status; + /* timer for sending keepalive messages */ static struct ctimer keepalive_timer; @@ -190,11 +190,7 @@ void tsch_set_ka_timeout(uint32_t timeout) { tsch_current_ka_timeout = timeout; - if(timeout == 0) { - ctimer_stop(&keepalive_timer); - } else { - tsch_schedule_keepalive(); - } + tsch_schedule_keepalive(0); } /*---------------------------------------------------------------------------*/ void @@ -240,6 +236,7 @@ tsch_reset(void) } #endif /* TSCH_AUTOSELECT_TIME_SOURCE */ tsch_set_eb_period(TSCH_EB_PERIOD); + keepalive_status = KEEPALIVE_SCHEDULING_UNCHANGED; } /* TSCH keep-alive functions */ @@ -275,7 +272,7 @@ resynchronize(const linkaddr_t *original_time_source_addr) tsch_queue_update_time_source(&last_eb_nbr_addr); tsch_join_priority = last_eb_nbr_jp + 1; /* Try to get in sync ASAP */ - tsch_schedule_keepalive_immediately(); + tsch_schedule_keepalive(1); return 1; } } @@ -302,7 +299,7 @@ keepalive_packet_sent(void *ptr, int status, int transmissions) } if(schedule_next_keepalive) { - tsch_schedule_keepalive(); + tsch_schedule_keepalive(0); } } /*---------------------------------------------------------------------------*/ @@ -310,6 +307,9 @@ keepalive_packet_sent(void *ptr, int status, int transmissions) static void keepalive_send(void *ptr) { + /* If not here from a timer callback, the timer must be stopped */ + ctimer_stop(&keepalive_timer); + if(tsch_is_associated) { struct tsch_neighbor *n = tsch_queue_get_time_source(); if(n != NULL) { @@ -326,25 +326,58 @@ keepalive_send(void *ptr) } } /*---------------------------------------------------------------------------*/ -/* Set ctimer to send a keepalive message after expiration of TSCH_KEEPALIVE_TIMEOUT */ void -tsch_schedule_keepalive(void) +tsch_schedule_keepalive(int immediate) { - /* Pick a delay in the range [tsch_current_ka_timeout*0.9, tsch_current_ka_timeout[ */ - if(!tsch_is_coordinator && tsch_is_associated && tsch_current_ka_timeout > 0) { - unsigned long delay = (tsch_current_ka_timeout - tsch_current_ka_timeout / 10) - + random_rand() % (tsch_current_ka_timeout / 10); - ctimer_set(&keepalive_timer, delay, keepalive_send, NULL); + if(immediate) { + /* send as soon as possible */ + keepalive_status = KEEPALIVE_SEND_IMMEDIATELY; + } else if(keepalive_status != KEEPALIVE_SEND_IMMEDIATELY) { + /* send based on the tsch_current_ka_timeout */ + keepalive_status = KEEPALIVE_SCHEDULE_OR_STOP; } + process_poll(&tsch_pending_events_process); } /*---------------------------------------------------------------------------*/ -/* Set ctimer to send a keepalive message immediately */ -void -tsch_schedule_keepalive_immediately(void) +static void +tsch_keepalive_process_pending(void) { - /* Pick a delay in the range [tsch_current_ka_timeout*0.9, tsch_current_ka_timeout[ */ - if(!tsch_is_coordinator && tsch_is_associated) { - ctimer_set(&keepalive_timer, 0, keepalive_send, NULL); + if(keepalive_status != KEEPALIVE_SCHEDULING_UNCHANGED) { + /* first, save and reset the old status */ + enum tsch_keepalive_status scheduled_status = keepalive_status; + keepalive_status = KEEPALIVE_SCHEDULING_UNCHANGED; + + if(!tsch_is_coordinator && tsch_is_associated) { + switch(scheduled_status) { + case KEEPALIVE_SEND_IMMEDIATELY: + /* always send, and as soon as possible (now) */ + keepalive_send(NULL); + break; + + case KEEPALIVE_SCHEDULE_OR_STOP: + if(tsch_current_ka_timeout > 0) { + /* Pick a delay in the range [tsch_current_ka_timeout*0.9, tsch_current_ka_timeout[ */ + unsigned long delay; + if(tsch_current_ka_timeout >= 10) { + delay = (tsch_current_ka_timeout - tsch_current_ka_timeout / 10) + + random_rand() % (tsch_current_ka_timeout / 10); + } else { + delay = tsch_current_ka_timeout - 1; + } + ctimer_set(&keepalive_timer, delay, keepalive_send, NULL); + } else { + /* zero timeout set, stop sending keepalives */ + ctimer_stop(&keepalive_timer); + } + break; + + default: + break; + } + } else { + /* either coordinator or not associated */ + ctimer_stop(&keepalive_timer); + } } } /*---------------------------------------------------------------------------*/ @@ -535,6 +568,7 @@ tsch_disassociate(void) { if(tsch_is_associated == 1) { tsch_is_associated = 0; + tsch_adaptive_timesync_reset(); process_poll(&tsch_process); } } @@ -550,7 +584,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp) if(input_eb == NULL || tsch_packet_parse_eb(input_eb->payload, input_eb->len, &frame, &ies, &hdrlen, 0) == 0) { - LOG_ERR("! failed to parse EB (len %u)\n", input_eb->len); + LOG_DBG("! failed to parse EB (len %u)\n", input_eb->len); return 0; } @@ -686,7 +720,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp) max_drift_seen = 0; /* Start sending keep-alives now that tsch_is_associated is set */ - tsch_schedule_keepalive(); + tsch_schedule_keepalive(0); #ifdef TSCH_CALLBACK_JOINING_NETWORK TSCH_CALLBACK_JOINING_NETWORK(); @@ -769,21 +803,23 @@ PT_THREAD(tsch_scan(struct pt *pt)) /* Read packet */ input_eb.len = NETSTACK_RADIO.read(input_eb.payload, TSCH_PACKET_MAX_LEN); - /* Save packet timestamp */ - NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &t0, sizeof(rtimer_clock_t)); - t1 = RTIMER_NOW(); - - /* Parse EB and attempt to associate */ - LOG_INFO("scan: received packet (%u bytes) on channel %u\n", input_eb.len, current_channel); - - /* Sanity-check the timestamp */ - if(ABS(RTIMER_CLOCK_DIFF(t0, t1)) < tsch_timing[tsch_ts_timeslot_length]) { - tsch_associate(&input_eb, t0); - } else { - LOG_WARN("scan: dropping packet, timestamp too far from current time %u %u\n", - (unsigned)t0, - (unsigned)t1 - ); + if(input_eb.len > 0) { + /* Save packet timestamp */ + NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &t0, sizeof(rtimer_clock_t)); + t1 = RTIMER_NOW(); + + /* Parse EB and attempt to associate */ + LOG_INFO("scan: received packet (%u bytes) on channel %u\n", input_eb.len, current_channel); + + /* Sanity-check the timestamp */ + if(ABS(RTIMER_CLOCK_DIFF(t0, t1)) < 2ul * RTIMER_SECOND) { + tsch_associate(&input_eb, t0); + } else { + LOG_WARN("scan: dropping packet, timestamp too far from current time %u %u\n", + (unsigned)t0, + (unsigned)t1 + ); + } } } @@ -854,7 +890,7 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) /* Set an initial delay except for coordinator, which should send an EB asap */ if(!tsch_is_coordinator) { - etimer_set(&eb_timer, random_rand() % TSCH_EB_PERIOD); + etimer_set(&eb_timer, TSCH_EB_PERIOD ? random_rand() % TSCH_EB_PERIOD : 0); PROCESS_WAIT_UNTIL(etimer_expired(&eb_timer)); } @@ -866,6 +902,8 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) /* Implementation section 6.3 of RFC 8180 */ && TSCH_RPL_CHECK_DODAG_JOINED() #endif /* TSCH_RPL_CHECK_DODAG_JOINED */ + /* don't send when in leaf mode */ + && !NETSTACK_ROUTING.is_in_leaf_mode() ) { /* Enqueue EB only if there isn't already one in queue */ if(tsch_queue_packet_count(&tsch_eb_address) == 0) { @@ -911,6 +949,7 @@ PROCESS_THREAD(tsch_pending_events_process, ev, data) tsch_rx_process_pending(); tsch_tx_process_pending(); tsch_log_process_pending(); + tsch_keepalive_process_pending(); #ifdef TSCH_CALLBACK_SELECT_CHANNELS TSCH_CALLBACK_SELECT_CHANNELS(); #endif @@ -926,6 +965,8 @@ tsch_init(void) { radio_value_t radio_rx_mode; radio_value_t radio_tx_mode; + radio_value_t radio_max_payload_len; + rtimer_clock_t t; /* Check that the platform provides a TSCH timeslot timing template */ @@ -934,6 +975,12 @@ tsch_init(void) return; } + /* Check that the radio can correctly report its max supported payload */ + if(NETSTACK_RADIO.get_value(RADIO_CONST_MAX_PAYLOAD_LEN, &radio_max_payload_len) != RADIO_RESULT_OK) { + LOG_ERR("! radio does not support getting RADIO_CONST_MAX_PAYLOAD_LEN. Abort init.\n"); + return; + } + /* Radio Rx mode */ if(NETSTACK_RADIO.get_value(RADIO_PARAM_RX_MODE, &radio_rx_mode) != RADIO_RESULT_OK) { LOG_ERR("! radio does not support getting RADIO_PARAM_RX_MODE. Abort init.\n"); @@ -1043,12 +1090,7 @@ send_packet(mac_callback_t sent, void *ptr) packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_DATAFRAME); #if LLSEC802154_ENABLED - if(tsch_is_pan_secured) { - /* Set security level, key id and index */ - packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, TSCH_SECURITY_KEY_SEC_LEVEL_OTHER); - packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, FRAME802154_1_BYTE_KEY_ID_MODE); /* Use 1-byte key index */ - packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, TSCH_SECURITY_KEY_INDEX_OTHER); - } + tsch_security_set_packetbuf_attr(FRAME802154_DATAFRAME); #endif /* LLSEC802154_ENABLED */ #if !NETSTACK_CONF_BRIDGE_MODE @@ -1159,8 +1201,30 @@ turn_off(void) static int max_payload(void) { + int framer_hdrlen; + radio_value_t max_radio_payload_len; + radio_result_t res; + + res = NETSTACK_RADIO.get_value(RADIO_CONST_MAX_PAYLOAD_LEN, + &max_radio_payload_len); + + if(res == RADIO_RESULT_NOT_SUPPORTED) { + LOG_ERR("Failed to retrieve max radio driver payload length\n"); + return 0; + } + + /* Set packetbuf security attributes */ + tsch_security_set_packetbuf_attr(FRAME802154_DATAFRAME); + + framer_hdrlen = NETSTACK_FRAMER.length(); + if(framer_hdrlen < 0) { + return 0; + } + /* Setup security... before. */ - return TSCH_PACKET_MAX_LEN - NETSTACK_FRAMER.length(); + return MIN(max_radio_payload_len, TSCH_PACKET_MAX_LEN) + - framer_hdrlen + - LLSEC802154_PACKETBUF_MIC_LEN(); } /*---------------------------------------------------------------------------*/ const struct mac_driver tschmac_driver = { diff --git a/os/net/mac/tsch/tsch.h b/os/net/mac/tsch/tsch.h index 6991c08c44bc0a5e74ad471d0418d431ec629cbf..1738a629adf96b340f6d66c8ba9a358190064b77 100644 --- a/os/net/mac/tsch/tsch.h +++ b/os/net/mac/tsch/tsch.h @@ -140,7 +140,7 @@ void TSCH_CALLBACK_NEW_TIME_SOURCE(const struct tsch_neighbor *old, const struct /* Called by TSCH every time a packet is ready to be added to the send queue */ #ifdef TSCH_CALLBACK_PACKET_READY -void TSCH_CALLBACK_PACKET_READY(void); +int TSCH_CALLBACK_PACKET_READY(void); #endif /***** External Variables *****/ @@ -205,8 +205,8 @@ void tsch_set_eb_period(uint32_t period); /** * Set the desynchronization timeout after which a node sends a unicasst * keep-alive (KA) to its time source. Set to 0 to stop sending KAs. The - * actual timeout is a random number within - * [timeout*0.9, timeout[ + * actual timeout is a random number within [timeout*0.9, timeout[ + * Can be called from an interrupt. * * \param timeout The timeout in Clock ticks. */ @@ -228,13 +228,12 @@ void tsch_set_coordinator(int enable); void tsch_set_pan_secured(int enable); /** * Schedule a keep-alive transmission within [timeout*0.9, timeout[ + * Can be called from an interrupt. * @see tsch_set_ka_timeout + * + * \param immediate send immediately when 1, schedule using current timeout when 0 */ -void tsch_schedule_keepalive(void); -/** - * Schedule a keep-alive immediately - */ -void tsch_schedule_keepalive_immediately(void); +void tsch_schedule_keepalive(int immediate); /** * Get the time, in clock ticks, since the TSCH network was started. * diff --git a/os/net/netstack.h b/os/net/netstack.h index dcfc1d344481480fec5892a5a4d93151972fb602..941bbfeb2ae2647abf70c46ce494c00395ef6581 100644 --- a/os/net/netstack.h +++ b/os/net/netstack.h @@ -96,8 +96,6 @@ #define NETSTACK_RADIO NETSTACK_CONF_RADIO #else /* NETSTACK_CONF_RADIO */ #define NETSTACK_RADIO nullradio_driver -/* for nullradio, allow unlimited packet size */ -#define nullradio_driver_max_payload_len ((unsigned short)-1) #endif /* NETSTACK_CONF_RADIO */ /* Framer selection. The framer is used by the MAC implementation @@ -108,12 +106,6 @@ #define NETSTACK_FRAMER framer_802154 #endif /* NETSTACK_CONF_FRAMER */ -/* Maximal packet length. Each radio driver should define this. - When Contiki-NG is compiled for a specific platform (radio), that value is used. */ -#define NETSTACK_RADIO_MAX_PAYLOAD_LEN_XX(radio) radio##_max_payload_len -#define NETSTACK_RADIO_MAX_PAYLOAD_LEN_X(radio) NETSTACK_RADIO_MAX_PAYLOAD_LEN_XX(radio) -#define NETSTACK_RADIO_MAX_PAYLOAD_LEN NETSTACK_RADIO_MAX_PAYLOAD_LEN_X(NETSTACK_RADIO) - #include "net/mac/mac.h" #include "net/mac/framer/framer.h" #include "dev/radio.h" diff --git a/os/net/packetbuf.h b/os/net/packetbuf.h index c077ae940b65ae6fcdee23ec56bdeaa852b887ec..efdd5b3eafbc4c9fb457d7cb57abd090dd7f11d7 100644 --- a/os/net/packetbuf.h +++ b/os/net/packetbuf.h @@ -227,6 +227,7 @@ enum { #if TSCH_WITH_LINK_SELECTOR PACKETBUF_ATTR_TSCH_SLOTFRAME, PACKETBUF_ATTR_TSCH_TIMESLOT, + PACKETBUF_ATTR_TSCH_CHANNEL_OFFSET, #endif /* TSCH_WITH_LINK_SELECTOR */ /* Scope 1 attributes: used between two neighbors only. */ diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index aeb6550ac8b5894a3aec8186739c411adb3f7146..7bae64066e5508f625c57368e4888f3c53c9c327 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -152,6 +152,12 @@ drop_route(uip_ds6_route_t *route) { } /*---------------------------------------------------------------------------*/ +static uint8_t +is_in_leaf_mode(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { "nullrouting", init, @@ -173,6 +179,7 @@ const struct routing_driver nullrouting_driver = { link_callback, neighbor_state_changed, drop_route, + is_in_leaf_mode, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index 89e486711506746cbb88ba1a998e8006d83caa23..a5b05755230e9d7d149f23b87be312bdfd7fd17e 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -182,6 +182,12 @@ struct routing_driver { * \param route The route that will be dropped after this function returns */ void (* drop_route)(uip_ds6_route_t *route); + /** + * Tells whether the protocol is in leaf mode + * + * \retval 1 if the protocol is in leaf mode, 0 if not. + */ + uint8_t (* is_in_leaf_mode)(void); }; #endif /* ROUTING_H_ */ diff --git a/os/net/routing/rpl-classic/rpl-conf.h b/os/net/routing/rpl-classic/rpl-conf.h index 76fda227167973779af3d5b874841d1e895218ab..5f2e7915fe81fc75352f904a05f17515df4326b7 100644 --- a/os/net/routing/rpl-classic/rpl-conf.h +++ b/os/net/routing/rpl-classic/rpl-conf.h @@ -91,17 +91,6 @@ #define RPL_CONF_STATS 0 #endif /* RPL_CONF_STATS */ -/* Set to 1 to drop packets when a forwarding loop is detected - * on a packet that already had an error signaled, as per RFC6550 - 11.2.2.2. - * Disabled by default for more reliability: even in the event of a loop, - * packets get a chance to eventually find their way to the destination. */ -#ifdef RPL_CONF_LOOP_ERROR_DROP -#define RPL_LOOP_ERROR_DROP RPL_CONF_LOOP_ERROR_DROP -#else /* RPL_CONF_LOOP_ERROR_DROP */ -#define RPL_LOOP_ERROR_DROP 0 -#endif /* RPL_CONF_LOOP_ERROR_DROP */ - - /* * The objective function (OF) used by a RPL root is configurable through * the RPL_CONF_OF_OCP parameter. This is defined as the objective code diff --git a/os/net/routing/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c index e1a4042d2ce12421b248077ccc67222aaa1256ec..111cae4b2b72c5384ea73492afbf2d1c41a50633 100644 --- a/os/net/routing/rpl-classic/rpl-dag.c +++ b/os/net/routing/rpl-classic/rpl-dag.c @@ -1011,10 +1011,25 @@ rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent) parent->dag = dag_dst; } /*---------------------------------------------------------------------------*/ +static rpl_dag_t * +rpl_get_any_dag_with_parent(bool requires_parent) +{ + int i; + + for(i = 0; i < RPL_MAX_INSTANCES; ++i) { + if(instance_table[i].used + && instance_table[i].current_dag->joined + && (!requires_parent || instance_table[i].current_dag->preferred_parent != NULL)) { + return instance_table[i].current_dag; + } + } + return NULL; +} +/*---------------------------------------------------------------------------*/ int rpl_has_joined(void) { - return rpl_get_any_dag() != NULL; + return rpl_get_any_dag_with_parent(true) != NULL; } /*---------------------------------------------------------------------------*/ int @@ -1054,14 +1069,7 @@ rpl_get_dag(const uip_ipaddr_t *addr) rpl_dag_t * rpl_get_any_dag(void) { - int i; - - for(i = 0; i < RPL_MAX_INSTANCES; ++i) { - if(instance_table[i].used && instance_table[i].current_dag->joined) { - return instance_table[i].current_dag; - } - } - return NULL; + return rpl_get_any_dag_with_parent(false); } /*---------------------------------------------------------------------------*/ rpl_instance_t * diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 1778329b9aa611098906ccb29956412b74ff3cd1..a254a8c399f1031ac4bab827026d212c5d60f024 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -423,6 +423,18 @@ get_root_ipaddr(uip_ipaddr_t *ipaddr) return 0; } /*---------------------------------------------------------------------------*/ +uint8_t +rpl_is_in_leaf_mode(void) +{ + /* + * Confusingly, most of the RPL code uses the `rpl_mode` variable + * ony to check whether the node is in mesh or feather mode, + * and makes decision about the leaf status based on the preprocessor flag. + * For consistency, do the same here. + */ + return RPL_LEAF_ONLY ? 1 : 0; +} +/*---------------------------------------------------------------------------*/ const struct routing_driver rpl_classic_driver = { "RPL Classic", init, @@ -444,6 +456,7 @@ const struct routing_driver rpl_classic_driver = { rpl_link_callback, rpl_ipv6_neighbor_callback, drop_route, + rpl_is_in_leaf_mode, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-classic/rpl.h b/os/net/routing/rpl-classic/rpl.h index 34d0269788056f21e4e51cc1f67d4c8c04ae7e92..c897771d1171f26d6c76fb0ade71cbb3ea8ab52f 100644 --- a/os/net/routing/rpl-classic/rpl.h +++ b/os/net/routing/rpl-classic/rpl.h @@ -341,5 +341,12 @@ int rpl_has_joined(void); */ int rpl_has_downward_route(void); +/** + * Tells whether the protocol is in leaf mode + * + * \retval 1 if the protocol is in leaf mode, 0 if not. + */ +uint8_t rpl_is_in_leaf_mode(void); + /*---------------------------------------------------------------------------*/ #endif /* RPL_H */ diff --git a/os/net/routing/rpl-lite/rpl-conf.h b/os/net/routing/rpl-lite/rpl-conf.h index 5d674fa9672b09def2d23c424605e9251867d487..8a1fbdfa03a7b2fb196773efb122b1874ff64360 100644 --- a/os/net/routing/rpl-lite/rpl-conf.h +++ b/os/net/routing/rpl-lite/rpl-conf.h @@ -396,6 +396,16 @@ #endif /* MAC_CONF_WITH_TSCH */ +/* Set to 1 to drop packets when a forwarding loop is detected + * on a packet that already had an error signaled, as per RFC6550 - 11.2.2.2. + * Disabled by default for more reliability: even in the event of a loop, + * packets get a chance to eventually find their way to the destination. */ +#ifdef RPL_CONF_LOOP_ERROR_DROP +#define RPL_LOOP_ERROR_DROP RPL_CONF_LOOP_ERROR_DROP +#else /* RPL_CONF_LOOP_ERROR_DROP */ +#define RPL_LOOP_ERROR_DROP 0 +#endif /* RPL_CONF_LOOP_ERROR_DROP */ + /** @} */ #endif /* RPL_CONF_H */ diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index 5ec080c15e66cbfa76f4d1628fa226ef619970d0..ac9e304ea9d18ce9ad0004bd4687faefa3dcfe89 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -55,7 +55,7 @@ /*---------------------------------------------------------------------------*/ extern rpl_of_t rpl_of0, rpl_mrhof; static rpl_of_t * const objective_functions[] = RPL_SUPPORTED_OFS; -static int init_dag_from_dio(rpl_dio_t *dio); +static int process_dio_init_dag(rpl_dio_t *dio); /*---------------------------------------------------------------------------*/ /* Allocate instance table. */ @@ -111,7 +111,7 @@ rpl_dag_leave(void) /* Forget past link statistics */ link_stats_reset(); - /* Remove all neighbors and lnks */ + /* Remove all neighbors, links and default route */ rpl_neighbor_remove_all(); uip_sr_free_all(); @@ -229,7 +229,9 @@ global_repair_non_root(rpl_dio_t *dio) } /* Re-initialize configuration from DIO */ rpl_timers_stop_dag_timers(); - init_dag_from_dio(dio); + rpl_neighbor_set_preferred_parent(NULL); + /* This will both re-init the DAG and schedule required timers */ + process_dio_init_dag(dio); rpl_local_repair("Global repair"); } } @@ -324,7 +326,7 @@ rpl_dag_update_state(void) } /* Parent switch */ - if(curr_instance.dag.preferred_parent != old_parent) { + if(curr_instance.dag.unprocessed_parent_switch) { /* We just got a parent (was NULL), reset trickle timer to advertise this */ if(old_parent == NULL) { curr_instance.dag.state = DAG_JOINED; @@ -350,6 +352,9 @@ rpl_dag_update_state(void) if(LOG_INFO_ENABLED) { rpl_neighbor_print_list("Parent switch"); } + + /* Clear unprocessed_parent_switch now that we have processed it */ + curr_instance.dag.unprocessed_parent_switch = false; } } @@ -446,10 +451,10 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) return; } - /* Add neighbor to RPL neighbor table */ nbr = rpl_neighbor_get_from_ipaddr(from); last_dtsn = nbr != NULL ? nbr->dtsn : RPL_LOLLIPOP_INIT; + /* Add neighbor to RPL neighbor table */ if(!update_nbr_from_dio(from, dio)) { LOG_ERR("neighbor table full, dropping DIO\n"); return; @@ -540,13 +545,14 @@ init_dag_from_dio(rpl_dio_t *dio) curr_instance.dag.preference = dio->preference; curr_instance.dag.grounded = dio->grounded; curr_instance.dag.version = dio->version; - curr_instance.dag.dio_intcurrent = dio->dag_intmin; + /* dio_intcurrent will be reset by rpl_timers_dio_reset() */ + curr_instance.dag.dio_intcurrent = 0; return 1; } /*---------------------------------------------------------------------------*/ static int -process_dio_init_dag(uip_ipaddr_t *from, rpl_dio_t *dio) +process_dio_init_dag(rpl_dio_t *dio) { #ifdef RPL_VALIDATE_DIO_FUNC if(!RPL_VALIDATE_DIO_FUNC(dio)) { @@ -595,7 +601,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio) { if(!curr_instance.used && !rpl_dag_root_is_root()) { /* Attempt to init our DAG from this DIO */ - if(!process_dio_init_dag(from, dio)) { + if(!process_dio_init_dag(dio)) { LOG_WARN("failed to init DAG\n"); return; } @@ -738,7 +744,8 @@ rpl_dag_init_root(uint8_t instance_id, uip_ipaddr_t *dag_id, curr_instance.dag.version = version; curr_instance.dag.rank = ROOT_RANK; curr_instance.dag.lifetime = RPL_LIFETIME(RPL_INFINITE_LIFETIME); - curr_instance.dag.dio_intcurrent = RPL_DIO_INTERVAL_MIN; + /* dio_intcurrent will be reset by rpl_timers_dio_reset() */ + curr_instance.dag.dio_intcurrent = 0; curr_instance.dag.state = DAG_REACHABLE; rpl_timers_dio_reset("Init root"); diff --git a/os/net/routing/rpl-lite/rpl-neighbor.c b/os/net/routing/rpl-lite/rpl-neighbor.c index 6d33e7be3dbdbe04a71290b80c6c6c5bdc5b52fc..2f8280cfb54defda20c35a4c37086dbc9cf8af12 100644 --- a/os/net/routing/rpl-lite/rpl-neighbor.c +++ b/os/net/routing/rpl-lite/rpl-neighbor.c @@ -317,10 +317,11 @@ rpl_neighbor_set_preferred_parent(rpl_nbr_t *nbr) uip_ds6_defrt_add(rpl_neighbor_get_ipaddr(nbr), 0); curr_instance.dag.preferred_parent = nbr; + curr_instance.dag.unprocessed_parent_switch = true; } } /*---------------------------------------------------------------------------*/ -/* Remove DAG neighbors with a rank that is at least the same as minimum_rank. */ +/* Remove all DAG neighbors */ void rpl_neighbor_remove_all(void) { @@ -328,14 +329,19 @@ rpl_neighbor_remove_all(void) LOG_INFO("removing all neighbors\n"); + /* Unset preferred parent before we de-allocate it. This will set + * unprocessed_parent_switch which will make sure rpl_dag_update_state takes + * all actions necessary after losing the preferred parent */ + rpl_neighbor_set_preferred_parent(NULL); + nbr = nbr_table_head(rpl_neighbors); while(nbr != NULL) { remove_neighbor(nbr); nbr = nbr_table_next(rpl_neighbors, nbr); } - /* Update needed immediately so as to ensure preferred_parent becomes NULL, - * and no longer points to a de-allocated neighbor. */ + /* Update needed immediately. As we have lost the preferred parent this will + * enter poisoining and set timers accordingly. */ rpl_dag_update_state(); } /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl-timers.c b/os/net/routing/rpl-lite/rpl-timers.c index 169226fd5c4c156df73c9b469f7c07c0001b58a6..8f6c842b4915add6cd2daee465fedd81aa57ce4c 100644 --- a/os/net/routing/rpl-lite/rpl-timers.c +++ b/os/net/routing/rpl-lite/rpl-timers.c @@ -149,7 +149,13 @@ new_dio_interval(void) void rpl_timers_dio_reset(const char *str) { - if(rpl_dag_ready_to_advertise()) { + if(rpl_dag_ready_to_advertise() && + (curr_instance.dag.dio_intcurrent == 0 || + curr_instance.dag.dio_intcurrent > curr_instance.dio_intmin)) { + /* + * don't reset the DIO timer if the current interval is Imin; see + * Section 4.2, RFC 6206. + */ LOG_INFO("reset DIO timer (%s)\n", str); if(!rpl_get_leaf_only()) { curr_instance.dag.dio_counter = 0; diff --git a/os/net/routing/rpl-lite/rpl-types.h b/os/net/routing/rpl-lite/rpl-types.h index 2c57bf664dc83d88a037fad91d07c88113f9fc6f..c39e12a0195e5abdc7325960956c4dd45ec93ac8 100644 --- a/os/net/routing/rpl-lite/rpl-types.h +++ b/os/net/routing/rpl-lite/rpl-types.h @@ -199,6 +199,7 @@ struct rpl_dag { uint8_t dao_last_seqno; /* the node's last sent DAO seqno */ uint8_t dao_last_acked_seqno; /* the last seqno we got an ACK for */ uint8_t dao_transmissions; /* the number of transmissions for the current DAO */ + bool unprocessed_parent_switch; enum rpl_dag_state state; /* Timers */ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 681b85d9ee8e99ff4f62c70b11d68c16a81b6f85..bf7ef2de840f21ccec3da1ac50cf13e7538042bf 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -264,6 +264,7 @@ const struct routing_driver rpl_lite_driver = { rpl_link_callback, neighbor_state_changed, drop_route, + rpl_get_leaf_only, }; /*---------------------------------------------------------------------------*/ diff --git a/os/services/orchestra/orchestra-conf.h b/os/services/orchestra/orchestra-conf.h index a23b31f9b67804fbca8c06bbe7be9f736f393bc0..ac29122e0267c092104475755a9db613f1cac4e6 100644 --- a/os/services/orchestra/orchestra-conf.h +++ b/os/services/orchestra/orchestra-conf.h @@ -81,7 +81,8 @@ #define ORCHESTRA_UNICAST_SENDER_BASED 0 #endif /* ORCHESTRA_CONF_UNICAST_SENDER_BASED */ -/* The hash function used to assign timeslot to a given node (based on its link-layer address) */ +/* The hash function used to assign timeslot to a given node (based on its link-layer address). + * For rules with multiple channel offsets, it is also used to select the channel offset. */ #ifdef ORCHESTRA_CONF_LINKADDR_HASH #define ORCHESTRA_LINKADDR_HASH ORCHESTRA_CONF_LINKADDR_HASH #else /* ORCHESTRA_CONF_LINKADDR_HASH */ @@ -102,4 +103,32 @@ #define ORCHESTRA_COLLISION_FREE_HASH 0 /* Set to 1 if ORCHESTRA_LINKADDR_HASH returns unique hashes */ #endif /* ORCHESTRA_CONF_COLLISION_FREE_HASH */ +/* Channel offset for the EB rule, default 0 */ +#ifdef ORCHESTRA_CONF_EB_CHANNEL_OFFSET +#define ORCHESTRA_EB_CHANNEL_OFFSET ORCHESTRA_CONF_EB_CHANNEL_OFFSET +#else +#define ORCHESTRA_EB_CHANNEL_OFFSET 0 +#endif + +/* Channel offset for the default common rule, default 1 */ +#ifdef ORCHESTRA_CONF_DEFAULT_COMMON_CHANNEL_OFFSET +#define ORCHESTRA_DEFAULT_COMMON_CHANNEL_OFFSET ORCHESTRA_CONF_DEFAULT_COMMON_CHANNEL_OFFSET +#else +#define ORCHESTRA_DEFAULT_COMMON_CHANNEL_OFFSET 1 +#endif + +/* Min channel offset for the unicast rules; the default min/max range is [2, 255] */ +#ifdef ORCHESTRA_CONF_UNICAST_MIN_CHANNEL_OFFSET +#define ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET ORCHESTRA_CONF_UNICAST_MIN_CHANNEL_OFFSET +#else +#define ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET 2 +#endif + +/* Max channel offset for the unicast rules */ +#ifdef ORCHESTRA_CONF_UNICAST_MAX_CHANNEL_OFFSET +#define ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET ORCHESTRA_CONF_UNICAST_MAX_CHANNEL_OFFSET +#else +#define ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET 255 +#endif + #endif /* __ORCHESTRA_CONF_H__ */ diff --git a/os/services/orchestra/orchestra-rule-default-common.c b/os/services/orchestra/orchestra-rule-default-common.c index 49ac3b496bb2ad0886873fd3b79908cef5874418..2dffe44e0ead640a1925849cd932a5fb86950ec8 100644 --- a/os/services/orchestra/orchestra-rule-default-common.c +++ b/os/services/orchestra/orchestra-rule-default-common.c @@ -39,7 +39,6 @@ #include "orchestra.h" static uint16_t slotframe_handle = 0; -static uint16_t channel_offset = 0; #if ORCHESTRA_EBSF_PERIOD > 0 /* There is a slotframe for EBs, use this slotframe for non-EB traffic only */ @@ -51,7 +50,7 @@ static uint16_t channel_offset = 0; /*---------------------------------------------------------------------------*/ static int -select_packet(uint16_t *slotframe, uint16_t *timeslot) +select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset) { /* We are the default slotframe, select anything */ if(slotframe != NULL) { @@ -67,14 +66,13 @@ static void init(uint16_t sf_handle) { slotframe_handle = sf_handle; - channel_offset = slotframe_handle; /* Default slotframe: for broadcast or unicast to neighbors we * do not have a link to */ struct tsch_slotframe *sf_common = tsch_schedule_add_slotframe(slotframe_handle, ORCHESTRA_COMMON_SHARED_PERIOD); tsch_schedule_add_link(sf_common, LINK_OPTION_RX | LINK_OPTION_TX | LINK_OPTION_SHARED, ORCHESTRA_COMMON_SHARED_TYPE, &tsch_broadcast_address, - 0, channel_offset); + 0, ORCHESTRA_DEFAULT_COMMON_CHANNEL_OFFSET); } /*---------------------------------------------------------------------------*/ struct orchestra_rule default_common = { @@ -83,4 +81,5 @@ struct orchestra_rule default_common = { select_packet, NULL, NULL, + "default common", }; diff --git a/os/services/orchestra/orchestra-rule-eb-per-time-source.c b/os/services/orchestra/orchestra-rule-eb-per-time-source.c index ed037291ba79092fb195c1ce69d4040bcfc632f7..2539f77e6da05c2b8ff8879668cc547b70d3b536 100644 --- a/os/services/orchestra/orchestra-rule-eb-per-time-source.c +++ b/os/services/orchestra/orchestra-rule-eb-per-time-source.c @@ -56,7 +56,7 @@ get_node_timeslot(const linkaddr_t *addr) } /*---------------------------------------------------------------------------*/ static int -select_packet(uint16_t *slotframe, uint16_t *timeslot) +select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset) { /* Select EBs only */ if(packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE) == FRAME802154_BEACONFRAME) { @@ -86,7 +86,7 @@ new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new if(old_ts == get_node_timeslot(&linkaddr_node_addr)) { /* This was the same timeslot as slot. Reset original link options */ tsch_schedule_add_link(sf_eb, LINK_OPTION_TX, LINK_TYPE_ADVERTISING_ONLY, - &tsch_broadcast_address, old_ts, 0); + &tsch_broadcast_address, old_ts, ORCHESTRA_EB_CHANNEL_OFFSET); } else { /* Remove slot */ tsch_schedule_remove_link_by_timeslot(sf_eb, old_ts); @@ -100,7 +100,7 @@ new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new } /* Listen to the time source's EBs */ tsch_schedule_add_link(sf_eb, link_options, LINK_TYPE_ADVERTISING_ONLY, - &tsch_broadcast_address, new_ts, 0); + &tsch_broadcast_address, new_ts, ORCHESTRA_EB_CHANNEL_OFFSET); } } /*---------------------------------------------------------------------------*/ @@ -114,7 +114,7 @@ init(uint16_t sf_handle) tsch_schedule_add_link(sf_eb, LINK_OPTION_TX, LINK_TYPE_ADVERTISING_ONLY, &tsch_broadcast_address, - get_node_timeslot(&linkaddr_node_addr), 0); + get_node_timeslot(&linkaddr_node_addr), ORCHESTRA_EB_CHANNEL_OFFSET); } /*---------------------------------------------------------------------------*/ struct orchestra_rule eb_per_time_source = { @@ -123,4 +123,5 @@ struct orchestra_rule eb_per_time_source = { select_packet, NULL, NULL, + "EB per time source", }; diff --git a/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-ns.c b/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-ns.c index d72646e1d083d45f8da6cff3b7a9e6f05a90f06e..32c2b272c978e6a5476cb5c66f09d32581afdbc2 100644 --- a/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-ns.c +++ b/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-ns.c @@ -44,7 +44,6 @@ #include "net/packetbuf.h" static uint16_t slotframe_handle = 0; -static uint16_t channel_offset = 0; static struct tsch_slotframe *sf_unicast; /*---------------------------------------------------------------------------*/ @@ -58,6 +57,17 @@ get_node_timeslot(const linkaddr_t *addr) } } /*---------------------------------------------------------------------------*/ +static uint16_t +get_node_channel_offset(const linkaddr_t *addr) +{ + if(addr != NULL && ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET >= ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET) { + return ORCHESTRA_LINKADDR_HASH(addr) % (ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET - ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET + 1) + + ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET; + } else { + return 0xffff; + } +} +/*---------------------------------------------------------------------------*/ static void child_added(const linkaddr_t *linkaddr) { @@ -69,7 +79,7 @@ child_removed(const linkaddr_t *linkaddr) } /*---------------------------------------------------------------------------*/ static int -select_packet(uint16_t *slotframe, uint16_t *timeslot) +select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset) { /* Select data packets we have a unicast link to */ const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); @@ -81,6 +91,10 @@ select_packet(uint16_t *slotframe, uint16_t *timeslot) if(timeslot != NULL) { *timeslot = get_node_timeslot(dest); } + /* set per-packet channel offset */ + if(channel_offset != NULL) { + *channel_offset = get_node_channel_offset(dest); + } return 1; } return 0; @@ -96,17 +110,18 @@ init(uint16_t sf_handle) { int i; uint16_t rx_timeslot; + linkaddr_t *local_addr = &linkaddr_node_addr; + slotframe_handle = sf_handle; - channel_offset = sf_handle; /* Slotframe for unicast transmissions */ sf_unicast = tsch_schedule_add_slotframe(slotframe_handle, ORCHESTRA_UNICAST_PERIOD); - rx_timeslot = get_node_timeslot(&linkaddr_node_addr); + rx_timeslot = get_node_timeslot(local_addr); /* Add a Tx link at each available timeslot. Make the link Rx at our own timeslot. */ for(i = 0; i < ORCHESTRA_UNICAST_PERIOD; i++) { tsch_schedule_add_link(sf_unicast, LINK_OPTION_SHARED | LINK_OPTION_TX | ( i == rx_timeslot ? LINK_OPTION_RX : 0 ), LINK_TYPE_NORMAL, &tsch_broadcast_address, - i, channel_offset); + i, get_node_channel_offset(local_addr)); } } /*---------------------------------------------------------------------------*/ @@ -116,4 +131,5 @@ struct orchestra_rule unicast_per_neighbor_rpl_ns = { select_packet, child_added, child_removed, + "unicast per neighbor non-storing", }; diff --git a/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c b/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c index 723b9e847f2774cc24a774448e92a109227946d9..7f39758c74bb18ff1fd799041f7420c72942256b 100644 --- a/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c +++ b/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c @@ -60,7 +60,7 @@ #endif static uint16_t slotframe_handle = 0; -static uint16_t channel_offset = 0; +static uint16_t local_channnel_offset; static struct tsch_slotframe *sf_unicast; /*---------------------------------------------------------------------------*/ @@ -74,6 +74,17 @@ get_node_timeslot(const linkaddr_t *addr) } } /*---------------------------------------------------------------------------*/ +static uint16_t +get_node_channel_offset(const linkaddr_t *addr) +{ + if(addr != NULL && ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET >= ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET) { + return ORCHESTRA_LINKADDR_HASH(addr) % (ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET - ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET + 1) + + ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET; + } else { + return 0xffff; + } +} +/*---------------------------------------------------------------------------*/ static int neighbor_has_uc_link(const linkaddr_t *linkaddr) { @@ -101,9 +112,13 @@ add_uc_link(const linkaddr_t *linkaddr) link_options |= ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX; } - /* Add/update link */ + /* Add/update link. + * Always configure the link with the local node's channel offset. + * If this is an Rx link, that is what the node needs to use. + * If this is a Tx link, packet's channel offset will override the link's channel offset. + */ tsch_schedule_add_link(sf_unicast, link_options, LINK_TYPE_NORMAL, &tsch_broadcast_address, - timeslot, channel_offset); + timeslot, local_channel_offset); } } /*---------------------------------------------------------------------------*/ @@ -144,7 +159,7 @@ remove_uc_link(const linkaddr_t *linkaddr) /* This is our link, keep it but update the link options */ uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX; tsch_schedule_add_link(sf_unicast, link_options, LINK_TYPE_NORMAL, &tsch_broadcast_address, - timeslot, channel_offset); + timeslot, local_channnel_offset); } else { /* Remove link */ tsch_schedule_remove_link(sf_unicast, l); @@ -164,7 +179,7 @@ child_removed(const linkaddr_t *linkaddr) } /*---------------------------------------------------------------------------*/ static int -select_packet(uint16_t *slotframe, uint16_t *timeslot) +select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset) { /* Select data packets we have a unicast link to */ const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); @@ -176,6 +191,10 @@ select_packet(uint16_t *slotframe, uint16_t *timeslot) if(timeslot != NULL) { *timeslot = ORCHESTRA_UNICAST_SENDER_BASED ? get_node_timeslot(&linkaddr_node_addr) : get_node_timeslot(dest); } + /* set per-packet channel offset */ + if(channel_offset != NULL) { + *channel_offset = get_node_channel_offset(dest); + } return 1; } return 0; @@ -200,15 +219,18 @@ new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new static void init(uint16_t sf_handle) { + uint16_t timeslot; + linkaddr_t *local_addr = &linkaddr_node_addr; + slotframe_handle = sf_handle; - channel_offset = sf_handle; + local_channnel_offset = get_node_channel_offset(local_addr); /* Slotframe for unicast transmissions */ sf_unicast = tsch_schedule_add_slotframe(slotframe_handle, ORCHESTRA_UNICAST_PERIOD); - uint16_t timeslot = get_node_timeslot(&linkaddr_node_addr); + timeslot = get_node_timeslot(local_addr); tsch_schedule_add_link(sf_unicast, ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX, LINK_TYPE_NORMAL, &tsch_broadcast_address, - timeslot, channel_offset); + timeslot, local_channnel_offset); } /*---------------------------------------------------------------------------*/ struct orchestra_rule unicast_per_neighbor_rpl_storing = { @@ -217,6 +239,7 @@ struct orchestra_rule unicast_per_neighbor_rpl_storing = { select_packet, child_added, child_removed, + "unicast per neighbor storing", }; #endif /* UIP_MAX_ROUTES */ diff --git a/os/services/orchestra/orchestra.c b/os/services/orchestra/orchestra.c index 8b9929c03eb2a9e736c3259eb3135f9ca11bdf1c..cf28f3781121152cfb9dad547c14ca2e86fde5fa 100644 --- a/os/services/orchestra/orchestra.c +++ b/os/services/orchestra/orchestra.c @@ -45,6 +45,7 @@ #include "net/routing/rpl-lite/rpl.h" #elif ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" #endif #define DEBUG DEBUG_PRINT @@ -109,18 +110,24 @@ orchestra_callback_child_removed(const linkaddr_t *addr) } } /*---------------------------------------------------------------------------*/ -void +int orchestra_callback_packet_ready(void) { int i; /* By default, use any slotframe, any timeslot */ - uint16_t slotframe = 9; + uint16_t slotframe = 0xffff; uint16_t timeslot = 0xffff; + /* The default channel offset 0xffff means that the channel offset in the scheduled + * tsch_link structure is used instead. Any other value specified in the packetbuf + * overrides per-link value, allowing to implement multi-channel Orchestra. */ + uint16_t channel_offset = 0xffff; + int matched_rule = -1; /* Loop over all rules until finding one able to handle the packet */ for(i = 0; i < NUM_RULES; i++) { if(all_rules[i]->select_packet != NULL) { - if(all_rules[i]->select_packet(&slotframe, ×lot)) { + if(all_rules[i]->select_packet(&slotframe, ×lot, &channel_offset)) { + matched_rule = i; break; } } @@ -129,7 +136,10 @@ orchestra_callback_packet_ready(void) #if TSCH_WITH_LINK_SELECTOR packetbuf_set_attr(PACKETBUF_ATTR_TSCH_SLOTFRAME, slotframe); packetbuf_set_attr(PACKETBUF_ATTR_TSCH_TIMESLOT, timeslot); + packetbuf_set_attr(PACKETBUF_ATTR_TSCH_CHANNEL_OFFSET, channel_offset); #endif + + return matched_rule; } /*---------------------------------------------------------------------------*/ void @@ -161,8 +171,8 @@ orchestra_init(void) linkaddr_copy(&orchestra_parent_linkaddr, &linkaddr_null); /* Initialize all Orchestra rules */ for(i = 0; i < NUM_RULES; i++) { + PRINTF("Orchestra: initializing rule %s (%u)\n", all_rules[i]->name, i); if(all_rules[i]->init != NULL) { - PRINTF("Orchestra: initializing rule %u\n", i); all_rules[i]->init(i); } } diff --git a/os/services/orchestra/orchestra.h b/os/services/orchestra/orchestra.h index 32450466dbb5c3b24015b13ee60750f85eb3c4c2..1b67fdc027e4db49816fc5b2c8300f87534e25cb 100644 --- a/os/services/orchestra/orchestra.h +++ b/os/services/orchestra/orchestra.h @@ -45,9 +45,10 @@ struct orchestra_rule { void (* init)(uint16_t slotframe_handle); void (* new_time_source)(const struct tsch_neighbor *old, const struct tsch_neighbor *new); - int (* select_packet)(uint16_t *slotframe, uint16_t *timeslot); + int (* select_packet)(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset); void (* child_added)(const linkaddr_t *addr); void (* child_removed)(const linkaddr_t *addr); + const char *name; }; struct orchestra_rule eb_per_time_source; @@ -62,7 +63,7 @@ extern int orchestra_parent_knows_us; void orchestra_init(void); /* Callbacks requied for Orchestra to operate */ /* Set with #define TSCH_CALLBACK_PACKET_READY orchestra_callback_packet_ready */ -void orchestra_callback_packet_ready(void); +int orchestra_callback_packet_ready(void); /* Set with #define TSCH_CALLBACK_NEW_TIME_SOURCE orchestra_callback_new_time_source */ void orchestra_callback_new_time_source(const struct tsch_neighbor *old, const struct tsch_neighbor *new); /* Set with #define NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK orchestra_callback_child_added */ diff --git a/os/services/resolv/module-macros.h b/os/services/resolv/module-macros.h new file mode 100644 index 0000000000000000000000000000000000000000..ead36b2c54f364e288a3992bfdf7596a85a3c474 --- /dev/null +++ b/os/services/resolv/module-macros.h @@ -0,0 +1 @@ +#define BUILD_WITH_RESOLV 1 diff --git a/os/net/ipv6/resolv.c b/os/services/resolv/resolv.c similarity index 89% rename from os/net/ipv6/resolv.c rename to os/services/resolv/resolv.c index 29af2b4cf8c0d4cab01b243e79b9d9391d808c18..74d5c5208c0cfb759b66cb8c5f9fb7201f888d3b 100644 --- a/os/net/ipv6/resolv.c +++ b/os/services/resolv/resolv.c @@ -63,58 +63,23 @@ */ #include "net/ipv6/tcpip.h" -#include "net/ipv6/resolv.h" #include "net/ipv6/uip-udp-packet.h" #include "net/ipv6/uip-nameserver.h" #include "lib/random.h" - -#ifndef DEBUG -#define DEBUG CONTIKI_TARGET_COOJA -#endif +#include "resolv.h" #if UIP_UDP +#include "sys/log.h" +#define LOG_MODULE "Resolv" +#define LOG_LEVEL LOG_LEVEL_NONE + #include <string.h> #include <stdio.h> #include <ctype.h> -#ifndef NULL -#define NULL (void *)0 -#endif /* NULL */ - -#if !defined(__SDCC) && defined(SDCC_REVISION) -#define __SDCC 1 -#endif - -#if VERBOSE_DEBUG -#define DEBUG_PRINTF(...) printf(__VA_ARGS__) -#else -#define DEBUG_PRINTF(...) do { } while(0) -#endif - -#if DEBUG || VERBOSE_DEBUG -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) do { } while(0) -#endif - -#ifdef __SDCC -static int -strncasecmp(const char *s1, const char *s2, size_t n) -{ - /* TODO: Add case support! */ - return strncmp(s1, s2, n); -} -static int -strcasecmp(const char *s1, const char *s2) -{ - /* TODO: Add case support! */ - return strcmp(s1, s2); -} -#else int strcasecmp(const char *s1, const char *s2); int strncasecmp(const char *s1, const char *s2, size_t n); -#endif /* __SDCC */ /* If RESOLV_CONF_SUPPORTS_MDNS is set, then queries * for domain names in the local TLD will use mDNS as @@ -323,13 +288,13 @@ decode_name(const unsigned char *query, char *dest, unsigned char n = *query++; - //DEBUG_PRINTF("resolver: decoding name: \""); + LOG_DBG("decoding name: \""); while(len && n) { if(n & 0xc0) { const uint16_t offset = query[0] + ((n & ~0xC0) << 8); - //DEBUG_PRINTF("<skip-to-%d>",offset); + LOG_DBG("<skip-to-%d>",offset); query = packet + offset; n = *query++; } @@ -338,7 +303,7 @@ decode_name(const unsigned char *query, char *dest, break; for(; n; --n) { - //DEBUG_PRINTF("%c",*query); + LOG_DBG("%c",*query); *dest++ = *query++; @@ -351,13 +316,13 @@ decode_name(const unsigned char *query, char *dest, n = *query++; if(n) { - //DEBUG_PRINTF("."); + LOG_DBG("."); *dest++ = '.'; --len; } } - //DEBUG_PRINTF("\"\n"); + LOG_DBG("\"\n"); *dest = 0; return len != 0; } @@ -410,12 +375,12 @@ skip_name(unsigned char *query) { unsigned char n; - DEBUG_PRINTF("resolver: skip name: "); + LOG_DBG("skip name: "); do { n = *query; if(n & 0xc0) { - DEBUG_PRINTF("<skip-to-%d>", query[0] + ((n & ~0xC0) << 8)); + LOG_DBG("<skip-to-%d>", query[0] + ((n & ~0xC0) << 8)); ++query; break; } @@ -423,13 +388,13 @@ skip_name(unsigned char *query) ++query; while(n > 0) { - DEBUG_PRINTF("%c", *query); + LOG_DBG_("%c", *query); ++query; --n; }; - DEBUG_PRINTF("."); + LOG_DBG_("."); } while(*query != 0); - DEBUG_PRINTF("\n"); + LOG_DBG_("\n"); return query + 1; } /*---------------------------------------------------------------------------*/ @@ -720,7 +685,7 @@ check_entries(void) (query - (uint8_t *) uip_appdata), &resolv_mdns_addr, UIP_HTONS(MDNS_PORT)); - PRINTF("resolver: (i=%d) Sent MDNS %s for \"%s\".\n", i, + LOG_DBG("(i=%d) Sent MDNS %s for \"%s\".\n", i, namemapptr->is_probe?"probe":"request",namemapptr->name); } else { uip_udp_packet_sendto(resolv_conn, uip_appdata, @@ -729,7 +694,7 @@ check_entries(void) uip_nameserver_get(namemapptr->server), UIP_HTONS(DNS_PORT)); - PRINTF("resolver: (i=%d) Sent DNS request for \"%s\".\n", i, + LOG_DBG("(i=%d) Sent DNS request for \"%s\".\n", i, namemapptr->name); } #else /* RESOLV_CONF_SUPPORTS_MDNS */ @@ -737,7 +702,7 @@ check_entries(void) (query - (uint8_t *) uip_appdata), uip_nameserver_get(namemapptr->server), UIP_HTONS(DNS_PORT)); - PRINTF("resolver: (i=%d) Sent DNS request for \"%s\".\n", i, + LOG_DBG("(i=%d) Sent DNS request for \"%s\".\n", i, namemapptr->name); #endif /* RESOLV_CONF_SUPPORTS_MDNS */ break; @@ -774,15 +739,14 @@ newdata(void) queryptr = (unsigned char *)hdr + sizeof(*hdr); i = 0; - DEBUG_PRINTF - ("resolver: flags1=0x%02X flags2=0x%02X nquestions=%d, nanswers=%d, nauthrr=%d, nextrarr=%d\n", + LOG_DBG("flags1=0x%02X flags2=0x%02X nquestions=%d, nanswers=%d, nauthrr=%d, nextrarr=%d\n", hdr->flags1, hdr->flags2, (uint8_t) nquestions, (uint8_t) nanswers, (uint8_t) uip_ntohs(hdr->numauthrr), (uint8_t) uip_ntohs(hdr->numextrarr)); if(is_request && (nquestions == 0)) { /* Skip requests with no questions. */ - DEBUG_PRINTF("resolver: Skipping request with no questions.\n"); + LOG_DBG("Skipping request with no questions.\n"); return; } @@ -810,7 +774,7 @@ newdata(void) question = &aligned; #endif /* !ARCH_DOESNT_NEED_ALIGNED_STRUCTS */ - DEBUG_PRINTF("resolver: Question %d: type=%d class=%d\n", ++i, + LOG_DBG("Question %d: type=%d class=%d\n", ++i, uip_htons(question->type), uip_htons(question->class)); if(((uip_ntohs(question->class) & 0x7FFF) != DNS_CLASS_IN) || @@ -824,7 +788,7 @@ newdata(void) continue; } - PRINTF("resolver: THIS IS A REQUEST FOR US!!!\n"); + LOG_DBG("THIS IS A REQUEST FOR US!!!\n"); if(mdns_state == MDNS_STATE_READY) { /* We only send immediately if this isn't an MDNS request. @@ -841,7 +805,7 @@ newdata(void) return; } else { uint8_t nauthrr; - PRINTF("resolver: But we are still probing. Waiting...\n"); + LOG_DBG("But we are still probing. Waiting...\n"); /* We are still probing. We need to do the mDNS * probe race condition check here and make sure * we don't need to delay probing for a second. @@ -889,11 +853,11 @@ newdata(void) } if(i >= RESOLV_ENTRIES || i < 0 || namemapptr->state != STATE_ASKING) { - PRINTF("resolver: DNS response has bad ID (%04X) \n", uip_ntohs(hdr->id)); + LOG_DBG("DNS response has bad ID (%04X) \n", uip_ntohs(hdr->id)); return; } - PRINTF("resolver: Incoming response for \"%s\".\n", namemapptr->name); + LOG_DBG("Incoming response for \"%s\".\n", namemapptr->name); /* We'll change this to DONE when we find the record. */ namemapptr->state = STATE_ERROR; @@ -930,7 +894,7 @@ newdata(void) #if VERBOSE_DEBUG char debug_name[40]; decode_name(queryptr, debug_name, uip_appdata); - DEBUG_PRINTF("resolver: Answer %d: \"%s\", type %d, class %d, ttl %d, length %d\n", + LOG_DBG("Answer %d: \"%s\", type %d, class %d, ttl %d, length %d\n", ++i, debug_name, uip_ntohs(ans->type), uip_ntohs(ans->class) & 0x7FFF, (int)((uint32_t) uip_ntohs(ans->ttl[0]) << 16) | (uint32_t) @@ -954,7 +918,7 @@ newdata(void) hdr->id == 0) { int8_t available_i = RESOLV_ENTRIES; - DEBUG_PRINTF("resolver: MDNS query.\n"); + LOG_DBG("MDNS query.\n"); /* For MDNS, we need to actually look up the name we * are looking for. @@ -973,18 +937,18 @@ newdata(void) } } if(i == RESOLV_ENTRIES) { - DEBUG_PRINTF("resolver: Unsolicited MDNS response.\n"); + LOG_DBG("Unsolicited MDNS response.\n"); i = available_i; namemapptr = &names[i]; if(!decode_name(queryptr, namemapptr->name, uip_appdata)) { - DEBUG_PRINTF("resolver: MDNS name too big to cache.\n"); + LOG_DBG("MDNS name too big to cache.\n"); namemapptr = NULL; goto skip_to_next_answer; } } if(i == RESOLV_ENTRIES) { - DEBUG_PRINTF - ("resolver: Not enough room to keep track of unsolicited MDNS answer.\n"); + LOG_DBG + ("Not enough room to keep track of unsolicited MDNS answer.\n"); if(dns_name_isequal(queryptr, resolv_hostname, uip_appdata)) { /* Oh snap, they say they are us! We had better report them... */ @@ -1005,18 +969,20 @@ newdata(void) /* This is disabled for now, so that we don't fail on CNAME records. #if RESOLV_VERIFY_ANSWER_NAMES if(namemapptr && !dns_name_isequal(queryptr, namemapptr->name, uip_appdata)) { - DEBUG_PRINTF("resolver: Answer name doesn't match question...!\n"); + LOG_DBG("Answer name doesn't match question...!\n"); goto skip_to_next_answer; } #endif */ - DEBUG_PRINTF("resolver: Answer for \"%s\" is usable.\n", namemapptr->name); + LOG_DBG("Answer for \"%s\" is usable.\n", namemapptr->name); namemapptr->state = STATE_DONE; #if RESOLV_SUPPORTS_RECORD_EXPIRATION namemapptr->expiration = (uint32_t) uip_ntohs(ans->ttl[0]) << 16 | (uint32_t) uip_ntohs(ans->ttl[1]); + LOG_DBG("Expires in %lu seconds\n", namemapptr->expiration); + namemapptr->expiration += clock_seconds(); #endif /* RESOLV_SUPPORTS_RECORD_EXPIRATION */ @@ -1063,7 +1029,7 @@ resolv_set_hostname(const char *hostname) strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE - strlen(resolv_hostname)); } - PRINTF("resolver: hostname changed to \"%s\"\n", resolv_hostname); + LOG_DBG("hostname changed to \"%s\"\n", resolv_hostname); start_name_collision_check(0); } @@ -1088,11 +1054,11 @@ PROCESS_THREAD(mdns_probe_process, ev, data) PROCESS_BEGIN(); mdns_state = MDNS_STATE_WAIT_BEFORE_PROBE; - PRINTF("mdns-probe: Process (re)started.\n"); + LOG_DBG("mdns-probe: Process (re)started.\n"); /* Wait extra time if specified in data */ if(NULL != data) { - PRINTF("mdns-probe: Probing will begin in %ld clocks.\n", + LOG_DBG("mdns-probe: Probing will begin in %ld clocks.\n", (long)*(clock_time_t *) data); etimer_set(&delay, *(clock_time_t *) data); PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); @@ -1114,7 +1080,7 @@ PROCESS_THREAD(mdns_probe_process, ev, data) mdns_state = MDNS_STATE_READY; mdns_announce_requested(); - PRINTF("mdns-probe: Finished probing.\n"); + LOG_DBG("mdns-probe: Finished probing.\n"); PROCESS_END(); } @@ -1131,12 +1097,12 @@ PROCESS_THREAD(resolv_process, ev, data) resolv_event_found = process_alloc_event(); - PRINTF("resolver: Process started.\n"); + LOG_DBG("Process started.\n"); resolv_conn = udp_new(NULL, 0, NULL); #if RESOLV_CONF_SUPPORTS_MDNS - PRINTF("resolver: Supports MDNS.\n"); + LOG_DBG("Supports MDNS.\n"); uip_udp_bind(resolv_conn, UIP_HTONS(MDNS_PORT)); uip_ds6_maddr_add(&resolv_mdns_addr); @@ -1159,7 +1125,7 @@ PROCESS_THREAD(resolv_process, ev, data) if(mdns_needs_host_announce) { size_t len; - PRINTF("resolver: Announcing that we are \"%s\".\n", + LOG_DBG("Announcing that we are \"%s\".\n", resolv_hostname); memset(uip_appdata, 0, sizeof(struct dns_hdr)); @@ -1267,7 +1233,7 @@ resolv_query(const char *name) nameptr = &names[i]; } - PRINTF("resolver: Starting query for \"%s\".\n", name); + LOG_DBG("Starting query for \"%s\".\n", name); memset(nameptr, 0, sizeof(*nameptr)); @@ -1284,7 +1250,7 @@ resolv_query(const char *name) if((name_len > (sizeof(local_suffix) - 1)) && (0 == strcasecmp(name + name_len - (sizeof(local_suffix) - 1), local_suffix))) { - PRINTF("resolver: Using MDNS to look up \"%s\".\n", name); + LOG_DBG("Using MDNS to look up \"%s\".\n", name); nameptr->is_mdns = 1; } else { nameptr->is_mdns = 0; @@ -1369,29 +1335,21 @@ resolv_lookup(const char *name, uip_ipaddr_t ** ipaddr) } } -#if VERBOSE_DEBUG +#if LOG_LEVEL == LOG_LEVEL_DBG switch (ret) { case RESOLV_STATUS_CACHED: if(ipaddr) { - PRINTF("resolver: Found \"%s\" in cache.\n", name); + LOG_DBG("Found \"%s\" in cache. => ", name); const uip_ipaddr_t *addr = *ipaddr; - - DEBUG_PRINTF - ("resolver: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x \n", - ((uint8_t *) addr)[0], ((uint8_t *) addr)[1], ((uint8_t *) addr)[2], - ((uint8_t *) addr)[3], ((uint8_t *) addr)[4], ((uint8_t *) addr)[5], - ((uint8_t *) addr)[6], ((uint8_t *) addr)[7], ((uint8_t *) addr)[8], - ((uint8_t *) addr)[9], ((uint8_t *) addr)[10], - ((uint8_t *) addr)[11], ((uint8_t *) addr)[12], - ((uint8_t *) addr)[13], ((uint8_t *) addr)[14], - ((uint8_t *) addr)[15]); + LOG_DBG_6ADDR(addr); + LOG_DBG_("\n"); break; } default: - DEBUG_PRINTF("resolver: \"%s\" is NOT cached.\n", name); + LOG_DBG("\"%s\" is NOT cached.\n", name); break; } -#endif /* VERBOSE_DEBUG */ +#endif /* LOG_LEVEL == LOG_LEVEL_DBG */ return ret; } @@ -1407,14 +1365,14 @@ resolv_found(char *name, uip_ipaddr_t * ipaddr) if(strncasecmp(resolv_hostname, name, strlen(resolv_hostname)) == 0 && ipaddr && !uip_ds6_is_my_addr(ipaddr) - ) { + ) { uint8_t i; if(mdns_state == MDNS_STATE_PROBING) { /* We found this new name while probing. * We must now rename ourselves. */ - PRINTF("resolver: Name collision detected for \"%s\".\n", name); + LOG_DBG("Name collision detected for \"%s\".\n", name); /* Remove the ".local" suffix. */ resolv_hostname[strlen(resolv_hostname) - 6] = 0; @@ -1441,31 +1399,19 @@ resolv_found(char *name, uip_ipaddr_t * ipaddr) * that we owned this name. We need to immediately * and explicitly begin probing. */ - PRINTF("resolver: Possible name collision, probing...\n"); + LOG_DBG("Possible name collision, probing...\n"); start_name_collision_check(0); } } else #endif /* RESOLV_CONF_SUPPORTS_MDNS */ - -#if VERBOSE_DEBUG - if(ipaddr) { - PRINTF("resolver: Found address for \"%s\".\n", name); - PRINTF - ("resolver: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x \n", - ((uint8_t *) ipaddr)[0], ((uint8_t *) ipaddr)[1], - ((uint8_t *) ipaddr)[2], ((uint8_t *) ipaddr)[3], - ((uint8_t *) ipaddr)[4], ((uint8_t *) ipaddr)[5], - ((uint8_t *) ipaddr)[6], ((uint8_t *) ipaddr)[7], - ((uint8_t *) ipaddr)[8], ((uint8_t *) ipaddr)[9], - ((uint8_t *) ipaddr)[10], ((uint8_t *) ipaddr)[11], - ((uint8_t *) ipaddr)[12], ((uint8_t *) ipaddr)[13], - ((uint8_t *) ipaddr)[14], ((uint8_t *) ipaddr)[15]); - } else { - PRINTF("resolver: Unable to retrieve address for \"%s\".\n", name); - } -#endif /* VERBOSE_DEBUG */ - + if(ipaddr) { + LOG_DBG("Found address for \"%s\" => ", name); + LOG_DBG_6ADDR(ipaddr); + LOG_DBG_("\n"); + } else { + LOG_DBG("Unable to retrieve address for \"%s\".\n", name); + } process_post(PROCESS_BROADCAST, resolv_event_found, name); } /*---------------------------------------------------------------------------*/ diff --git a/os/net/ipv6/resolv.h b/os/services/resolv/resolv.h similarity index 100% rename from os/net/ipv6/resolv.h rename to os/services/resolv/resolv.h diff --git a/os/services/rpl-border-router/Makefile.rpl-border-router b/os/services/rpl-border-router/Makefile.rpl-border-router index 61ba5fa593da52e29a8771e68babd97fbc0a7b28..d0e2c1542b480e74d188280bc640a8d317a54de9 100644 --- a/os/services/rpl-border-router/Makefile.rpl-border-router +++ b/os/services/rpl-border-router/Makefile.rpl-border-router @@ -1,8 +1,9 @@ include $(CONTIKI)/Makefile.identify-target -# Include either native or embedded BR -ifeq ($(TARGET),native) - MODULES += os/services/rpl-border-router/native -else +# Include BR variant depending on platform and also generic BR code for all +# embedded platforms +MODULES += os/services/rpl-border-router/$(TARGET) + +ifneq ($(TARGET),native) MODULES += os/services/rpl-border-router/embedded endif diff --git a/os/services/rpl-border-router/embedded/Makefile.embedded b/os/services/rpl-border-router/embedded/Makefile.embedded index 8324722fc7e633527b3737913f1dcd708b9090d6..da3a3b18ff112876075051166dad98673618af4f 100644 --- a/os/services/rpl-border-router/embedded/Makefile.embedded +++ b/os/services/rpl-border-router/embedded/Makefile.embedded @@ -1,7 +1,13 @@ PREFIX ?= fd00::1/64 +ifdef PORT + TUNSLIP6_ARGS = -s $(PORT) $(PREFIX) +else + TUNSLIP6_ARGS = $(PREFIX) +endif + connect-router: $(TUNSLIP6) - sudo $(TUNSLIP6) $(PREFIX) + sudo $(TUNSLIP6) $(TUNSLIP6_ARGS) connect-router-cooja: $(TUNSLIP6) sudo $(TUNSLIP6) -a 127.0.0.1 $(PREFIX) diff --git a/os/services/rpl-border-router/zoul/module-macros.h b/os/services/rpl-border-router/zoul/module-macros.h new file mode 100644 index 0000000000000000000000000000000000000000..ae33b84df1e115da20e2a275e2efabc2736eaf6b --- /dev/null +++ b/os/services/rpl-border-router/zoul/module-macros.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019, George Oikonomou - http://www.spd.gr + * 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. + */ +/*---------------------------------------------------------------------------*/ +/* + * Since the BR's radio is always-on, the zoul will never drop to PM2. + * Disabling it explicitly here allows us to use all 32KB of the CC2538's RAM + */ +#define LPM_CONF_MAX_PM 1 +/*---------------------------------------------------------------------------*/ diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 0a48f7ce9bd868a66ba5043ff5bc712b88b6d3ce..38c3ccc6c6c5b3f8609af7f94d06ddefefbc0d95 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -52,6 +52,12 @@ #include "net/ipv6/uiplib.h" #include "net/ipv6/uip-icmp6.h" #include "net/ipv6/uip-ds6.h" +#if BUILD_WITH_RESOLV +#include "resolv.h" +#endif /* BUILD_WITH_RESOLV */ +#if BUILD_WITH_HTTP_SOCKET +#include "http-socket.h" +#endif /* BUILD_WITH_HTTP_SOCKET */ #if MAC_CONF_WITH_TSCH #include "net/mac/tsch/tsch.h" #endif /* MAC_CONF_WITH_TSCH */ @@ -678,6 +684,108 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) PT_END(pt); } +/*---------------------------------------------------------------------------*/ +#if BUILD_WITH_RESOLV +static +PT_THREAD(cmd_resolv(struct pt *pt, shell_output_func output, char *args)) +{ + PT_BEGIN(pt); + static struct etimer timeout_timer; + static int count, ret; + char *next_args; + static uip_ipaddr_t *remote_addr = NULL; + SHELL_ARGS_INIT(args, next_args); + + /* Get argument (remote hostname) */ + SHELL_ARGS_NEXT(args, next_args); + if(args == NULL) { + SHELL_OUTPUT(output, "Destination host is not specified\n"); + PT_EXIT(pt); + } else { + ret = resolv_lookup(args, &remote_addr); + if(ret == RESOLV_STATUS_UNCACHED || ret == RESOLV_STATUS_RESOLVING) { + SHELL_OUTPUT(output, "Looking up IPv6 address for host: %s\n", args); + if(ret != RESOLV_STATUS_RESOLVING) { + resolv_query(args); + } + /* Poll 10 times for resolve results (5 seconds max)*/ + for(count = 0; count < 10; count++) { + etimer_set(&timeout_timer, CLOCK_SECOND / 2); + PT_WAIT_UNTIL(pt, etimer_expired(&timeout_timer)); + printf("resoliving again...\n"); + if((ret = resolv_lookup(args, &remote_addr)) != RESOLV_STATUS_RESOLVING) { + break; + } + } + } + if(ret == RESOLV_STATUS_NOT_FOUND) { + SHELL_OUTPUT(output, "Did not find IPv6 address for host: %s\n", args); + } else if(ret == RESOLV_STATUS_CACHED) { + SHELL_OUTPUT(output, "Found IPv6 address for host: %s => ", args); + shell_output_6addr(output, remote_addr); + SHELL_OUTPUT(output, "\n"); + } + } + PT_END(pt); +} +#endif /* BUILD_WITH_RESOLV */ +/*---------------------------------------------------------------------------*/ +#if BUILD_WITH_HTTP_SOCKET +static struct http_socket s; +static int bytes_received = 0; + +static void +http_callback(struct http_socket *s, void *ptr, + http_socket_event_t e, + const uint8_t *data, uint16_t datalen) +{ + if(e == HTTP_SOCKET_ERR) { + printf("HTTP socket error\n"); + } else if(e == HTTP_SOCKET_TIMEDOUT) { + printf("HTTP socket error: timed out\n"); + } else if(e == HTTP_SOCKET_ABORTED) { + printf("HTTP socket error: aborted\n"); + } else if(e == HTTP_SOCKET_HOSTNAME_NOT_FOUND) { + printf("HTTP socket error: hostname not found\n"); + } else if(e == HTTP_SOCKET_CLOSED) { + printf("HTTP socket closed, %d bytes received\n", bytes_received); + } else if(e == HTTP_SOCKET_DATA) { + int i; + if(bytes_received == 0) { + printf("HTTP socket received data, total expects:%d\n", (int) s->header.content_length); + } + + bytes_received += datalen; + for(i = 0; i < datalen; i++) { + printf("%c", data[i]); + } + } +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(cmd_wget(struct pt *pt, shell_output_func output, char *args)) +{ + PT_BEGIN(pt); + char *next_args; + SHELL_ARGS_INIT(args, next_args); + + /* Get argument (remote hostname and url (http://host/url) */ + SHELL_ARGS_NEXT(args, next_args); + if(args == NULL) { + SHELL_OUTPUT(output, "URL is not specified\n"); + PT_EXIT(pt); + } else { + bytes_received = 0; + SHELL_OUTPUT(output, "Fetching web page at %s\n", args); + http_socket_init(&s); + http_socket_get(&s, args, 0, 0, + http_callback, NULL); + } + + PT_END(pt); +} +#endif /* BUILD_WITH_HTTP_SOCKET */ +/*---------------------------------------------------------------------------*/ #endif /* NETSTACK_CONF_WITH_IPV6 */ /*---------------------------------------------------------------------------*/ static @@ -878,6 +986,12 @@ const struct shell_command_t builtin_shell_commands[] = { { "ip-nbr", cmd_ip_neighbors, "'> ip-nbr': Shows all IPv6 neighbors" }, { "ping", cmd_ping, "'> ping addr': Pings the IPv6 address 'addr'" }, { "routes", cmd_routes, "'> routes': Shows the route entries" }, +#if BUILD_WITH_RESOLV + { "nslookup", cmd_resolv, "'> nslookup': Lookup IPv6 address of host" }, +#endif /* BUILD_WITH_RESOLV */ +#if BUILD_WITH_HTTP_SOCKET + { "wget", cmd_wget, "'> wget url': get content of URL (only http)." }, +#endif /* BUILD_WITH_HTTP_SOCKET */ #endif /* NETSTACK_CONF_WITH_IPV6 */ #if UIP_CONF_IPV6_RPL { "rpl-set-root", cmd_rpl_set_root, "'> rpl-set-root 0/1 [prefix]': Sets node as root (1) or not (0). A /64 prefix can be optionally specified." }, diff --git a/os/sys/cc-gcc.h b/os/sys/cc-gcc.h index e967163279d63896b9665b88b3a320dc2fc4c600..2e06697a6059121389fefa7f021061f14cc2e3eb 100644 --- a/os/sys/cc-gcc.h +++ b/os/sys/cc-gcc.h @@ -39,5 +39,7 @@ #define CC_CONF_ALIGN(n) __attribute__((__aligned__(n))) +#define CC_CONF_NORETURN __attribute__((__noreturn__)) + #endif /* __GNUC__ */ #endif /* _CC_GCC_H_ */ diff --git a/os/sys/cc.h b/os/sys/cc.h index 6670eca46f01d4e83eac3dac8fa2cbbff3afeee3..90d29c52af770d1268f273e03fc58eaf7c5f8549 100644 --- a/os/sys/cc.h +++ b/os/sys/cc.h @@ -105,6 +105,16 @@ #define CC_ALIGN(n) CC_CONF_ALIGN(n) #endif /* CC_CONF_INLINE */ +/** + * Configure if the C compiler supports functions that are not meant to return + * e.g. with __attribute__((__noreturn__)) + */ +#ifdef CC_CONF_NORETURN +#define CC_NORETURN CC_CONF_NORETURN +#else +#define CC_NORETURN +#endif /* CC_CONF_NORETURN */ + /** * Configure if the C compiler supports the assignment of struct value. */ diff --git a/os/sys/lc-addrlabels.h b/os/sys/lc-addrlabels.h index fc86f92ce864eb665acac485d17a869cd7237f82..d08ed16f41fb727c90db53e2efd871e38d12655b 100644 --- a/os/sys/lc-addrlabels.h +++ b/os/sys/lc-addrlabels.h @@ -73,7 +73,11 @@ typedef void * lc_t; } while(0) #define LC_SET(s) \ - do { ({ __label__ resume; resume: (s) = &&resume; }); }while(0) + do { \ + __label__ resume; \ + resume: \ + (s) = &&resume; \ + } while(0) #define LC_END(s) diff --git a/os/sys/log-conf.h b/os/sys/log-conf.h index 17d8562cc114e75dccff5a77fc4bc0c7ab67863c..f886e78681738d626639639a5509461e4dfb2f67 100644 --- a/os/sys/log-conf.h +++ b/os/sys/log-conf.h @@ -138,6 +138,10 @@ #define LOG_CONF_LEVEL_COAP LOG_LEVEL_NONE #endif /* LOG_CONF_LEVEL_COAP */ +#ifndef LOG_CONF_LEVEL_SNMP +#define LOG_CONF_LEVEL_SNMP LOG_LEVEL_NONE +#endif /* LOG_CONF_LEVEL_COAP */ + #ifndef LOG_CONF_LEVEL_LWM2M #define LOG_CONF_LEVEL_LWM2M LOG_LEVEL_NONE #endif /* LOG_CONF_LEVEL_LWM2M */ diff --git a/os/sys/log.c b/os/sys/log.c index abb960b980cb4535fbc84825d5ea8a9edb33612c..41d0ea734abb8eb283f601d21d873c57f8fd786e 100644 --- a/os/sys/log.c +++ b/os/sys/log.c @@ -62,6 +62,7 @@ int curr_log_level_mac = LOG_CONF_LEVEL_MAC; int curr_log_level_framer = LOG_CONF_LEVEL_FRAMER; int curr_log_level_6top = LOG_CONF_LEVEL_6TOP; int curr_log_level_coap = LOG_CONF_LEVEL_COAP; +int curr_log_level_snmp = LOG_CONF_LEVEL_SNMP; int curr_log_level_lwm2m = LOG_CONF_LEVEL_LWM2M; int curr_log_level_main = LOG_CONF_LEVEL_MAIN; @@ -75,6 +76,7 @@ struct log_module all_modules[] = { {"framer", &curr_log_level_framer, LOG_CONF_LEVEL_FRAMER}, {"6top", &curr_log_level_6top, LOG_CONF_LEVEL_6TOP}, {"coap", &curr_log_level_coap, LOG_CONF_LEVEL_COAP}, + {"snmp", &curr_log_level_snmp, LOG_CONF_LEVEL_SNMP}, {"lwm2m", &curr_log_level_lwm2m, LOG_CONF_LEVEL_LWM2M}, {"main", &curr_log_level_main, LOG_CONF_LEVEL_MAIN}, {NULL, NULL, 0}, diff --git a/os/sys/log.h b/os/sys/log.h index 0f5f840d2e702fd9f6a26edc1ff1ee0b497e5062..a01df9e9149c9662b2b16cb3519e167934cec0e1 100644 --- a/os/sys/log.h +++ b/os/sys/log.h @@ -82,6 +82,7 @@ extern int curr_log_level_mac; extern int curr_log_level_framer; extern int curr_log_level_6top; extern int curr_log_level_coap; +extern int curr_log_level_snmp; extern int curr_log_level_lwm2m; extern int curr_log_level_main; @@ -96,6 +97,7 @@ extern struct log_module all_modules[]; #define LOG_LEVEL_FRAMER MIN((LOG_CONF_LEVEL_FRAMER), curr_log_level_framer) #define LOG_LEVEL_6TOP MIN((LOG_CONF_LEVEL_6TOP), curr_log_level_6top) #define LOG_LEVEL_COAP MIN((LOG_CONF_LEVEL_COAP), curr_log_level_coap) +#define LOG_LEVEL_SNMP MIN((LOG_CONF_LEVEL_SNMP), curr_log_level_snmp) #define LOG_LEVEL_LWM2M MIN((LOG_CONF_LEVEL_LWM2M), curr_log_level_lwm2m) #define LOG_LEVEL_MAIN MIN((LOG_CONF_LEVEL_MAIN), curr_log_level_main) diff --git a/os/sys/rtimer.h b/os/sys/rtimer.h index 783e1569bb34cc2276d94f0e0286edc9e7c55588..86ffe762962145e1326637c60dd284d8c10ea9ed 100644 --- a/os/sys/rtimer.h +++ b/os/sys/rtimer.h @@ -57,6 +57,8 @@ #include "dev/watchdog.h" #include <stdbool.h> +/*---------------------------------------------------------------------------*/ + /** \brief The rtimer size (in bytes) */ #ifdef RTIMER_CONF_CLOCK_SIZE #define RTIMER_CLOCK_SIZE RTIMER_CONF_CLOCK_SIZE @@ -89,6 +91,26 @@ typedef uint64_t rtimer_clock_t; #include "rtimer-arch.h" + +/* + * RTIMER_GUARD_TIME is the minimum amount of rtimer ticks between + * the current time and the future time when a rtimer is scheduled. + * Necessary to avoid accidentally scheduling a rtimer in the past + * on platforms with fast rtimer ticks. Should be >= 2. + */ +#ifdef RTIMER_CONF_GUARD_TIME +#define RTIMER_GUARD_TIME RTIMER_CONF_GUARD_TIME +#else /* RTIMER_CONF_GUARD_TIME */ +#define RTIMER_GUARD_TIME (RTIMER_ARCH_SECOND >> 14) +#endif /* RTIMER_CONF_GUARD_TIME */ + +/*---------------------------------------------------------------------------*/ + +/** + * Number of rtimer ticks for 1 second. + */ +#define RTIMER_SECOND RTIMER_ARCH_SECOND + /** * \brief Initialize the real-time scheduler. * @@ -114,8 +136,11 @@ struct rtimer { void *ptr; }; +/** + * TODO: we need to document meanings of these symbols. + */ enum { - RTIMER_OK, + RTIMER_OK, /**< rtimer task is scheduled successfully */ RTIMER_ERR_FULL, RTIMER_ERR_TIME, RTIMER_ERR_ALREADY_SCHEDULED, @@ -123,13 +148,13 @@ enum { /** * \brief Post a real-time task. - * \param task A pointer to the task variable previously declared with RTIMER_TASK(). + * \param task A pointer to the task variable allocated somewhere. * \param time The time when the task is to be executed. * \param duration Unused argument. * \param func A function to be called when the task is executed. * \param ptr An opaque pointer that will be supplied as an argument to the callback function. - * \return Non-zero (true) if the task could be scheduled, zero - * (false) if the task could not be scheduled. + * \return RTIMER_OK if the task could be scheduled. Any other value indicates + * the task could not be scheduled. * * This function schedules a real-time task at a specified * time in the future. @@ -172,22 +197,6 @@ void rtimer_run_next(void); */ #define RTIMER_TIME(task) ((task)->time) -void rtimer_arch_init(void); -void rtimer_arch_schedule(rtimer_clock_t t); -/*rtimer_clock_t rtimer_arch_now(void);*/ - -#define RTIMER_SECOND RTIMER_ARCH_SECOND - -/* RTIMER_GUARD_TIME is the minimum amount of rtimer ticks between - the current time and the future time when a rtimer is scheduled. - Necessary to avoid accidentally scheduling a rtimer in the past - on platforms with fast rtimer ticks. Should be >= 2. */ -#ifdef RTIMER_CONF_GUARD_TIME -#define RTIMER_GUARD_TIME RTIMER_CONF_GUARD_TIME -#else /* RTIMER_CONF_GUARD_TIME */ -#define RTIMER_GUARD_TIME (RTIMER_ARCH_SECOND >> 14) -#endif /* RTIMER_CONF_GUARD_TIME */ - /** \brief Busy-wait until a condition. Start time is t0, max wait time is max_time */ #ifndef RTIMER_BUSYWAIT_UNTIL_ABS #define RTIMER_BUSYWAIT_UNTIL_ABS(cond, t0, max_time) \ @@ -208,6 +217,45 @@ void rtimer_arch_schedule(rtimer_clock_t t); /** \brief Busy-wait for a fixed duration */ #define RTIMER_BUSYWAIT(duration) RTIMER_BUSYWAIT_UNTIL(0, duration) +/*---------------------------------------------------------------------------*/ + +/** + * \name Architecture-dependent symbols + * + * The functions declared in this section must be defined in + * architecture-dependent implementation of rtimer. Alternatively, + * they can be defined as macros in rtimer-arch.h. + * + * In addition, the architecture-dependent header (rtimer-arch.h) + * must define the following macros. + * + * - RTIMER_ARCH_SECOND + * - US_TO_RTIMERTICKS(us) + * - RTIMERTICKS_TO_US(t) + * - RTIMERTICKS_TO_US_64(t) + * + * @{ + */ + +/** + * Initialized the architecture-dependent part of rtimer. + */ +void rtimer_arch_init(void); + +/** + * Schedule the call to `rtimer_run_next` at the time t. + */ +void rtimer_arch_schedule(rtimer_clock_t t); + +/* + * Return the current time in rtimer ticks. + * + * Currently rtimer_arch_now() needs to be defined in rtimer-arch.h + */ +/* rtimer_clock_t rtimer_arch_now(void); */ + +/** @} */ + #endif /* RTIMER_H_ */ /** @} */ diff --git a/tests/01-compile-base/Makefile b/tests/01-compile-base/Makefile index 51e68f9a258cea9c22e13e3e05a7cabdd6ce348b..e7592e824f18353ae4d68135409bcbc50c5686f5 100644 --- a/tests/01-compile-base/Makefile +++ b/tests/01-compile-base/Makefile @@ -32,6 +32,7 @@ coap/coap-example-client/native \ coap/coap-example-server/native \ coap/coap-plugtest-server/native \ sensniff/z1 \ +snmp-server/sky \ TOOLS= diff --git a/tests/02-compile-arm-ports-01/Makefile b/tests/02-compile-arm-ports-01/Makefile index 43e008c8e8a581b70e0b34177b2e9b471841b622..f94d758e6bcd419d46a47ee0c6656a029b36e9c9 100644 --- a/tests/02-compile-arm-ports-01/Makefile +++ b/tests/02-compile-arm-ports-01/Makefile @@ -98,7 +98,8 @@ platform-specific/nrf52dk/mqtt-demo/nrf52dk \ platform-specific/nrf52dk/blink-hello/nrf52dk \ platform-specific/nrf52dk/timer-test/nrf52dk \ libs/data-structures/nrf52dk \ -libs/logging/nrf52dk +libs/logging/nrf52dk \ +snmp-server/cc2538dk \ TOOLS= diff --git a/tests/03-compile-arm-ports-02/Makefile b/tests/03-compile-arm-ports-02/Makefile index 655967e1bc9b5e23598bc6613a2529d8985ecce3..f5362c30a9d9b82989b712a2a88b4863bd8bb41e 100644 --- a/tests/03-compile-arm-ports-02/Makefile +++ b/tests/03-compile-arm-ports-02/Makefile @@ -3,6 +3,7 @@ TOOLSDIR=../../tools EXAMPLES = \ rpl-border-router/zoul \ +rpl-border-router/zoul:MAKE_MAC=MAKE_MAC_TSCH \ platform-specific/cc2538-common/zoul \ platform-specific/cc2538-common/crypto/zoul \ platform-specific/cc2538-common/pka/zoul \ @@ -20,8 +21,9 @@ lwm2m-ipso-objects/zoul:MAKE_WITH_DTLS=1 \ lwm2m-ipso-objects/zoul:DEFINES=LWM2M_Q_MODE_CONF_ENABLED=1 \ lwm2m-ipso-objects/zoul:DEFINES=LWM2M_Q_MODE_CONF_ENABLED=1,LWM2M_Q_MODE_CONF_INCLUDE_DYNAMIC_ADAPTATION=1\ hello-world/zoul \ +hello-world/zoul:DEFINES=ZOUL_CONF_USE_CC1200_RADIO=1 \ sensniff/zoul \ -sensniff/zoul:ZOUL_CONF_SUB_GHZ_SNIFFER=1 \ +sensniff/zoul:DEFINES=ZOUL_CONF_SUB_GHZ_SNIFFER=1 \ storage/cfs-coffee/zoul \ storage/antelope-shell/zoul \ 6tisch/simple-node/zoul \ @@ -57,20 +59,27 @@ dev/rgb-led/zoul:BOARD=firefly-reva \ dev/rgb-led/zoul:BOARD=firefly \ dev/rgb-led/zoul:BOARD=orion \ mqtt-client/zoul:BOARD=firefly \ -mqtt-client/openmote-cc2538 \ -storage/cfs-coffee/openmote-cc2538 \ -sensniff/openmote-cc2538 \ -hello-world/openmote-cc2538 \ -rpl-udp/openmote-cc2538 \ -dev/gpio-hal/openmote-cc2538 \ -dev/leds/openmote-cc2538 \ -rpl-border-router/openmote-cc2538 \ -libs/ipv6-hooks/openmote-cc2538 \ -libs/shell/openmote-cc2538 \ -libs/simple-energest/openmote-cc2538 \ -libs/deployment/openmote-cc2538 \ -6tisch/simple-node/openmote-cc2538 \ -6tisch/simple-node/openmote-cc2538:MAKE_WITH_SECURITY=1,MAKE_WITH_ORCHESTRA=1 \ +mqtt-client/openmote:BOARD=openmote-cc2538 \ +mqtt-client/openmote:BOARD=openmote-b \ +storage/cfs-coffee/openmote:BOARD=openmote-cc2538 \ +storage/cfs-coffee/openmote:BOARD=openmote-b \ +sensniff/openmote \ +hello-world/openmote:BOARD=openmote-cc2538 \ +hello-world/openmote:BOARD=openmote-b \ +rpl-udp/openmote:BOARD=openmote-cc2538 \ +rpl-udp/openmote:BOARD=openmote-b \ +dev/gpio-hal/openmote:BOARD=openmote-cc2538 \ +dev/gpio-hal/openmote:BOARD=openmote-b \ +dev/leds/openmote:BOARD=openmote-cc2538 \ +dev/leds/openmote:BOARD=openmote-b \ +rpl-border-router/openmote:BOARD=openmote-cc2538 \ +rpl-border-router/openmote:BOARD=openmote-b \ +libs/ipv6-hooks/openmote \ +libs/shell/openmote \ +libs/simple-energest/openmote \ +libs/deployment/openmote \ +6tisch/simple-node/openmote \ +6tisch/simple-node/openmote:MAKE_WITH_SECURITY=1,MAKE_WITH_ORCHESTRA=1 \ TOOLS= diff --git a/tests/06-script-base/01-test-lc-switch.sh b/tests/06-script-base/01-test-lc-switch.sh new file mode 100755 index 0000000000000000000000000000000000000000..3f2385bef3a2c50afa332522659c195970fde1d7 --- /dev/null +++ b/tests/06-script-base/01-test-lc-switch.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./run-test-lc.sh 01-test-lc-switch diff --git a/tests/06-script-base/02-test-lc-addrlabels.sh b/tests/06-script-base/02-test-lc-addrlabels.sh new file mode 100755 index 0000000000000000000000000000000000000000..02b793a2e79912c054d49137237d274de51d1326 --- /dev/null +++ b/tests/06-script-base/02-test-lc-addrlabels.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./run-test-lc.sh ${TESTNAME} 02-test-lc-addrlabels diff --git a/tests/06-script-base/03-test-memb.sh b/tests/06-script-base/03-test-memb.sh new file mode 100755 index 0000000000000000000000000000000000000000..b37c3bb8c145c0091e24a0ddfd010ff92dbc1c16 --- /dev/null +++ b/tests/06-script-base/03-test-memb.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +TESTNAME=03-test-memb +TEST_CODE_DIR=code-test-memb +TARGET=test-memb + +make -C ${TEST_CODE_DIR} clean +make -C ${TEST_CODE_DIR} ${TARGET} +${TEST_CODE_DIR}/${TARGET} > ${TESTNAME}.log + +if [ $? -eq 0 ]; then + echo "${TESTNAME} TEST OK" > ${TESTNAME}.testlog + make -C ${TEST_CODE_DIR} clean + exit 0 +else + echo "${TESTNAME} TEST FAIL" > ${TESTNAME}.testlog + exit 1 +fi diff --git a/tests/06-script-base/Makefile b/tests/06-script-base/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..c46e5271d5a3d2374a99b4d70b09ac5e8870495b --- /dev/null +++ b/tests/06-script-base/Makefile @@ -0,0 +1 @@ +include ../Makefile.script-test diff --git a/tests/06-script-base/code-test-lc/Makefile b/tests/06-script-base/code-test-lc/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d53db1cc62da517ff0b062872df7b7159e2e908e --- /dev/null +++ b/tests/06-script-base/code-test-lc/Makefile @@ -0,0 +1,16 @@ +CONTIKI = ../../.. + +CC ?= gcc +CFLAGS += -Wall -g -I/user/local/include +CFLAGS += -I$(CONTIKI)/os + +all: test_lc_switch test_lc_addrlabels + +test-lc-switch: test.c + $(CC) $(CFLAGS) -DTEST_LC_SWITCH -o $@ test.c + +test-lc-addrlabels: test.c + $(CC) $(CFLAGS) -DTEST_LC_ADDRLABELS -o $@ test.c + +clean: + rm -rf test-lc-switch* test-lc-addrlabels* diff --git a/tests/06-script-base/code-test-lc/test.c b/tests/06-script-base/code-test-lc/test.c new file mode 100644 index 0000000000000000000000000000000000000000..dc9cc6219d99d208d68fffe5b5a811a9cd5044da --- /dev/null +++ b/tests/06-script-base/code-test-lc/test.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2019, Inria. + * 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 <stdio.h> + +#if TEST_LC_SWITCH +#include <sys/lc-switch.h> +#endif /* TEST_LC_SWITCH */ + +#if TEST_LC_ADDRLABELS +#include <sys/lc-addrlabels.h> +#endif /* TEST_LC_ADDRLABELS */ + +#define MAX_NUM_CALLS 10 +lc_t lc; + +int +return_lc_set_call_count(void) +{ + static int call_count = 0; + + printf("- LC_RESUME()\n"); + LC_RESUME(lc); + + /* + * The following three lines should be called only for the first + * call of this function after LC_INIT(). + */ + printf("- LC_SET()\n"); + call_count++; + LC_SET(lc); + /* + * We should resume this function here for the second call and + * further + */ + + printf("- LC_END()\n\n"); + LC_END(); + + return call_count; +} + +int +main(void) +{ + int ret = 0; + LC_INIT(lc); + + /* We're going to call return_lc_set_call_count() several times */ + for(int i = 0; i < MAX_NUM_CALLS; i++) { + if(return_lc_set_call_count() != 1) { + /* return_lc_set_call_count() should always return 1 */ + ret = -1; + break; + } + } + + if(ret == 0) { + /* LC_INIT() clears lc */ + LC_INIT(lc); + + /* + * After calling LC_INIT(), return_lc_set_call_count() should + * return 2, which means LC_SET() should be called this time since + * lc is cleared. + */ + if(return_lc_set_call_count() != 2) { + ret = -1; + } + } + + if(ret == 0) { + printf("test passed\n"); + } else { + printf("test failed\n"); + } + + return ret; +} diff --git a/tests/06-script-base/code-test-memb/Makefile b/tests/06-script-base/code-test-memb/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e3d671399571bd235bbed9b4312f5716856a0b88 --- /dev/null +++ b/tests/06-script-base/code-test-memb/Makefile @@ -0,0 +1,22 @@ +CONTIKI = ../../.. + +CC ?= gcc +CFLAGS += -Wall -g +CFLAGS += -I. +CFLAGS += -I/user/local/include +CFLAGS += -I$(CONTIKI)/os + +MEMB_C = $(CONTIKI)/os/lib/memb.c + +ARCH = native + +all: test-memb + +memb.o: $(MEMB_C) + $(CC) $(CFLAGS) -c $< -o $@ + +test-memb: test-memb-api.o memb.o + $(CC) $^ -o $@ + +clean: + rm -rf test-memb test-memb.* *.o build diff --git a/tests/06-script-base/code-test-memb/contiki.h b/tests/06-script-base/code-test-memb/contiki.h new file mode 100644 index 0000000000000000000000000000000000000000..43f0dbb1bfc0c739b49c224288b677af73ca015d --- /dev/null +++ b/tests/06-script-base/code-test-memb/contiki.h @@ -0,0 +1,8 @@ +/* + * When memb.h is "included", contiki.h is also loaded as a result + * since it is a dependency of cc.h, which memb.h needs for + * CC_CONCAT() macro. + * + * This file serves as a dummy contiki.h to make it possible to + * compile a test file having "#include <lib/memb.h>" in it. + */ diff --git a/tests/06-script-base/code-test-memb/test-memb-api.c b/tests/06-script-base/code-test-memb/test-memb-api.c new file mode 100644 index 0000000000000000000000000000000000000000..c590f4346c61c3ab153e45c16ceabdf92509c4a9 --- /dev/null +++ b/tests/06-script-base/code-test-memb/test-memb-api.c @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2019, Inria. + * 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 <stdio.h> +#include <inttypes.h> +#include <string.h> + +#include <lib/memb.h> + +#define NUM_MEMB_BLOCKS 8 +#define DATA_LEN 128 +#define ONE_BYTE_OFF_ADDR(p) ((uint8_t *)p + 1) + +typedef struct test_struct { + uint8_t index; + uint16_t length; + char data[DATA_LEN]; +} test_struct_t; + +MEMB(memb_pool, test_struct_t, NUM_MEMB_BLOCKS); + +int +main(void) +{ + int ret; + test_struct_t *memb_block_p; + test_struct_t *memb_block_list[NUM_MEMB_BLOCKS]; + + /* initialize the memory blocks */ + memb_init(&memb_pool); + + /* + * all the blocks should be "unused"; memb_numfree() should return + * NUM_MEMB_BLOCKS + */ + if((ret = memb_numfree(&memb_pool)) != NUM_MEMB_BLOCKS) { + printf("test failed: memb_numfree() returns %d, which should be %d\n", + ret, NUM_MEMB_BLOCKS); + return -1; + } else { + printf("- memb_init (and memb_numfree) is OK\n"); + } + + /* allocate memory blocks */ + memset(memb_block_list, 0, sizeof(memb_block_list)); + for(int i = 0; i < NUM_MEMB_BLOCKS; i++) { + memb_block_p = (test_struct_t *)memb_alloc(&memb_pool); + if(memb_block_p == NULL) { + printf("test failed: memb_alloc() returns NULL with i==%d\n", i); + return -1; + } else if((ret = memb_inmemb(&memb_pool, memb_block_p)) != 1) { + printf("test failed: %p returned memb_alloc() is invalid\n", + memb_block_p); + return -1; + } else if((ret = memb_numfree(&memb_pool)) != NUM_MEMB_BLOCKS - i - 1) { + printf("test failed: memb_numfree() returns an invalid value %d, " + "which should be %d\n", ret, NUM_MEMB_BLOCKS - i - 1); + return -1; + } else { + printf("- memb_alloc is OK: memory block %p is allocated\n", + memb_block_p); + } + memb_block_list[i] = memb_block_p; + } + + /* try to allocate another memory block, which should fail */ + if((memb_block_p = (test_struct_t *)memb_alloc(&memb_pool)) != NULL) { + printf("test failed: memb_alloc() allocates more memory than defined\n"); + return -1; + } else { + printf("- memb_alloc is OK: we cannot get any more memory block\n"); + } + + /* free the allocated memory blocks */ + for(int i = 0; i < NUM_MEMB_BLOCKS; i++) { + memb_block_p = memb_block_list[i]; + if((ret = memb_free(&memb_pool, memb_block_p)) != 0) { + printf("test failed: cannot memb_free() to %p, return value is %d\n", + memb_block_p, ret); + return -1; + } else if((ret = memb_numfree(&memb_pool)) != i + 1) { + printf("test failed: memb_numfree() returns an invalid value %d, " + "which should be %d\n", ret, i + 1); + return -1; + } else { + printf("- memb_free is OK: memory block %p is freed\n", memb_block_p); + } + } + + /* + * call memb_free() again with the addresses of previously allocated + * memory blocks (test for double-free) + */ + for(int i = 0; i < NUM_MEMB_BLOCKS; i++) { + memb_block_p = memb_block_list[i]; + if((ret = memb_free(&memb_pool, memb_block_p)) != -1) { + /* double free shouldn't succeed (we should have -1 returned) */ + printf("test failed: cannot double free to %p, return value is %d\n", + memb_block_p, ret); + return -1; + } else if((ret = memb_numfree(&memb_pool)) != NUM_MEMB_BLOCKS) { + /* memb_numfree() should return NUM_MEMB_BLOCKS as no memory is used */ + printf("test failed: memb_numfree() returns an invalid value %d, " + "which should be %d\n", ret, NUM_MEMB_BLOCKS); + return -1; + } else { + printf("- memb_free is OK: memory block %p is double-freed\n", + memb_block_p); + } + } + + /* free with a invalid address, which are not the beginning of a block */ + if((memb_block_p = memb_alloc(&memb_pool)) == NULL) { + printf("test failed: memb_alloc() returns NULL while no memory is used\n"); + return -1; + } else if(memb_free(&memb_pool, ONE_BYTE_OFF_ADDR(memb_block_p)) != -1) { + printf("test failed: memb_free accepts an invalid address %p, " + "which is one byte off from memory block starting at %p\n", + ONE_BYTE_OFF_ADDR(memb_block_p), memb_block_p); + return -1; + } else { + printf("- memb_free is OK: reject an invalid address %p\n", + ONE_BYTE_OFF_ADDR(memb_block_p)); + (void)memb_free(&memb_pool, memb_block_p); + } + + return 0; +} diff --git a/tests/06-script-base/run-test-lc.sh b/tests/06-script-base/run-test-lc.sh new file mode 100755 index 0000000000000000000000000000000000000000..678197eca13696e3f94da82db0623d37fe321065 --- /dev/null +++ b/tests/06-script-base/run-test-lc.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +TEST_CODE_DIR=code-test-lc +TESTNAME=$1 +TARGET=`echo ${TESTNAME} | sed -e 's/[0-9]*-\(.*\)/\1/'` + +make -C ${TEST_CODE_DIR} clean +make -C ${TEST_CODE_DIR} ${TARGET} +${TEST_CODE_DIR}/${TARGET} > ${TESTNAME}.log + +if [ $? -eq 0 ]; then + echo "${TESTNAME} TEST OK" > ${TESTNAME}.testlog + make -C ${TEST_CODE_DIR} clean + exit 0 +else + echo "${TESTNAME} TEST FAIL" > ${TESTNAME}.testlog + exit 1 +fi diff --git a/tests/08-native-runs/02-mqtt-client-31.sh b/tests/08-native-runs/02-mqtt-client-31.sh new file mode 100755 index 0000000000000000000000000000000000000000..5741010674ec0a5c1447f66d42df8aca9e7538c9 --- /dev/null +++ b/tests/08-native-runs/02-mqtt-client-31.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +MQTT_VERSION="3_1" ./mqtt-client.sh "$@" \ No newline at end of file diff --git a/tests/08-native-runs/03-mqtt-client-31-valgrind.sh b/tests/08-native-runs/03-mqtt-client-31-valgrind.sh new file mode 100755 index 0000000000000000000000000000000000000000..6f0f0c1fcd8f7f4fdef1ec7fe22a86e6a108b1c7 --- /dev/null +++ b/tests/08-native-runs/03-mqtt-client-31-valgrind.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +MQTT_VERSION="3_1" VALGRIND_CMD="valgrind" ./mqtt-client.sh "$@" \ No newline at end of file diff --git a/tests/08-native-runs/04-mqtt-client-311.sh b/tests/08-native-runs/04-mqtt-client-311.sh new file mode 100755 index 0000000000000000000000000000000000000000..8163067767cc917818c1a0a7703ec7b10d5a1cec --- /dev/null +++ b/tests/08-native-runs/04-mqtt-client-311.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +MQTT_VERSION="3_1_1" ./mqtt-client.sh "$@" \ No newline at end of file diff --git a/tests/08-native-runs/05-mqtt-client-311-valgrind.sh b/tests/08-native-runs/05-mqtt-client-311-valgrind.sh new file mode 100755 index 0000000000000000000000000000000000000000..0ecea9ef73ad3ea2c81aa5aef28219cbf482f515 --- /dev/null +++ b/tests/08-native-runs/05-mqtt-client-311-valgrind.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +VALGRIND_CMD="valgrind" MQTT_VERSION="3_1_1" ./mqtt-client.sh "$@" \ No newline at end of file diff --git a/tests/08-native-runs/06-snmp-server.sh b/tests/08-native-runs/06-snmp-server.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a6e12f381aed123ad44c90e5d2aea16ea34bbfa --- /dev/null +++ b/tests/08-native-runs/06-snmp-server.sh @@ -0,0 +1,48 @@ +#!/bin/bash +source ../utils.sh + +# Contiki directory +CONTIKI=$1 +# Test basename +BASENAME=$(basename $0 .sh) + +IPADDR=fd00::302:304:506:708 + +# Starting Contiki-NG native node +echo "Starting native node" +make -C $CONTIKI/examples/snmp-server > make.log 2> make.err +sudo $CONTIKI/examples/snmp-server/snmp-server.native > node.log 2> node.err & +CPID=$! +sleep 2 + +# Do Walk +echo "WALK!" +snmpwalk -t 4 -v 2c -c public udp6:[$IPADDR]:161 1 | tee $BASENAME.log +# Fetch snmpwalk status code (not $? because this is piped) +STATUS=${PIPESTATUS[0]} + +echo "Closing native node" +sleep 2 +kill_bg $CPID + +if [ $STATUS -eq 0 ] ; then + cp $BASENAME.log $BASENAME.testlog + printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog; +else + echo "==== make.log ====" ; cat make.log; + echo "==== make.err ====" ; cat make.err; + echo "==== node.log ====" ; cat node.log; + echo "==== node.err ====" ; cat node.err; + echo "==== $BASENAME.log ====" ; cat $BASENAME.log; + + printf "%-32s TEST FAIL\n" "$BASENAME" | tee $BASENAME.testlog; +fi + +rm make.log +rm make.err +rm node.log +rm node.err + +# We do not want Make to stop -> Return 0 +# The Makefile will check if a log contains FAIL at the end +exit 0 diff --git a/tests/08-native-runs/02-mqtt-client.sh b/tests/08-native-runs/mqtt-client.sh similarity index 63% rename from tests/08-native-runs/02-mqtt-client.sh rename to tests/08-native-runs/mqtt-client.sh index 1c3b089f034d30024e3ec28bfdf45a36eecadab3..929569ea5338761b163f25a1d5b75a0098de6520 100755 --- a/tests/08-native-runs/02-mqtt-client.sh +++ b/tests/08-native-runs/mqtt-client.sh @@ -4,13 +4,23 @@ source ../utils.sh # Contiki directory CONTIKI=$1 +# 3_1, 3_1_1, or 5 +# default: 3_1 +MQTT_VERSION=${MQTT_VERSION=3_1} + # Example code directory CODE_DIR=$CONTIKI/examples/mqtt-client/ CODE=mqtt-client -CLIENT_LOG=$CODE.log -CLIENT_TESTLOG=$CODE.testlog -CLIENT_ERR=$CODE.err +TEST_NAME=$CODE-$MQTT_VERSION +if [ -n "$VALGRIND_CMD" ] +then + TEST_NAME+="-valgrind" +fi + +CLIENT_LOG=$TEST_NAME.log +CLIENT_TESTLOG=$TEST_NAME.testlog +CLIENT_ERR=$TEST_NAME.err MOSQ_SUB_LOG=mosquitto_sub.log MOSQ_SUB_ERR=mosquitto_sub.err @@ -29,9 +39,9 @@ sleep 2 # Starting Contiki-NG native node echo "Starting native node" make -C $CODE_DIR -B TARGET=native \ - DEFINES=MQTT_CLIENT_CONF_ORG_ID=\\\"travis-test\\\",MQTT_CLIENT_CONF_LOG_LEVEL=LOG_LEVEL_DBG \ + DEFINES=MQTT_CLIENT_CONF_ORG_ID=\\\"travis-test\\\",MQTT_CLIENT_CONF_LOG_LEVEL=LOG_LEVEL_DBG,MQTT_CONF_VERSION=MQTT_PROTOCOL_VERSION_$MQTT_VERSION \ > make.log 2> make.err -sudo $CODE_DIR/$CODE.native > $CLIENT_LOG 2> $CLIENT_ERR & +sudo $VALGRIND_CMD $CODE_DIR/$CODE.native > $CLIENT_LOG 2> $CLIENT_ERR & CPID=$! # The mqtt-client will publish every 30 secs. Wait for 45 @@ -42,7 +52,9 @@ mosquitto_pub -m "1" -t iot-2/cmd/leds/fmt/json echo "Closing native node" sleep 2 -kill_bg $CPID +# If we're running Valgrind, we want it to dump the final report, so we don't SIGKILL it +kill_bg $CPID SIGTERM +sleep 1 echo "Stopping mosquitto daemon" kill_bg $MOSQID @@ -53,11 +65,13 @@ kill_bg $MSUBID # Success criteria: # * mosquitto_sub output not empty # * mqtt-client.native output contains "MQTT SUB" +# * Valgrind off or 0 errors reported SUB_RCV=`grep "MQTT SUB" $CLIENT_LOG` -if [ -s "$MOSQ_SUB_LOG" -a -n "$SUB_RCV" ] +VALGRIND_NO_ERR=`grep "ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)" $CLIENT_ERR` +if [ -s "$MOSQ_SUB_LOG" -a -n "$SUB_RCV" ] && [ -z "$VALGRIND_CMD" -o -n "$VALGRIND_NO_ERR" ] then - cp $CLIENT_LOG $CODE.testlog - printf "%-32s TEST OK\n" "$CODE" | tee $CODE.testlog; + cp $CLIENT_LOG $CLIENT_TESTLOG + printf "%-32s TEST OK\n" "$TEST_NAME" | tee $CLIENT_TESTLOG; else echo "==== make.log ====" ; cat make.log; echo "==== make.err ====" ; cat make.err; @@ -66,7 +80,7 @@ else echo "==== $MOSQ_SUB_LOG ====" ; cat $MOSQ_SUB_LOG; echo "==== $MOSQ_SUB_ERR ====" ; cat $MOSQ_SUB_ERR; - printf "%-32s TEST FAIL\n" "$CODE" | tee $CODE.testlog; + printf "%-32s TEST FAIL\n" "$TEST_NAME" | tee $CLIENT_TESTLOG; fi rm make.log diff --git a/tests/09-ipv6/js/ping-test-lla-ula.js b/tests/09-ipv6/js/ping-test-lla-ula.js index c15dcbf154344d09d3744d1161ed38527dde79c3..8e34300cc01383017ee7b65ebf1a1449e9de760c 100644 --- a/tests/09-ipv6/js/ping-test-lla-ula.js +++ b/tests/09-ipv6/js/ping-test-lla-ula.js @@ -1,4 +1,4 @@ -TIMEOUT(20000, log.testFailed()); +TIMEOUT(25000, log.testFailed()); dst_lla = "fe80::202:2:2:2"; dst_ula = "fd00::202:2:2:2"; @@ -21,12 +21,12 @@ while(1) { rpl_is_enabled = true; } - if(step == 2 && time > 15000000) { + if(step == 2 && time > 20000000) { write(sim.getMoteWithID(1), "ping " + dst_lla); step += 1; } - if(step == 4 && time > 15000000) { + if(step == 4 && time > 20000000) { write(sim.getMoteWithID(1), "ping " + dst_ula); step += 1; } diff --git a/tests/09-ipv6/js/ping-test-lla.js b/tests/09-ipv6/js/ping-test-lla.js index d9beedf8bcfe6c1d182757f94e68a0811042cd80..2e1b9ef7d118a3a1eec1952a114d950f8e3da5c5 100644 --- a/tests/09-ipv6/js/ping-test-lla.js +++ b/tests/09-ipv6/js/ping-test-lla.js @@ -1,4 +1,4 @@ -TIMEOUT(20000, log.testFailed()); +TIMEOUT(25000, log.testFailed()); dst_lla = "fe80::202:2:2:2"; dst_mac = "0002.0002.0002.0002"; @@ -15,7 +15,7 @@ while(1) { step += 1; } - if(step == 2 && time > 15000000) { + if(step == 2 && time > 20000000) { write(sim.getMoteWithID(1), "ping " + dst_lla); step += 1; } diff --git a/tests/09-ipv6/js/ping-test-ula.js b/tests/09-ipv6/js/ping-test-ula.js index adbd22ccffd4a10c4743b5423c16403ad3b00bea..818864bbf9e0303b9df49798ce89fd05ee1c38e2 100644 --- a/tests/09-ipv6/js/ping-test-ula.js +++ b/tests/09-ipv6/js/ping-test-ula.js @@ -1,4 +1,4 @@ -;TIMEOUT(20000, log.testFailed()); +;TIMEOUT(25000, log.testFailed()); dst_lla = "fe80::202:2:2:2"; dst_ula = "fd00::202:2:2:2"; @@ -16,7 +16,7 @@ while(1) { step += 1; } - if(step == 2 && time > 15000000) { + if(step == 2 && time > 20000000) { write(sim.getMoteWithID(1), "ping " + dst_ula); step += 1; } diff --git a/tests/14-rpl-lite/10-rpl-resetting-dio-timer-by-dis.csc b/tests/14-rpl-lite/10-rpl-resetting-dio-timer-by-dis.csc new file mode 100644 index 0000000000000000000000000000000000000000..fa4e634aadf5f7a48596e2a9fabf2a811920c47b --- /dev/null +++ b/tests/14-rpl-lite/10-rpl-resetting-dio-timer-by-dis.csc @@ -0,0 +1,207 @@ +<?xml version="1.0" encoding="UTF-8"?> +<simconf> + <project EXPORT="discard">[APPS_DIR]/mrm</project> + <project EXPORT="discard">[APPS_DIR]/mspsim</project> + <project EXPORT="discard">[APPS_DIR]/avrora</project> + <project EXPORT="discard">[APPS_DIR]/serial_socket</project> + <project EXPORT="discard">[APPS_DIR]/powertracker</project> + <simulation> + <title>Test of Resetting DIO Timer by DIS</title> + <randomseed>123456</randomseed> + <motedelay_us>1000000</motedelay_us> + <radiomedium> + org.contikios.cooja.radiomediums.UDGM + <transmitting_range>50.0</transmitting_range> + <interference_range>100.0</interference_range> + <success_ratio_tx>1.0</success_ratio_tx> + <success_ratio_rx>1.0</success_ratio_rx> + </radiomedium> + <events> + <logoutput>40000</logoutput> + </events> + <motetype> + org.contikios.cooja.contikimote.ContikiMoteType + <identifier>mtype325</identifier> + <description>root</description> + <source>[CONTIKI_DIR]/tests/14-rpl-lite/code/root-node.c</source> + <commands>make root-node.cooja TARGET=cooja</commands> + <moteinterface>org.contikios.cooja.interfaces.Position</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface> + <symbols>false</symbols> + </motetype> + <motetype> + org.contikios.cooja.contikimote.ContikiMoteType + <identifier>mtype151</identifier> + <description>dis-sender</description> + <source>[CONTIKI_DIR]/tests/14-rpl-lite/code/dis-sender.c</source> + <commands>make dis-sender.cooja TARGET=cooja</commands> + <moteinterface>org.contikios.cooja.interfaces.Position</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface> + <symbols>false</symbols> + </motetype> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>0.0</x> + <y>0.0</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>1</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype325</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>0.0</x> + <y>10.0</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>2</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype151</motetype_identifier> + </mote> + </simulation> + <plugin> + org.contikios.cooja.plugins.SimControl + <width>280</width> + <z>5</z> + <height>160</height> + <location_x>400</location_x> + <location_y>0</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.Visualizer + <plugin_config> + <moterelations>true</moterelations> + <skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin> + <viewport>3.257437090909091 0.0 0.0 3.257437090909091 194.00000000000028 156.71281454545456</viewport> + </plugin_config> + <width>400</width> + <z>1</z> + <height>400</height> + <location_x>1</location_x> + <location_y>1</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.LogListener + <plugin_config> + <filter /> + <formatted_time /> + <coloring /> + </plugin_config> + <width>936</width> + <z>4</z> + <height>240</height> + <location_x>400</location_x> + <location_y>160</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.TimeLine + <plugin_config> + <mote>0</mote> + <mote>1</mote> + <showRadioRXTX /> + <showRadioHW /> + <showLEDs /> + <zoomfactor>500.0</zoomfactor> + </plugin_config> + <width>1336</width> + <z>3</z> + <height>166</height> + <location_x>0</location_x> + <location_y>622</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.Notes + <plugin_config> + <notes>Enter notes here</notes> + <decorations>true</decorations> + </plugin_config> + <width>656</width> + <z>2</z> + <height>160</height> + <location_x>680</location_x> + <location_y>0</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.RadioLogger + <plugin_config> + <split>150</split> + <formatted_time /> + <showdups>false</showdups> + <hidenodests>false</hidenodests> + <analyzers name="6lowpan-pcap" /> + </plugin_config> + <width>500</width> + <z>0</z> + <height>300</height> + <location_x>1</location_x> + <location_y>401</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.ScriptRunner + <plugin_config> + <scriptfile>[CONFIG_DIR]/js/10-rpl-setting-dio-timer-by-dis.js</scriptfile> + <active>true</active> + </plugin_config> + <width>495</width> + <z>0</z> + <height>525</height> + <location_x>663</location_x> + <location_y>105</location_y> + </plugin> +</simconf> diff --git a/tests/14-rpl-lite/code/Makefile b/tests/14-rpl-lite/code/Makefile index 7e2883eff69fe5ada41297e8a0f93182160ccaed..de2b2641edf1c5f1d7a25a6b51c4521c0a1dea49 100644 --- a/tests/14-rpl-lite/code/Makefile +++ b/tests/14-rpl-lite/code/Makefile @@ -1,4 +1,4 @@ -all: sender-node receiver-node root-node +all: dis-sender sender-node receiver-node root-node CONTIKI=../../.. include $(CONTIKI)/Makefile.include diff --git a/tests/14-rpl-lite/code/dis-sender.c b/tests/14-rpl-lite/code/dis-sender.c new file mode 100644 index 0000000000000000000000000000000000000000..a68022aa2e00c0fe7d394d604cbc81c69372965f --- /dev/null +++ b/tests/14-rpl-lite/code/dis-sender.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2019, Inria. + * 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 <contiki.h> + +#include <lib/assert.h> + +#include <net/routing/rpl-lite/rpl.h> + +#define DIS_INTERVAL_SECONDS 1 + +PROCESS(dis_sender_process, "DIS sender process"); +AUTOSTART_PROCESSES(&dis_sender_process); + +PROCESS_THREAD(dis_sender_process, ev, data) +{ + static struct etimer et; + + PROCESS_BEGIN(); + + assert(DIS_INTERVAL_SECONDS < RPL_DIO_INTERVAL_MIN); + etimer_set(&et, CLOCK_SECOND * DIS_INTERVAL_SECONDS); + + while(1) { + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + etimer_reset(&et); + rpl_icmp6_dis_output(NULL); + } + + PROCESS_END(); +} diff --git a/tests/14-rpl-lite/code/project-conf.h b/tests/14-rpl-lite/code/project-conf.h index d6cd59471761d9f6bad11e269fa2bbb10c8fbe91..439cdef98e0ab2625b1fd3b1386c298832c31f6c 100644 --- a/tests/14-rpl-lite/code/project-conf.h +++ b/tests/14-rpl-lite/code/project-conf.h @@ -27,3 +27,4 @@ * SUCH DAMAGE. */ #define TCPIP_CONF_ANNOTATE_TRANSMISSIONS 1 +#define LOG_CONF_LEVEL_RPL LOG_LEVEL_INFO diff --git a/tests/14-rpl-lite/js/10-rpl-setting-dio-timer-by-dis.js b/tests/14-rpl-lite/js/10-rpl-setting-dio-timer-by-dis.js new file mode 100644 index 0000000000000000000000000000000000000000..0b9dba40fec70685c2586b1eb104c48062d1404e --- /dev/null +++ b/tests/14-rpl-lite/js/10-rpl-setting-dio-timer-by-dis.js @@ -0,0 +1,25 @@ +// we want to see ten DIOs by the root at least, tweleve at most, +// during the test of 60 seconds when RPL_DIO_INTERVAL_MIN is set to +// 12 (4 seconds) +var node_id_of_root = 1 +var expected_num_of_dios = 10; +var num_of_dios = 0; + +TIMEOUT(60000, log.testFailed()); // ms + +while(true) { + YIELD(); + + log.log(time + " node-" + id + " "+ msg + "\n"); + + if(id == node_id_of_root) { + if(msg.contains('sending a multicast-DIO')) { + num_of_dios++; + } + + if(num_of_dios >= expected_num_of_dios) { + log.testOK(); + break; + } + } +} diff --git a/tests/15-rpl-classic/11-rpl-resetting-dio-timer-by-dis.csc b/tests/15-rpl-classic/11-rpl-resetting-dio-timer-by-dis.csc new file mode 100644 index 0000000000000000000000000000000000000000..0eca1c953fc4bd5b3f39a6e46e972401ffff2ee8 --- /dev/null +++ b/tests/15-rpl-classic/11-rpl-resetting-dio-timer-by-dis.csc @@ -0,0 +1,207 @@ +<?xml version="1.0" encoding="UTF-8"?> +<simconf> + <project EXPORT="discard">[APPS_DIR]/mrm</project> + <project EXPORT="discard">[APPS_DIR]/mspsim</project> + <project EXPORT="discard">[APPS_DIR]/avrora</project> + <project EXPORT="discard">[APPS_DIR]/serial_socket</project> + <project EXPORT="discard">[APPS_DIR]/powertracker</project> + <simulation> + <title>Test of Resetting DIO Timer by DIS</title> + <randomseed>123456</randomseed> + <motedelay_us>1000000</motedelay_us> + <radiomedium> + org.contikios.cooja.radiomediums.UDGM + <transmitting_range>50.0</transmitting_range> + <interference_range>100.0</interference_range> + <success_ratio_tx>1.0</success_ratio_tx> + <success_ratio_rx>1.0</success_ratio_rx> + </radiomedium> + <events> + <logoutput>40000</logoutput> + </events> + <motetype> + org.contikios.cooja.contikimote.ContikiMoteType + <identifier>mtype325</identifier> + <description>root</description> + <source>[CONTIKI_DIR]/tests/15-rpl-classic/code/root-node.c</source> + <commands>make root-node.cooja TARGET=cooja</commands> + <moteinterface>org.contikios.cooja.interfaces.Position</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface> + <symbols>false</symbols> + </motetype> + <motetype> + org.contikios.cooja.contikimote.ContikiMoteType + <identifier>mtype151</identifier> + <description>dis-sender</description> + <source>[CONTIKI_DIR]/tests/15-rpl-classic/code/dis-sender.c</source> + <commands>make dis-sender.cooja TARGET=cooja</commands> + <moteinterface>org.contikios.cooja.interfaces.Position</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface> + <moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface> + <moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface> + <symbols>false</symbols> + </motetype> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>0.0</x> + <y>0.0</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>1</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype325</motetype_identifier> + </mote> + <mote> + <interface_config> + org.contikios.cooja.interfaces.Position + <x>0.0</x> + <y>10.0</y> + <z>0.0</z> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + <id>2</id> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiRadio + <bitrate>250.0</bitrate> + </interface_config> + <interface_config> + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + <eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom> + </interface_config> + <motetype_identifier>mtype151</motetype_identifier> + </mote> + </simulation> + <plugin> + org.contikios.cooja.plugins.SimControl + <width>280</width> + <z>5</z> + <height>160</height> + <location_x>400</location_x> + <location_y>0</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.Visualizer + <plugin_config> + <moterelations>true</moterelations> + <skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin> + <skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin> + <viewport>3.257437090909091 0.0 0.0 3.257437090909091 194.00000000000028 156.71281454545456</viewport> + </plugin_config> + <width>400</width> + <z>1</z> + <height>400</height> + <location_x>1</location_x> + <location_y>1</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.LogListener + <plugin_config> + <filter /> + <formatted_time /> + <coloring /> + </plugin_config> + <width>936</width> + <z>4</z> + <height>240</height> + <location_x>400</location_x> + <location_y>160</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.TimeLine + <plugin_config> + <mote>0</mote> + <mote>1</mote> + <showRadioRXTX /> + <showRadioHW /> + <showLEDs /> + <zoomfactor>500.0</zoomfactor> + </plugin_config> + <width>1336</width> + <z>3</z> + <height>166</height> + <location_x>0</location_x> + <location_y>622</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.Notes + <plugin_config> + <notes>Enter notes here</notes> + <decorations>true</decorations> + </plugin_config> + <width>656</width> + <z>2</z> + <height>160</height> + <location_x>680</location_x> + <location_y>0</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.RadioLogger + <plugin_config> + <split>150</split> + <formatted_time /> + <showdups>false</showdups> + <hidenodests>false</hidenodests> + <analyzers name="6lowpan-pcap" /> + </plugin_config> + <width>500</width> + <z>0</z> + <height>300</height> + <location_x>1</location_x> + <location_y>401</location_y> + </plugin> + <plugin> + org.contikios.cooja.plugins.ScriptRunner + <plugin_config> + <scriptfile>[CONFIG_DIR]/js/11-rpl-setting-dio-timer-by-dis.js</scriptfile> + <active>true</active> + </plugin_config> + <width>495</width> + <z>0</z> + <height>525</height> + <location_x>663</location_x> + <location_y>105</location_y> + </plugin> +</simconf> diff --git a/tests/15-rpl-classic/code/Makefile b/tests/15-rpl-classic/code/Makefile index 40155b3435721c6ae0aec525c6ea5b32bbfeb7f6..b5ec959e33ba383579157ee1da4bbf492de93bbc 100644 --- a/tests/15-rpl-classic/code/Makefile +++ b/tests/15-rpl-classic/code/Makefile @@ -1,4 +1,4 @@ -all: sender-node receiver-node root-node +all: dis-sender sender-node receiver-node root-node CONTIKI=../../.. MAKE_ROUTING = MAKE_ROUTING_RPL_CLASSIC diff --git a/tests/15-rpl-classic/code/dis-sender.c b/tests/15-rpl-classic/code/dis-sender.c new file mode 100644 index 0000000000000000000000000000000000000000..6378991fcd5e0d9e9b8ac85280cd98cc1d0b6df8 --- /dev/null +++ b/tests/15-rpl-classic/code/dis-sender.c @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019, Inria. + * 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 <contiki.h> + +#include <lib/assert.h> + +#include <net/routing/rpl-classic/rpl.h> + +#define DIS_INTERVAL_SECONDS 1 + +PROCESS(dis_sender_process, "DIS sender process"); +AUTOSTART_PROCESSES(&dis_sender_process); + +/* + * dis_output() is a NON-static implemented in rpl-icmp6.c, but it's + * not listed in a header file of rpl-classic module. declare its + * prototype here. + */ +void dis_output(uip_ipaddr_t *addr); + +PROCESS_THREAD(dis_sender_process, ev, data) +{ + static struct etimer et; + + PROCESS_BEGIN(); + + assert(DIS_INTERVAL_SECONDS < RPL_DIO_INTERVAL_MIN); + etimer_set(&et, CLOCK_SECOND * DIS_INTERVAL_SECONDS); + + while(1) { + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + etimer_reset(&et); + dis_output(NULL); + } + + PROCESS_END(); +} diff --git a/tests/15-rpl-classic/code/project-conf.h b/tests/15-rpl-classic/code/project-conf.h index d6cd59471761d9f6bad11e269fa2bbb10c8fbe91..439cdef98e0ab2625b1fd3b1386c298832c31f6c 100644 --- a/tests/15-rpl-classic/code/project-conf.h +++ b/tests/15-rpl-classic/code/project-conf.h @@ -27,3 +27,4 @@ * SUCH DAMAGE. */ #define TCPIP_CONF_ANNOTATE_TRANSMISSIONS 1 +#define LOG_CONF_LEVEL_RPL LOG_LEVEL_INFO diff --git a/tests/15-rpl-classic/js/11-rpl-setting-dio-timer-by-dis.js b/tests/15-rpl-classic/js/11-rpl-setting-dio-timer-by-dis.js new file mode 100644 index 0000000000000000000000000000000000000000..f5858385482b427a063dc0318863af8337dc859c --- /dev/null +++ b/tests/15-rpl-classic/js/11-rpl-setting-dio-timer-by-dis.js @@ -0,0 +1,25 @@ +// we want to see ten DIOs by the root at least, tweleve at most, +// during the test of 60 seconds when RPL_DIO_INTERVAL_MIN is set to +// 12 (4 seconds) +var node_id_of_root = 1 +var expected_num_of_dios = 10; +var num_of_dios = 0; + +TIMEOUT(60000, log.testFailed()); // ms + +while(true) { + YIELD(); + + log.log(time + " node-" + id + " "+ msg + "\n"); + + if(id == node_id_of_root) { + if(msg.contains('Sending a multicast-DIO')) { + num_of_dios++; + } + + if(num_of_dios >= expected_num_of_dios) { + log.testOK(); + break; + } + } +} diff --git a/tests/17-tun-rpl-br/test-border-router.sh b/tests/17-tun-rpl-br/test-border-router.sh index a6944625429fbb5f4400780ac40a81bfc4e234c8..8bb591c9999510ddc07ced5fd9378206242278e3 100755 --- a/tests/17-tun-rpl-br/test-border-router.sh +++ b/tests/17-tun-rpl-br/test-border-router.sh @@ -21,6 +21,8 @@ PING_DELAY=${6:-1} # ICMP request-reply count COUNT=5 +# Test OK of COUNT_TARGET ok out of COUNT +COUNT_TARGET=3 # Start simulation echo "Starting Cooja simulation $BASENAME.csc" @@ -50,7 +52,7 @@ sleep 1 rm COOJA.testlog rm COOJA.log -if [ $STATUS -eq 0 ] && [ $REPLIES -eq $COUNT ] ; then +if [ $STATUS -eq 0 ] && [ $REPLIES -ge $COUNT_TARGET ] ; then printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog; else echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog; diff --git a/tests/17-tun-rpl-br/test-native-border-router.sh b/tests/17-tun-rpl-br/test-native-border-router.sh index 08b70dd2f150bf6b5e54d2994ede11dd842d2557..c35184a2db6b6c08a1069a3714788de2b63ec2ad 100755 --- a/tests/17-tun-rpl-br/test-native-border-router.sh +++ b/tests/17-tun-rpl-br/test-native-border-router.sh @@ -21,6 +21,8 @@ PING_DELAY=${6:-1} # ICMP request-reply count COUNT=5 +# Test OK of COUNT_TARGET ok out of COUNT +COUNT_TARGET=3 # Start simulation echo "Starting Cooja simulation $BASENAME.csc" @@ -50,7 +52,7 @@ sleep 1 rm COOJA.testlog rm COOJA.log -if [ $STATUS -eq 0 ] && [ $REPLIES -eq $COUNT ] ; then +if [ $STATUS -eq 0 ] && [ $REPLIES -ge $COUNT_TARGET ] ; then printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog; else echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog; diff --git a/tests/19-out-of-tree-build/Makefile b/tests/19-out-of-tree-build/Makefile index 30d7e230284016ca40df841f36bf3eec7bc288f8..20f1a10c27e0a474fe5c9367cbc0a3d88a4fc664 100644 --- a/tests/19-out-of-tree-build/Makefile +++ b/tests/19-out-of-tree-build/Makefile @@ -9,7 +9,7 @@ hello-world/sky \ hello-world/nrf52dk \ hello-world/cc2538dk \ hello-world/zoul \ -hello-world/openmote-cc2538 \ +hello-world/openmote \ hello-world/cc26x0-cc13x0 \ hello-world/jn516x \ hello-world/simplelink:BOARD=launchpad/cc26x2r1 \ diff --git a/tests/20-packet-parsing/01-test-uip.sh b/tests/20-packet-parsing/01-test-uip.sh new file mode 100755 index 0000000000000000000000000000000000000000..224fc307a9705c9495aede7ddffba07d9381feb0 --- /dev/null +++ b/tests/20-packet-parsing/01-test-uip.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +export TEST_PROTOCOL=uip + +source packet-injector.sh diff --git a/tests/20-packet-parsing/02-test-sicslowpan.sh b/tests/20-packet-parsing/02-test-sicslowpan.sh new file mode 100755 index 0000000000000000000000000000000000000000..f56b7f1c942f3a67e29da9fd02ccf615410406c7 --- /dev/null +++ b/tests/20-packet-parsing/02-test-sicslowpan.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +export TEST_PROTOCOL=sicslowpan + +source packet-injector.sh diff --git a/tests/20-packet-parsing/Makefile b/tests/20-packet-parsing/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..c46e5271d5a3d2374a99b4d70b09ac5e8870495b --- /dev/null +++ b/tests/20-packet-parsing/Makefile @@ -0,0 +1 @@ +include ../Makefile.script-test diff --git a/tests/20-packet-parsing/packet-injector.sh b/tests/20-packet-parsing/packet-injector.sh new file mode 100755 index 0000000000000000000000000000000000000000..b156faf0a2323485fa968505031fe9594ead446b --- /dev/null +++ b/tests/20-packet-parsing/packet-injector.sh @@ -0,0 +1,70 @@ +#!/bin/bash +source ../utils.sh + +# Contiki directory +CONTIKI=$1 + +# Basic statistics for packet parsing results. +SUCCEEDED=0 +FAILED=0 +TIMEDOUT=0 + +# Example code directory +CODE_DIR=packet-injector +CODE=packet-injector +PACKET_DIR=$CODE_DIR/$TEST_PROTOCOL-data +echo packet dir = $PACKET_DIR + +# Starting Contiki-NG native node +echo "Starting native node" +make -C $CODE_DIR TARGET=native > make.log 2> make.err + +for i in $PACKET_DIR/* +do + export TEST_FILE=$i + echo Injecting file $TEST_FILE + timeout -k 1s 2s sh -c "$CODE_DIR/$CODE.native >> $CODE.log 2>> $CODE.err" + INJECTOR_EXIT_CODE=$? + echo "exit code:" $INJECTOR_EXIT_CODE + + case $INJECTOR_EXIT_CODE in + 0) echo "Packet $i: SUCCESS" + SUCCEEDED=$((SUCCEEDED + 1)) + ;; + 124) echo "Packet $i: TIMEOUT" + TIMEDOUT=$((TIMEDOUT + 1)) + ;; + *) echo "Packet $i: FAILURE" + FAILED=$((FAILED + 1)) + ;; + esac +done + +echo "Closing native node" + +if [ $((TIMEDOUT + FAILED)) -gt 0 ]; then + echo "==== make.log ====" ; cat make.log; + echo "==== make.err ====" ; cat make.err; + echo "==== $CODE.log ====" ; cat $CODE.log; + echo "==== $CODE.err ====" ; cat $CODE.err; + + printf "%-32s TEST FAIL\n" "$CODE-$TEST_PROTOCOL" | tee $CODE.testlog; +else + cp $CODE.log $CODE.testlog + printf "%-32s TEST OK\n" "$CODE-$TEST_PROTOCOL" | tee $CODE.testlog; +fi + +rm make.log +rm make.err +rm $CODE.log +rm $CODE.err + +echo "Succeeded: " $SUCCEEDED +echo "Timed out: " $TIMEDOUT +echo "Failed : " $FAILED + +sleep 3 + +# We do not want Make to stop -> Return 0 +# The Makefile will check if a log contains FAIL at the end +exit 0 diff --git a/tests/20-packet-parsing/packet-injector/Makefile b/tests/20-packet-parsing/packet-injector/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9b34174218c330adfcad3d42713988753851d1de --- /dev/null +++ b/tests/20-packet-parsing/packet-injector/Makefile @@ -0,0 +1,10 @@ +CONTIKI_PROJECT = packet-injector +all: $(CONTIKI_PROJECT) + +PLATFORM_ONLY = native +TARGET = native + +MODULES += os/net/app-layer/coap + +CONTIKI = ../../../ +include $(CONTIKI)/Makefile.include diff --git a/tests/20-packet-parsing/packet-injector/packet-injector.c b/tests/20-packet-parsing/packet-injector/packet-injector.c new file mode 100644 index 0000000000000000000000000000000000000000..0f6426d2b385d51b1878c8441aa86c9d0a509a9f --- /dev/null +++ b/tests/20-packet-parsing/packet-injector/packet-injector.c @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2019, RISE Research Institutes of Sweden AB + * 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 Institute 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 INSTITUTE 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 INSTITUTE 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 + * Packet injector for various protocol implementations in Contiki-NG. + * \author + * Nicolas Tsiftes <nicolas.tsiftes@ri.se> + */ + +#include "contiki.h" + +/* Standard C and POSIX headers. */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +/* Contiki-NG headers. */ +#include <net/ipv6/uip.h> +#include <net/ipv6/uiplib.h> +#include <net/netstack.h> +#include <net/packetbuf.h> +#include <net/ipv6/sicslowpan.h> +#include <net/app-layer/coap/coap.h> +#include <net/app-layer/coap/coap-engine.h> + +/* Log configuration. */ +#include "sys/log.h" +#define LOG_MODULE "PacketInjector" +#define LOG_LEVEL LOG_LEVEL_INFO + +#define TEST_PROTOCOL_DEFAULT "uip" +#define TEST_FILE_DEFAULT "fuzzing-input" +#define TEST_BUFFER_SIZE 2000 + +#define TEST_COAP_ENDPOINT "fdfd::100" +#define TEST_COAP_PORT 8293 + +typedef bool (*protocol_function_t)(char *, int); + +/*---------------------------------------------------------------------------*/ +PROCESS(packet_injector_process, "Packet injector process"); +AUTOSTART_PROCESSES(&packet_injector_process); +/*---------------------------------------------------------------------------*/ +static int +read_packet(const char *filename, char *buf, int max_len) +{ + int fd; + int len; + + /* Read packet data from a file. */ + fd = open(filename, O_RDONLY); + if(fd < 0) { + LOG_ERR("open: %s\n", strerror(errno)); + return -1; + } + + len = read(fd, buf, max_len); + if(len < 0) { + LOG_ERR("read: %s\n", strerror(errno)); + return -1; + } + + return len; +} +/*---------------------------------------------------------------------------*/ +static bool +inject_coap_packet(char *data, int len) +{ + static coap_endpoint_t end_point; + + uiplib_ipaddrconv(TEST_COAP_ENDPOINT, &end_point.ipaddr); + end_point.port = TEST_COAP_PORT; + end_point.secure = 0; + + coap_endpoint_print(&end_point); + + coap_receive(&end_point, (uint8_t *)data, len); + + return true; +} +/*---------------------------------------------------------------------------*/ +static bool +inject_uip_packet(char *data, int len) +{ + if(len > sizeof(uip_buf)) { + LOG_DBG("Adjusting the input length from %d to %d to fit the uIP buffer\n", + len, (int)sizeof(uip_buf)); + len = sizeof(uip_buf); + } + + uip_len = len; + + /* Fill uIP buffer with packet data. */ + memcpy(uip_buf, data, len); + + uip_input(); + + return true; +} +/*---------------------------------------------------------------------------*/ +static bool +inject_sicslowpan_packet(char *data, int len) +{ + packetbuf_copyfrom(data, len); + + NETSTACK_NETWORK.input(); + NETSTACK_FRAMER.parse(); + + sicslowpan_driver.input(); + + return true; +} +/*---------------------------------------------------------------------------*/ +protocol_function_t +select_protocol(const char *protocol_name) +{ + struct proto_mapper { + const char *protocol_name; + protocol_function_t function; + }; + struct proto_mapper map[] = { + {"coap", inject_coap_packet}, + {"sicslowpan", inject_sicslowpan_packet}, + {"uip", inject_uip_packet} + }; + int i; + + if(protocol_name == NULL) { + return NULL; + } + + for(i = 0; i < sizeof(map) / sizeof(map[0]); i++) { + if(strcasecmp(protocol_name, map[i].protocol_name) == 0) { + return map[i].function; + } + } + + return NULL; +} +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(packet_injector_process, ev, data) +{ + static char file_buf[TEST_BUFFER_SIZE]; + static int len; + static const char *filename; + static const char *protocol_name; + static protocol_function_t protocol_input; + + PROCESS_BEGIN(); + + filename = getenv("TEST_FILE"); + if(filename == NULL) { + filename = TEST_FILE_DEFAULT; + } + + protocol_name = getenv("TEST_PROTOCOL"); + if(protocol_name == NULL) { + protocol_name = TEST_PROTOCOL_DEFAULT; + } + + LOG_INFO("Using input file \"%s\"\n", filename); + + len = read_packet(filename, file_buf, TEST_BUFFER_SIZE); + if(len < 0) { + LOG_ERR("Unable to read packet data: %s\n", strerror(errno)); + exit(EXIT_FAILURE); + } + + protocol_input = select_protocol(protocol_name); + if(protocol_input == NULL) { + LOG_ERR("unsupported protocol: \"%s\"\n", + protocol_name == NULL ? "<null>" : protocol_name); + exit(EXIT_FAILURE); + } + + LOG_INFO("Injecting a packet of %d bytes into %s\n", len, protocol_name); + + if(protocol_input(file_buf, len) == false) { + exit(EXIT_FAILURE); + } + + exit(EXIT_SUCCESS); + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-01 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-01 new file mode 100644 index 0000000000000000000000000000000000000000..ac24062c30cdd7da63c77830d25948fe20a3210f Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-01 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-02 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-02 new file mode 100644 index 0000000000000000000000000000000000000000..b7cfa5a4ceda00a61d321f011a598132ee7bc305 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-02 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-03 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-03 new file mode 100644 index 0000000000000000000000000000000000000000..1f9c7de0e0d721e0777587800f88c49c02fb3679 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-03 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-04 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-04 new file mode 100644 index 0000000000000000000000000000000000000000..aebc91f9374724f130863f54f37ebbdf01c1c9f3 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-04 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-05 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-05 new file mode 100644 index 0000000000000000000000000000000000000000..d6b97f053f98d27fd1e1316a23905cc4b4bb5b46 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-05 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-06 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-06 new file mode 100644 index 0000000000000000000000000000000000000000..6e30ead6e731b898565e1ae160faa75c806e2c2a Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-06 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-07 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-07 new file mode 100644 index 0000000000000000000000000000000000000000..586fa14c8b2327bdfd883f279be5738798023f4e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-07 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-08 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-08 new file mode 100644 index 0000000000000000000000000000000000000000..6a896e2d9c5a9a93c827b897355492b5c066749f Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-08 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-09 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-09 new file mode 100644 index 0000000000000000000000000000000000000000..282b29299cf2d6586b18bcfee4f51043bf592f1e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-09 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-10 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-10 new file mode 100644 index 0000000000000000000000000000000000000000..b1946797c2020918ea936f5b5a5c0e93f3c9dc0e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-10 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-11 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-11 new file mode 100644 index 0000000000000000000000000000000000000000..e589acb92b2c6dfdd69d90054eb27b06cc80dc5e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-11 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-12 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-12 new file mode 100644 index 0000000000000000000000000000000000000000..97c9e856d2056f300bd72b83286d9bba65678022 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-12 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-13 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-13 new file mode 100644 index 0000000000000000000000000000000000000000..2dc45d61380aee15eb99479d21be3ce6061d29a9 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-13 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-14 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-14 new file mode 100644 index 0000000000000000000000000000000000000000..97914199e19b6c2880dff603fa051ef05815f810 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-14 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-15 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-15 new file mode 100644 index 0000000000000000000000000000000000000000..e62371c2d2ca2f352c9c6614a2844b08a8dafb83 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-15 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-16 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-16 new file mode 100644 index 0000000000000000000000000000000000000000..232e9b9f353b5ed31472323a4f0e496db57db348 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-16 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-17 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-17 new file mode 100644 index 0000000000000000000000000000000000000000..837a05e66484876d9bd53abf1fc440b389e5bb48 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-17 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-18 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-18 new file mode 100644 index 0000000000000000000000000000000000000000..a361383d0a1ffacaa3e290ad0cdd204ac5eda91b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-18 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-19 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-19 new file mode 100644 index 0000000000000000000000000000000000000000..746f81b8ef6428dbda80009b006f7669e2d9d7a0 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-19 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-20 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-20 new file mode 100644 index 0000000000000000000000000000000000000000..cbc7ae5112419d822a25697f82a77f878082458a Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-20 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-21 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-21 new file mode 100644 index 0000000000000000000000000000000000000000..44e10c164faeee88c8235ae2d9b5c0569e82a6ac Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-21 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-22 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-22 new file mode 100644 index 0000000000000000000000000000000000000000..0275d2548e42b18a7b177fd2b22ee7d137084621 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-22 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-23 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-23 new file mode 100644 index 0000000000000000000000000000000000000000..3b790e5fb90f6084d81193907f711d1debce825e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-23 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-24 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-24 new file mode 100644 index 0000000000000000000000000000000000000000..3fb57daee7187b0645b853c852b7424c0b6ee0e8 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-24 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-25 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-25 new file mode 100644 index 0000000000000000000000000000000000000000..3cb8c1c9006a6f04b5c5bc6f48d9e06e368ed07b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-25 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-26 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-26 new file mode 100644 index 0000000000000000000000000000000000000000..b4bbde9610f08740180757d485f89de1cdf920cf Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-26 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-27 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-27 new file mode 100644 index 0000000000000000000000000000000000000000..b3afde701dc66d78613bcd8e6a0fab72a2fddfc6 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-27 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-28 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-28 new file mode 100644 index 0000000000000000000000000000000000000000..32486da04abd423c40ebe7948180b09a397d4182 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-28 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-29 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-29 new file mode 100644 index 0000000000000000000000000000000000000000..1aafb1fa0f70447a17bfeb1623b9ae9b6a00b2e3 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-29 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-30 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-30 new file mode 100644 index 0000000000000000000000000000000000000000..9629e749ffcd1400cec8d715f575980ac8de181b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-30 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-31 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-31 new file mode 100644 index 0000000000000000000000000000000000000000..5be524ec46d6d4ec82301de072276ce6486eee6d Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-31 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-32 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-32 new file mode 100644 index 0000000000000000000000000000000000000000..df67e9ac584fd19c6dabdab311234b2da088a9c5 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-32 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-33 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-33 new file mode 100644 index 0000000000000000000000000000000000000000..3ab98dcda38eb79606d37aabe8a87e82ec6f268b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-33 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-34 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-34 new file mode 100644 index 0000000000000000000000000000000000000000..6d89bcc8d814587ddd1457951cae85e542d30247 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-34 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-35 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-35 new file mode 100644 index 0000000000000000000000000000000000000000..f5ea777a16146c1712ae049b186488fae88fcffb Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-35 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-36 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-36 new file mode 100644 index 0000000000000000000000000000000000000000..4bdc7def24b05b601f422543c4eac1210f61dee2 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-36 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-37 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-37 new file mode 100644 index 0000000000000000000000000000000000000000..9b1fbcbbc9c25102bff24a6f3890ae479d15677a Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-37 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-38 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-38 new file mode 100644 index 0000000000000000000000000000000000000000..be1f3700602acb2a65cd8c20c9a0f12f5594863b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-38 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-39 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-39 new file mode 100644 index 0000000000000000000000000000000000000000..5c393db1201e964527295da9cb96f0bedf191eb7 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-39 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-40 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-40 new file mode 100644 index 0000000000000000000000000000000000000000..bc22bec236ad416ea5700e3c6dea95f4d4b41d18 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-40 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-41 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-41 new file mode 100644 index 0000000000000000000000000000000000000000..12d555e9c05c4c652e268b03bc2bf74ed8c3e537 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-41 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-42 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-42 new file mode 100644 index 0000000000000000000000000000000000000000..d81c73415628b9842cbd219f5e15dccf31120d5b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-42 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-43 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-43 new file mode 100644 index 0000000000000000000000000000000000000000..0d8549b878c2e48e17e812979dd703556a69ae07 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-43 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-44 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-44 new file mode 100644 index 0000000000000000000000000000000000000000..94dc112d25c90fa82bfbf45e5db7243788415131 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-44 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-45 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-45 new file mode 100644 index 0000000000000000000000000000000000000000..03189fb46255022e786a19114cf040cb00edf9f9 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-45 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-46 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-46 new file mode 100644 index 0000000000000000000000000000000000000000..1bf5b7c26bcd49c5074cc57fdbc950075a77519b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-46 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-47 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-47 new file mode 100644 index 0000000000000000000000000000000000000000..766e115bb23fc5526f37a64691447b4bfbbbfa95 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-47 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-48 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-48 new file mode 100644 index 0000000000000000000000000000000000000000..0752e3b5741f67e73df1d87671b7a06d8547c351 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-48 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-49 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-49 new file mode 100644 index 0000000000000000000000000000000000000000..2ebd50f5e90c38e8501da60377f60fe5fd4c3d48 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-49 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-50 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-50 new file mode 100644 index 0000000000000000000000000000000000000000..3b50b7ec96a957cdc8d0523123c3f72c78df244b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-50 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-51 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-51 new file mode 100644 index 0000000000000000000000000000000000000000..3feaeb280ceefda0d89bbb13d8912f58381bd664 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-51 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-52 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-52 new file mode 100644 index 0000000000000000000000000000000000000000..7913c4c08e89bdc6636736e4bf3f5c0bb2d2b035 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-52 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-53 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-53 new file mode 100644 index 0000000000000000000000000000000000000000..fa882f44a4f00130d4d663c357d63a70b701734f Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-53 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-54 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-54 new file mode 100644 index 0000000000000000000000000000000000000000..f6bae0c880aae04a17fd4dc7d643e31567d13c62 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-54 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-55 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-55 new file mode 100644 index 0000000000000000000000000000000000000000..e584d114a0b575742089cc4c26bd2f576803ce70 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-55 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-56 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-56 new file mode 100644 index 0000000000000000000000000000000000000000..fb863122ad6a8602a2176d8369d58e0514f49cd5 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-56 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-57 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-57 new file mode 100644 index 0000000000000000000000000000000000000000..8d3ecc2bba39815efc97afe74b17339b9a6722b2 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-57 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-58 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-58 new file mode 100644 index 0000000000000000000000000000000000000000..313123e1876f078f2ca0a09bd122e77aedee8d05 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-58 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-59 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-59 new file mode 100644 index 0000000000000000000000000000000000000000..b64bc5c2205a50c42c1cccbcc36a2dd55f5ab113 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-59 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-60 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-60 new file mode 100644 index 0000000000000000000000000000000000000000..859fe7d62fb890ba05c6b0df7a0c4d5669912747 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-60 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-61 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-61 new file mode 100644 index 0000000000000000000000000000000000000000..82b1bba291d55871209b7698cd749cf3c080130f Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-61 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-62 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-62 new file mode 100644 index 0000000000000000000000000000000000000000..ce91e3977ce5ffdf99612d40a17547f0d59e0795 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-62 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-63 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-63 new file mode 100644 index 0000000000000000000000000000000000000000..0b3933eed636f2866bd644b1aec5e2b869fe6d6b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-63 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-64 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-64 new file mode 100644 index 0000000000000000000000000000000000000000..060c29ba04fda42ba95d23876dac09a00aca10fc Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-64 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-65 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-65 new file mode 100644 index 0000000000000000000000000000000000000000..2ad3c925f3115fada14e36eb338749fc759c76a4 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-65 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-66 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-66 new file mode 100644 index 0000000000000000000000000000000000000000..cded20d67100690c1b624107f861e14918667489 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-66 differ diff --git a/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-67 b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-67 new file mode 100644 index 0000000000000000000000000000000000000000..1662b155e5540ee971f92b6835353ce1c37a68ac Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/sicslowpan-data/sicslowpan-packet-67 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-001 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-001 new file mode 100644 index 0000000000000000000000000000000000000000..f4238044103165f01f79ef79b254c9b434df638a Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-001 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-002 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-002 new file mode 100644 index 0000000000000000000000000000000000000000..4f3603c38f1db6fd1311bc6393c3c9dc86c459cb Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-002 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-003 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-003 new file mode 100644 index 0000000000000000000000000000000000000000..bce9fb145d5f4bb2b5b612109b77586ba4ee6637 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-003 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-004 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-004 new file mode 100644 index 0000000000000000000000000000000000000000..1502bd9b4f5d122c6f0a8d5e21a726bab70f9cbf Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-004 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-005 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-005 new file mode 100644 index 0000000000000000000000000000000000000000..df1892e121043d8d60ad35aae664102bedeb6e4e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-005 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-006 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-006 new file mode 100644 index 0000000000000000000000000000000000000000..d759c5e68d86b9d000c4881fd5de3405c2fc8a36 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-006 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-007 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-007 new file mode 100644 index 0000000000000000000000000000000000000000..d261078d50f33ec5bc2bfff246604ea27fc1e8c8 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-007 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-008 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-008 new file mode 100644 index 0000000000000000000000000000000000000000..482aaa4045bffe01d9c95d66bb205977c9e6362e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-008 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-009 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-009 new file mode 100644 index 0000000000000000000000000000000000000000..955e90640289a2ba595a820e1deaf6547e0bbc8f Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-009 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-010 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-010 new file mode 100644 index 0000000000000000000000000000000000000000..f9d499ffdb7edbbfb04e9025ca56df66524e006e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-010 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-011 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-011 new file mode 100644 index 0000000000000000000000000000000000000000..d03d219ec33832dfb6cd9e57bf485c96268345b9 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-011 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-012 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-012 new file mode 100644 index 0000000000000000000000000000000000000000..766e9cba05f31d3d8e9461b443258892a2098605 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-012 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-013 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-013 new file mode 100644 index 0000000000000000000000000000000000000000..9ec3a5aa8b471f1fbce43a7efe0a46c47b4e896d Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-013 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-014 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-014 new file mode 100644 index 0000000000000000000000000000000000000000..14c770193d22f6f16f1fb844b6ce571b98222e5e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-014 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-015 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-015 new file mode 100644 index 0000000000000000000000000000000000000000..c2a09235ae1cd03cb03e0d1f7362e0ce51565002 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-015 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-016 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-016 new file mode 100644 index 0000000000000000000000000000000000000000..a8565305c267aa37179bfac93627b0c5b2a0524b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-016 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-017 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-017 new file mode 100644 index 0000000000000000000000000000000000000000..251ac5eedbd6d9cc69c09d66766c7fb36160f96e Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-017 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-018 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-018 new file mode 100644 index 0000000000000000000000000000000000000000..173b8760eb37064c11baf5cdfe4e81e46f499fb7 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-018 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-019 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-019 new file mode 100644 index 0000000000000000000000000000000000000000..766de0caffb9b8d378ea85467a37d0c173434397 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-019 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-020 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-020 new file mode 100644 index 0000000000000000000000000000000000000000..8a3c9507e37982e69783989dbdd881ddc116ead9 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-020 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-021 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-021 new file mode 100644 index 0000000000000000000000000000000000000000..ff3668fdddd1d14e90729c503984c62d0163d596 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-021 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-022 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-022 new file mode 100644 index 0000000000000000000000000000000000000000..75f72d10c349ec8cab8256ff9d714b37d82b1a4b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-022 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-023 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-023 new file mode 100644 index 0000000000000000000000000000000000000000..a117bf9591d773f288ed4bd5584ad2f9233463af Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-023 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-024 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-024 new file mode 100644 index 0000000000000000000000000000000000000000..9487bf17213f1e70506a5d33ca380084f17a4e63 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-024 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-025 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-025 new file mode 100644 index 0000000000000000000000000000000000000000..7e99f76a8b6c9340a41e156d4397e2a528707492 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-025 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-026 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-026 new file mode 100644 index 0000000000000000000000000000000000000000..694a9cc4ea01aaad9adca75aae6c7c8c790404bc Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-026 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-027 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-027 new file mode 100644 index 0000000000000000000000000000000000000000..c33b52bb62b6e6cbc12cfb416fe89501bc183c07 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-027 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-028 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-028 new file mode 100644 index 0000000000000000000000000000000000000000..9ff8f3800b2b9929a867850f6681025df22cf32f Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-028 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-029 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-029 new file mode 100644 index 0000000000000000000000000000000000000000..054799a46035353b9ed141606371b313e3219c4f Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-029 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-030 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-030 new file mode 100644 index 0000000000000000000000000000000000000000..70b38b88c1f93d68475ef3face05209dd871207d Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-030 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-031 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-031 new file mode 100644 index 0000000000000000000000000000000000000000..473f7ee6c32e7ecff8aab0c63d9aa0af907fde4b Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-031 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-032 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-032 new file mode 100644 index 0000000000000000000000000000000000000000..c238965f1ce2b084e795c9680af6ac867c7e6c67 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-032 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-033 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-033 new file mode 100644 index 0000000000000000000000000000000000000000..d7dbbe514b9dd2b9eacdb46c5cfdf9225b62cf33 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-033 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-034 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-034 new file mode 100644 index 0000000000000000000000000000000000000000..dc014bdbf7db981214afe05957030210b3d29eac Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-034 differ diff --git a/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-035 b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-035 new file mode 100644 index 0000000000000000000000000000000000000000..4116c5906d08a35777c370a6a6953616f31edf12 Binary files /dev/null and b/tests/20-packet-parsing/packet-injector/uip-data/uip-packet-035 differ diff --git a/tests/utils.sh b/tests/utils.sh index bd00ca539e6453d88fb7d090cb3e58d6972473c1..b9b40622b86806ec8ae5b4b30f6770fd9cb578c0 100755 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -6,15 +6,18 @@ function echo_run( ) $@ } +# arg 1: PID +# arg 2 (optional): signal (default: 9) function kill_bg( ) { PID=$1 CMD=$(ps -p $PID -o cmd=) SUDO= TOKILL=$PID + SIGNAL=${2:-9} if [[ ${CMD:0:5} == "sudo " ]] ; then SUDO="sudo " TOKILL=$(ps --ppid $PID -o pid=) fi - echo_run ${SUDO}kill -9 $TOKILL + echo_run ${SUDO}kill -$SIGNAL $TOKILL } diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 6eb9dbb179d70e7e03ca591e7a28b5cf0f82e33c..6a697625ed67730e167ab03007d8dc7945a7812b 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -29,12 +29,16 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E03280 srecord \ uml-utilities \ unzip \ + valgrind \ wget \ + smitools \ + snmp \ + snmp-mibs-downloader \ > /dev/null \ && apt-get -qq clean # Install coap-cli -RUN npm -q install coap-cli -g \ +RUN npm -q install coap-cli@0.5.1 -g \ && sudo ln -s /usr/bin/nodejs /usr/bin/node # Install ARM toolchain @@ -119,8 +123,5 @@ ENV PATH="${HOME}/renode:${PATH}" # Working directory WORKDIR ${CONTIKI_NG} -# Enable IPv6 -- must be done at runtime, hence added to .profile -RUN echo "sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 > /dev/null" >> ${HOME}/.profile - # Start a bash CMD bash --login diff --git a/tools/serial-io/tunslip6.c b/tools/serial-io/tunslip6.c index 61013c30c11e75e3b328f25b87ea07b567340cd8..168f2dc0b8f350aea787c61f734a73f24d838b1b 100644 --- a/tools/serial-io/tunslip6.c +++ b/tools/serial-io/tunslip6.c @@ -64,7 +64,7 @@ #endif speed_t b_rate = BAUDRATE; -int verbose = 1; +int verbose = 2; const char *ipaddr; const char *netmask; int slipfd = 0; @@ -862,13 +862,13 @@ fprintf(stderr," -v level Verbosity level\n"); fprintf(stderr," -v[level] Verbosity level\n"); #endif fprintf(stderr," -v0 No messages\n"); -fprintf(stderr," -v1 Encapsulated SLIP debug messages (default)\n"); -fprintf(stderr," -v2 Printable strings after they are received\n"); +fprintf(stderr," -v1 Encapsulated SLIP debug messages\n"); +fprintf(stderr," -v2 Printable strings after they are received (default)\n"); fprintf(stderr," -v3 Printable strings and SLIP packet notifications\n"); fprintf(stderr," -v4 All printable characters as they are received\n"); fprintf(stderr," -v5 All SLIP packets in hex\n"); #ifndef __APPLE__ -fprintf(stderr," -v Equivalent to -v3\n"); +fprintf(stderr," -v Equivalent to -v2\n"); #endif fprintf(stderr," -d[basedelay] Minimum delay between outgoing SLIP packets.\n"); fprintf(stderr," Actual delay is basedelay*(#6LowPAN fragments) milliseconds.\n"); diff --git a/tools/viewconf/viewconf.c b/tools/viewconf/viewconf.c index c762e02f6f8f72df4d7bff8b7dbb895760d8b5dc..53a38cf6f3cbd94c1e870d26c0897a5978226770 100644 --- a/tools/viewconf/viewconf.c +++ b/tools/viewconf/viewconf.c @@ -31,7 +31,7 @@ #if MAC_CONF_WITH_TSCH #ifdef TSCH_CONF_DEFAULT_HOPPING_SEQUENCE -##### "TSCH_CONF_DEFAULT_HOPPING_SEQUENCE": ____ == TTSCH_CONF_DEFAULT_HOPPING_SEQUENCE +##### "TSCH_CONF_DEFAULT_HOPPING_SEQUENCE": ____ == TSCH_CONF_DEFAULT_HOPPING_SEQUENCE #else ##### "TSCH_CONF_DEFAULT_HOPPING_SEQUENCE": ____ -> TSCH_DEFAULT_HOPPING_SEQUENCE #endif @@ -88,8 +88,6 @@ ##### "NBR_TABLE_CONF_MAX_NEIGHBORS": __________ -> NBR_TABLE_MAX_NEIGHBORS #endif -##### "NETSTACK_RADIO_MAX_PAYLOAD_LEN": ________ == NETSTACK_RADIO_MAX_PAYLOAD_LEN - ##### "NETSTACK_MAX_ROUTE_ENTRIES": ____________ == NETSTACK_MAX_ROUTE_ENTRIES ##### "UIP_CONF_BUFFER_SIZE": __________________ == UIP_CONF_BUFFER_SIZE ##### "UIP_CONF_UDP": __________________________ == UIP_CONF_UDP @@ -151,5 +149,6 @@ ##### "LOG_CONF_LEVEL_FRAMER": _________________ == LOG_CONF_LEVEL_FRAMER ##### "LOG_CONF_LEVEL_6TOP": ___________________ == LOG_CONF_LEVEL_6TOP ##### "LOG_CONF_LEVEL_COAP": ___________________ == LOG_CONF_LEVEL_COAP +##### "LOG_CONF_LEVEL_SNMP": ___________________ == LOG_CONF_LEVEL_SNMP ##### "LOG_CONF_LEVEL_LWM2M": __________________ == LOG_CONF_LEVEL_LWM2M ##### "LOG_CONF_LEVEL_MAIN": ___________________ == LOG_CONF_LEVEL_MAIN