Merge branch 'develop' into feature/ipv6_over_ble

This commit is contained in:
George Oikonomou 2018-03-12 08:52:25 +00:00 committed by GitHub
commit c250cf93b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
544 changed files with 16114 additions and 16727 deletions

2
.gitignore vendored
View File

@ -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

6
.gitmodules vendored
View File

@ -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

View File

@ -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'

View File

@ -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.

View File

@ -52,9 +52,15 @@ 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)}}
@ -145,7 +151,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
@ -153,19 +159,18 @@ 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
MODULEDIRS = $(MODULES_REL) ${wildcard ${addprefix $(CONTIKI)/, $(MODULES)}}
@ -220,6 +225,7 @@ SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) $(CONTIKI_ARCH_DIRS)
vpath %.c $(SOURCEDIRS)
vpath %.S $(SOURCEDIRS)
vpath %.s $(SOURCEDIRS)
CFLAGS += ${addprefix -I,$(SOURCEDIRS) $(CONTIKI)}
@ -274,6 +280,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
@ -366,6 +375,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 "------------------------------------------------"

View File

@ -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

View File

@ -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
*

View File

@ -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;

View File

@ -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__ */

View File

@ -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

View File

@ -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_ */
/*---------------------------------------------------------------------------*/

View File

@ -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;

View File

@ -0,0 +1,196 @@
/*
* 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);
}
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);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -1,17 +1,16 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* 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.
@ -29,73 +28,59 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup zoul
* \addtogroup cc2538
* @{
*
* \defgroup remote-revb-leds RE-Mote revision B arch LED
* \defgroup cc2538-gpio-hal CC2538 GPIO HAL implementation
*
* LED driver implementation for the RE-Mote revision B
* @{
*
* \file
* LED driver implementation for the RE-Mote revision B
* 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 "reg.h"
#include "dev/leds.h"
#include "dev/gpio.h"
#include "dev/ioc.h"
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#define LEDS_PORTB_PIN_MASK (LEDS_GREEN_PIN_MASK | LEDS_BLUE_PIN_MASK)
#define PIN_TO_PORT(pin) (pin >> 3)
#define PIN_TO_PORT_BASE(pin) GPIO_PORT_TO_BASE(PIN_TO_PORT(pin))
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
/* Initialize LED2 (Green) and LED3 (Blue) */
GPIO_SOFTWARE_CONTROL(GPIO_B_BASE, LEDS_PORTB_PIN_MASK);
GPIO_SET_OUTPUT(GPIO_B_BASE, LEDS_PORTB_PIN_MASK);
GPIO_CLR_PIN(GPIO_B_BASE, LEDS_PORTB_PIN_MASK);
#define gpio_hal_arch_interrupt_enable(p) \
GPIO_ENABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
/* Initialize LED1 (Red) */
GPIO_SOFTWARE_CONTROL(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
GPIO_SET_OUTPUT(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
GPIO_CLR_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
}
#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)
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
uint8_t mask_leds;
mask_leds = GPIO_READ_PIN(LEDS_GREEN_PORT_BASE, LEDS_GREEN_PIN_MASK) == 0 ? 0: LEDS_GREEN;
mask_leds |= GPIO_READ_PIN(LEDS_BLUE_PORT_BASE, LEDS_BLUE_PIN_MASK) == 0 ? 0 : LEDS_BLUE;
mask_leds |= GPIO_READ_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK) == 0 ? 0 : LEDS_RED;
return mask_leds;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
if(leds & LEDS_GREEN) {
GPIO_SET_PIN(LEDS_GREEN_PORT_BASE, LEDS_GREEN_PIN_MASK);
} else {
GPIO_CLR_PIN(LEDS_GREEN_PORT_BASE, LEDS_GREEN_PIN_MASK);
}
if(leds & LEDS_BLUE) {
GPIO_SET_PIN(LEDS_BLUE_PORT_BASE, LEDS_BLUE_PIN_MASK);
} else {
GPIO_CLR_PIN(LEDS_BLUE_PORT_BASE, LEDS_BLUE_PIN_MASK);
}
if(leds & LEDS_RED) {
GPIO_SET_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
} else {
GPIO_CLR_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
}
}
#endif /* GPIO_HAL_ARCH_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}

View File

@ -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));
}
/** @} */

View File

@ -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_ */
/**

View File

@ -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)
{

View File

@ -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)

View File

@ -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();
}
/*----------------------------------------------------------------------------*/
/** @} */

View File

@ -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;
/** @} */

View File

@ -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__ */

View File

@ -32,7 +32,7 @@ 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

View File

@ -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_ */
/*---------------------------------------------------------------------------*/

View File

@ -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;

View File

@ -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"

View File

@ -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);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -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_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -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);
}
}
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
/*----------------------------------------------------------------------------*/
/** @} */

View File

@ -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_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -6,7 +6,7 @@ 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
@ -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

View File

@ -41,6 +41,7 @@
#include <stdint.h>
#include <string.h>
#include <inttypes.h>
/*---------------------------------------------------------------------------*/
/* Include Project Specific conf */
#ifdef PROJECT_CONF_PATH

View File

@ -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

View File

@ -88,15 +88,8 @@ config(uint32_t port_base, uint32_t 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)
button_press_handler(gpio_hal_pin_mask_t pin_mask)
{
if(!timer_expired(&debouncetimer)) {
return;
@ -104,19 +97,39 @@ btn_callback(uint8_t port, uint8_t pin)
timer_set(&debouncetimer, CLOCK_SECOND / 8);
if((port == BUTTON_SELECT_PORT) && (pin == BUTTON_SELECT_PIN)) {
if(pin_mask &
(gpio_hal_pin_to_mask(BUTTON_SELECT_PIN) << (BUTTON_SELECT_PORT << 3))) {
sensors_changed(&button_select_sensor);
} else if((port == BUTTON_LEFT_PORT) && (pin == BUTTON_LEFT_PIN)) {
} else if(pin_mask &
(gpio_hal_pin_to_mask(BUTTON_LEFT_PIN) << (BUTTON_LEFT_PORT << 3))) {
sensors_changed(&button_left_sensor);
} else if((port == BUTTON_RIGHT_PORT) && (pin == BUTTON_RIGHT_PIN)) {
} else if(pin_mask &
(gpio_hal_pin_to_mask(BUTTON_RIGHT_PIN) << (BUTTON_RIGHT_PORT << 3))) {
sensors_changed(&button_right_sensor);
} else if((port == BUTTON_UP_PORT) && (pin == BUTTON_UP_PIN)) {
} else if(pin_mask &
(gpio_hal_pin_to_mask(BUTTON_UP_PIN) << (BUTTON_UP_PORT << 3))) {
sensors_changed(&button_up_sensor);
} else if((port == BUTTON_DOWN_PORT) && (pin == BUTTON_DOWN_PIN)) {
} else if(pin_mask &
(gpio_hal_pin_to_mask(BUTTON_DOWN_PIN) << (BUTTON_DOWN_PORT << 3))) {
sensors_changed(&button_down_sensor);
}
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t press_handler = {
.next = NULL,
.handler = button_press_handler,
.pin_mask = 0,
};
/*---------------------------------------------------------------------------*/
static void
register_btn_callback(uint8_t port_num, uint8_t pin)
{
press_handler.pin_mask |=
gpio_hal_pin_to_mask(pin) << (port_num << 3);
gpio_hal_register_handler(&press_handler);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Init function for the select button.
*
@ -137,7 +150,7 @@ config_select(int type, int value)
NVIC_EnableIRQ(BUTTON_SELECT_VECTOR);
gpio_register_callback(btn_callback, BUTTON_SELECT_PORT, BUTTON_SELECT_PIN);
register_btn_callback(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN);
return 1;
}
/*---------------------------------------------------------------------------*/
@ -161,7 +174,7 @@ config_left(int type, int value)
NVIC_EnableIRQ(BUTTON_LEFT_VECTOR);
gpio_register_callback(btn_callback, BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
register_btn_callback(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
return 1;
}
/*---------------------------------------------------------------------------*/
@ -185,7 +198,7 @@ config_right(int type, int value)
NVIC_EnableIRQ(BUTTON_RIGHT_VECTOR);
gpio_register_callback(btn_callback, BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN);
register_btn_callback(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN);
return 1;
}
/*---------------------------------------------------------------------------*/
@ -209,7 +222,7 @@ config_up(int type, int value)
NVIC_EnableIRQ(BUTTON_UP_VECTOR);
gpio_register_callback(btn_callback, BUTTON_UP_PORT, BUTTON_UP_PIN);
register_btn_callback(BUTTON_UP_PORT, BUTTON_UP_PIN);
return 1;
}
/*---------------------------------------------------------------------------*/
@ -233,7 +246,7 @@ config_down(int type, int value)
NVIC_EnableIRQ(BUTTON_DOWN_VECTOR);
gpio_register_callback(btn_callback, BUTTON_DOWN_PORT, BUTTON_DOWN_PIN);
register_btn_callback(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN);
return 1;
}
/*---------------------------------------------------------------------------*/

View File

@ -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
};
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -74,7 +74,7 @@
#define LOG_LEVEL LOG_LEVEL_MAIN
/*---------------------------------------------------------------------------*/
static void
fade(unsigned char l)
fade(leds_mask_t l)
{
volatile int i;
int k, j;

View File

@ -40,9 +40,6 @@ ARCHIVE = $(OBJECTDIR)/$(LIBNAME).a
JNILIB = $(OBJECTDIR)/$(LIBNAME).$(TARGET)
CONTIKI_APP_OBJ = $(CONTIKI_APP).o
# Modules
MODULES += os/net os/net/mac os/net/mac/framer
### COOJA platform sources
COOJA = $(CONTIKI)/arch/platform/$(TARGET)
CONTIKI_TARGET_DIRS = . dev lib sys cfs net

View File

@ -46,6 +46,8 @@
#define COOJA 1
#define LEDS_CONF_LEGACY_API 1
#ifndef EEPROM_CONF_SIZE
#define EEPROM_CONF_SIZE 1024
#endif
@ -98,9 +100,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;

View File

@ -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;
}

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -33,5 +33,3 @@ MAKE_MAC ?= MAKE_MAC_NULLMAC
### 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

View File

@ -58,9 +58,6 @@ 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;
@ -69,6 +66,8 @@ typedef int32_t s32_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

View File

@ -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;
}

View File

@ -111,7 +111,12 @@
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 */
@ -177,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;
@ -253,6 +258,7 @@ void
platform_init_stage_two()
{
set_lladdr();
serial_line_init();
}
/*---------------------------------------------------------------------------*/
void

View File

@ -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

View File

@ -41,6 +41,7 @@
#define CONTIKI_CONF_H
#include <stdint.h>
#include <inttypes.h>
/*---------------------------------------------------------------------------*/
/* Include Project Specific conf */
#ifdef PROJECT_CONF_PATH

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -50,6 +50,7 @@
#include <stdint.h>
#include <string.h>
#include <inttypes.h>
/*---------------------------------------------------------------------------*/
/* Include Project Specific conf */
#ifdef PROJECT_CONF_PATH

View File

@ -95,15 +95,8 @@ value(int type)
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)
button_press_handler(gpio_hal_pin_mask_t pin_mask)
{
if(!timer_expired(&debouncetimer)) {
return;
@ -124,6 +117,12 @@ btn_callback(uint8_t port, uint8_t pin)
sensors_changed(&button_sensor);
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t press_handler = {
.next = NULL,
.handler = button_press_handler,
.pin_mask = gpio_hal_pin_to_mask(BUTTON_USER_PIN) << (BUTTON_USER_PORT << 3),
};
/*---------------------------------------------------------------------------*/
/**
* \brief Init function for the User button.
* \param type SENSORS_ACTIVE: Activate / Deactivate the sensor (value == 1
@ -153,7 +152,7 @@ config_user(int type, int value)
ioc_set_over(BUTTON_USER_PORT, BUTTON_USER_PIN, IOC_OVERRIDE_PUE);
gpio_register_callback(btn_callback, BUTTON_USER_PORT, BUTTON_USER_PIN);
gpio_hal_register_handler(&press_handler);
break;
case SENSORS_ACTIVE:
if(value) {

View File

@ -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);
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -82,7 +82,7 @@
void board_init(void);
/*---------------------------------------------------------------------------*/
static void
fade(unsigned char l)
fade(leds_mask_t l)
{
volatile int i;
int k, j;

View File

@ -6,6 +6,4 @@ CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c \
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

View File

@ -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

View File

@ -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

View File

@ -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 */

View File

@ -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;
}

View File

@ -38,6 +38,7 @@
#define CONTIKI_CONF_H
#include <stdint.h>
#include <inttypes.h>
/*---------------------------------------------------------------------------*/
/* Include Project Specific conf */
#ifdef PROJECT_CONF_PATH

View File

@ -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 launchpad-sensors.c button-sensor.c xmem.c
BOARD_SOURCEFILES += ext-flash.c board-spi.c
### Signal that we can be programmed with cc2538-bsl

View File

@ -39,7 +39,7 @@
#include "contiki.h"
#include "lib/sensors.h"
#include "launchpad/button-sensor.h"
#include "gpio-interrupt.h"
#include "gpio-hal.h"
#include "sys/timer.h"
#include "lpm.h"
@ -70,9 +70,9 @@ struct btn_timer {
static struct btn_timer left_timer, right_timer;
/*---------------------------------------------------------------------------*/
static void
button_press_handler(uint8_t ioid)
button_press_handler(gpio_hal_pin_mask_t pin_mask)
{
if(ioid == BOARD_IOID_KEY_LEFT) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_LEFT)) {
if(!timer_expired(&left_timer.debounce)) {
return;
}
@ -92,7 +92,7 @@ button_press_handler(uint8_t ioid)
}
}
if(ioid == BOARD_IOID_KEY_RIGHT) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_RIGHT)) {
if(BUTTON_SENSOR_ENABLE_SHUTDOWN == 0) {
if(!timer_expired(&right_timer.debounce)) {
return;
@ -117,6 +117,12 @@ button_press_handler(uint8_t ioid)
}
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t press_handler = {
.next = NULL,
.handler = button_press_handler,
.pin_mask = 0,
};
/*---------------------------------------------------------------------------*/
static void
config_buttons(int type, int c, uint32_t key)
{
@ -125,7 +131,8 @@ config_buttons(int type, int c, uint32_t key)
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);
press_handler.pin_mask |= gpio_hal_pin_to_mask(key);
gpio_hal_register_handler(&press_handler);
break;
case SENSORS_ACTIVE:
if(c) {

View File

@ -55,20 +55,14 @@
#include "ioc.h"
/*---------------------------------------------------------------------------*/
/**
* \name LED configurations
* \name LED HAL configuration
*
* Those values are not meant to be modified by the user
* @{
*/
#define LEDS_RED 1
#define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN
#define LEDS_ORANGE LEDS_RED
#define LEDS_CONF_ALL 3
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 2
#define LEDS_CONF_RED 1
#define LEDS_CONF_YELLOW 2
/** @} */
/*---------------------------------------------------------------------------*/
/**
@ -79,9 +73,6 @@
*/
#define BOARD_IOID_LED_1 IOID_6
#define BOARD_IOID_LED_2 IOID_7
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -55,20 +55,14 @@
#include "ioc.h"
/*---------------------------------------------------------------------------*/
/**
* \name LED configurations
* \name LED HAL configuration
*
* Those values are not meant to be modified by the user
* @{
*/
#define LEDS_RED 1
#define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN
#define LEDS_ORANGE LEDS_RED
#define LEDS_CONF_ALL 3
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 2
#define LEDS_CONF_RED 1
#define LEDS_CONF_YELLOW 2
/** @} */
/*---------------------------------------------------------------------------*/
/**
@ -79,9 +73,6 @@
*/
#define BOARD_IOID_LED_1 IOID_6
#define BOARD_IOID_LED_2 IOID_7
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -55,20 +55,14 @@
#include "ioc.h"
/*---------------------------------------------------------------------------*/
/**
* \name LED configurations
* \name LED HAL configuration
*
* Those values are not meant to be modified by the user
* @{
*/
#define LEDS_RED 1
#define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN
#define LEDS_ORANGE LEDS_RED
#define LEDS_CONF_ALL 3
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 2
#define LEDS_CONF_RED 1
#define LEDS_CONF_YELLOW 2
/** @} */
/*---------------------------------------------------------------------------*/
/**
@ -79,9 +73,6 @@
*/
#define BOARD_IOID_LED_1 IOID_6
#define BOARD_IOID_LED_2 IOID_7
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -1,10 +1,11 @@
/*
* Copyright (c) 2015, 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
@ -28,54 +29,17 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup launchpad-peripherals
* @{
*
* \file
* Driver for LaunchPad LEDs
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/leds.h"
#include "dev/gpio-hal.h"
#include "ti-lib.h"
/*---------------------------------------------------------------------------*/
static unsigned char c;
static int inited = 0;
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
if(inited) {
return;
}
inited = 1;
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_2);
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
return c;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
c = leds;
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
if((leds & LEDS_RED) == LEDS_RED) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
}
if((leds & LEDS_YELLOW) == LEDS_YELLOW) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_2);
}
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -47,15 +47,16 @@
#include "ti-lib.h"
#include "contiki.h"
#include "contiki-net.h"
#include "leds.h"
#include "lpm.h"
#include "gpio-interrupt.h"
#include "dev/leds.h"
#include "dev/gpio-hal.h"
#include "dev/oscillators.h"
#include "ieee-addr.h"
#include "ble-addr.h"
#include "vims.h"
#include "dev/cc26xx-uart.h"
#include "dev/soc-rtc.h"
#include "dev/serial-line.h"
#include "rf-core/rf-core.h"
#include "sys_ctrl.h"
#include "uart.h"
@ -84,7 +85,7 @@ unsigned short node_id = 0;
void board_init(void);
/*---------------------------------------------------------------------------*/
static void
fade(unsigned char l)
fade(leds_mask_t l)
{
volatile int i;
int k, j;
@ -143,7 +144,7 @@ platform_init_stage_one()
board_init();
gpio_interrupt_init();
gpio_hal_init();
leds_init();
fade(LEDS_RED);
@ -156,6 +157,7 @@ platform_init_stage_one()
*/
ti_lib_pwr_ctrl_io_freeze_disable();
ti_lib_rom_int_enable(INT_AON_GPIO_EDGE);
ti_lib_int_master_enable();
soc_rtc_init();
@ -174,6 +176,10 @@ platform_init_stage_two()
serial_line_init();
#if BUILD_WITH_SHELL
cc26xx_uart_set_input(serial_line_input_byte);
#endif
/* Populate linkaddr_node_addr */
#if MAKE_MAC == MAKE_MAC_BLE
uint8_t ext_addr[8];

View File

@ -5,6 +5,6 @@ CONTIKI_TARGET_DIRS += sensortag common
BOARD_SOURCEFILES += sensortag-sensors.c sensor-common.c
BOARD_SOURCEFILES += bmp-280-sensor.c tmp-007-sensor.c opt-3001-sensor.c
BOARD_SOURCEFILES += hdc-1000-sensor.c mpu-9250-sensor.c button-sensor.c
BOARD_SOURCEFILES += hdc-1000-sensor.c mpu-9250-sensor.c button-sensor.c xmem.c
BOARD_SOURCEFILES += reed-relay.c ext-flash.c buzzer.c
BOARD_SOURCEFILES += board.c board-spi.c board-i2c.c

View File

@ -39,7 +39,7 @@
#include "contiki.h"
#include "lib/sensors.h"
#include "sensortag/button-sensor.h"
#include "gpio-interrupt.h"
#include "gpio-hal.h"
#include "sys/timer.h"
#include "lpm.h"
@ -73,9 +73,9 @@ static struct btn_timer left_timer, right_timer;
* \brief Handler for Sensortag-CC26XX button presses
*/
static void
button_press_handler(uint8_t ioid)
button_press_handler(gpio_hal_pin_mask_t pin_mask)
{
if(ioid == BOARD_IOID_KEY_LEFT) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_LEFT)) {
if(!timer_expired(&left_timer.debounce)) {
return;
}
@ -95,7 +95,7 @@ button_press_handler(uint8_t ioid)
}
}
if(ioid == BOARD_IOID_KEY_RIGHT) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_RIGHT)) {
if(BUTTON_SENSOR_ENABLE_SHUTDOWN == 0) {
if(!timer_expired(&right_timer.debounce)) {
return;
@ -120,6 +120,12 @@ button_press_handler(uint8_t ioid)
}
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t press_handler = {
.next = NULL,
.handler = button_press_handler,
.pin_mask = 0,
};
/*---------------------------------------------------------------------------*/
/**
* \brief Configuration function for the button sensor for all buttons.
*
@ -135,7 +141,8 @@ config_buttons(int type, int c, uint32_t key)
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);
press_handler.pin_mask |= gpio_hal_pin_to_mask(key);
gpio_hal_register_handler(&press_handler);
break;
case SENSORS_ACTIVE:
if(c) {

View File

@ -1,6 +1,3 @@
### Add to the source list
BOARD_SOURCEFILES += leds-arch.c
### Will allow the inclusion of the correct CPU makefile
CPU_FAMILY = cc13xx

View File

@ -58,20 +58,13 @@
#include "ioc.h"
/*---------------------------------------------------------------------------*/
/**
* \name LED configurations
* \name LED HAL configuration
*
* Those values are not meant to be modified by the user
* @{
*/
#define LEDS_RED 1
#define LEDS_GREEN LEDS_RED
#define LEDS_YELLOW LEDS_RED
#define LEDS_ORANGE LEDS_RED
#define LEDS_CONF_ALL 1
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 1
#define LEDS_CONF_RED 1
/** @} */
/*---------------------------------------------------------------------------*/
/**
@ -81,8 +74,6 @@
* @{
*/
#define BOARD_IOID_LED_1 IOID_10
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
#define BOARD_LED_ALL BOARD_LED_1
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -1,10 +1,11 @@
/*
* Copyright (c) 2014, 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
@ -28,50 +29,15 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup sensortag-cc13xx-peripherals
* @{
*
* \file
* Driver for the Sensortag-CC1350 LEDs
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/leds.h"
#include "dev/gpio-hal.h"
#include "ti-lib.h"
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
static unsigned char c;
static int inited = 0;
const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
if(inited) {
return;
}
inited = 1;
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
return c;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
c = leds;
ti_lib_gpio_clear_dio(BOARD_IOID_LED_1);
if((leds & LEDS_RED) == LEDS_RED) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
}
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -1,6 +1,3 @@
### Add to the source list
BOARD_SOURCEFILES += leds-arch.c
### Will allow the inclusion of the correct CPU makefile
CPU_FAMILY = cc26xx

View File

@ -58,20 +58,14 @@
#include "ioc.h"
/*---------------------------------------------------------------------------*/
/**
* \name LED configurations
* \name LED HAL configuration
*
* Those values are not meant to be modified by the user
* @{
*/
#define LEDS_RED 1
#define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN
#define LEDS_ORANGE LEDS_RED
#define LEDS_CONF_ALL 3
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 2
#define LEDS_CONF_RED 1
#define LEDS_CONF_GREEN 2
/** @} */
/*---------------------------------------------------------------------------*/
/**
@ -82,9 +76,6 @@
*/
#define BOARD_IOID_LED_1 IOID_10
#define BOARD_IOID_LED_2 IOID_15
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -1,10 +1,11 @@
/*
* Copyright (c) 2014, 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
@ -28,54 +29,16 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup sensortag-cc26xx-peripherals
* @{
*
* \file
* Driver for the Sensortag-CC26XX LEDs
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/leds.h"
#include "dev/gpio-hal.h"
#include "ti-lib.h"
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
static unsigned char c;
static int inited = 0;
const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
if(inited) {
return;
}
inited = 1;
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_2);
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
return c;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
c = leds;
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
if((leds & LEDS_RED) == LEDS_RED) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
}
if((leds & LEDS_YELLOW) == LEDS_YELLOW) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_2);
}
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -39,9 +39,9 @@
#include "contiki.h"
#include "sys/clock.h"
#include "sys/timer.h"
#include "dev/gpio-hal.h"
#include "lib/sensors.h"
#include "sensortag/reed-relay.h"
#include "gpio-interrupt.h"
#include "sys/timer.h"
#include "ti-lib.h"
@ -60,7 +60,7 @@ static struct timer debouncetimer;
* \brief Handler for Sensortag-CC26XX reed interrupts
*/
static void
reed_interrupt_handler(uint8_t ioid)
reed_interrupt_handler(gpio_hal_pin_mask_t pin_mask)
{
if(!timer_expired(&debouncetimer)) {
return;
@ -76,6 +76,12 @@ value(int type)
return (int)ti_lib_gpio_read_dio(BOARD_IOID_REED_RELAY);
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t event_handler = {
.next = NULL,
.handler = reed_interrupt_handler,
.pin_mask = gpio_hal_pin_to_mask(BOARD_IOID_REED_RELAY),
};
/*---------------------------------------------------------------------------*/
/**
* \brief Configuration function for the button sensor for all buttons.
*
@ -99,8 +105,7 @@ configure(int type, int value)
ti_lib_ioc_port_configure_set(BOARD_IOID_REED_RELAY, IOC_PORT_GPIO,
REED_IO_CFG);
gpio_interrupt_register_handler(BOARD_IOID_REED_RELAY,
reed_interrupt_handler);
gpio_hal_register_handler(&event_handler);
break;
case SENSORS_ACTIVE:
if(value) {

View File

@ -2,7 +2,7 @@ CFLAGS += -DBOARD_SMARTRF06EB=1
CONTIKI_TARGET_DIRS += srf06
BOARD_SOURCEFILES += leds-arch.c srf06-sensors.c button-sensor.c board.c
BOARD_SOURCEFILES += srf06-sensors.c button-sensor.c board.c
BOARD_SOURCEFILES += als-sensor.c
### Signal that we can be programmed with cc2538-bsl

View File

@ -39,7 +39,7 @@
#include "contiki.h"
#include "lib/sensors.h"
#include "srf06/button-sensor.h"
#include "gpio-interrupt.h"
#include "gpio-hal.h"
#include "sys/timer.h"
#include "lpm.h"
@ -74,9 +74,9 @@ static struct btn_timer sel_timer, left_timer, right_timer, up_timer,
* \brief Handler for SmartRF button presses
*/
static void
button_press_handler(uint8_t ioid)
button_press_handler(gpio_hal_pin_mask_t pin_mask)
{
if(ioid == BOARD_IOID_KEY_SELECT) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_SELECT)) {
if(!timer_expired(&sel_timer.debounce)) {
return;
}
@ -96,7 +96,7 @@ button_press_handler(uint8_t ioid)
}
}
if(ioid == BOARD_IOID_KEY_LEFT) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_LEFT)) {
if(!timer_expired(&left_timer.debounce)) {
return;
}
@ -116,7 +116,7 @@ button_press_handler(uint8_t ioid)
}
}
if(ioid == BOARD_IOID_KEY_RIGHT) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_RIGHT)) {
if(BUTTON_SENSOR_ENABLE_SHUTDOWN == 0) {
if(!timer_expired(&right_timer.debounce)) {
return;
@ -140,7 +140,7 @@ button_press_handler(uint8_t ioid)
}
}
if(ioid == BOARD_IOID_KEY_UP) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_UP)) {
if(!timer_expired(&up_timer.debounce)) {
return;
}
@ -160,7 +160,7 @@ button_press_handler(uint8_t ioid)
}
}
if(ioid == BOARD_IOID_KEY_DOWN) {
if(pin_mask & gpio_hal_pin_to_mask(BOARD_IOID_KEY_DOWN)) {
if(!timer_expired(&down_timer.debounce)) {
return;
}
@ -181,6 +181,12 @@ button_press_handler(uint8_t ioid)
}
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t press_handler = {
.next = NULL,
.handler = button_press_handler,
.pin_mask = 0,
};
/*---------------------------------------------------------------------------*/
/**
* \brief Configuration function for the button sensor for all buttons.
*
@ -196,7 +202,8 @@ config_buttons(int type, int c, uint32_t key)
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);
press_handler.pin_mask |= gpio_hal_pin_to_mask(key);
gpio_hal_register_handler(&press_handler);
break;
case SENSORS_ACTIVE:
if(c) {

View File

@ -58,20 +58,16 @@
#include "ioc.h"
/*---------------------------------------------------------------------------*/
/**
* \name LED configurations
* \name LED HAL configuration
*
* Those values are not meant to be modified by the user
* @{
*/
#define LEDS_RED 1 /**< LED1 (Red) */
#define LEDS_YELLOW 2 /**< LED2 (Yellow) */
#define LEDS_GREEN 4 /**< LED3 (Green) */
#define LEDS_ORANGE 8 /**< LED4 (Orange) */
#define LEDS_CONF_ALL 15
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 4
#define LEDS_CONF_RED 1
#define LEDS_CONF_YELLOW 2
#define LEDS_CONF_GREEN 4
#define LEDS_CONF_ORANGE 8
/** @} */
/*---------------------------------------------------------------------------*/
/**
@ -84,12 +80,6 @@
#define BOARD_IOID_LED_2 IOID_27
#define BOARD_IOID_LED_3 IOID_7
#define BOARD_IOID_LED_4 IOID_6
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
#define BOARD_LED_3 (1 << BOARD_IOID_LED_3)
#define BOARD_LED_4 (1 << BOARD_IOID_LED_4)
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2 | BOARD_LED_3 | \
BOARD_LED_4)
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -58,20 +58,16 @@
#include "ioc.h"
/*---------------------------------------------------------------------------*/
/**
* \name LED configurations
* \name LED HAL configuration
*
* Those values are not meant to be modified by the user
* @{
*/
#define LEDS_RED 1 /**< LED1 (Red) */
#define LEDS_YELLOW 2 /**< LED2 (Yellow) */
#define LEDS_GREEN 4 /**< LED3 (Green) */
#define LEDS_ORANGE 8 /**< LED4 (Orange) */
#define LEDS_CONF_ALL 15
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 4
#define LEDS_CONF_RED 1
#define LEDS_CONF_YELLOW 2
#define LEDS_CONF_GREEN 4
#define LEDS_CONF_ORANGE 8
/** @} */
/*---------------------------------------------------------------------------*/
/**
@ -84,12 +80,6 @@
#define BOARD_IOID_LED_2 IOID_27
#define BOARD_IOID_LED_3 IOID_7
#define BOARD_IOID_LED_4 IOID_6
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
#define BOARD_LED_3 (1 << BOARD_IOID_LED_3)
#define BOARD_LED_4 (1 << BOARD_IOID_LED_4)
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2 | BOARD_LED_3 | \
BOARD_LED_4)
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -1,10 +1,11 @@
/*
* Copyright (c) 2014, 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
@ -28,63 +29,18 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup srf06-common-peripherals
* @{
*
* \file
* Driver for the SmartRF06EB LEDs when a CC13xx/CC26xx EM is mounted on it
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/leds.h"
#include "ti-lib.h"
/*---------------------------------------------------------------------------*/
static unsigned char c;
static int inited = 0;
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
if(inited) {
return;
}
inited = 1;
#include "dev/gpio-hal.h"
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_2);
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_3);
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_4);
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
}
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
return c;
}
const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
{ .pin = BOARD_IOID_LED_3, .negative_logic = false },
{ .pin = BOARD_IOID_LED_4, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
c = leds;
/* Clear everything */
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
if((leds & LEDS_RED) == LEDS_RED) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
}
if((leds & LEDS_YELLOW) == LEDS_YELLOW) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_2);
}
if((leds & LEDS_GREEN) == LEDS_GREEN) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_3);
}
if((leds & LEDS_ORANGE) == LEDS_ORANGE) {
ti_lib_gpio_set_dio(BOARD_IOID_LED_4);
}
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -31,7 +31,7 @@ PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(BOARD)
### Include
CONTIKI_TARGET_SOURCEFILES += platform.c
CONTIKI_TARGET_SOURCEFILES += platform.c leds-arch.c
CONTIKI_TARGET_SOURCEFILES += leds.c cc1200-zoul-arch.c
CONTIKI_TARGET_SOURCEFILES += adc-zoul.c button-sensor.c zoul-sensors.c
CONTIKI_TARGET_SOURCEFILES += $(BOARD_SOURCEFILES)
@ -44,9 +44,7 @@ CLEAN += *.zoul
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc2538
include $(CONTIKI_CPU)/Makefile.cc2538
MODULES += os/net os/net/mac os/net/mac/framer \
arch/dev/cc1200 \
os/storage/cfs
MODULES += arch/dev/cc1200 arch/dev/rgb-led os/storage/cfs
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py

View File

@ -47,6 +47,7 @@
#include <stdint.h>
#include <string.h>
#include <inttypes.h>
/*---------------------------------------------------------------------------*/
/* Include Project Specific conf */
#ifdef PROJECT_CONF_PATH

View File

@ -40,6 +40,7 @@
#include "contiki.h"
#include "ac-dimmer.h"
#include "dev/gpio.h"
#include "dev/gpio-hal.h"
#include "lib/sensors.h"
#include "dev/ioc.h"
/*---------------------------------------------------------------------------*/
@ -76,13 +77,17 @@ PROCESS_THREAD(ac_dimmer_int_process, ev, data)
}
/*---------------------------------------------------------------------------*/
static void
dimmer_zero_cross_int_handler(uint8_t port, uint8_t pin)
dimmer_zero_cross_int_handler(gpio_hal_pin_mask_t pin_mask)
{
if((port == DIMMER_SYNC_PORT) && (pin == DIMMER_SYNC_PIN)) {
process_poll(&ac_dimmer_int_process);
}
process_poll(&ac_dimmer_int_process);
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t dimmer_handler = {
.next = NULL,
.handler = dimmer_zero_cross_int_handler,
.pin_mask = gpio_hal_pin_to_mask(DIMMER_SYNC_PIN) << (DIMMER_SYNC_PORT << 3),
};
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
@ -128,8 +133,7 @@ configure(int type, int value)
GPIO_DETECT_EDGE(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK);
GPIO_TRIGGER_SINGLE_EDGE(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK);
GPIO_DETECT_RISING(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK);
gpio_register_callback(dimmer_zero_cross_int_handler, DIMMER_SYNC_PORT,
DIMMER_SYNC_PIN);
gpio_hal_register_handler(&dimmer_handler);
/* Spin process until an interrupt is received */
process_start(&ac_dimmer_int_process, NULL);

View File

@ -43,6 +43,7 @@
#include "dev/nvic.h"
#include "dev/ioc.h"
#include "dev/gpio.h"
#include "dev/gpio-hal.h"
#include "dev/button-sensor.h"
#include "sys/timer.h"
#include "sys/ctimer.h"
@ -94,15 +95,8 @@ value(int type)
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)
button_press_handler(gpio_hal_pin_mask_t pin_mask)
{
if(!timer_expired(&debouncetimer)) {
return;
@ -123,6 +117,12 @@ btn_callback(uint8_t port, uint8_t pin)
sensors_changed(&button_sensor);
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t press_handler = {
.next = NULL,
.handler = button_press_handler,
.pin_mask = gpio_hal_pin_to_mask(BUTTON_USER_PIN) << (BUTTON_USER_PORT << 3),
};
/*---------------------------------------------------------------------------*/
/**
* \brief Init function for the User button.
* \param type SENSORS_ACTIVE: Activate / Deactivate the sensor (value == 1
@ -152,7 +152,7 @@ config_user(int type, int value)
ioc_set_over(BUTTON_USER_PORT, BUTTON_USER_PIN, IOC_OVERRIDE_PUE);
gpio_register_callback(btn_callback, BUTTON_USER_PORT, BUTTON_USER_PIN);
gpio_hal_register_handler(&press_handler);
break;
case SENSORS_ACTIVE:
if(value) {

View File

@ -52,6 +52,7 @@
#include "dev/spi.h"
#include "dev/ssi.h"
#include "dev/gpio.h"
#include "dev/gpio-hal.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
#define CC1200_SPI_CLK_PORT_BASE GPIO_PORT_TO_BASE(SPI0_CLK_PORT)
@ -92,7 +93,7 @@
extern int cc1200_rx_interrupt(void);
/*---------------------------------------------------------------------------*/
void
cc1200_int_handler(uint8_t port, uint8_t pin)
cc1200_int_handler(gpio_hal_pin_mask_t pin_mask)
{
/* To keep the gpio_register_callback happy */
cc1200_rx_interrupt();
@ -166,6 +167,14 @@ cc1200_arch_spi_rw(uint8_t *inbuf, const uint8_t *write_buf, uint16_t len)
return 0;
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t interrupt_handler = {
.next = NULL,
.handler = cc1200_int_handler,
.pin_mask =
(gpio_hal_pin_to_mask(CC1200_GDO0_PIN) << (CC1200_GDO0_PORT << 3)) |
(gpio_hal_pin_to_mask(CC1200_GDO2_PIN) << (CC1200_GDO2_PORT << 3))
};
/*---------------------------------------------------------------------------*/
void
cc1200_arch_gpio0_setup_irq(int rising)
{
@ -184,8 +193,7 @@ cc1200_arch_gpio0_setup_irq(int rising)
GPIO_ENABLE_INTERRUPT(CC1200_GDO0_PORT_BASE, CC1200_GDO0_PIN_MASK);
ioc_set_over(CC1200_GDO0_PORT, CC1200_GDO0_PIN, IOC_OVERRIDE_PUE);
NVIC_EnableIRQ(CC1200_GPIOx_VECTOR);
gpio_register_callback(cc1200_int_handler, CC1200_GDO0_PORT,
CC1200_GDO0_PIN);
gpio_hal_register_handler(&interrupt_handler);
}
/*---------------------------------------------------------------------------*/
void
@ -206,8 +214,7 @@ cc1200_arch_gpio2_setup_irq(int rising)
GPIO_ENABLE_INTERRUPT(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK);
ioc_set_over(CC1200_GDO2_PORT, CC1200_GDO2_PIN, IOC_OVERRIDE_PUE);
NVIC_EnableIRQ(CC1200_GPIOx_VECTOR);
gpio_register_callback(cc1200_int_handler, CC1200_GDO2_PORT,
CC1200_GDO2_PIN);
gpio_hal_register_handler(&interrupt_handler);
}
/*---------------------------------------------------------------------------*/
void

View File

@ -44,6 +44,7 @@
#include "contiki.h"
#include "dev/i2c.h"
#include "dev/grove-gyro.h"
#include "dev/gpio-hal.h"
#include "lib/sensors.h"
#include "dev/watchdog.h"
/*---------------------------------------------------------------------------*/
@ -458,11 +459,17 @@ PROCESS_THREAD(grove_gyro_int_process, ev, data)
}
/*---------------------------------------------------------------------------*/
static void
grove_gyro_interrupt_handler(uint8_t port, uint8_t pin)
grove_gyro_interrupt_handler(gpio_hal_pin_mask_t pin_mask)
{
process_poll(&grove_gyro_int_process);
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t gyro_handler = {
.next = NULL,
.handler = grove_gyro_interrupt_handler,
.pin_mask = gpio_hal_pin_to_mask(I2C_INT_PIN) << (I2C_INT_PORT << 3),
};
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
@ -593,8 +600,7 @@ configure(int type, int value)
GPIO_DETECT_EDGE(GROVE_GYRO_INT_PORT_BASE, GROVE_GYRO_INT_PIN_MASK);
GPIO_TRIGGER_SINGLE_EDGE(GROVE_GYRO_INT_PORT_BASE, GROVE_GYRO_INT_PIN_MASK);
GPIO_DETECT_FALLING(GROVE_GYRO_INT_PORT_BASE, GROVE_GYRO_INT_PIN_MASK);
gpio_register_callback(grove_gyro_interrupt_handler, I2C_INT_PORT,
I2C_INT_PIN);
gpio_hal_register_handler(&gyro_handler);
/* Spin process until an interrupt is received */
process_start(&grove_gyro_int_process, NULL);

View File

@ -1,17 +1,16 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* 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.
@ -29,45 +28,27 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup zoul
* @{
*
* \defgroup zoul-leds Zoul LED driver
*
* LED driver implementation for the Zoul-based platforms
* @{
*
* \file
* LED driver implementation for the Zoul-based platforms
*/
/*---------------------------------------------------------------------------*/
#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
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
GPIO_SET_OUTPUT(GPIO_D_BASE, LEDS_GPIO_PIN_MASK);
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
return GPIO_READ_PIN(GPIO_D_BASE, LEDS_GPIO_PIN_MASK);
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
GPIO_WRITE_PIN(GPIO_D_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
},
};
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -47,6 +47,7 @@
#include "lib/sensors.h"
#include "dev/sys-ctrl.h"
#include "dev/gpio.h"
#include "dev/gpio-hal.h"
#include "dev/ioc.h"
/*---------------------------------------------------------------------------*/
#define DEBUG 0
@ -76,11 +77,17 @@ PROCESS_THREAD(motion_int_process, ev, data)
}
/*---------------------------------------------------------------------------*/
static void
motion_interrupt_handler(uint8_t port, uint8_t pin)
motion_interrupt_handler(gpio_hal_pin_mask_t pin_mask)
{
process_poll(&motion_int_process);
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t motion_handler = {
.next = NULL,
.handler = motion_interrupt_handler,
.pin_mask = gpio_hal_pin_to_mask(MOTION_SENSOR_PIN) << (MOTION_SENSOR_PORT << 3),
};
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
@ -113,8 +120,7 @@ configure(int type, int value)
GPIO_DETECT_RISING(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK);
GPIO_TRIGGER_SINGLE_EDGE(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK);
ioc_set_over(MOTION_SENSOR_PORT, MOTION_SENSOR_PIN, IOC_OVERRIDE_DIS);
gpio_register_callback(motion_interrupt_handler, MOTION_SENSOR_PORT,
MOTION_SENSOR_PIN);
gpio_hal_register_handler(&motion_handler);
process_start(&motion_int_process, NULL);

View File

@ -735,7 +735,7 @@ rtcc_print(uint8_t value)
}
/*---------------------------------------------------------------------------*/
static void
rtcc_interrupt_handler(uint8_t port, uint8_t pin)
rtcc_interrupt_handler(gpio_hal_pin_mask_t pin_mask)
{
process_poll(&rtcc_int_process);
}
@ -912,6 +912,12 @@ rtcc_set_calibration(uint8_t mode, int32_t adjust)
return AB08_SUCCESS;
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t rtcc_handler = {
.next = NULL,
.handler = rtcc_interrupt_handler,
.pin_mask = gpio_hal_pin_to_mask(RTC_INT1_PIN) << (RTC_INT1_PORT << 3),
};
/*---------------------------------------------------------------------------*/
int8_t
rtcc_init(void)
{
@ -937,7 +943,7 @@ rtcc_init(void)
GPIO_DETECT_EDGE(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK);
GPIO_TRIGGER_SINGLE_EDGE(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK);
GPIO_DETECT_FALLING(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK);
gpio_register_callback(rtcc_interrupt_handler, RTC_INT1_PORT, RTC_INT1_PIN);
gpio_hal_register_handler(&rtcc_handler);
/* Spin process until an interrupt is received */
process_start(&rtcc_int_process, NULL);

View File

@ -43,6 +43,7 @@
#include "contiki.h"
#include "dev/i2c.h"
#include "dev/gpio.h"
#include "dev/gpio-hal.h"
#include "dev/zoul-sensors.h"
#include "lib/sensors.h"
#include "tsl256x.h"
@ -255,7 +256,7 @@ PROCESS_THREAD(tsl256x_int_process, ev, data)
}
/*---------------------------------------------------------------------------*/
static void
tsl256x_interrupt_handler(uint8_t port, uint8_t pin)
tsl256x_interrupt_handler(gpio_hal_pin_mask_t pin_mask)
{
/* There's no alert/interruption flag to check, clear the interruption by
* writting to the CLEAR bit in the COMMAND register
@ -263,6 +264,12 @@ tsl256x_interrupt_handler(uint8_t port, uint8_t pin)
process_poll(&tsl256x_int_process);
}
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t tsl256x_handler = {
.next = NULL,
.handler = tsl256x_interrupt_handler,
.pin_mask = gpio_hal_pin_to_mask(I2C_INT_PIN) << (I2C_INT_PORT << 3),
};
/*---------------------------------------------------------------------------*/
static int
configure(int type, int value)
{
@ -440,7 +447,7 @@ configure(int type, int value)
GPIO_DETECT_EDGE(TSL256X_INT_PORT_BASE, TSL256X_INT_PIN_MASK);
GPIO_TRIGGER_SINGLE_EDGE(TSL256X_INT_PORT_BASE, TSL256X_INT_PIN_MASK);
GPIO_DETECT_FALLING(TSL256X_INT_PORT_BASE, TSL256X_INT_PIN_MASK);
gpio_register_callback(tsl256x_interrupt_handler, I2C_INT_PORT, I2C_INT_PIN);
gpio_hal_register_handler(&tsl256x_handler);
/* Spin process until an interrupt is received */
process_start(&tsl256x_int_process, NULL);

View File

@ -51,6 +51,7 @@
#include "lib/sensors.h"
#include "dev/sys-ctrl.h"
#include "dev/gpio.h"
#include "dev/gpio-hal.h"
#include "dev/ioc.h"
#include "sys/timer.h"
#include "sys/ctimer.h"
@ -292,8 +293,22 @@ PROCESS_THREAD(weather_meter_int_process, ev, data)
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
static void weather_meter_interrupt_handler(gpio_hal_pin_mask_t pin_mask);
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t rain_handler = {
.next = NULL,
.handler = weather_meter_interrupt_handler,
.pin_mask = gpio_hal_pin_to_mask(RAIN_GAUGE_SENSOR_PIN) << (RAIN_GAUGE_SENSOR_PORT << 3),
};
/*---------------------------------------------------------------------------*/
static gpio_hal_event_handler_t anemometer_handler = {
.next = NULL,
.handler = weather_meter_interrupt_handler,
.pin_mask = gpio_hal_pin_to_mask(ANEMOMETER_SENSOR_PIN) << (ANEMOMETER_SENSOR_PORT << 3),
};
/*---------------------------------------------------------------------------*/
static void
weather_meter_interrupt_handler(uint8_t port, uint8_t pin)
weather_meter_interrupt_handler(gpio_hal_pin_mask_t pin_mask)
{
uint32_t aux;
@ -308,10 +323,10 @@ weather_meter_interrupt_handler(uint8_t port, uint8_t pin)
* value
*/
if((port == ANEMOMETER_SENSOR_PORT) && (pin == ANEMOMETER_SENSOR_PIN)) {
if(pin_mask == rain_handler.pin_mask) {
weather_sensors.anemometer.ticks++;
process_post(&weather_meter_int_process, anemometer_int_event, NULL);
} else if((port == RAIN_GAUGE_SENSOR_PORT) && (pin == RAIN_GAUGE_SENSOR_PIN)) {
} else if(pin_mask == anemometer_handler.pin_mask) {
weather_sensors.rain_gauge.ticks++;
aux = weather_sensors.rain_gauge.ticks * WEATHER_METER_AUX_RAIN_MM;
aux /= 1000;
@ -427,8 +442,7 @@ configure(int type, int value)
GPIO_TRIGGER_SINGLE_EDGE(ANEMOMETER_SENSOR_PORT_BASE,
ANEMOMETER_SENSOR_PIN_MASK);
ioc_set_over(ANEMOMETER_SENSOR_PORT, ANEMOMETER_SENSOR_PIN, IOC_OVERRIDE_DIS);
gpio_register_callback(weather_meter_interrupt_handler, ANEMOMETER_SENSOR_PORT,
ANEMOMETER_SENSOR_PIN);
gpio_hal_register_handler(&anemometer_handler);
/* Configure rain gauge interruption */
GPIO_SOFTWARE_CONTROL(RAIN_GAUGE_SENSOR_PORT_BASE, RAIN_GAUGE_SENSOR_PIN_MASK);
@ -437,8 +451,7 @@ configure(int type, int value)
GPIO_TRIGGER_SINGLE_EDGE(RAIN_GAUGE_SENSOR_PORT_BASE,
RAIN_GAUGE_SENSOR_PIN_MASK);
ioc_set_over(RAIN_GAUGE_SENSOR_PORT, RAIN_GAUGE_SENSOR_PIN, IOC_OVERRIDE_DIS);
gpio_register_callback(weather_meter_interrupt_handler, RAIN_GAUGE_SENSOR_PORT,
RAIN_GAUGE_SENSOR_PIN);
gpio_hal_register_handler(&rain_handler);
process_start(&weather_meter_int_process, NULL);

View File

@ -1,2 +1,2 @@
MOTELIST_ZOLERTIA = firefly
BOARD_SOURCEFILES += board.c leds-arch.c
BOARD_SOURCEFILES += board.c

View File

@ -98,20 +98,18 @@
* @{
*/
/*---------------------------------------------------------------------------*/
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */
#define LEDS_RED (1 << 5) /**< LED3 (Red) -> PD5 */
#define LEDS_ARCH_L1_PORT GPIO_D_NUM
#define LEDS_ARCH_L1_PIN 5
#define LEDS_ARCH_L2_PORT GPIO_D_NUM
#define LEDS_ARCH_L2_PIN 4
#define LEDS_ARCH_L3_PORT GPIO_D_NUM
#define LEDS_ARCH_L3_PIN 3
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
#define LEDS_CONF_RED 1
#define LEDS_CONF_GREEN 2
#define LEDS_CONF_BLUE 4
#define LEDS_LIGHT_BLUE (LEDS_GREEN | LEDS_BLUE) /**< Green + Blue (24) */
#define LEDS_YELLOW (LEDS_GREEN | LEDS_RED) /**< Green + Red (48) */
#define LEDS_PURPLE (LEDS_BLUE | LEDS_RED) /**< Blue + Red (40) */
#define LEDS_WHITE LEDS_ALL /**< Green + Blue + Red (56) */
/* Notify various examples that we have LEDs */
#define PLATFORM_HAS_LEDS 1
#define LEDS_CONF_COUNT 3
/** @} */
/*---------------------------------------------------------------------------*/
/** \name USB configuration

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