Merge branch 'develop' into simonduq-patch-1
This commit is contained in:
commit
06b12a0a72
|
@ -20,8 +20,6 @@ tools/tunslip6
|
|||
build
|
||||
tools/coffee-manager/build/
|
||||
tools/coffee-manager/coffee.jar
|
||||
tools/collect-view/build/
|
||||
tools/collect-view/dist/
|
||||
COOJA.testlog
|
||||
|
||||
# platform build artifacts
|
||||
|
|
|
@ -13,3 +13,9 @@
|
|||
[submodule "tools/cooja"]
|
||||
path = tools/cooja
|
||||
url = https://github.com/contiki-ng/cooja.git
|
||||
[submodule "os/net/security/tinydtls"]
|
||||
path = os/net/security/tinydtls
|
||||
url = https://github.com/contiki-ng/tinydtls.git
|
||||
[submodule "tests/18-coap-lwm2m/example-lwm2m-standalone"]
|
||||
path = tests/18-coap-lwm2m/example-lwm2m-standalone
|
||||
url = https://github.com/contiki-ng/example-lwm2m-standalone.git
|
||||
|
|
|
@ -14,7 +14,7 @@ before_install:
|
|||
- ant -q -f $CNG_HOST_PATH/tools/cooja/build.xml jar
|
||||
|
||||
script: # The test script for each build.
|
||||
- docker run --privileged -v $CNG_HOST_PATH:/home/user/contiki-ng -ti $DOCKER_IMG bash -c "make -C tests/??-$TEST_NAME";
|
||||
- docker run --privileged -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 $?;
|
||||
|
||||
|
@ -26,6 +26,7 @@ env:
|
|||
- TEST_NAME='rpl-lite'
|
||||
- TEST_NAME='rpl-classic'
|
||||
- TEST_NAME='tun-rpl-br'
|
||||
- TEST_NAME='coap-lwm2m'
|
||||
- TEST_NAME='simulation-base'
|
||||
- TEST_NAME='ieee802154'
|
||||
- TEST_NAME='compile-nxp-ports'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Contiki is licensed under the 3-clause BSD license. This license gives
|
||||
Contiki-NG is licensed under the 3-clause BSD license. This license gives
|
||||
everyone the right to use and distribute the code, either in binary or
|
||||
source code format, as long as the copyright license is retained in
|
||||
the source code.
|
||||
|
|
126
Makefile.include
126
Makefile.include
|
@ -8,7 +8,7 @@ endif
|
|||
# Setting this option is also important for tests on Cooja motes to check for warnings.
|
||||
WERROR ?= 1
|
||||
|
||||
include $(CONTIKI)/Makefile.identify-target
|
||||
include $(CONTIKI)/Makefile.identify-target
|
||||
|
||||
ifeq ($(DEFINES),)
|
||||
-include Makefile.$(TARGET).defines
|
||||
|
@ -40,9 +40,11 @@ LOWERCASE = -abcdefghijklmnopqrstuvwxyz/
|
|||
UPPERCASE = _ABCDEFGHIJKLMNOPQRSTUVWXYZ_
|
||||
TARGET_UPPERCASE := ${strip ${shell echo $(TARGET) | sed y!$(LOWERCASE)!$(UPPERCASE)!}}
|
||||
CFLAGS += -DCONTIKI=1 -DCONTIKI_TARGET_$(TARGET_UPPERCASE)=1
|
||||
CFLAGS += -DCONTIKI_TARGET_STRING=\"$(TARGET)\"
|
||||
ifneq ($(BOARD),)
|
||||
TARGET_BOARD_UPPERCASE := ${strip ${shell echo $(BOARD) | sed y!$(LOWERCASE)!$(UPPERCASE)!}}
|
||||
CFLAGS += -DCONTIKI_BOARD_$(TARGET_BOARD_UPPERCASE)=1
|
||||
CFLAGS += -DCONTIKI_BOARD_STRING=\"$(BOARD)\"
|
||||
endif
|
||||
|
||||
MODULES += os os/sys os/dev os/lib os/services
|
||||
|
@ -52,12 +54,17 @@ ifneq ("$(wildcard project-conf.h)","")
|
|||
CFLAGS += -DPROJECT_CONF_PATH=\"project-conf.h\"
|
||||
endif
|
||||
|
||||
MODULES += os os/net os/net/mac os/storage
|
||||
MODULES += os os/net os/net/mac os/net/mac/framer os/net/routing os/storage
|
||||
|
||||
oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}}
|
||||
define oname
|
||||
${patsubst %.c,%.o, \
|
||||
${patsubst %.S,%.o, \
|
||||
${patsubst %.s,%.o, \
|
||||
$(1) \
|
||||
}}}
|
||||
endef
|
||||
|
||||
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}}
|
||||
|
||||
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}}
|
||||
|
||||
# Provide way to create $(OBJECTDIR) if it has been removed by make clean
|
||||
|
@ -80,13 +87,43 @@ else
|
|||
include $(target_makefile)
|
||||
endif
|
||||
|
||||
# Decide whether to build or to skip this target for this platform
|
||||
ifneq ("", "$(PLATFORMS_ONLY)")
|
||||
ifeq ("","$(filter $(TARGET), $(PLATFORMS_ONLY))")
|
||||
PLATFORM_ACTION = skip
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ("", "$(PLATFORMS_EXCLUDE)")
|
||||
ifneq ("","$(filter $(TARGET), $(PLATFORMS_EXCLUDE))")
|
||||
PLATFORM_ACTION = skip
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD),)
|
||||
ifneq ("", "$(BOARDS_ONLY)")
|
||||
ifeq ("","$(filter $(BOARD), $(BOARDS_ONLY))")
|
||||
PLATFORM_ACTION = skip
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ("", "$(BOARDS_EXCLUDE)")
|
||||
ifneq ("","$(filter $(BOARD), $(BOARDS_EXCLUDE))")
|
||||
PLATFORM_ACTION = skip
|
||||
endif
|
||||
endif
|
||||
endif # $(BOARD) not empty
|
||||
|
||||
PLATFORM_ACTION ?= build
|
||||
|
||||
# Configure MAC layer
|
||||
|
||||
# The different options
|
||||
MAKE_MAC_NULLMAC = 0
|
||||
MAKE_MAC_CSMA = 1
|
||||
MAKE_MAC_TSCH = 2
|
||||
MAKE_MAC_OTHER = 3
|
||||
MAKE_MAC_BLE = 3
|
||||
MAKE_MAC_OTHER = 4
|
||||
|
||||
# Make CSMA the default MAC
|
||||
MAKE_MAC ?= MAKE_MAC_CSMA
|
||||
|
@ -106,6 +143,11 @@ ifeq ($(MAKE_MAC),MAKE_MAC_TSCH)
|
|||
CFLAGS += -DMAC_CONF_WITH_TSCH=1
|
||||
endif
|
||||
|
||||
ifeq ($(MAKE_MAC),MAKE_MAC_BLE)
|
||||
MODULES += os/net/mac/ble
|
||||
CFLAGS += -DMAC_CONF_WITH_BLE=1
|
||||
endif
|
||||
|
||||
ifeq ($(MAKE_MAC),MAKE_MAC_OTHER)
|
||||
CFLAGS += -DMAC_CONF_WITH_OTHER=1
|
||||
endif
|
||||
|
@ -140,7 +182,7 @@ ifeq ($(WITH_IP64),1)
|
|||
endif
|
||||
|
||||
# Configure Routing protocol
|
||||
MAKE_ROUTING_NONE = 0
|
||||
MAKE_ROUTING_NULLROUTING = 0
|
||||
MAKE_ROUTING_RPL_CLASSIC = 1
|
||||
MAKE_ROUTING_RPL_LITE = 2
|
||||
|
||||
|
@ -148,28 +190,36 @@ MAKE_ROUTING_RPL_LITE = 2
|
|||
ifeq ($(MAKE_NET),MAKE_NET_IPV6)
|
||||
MAKE_ROUTING ?= MAKE_ROUTING_RPL_LITE
|
||||
else
|
||||
MAKE_ROUTING ?= MAKE_ROUTING_NONE
|
||||
MAKE_ROUTING ?= MAKE_ROUTING_NULLROUTING
|
||||
endif
|
||||
|
||||
ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL_CLASSIC=1
|
||||
MODULES += os/net/rpl-classic
|
||||
CFLAGS += -DROUTING_CONF_RPL_CLASSIC=1
|
||||
MODULES += os/net/routing/rpl-classic
|
||||
else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1
|
||||
MODULES += os/net/rpl-lite
|
||||
else
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=0
|
||||
CFLAGS += -DROUTING_CONF_RPL_LITE=1
|
||||
MODULES += os/net/routing/rpl-lite
|
||||
else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_NULLROUTING)
|
||||
CFLAGS += -DROUTING_CONF_NULLROUTING=1
|
||||
MODULES += os/net/routing/nullrouting
|
||||
endif
|
||||
|
||||
ifdef MODULES
|
||||
UNIQUEMODULES = $(call uniq,$(MODULES))
|
||||
MODULEDIRS = ${wildcard ${addprefix $(CONTIKI)/, $(UNIQUEMODULES)}}
|
||||
MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}}
|
||||
MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}}
|
||||
include $(MODULES_INCLUDES)
|
||||
CONTIKI_SOURCEFILES += $(MODULES_SOURCES)
|
||||
MODULEDIRS = $(MODULES_REL) ${wildcard ${addprefix $(CONTIKI)/, $(MODULES)}}
|
||||
UNIQUEMODULES = $(call uniq,$(MODULEDIRS))
|
||||
MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}}
|
||||
CONTIKI_SOURCEFILES += $(MODULES_SOURCES)
|
||||
|
||||
# Include module-specific makefiles
|
||||
MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}}
|
||||
include $(MODULES_INCLUDES)
|
||||
# Iterate once more: include the modules added from the previous include.
|
||||
# Only works with one level of nested module inclusion.
|
||||
include $(MODULES_INCLUDES)
|
||||
|
||||
# C-include module-specific macros using -imacros
|
||||
MODULES_IMACROS = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/module-macros.h}}
|
||||
ifneq ($(MODULES_IMACROS),)
|
||||
CFLAGS += ${foreach d, $(MODULES_IMACROS), -imacros $(d)}
|
||||
endif
|
||||
|
||||
### Verbosity control. Use make V=1 to get verbose builds.
|
||||
|
@ -206,6 +256,7 @@ SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) $(CONTIKI_ARCH_DIRS)
|
|||
|
||||
vpath %.c $(SOURCEDIRS)
|
||||
vpath %.S $(SOURCEDIRS)
|
||||
vpath %.s $(SOURCEDIRS)
|
||||
|
||||
CFLAGS += ${addprefix -I,$(SOURCEDIRS) $(CONTIKI)}
|
||||
|
||||
|
@ -239,9 +290,8 @@ endef
|
|||
|
||||
clean:
|
||||
-rm -f *~ *core core *.srec \
|
||||
*.lst *.map \
|
||||
*.lst *.map *.o \
|
||||
*.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
|
||||
*.ce *.co
|
||||
rm -rf $(CLEAN)
|
||||
-rm -rf $(OBJECTDIR)
|
||||
|
||||
|
@ -250,13 +300,6 @@ distclean: clean
|
|||
|
||||
-include $(CONTIKI)/arch/platform/$(TARGET)/Makefile.customrules-$(TARGET)
|
||||
|
||||
ifndef CUSTOM_RULE_C_TO_CE
|
||||
%.ce: %.c
|
||||
$(TRACE_CC)
|
||||
$(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
||||
$(STRIP) --strip-unneeded -g -x $@
|
||||
endif
|
||||
|
||||
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O
|
||||
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
||||
$(TRACE_CC)
|
||||
|
@ -268,6 +311,9 @@ ifndef CUSTOM_RULE_S_TO_OBJECTDIR_O
|
|||
$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR)
|
||||
$(TRACE_AS)
|
||||
$(Q)$(AS) $(ASFLAGS) -o $@ $<
|
||||
$(OBJECTDIR)/%.o: %.s | $(OBJECTDIR)
|
||||
$(TRACE_AS)
|
||||
$(Q)$(AS) $(ASFLAGS) -o $@ $<
|
||||
endif
|
||||
|
||||
ifndef CUSTOM_RULE_C_TO_OBJECTDIR_S
|
||||
|
@ -300,12 +346,6 @@ ifndef CUSTOM_RULE_C_TO_E
|
|||
$(Q)$(CC) $(CFLAGS) -E $< -o $@
|
||||
endif
|
||||
|
||||
ifndef CUSTOM_RULE_C_TO_CO
|
||||
%.co: %.c
|
||||
$(TRACE_CC)
|
||||
$(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
||||
endif
|
||||
|
||||
ifndef AROPTS
|
||||
AROPTS = rcf
|
||||
endif
|
||||
|
@ -321,7 +361,7 @@ ifndef LD
|
|||
endif
|
||||
|
||||
ifndef CUSTOM_RULE_LINK
|
||||
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
$(TRACE_LD)
|
||||
$(Q)$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \
|
||||
${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
||||
|
@ -366,6 +406,9 @@ viewconf:
|
|||
@echo "##### \"MAKE_MAC\": ______________________________ $(MAKE_MAC)"
|
||||
@echo "##### \"MAKE_NET\": ______________________________ $(MAKE_NET)"
|
||||
@echo "##### \"MAKE_ROUTING\": __________________________ $(MAKE_ROUTING)"
|
||||
ifdef MAKE_COAP_DTLS_KEYSTORE
|
||||
@echo "##### \"MAKE_COAP_DTLS_KEYSTORE\": _______________ $(MAKE_COAP_DTLS_KEYSTORE)"
|
||||
endif
|
||||
@echo "----------------- C variables: -----------------"
|
||||
$(Q)$(CC) $(CFLAGS) -E $(CONTIKI)/tools/viewconf.c | grep \#\#\#\#\#
|
||||
@echo "------------------------------------------------"
|
||||
|
@ -384,8 +427,15 @@ viewconf:
|
|||
# the match-anything rule below instead.
|
||||
%: %.c
|
||||
|
||||
ifeq ($(PLATFORM_ACTION),skip)
|
||||
# Skip this target.
|
||||
$(CONTIKI_PROJECT):
|
||||
@echo "Skipping $@: not for the '$(TARGET)/$(BOARD)' platform!"
|
||||
else
|
||||
# Build this target.
|
||||
# Match-anything pattern rule to allow the project makefiles to
|
||||
# abstract from the actual binary name. It needs to contain some
|
||||
# command in order to be a rule, not just a prerequisite.
|
||||
%: %.$(TARGET)
|
||||
@
|
||||
endif
|
||||
|
|
22
README.md
22
README.md
|
@ -1,11 +1,25 @@
|
|||
# Contiki-NG: the Next Generation Contiki
|
||||
# Contiki-NG: The OS for Next Generation IoT Devices
|
||||
|
||||
[![Build Status](https://travis-ci.org/contiki-ng/contiki-ng.svg?branch=master)](https://travis-ci.org/contiki-ng/contiki-ng/branches)
|
||||
[![License](https://img.shields.io/badge/License-3--Clause%20BSD-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md)
|
||||
[![Latest release](https://img.shields.io/github/release/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
|
||||
[![GitHub Release Date](https://img.shields.io/github/release-date/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
|
||||
[![Last commit](https://img.shields.io/github/last-commit/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/commit/HEAD)
|
||||
|
||||
Contiki-NG is an open-source, cross-platform operating system for Next-Generation IoT devices. It focuses on dependable (secure and reliable) low-power communication and standard protocols, such as IPv6/6LoWPAN, 6TiSCH, RPL, and CoAP. Contiki-NG comes with extensive documentation, tutorials, a roadmap, release cycle, and well-defined development flow for smooth integration of community contributions.
|
||||
|
||||
Unless excplicitly stated otherwise, Contiki-NG sources are distributed under
|
||||
the terms of the [3-clause BSD license](LICENSE.md).
|
||||
|
||||
Contiki-NG started as a fork of the Contiki OS and retains some of its original features.
|
||||
|
||||
Find out more:
|
||||
|
||||
Contiki-NG is a fork of Contiki, with focus on next generation IoT protocols and platforms.
|
||||
Important links:
|
||||
* GitHub repository: https://github.com/contiki-ng/contiki-ng
|
||||
* Documentation: https://github.com/contiki-ng/contiki-ng/wiki
|
||||
* Web site: http://contiki-ng.org
|
||||
|
||||
Engage with the community:
|
||||
|
||||
* Gitter: https://gitter.im/contiki-ng
|
||||
* Twitter: https://twitter.com/contiki_ng
|
||||
* Web site: http://contiki-ng.org
|
||||
|
|
|
@ -42,16 +42,6 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Compiler configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Macros and typedefs
|
||||
*
|
||||
|
|
|
@ -6,7 +6,7 @@ endif
|
|||
|
||||
STRUCTGEN = structgen
|
||||
|
||||
PROJECTDIRS += $(BUILTSRCDIR)
|
||||
MODULES_REL += $(BUILTSRCDIR)
|
||||
|
||||
USB_STRING_DESCRIPTORS ?= $(CONTIKI_CPU_ARM)/common/usb/cdc-acm/string-descriptors.xml
|
||||
|
||||
|
|
|
@ -122,5 +122,5 @@ const struct configuration_st {
|
|||
|
||||
};
|
||||
|
||||
const struct usb_st_configuration_descriptor const *configuration_head =
|
||||
(struct usb_st_configuration_descriptor const*)&configuration_block;
|
||||
const struct usb_st_configuration_descriptor* const configuration_head =
|
||||
(const struct usb_st_configuration_descriptor*)&configuration_block;
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
#endif
|
||||
|
||||
extern const struct usb_st_device_descriptor device_descriptor;
|
||||
extern const struct usb_st_configuration_descriptor const *configuration_head;
|
||||
extern const struct usb_st_configuration_descriptor* const configuration_head;
|
||||
#endif /* DESCRIPTORS_H_RPFUB8O7OV__ */
|
||||
|
|
|
@ -19,7 +19,7 @@ CUSTOM_RULE_LINK = 1
|
|||
|
||||
.SECONDEXPANSION:
|
||||
|
||||
%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT)
|
||||
%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT)
|
||||
$(TRACE_LD)
|
||||
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -lm -o $@
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ LDFLAGS += -mcpu=cortex-m4
|
|||
### Compilation rules
|
||||
CUSTOM_RULE_LINK=1
|
||||
|
||||
%.elf: $(TARGET_STARTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TARGET_LIBS)
|
||||
%.elf: $(TARGET_STARTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TARGET_LIBS)
|
||||
$(TRACE_LD)
|
||||
$(Q)$(CC) $(LDFLAGS) ${filter %o %.co %.a,$^} -o $@
|
||||
$(Q)$(CC) $(LDFLAGS) ${filter %.o %.a,$^} -o $@
|
||||
|
||||
include $(CONTIKI)/arch/cpu/arm/cortex-m/Makefile.cortex-m
|
||||
|
|
|
@ -17,7 +17,7 @@ CONTIKI_CPU_DIRS = . dev usb usb/common usb/common/cdc-acm
|
|||
CONTIKI_CPU_SOURCEFILES += soc.c clock.c rtimer-arch.c uart.c watchdog.c
|
||||
CONTIKI_CPU_SOURCEFILES += nvic.c sys-ctrl.c gpio.c ioc.c spi.c adc.c
|
||||
CONTIKI_CPU_SOURCEFILES += crypto.c aes.c ecb.c cbc.c ctr.c cbc-mac.c gcm.c
|
||||
CONTIKI_CPU_SOURCEFILES += ccm.c sha256.c
|
||||
CONTIKI_CPU_SOURCEFILES += ccm.c sha256.c gpio-hal-arch.c
|
||||
CONTIKI_CPU_SOURCEFILES += cc2538-aes-128.c cc2538-ccm-star.c
|
||||
CONTIKI_CPU_SOURCEFILES += cc2538-rf.c udma.c lpm.c int-master.c
|
||||
CONTIKI_CPU_SOURCEFILES += pka.c bignum-driver.c ecc-driver.c ecc-algorithm.c
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
/* Path to headers with implementation of mutexes and memory barriers */
|
||||
#define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
|
||||
#define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
|
||||
|
||||
#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC2538_DEF_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -114,7 +114,7 @@ clock_init(void)
|
|||
REG(GPT_0_BASE + GPTIMER_TAPR) = PRESCALER_VALUE;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
CCIF clock_time_t
|
||||
clock_time_t
|
||||
clock_time(void)
|
||||
{
|
||||
return rt_ticks_startup / RTIMER_CLOCK_TICK_RATIO;
|
||||
|
@ -126,7 +126,7 @@ clock_set_seconds(unsigned long sec)
|
|||
rt_ticks_epoch = (uint64_t)sec * RTIMER_SECOND;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
CCIF unsigned long
|
||||
unsigned long
|
||||
clock_seconds(void)
|
||||
{
|
||||
return rt_ticks_epoch / RTIMER_SECOND;
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
* 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 cc2538-gpio-hal
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation file for the CC2538 GPIO HAL functions
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/ioc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
{
|
||||
uint8_t port, pin_num, pin_mask;
|
||||
uint32_t port_base;
|
||||
|
||||
port = PIN_TO_PORT(pin);
|
||||
port_base = PIN_TO_PORT_BASE(pin);
|
||||
pin_num = pin % 8;
|
||||
pin_mask = GPIO_PIN_MASK(pin_num);
|
||||
|
||||
gpio_hal_pin_cfg_t tmp;
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_EDGE_NONE) {
|
||||
GPIO_DISABLE_INTERRUPT(port_base, pin_mask);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_RISING) {
|
||||
GPIO_DETECT_EDGE(port_base, pin_mask);
|
||||
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
|
||||
GPIO_DETECT_RISING(port_base, pin_mask);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_FALLING) {
|
||||
GPIO_DETECT_EDGE(port_base, pin_mask);
|
||||
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
|
||||
GPIO_DETECT_FALLING(port_base, pin_mask);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_BOTH) {
|
||||
GPIO_DETECT_EDGE(port_base, pin_mask);
|
||||
GPIO_TRIGGER_BOTH_EDGES(port_base, pin_mask);
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_PULL_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_PULL_NONE) {
|
||||
ioc_set_over(port, pin_num, IOC_OVERRIDE_DIS);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_DOWN) {
|
||||
ioc_set_over(port, pin_num, IOC_OVERRIDE_PDE);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_UP) {
|
||||
ioc_set_over(port, pin_num, IOC_OVERRIDE_PUE);
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_INT_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) {
|
||||
GPIO_DISABLE_INTERRUPT(port_base, pin_mask);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_ENABLE) {
|
||||
GPIO_ENABLE_INTERRUPT(port_base, pin_mask);
|
||||
NVIC_EnableIRQ(port);
|
||||
}
|
||||
|
||||
GPIO_SOFTWARE_CONTROL(port_base, pin_mask);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_cfg_t
|
||||
gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
||||
{
|
||||
uint8_t port, pin_num, pin_mask;
|
||||
uint32_t port_base;
|
||||
gpio_hal_pin_cfg_t cfg;
|
||||
uint32_t tmp;
|
||||
|
||||
port = PIN_TO_PORT(pin);
|
||||
port_base = PIN_TO_PORT_BASE(pin);
|
||||
pin_num = pin % 8;
|
||||
pin_mask = GPIO_PIN_MASK(pin_num);
|
||||
|
||||
cfg = 0;
|
||||
|
||||
/* Pull */
|
||||
tmp = ioc_get_over(port, pin_num);
|
||||
if(tmp == IOC_OVERRIDE_PUE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_UP;
|
||||
} else if(tmp == IOC_OVERRIDE_PDE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN;
|
||||
} else {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_NONE;
|
||||
}
|
||||
|
||||
/* Interrupt enable/disable */
|
||||
tmp = REG((port_base) + GPIO_IE) & pin_mask;
|
||||
if(tmp == 0) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
|
||||
} else {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
}
|
||||
|
||||
/* Edge detection */
|
||||
if(REG((port_base) + GPIO_IS) & pin_mask) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_NONE;
|
||||
} else {
|
||||
if(REG((port_base) + GPIO_IBE) & pin_mask) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
} else {
|
||||
if(REG((port_base) + GPIO_IEV) & pin_mask) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING;
|
||||
} else {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cfg;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_write_pin(gpio_hal_pin_t pin, uint8_t value)
|
||||
{
|
||||
if(value == 1) {
|
||||
gpio_hal_arch_set_pin(pin);
|
||||
return;
|
||||
}
|
||||
gpio_hal_arch_clear_pin(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_set_pins(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
GPIO_SET_PIN(GPIO_A_BASE, pins & 0xFF);
|
||||
GPIO_SET_PIN(GPIO_B_BASE, (pins >> 8) & 0xFF);
|
||||
GPIO_SET_PIN(GPIO_C_BASE, (pins >> 16) & 0xFF);
|
||||
GPIO_SET_PIN(GPIO_D_BASE, (pins >> 24) & 0xFF);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_clear_pins(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
GPIO_CLR_PIN(GPIO_A_BASE, pins & 0xFF);
|
||||
GPIO_CLR_PIN(GPIO_B_BASE, (pins >> 8) & 0xFF);
|
||||
GPIO_CLR_PIN(GPIO_C_BASE, (pins >> 16) & 0xFF);
|
||||
GPIO_CLR_PIN(GPIO_D_BASE, (pins >> 24) & 0xFF);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_mask_t
|
||||
gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
gpio_hal_pin_mask_t rv = 0;
|
||||
|
||||
rv |= GPIO_READ_PIN(GPIO_A_BASE, pins & 0xFF);
|
||||
rv |= GPIO_READ_PIN(GPIO_B_BASE, (pins >> 8) & 0xFF) << 8;
|
||||
rv |= GPIO_READ_PIN(GPIO_C_BASE, (pins >> 16) & 0xFF) << 16;
|
||||
rv |= GPIO_READ_PIN(GPIO_D_BASE, (pins >> 24) & 0xFF) << 24;
|
||||
|
||||
return rv;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_write_pins(gpio_hal_pin_mask_t pins, gpio_hal_pin_mask_t value)
|
||||
{
|
||||
GPIO_WRITE_PIN(GPIO_A_BASE, pins & 0xFF, value & 0xFF);
|
||||
GPIO_WRITE_PIN(GPIO_B_BASE, (pins >> 8) & 0xFF, (value >> 8) & 0xFF);
|
||||
GPIO_WRITE_PIN(GPIO_C_BASE, (pins >> 16) & 0xFF, (value >> 16) & 0xFF);
|
||||
GPIO_WRITE_PIN(GPIO_D_BASE, (pins >> 24) & 0xFF, (value >> 24) & 0xFF);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* 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 cc2538
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc2538-gpio-hal CC2538 GPIO HAL implementation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the CC2538 GPIO HAL functions
|
||||
*
|
||||
* \note
|
||||
* Do not include this header directly
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef GPIO_HAL_ARCH_H_
|
||||
#define GPIO_HAL_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define PIN_TO_PORT(pin) (pin >> 3)
|
||||
#define PIN_TO_PORT_BASE(pin) GPIO_PORT_TO_BASE(PIN_TO_PORT(pin))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_interrupt_enable(p) do { \
|
||||
GPIO_ENABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
NVIC_EnableIRQ(PIN_TO_PORT(p)); \
|
||||
} while(0);
|
||||
|
||||
#define gpio_hal_arch_interrupt_disable(p) \
|
||||
GPIO_DISABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
|
||||
|
||||
#define gpio_hal_arch_pin_set_input(p) do { \
|
||||
GPIO_SOFTWARE_CONTROL(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
GPIO_SET_INPUT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
} while(0);
|
||||
|
||||
#define gpio_hal_arch_pin_set_output(p) do { \
|
||||
GPIO_SOFTWARE_CONTROL(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
GPIO_SET_OUTPUT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
} while(0);
|
||||
|
||||
#define gpio_hal_arch_set_pin(p) \
|
||||
GPIO_SET_PIN(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
|
||||
|
||||
#define gpio_hal_arch_clear_pin(p) \
|
||||
GPIO_CLR_PIN(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
|
||||
|
||||
#define gpio_hal_arch_read_pin(p) \
|
||||
(GPIO_READ_PIN(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)) == 0 ? 0 : 1)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -37,46 +37,13 @@
|
|||
*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/nvic.h"
|
||||
#include "reg.h"
|
||||
#include "lpm.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* \brief Pointer to a function to be called when a GPIO interrupt is detected.
|
||||
* Callbacks for Port A, Pins[0:7] are stored in positions [0:7] of this
|
||||
* buffer, Port B callbacks in [8:15] and so on
|
||||
*/
|
||||
static gpio_callback_t gpio_callbacks[32];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_register_callback(gpio_callback_t f, uint8_t port, uint8_t pin)
|
||||
{
|
||||
gpio_callbacks[(port << 3) + pin] = f;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \brief Run through all registered GPIO callbacks and invoke those
|
||||
* associated with the \a port and the pins specified by \a mask
|
||||
* \param mask Search callbacks associated with pins specified by this mask
|
||||
* \param port Search callbacks associated with this port. Here, port is
|
||||
* specified as a number between 0 and 3. Port A: 0, Port B: 1 etc */
|
||||
void
|
||||
notify(uint8_t mask, uint8_t port)
|
||||
{
|
||||
uint8_t i;
|
||||
gpio_callback_t *f = &gpio_callbacks[port << 3];
|
||||
|
||||
for(i = 0; i < 8; i++) {
|
||||
if(mask & (1 << i)) {
|
||||
if((*f) != NULL) {
|
||||
(*f)(port, i);
|
||||
}
|
||||
}
|
||||
f++;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \brief Interrupt service routine for Port \a port
|
||||
* \param port Number between 0 and 3. Port A: 0, Port B: 1, etc.
|
||||
|
@ -93,7 +60,7 @@ gpio_port_isr(uint8_t port)
|
|||
int_status = GPIO_GET_MASKED_INT_STATUS(base);
|
||||
power_up_int_status = GPIO_GET_POWER_UP_INT_STATUS(port);
|
||||
|
||||
notify(int_status | power_up_int_status, port);
|
||||
gpio_hal_event_handler((int_status | power_up_int_status) << (port << 3));
|
||||
|
||||
GPIO_CLEAR_INTERRUPT(base, int_status);
|
||||
GPIO_CLEAR_POWER_UP_INTERRUPT(port, power_up_int_status);
|
||||
|
@ -110,9 +77,4 @@ GPIO_PORT_ISR(b, B)
|
|||
GPIO_PORT_ISR(c, C)
|
||||
GPIO_PORT_ISR(d, D)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_init()
|
||||
{
|
||||
memset(gpio_callbacks, 0, sizeof(gpio_callbacks));
|
||||
}
|
||||
/** @} */
|
||||
|
|
|
@ -42,27 +42,12 @@
|
|||
*/
|
||||
#ifndef GPIO_H_
|
||||
#define GPIO_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "reg.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* \brief Type definition for callbacks invoked by the GPIO ISRs
|
||||
* \param port The port that triggered the GPIO interrupt. \e port is passed
|
||||
* by its numeric representation (Port A:0, B:1 etc). Defines for
|
||||
* these numeric representations are GPIO_x_NUM
|
||||
* \param pin The pin that triggered the interrupt, specified by number
|
||||
* (0, 1, ..., 7)
|
||||
*
|
||||
* This is the prototype of a function pointer passed to
|
||||
* gpio_register_callback(). These callbacks are registered on a port/pin
|
||||
* basis. When a GPIO port generates an interrupt, if a callback has been
|
||||
* registered for the port/pin combination, the ISR will invoke it. The ISR
|
||||
* will pass the port/pin as arguments in that call, so that a developer can
|
||||
* re-use the same callback for multiple port/pin combinations
|
||||
*/
|
||||
typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Base addresses for the GPIO register instances
|
||||
* @{
|
||||
|
@ -341,6 +326,14 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
|
|||
* number.
|
||||
*/
|
||||
#define GPIO_PORT_TO_BASE(PORT) (GPIO_A_BASE + ((PORT) << 12))
|
||||
|
||||
/**
|
||||
* \brief Converts a port/pin pair to GPIO HAL pin number
|
||||
* \param PORT The port number in the range 0 - 3 (GPIO_n_NUM).
|
||||
* \param PIN The pin number in the range 0 - 7.
|
||||
* \return The pin representation using GPIO HAL semantics
|
||||
*/
|
||||
#define GPIO_PORT_PIN_TO_GPIO_HAL_PIN(PORT, PIN) (((PORT) << 3) + (PIN))
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name GPIO Register offset declarations
|
||||
|
@ -612,21 +605,6 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
|
|||
#define GPIO_IRQ_DETECT_UNMASK_PAIACK0 0x00000001 /**< Port A bit 0 */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \brief Initialise the GPIO module */
|
||||
void gpio_init();
|
||||
|
||||
/**
|
||||
* \brief Register GPIO callback
|
||||
* \param f Pointer to a function to be called when \a pin of \a port
|
||||
* generates an interrupt
|
||||
* \param port Associate \a f with this port. \e port must be specified with
|
||||
* its numeric representation (Port A:0, B:1 etc). Defines for these
|
||||
* numeric representations are GPIO_x_NUM
|
||||
* \param pin Associate \a f with this pin, which is specified by number
|
||||
* (0, 1, ..., 7)
|
||||
*/
|
||||
void gpio_register_callback(gpio_callback_t f, uint8_t port, uint8_t pin);
|
||||
|
||||
#endif /* GPIO_H_ */
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,6 +56,12 @@ ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
|
|||
ioc_over[(port << 3) + pin] = over;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint32_t
|
||||
ioc_get_over(uint8_t port, uint8_t pin)
|
||||
{
|
||||
return ioc_over[(port << 3) + pin] & 0x0F;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ioc_set_sel(uint8_t port, uint8_t pin, uint8_t sel)
|
||||
{
|
||||
|
|
|
@ -249,6 +249,22 @@ void ioc_init();
|
|||
*/
|
||||
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over);
|
||||
|
||||
/**
|
||||
* \brief Get Port:Pin override function
|
||||
* \param port The port as a number (PA: 0, PB: 1 etc)
|
||||
* \param pin The pin as a number
|
||||
* \return The override function
|
||||
*
|
||||
* The return value can be one of
|
||||
*
|
||||
* - IOC_OVERRIDE_OE: Output
|
||||
* - IOC_OVERRIDE_PUE: Pull-Up
|
||||
* - IOC_OVERRIDE_PDE: Pull-Down
|
||||
* - IOC_OVERRIDE_ANA: Analog
|
||||
* - IOC_OVERRIDE_DIS: Disabled
|
||||
*/
|
||||
uint32_t ioc_get_over(uint8_t port, uint8_t pin);
|
||||
|
||||
/**
|
||||
* \brief Function select for Port:Pin
|
||||
* \param port The port as a number (PA: 0, PB: 1 etc)
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "dev/ioc.h"
|
||||
#include "dev/nvic.h"
|
||||
#include "dev/sys-ctrl.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "lpm.h"
|
||||
#include "reg.h"
|
||||
#include "soc.h"
|
||||
|
@ -123,7 +124,7 @@ soc_init()
|
|||
clock_init();
|
||||
lpm_init();
|
||||
rtimer_init();
|
||||
gpio_init();
|
||||
gpio_hal_init();
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
|
|
@ -161,7 +161,7 @@ const struct configuration_st {
|
|||
|
||||
};
|
||||
|
||||
const struct usb_st_configuration_descriptor const *configuration_head =
|
||||
(struct usb_st_configuration_descriptor const *)&configuration_block;
|
||||
const struct usb_st_configuration_descriptor* const configuration_head =
|
||||
(const struct usb_st_configuration_descriptor*)&configuration_block;
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
#endif
|
||||
|
||||
extern const struct usb_st_device_descriptor device_descriptor;
|
||||
extern const struct usb_st_configuration_descriptor const *configuration_head;
|
||||
extern const struct usb_st_configuration_descriptor* const configuration_head;
|
||||
#endif /* DESCRIPTORS_H_RPFUB8O7OV__ */
|
||||
|
|
|
@ -25,15 +25,16 @@ ifdef NODEID
|
|||
endif
|
||||
|
||||
### CPU-dependent directories
|
||||
CONTIKI_CPU_DIRS += . dev rf-core rf-core/api $(TI_XXWARE_STARTUP_DIR)
|
||||
CONTIKI_CPU_DIRS += . dev rf-core rf-core/api rf-core/ble-hal $(TI_XXWARE_STARTUP_DIR)
|
||||
|
||||
### CPU-dependent source files
|
||||
CONTIKI_CPU_SOURCEFILES += clock.c rtimer-arch.c soc-rtc.c uart.c
|
||||
CONTIKI_CPU_SOURCEFILES += contiki-watchdog.c aux-ctrl.c
|
||||
CONTIKI_CPU_SOURCEFILES += putchar.c ieee-addr.c batmon-sensor.c adc-sensor.c
|
||||
CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c cc26xx-uart.c lpm.c
|
||||
CONTIKI_CPU_SOURCEFILES += gpio-interrupt.c oscillators.c
|
||||
CONTIKI_CPU_SOURCEFILES += gpio-interrupt.c gpio-hal-arch.c oscillators.c
|
||||
CONTIKI_CPU_SOURCEFILES += rf-core.c rf-ble.c ieee-mode.c
|
||||
CONTIKI_CPU_SOURCEFILES += ble-cc2650.c ble-hal-cc26xx.c ble-addr.c rf-ble-cmd.c
|
||||
CONTIKI_CPU_SOURCEFILES += random.c soc-trng.c int-master.c
|
||||
|
||||
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Michael Spoerk
|
||||
* 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
|
||||
* Driver for the retrieval of an BLE address from flash
|
||||
*
|
||||
* \author
|
||||
* Michael Spoerk <mi.spoerk@gmail.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
#include "net/linkaddr.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "ble-addr.h"
|
||||
#include "os/dev/ble-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ble_addr_cpy_to(uint8_t *dst)
|
||||
{
|
||||
int i;
|
||||
uint8_t *location = (uint8_t *)BLE_ADDR_LOCATION;
|
||||
|
||||
for(i = 0; i < BLE_ADDR_SIZE; i++) {
|
||||
dst[i] = location[BLE_ADDR_SIZE - 1 - i];
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ble_addr_to_eui64(uint8_t *dst, uint8_t *src)
|
||||
{
|
||||
memcpy(dst, src, 3);
|
||||
dst[3] = 0xFF;
|
||||
dst[4] = 0xFE;
|
||||
memcpy(&dst[5], &src[3], 3);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ble_eui64_addr_cpy_to(uint8_t *dst)
|
||||
{
|
||||
uint8_t ble_addr[BLE_ADDR_SIZE];
|
||||
ble_addr_cpy_to(ble_addr);
|
||||
ble_addr_to_eui64(dst, ble_addr);
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Michael Spoerk
|
||||
* 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
|
||||
* Driver for the retrieval of an BLE address from flash
|
||||
*
|
||||
* \author
|
||||
* Michael Spoerk <mi.spoerk@gmail.com>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef BLE_ADDR_H_
|
||||
#define BLE_ADDR_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki-conf.h"
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* primary BLE address location */
|
||||
#define BLE_ADDR_LOCATION 0x500012E8
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Copy the node's factory BLE address to a destination memory area
|
||||
* \param dst A pointer to the destination area where the BLE address is to be
|
||||
* written
|
||||
*
|
||||
* This function will copy 6 bytes and it will invert byte order in
|
||||
* the process. The factory address on devices is normally little-endian,
|
||||
* therefore you should expect dst to store the address in a big-endian order.
|
||||
*/
|
||||
void ble_addr_cpy_to(uint8_t *dst);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Copy the node's BLE address to a destination memory area and converts
|
||||
* it into a EUI64 address in the process
|
||||
* \param dst A pointer to the destination area where the EUI64 address is to be
|
||||
* written
|
||||
* \param src A pointer to the BLE address that is to be copied
|
||||
*/
|
||||
void ble_addr_to_eui64(uint8_t *dst, uint8_t *src);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Copy the node's EUI64 address that is based on its factory BLE address
|
||||
* to a destination memory area
|
||||
* \param dst A pointer to the destination area where the EUI64 address is to be
|
||||
* written
|
||||
*/
|
||||
void ble_eui64_addr_cpy_to(uint8_t *dst);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* BLE_ADDR_H_ */
|
|
@ -90,7 +90,9 @@
|
|||
#define CSMA_CONF_SEND_SOFT_ACK 1
|
||||
|
||||
#else /* CC13XX_CONF_PROP_MODE */
|
||||
#ifndef NETSTACK_CONF_RADIO
|
||||
#define NETSTACK_CONF_RADIO ieee_mode_driver
|
||||
#endif
|
||||
|
||||
#define CSMA_CONF_SEND_SOFT_ACK 0
|
||||
#endif /* CC13XX_CONF_PROP_MODE */
|
||||
|
|
|
@ -99,6 +99,10 @@
|
|||
/* Path to headers with implementation of mutexes and memory barriers */
|
||||
#define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
|
||||
#define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
|
||||
|
||||
#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 0
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC13XX_CC26XX_DEF_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -124,7 +124,7 @@ update_clock_variable(void)
|
|||
count = (aon_rtc_secs_now * CLOCK_SECOND) + (aon_rtc_ticks_now >> 9);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
CCIF clock_time_t
|
||||
clock_time_t
|
||||
clock_time(void)
|
||||
{
|
||||
update_clock_variable();
|
||||
|
@ -142,7 +142,7 @@ clock_update(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
CCIF unsigned long
|
||||
unsigned long
|
||||
clock_seconds(void)
|
||||
{
|
||||
bool interrupts_disabled;
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "contiki.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/adc-sensor.h"
|
||||
#include "gpio-interrupt.h"
|
||||
#include "sys/timer.h"
|
||||
#include "lpm.h"
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#ifndef BATMON_SENSOR_H_
|
||||
#define BATMON_SENSOR_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "lib/sensors.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BATMON_SENSOR_TYPE_TEMP 1
|
||||
#define BATMON_SENSOR_TYPE_VOLT 2
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* 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 cc26xx-gpio-hal
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation file for the CC13xx/CC26xx GPIO HAL functions
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "ti-lib.h"
|
||||
#include "ti-lib-rom.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define CONFIG_MASK (IOC_IOPULL_M | IOC_INT_M | IOC_IOMODE_OPEN_SRC_INV)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
{
|
||||
uint32_t config;
|
||||
gpio_hal_pin_cfg_t tmp;
|
||||
|
||||
/* Clear settings that we are about to change, keep everything else */
|
||||
config = ti_lib_rom_ioc_port_configure_get(pin);
|
||||
config &= ~CONFIG_MASK;
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_EDGE_NONE) {
|
||||
config |= IOC_NO_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_RISING) {
|
||||
config |= IOC_RISING_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_FALLING) {
|
||||
config |= IOC_FALLING_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_BOTH) {
|
||||
config |= IOC_BOTH_EDGES;
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_PULL_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_PULL_NONE) {
|
||||
config |= IOC_NO_IOPULL;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_DOWN) {
|
||||
config |= IOC_IOPULL_DOWN;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_UP) {
|
||||
config |= IOC_IOPULL_UP;
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_INT_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) {
|
||||
config |= IOC_INT_DISABLE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_ENABLE) {
|
||||
config |= IOC_INT_ENABLE;
|
||||
}
|
||||
|
||||
ti_lib_rom_ioc_port_configure_set(pin, IOC_PORT_GPIO, config);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_cfg_t
|
||||
gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
||||
{
|
||||
gpio_hal_pin_cfg_t cfg;
|
||||
uint32_t tmp;
|
||||
uint32_t config;
|
||||
|
||||
cfg = 0;
|
||||
config = ti_lib_rom_ioc_port_configure_get(pin);
|
||||
|
||||
/* Pull */
|
||||
tmp = config & IOC_IOPULL_M;
|
||||
if(tmp == IOC_IOPULL_UP) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_UP;
|
||||
} else if(tmp == IOC_IOPULL_DOWN) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN;
|
||||
} else if(tmp == IOC_NO_IOPULL) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_NONE;
|
||||
}
|
||||
|
||||
/* Interrupt enable/disable */
|
||||
tmp = config & IOC_INT_ENABLE;
|
||||
if(tmp == IOC_INT_DISABLE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
|
||||
} else if(tmp == IOC_INT_ENABLE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
}
|
||||
|
||||
/* Edge detection */
|
||||
tmp = config & IOC_BOTH_EDGES;
|
||||
if(tmp == IOC_NO_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_NONE;
|
||||
} else if(tmp == IOC_FALLING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING;
|
||||
} else if(tmp == IOC_RISING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING;
|
||||
} else if(tmp == IOC_BOTH_EDGES) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
}
|
||||
|
||||
return cfg;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_mask_t
|
||||
gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
gpio_hal_pin_mask_t oe_pins;
|
||||
|
||||
/* For pins configured as output we need to read DOUT31_0 */
|
||||
oe_pins = ti_lib_gpio_get_output_enable_multi_dio(pins);
|
||||
|
||||
pins &= ~oe_pins;
|
||||
|
||||
return (HWREG(GPIO_BASE + GPIO_O_DOUT31_0) & oe_pins) |
|
||||
ti_lib_gpio_read_multi_dio(pins);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t
|
||||
gpio_hal_arch_read_pin(gpio_hal_pin_t pin)
|
||||
{
|
||||
if(ti_lib_gpio_get_output_enable_dio(pin)) {
|
||||
return (HWREG(GPIO_BASE + GPIO_O_DOUT31_0) >> pin) & 1;
|
||||
}
|
||||
|
||||
return ti_lib_gpio_read_dio(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* 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 cc26xx
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc26xx-gpio-hal CC13xx/CC26xx GPIO HAL implementation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the CC13xx/CC26xx GPIO HAL functions
|
||||
*
|
||||
* \note
|
||||
* Do not include this header directly
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef GPIO_HAL_ARCH_H_
|
||||
#define GPIO_HAL_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "ti-lib.h"
|
||||
#include "ti-lib-rom.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_interrupt_enable(p) interrupt_enable(p)
|
||||
#define gpio_hal_arch_interrupt_disable(p) ti_lib_rom_ioc_int_disable(p)
|
||||
|
||||
#define gpio_hal_arch_pin_set_input(p) ti_lib_rom_ioc_pin_type_gpio_input(p)
|
||||
#define gpio_hal_arch_pin_set_output(p) ti_lib_rom_ioc_pin_type_gpio_output(p)
|
||||
|
||||
#define gpio_hal_arch_set_pin(p) ti_lib_gpio_set_dio(p)
|
||||
#define gpio_hal_arch_clear_pin(p) ti_lib_gpio_clear_dio(p)
|
||||
#define gpio_hal_arch_toggle_pin(p) ti_lib_gpio_toggle_dio(p)
|
||||
#define gpio_hal_arch_write_pin(p, v) ti_lib_gpio_write_dio(p, v)
|
||||
|
||||
#define gpio_hal_arch_set_pins(p) ti_lib_gpio_set_multi_dio(p)
|
||||
#define gpio_hal_arch_clear_pins(p) ti_lib_gpio_clear_multi_dio(p)
|
||||
#define gpio_hal_arch_toggle_pins(p) ti_lib_gpio_toggle_multi_dio(p)
|
||||
#define gpio_hal_arch_write_pins(p, v) ti_lib_gpio_write_multi_dio(p, v)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline void
|
||||
interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
ti_lib_gpio_clear_event_dio(pin);
|
||||
ti_lib_rom_ioc_int_enable(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -29,72 +29,33 @@
|
|||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup cc26xx-gpio-interrupts
|
||||
* \addtogroup cc26xx
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of CC13xx/CC26xx GPIO interrupt handling.
|
||||
* CC13xx/CC26xx GPIO interrupt ISR.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ioc.h"
|
||||
#include "gpio-interrupt.h"
|
||||
#include "lpm.h"
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "ti-lib.h"
|
||||
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_interrupt_isr GPIOIntHandler
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Handler array */
|
||||
static gpio_interrupt_handler_t handlers[NUM_IO_MAX];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_interrupt_register_handler(uint8_t ioid, gpio_interrupt_handler_t f)
|
||||
{
|
||||
uint8_t interrupts_disabled = ti_lib_int_master_disable();
|
||||
|
||||
/* Clear interrupts on specified pins */
|
||||
ti_lib_gpio_clear_event_dio(ioid);
|
||||
|
||||
handlers[ioid] = f;
|
||||
|
||||
/* Re-enable interrupts */
|
||||
if(!interrupts_disabled) {
|
||||
ti_lib_int_master_enable();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_interrupt_init()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < NUM_IO_MAX; i++) {
|
||||
handlers[i] = NULL;
|
||||
}
|
||||
|
||||
ti_lib_int_enable(INT_AON_GPIO_EDGE);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_interrupt_isr(void)
|
||||
{
|
||||
uint32_t pin_mask;
|
||||
uint8_t i;
|
||||
gpio_hal_pin_mask_t pin_mask;
|
||||
|
||||
/* Read interrupt flags */
|
||||
pin_mask = (HWREG(GPIO_BASE + GPIO_O_EVFLAGS31_0) & GPIO_DIO_ALL_MASK);
|
||||
|
||||
gpio_hal_event_handler(pin_mask);
|
||||
|
||||
/* Clear the interrupt flags */
|
||||
HWREG(GPIO_BASE + GPIO_O_EVFLAGS31_0) = pin_mask;
|
||||
|
||||
/* Run custom ISRs */
|
||||
for(i = 0; i < NUM_IO_MAX; i++) {
|
||||
/* Call the handler if there is one registered for this event */
|
||||
if((pin_mask & (1 << i)) && handlers[i] != NULL) {
|
||||
handlers[i](i);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
|
|
@ -0,0 +1,280 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Graz University of Technology
|
||||
* 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
|
||||
* BLE radio for the TI CC26xx platform
|
||||
*
|
||||
* \author
|
||||
* Michael Spoerk <michael.spoerk@tugraz.at>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/radio.h"
|
||||
#include "os/dev/ble-hal.h"
|
||||
#include "rf-core/ble-hal/ble-hal-cc26xx.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RADIO"
|
||||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint16_t adv_interval;
|
||||
static ble_adv_type_t adv_type;
|
||||
static ble_addr_type_t adv_own_addr_type;
|
||||
static uint8_t adv_channel_map;
|
||||
static uint16_t buffer_size = 0;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint16_t scan_interval;
|
||||
static uint16_t scan_window;
|
||||
static ble_scan_type_t scan_type;
|
||||
static ble_addr_type_t scan_own_addr_type;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static ble_addr_type_t initiator_peer_addr_type;
|
||||
static uint8_t initiator_peer_addr[BLE_ADDR_SIZE];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint16_t connection_interval;
|
||||
static uint16_t connection_latency;
|
||||
static uint16_t connection_timeout;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
init(void)
|
||||
{
|
||||
int result = ble_hal.reset();
|
||||
return result == BLE_RESULT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
send(const void *payload, unsigned short payload_len)
|
||||
{
|
||||
uint8_t res;
|
||||
res = ble_hal.send((void *)payload, payload_len);
|
||||
LOG_DBG("ble-mode send() %d bytes\n", payload_len);
|
||||
if(res == BLE_RESULT_OK) {
|
||||
return RADIO_TX_OK;
|
||||
} else {
|
||||
LOG_ERR("ble-mode send() error: %d\n", res);
|
||||
return RADIO_TX_ERR;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
on(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
off(void)
|
||||
{
|
||||
ble_hal.disconnect(0, 0);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
get_value(radio_param_t param, radio_value_t *value)
|
||||
{
|
||||
unsigned int temp;
|
||||
|
||||
if(!value) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
|
||||
switch(param) {
|
||||
case RADIO_CONST_CHANNEL_MIN:
|
||||
*value = BLE_DATA_CHANNEL_MIN;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_CONST_CHANNEL_MAX:
|
||||
*value = BLE_DATA_CHANNEL_MAX;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_CONST_BLE_BUFFER_SIZE:
|
||||
if(buffer_size == 0) {
|
||||
ble_hal.read_buffer_size((unsigned int *)&buffer_size, &temp);
|
||||
}
|
||||
memcpy(value, &buffer_size, 2);
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_CONST_BLE_BUFFER_AMOUNT:
|
||||
ble_hal.read_buffer_size(&temp, (unsigned int *)value);
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_CONN_INTERVAL:
|
||||
ble_hal.read_connection_interval(0, (unsigned int *)value);
|
||||
return RADIO_RESULT_OK;
|
||||
default:
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
set_value(radio_param_t param, radio_value_t value)
|
||||
{
|
||||
switch(param) {
|
||||
case RADIO_PARAM_BLE_ADV_INTERVAL:
|
||||
if((value > BLE_ADV_INTERVAL_MAX) || (value < BLE_ADV_INTERVAL_MIN)) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
adv_interval = (uint16_t)value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_ADV_TYPE:
|
||||
adv_type = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_ADV_OWN_ADDR_TYPE:
|
||||
adv_own_addr_type = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_ADV_CHANNEL_MAP:
|
||||
adv_channel_map = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_ADV_ENABLE:
|
||||
if(value) {
|
||||
/* set the advertisement parameter before enabling */
|
||||
ble_hal.set_adv_param(adv_interval, adv_type,
|
||||
adv_own_addr_type, adv_channel_map);
|
||||
}
|
||||
ble_hal.set_adv_enable(value);
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_SCAN_INTERVAL:
|
||||
if((value > BLE_SCAN_INTERVAL_MAX) || (value < BLE_SCAN_INTERVAL_MIN)) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
scan_interval = (uint16_t)value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_SCAN_WINDOW:
|
||||
if((value > BLE_SCAN_INTERVAL_MAX) || (value < BLE_SCAN_INTERVAL_MIN)) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
scan_window = (uint16_t)value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_SCAN_TYPE:
|
||||
scan_type = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_SCAN_OWN_ADDR_TYPE:
|
||||
scan_own_addr_type = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_SCAN_ENABLE:
|
||||
if(value) {
|
||||
ble_hal.set_scan_param(scan_type, scan_interval,
|
||||
scan_window, scan_own_addr_type);
|
||||
}
|
||||
ble_hal.set_scan_enable(value, 0);
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_PEER_ADDR_TYPE:
|
||||
initiator_peer_addr_type = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_CONN_INTERVAL:
|
||||
connection_interval = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_CONN_LATENCY:
|
||||
connection_latency = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_CONN_SUPERVISION_TIMEOUT:
|
||||
connection_timeout = value;
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_INITIATOR_ENABLE:
|
||||
if(value) {
|
||||
ble_hal.create_connection(scan_interval, scan_window,
|
||||
initiator_peer_addr_type,
|
||||
initiator_peer_addr,
|
||||
scan_own_addr_type,
|
||||
connection_interval,
|
||||
connection_latency,
|
||||
connection_timeout);
|
||||
} else {
|
||||
ble_hal.create_connection_cancel();
|
||||
}
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_CONN_UPDATE:
|
||||
if(value) {
|
||||
return ble_hal.connection_update(0, connection_interval, connection_latency, connection_timeout);
|
||||
} else {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
default:
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
get_object(radio_param_t param, void *dest, size_t size)
|
||||
{
|
||||
switch(param) {
|
||||
case RADIO_CONST_BLE_BD_ADDR:
|
||||
if(size != BLE_ADDR_SIZE || !dest) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
ble_hal.read_bd_addr(dest);
|
||||
return RADIO_RESULT_OK;
|
||||
}
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static radio_result_t
|
||||
set_object(radio_param_t param, const void *src, size_t size)
|
||||
{
|
||||
switch(param) {
|
||||
case RADIO_PARAM_BLE_ADV_PAYLOAD:
|
||||
if(size <= 0 || size >= BLE_ADV_DATA_LEN || !src) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
ble_hal.set_adv_data((unsigned short)size, (char *)src);
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_ADV_SCAN_RESPONSE:
|
||||
if(size <= 0 || size >= BLE_SCAN_RESP_DATA_LEN || !src) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
ble_hal.set_scan_resp_data((unsigned short)size, (char *)src);
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_BLE_PEER_ADDR:
|
||||
if(size <= 0 || size > BLE_ADDR_SIZE || !src) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
memcpy(initiator_peer_addr, src, size);
|
||||
return RADIO_RESULT_OK;
|
||||
}
|
||||
return RADIO_RESULT_NOT_SUPPORTED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct radio_driver ble_cc2650_driver = {
|
||||
init,
|
||||
NULL,
|
||||
NULL,
|
||||
send,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
on,
|
||||
off,
|
||||
get_value,
|
||||
set_value,
|
||||
get_object,
|
||||
set_object,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Graz University of Technology
|
||||
* 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
|
||||
* BLE radio hardware abstraction for the TI CC26XX controller
|
||||
*
|
||||
* \author
|
||||
* Michael Spoerk <michael.spoerk@tugraz.at>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BLE_HAL_CC26XX_H_
|
||||
#define BLE_HAL_CC26XX_H_
|
||||
|
||||
#include "os/dev/ble-hal.h"
|
||||
|
||||
extern const struct ble_hal_driver ble_hal;
|
||||
|
||||
#endif /* BLE_HAL_CC26XX_H_ */
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Graz University of Technology
|
||||
* 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
|
||||
* BLE commands for the TI CC26xx BLE radio.
|
||||
* These functions are specific to the TI CC26xx and cannot be
|
||||
* reused by other BLE radios.
|
||||
*
|
||||
* \author
|
||||
* Michael Spoerk <michael.spoerk@tugraz.at>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
|
||||
#include "rf_ble_cmd.h"
|
||||
#include "rf-core/rf-core.h"
|
||||
#include "rf-core/ble-hal/rf-ble-cmd.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "BLE-RADIO"
|
||||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define CMD_GET_STATUS(X) (((rfc_radioOp_t *)X)->status)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* values for a selection of available TX powers (values from SmartRF Studio) */
|
||||
/*static uint16_t tx_power = 0x9330; / * +5 dBm * / */
|
||||
static uint16_t tx_power = 0x3161; /* 0 dBm */
|
||||
/*static uint16_t tx_power = 0x0CCB; / * -15 dBm * / */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* BLE overrides */
|
||||
static uint32_t ble_overrides[] = {
|
||||
0x00364038, /* Synth: Set RTRIM (POTAILRESTRIM) to 6 */
|
||||
0x000784A3, /* Synth: Set FREF = 3.43 MHz (24 MHz / 7) */
|
||||
0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz (K2) */
|
||||
0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, LSB) */
|
||||
0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, MSB) */
|
||||
0x00456088, /* Adjust AGC reference level */
|
||||
0x008F88B3, /* GPIO mode: https://e2e.ti.com/support/wireless_connectivity/proprietary_sub_1_ghz_simpliciti/f/156/t/488244?*/
|
||||
0xFFFFFFFF, /* End of override list */
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
rf_ble_cmd_send(uint8_t *command)
|
||||
{
|
||||
uint32_t cmdsta;
|
||||
rfc_radioOp_t *cmd = (rfc_radioOp_t *)command;
|
||||
|
||||
if(rf_core_send_cmd((uint32_t)cmd, &cmdsta) != RF_CORE_CMD_OK) {
|
||||
LOG_ERR("rf_ble_cmd_send() could not send cmd. status: 0x%04X\n",
|
||||
CMD_GET_STATUS(cmd));
|
||||
return RF_BLE_CMD_ERROR;
|
||||
}
|
||||
return RF_BLE_CMD_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
rf_ble_cmd_wait(uint8_t *command)
|
||||
{
|
||||
rfc_radioOp_t *cmd = (rfc_radioOp_t *)command;
|
||||
if(rf_core_wait_cmd_done((void *)cmd) != RF_CORE_CMD_OK) {
|
||||
LOG_ERR("rf_ble_cmd_wait() could not wait. status: 0x%04X\n",
|
||||
CMD_GET_STATUS(cmd));
|
||||
return RF_BLE_CMD_ERROR;
|
||||
}
|
||||
return RF_BLE_CMD_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
rf_ble_cmd_setup_ble_mode(void)
|
||||
{
|
||||
rfc_CMD_RADIO_SETUP_t cmd;
|
||||
|
||||
/* Create radio setup command */
|
||||
rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP);
|
||||
|
||||
cmd.txPower = tx_power;
|
||||
cmd.pRegOverride = ble_overrides;
|
||||
cmd.mode = 0;
|
||||
|
||||
/* Send Radio setup to RF Core */
|
||||
if(rf_ble_cmd_send((uint8_t *)&cmd) != RF_BLE_CMD_OK) {
|
||||
return RF_BLE_CMD_ERROR;
|
||||
}
|
||||
|
||||
/* Wait until radio setup is done */
|
||||
return rf_ble_cmd_wait((uint8_t *)&cmd);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ADVERTISING functions */
|
||||
void
|
||||
rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel,
|
||||
uint8_t *param, uint8_t *output)
|
||||
{
|
||||
rfc_CMD_BLE_ADV_t *c = (rfc_CMD_BLE_ADV_t *)command;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE_ADV_t));
|
||||
c->commandNo = CMD_BLE_ADV;
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
c->pParams = (rfc_bleAdvPar_t *)param;
|
||||
c->startTrigger.triggerType = TRIG_NOW;
|
||||
c->pOutput = (rfc_bleAdvOutput_t *)output;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue,
|
||||
uint8_t adv_data_len, uint8_t *adv_data,
|
||||
uint8_t scan_resp_data_len, uint8_t *scan_resp_data,
|
||||
ble_addr_type_t own_addr_type, uint8_t *own_addr)
|
||||
{
|
||||
rfc_bleAdvPar_t *p = (rfc_bleAdvPar_t *)param;
|
||||
|
||||
memset(p, 0x00, sizeof(rfc_bleAdvPar_t));
|
||||
|
||||
p->pRxQ = rx_queue;
|
||||
p->rxConfig.bAutoFlushIgnored = 1;
|
||||
p->rxConfig.bAutoFlushCrcErr = 0;
|
||||
p->rxConfig.bAutoFlushEmpty = 1;
|
||||
p->rxConfig.bIncludeLenByte = 1;
|
||||
p->rxConfig.bIncludeCrc = 0;
|
||||
p->rxConfig.bAppendRssi = 1;
|
||||
p->rxConfig.bAppendStatus = 1;
|
||||
p->rxConfig.bAppendTimestamp = 1;
|
||||
p->advConfig.advFilterPolicy = 0;
|
||||
p->advConfig.bStrictLenFilter = 0;
|
||||
p->advConfig.deviceAddrType = own_addr_type;
|
||||
p->pDeviceAddress = (uint16_t *)own_addr;
|
||||
p->advLen = adv_data_len;
|
||||
p->scanRspLen = scan_resp_data_len;
|
||||
p->pAdvData = adv_data;
|
||||
p->pScanRspData = scan_resp_data;
|
||||
p->endTrigger.triggerType = TRIG_NEVER;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* CONNECTION slave functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
|
||||
uint8_t *output, uint32_t start_time)
|
||||
{
|
||||
rfc_CMD_BLE_SLAVE_t *c = (rfc_CMD_BLE_SLAVE_t *)cmd;
|
||||
|
||||
memset(c, 0x00, sizeof(rfc_CMD_BLE_SLAVE_t));
|
||||
|
||||
c->commandNo = CMD_BLE_SLAVE;
|
||||
c->condition.rule = COND_NEVER;
|
||||
c->whitening.bOverride = 0;
|
||||
c->channel = channel;
|
||||
c->pParams = (rfc_bleSlavePar_t *)params;
|
||||
c->startTrigger.triggerType = TRIG_ABSTIME;
|
||||
c->startTrigger.pastTrig = 0;
|
||||
c->startTime = start_time;
|
||||
c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rf_ble_cmd_create_slave_params(uint8_t *params, dataQueue_t *rx_queue,
|
||||
dataQueue_t *tx_queue, uint32_t access_address,
|
||||
uint8_t crc_init_0, uint8_t crc_init_1,
|
||||
uint8_t crc_init_2, uint32_t win_size,
|
||||
uint32_t window_widening, uint8_t first_packet)
|
||||
{
|
||||
rfc_bleSlavePar_t *p = (rfc_bleSlavePar_t *)params;
|
||||
|
||||
p->pRxQ = rx_queue;
|
||||
p->pTxQ = tx_queue;
|
||||
p->rxConfig.bAutoFlushIgnored = 1;
|
||||
p->rxConfig.bAutoFlushCrcErr = 1;
|
||||
p->rxConfig.bAutoFlushEmpty = 1;
|
||||
p->rxConfig.bIncludeLenByte = 1;
|
||||
p->rxConfig.bIncludeCrc = 0;
|
||||
p->rxConfig.bAppendRssi = 1;
|
||||
p->rxConfig.bAppendStatus = 1;
|
||||
p->rxConfig.bAppendTimestamp = 1;
|
||||
|
||||
if(first_packet) {
|
||||
/* set parameters for first packet according to TI Technical Reference Manual */
|
||||
p->seqStat.lastRxSn = 1;
|
||||
p->seqStat.lastTxSn = 1;
|
||||
p->seqStat.nextTxSn = 0;
|
||||
p->seqStat.bFirstPkt = 1;
|
||||
p->seqStat.bAutoEmpty = 0;
|
||||
p->seqStat.bLlCtrlTx = 0;
|
||||
p->seqStat.bLlCtrlAckRx = 0;
|
||||
p->seqStat.bLlCtrlAckPending = 0;
|
||||
}
|
||||
|
||||
p->maxNack = 0;
|
||||
p->maxPkt = 0;
|
||||
p->accessAddress = access_address;
|
||||
p->crcInit0 = crc_init_0;
|
||||
p->crcInit1 = crc_init_1;
|
||||
p->crcInit2 = crc_init_2;
|
||||
p->timeoutTrigger.triggerType = TRIG_REL_START;
|
||||
if(first_packet) {
|
||||
p->timeoutTime = (uint32_t)(10 * win_size);
|
||||
} else {
|
||||
p->timeoutTime = (uint32_t)(win_size + 2 * window_widening);
|
||||
}
|
||||
p->endTrigger.triggerType = TRIG_NEVER;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* DATA queue functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
rf_ble_cmd_add_data_queue_entry(dataQueue_t *q, uint8_t *e)
|
||||
{
|
||||
uint32_t cmdsta;
|
||||
|
||||
rfc_CMD_ADD_DATA_ENTRY_t cmd;
|
||||
cmd.commandNo = CMD_ADD_DATA_ENTRY;
|
||||
cmd.pQueue = q;
|
||||
cmd.pEntry = e;
|
||||
|
||||
if(rf_core_send_cmd((uint32_t)&cmd, &cmdsta) != RF_CORE_CMD_OK) {
|
||||
LOG_ERR("could not add entry to data queue. status: 0x%04X\n",
|
||||
CMD_GET_STATUS(&cmd));
|
||||
return RF_BLE_CMD_ERROR;
|
||||
}
|
||||
return RF_BLE_CMD_OK;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Graz University of Technology
|
||||
* 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
|
||||
* BLE commands for the TI CC26xx BLE radio.
|
||||
* These functions are specific to the TI CC26xx and cannot be
|
||||
* reused by other BLE radios.
|
||||
*
|
||||
* \author
|
||||
* Michael Spoerk <michael.spoerk@tugraz.at>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef RF_BLE_CMD_H_
|
||||
#define RF_BLE_CMD_H_
|
||||
|
||||
#include "os/dev/ble-hal.h"
|
||||
#include "../../ble-addr.h"
|
||||
#include "rf_common_cmd.h"
|
||||
|
||||
#define RF_BLE_CMD_OK 1
|
||||
#define RF_BLE_CMD_ERROR 0
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Sends a BLE radio command to the radio
|
||||
* \param cmd A pointer to the command to be send
|
||||
* \return RF_CORE_CMD_OK or RF_CORE_CMD_ERROR
|
||||
*/
|
||||
unsigned short rf_ble_cmd_send(uint8_t *cmd);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Waits for a running BLE radio command to be finished
|
||||
* \param cmd A pointer to the running command
|
||||
* \return RF_CORE_CMD_OK or RF_CORE_CMD_ERROR
|
||||
*/
|
||||
unsigned short rf_ble_cmd_wait(uint8_t *cmd);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initializes the radio core to be used as a BLE radio
|
||||
* \return RF_CORE_CMD_OK or RF_CORE_CMD_ERROR
|
||||
*/
|
||||
unsigned short rf_ble_cmd_setup_ble_mode(void);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates a BLE radio command structure that enables
|
||||
* BLE advertisement when sent to the radio core
|
||||
* \param command A pointer to command that is created
|
||||
* \param channel The BLE advertisement channel used for advertisement
|
||||
* \param param A pointer to the radio command parameters
|
||||
* \param output A pointer to the radio command output
|
||||
*/
|
||||
void rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel,
|
||||
uint8_t *param, uint8_t *output);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates BLE radio command parameters that are used to enable
|
||||
* BLE advertisement on the radio core
|
||||
* \param param A pointer to parameter structure that is created
|
||||
* \param rx_queue A pointer to the RX queue that is used
|
||||
* \param adv_data_len
|
||||
* The length of the advertisement data
|
||||
* \param adv_data A pointer to the advertisement data that is advertised
|
||||
* \param scan_resp_data_len
|
||||
* The length of the scan response data
|
||||
* \param scan_resp_data
|
||||
* A pointer to the scan response data
|
||||
* \param own_addr_type
|
||||
* Either BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM
|
||||
* \param own_addr A pointer to the device address that is used as own address
|
||||
*/
|
||||
void rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue,
|
||||
uint8_t adv_data_len, uint8_t *adv_data,
|
||||
uint8_t scan_resp_data_len, uint8_t *scan_resp_data,
|
||||
ble_addr_type_t own_addr_type, uint8_t *own_addr);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates a BLE radio command structure that sets up a single
|
||||
* BLE connection event when sent to the radio core
|
||||
* \param cmd A pointer to command that is created
|
||||
* \param channel The BLE data channel used for the connection event
|
||||
* \param param A pointer to the radio command parameters
|
||||
* \param output A pointer to the radio command output
|
||||
* \param start_time
|
||||
* The time in rf_core_ticks when the connection event will start
|
||||
*/
|
||||
void rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *param,
|
||||
uint8_t *output, uint32_t start_time);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Creates BLE radio command parameters that are used to setup a single
|
||||
* BLE connection event on the radio core
|
||||
* \param param A pointer to parameter structure that is created
|
||||
* \param rx_queue A pointer to the RX queue that is used
|
||||
* \param tx_queue A pointer to the TX queue that is used
|
||||
* \param access_address
|
||||
* The access address of the used BLE connection
|
||||
* \param crc_init_0
|
||||
* Part of the initialization of the CRC checksum
|
||||
* \param crc_init_1
|
||||
* Part of the initialization of the CRC checksum
|
||||
* \param crc_init_2
|
||||
* Part of the initialization of the CRC checksum
|
||||
* \param win_size The window size parameter of the BLE connection event
|
||||
* \param window_widening
|
||||
* The window widening parameter used for this connection event
|
||||
* \param first_packet
|
||||
* 1 for the first packet of the BLE connection so that the
|
||||
* connection is properly initialized
|
||||
*/
|
||||
void rf_ble_cmd_create_slave_params(uint8_t *param, dataQueue_t *rx_queue,
|
||||
dataQueue_t *tx_queue, uint32_t access_address,
|
||||
uint8_t crc_init_0, uint8_t crc_init_1,
|
||||
uint8_t crc_init_2, uint32_t win_size,
|
||||
uint32_t window_widening, uint8_t first_packet);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Adds a data buffer to a BLE transmission queue
|
||||
* \param q A pointer to BLE transmission queue where the buffer
|
||||
* should be added
|
||||
* \param e A pointer to the data buffer that is added
|
||||
*/
|
||||
unsigned short rf_ble_cmd_add_data_queue_entry(dataQueue_t *q, uint8_t *e);
|
||||
|
||||
#endif /* RF_BLE_CMD_H_ */
|
|
@ -263,6 +263,20 @@ static uint8_t rx_buf_1[RX_BUF_SIZE] CC_ALIGN(4);
|
|||
static uint8_t rx_buf_2[RX_BUF_SIZE] CC_ALIGN(4);
|
||||
static uint8_t rx_buf_3[RX_BUF_SIZE] CC_ALIGN(4);
|
||||
|
||||
#define RX_BUF_INCLUDE_CRC 1
|
||||
#define RX_BUF_INCLUDE_RSSI 1
|
||||
#define RX_BUF_INCLUDE_CORR 1
|
||||
#define RX_BUF_INCLUDE_TIMESTAMP 1
|
||||
|
||||
/* The size of the metadata (excluding the packet length field) */
|
||||
#define RX_BUF_METADATA_SIZE \
|
||||
(2 * RX_BUF_INCLUDE_CRC + RX_BUF_INCLUDE_RSSI + RX_BUF_INCLUDE_CORR + 4 * RX_BUF_INCLUDE_TIMESTAMP)
|
||||
|
||||
/* The offset of the packet length in a rx buffer */
|
||||
#define RX_BUF_LENGTH_OFFSET sizeof(rfc_dataEntry_t)
|
||||
/* The offset of the packet data in a rx buffer */
|
||||
#define RX_BUF_DATA_OFFSET (RX_BUF_LENGTH_OFFSET + 1)
|
||||
|
||||
/* The RX Data Queue */
|
||||
static dataQueue_t rx_data_queue = { 0 };
|
||||
|
||||
|
@ -565,22 +579,22 @@ init_rx_buffers(void)
|
|||
entry = (rfc_dataEntry_t *)rx_buf_0;
|
||||
entry->pNextEntry = rx_buf_1;
|
||||
entry->config.lenSz = DATA_ENTRY_LENSZ_BYTE;
|
||||
entry->length = sizeof(rx_buf_0) - 8;
|
||||
entry->length = sizeof(rx_buf_0) - sizeof(*entry);
|
||||
|
||||
entry = (rfc_dataEntry_t *)rx_buf_1;
|
||||
entry->pNextEntry = rx_buf_2;
|
||||
entry->config.lenSz = DATA_ENTRY_LENSZ_BYTE;
|
||||
entry->length = sizeof(rx_buf_0) - 8;
|
||||
entry->length = sizeof(rx_buf_0) - sizeof(*entry);
|
||||
|
||||
entry = (rfc_dataEntry_t *)rx_buf_2;
|
||||
entry->pNextEntry = rx_buf_3;
|
||||
entry->config.lenSz = DATA_ENTRY_LENSZ_BYTE;
|
||||
entry->length = sizeof(rx_buf_0) - 8;
|
||||
entry->length = sizeof(rx_buf_0) - sizeof(*entry);
|
||||
|
||||
entry = (rfc_dataEntry_t *)rx_buf_3;
|
||||
entry->pNextEntry = rx_buf_0;
|
||||
entry->config.lenSz = DATA_ENTRY_LENSZ_BYTE;
|
||||
entry->length = sizeof(rx_buf_0) - 8;
|
||||
entry->length = sizeof(rx_buf_0) - sizeof(*entry);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
|
@ -601,11 +615,11 @@ init_rf_params(void)
|
|||
cmd->rxConfig.bAutoFlushCrc = 1;
|
||||
cmd->rxConfig.bAutoFlushIgn = 0;
|
||||
cmd->rxConfig.bIncludePhyHdr = 0;
|
||||
cmd->rxConfig.bIncludeCrc = 1;
|
||||
cmd->rxConfig.bAppendRssi = 1;
|
||||
cmd->rxConfig.bAppendCorrCrc = 1;
|
||||
cmd->rxConfig.bIncludeCrc = RX_BUF_INCLUDE_CRC;
|
||||
cmd->rxConfig.bAppendRssi = RX_BUF_INCLUDE_RSSI;
|
||||
cmd->rxConfig.bAppendCorrCrc = RX_BUF_INCLUDE_CORR;
|
||||
cmd->rxConfig.bAppendSrcInd = 0;
|
||||
cmd->rxConfig.bAppendTimestamp = 1;
|
||||
cmd->rxConfig.bAppendTimestamp = RX_BUF_INCLUDE_TIMESTAMP;
|
||||
|
||||
cmd->pRxQ = &rx_data_queue;
|
||||
cmd->pOutput = (rfc_ieeeRxOutput_t *)rf_stats;
|
||||
|
@ -1079,15 +1093,15 @@ read_frame(void *buf, unsigned short buf_len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(rx_read_entry[8] < 4) {
|
||||
PRINTF("RF: too short\n");
|
||||
len = rx_read_entry[RX_BUF_LENGTH_OFFSET];
|
||||
if(len <= RX_BUF_METADATA_SIZE) {
|
||||
PRINTF("RF: too short!");
|
||||
|
||||
release_data_entry();
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = rx_read_entry[8] - 8;
|
||||
|
||||
len -= RX_BUF_METADATA_SIZE;
|
||||
if(len > buf_len) {
|
||||
PRINTF("RF: too long\n");
|
||||
|
||||
|
@ -1095,13 +1109,13 @@ read_frame(void *buf, unsigned short buf_len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buf, (char *)&rx_read_entry[9], len);
|
||||
memcpy(buf, (uint8_t *)rx_read_entry + RX_BUF_DATA_OFFSET, len);
|
||||
|
||||
last_rssi = (int8_t)rx_read_entry[9 + len + 2];
|
||||
last_corr_lqi = (uint8_t)rx_read_entry[9 + len + 3] & STATUS_CORRELATION;
|
||||
last_rssi = (int8_t)rx_read_entry[RX_BUF_DATA_OFFSET + len + 2];
|
||||
last_corr_lqi = (uint8_t)rx_read_entry[RX_BUF_DATA_OFFSET + len + 3] & STATUS_CORRELATION;
|
||||
|
||||
/* get the timestamp */
|
||||
memcpy(&rat_timestamp, (char *)rx_read_entry + 9 + len + 4, 4);
|
||||
memcpy(&rat_timestamp, (uint8_t *)rx_read_entry + RX_BUF_DATA_OFFSET + len + 4, 4);
|
||||
|
||||
last_packet_timestamp = calc_last_packet_timestamp(rat_timestamp);
|
||||
|
||||
|
|
|
@ -108,11 +108,6 @@ ifeq ($(HOST_OS),Windows)
|
|||
@$(FINALIZE_CYGWIN_DEPENDENCY)
|
||||
endif
|
||||
|
||||
CUSTOM_RULE_C_TO_CO = 1
|
||||
%.co: %.c
|
||||
$(TRACE_CC)
|
||||
$(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
|
||||
|
||||
AROPTS = -o
|
||||
|
||||
else
|
||||
|
@ -195,10 +190,6 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
|
|||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(STRIP) --strip-unneeded -g -x $@
|
||||
|
||||
%.cm: %.co
|
||||
$(LD) -i -r --unresolved-symbols=ignore-in-object-files -mmsp430x149 -o $@ $^
|
||||
$(STRIP) --strip-unneeded -g -x $@
|
||||
|
||||
%-stripped.o: %.o
|
||||
$(STRIP) --strip-unneeded -g -x -o $@ $<
|
||||
|
||||
|
@ -206,7 +197,7 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
|
|||
mv $< $@
|
||||
|
||||
ifdef IAR
|
||||
%.ihex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
%.ihex: %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
$(LD) $(LDFLAGSNO) -Fintel-extended $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
||||
else
|
||||
%.ihex: %.$(TARGET)
|
||||
|
|
|
@ -1,9 +1,39 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/uart0.h"
|
||||
|
||||
/* In case of IPv4: putchar() is defined by the SLIP driver */
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define SLIP_END 0300
|
||||
#undef putchar
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
putchar(int c)
|
||||
{
|
||||
#if SLIP_ARCH_CONF_ENABLED
|
||||
static char debug_frame = 0;
|
||||
|
||||
if(!debug_frame) { /* Start of debug output */
|
||||
uart0_writeb(SLIP_END);
|
||||
uart0_writeb('\r'); /* Type debug line == '\r' */
|
||||
debug_frame = 1;
|
||||
}
|
||||
#endif /* SLIP_ARCH_CONF_ENABLED */
|
||||
|
||||
/* Need to also print '\n' because for example COOJA will not show
|
||||
any output before line end */
|
||||
uart0_writeb((char)c);
|
||||
|
||||
#if SLIP_ARCH_CONF_ENABLED
|
||||
/*
|
||||
* Line buffered output, a newline marks the end of debug output and
|
||||
* implicitly flushes debug output.
|
||||
*/
|
||||
if(c == '\n') {
|
||||
uart0_writeb(SLIP_END);
|
||||
debug_frame = 0;
|
||||
}
|
||||
#endif /* SLIP_ARCH_CONF_ENABLED */
|
||||
return c;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -1,9 +1,39 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/uart1.h"
|
||||
|
||||
/* In case of IPv4: putchar() is defined by the SLIP driver */
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define SLIP_END 0300
|
||||
#undef putchar
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
putchar(int c)
|
||||
{
|
||||
#if SLIP_ARCH_CONF_ENABLED
|
||||
static char debug_frame = 0;
|
||||
|
||||
if(!debug_frame) { /* Start of debug output */
|
||||
uart1_writeb(SLIP_END);
|
||||
uart1_writeb('\r'); /* Type debug line == '\r' */
|
||||
debug_frame = 1;
|
||||
}
|
||||
#endif /* SLIP_ARCH_CONF_ENABLED */
|
||||
|
||||
/* Need to also print '\n' because for example COOJA will not show
|
||||
any output before line end */
|
||||
uart1_writeb((char)c);
|
||||
|
||||
#if SLIP_ARCH_CONF_ENABLED
|
||||
/*
|
||||
* Line buffered output, a newline marks the end of debug output and
|
||||
* implicitly flushes debug output.
|
||||
*/
|
||||
if(c == '\n') {
|
||||
uart1_writeb(SLIP_END);
|
||||
debug_frame = 0;
|
||||
}
|
||||
#endif /* SLIP_ARCH_CONF_ENABLED */
|
||||
return c;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -46,10 +46,10 @@ leds_arch_init(void)
|
|||
LEDS_PxOUT |= (LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
unsigned char leds;
|
||||
leds_mask_t leds;
|
||||
leds = LEDS_PxOUT;
|
||||
return ((leds & LEDS_CONF_RED) ? 0 : LEDS_RED)
|
||||
| ((leds & LEDS_CONF_GREEN) ? 0 : LEDS_GREEN)
|
||||
|
@ -57,7 +57,7 @@ leds_arch_get(void)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
leds_arch_set(leds_mask_t leds)
|
||||
{
|
||||
LEDS_PxOUT = (LEDS_PxOUT & ~(LEDS_CONF_RED|LEDS_CONF_GREEN|LEDS_CONF_YELLOW))
|
||||
| ((leds & LEDS_RED) ? 0 : LEDS_CONF_RED)
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
* 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.
|
||||
* 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.
|
||||
* 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 MSP430_CONF_H_
|
||||
|
@ -42,6 +42,20 @@
|
|||
#else
|
||||
#define MSP430_CPU_SPEED 2457600UL
|
||||
#endif
|
||||
|
||||
#ifndef SLIP_ARCH_CONF_ENABLED
|
||||
/*
|
||||
* Determine whether we need SLIP
|
||||
* This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
|
||||
* keep using SLIP
|
||||
*/
|
||||
#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT)
|
||||
#define SLIP_ARCH_CONF_ENABLED 1
|
||||
#else
|
||||
#define SLIP_ARCH_CONF_ENABLED 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* MSP430_CONF_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -79,9 +79,6 @@ typedef long off_t;
|
|||
/* Our clock resolution, this is the same as Unix HZ. */
|
||||
#define CLOCK_CONF_SECOND 128UL
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef int spl_t;
|
||||
spl_t splhigh_(void);
|
||||
|
||||
|
|
|
@ -14,12 +14,6 @@ endif
|
|||
# custom MAC: ble_ipsp_mac_driver
|
||||
MAKE_MAC ?= MAKE_MAC_OTHER
|
||||
|
||||
# we only support IPv6
|
||||
MAKE_NET ?= MAKE_NET_IPV6
|
||||
ifneq ($(MAKE_NET),MAKE_NET_IPV6)
|
||||
$(error Only IPv6 stack is supported!)
|
||||
endif
|
||||
|
||||
$(info SDK: $(NRF52_SDK_ROOT))
|
||||
|
||||
ifeq ($(NRF52_DK_REVISION),)
|
||||
|
@ -145,7 +139,7 @@ CFLAGS += -ggdb
|
|||
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
|
||||
# keep every function in separate section. This will allow linker to dump unused functions
|
||||
LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map
|
||||
LDFLAGS += -Xlinker -Map=$(@:.elf=-$(TARGET).map)
|
||||
LDFLAGS += -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
|
||||
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
# let linker to dump unused sections
|
||||
|
|
|
@ -116,7 +116,7 @@ clock_init(void)
|
|||
rtc_config();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
CCIF clock_time_t
|
||||
clock_time_t
|
||||
clock_time(void)
|
||||
{
|
||||
return (clock_time_t)(ticks & 0xFFFFFFFF);
|
||||
|
@ -131,7 +131,7 @@ clock_update(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
CCIF unsigned long
|
||||
unsigned long
|
||||
clock_seconds(void)
|
||||
{
|
||||
return (unsigned long)ticks/CLOCK_CONF_SECOND;
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#include "cm4/cm4-def.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
/* we only support IPv6 */
|
||||
#error "Only IPv6 stack is supported!"
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define RTIMER_ARCH_SECOND 62500
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* NRF52832_DEF_H_ */
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup rgb-led
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the RGB LED driver.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/rgb-led/rgb-led.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rgb_led_off(void)
|
||||
{
|
||||
leds_off(LEDS_ALL);
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void
|
||||
rgb_led_set(uint8_t colour)
|
||||
{
|
||||
leds_mask_t leds =
|
||||
((colour & RGB_LED_RED) ? LEDS_RED : LEDS_COLOUR_NONE) |
|
||||
((colour & RGB_LED_GREEN) ? LEDS_GREEN : LEDS_COLOUR_NONE) |
|
||||
((colour & RGB_LED_BLUE) ? LEDS_BLUE : LEDS_COLOUR_NONE);
|
||||
|
||||
leds_off(LEDS_ALL);
|
||||
leds_on(leds);
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef RGB_LED_H_
|
||||
#define RGB_LED_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup dev
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \defgroup rgb-led Generic RGB LED driver
|
||||
*
|
||||
* This is a driver for a tri-color RGB LED part, such as for example the
|
||||
* Broadcom (ex Avago Technologies) PLCC-4 Tricolor Black Surface LED present
|
||||
* on all Zolertia Zoul-based boards.
|
||||
*
|
||||
*
|
||||
* This driver sits on top of the LED HAL. Therefore, any port that wishes to
|
||||
* use this driver should first implement the GPIO HAL and the new LED API.
|
||||
* This driver will set the colour of the RGB LED by using combinations of
|
||||
* LED_RED, LED_GREEN and LED_BLUE. Therefore, those must be correctly defined
|
||||
* by the platform configuration.
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the RGB LED driver.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define RGB_LED_RED 1
|
||||
#define RGB_LED_GREEN 2
|
||||
#define RGB_LED_BLUE 4
|
||||
#define RGB_LED_MAGENTA (RGB_LED_RED | RGB_LED_BLUE)
|
||||
#define RGB_LED_YELLOW (RGB_LED_RED | RGB_LED_GREEN)
|
||||
#define RGB_LED_CYAN (RGB_LED_GREEN | RGB_LED_BLUE )
|
||||
#define RGB_LED_WHITE (RGB_LED_RED | RGB_LED_GREEN | RGB_LED_BLUE)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Turn off the RGB LED
|
||||
*/
|
||||
void rgb_led_off(void);
|
||||
|
||||
/**
|
||||
* \brief Set the colour of the RGB LED
|
||||
* \param colour The colour to set
|
||||
*
|
||||
* \e colour can take the value of one of the RGB_LED_xyz defines.
|
||||
*/
|
||||
void rgb_led_set(uint8_t colour);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RGB_LED_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -6,10 +6,10 @@ endif
|
|||
|
||||
CONTIKI_TARGET_DIRS = . dev
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += leds.c leds-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += leds-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c
|
||||
CONTIKI_TARGET_SOURCEFILES += sensors.c smartrf-sensors.c
|
||||
CONTIKI_TARGET_SOURCEFILES += button-sensor.c als-sensor.c
|
||||
CONTIKI_TARGET_SOURCEFILES += board-buttons.c als-sensor.c
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
||||
|
@ -19,8 +19,7 @@ CLEAN += *.cc2538dk
|
|||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc2538
|
||||
include $(CONTIKI_CPU)/Makefile.cc2538
|
||||
|
||||
MODULES += os/net os/net/mac os/net/mac/framer \
|
||||
os/storage/cfs
|
||||
MODULES += os/storage/cfs
|
||||
|
||||
PYTHON = python
|
||||
BSL_FLAGS += -e -w -v
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Include Project Specific conf */
|
||||
#ifdef PROJECT_CONF_PATH
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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 cc2538-smartrf
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc2538-smartrf-buttons SmartRF06EB Buttons
|
||||
*
|
||||
* Generic module controlling buttons on the SmartRF06EB
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Defines SmartRF06EB buttons for use with the button HAL
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/button-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTON(key_left, "Key Left", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN), \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_ZERO, true);
|
||||
BUTTON_HAL_BUTTON(key_right, "Key Right", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN), \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_ONE, true);
|
||||
BUTTON_HAL_BUTTON(key_up, "Key Up", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_UP_PORT, BUTTON_UP_PIN), \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_TWO, true);
|
||||
BUTTON_HAL_BUTTON(key_down, "Key Down", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN), \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_THREE, true);
|
||||
BUTTON_HAL_BUTTON(key_select, "Key Select", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN), \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_FOUR, true);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_left, &key_right, &key_up, &key_down, &key_select);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -71,20 +71,25 @@
|
|||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_YELLOW 2 /**< LED2 (Yellow) -> PC1 */
|
||||
#define LEDS_GREEN 4 /**< LED3 (Green) -> PC2 */
|
||||
#define LEDS_ORANGE 8 /**< LED4 (Orange) -> PC3 */
|
||||
#define LEDS_CONF_YELLOW 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
#define LEDS_CONF_ORANGE 4
|
||||
|
||||
#define LEDS_ARCH_L1_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L1_PIN 1
|
||||
#define LEDS_ARCH_L2_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L2_PIN 2
|
||||
#define LEDS_ARCH_L3_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L3_PIN 3
|
||||
|
||||
#if USB_SERIAL_CONF_ENABLE
|
||||
#define LEDS_CONF_ALL 14
|
||||
#define LEDS_RED LEDS_ORANGE
|
||||
#define LEDS_CONF_COUNT 3
|
||||
#else
|
||||
#define LEDS_CONF_ALL 15
|
||||
#define LEDS_RED 1 /**< LED1 (Red) -> PC0 */
|
||||
#define LEDS_ARCH_L4_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L4_PIN 0
|
||||
#define LEDS_CONF_RED 8
|
||||
#define LEDS_CONF_COUNT 4
|
||||
#endif
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -158,6 +163,7 @@
|
|||
|
||||
/* Notify various examples that we have Buttons */
|
||||
#define PLATFORM_HAS_BUTTON 1
|
||||
#define PLATFORM_SUPPORTS_BUTTON_HAL 1
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
|
|
@ -1,252 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup cc2538dk-button-sensor
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for the SmartRF06EB buttons
|
||||
*/
|
||||
#include "contiki.h"
|
||||
#include "dev/nvic.h"
|
||||
#include "dev/ioc.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "sys/timer.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BUTTON_SELECT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_SELECT_PORT)
|
||||
#define BUTTON_SELECT_PIN_MASK GPIO_PIN_MASK(BUTTON_SELECT_PIN)
|
||||
|
||||
#define BUTTON_LEFT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_LEFT_PORT)
|
||||
#define BUTTON_LEFT_PIN_MASK GPIO_PIN_MASK(BUTTON_LEFT_PIN)
|
||||
|
||||
#define BUTTON_RIGHT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_RIGHT_PORT)
|
||||
#define BUTTON_RIGHT_PIN_MASK GPIO_PIN_MASK(BUTTON_RIGHT_PIN)
|
||||
|
||||
#define BUTTON_UP_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_UP_PORT)
|
||||
#define BUTTON_UP_PIN_MASK GPIO_PIN_MASK(BUTTON_UP_PIN)
|
||||
|
||||
#define BUTTON_DOWN_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_DOWN_PORT)
|
||||
#define BUTTON_DOWN_PIN_MASK GPIO_PIN_MASK(BUTTON_DOWN_PIN)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct timer debouncetimer;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Common initialiser for all buttons
|
||||
* \param port_base GPIO port's register offset
|
||||
* \param pin_mask Pin mask corresponding to the button's pin
|
||||
*/
|
||||
static void
|
||||
config(uint32_t port_base, uint32_t pin_mask)
|
||||
{
|
||||
/* Software controlled */
|
||||
GPIO_SOFTWARE_CONTROL(port_base, pin_mask);
|
||||
|
||||
/* Set pin to input */
|
||||
GPIO_SET_INPUT(port_base, pin_mask);
|
||||
|
||||
/* Enable edge detection */
|
||||
GPIO_DETECT_EDGE(port_base, pin_mask);
|
||||
|
||||
/* Single edge */
|
||||
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
|
||||
|
||||
/* Trigger interrupt on Falling edge */
|
||||
GPIO_DETECT_RISING(port_base, pin_mask);
|
||||
|
||||
GPIO_ENABLE_INTERRUPT(port_base, pin_mask);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Callback registered with the GPIO module. Gets fired with a button
|
||||
* port/pin generates an interrupt
|
||||
* \param port The port number that generated the interrupt
|
||||
* \param pin The pin number that generated the interrupt. This is the pin
|
||||
* absolute number (i.e. 0, 1, ..., 7), not a mask
|
||||
*/
|
||||
static void
|
||||
btn_callback(uint8_t port, uint8_t pin)
|
||||
{
|
||||
if(!timer_expired(&debouncetimer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
timer_set(&debouncetimer, CLOCK_SECOND / 8);
|
||||
|
||||
if((port == BUTTON_SELECT_PORT) && (pin == BUTTON_SELECT_PIN)) {
|
||||
sensors_changed(&button_select_sensor);
|
||||
} else if((port == BUTTON_LEFT_PORT) && (pin == BUTTON_LEFT_PIN)) {
|
||||
sensors_changed(&button_left_sensor);
|
||||
} else if((port == BUTTON_RIGHT_PORT) && (pin == BUTTON_RIGHT_PIN)) {
|
||||
sensors_changed(&button_right_sensor);
|
||||
} else if((port == BUTTON_UP_PORT) && (pin == BUTTON_UP_PIN)) {
|
||||
sensors_changed(&button_up_sensor);
|
||||
} else if((port == BUTTON_DOWN_PORT) && (pin == BUTTON_DOWN_PIN)) {
|
||||
sensors_changed(&button_down_sensor);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init function for the select button.
|
||||
*
|
||||
* Parameters are ignored. They have been included because the prototype is
|
||||
* dictated by the core sensor api. The return value is also not required by
|
||||
* the API but otherwise ignored.
|
||||
*
|
||||
* \param type ignored
|
||||
* \param value ignored
|
||||
* \return ignored
|
||||
*/
|
||||
static int
|
||||
config_select(int type, int value)
|
||||
{
|
||||
config(BUTTON_SELECT_PORT_BASE, BUTTON_SELECT_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
NVIC_EnableIRQ(BUTTON_SELECT_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_SELECT_PORT, BUTTON_SELECT_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init function for the left button.
|
||||
*
|
||||
* Parameters are ignored. They have been included because the prototype is
|
||||
* dictated by the core sensor api. The return value is also not required by
|
||||
* the API but otherwise ignored.
|
||||
*
|
||||
* \param type ignored
|
||||
* \param value ignored
|
||||
* \return ignored
|
||||
*/
|
||||
static int
|
||||
config_left(int type, int value)
|
||||
{
|
||||
config(BUTTON_LEFT_PORT_BASE, BUTTON_LEFT_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
NVIC_EnableIRQ(BUTTON_LEFT_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init function for the right button.
|
||||
*
|
||||
* Parameters are ignored. They have been included because the prototype is
|
||||
* dictated by the core sensor api. The return value is also not required by
|
||||
* the API but otherwise ignored.
|
||||
*
|
||||
* \param type ignored
|
||||
* \param value ignored
|
||||
* \return ignored
|
||||
*/
|
||||
static int
|
||||
config_right(int type, int value)
|
||||
{
|
||||
config(BUTTON_RIGHT_PORT_BASE, BUTTON_RIGHT_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
NVIC_EnableIRQ(BUTTON_RIGHT_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init function for the up button.
|
||||
*
|
||||
* Parameters are ignored. They have been included because the prototype is
|
||||
* dictated by the core sensor api. The return value is also not required by
|
||||
* the API but otherwise ignored.
|
||||
*
|
||||
* \param type ignored
|
||||
* \param value ignored
|
||||
* \return ignored
|
||||
*/
|
||||
static int
|
||||
config_up(int type, int value)
|
||||
{
|
||||
config(BUTTON_UP_PORT_BASE, BUTTON_UP_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_UP_PORT, BUTTON_UP_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
NVIC_EnableIRQ(BUTTON_UP_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_UP_PORT, BUTTON_UP_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init function for the down button.
|
||||
*
|
||||
* Parameters are ignored. They have been included because the prototype is
|
||||
* dictated by the core sensor api. The return value is also not required by
|
||||
* the API but otherwise ignored.
|
||||
*
|
||||
* \param type ignored
|
||||
* \param value ignored
|
||||
* \return ignored
|
||||
*/
|
||||
static int
|
||||
config_down(int type, int value)
|
||||
{
|
||||
config(BUTTON_DOWN_PORT_BASE, BUTTON_DOWN_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
NVIC_EnableIRQ(BUTTON_DOWN_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_DOWN_PORT, BUTTON_DOWN_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
button_sensor_init()
|
||||
{
|
||||
timer_set(&debouncetimer, 0);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_select_sensor, BUTTON_SENSOR, NULL, config_select, NULL);
|
||||
SENSORS_SENSOR(button_left_sensor, BUTTON_SENSOR, NULL, config_left, NULL);
|
||||
SENSORS_SENSOR(button_right_sensor, BUTTON_SENSOR, NULL, config_right, NULL);
|
||||
SENSORS_SENSOR(button_up_sensor, BUTTON_SENSOR, NULL, config_up, NULL);
|
||||
SENSORS_SENSOR(button_down_sensor, BUTTON_SENSOR, NULL, config_down, NULL);
|
||||
|
||||
/** @} */
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup cc2538-smartrf-sensors
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc2538dk-button-sensor cc2538dk Button Driver
|
||||
*
|
||||
* Driver for the SmartRF06EB buttons
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the cc2538dk Button Driver
|
||||
*/
|
||||
#ifndef BUTTON_SENSOR_H_
|
||||
#define BUTTON_SENSOR_H_
|
||||
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/gpio.h"
|
||||
|
||||
#define BUTTON_SENSOR "Button"
|
||||
|
||||
#define button_sensor button_select_sensor
|
||||
extern const struct sensors_sensor button_select_sensor;
|
||||
extern const struct sensors_sensor button_left_sensor;
|
||||
extern const struct sensors_sensor button_right_sensor;
|
||||
extern const struct sensors_sensor button_up_sensor;
|
||||
extern const struct sensors_sensor button_down_sensor;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* BUTTON_SENSOR_H_ */
|
||||
|
||||
/** \brief Common initialiser for all SmartRF Buttons */
|
||||
void button_sensor_init();
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* 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.
|
||||
|
@ -28,45 +28,34 @@
|
|||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup cc2538-smartrf
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc2538dk-leds SmartRF06EB LED driver
|
||||
*
|
||||
* LED driver implementation for the TI SmartRF06EB + cc2538EM
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* LED driver implementation for the TI SmartRF06EB + cc2538EM
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/gpio-hal-arch.h"
|
||||
|
||||
#define LEDS_GPIO_PIN_MASK LEDS_ALL
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
GPIO_SET_OUTPUT(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return GPIO_READ_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
GPIO_WRITE_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK, leds);
|
||||
}
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L1_PORT, LEDS_ARCH_L1_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L2_PORT, LEDS_ARCH_L2_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L3_PORT, LEDS_ARCH_L3_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
#if !USB_SERIAL_CONF_ENABLE
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L4_PORT, LEDS_ARCH_L4_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
#endif
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
|
|
@ -41,16 +41,13 @@
|
|||
* Implementation of a generic module controlling SmartRF06EB sensors
|
||||
*/
|
||||
#include "contiki.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/als-sensor.h"
|
||||
#include "dev/cc2538-sensors.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/** \brief Exports a global symbol to be used by the sensor API */
|
||||
SENSORS(&button_select_sensor, &button_left_sensor, &button_right_sensor,
|
||||
&button_up_sensor, &button_down_sensor, &als_sensor,
|
||||
&cc2538_temp_sensor, &vdd3_sensor);
|
||||
SENSORS(&als_sensor, &cc2538_temp_sensor, &vdd3_sensor);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -46,14 +46,15 @@
|
|||
#include "dev/adc.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/uart.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/serial-line.h"
|
||||
#include "dev/slip.h"
|
||||
#include "dev/cc2538-rf.h"
|
||||
#include "dev/udma.h"
|
||||
#include "dev/crypto.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "usb/usb-serial.h"
|
||||
#include "lib/random.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/mac/framer/frame802154.h"
|
||||
#include "net/linkaddr.h"
|
||||
|
@ -74,7 +75,7 @@
|
|||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
fade(unsigned char l)
|
||||
fade(leds_mask_t l)
|
||||
{
|
||||
volatile int i;
|
||||
int k, j;
|
||||
|
@ -121,8 +122,6 @@ platform_init_stage_one(void)
|
|||
void
|
||||
platform_init_stage_two()
|
||||
{
|
||||
button_sensor_init();
|
||||
|
||||
/*
|
||||
* Character I/O Initialisation.
|
||||
* When the UART receives a character it will call serial_line_input_byte to
|
||||
|
@ -159,6 +158,8 @@ platform_init_stage_two()
|
|||
/* Populate linkaddr_node_addr */
|
||||
ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE);
|
||||
|
||||
button_hal_init();
|
||||
|
||||
INTERRUPTS_ENABLE();
|
||||
|
||||
fade(LEDS_GREEN);
|
||||
|
|
|
@ -38,10 +38,7 @@ endif ## QUICKSTART
|
|||
MAIN_OBJ = $(OBJECTDIR)/$(LIBNAME).o
|
||||
ARCHIVE = $(OBJECTDIR)/$(LIBNAME).a
|
||||
JNILIB = $(OBJECTDIR)/$(LIBNAME).$(TARGET)
|
||||
CONTIKI_APP_OBJ = $(CONTIKI_APP).co
|
||||
|
||||
# Modules
|
||||
MODULES += os/net os/net/mac os/net/mac/framer
|
||||
CONTIKI_APP_OBJ = $(CONTIKI_APP).o
|
||||
|
||||
### COOJA platform sources
|
||||
COOJA = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
|
|
|
@ -32,5 +32,5 @@ $(CONTIKI_APP).cooja: $(JNILIB)
|
|||
|
||||
# Trickiness: GNU make matches this against the file base name.
|
||||
# Assume that the directory part is the standard location.
|
||||
mtype%.o: contiki-cooja-main.o | $(OBJECTDIR)
|
||||
mv contiki-cooja-main.o $@
|
||||
mtype%.o: platform.o | $(OBJECTDIR)
|
||||
mv platform.o $@
|
||||
|
|
|
@ -42,10 +42,14 @@
|
|||
#include "subplatform-conf.h"
|
||||
#endif /* INCLUDE_SUBPLATFORM_CONF */
|
||||
|
||||
#define PLATFORM_CONF_PROVIDES_MAIN_LOOP 1
|
||||
|
||||
#define LOG_CONF_ENABLED 1
|
||||
|
||||
#define COOJA 1
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#ifndef EEPROM_CONF_SIZE
|
||||
#define EEPROM_CONF_SIZE 1024
|
||||
#endif
|
||||
|
@ -98,9 +102,6 @@
|
|||
#define CC_CONF_VA_ARGS 1
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
/* These names are deprecated, use C99 names. */
|
||||
#include <inttypes.h>
|
||||
typedef uint8_t u8_t;
|
||||
|
|
|
@ -34,18 +34,18 @@
|
|||
const struct simInterface leds_interface;
|
||||
|
||||
// COOJA variables
|
||||
unsigned char simLedsValue;
|
||||
leds_mask_t simLedsValue;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void leds_arch_init() {
|
||||
simLedsValue = 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
unsigned char leds_arch_get() {
|
||||
leds_mask_t leds_arch_get() {
|
||||
return simLedsValue;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void leds_arch_set(unsigned char leds) {
|
||||
void leds_arch_set(leds_mask_t leds) {
|
||||
if(leds != simLedsValue) {
|
||||
simLedsValue = leds;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,12 @@
|
|||
#include "sys/clock.h"
|
||||
#include "sys/etimer.h"
|
||||
#include "sys/cooja_mt.h"
|
||||
#include "sys/autostart.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "Cooja"
|
||||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||
|
||||
#include "lib/random.h"
|
||||
#include "lib/simEnvChange.h"
|
||||
|
@ -62,6 +66,7 @@
|
|||
#include "dev/vib-sensor.h"
|
||||
|
||||
#include "sys/node-id.h"
|
||||
#include "services/rpl-border-router/rpl-border-router.h"
|
||||
#if BUILD_WITH_ORCHESTRA
|
||||
#include "orchestra.h"
|
||||
#endif /* BUILD_WITH_ORCHESTRA */
|
||||
|
@ -71,7 +76,7 @@
|
|||
|
||||
/* JNI-defined functions, depends on the environment variable CLASSNAME */
|
||||
#ifndef CLASSNAME
|
||||
#error CLASSNAME is undefined, required by contiki-cooja-main.c
|
||||
#error CLASSNAME is undefined, required by platform.c
|
||||
#endif /* CLASSNAME */
|
||||
#define COOJA__QUOTEME(a,b,c) COOJA_QUOTEME(a,b,c)
|
||||
#define COOJA_QUOTEME(a,b,c) a##b##c
|
||||
|
@ -82,15 +87,14 @@
|
|||
#define Java_org_contikios_cooja_corecomm_CLASSNAME_tick COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_tick)
|
||||
#define Java_org_contikios_cooja_corecomm_CLASSNAME_setReferenceAddress COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_setReferenceAddress)
|
||||
|
||||
#ifndef NETSTACK_CONF_WITH_IPV6
|
||||
#define NETSTACK_CONF_WITH_IPV6 0
|
||||
#endif
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#include "net/ipv6/uip.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#define PRINT6ADDR(addr) printf("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", ((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])
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* The main function, implemented in contiki-main.c */
|
||||
int main(void);
|
||||
|
||||
/* Simulation mote interfaces */
|
||||
SIM_INTERFACE_NAME(moteid_interface);
|
||||
SIM_INTERFACE_NAME(vib_interface);
|
||||
|
@ -124,18 +128,6 @@ long referenceVar;
|
|||
static struct cooja_mt_thread rtimer_thread;
|
||||
static struct cooja_mt_thread process_run_thread;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
print_processes(struct process * const processes[])
|
||||
{
|
||||
/* const struct process * const * p = processes;*/
|
||||
printf("Starting");
|
||||
while(*processes != NULL) {
|
||||
printf(" '%s'", (*processes)->name);
|
||||
processes++;
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
rtimer_thread_loop(void *data)
|
||||
|
@ -168,117 +160,65 @@ set_lladdr(void)
|
|||
addr.u8[1] = node_id >> 8;
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
linkaddr_set_node_addr(&addr);
|
||||
|
||||
printf("Link-layer address ");
|
||||
log_lladdr(&addr);
|
||||
printf("\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
contiki_init()
|
||||
platform_init_stage_one()
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
platform_init_stage_two()
|
||||
{
|
||||
/* Initialize random generator (moved to moteid.c) */
|
||||
|
||||
/* Start process handler */
|
||||
process_init();
|
||||
|
||||
|
||||
/* Start Contiki processes */
|
||||
|
||||
process_start(&etimer_process, NULL);
|
||||
process_start(&sensors_process, NULL);
|
||||
ctimer_init();
|
||||
|
||||
/* Print startup information */
|
||||
printf(CONTIKI_VERSION_STRING " started. ");
|
||||
if(node_id > 0) {
|
||||
printf("Node id is set to %u.\n", node_id);
|
||||
} else {
|
||||
printf("Node id is not set.\n");
|
||||
}
|
||||
|
||||
set_lladdr();
|
||||
{
|
||||
uint8_t longaddr[8];
|
||||
|
||||
memset(longaddr, 0, sizeof(longaddr));
|
||||
linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);
|
||||
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
|
||||
longaddr[0], longaddr[1], longaddr[2], longaddr[3],
|
||||
longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
platform_init_stage_three()
|
||||
{
|
||||
if(node_id > 0) {
|
||||
LOG_INFO("Node id is set to %u.\n", node_id);
|
||||
} else {
|
||||
LOG_INFO("Node id is not set.\n");
|
||||
}
|
||||
|
||||
/* Initialize communication stack */
|
||||
netstack_init();
|
||||
printf("%s/%s\n",
|
||||
NETSTACK_NETWORK.name, NETSTACK_MAC.name);
|
||||
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* IPv6 CONFIGURATION */
|
||||
{
|
||||
int i;
|
||||
uip_ds6_addr_t *lladdr;
|
||||
uint8_t addr[sizeof(uip_lladdr.addr)];
|
||||
for(i = 0; i < sizeof(uip_lladdr.addr); i += 2) {
|
||||
addr[i + 1] = node_id & 0xff;
|
||||
addr[i + 0] = node_id >> 8;
|
||||
}
|
||||
linkaddr_copy((linkaddr_t *)addr, &linkaddr_node_addr);
|
||||
memcpy(&uip_lladdr.addr, addr, sizeof(uip_lladdr.addr));
|
||||
|
||||
process_start(&tcpip_process, NULL);
|
||||
|
||||
lladdr = uip_ds6_get_link_local(-1);
|
||||
printf("Tentative link-local IPv6 address ");
|
||||
log_6addr(lladdr != NULL ? &lladdr->ipaddr : NULL);
|
||||
printf("\n");
|
||||
}
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* Initialize eeprom */
|
||||
eeprom_init();
|
||||
|
||||
/* Start serial process */
|
||||
serial_line_init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
platform_main_loop()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
simProcessRunValue = process_run();
|
||||
while(simProcessRunValue-- > 0) {
|
||||
process_run();
|
||||
}
|
||||
simProcessRunValue = process_nevents();
|
||||
|
||||
#if BUILD_WITH_ORCHESTRA
|
||||
orchestra_init();
|
||||
#endif /* BUILD_WITH_ORCHESTRA */
|
||||
#if BUILD_WITH_SHELL
|
||||
serial_shell_init();
|
||||
#endif /* BUILD_WITH_SHELL */
|
||||
/* Check if we must stay awake */
|
||||
if(simDontFallAsleep) {
|
||||
simDontFallAsleep = 0;
|
||||
simProcessRunValue = 1;
|
||||
}
|
||||
|
||||
/* Start autostart processes (defined in Contiki application) */
|
||||
print_processes(autostart_processes);
|
||||
autostart_start(autostart_processes);
|
||||
/* Return to COOJA */
|
||||
cooja_mt_yield();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
process_run_thread_loop(void *data)
|
||||
{
|
||||
/* Yield once during bootup */
|
||||
simProcessRunValue = 1;
|
||||
cooja_mt_yield();
|
||||
/* Yield once during bootup */
|
||||
simProcessRunValue = 1;
|
||||
cooja_mt_yield();
|
||||
|
||||
contiki_init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
simProcessRunValue = process_run();
|
||||
while(simProcessRunValue-- > 0) {
|
||||
process_run();
|
||||
}
|
||||
simProcessRunValue = process_nevents();
|
||||
|
||||
/* Check if we must stay awake */
|
||||
if(simDontFallAsleep) {
|
||||
simDontFallAsleep=0;
|
||||
simProcessRunValue = 1;
|
||||
}
|
||||
|
||||
/* Return to COOJA */
|
||||
cooja_mt_yield();
|
||||
}
|
||||
/* Then call common Contiki-NG main function */
|
||||
main();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
|
@ -143,8 +143,6 @@ endif
|
|||
CLEAN += *.jn516x
|
||||
CLEAN += *.jn516x.bin
|
||||
|
||||
MODULES += os/net os/net/mac os/net/mac/framer
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += $(ARCH)
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
||||
|
@ -236,7 +234,7 @@ ABS_APPLIBS = $(addsuffix _$(JENNIC_CHIP_FAMILY).a,$(addprefix $(COMPONENTS_BASE
|
|||
|
||||
ifneq ($(wildcard $(SDK_BASE_DIR)/Components/Library/*),)
|
||||
# The SDK is fully installed, proceed to linking and objcopy to ready-to-upload .jn516x.bin file
|
||||
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(ABS_APPLIBS)
|
||||
%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(ABS_APPLIBS)
|
||||
echo ${filter %.a,$^}
|
||||
$(Q)$(CC) -Wl,--gc-sections $(LDFLAGS) -T$(LINKCMD) -o $@ -Wl,--start-group \
|
||||
$(patsubst /cygdrive/c/%,c:/%,${filter-out %.a,$^}) \
|
||||
|
@ -245,7 +243,7 @@ ifneq ($(wildcard $(SDK_BASE_DIR)/Components/Library/*),)
|
|||
$(OBJCOPY) -S -O binary $@ $@.bin
|
||||
else
|
||||
# The SDK does not include libraries, only build objects and libraries, skip linking
|
||||
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
echo Creating empty $@
|
||||
touch $@
|
||||
endif
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#define LED_G (1 << 16)
|
||||
#define LED_R (1 << 17)
|
||||
|
||||
static volatile uint8_t leds;
|
||||
static volatile leds_mask_t leds;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -49,14 +49,14 @@ leds_arch_init(void)
|
|||
leds = 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return leds;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char c)
|
||||
leds_arch_set(leds_mask_t c)
|
||||
{
|
||||
uint32 on_mask = 0;
|
||||
uint32 off_mask = 0;
|
||||
|
|
|
@ -278,8 +278,7 @@ init(void)
|
|||
vMMAC_EnableInterrupts(&radio_interrupt_handler);
|
||||
}
|
||||
vMMAC_ConfigureRadio();
|
||||
set_channel(current_channel);
|
||||
set_txpower(current_tx_power);
|
||||
set_txpower(current_tx_power); /* it sets also the current_channel */
|
||||
|
||||
vMMAC_GetMacAddress(&node_long_address);
|
||||
/* Short addresses are disabled by default */
|
||||
|
@ -493,8 +492,7 @@ void
|
|||
set_channel(int c)
|
||||
{
|
||||
current_channel = c;
|
||||
/* will fine tune TX power as well */
|
||||
vMMAC_SetChannel(current_channel);
|
||||
vMMAC_SetChannelAndPower(current_channel, current_tx_power);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if !MICROMAC_RADIO_MAC
|
||||
|
|
|
@ -196,6 +196,8 @@ typedef uint32_t rtimer_clock_t;
|
|||
#define PLATFORM_HAS_SHT11 0
|
||||
#define PLATFORM_HAS_RADIO 1
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#define PLATFORM_CONF_PROVIDES_MAIN_LOOP 1
|
||||
|
||||
/* CPU target speed in Hz
|
||||
|
@ -217,9 +219,6 @@ typedef uint32_t rtimer_clock_t;
|
|||
#define CC_CONF_VA_ARGS 1
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
|
@ -272,9 +271,14 @@ typedef uint32_t clock_time_t;
|
|||
|
||||
/* Set this to zero only if we are using SLIP */
|
||||
#ifndef SLIP_BRIDGE_CONF_NO_PUTCHAR
|
||||
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1
|
||||
#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT)
|
||||
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 0
|
||||
#else
|
||||
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1
|
||||
#endif
|
||||
#endif /* SLIP_BRIDGE_CONF_NO_PUTCHAR */
|
||||
|
||||
|
||||
/* Extension of LED definitions from leds.h for various JN516x dev boards
|
||||
JN516x Dongle:
|
||||
LEDS_RED Red LED on dongle
|
||||
|
|
|
@ -30,8 +30,8 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|||
# Enable nullmac by default
|
||||
MAKE_MAC ?= MAKE_MAC_NULLMAC
|
||||
|
||||
CLEAN += *.native
|
||||
|
||||
### Define the CPU directory
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/native
|
||||
include $(CONTIKI)/arch/cpu/native/Makefile.native
|
||||
|
||||
MODULES+=os/net os/net/mac os/net/mac/framer
|
||||
|
|
|
@ -58,18 +58,19 @@ int select_set_callback(int fd, const struct select_callback *callback);
|
|||
#define EEPROM_CONF_SIZE 1024
|
||||
#endif
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
/* These names are deprecated, use C99 names. */
|
||||
typedef uint8_t u8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef int32_t s32_t;
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
typedef unsigned int uip_stats_t;
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#ifndef UIP_CONF_BYTE_ORDER
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include "dev/leds.h"
|
||||
static unsigned char leds;
|
||||
static leds_mask_t leds;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
|
@ -46,14 +46,14 @@ leds_arch_init(void)
|
|||
leds = 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return leds;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char l)
|
||||
leds_arch_set(leds_mask_t l)
|
||||
{
|
||||
leds = l;
|
||||
}
|
||||
|
|
|
@ -70,16 +70,53 @@
|
|||
#define LOG_MODULE "Native"
|
||||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Native Platform Configuration
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Defines the maximum number of file descriptors monitored by the platform
|
||||
* main loop.
|
||||
*/
|
||||
#ifdef SELECT_CONF_MAX
|
||||
#define SELECT_MAX SELECT_CONF_MAX
|
||||
#else
|
||||
#define SELECT_MAX 8
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines the timeout (in msec) of the select operation if no monitored file
|
||||
* descriptors becomes ready.
|
||||
*/
|
||||
#ifdef SELECT_CONF_TIMEOUT
|
||||
#define SELECT_TIMEOUT SELECT_CONF_TIMEOUT
|
||||
#else
|
||||
#define SELECT_TIMEOUT 1000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Adds the STDIN file descriptor to the list of monitored file descriptors.
|
||||
*/
|
||||
#ifdef SELECT_CONF_STDIN
|
||||
#define SELECT_STDIN SELECT_CONF_STDIN
|
||||
#else
|
||||
#define SELECT_STDIN 1
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static const struct select_callback *select_callback[SELECT_MAX];
|
||||
static int select_max = 0;
|
||||
|
||||
static uint8_t serial_id[] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
|
||||
#ifdef PLATFORM_CONF_MAC_ADDR
|
||||
static uint8_t mac_addr[] = PLATFORM_CONF_MAC_ADDR;
|
||||
#else /* PLATFORM_CONF_MAC_ADDR */
|
||||
static uint8_t mac_addr[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
||||
#endif /* PLATFORM_CONF_MAC_ADDR */
|
||||
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
static uint16_t node_id = 0x0102;
|
||||
#endif /* !NETSTACK_CONF_WITH_IPV6 */
|
||||
|
@ -116,6 +153,7 @@ select_set_callback(int fd, const struct select_callback *callback)
|
|||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if SELECT_STDIN
|
||||
static int
|
||||
stdin_set_fd(fd_set *rset, fd_set *wset)
|
||||
{
|
||||
|
@ -135,6 +173,7 @@ stdin_handle_fd(fd_set *rset, fd_set *wset)
|
|||
const static struct select_callback stdin_fd = {
|
||||
stdin_set_fd, stdin_handle_fd
|
||||
};
|
||||
#endif /* SELECT_STDIN */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
set_lladdr(void)
|
||||
|
@ -143,12 +182,12 @@ set_lladdr(void)
|
|||
|
||||
memset(&addr, 0, sizeof(linkaddr_t));
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
memcpy(addr.u8, serial_id, sizeof(addr.u8));
|
||||
memcpy(addr.u8, mac_addr, sizeof(addr.u8));
|
||||
#else
|
||||
if(node_id == 0) {
|
||||
int i;
|
||||
for(i = 0; i < sizeof(linkaddr_t); ++i) {
|
||||
addr.u8[i] = serial_id[7 - i];
|
||||
addr.u8[i] = mac_addr[7 - i];
|
||||
}
|
||||
} else {
|
||||
addr.u8[0] = node_id & 0xff;
|
||||
|
@ -219,6 +258,7 @@ void
|
|||
platform_init_stage_two()
|
||||
{
|
||||
set_lladdr();
|
||||
serial_line_init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -240,7 +280,9 @@ platform_init_stage_three()
|
|||
void
|
||||
platform_main_loop()
|
||||
{
|
||||
#if SELECT_STDIN
|
||||
select_set_callback(STDIN_FILENO, &stdin_fd);
|
||||
#endif /* SELECT_STDIN */
|
||||
while(1) {
|
||||
fd_set fdr;
|
||||
fd_set fdw;
|
||||
|
@ -252,7 +294,7 @@ platform_main_loop()
|
|||
retval = process_run();
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = retval ? 1 : 1000;
|
||||
tv.tv_usec = retval ? 1 : SELECT_TIMEOUT;
|
||||
|
||||
FD_ZERO(&fdr);
|
||||
FD_ZERO(&fdw);
|
||||
|
|
|
@ -27,5 +27,3 @@ SMALL ?= 0
|
|||
### Define the CPU directory and pull in the correct CPU makefile.
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/nrf52832
|
||||
include $(CONTIKI_CPU)/Makefile.nrf52832
|
||||
|
||||
MODULES += os/net os/net/mac os/net/mac/framer
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#define CONTIKI_CONF_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Include Project Specific conf */
|
||||
#ifdef PROJECT_CONF_PATH
|
||||
|
|
|
@ -55,14 +55,14 @@ leds_arch_init(void)
|
|||
LEDS_OFF(LEDS_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return (unsigned char)(LED_IS_ON(LEDS_MASK) >> LED_START);
|
||||
return (leds_mask_t)(LED_IS_ON(LEDS_MASK) >> LED_START);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
leds_arch_set(leds_mask_t leds)
|
||||
{
|
||||
unsigned int mask = (unsigned int)leds << LED_START;
|
||||
LEDS_OFF(LEDS_MASK);
|
||||
|
|
|
@ -60,16 +60,17 @@
|
|||
* @{
|
||||
*/
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#define LEDS_1 (1 << (LED_1 - LED_START)) // 1
|
||||
#define LEDS_2 (1 << (LED_2 - LED_START)) // 2
|
||||
#define LEDS_3 (1 << (LED_3 - LED_START)) // 4
|
||||
#define LEDS_4 (1 << (LED_4 - LED_START)) // 8
|
||||
|
||||
#define LEDS_GREEN LEDS_1
|
||||
#define LEDS_YELLOW LEDS_2
|
||||
#define LEDS_RED LEDS_3
|
||||
#define LEDS_BLUE LEDS_4
|
||||
#define LEDS_CONF_GREEN LEDS_1
|
||||
#define LEDS_CONF_YELLOW LEDS_2
|
||||
#define LEDS_CONF_RED LEDS_3
|
||||
#define LEDS_CONF_BLUE LEDS_4
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_1 | LEDS_2 | LEDS_3 | LEDS_4)
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ platform_init_stage_two(void)
|
|||
#ifdef UART0_ENABLED
|
||||
uart0_init();
|
||||
#if SLIP_ARCH_CONF_ENABLE
|
||||
slip_arch_init();
|
||||
#error Platform does not support SLIP
|
||||
#else
|
||||
uart0_set_input(serial_line_input_byte);
|
||||
serial_line_init();
|
||||
|
|
|
@ -15,7 +15,7 @@ PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
|||
|
||||
### Include
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c board.c
|
||||
CONTIKI_TARGET_SOURCEFILES += leds-arch.c button-sensor.c openmote-sensors.c
|
||||
CONTIKI_TARGET_SOURCEFILES += leds-arch.c board-buttons.c openmote-sensors.c
|
||||
CONTIKI_TARGET_SOURCEFILES += antenna.c adxl346.c max44009.c sht21.c tps62730.c
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
@ -26,8 +26,7 @@ CLEAN += *.openmote-cc2538
|
|||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc2538
|
||||
include $(CONTIKI_CPU)/Makefile.cc2538
|
||||
|
||||
MODULES += os/net os/net/mac os/net/mac/framer \
|
||||
os/storage/cfs
|
||||
MODULES += os/storage/cfs
|
||||
|
||||
PYTHON = python
|
||||
BSL_FLAGS += -e --bootloader-invert-lines -w -v -b 450000
|
||||
|
|
|
@ -63,14 +63,21 @@
|
|||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_RED 16 /**< LED1 (Red) -> PC4 */
|
||||
#define LEDS_YELLOW 64 /**< LED2 (Yellow) -> PC6 */
|
||||
#define LEDS_GREEN 128 /**< LED3 (Green) -> PC7 */
|
||||
#define LEDS_ORANGE 32 /**< LED4 (Orange) -> PC5 */
|
||||
#define LEDS_CONF_ALL 240
|
||||
#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
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#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
|
||||
|
@ -121,6 +128,7 @@
|
|||
#define BUTTON_USER_VECTOR GPIO_C_IRQn
|
||||
/* Notify various examples that we have Buttons */
|
||||
#define PLATFORM_HAS_BUTTON 1
|
||||
#define PLATFORM_SUPPORTS_BUTTON_HAL 1
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Include Project Specific conf */
|
||||
#ifdef PROJECT_CONF_PATH
|
||||
|
|
|
@ -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-cc2538
|
||||
* @{
|
||||
*
|
||||
* \defgroup openmote-cc2538-buttons OpenMote-CC2538 user button
|
||||
*
|
||||
* Generic module controlling the user button on the OpenMote-CC2538
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Defines the OpenMote-CC2538 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_PULL_UP, BUTTON_HAL_ID_USER_BUTTON, true);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&button_user);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 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-button-sensor
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for for the OpenMote-CC2538 user button
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/nvic.h"
|
||||
#include "dev/ioc.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "sys/timer.h"
|
||||
#include "sys/ctimer.h"
|
||||
#include "sys/process.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BUTTON_USER_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_USER_PORT)
|
||||
#define BUTTON_USER_PIN_MASK GPIO_PIN_MASK(BUTTON_USER_PIN)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define DEBOUNCE_DURATION (CLOCK_SECOND >> 4)
|
||||
|
||||
static struct timer debouncetimer;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static clock_time_t press_duration = 0;
|
||||
static struct ctimer press_counter;
|
||||
static uint8_t press_event_counter;
|
||||
|
||||
process_event_t button_press_duration_exceeded;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
duration_exceeded_callback(void *data)
|
||||
{
|
||||
press_event_counter++;
|
||||
process_post(PROCESS_BROADCAST, button_press_duration_exceeded,
|
||||
&press_event_counter);
|
||||
ctimer_set(&press_counter, press_duration, duration_exceeded_callback,
|
||||
NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Retrieves the value of the button pin
|
||||
* \param type Returns the pin level or the counter of press duration events.
|
||||
* type == BUTTON_SENSOR_VALUE_TYPE_LEVEL or
|
||||
* type == BUTTON_SENSOR_VALUE_TYPE_PRESS_DURATION
|
||||
* respectively
|
||||
*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case BUTTON_SENSOR_VALUE_TYPE_LEVEL:
|
||||
return GPIO_READ_PIN(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
|
||||
case BUTTON_SENSOR_VALUE_TYPE_PRESS_DURATION:
|
||||
return press_event_counter;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Callback registered with the GPIO module. Gets fired with a button
|
||||
* port/pin generates an interrupt
|
||||
* \param port The port number that generated the interrupt
|
||||
* \param pin The pin number that generated the interrupt. This is the pin
|
||||
* absolute number (i.e. 0, 1, ..., 7), not a mask
|
||||
*/
|
||||
static void
|
||||
btn_callback(uint8_t port, uint8_t pin)
|
||||
{
|
||||
if(!timer_expired(&debouncetimer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
timer_set(&debouncetimer, DEBOUNCE_DURATION);
|
||||
|
||||
if(press_duration) {
|
||||
press_event_counter = 0;
|
||||
if(value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) == BUTTON_SENSOR_PRESSED_LEVEL) {
|
||||
ctimer_set(&press_counter, press_duration, duration_exceeded_callback,
|
||||
NULL);
|
||||
} else {
|
||||
ctimer_stop(&press_counter);
|
||||
}
|
||||
}
|
||||
|
||||
sensors_changed(&button_sensor);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init function for the User button.
|
||||
* \param type SENSORS_ACTIVE: Activate / Deactivate the sensor (value == 1
|
||||
* or 0 respectively)
|
||||
*
|
||||
* \param value Depends on the value of the type argument
|
||||
* \return Depends on the value of the type argument
|
||||
*/
|
||||
static int
|
||||
config_user(int type, int value)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_HW_INIT:
|
||||
button_press_duration_exceeded = process_alloc_event();
|
||||
|
||||
/* Software controlled */
|
||||
GPIO_SOFTWARE_CONTROL(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
|
||||
|
||||
/* Set pin to input */
|
||||
GPIO_SET_INPUT(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
|
||||
|
||||
/* Enable edge detection */
|
||||
GPIO_DETECT_EDGE(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
|
||||
|
||||
/* Both Edges */
|
||||
GPIO_TRIGGER_BOTH_EDGES(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_USER_PORT, BUTTON_USER_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_USER_PORT, BUTTON_USER_PIN);
|
||||
break;
|
||||
case SENSORS_ACTIVE:
|
||||
if(value) {
|
||||
GPIO_ENABLE_INTERRUPT(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
|
||||
NVIC_EnableIRQ(BUTTON_USER_VECTOR);
|
||||
} else {
|
||||
GPIO_DISABLE_INTERRUPT(BUTTON_USER_PORT_BASE, BUTTON_USER_PIN_MASK);
|
||||
NVIC_DisableIRQ(BUTTON_USER_VECTOR);
|
||||
}
|
||||
return value;
|
||||
case BUTTON_SENSOR_CONFIG_TYPE_INTERVAL:
|
||||
press_duration = (clock_time_t)value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, value, config_user, NULL);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -1,10 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* 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
|
||||
|
@ -26,48 +27,32 @@
|
|||
* 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-cc2538
|
||||
* @{
|
||||
*
|
||||
* \defgroup openmote-leds OpenMote-CC2538 LED driver
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* LED driver implementation for the OpenMote-CC2538 platform
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_GPIO_PIN_MASK LEDS_ALL
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L1_PORT, LEDS_ARCH_L1_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L2_PORT, LEDS_ARCH_L2_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L3_PORT, LEDS_ARCH_L3_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L4_PORT, LEDS_ARCH_L4_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
GPIO_SET_OUTPUT(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return GPIO_READ_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
GPIO_WRITE_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK, leds);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
/**
|
||||
* \brief Exports a global symbol to be used by the sensor API
|
||||
*/
|
||||
SENSORS(&button_sensor, &cc2538_temp_sensor);
|
||||
SENSORS(&cc2538_temp_sensor);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/cc2538-sensors.h"
|
||||
#include "dev/button-sensor.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* OPENMOTE_SENSORS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -55,8 +55,10 @@
|
|||
#include "dev/cc2538-rf.h"
|
||||
#include "dev/udma.h"
|
||||
#include "dev/crypto.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "usb/usb-serial.h"
|
||||
#include "lib/random.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/mac/framer/frame802154.h"
|
||||
#include "net/linkaddr.h"
|
||||
|
@ -82,7 +84,7 @@
|
|||
void board_init(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
fade(unsigned char l)
|
||||
fade(leds_mask_t l)
|
||||
{
|
||||
volatile int i;
|
||||
int k, j;
|
||||
|
@ -157,6 +159,8 @@ platform_init_stage_two()
|
|||
/* Populate linkaddr_node_addr */
|
||||
ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE);
|
||||
|
||||
button_hal_init();
|
||||
|
||||
INTERRUPTS_ENABLE();
|
||||
|
||||
fade(LEDS_BLUE);
|
||||
|
@ -175,8 +179,6 @@ platform_init_stage_three()
|
|||
|
||||
process_start(&sensors_process, NULL);
|
||||
|
||||
SENSORS_ACTIVATE(button_sensor);
|
||||
|
||||
fade(LEDS_GREEN);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -4,8 +4,8 @@ CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c \
|
|||
sht11.c sht11-sensor.c light-sensor.c battery-sensor.c \
|
||||
button-sensor.c
|
||||
|
||||
CLEAN += *.sky
|
||||
|
||||
include $(CONTIKI)/arch/platform/sky/Makefile.common
|
||||
|
||||
MODULES += os/net/mac os/net/mac/framer os/net \
|
||||
arch/dev/cc2420 arch/dev/sht11 arch/dev/ds2411 \
|
||||
os/storage/cfs
|
||||
MODULES += arch/dev/cc2420 arch/dev/sht11 arch/dev/ds2411 os/storage/cfs
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "sys/node-id.h"
|
||||
#include "cfs-coffee-arch.h"
|
||||
#include "cfs/cfs-coffee.h"
|
||||
#include "sys/autostart.h"
|
||||
|
||||
#if DCOSYNCH_CONF_ENABLED
|
||||
static struct timer mgt_timer;
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
/* Delay between the SFD finishes arriving and it is detected in software */
|
||||
#define RADIO_DELAY_BEFORE_DETECT 0
|
||||
|
||||
/* Disable TSCH frame filtering */
|
||||
#define TSCH_CONF_HW_FRAME_FILTERING 0
|
||||
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define PLATFORM_HAS_BUTTON 1
|
||||
#define PLATFORM_HAS_LIGHT 1
|
||||
|
@ -72,6 +75,8 @@
|
|||
#define LEDS_CONF_GREEN 0x20
|
||||
#define LEDS_CONF_YELLOW 0x40
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
/* DCO speed resynchronization for more robust UART, etc. */
|
||||
#ifndef DCOSYNCH_CONF_ENABLED
|
||||
#define DCOSYNCH_CONF_ENABLED (!(MAC_CONF_WITH_TSCH)) /* TSCH needs timerB
|
||||
|
|
|
@ -6,7 +6,7 @@ endif
|
|||
|
||||
### Board and BSP selection
|
||||
BOARD ?= srf06/cc26xx
|
||||
BOARDS = srf06/cc26xx srf06/cc13xx launchpad/cc26xx launchpad/cc13xx sensortag/cc26xx sensortag/cc13xx
|
||||
BOARDS = srf06/cc26xx srf06/cc13xx launchpad/cc2650 launchpad/cc1310 launchpad/cc1350 sensortag/cc2650 sensortag/cc1350
|
||||
|
||||
CONTIKI_TARGET_DIRS += .
|
||||
|
||||
|
@ -14,8 +14,7 @@ CONTIKI_TARGET_DIRS += .
|
|||
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(notdir $(BOARD))
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c
|
||||
CONTIKI_TARGET_SOURCEFILES += sensors.c leds.c
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c leds-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += $(BOARD_SOURCEFILES)
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
@ -30,5 +29,3 @@ SMALL ?= 0
|
|||
### Makefile.cc26xx or Makefile.cc13xx
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc26xx-cc13xx
|
||||
include $(CONTIKI_CPU)/Makefile.$(CPU_FAMILY)
|
||||
|
||||
MODULES += os/net os/net/mac os/net/mac/framer
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 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.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Coffee architecture-dependent header for the srf06-cc2650 sensortag platform.
|
||||
* \author
|
||||
* Dongda Lee <dongdongbhbh@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef CFS_COFFEE_ARCH_H
|
||||
#define CFS_COFFEE_ARCH_H
|
||||
|
||||
#include "contiki-conf.h"
|
||||
#include "dev/xmem.h"
|
||||
|
||||
/*** MX25R8035F Memory Organization
|
||||
The memory is organized as:
|
||||
8Mbit = 1048576 bytes (8 bits each)
|
||||
256 sectors (32 Kbits, 4096 bytes each)
|
||||
4096 pages (256 bytes each).
|
||||
Each page can be individually programmed (bits are programmed from 1 to 0). The device is
|
||||
sector or bulk erasable (bits are erased from 0 to 1) but not page erasable
|
||||
*/
|
||||
#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL //Total size of the External Flash Memory in the Z1
|
||||
|
||||
/* Coffee configuration parameters. */
|
||||
#define COFFEE_SECTOR_SIZE 4096UL
|
||||
#define COFFEE_PAGE_SIZE 256UL
|
||||
#define COFFEE_START 0UL //COFFEE_SECTOR_SIZE
|
||||
#define COFFEE_SIZE (COFFEE_XMEM_TOTAL_SIZE_KB * 1024UL - COFFEE_START)
|
||||
#define COFFEE_NAME_LENGTH 16
|
||||
#define COFFEE_MAX_OPEN_FILES 6
|
||||
#define COFFEE_FD_SET_SIZE 8
|
||||
#define COFFEE_LOG_TABLE_LIMIT 256
|
||||
#define COFFEE_DYN_SIZE 2*1024
|
||||
#define COFFEE_LOG_SIZE 1024
|
||||
|
||||
#define COFFEE_MICRO_LOGS 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Flash operations. */
|
||||
#define COFFEE_WRITE(buf, size, offset) \
|
||||
xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset))
|
||||
|
||||
#define COFFEE_READ(buf, size, offset) \
|
||||
xmem_pread((char *)(buf), (size), COFFEE_START + (offset))
|
||||
|
||||
#define COFFEE_ERASE(sector) \
|
||||
xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE)
|
||||
|
||||
/* Coffee types. */
|
||||
typedef int16_t coffee_page_t;
|
||||
|
||||
#endif /* !COFFEE_ARCH_H */
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Device driver for the MX25R8035F 1Mbyte external memory.
|
||||
* \author
|
||||
* Dongda Lee <dongdongbhbh@gmail.com>
|
||||
*
|
||||
* Data is written bit inverted (~-operator) to flash so that
|
||||
* unwritten data will read as zeros (UNIX style).
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "ext-flash.h"
|
||||
#include "dev/xmem.h"
|
||||
#include "dev/watchdog.h"
|
||||
#include "cfs-coffee-arch.h"
|
||||
#include <stdio.h> /* For PRINTF() */
|
||||
|
||||
#define EXT_ERASE_UNIT_SIZE 4096UL
|
||||
|
||||
#define XMEM_BUFF_LENGHT 128
|
||||
|
||||
|
||||
#if 0
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
xmem_init(void)
|
||||
{
|
||||
ext_flash_open();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
xmem_pread(void *_p, int size, unsigned long addr)
|
||||
{
|
||||
int rv;
|
||||
uint8_t x;
|
||||
int i;
|
||||
|
||||
rv = ext_flash_open();
|
||||
|
||||
if(!rv) {
|
||||
PRINTF("Could not open flash to save config\n");
|
||||
ext_flash_close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = ext_flash_read(addr, size, _p);
|
||||
for (i = 0; i < size; i++){
|
||||
x = ~*((uint8_t *)_p + i);
|
||||
*((uint8_t *)_p+i) = x;
|
||||
}
|
||||
|
||||
ext_flash_close();
|
||||
|
||||
if(rv)
|
||||
return size;
|
||||
|
||||
PRINTF("Could not read flash memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
xmem_pwrite(const void *_buf, int size, unsigned long addr)
|
||||
{
|
||||
int rv;
|
||||
int i, j;
|
||||
int remain;
|
||||
|
||||
uint8_t tmp_buf[XMEM_BUFF_LENGHT];
|
||||
|
||||
rv = ext_flash_open();
|
||||
|
||||
if(!rv) {
|
||||
PRINTF("Could not open flash to save config!\n");
|
||||
ext_flash_close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (remain = size, j = 0; remain > 0; remain -= XMEM_BUFF_LENGHT, j += XMEM_BUFF_LENGHT) {
|
||||
int to_write = MIN(XMEM_BUFF_LENGHT, remain);
|
||||
for (i = 0; i < to_write; i++) {
|
||||
tmp_buf[i] = ~*((uint8_t *)_buf + j + i);
|
||||
}
|
||||
rv = ext_flash_write(addr + j, to_write, tmp_buf);
|
||||
if (!rv) {
|
||||
PRINTF("Could not write flash memory!\n");
|
||||
return size - remain;
|
||||
}
|
||||
}
|
||||
|
||||
ext_flash_close();
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
xmem_erase(long size, unsigned long addr)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = ext_flash_open();
|
||||
|
||||
|
||||
if(!rv) {
|
||||
PRINTF("Could not open flash to save config\n");
|
||||
ext_flash_close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(size % EXT_ERASE_UNIT_SIZE != 0) {
|
||||
PRINTF("xmem_erase: bad size\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(addr % EXT_ERASE_UNIT_SIZE != 0) {
|
||||
PRINTF("xmem_erase: bad offset\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = ext_flash_erase(addr, size);
|
||||
|
||||
ext_flash_close();
|
||||
|
||||
watchdog_periodic();
|
||||
|
||||
if(rv)
|
||||
return size;
|
||||
|
||||
PRINTF("Could not erase flash memory\n");
|
||||
return -1;
|
||||
}
|
|
@ -38,6 +38,7 @@
|
|||
#define CONTIKI_CONF_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Include Project Specific conf */
|
||||
#ifdef PROJECT_CONF_PATH
|
||||
|
@ -58,6 +59,7 @@
|
|||
|
||||
/* Notify various examples that we have Buttons */
|
||||
#define PLATFORM_HAS_BUTTON 1
|
||||
#define PLATFORM_SUPPORTS_BUTTON_HAL 1
|
||||
|
||||
/*
|
||||
* Override button symbols from dev/button-sensor.h, for the examples that
|
||||
|
|
|
@ -2,7 +2,7 @@ CFLAGS += -DBOARD_LAUNCHPAD=1
|
|||
|
||||
CONTIKI_TARGET_DIRS += launchpad common
|
||||
|
||||
BOARD_SOURCEFILES += board.c launchpad-sensors.c leds-arch.c button-sensor.c
|
||||
BOARD_SOURCEFILES += board.c board-buttons.c xmem.c
|
||||
BOARD_SOURCEFILES += ext-flash.c board-spi.c
|
||||
|
||||
### Signal that we can be programmed with cc2538-bsl
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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 launchpad-cc26xx-peripherals
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Defines CC13xx/CC26xx Launchpad buttons for use with the button HAL
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/button-hal.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_LEFT, \
|
||||
true);
|
||||
|
||||
BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_RIGHT, \
|
||||
true);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_left, &key_right);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -48,6 +48,8 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#include "ext-flash.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BOARD_CONF_HAS_SENSORS 0
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* BOARD_PERIPHERALS_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "lpm.h"
|
||||
#include "ti-lib.h"
|
||||
#include "board-peripherals.h"
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup launchpad-button-sensor
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for LaunchPad buttons
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "launchpad/button-sensor.h"
|
||||
#include "gpio-interrupt.h"
|
||||
#include "sys/timer.h"
|
||||
#include "lpm.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef BUTTON_SENSOR_CONF_ENABLE_SHUTDOWN
|
||||
#define BUTTON_SENSOR_ENABLE_SHUTDOWN BUTTON_SENSOR_CONF_ENABLE_SHUTDOWN
|
||||
#else
|
||||
#define BUTTON_SENSOR_ENABLE_SHUTDOWN 1
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BUTTON_GPIO_CFG (IOC_CURRENT_2MA | IOC_STRENGTH_AUTO | \
|
||||
IOC_IOPULL_UP | IOC_SLEW_DISABLE | \
|
||||
IOC_HYST_DISABLE | IOC_BOTH_EDGES | \
|
||||
IOC_INT_ENABLE | IOC_IOMODE_NORMAL | \
|
||||
IOC_NO_WAKE_UP | IOC_INPUT_ENABLE)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define DEBOUNCE_DURATION (CLOCK_SECOND >> 5)
|
||||
|
||||
struct btn_timer {
|
||||
struct timer debounce;
|
||||
clock_time_t start;
|
||||
clock_time_t duration;
|
||||
};
|
||||
|
||||
static struct btn_timer left_timer, right_timer;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
button_press_handler(uint8_t ioid)
|
||||
{
|
||||
if(ioid == BOARD_IOID_KEY_LEFT) {
|
||||
if(!timer_expired(&left_timer.debounce)) {
|
||||
return;
|
||||
}
|
||||
|
||||
timer_set(&left_timer.debounce, DEBOUNCE_DURATION);
|
||||
|
||||
/*
|
||||
* Start press duration counter on press (falling), notify on release
|
||||
* (rising)
|
||||
*/
|
||||
if(ti_lib_gpio_read_dio(BOARD_IOID_KEY_LEFT) == 0) {
|
||||
left_timer.start = clock_time();
|
||||
left_timer.duration = 0;
|
||||
} else {
|
||||
left_timer.duration = clock_time() - left_timer.start;
|
||||
sensors_changed(&button_left_sensor);
|
||||
}
|
||||
}
|
||||
|
||||
if(ioid == BOARD_IOID_KEY_RIGHT) {
|
||||
if(BUTTON_SENSOR_ENABLE_SHUTDOWN == 0) {
|
||||
if(!timer_expired(&right_timer.debounce)) {
|
||||
return;
|
||||
}
|
||||
|
||||
timer_set(&right_timer.debounce, DEBOUNCE_DURATION);
|
||||
|
||||
/*
|
||||
* Start press duration counter on press (falling), notify on release
|
||||
* (rising)
|
||||
*/
|
||||
if(ti_lib_gpio_read_dio(BOARD_IOID_KEY_RIGHT) == 0) {
|
||||
right_timer.start = clock_time();
|
||||
right_timer.duration = 0;
|
||||
} else {
|
||||
right_timer.duration = clock_time() - right_timer.start;
|
||||
sensors_changed(&button_right_sensor);
|
||||
}
|
||||
} else {
|
||||
lpm_shutdown(BOARD_IOID_KEY_RIGHT, IOC_IOPULL_UP, IOC_WAKE_ON_LOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
config_buttons(int type, int c, uint32_t key)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_HW_INIT:
|
||||
ti_lib_gpio_clear_event_dio(key);
|
||||
ti_lib_rom_ioc_pin_type_gpio_input(key);
|
||||
ti_lib_rom_ioc_port_configure_set(key, IOC_PORT_GPIO, BUTTON_GPIO_CFG);
|
||||
gpio_interrupt_register_handler(key, button_press_handler);
|
||||
break;
|
||||
case SENSORS_ACTIVE:
|
||||
if(c) {
|
||||
ti_lib_gpio_clear_event_dio(key);
|
||||
ti_lib_rom_ioc_pin_type_gpio_input(key);
|
||||
ti_lib_rom_ioc_port_configure_set(key, IOC_PORT_GPIO, BUTTON_GPIO_CFG);
|
||||
ti_lib_rom_ioc_int_enable(key);
|
||||
} else {
|
||||
ti_lib_rom_ioc_int_disable(key);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
config_left(int type, int value)
|
||||
{
|
||||
config_buttons(type, value, BOARD_IOID_KEY_LEFT);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
config_right(int type, int value)
|
||||
{
|
||||
config_buttons(type, value, BOARD_IOID_KEY_RIGHT);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type, uint32_t key_io_id)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
case SENSORS_READY:
|
||||
if(ti_lib_rom_ioc_port_configure_get(key_io_id) & IOC_INT_ENABLE) {
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value_left(int type)
|
||||
{
|
||||
if(type == BUTTON_SENSOR_VALUE_STATE) {
|
||||
return ti_lib_gpio_read_dio(BOARD_IOID_KEY_LEFT) == 0 ?
|
||||
BUTTON_SENSOR_VALUE_PRESSED : BUTTON_SENSOR_VALUE_RELEASED;
|
||||
} else if(type == BUTTON_SENSOR_VALUE_DURATION) {
|
||||
return (int)left_timer.duration;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value_right(int type)
|
||||
{
|
||||
if(type == BUTTON_SENSOR_VALUE_STATE) {
|
||||
return ti_lib_gpio_read_dio(BOARD_IOID_KEY_RIGHT) == 0 ?
|
||||
BUTTON_SENSOR_VALUE_PRESSED : BUTTON_SENSOR_VALUE_RELEASED;
|
||||
} else if(type == BUTTON_SENSOR_VALUE_DURATION) {
|
||||
return (int)right_timer.duration;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status_left(int type)
|
||||
{
|
||||
return status(type, BOARD_IOID_KEY_LEFT);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status_right(int type)
|
||||
{
|
||||
return status(type, BOARD_IOID_KEY_RIGHT);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_left_sensor, BUTTON_SENSOR, value_left, config_left,
|
||||
status_left);
|
||||
SENSORS_SENSOR(button_right_sensor, BUTTON_SENSOR, value_right, config_right,
|
||||
status_right);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue