Merge branch 'develop' into contrib/csma-defaults
This commit is contained in:
commit
2e3280b5c5
|
@ -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/net/routing 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)}}
|
||||
|
@ -213,6 +219,7 @@ SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) $(CONTIKI_ARCH_DIRS)
|
|||
|
||||
vpath %.c $(SOURCEDIRS)
|
||||
vpath %.S $(SOURCEDIRS)
|
||||
vpath %.s $(SOURCEDIRS)
|
||||
|
||||
CFLAGS += ${addprefix -I,$(SOURCEDIRS) $(CONTIKI)}
|
||||
|
||||
|
@ -267,6 +274,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
|
||||
|
|
22
README.md
22
README.md
|
@ -1,11 +1,25 @@
|
|||
# Contiki-NG: the Next Generation Contiki
|
||||
# Contiki-NG: The OS for Next Generation IoT Devices
|
||||
|
||||
[![Build Status](https://travis-ci.org/contiki-ng/contiki-ng.svg?branch=master)](https://travis-ci.org/contiki-ng/contiki-ng/branches)
|
||||
[![License](https://img.shields.io/badge/License-3--Clause%20BSD-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md)
|
||||
[![Latest release](https://img.shields.io/github/release/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
|
||||
[![GitHub Release Date](https://img.shields.io/github/release-date/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
|
||||
[![Last commit](https://img.shields.io/github/last-commit/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/commit/HEAD)
|
||||
|
||||
Contiki-NG is an open-source, cross-platform operating system for Next-Generation IoT devices. It focuses on dependable (secure and reliable) low-power communication and standard protocols, such as IPv6/6LoWPAN, 6TiSCH, RPL, and CoAP. Contiki-NG comes with extensive documentation, tutorials, a roadmap, release cycle, and well-defined development flow for smooth integration of community contributions.
|
||||
|
||||
Unless excplicitly stated otherwise, Contiki-NG sources are distributed under
|
||||
the terms of the [3-clause BSD license](LICENSE.md).
|
||||
|
||||
Contiki-NG started as a fork of the Contiki OS and retains some of its original features.
|
||||
|
||||
Find out more:
|
||||
|
||||
Contiki-NG is a fork of Contiki, with focus on next generation IoT protocols and platforms.
|
||||
Important links:
|
||||
* GitHub repository: https://github.com/contiki-ng/contiki-ng
|
||||
* Documentation: https://github.com/contiki-ng/contiki-ng/wiki
|
||||
* Web site: http://contiki-ng.org
|
||||
|
||||
Engage with the community:
|
||||
|
||||
* Gitter: https://gitter.im/contiki-ng
|
||||
* Twitter: https://twitter.com/contiki_ng
|
||||
* Web site: http://contiki-ng.org
|
||||
|
|
|
@ -17,7 +17,7 @@ CONTIKI_CPU_DIRS = . dev usb usb/common usb/common/cdc-acm
|
|||
CONTIKI_CPU_SOURCEFILES += soc.c clock.c rtimer-arch.c uart.c watchdog.c
|
||||
CONTIKI_CPU_SOURCEFILES += nvic.c sys-ctrl.c gpio.c ioc.c spi.c adc.c
|
||||
CONTIKI_CPU_SOURCEFILES += crypto.c aes.c ecb.c cbc.c ctr.c cbc-mac.c gcm.c
|
||||
CONTIKI_CPU_SOURCEFILES += ccm.c sha256.c
|
||||
CONTIKI_CPU_SOURCEFILES += ccm.c sha256.c gpio-hal-arch.c
|
||||
CONTIKI_CPU_SOURCEFILES += cc2538-aes-128.c cc2538-ccm-star.c
|
||||
CONTIKI_CPU_SOURCEFILES += cc2538-rf.c udma.c lpm.c int-master.c
|
||||
CONTIKI_CPU_SOURCEFILES += pka.c bignum-driver.c ecc-driver.c ecc-algorithm.c
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
/* Path to headers with implementation of mutexes and memory barriers */
|
||||
#define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
|
||||
#define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
|
||||
|
||||
#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* CC2538_DEF_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup cc2538
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc2538-gpio-hal CC2538 GPIO HAL implementation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the CC2538 GPIO HAL functions
|
||||
*
|
||||
* \note
|
||||
* Do not include this header directly
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef GPIO_HAL_ARCH_H_
|
||||
#define GPIO_HAL_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define PIN_TO_PORT(pin) (pin >> 3)
|
||||
#define PIN_TO_PORT_BASE(pin) GPIO_PORT_TO_BASE(PIN_TO_PORT(pin))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_interrupt_enable(p) \
|
||||
GPIO_ENABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
|
||||
|
||||
#define gpio_hal_arch_interrupt_disable(p) \
|
||||
GPIO_DISABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
|
||||
|
||||
#define gpio_hal_arch_pin_set_input(p) do { \
|
||||
GPIO_SOFTWARE_CONTROL(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
GPIO_SET_INPUT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
} while(0);
|
||||
|
||||
#define gpio_hal_arch_pin_set_output(p) do { \
|
||||
GPIO_SOFTWARE_CONTROL(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
GPIO_SET_OUTPUT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
} while(0);
|
||||
|
||||
#define gpio_hal_arch_set_pin(p) \
|
||||
GPIO_SET_PIN(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
|
||||
|
||||
#define gpio_hal_arch_clear_pin(p) \
|
||||
GPIO_CLR_PIN(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8))
|
||||
|
||||
#define gpio_hal_arch_read_pin(p) \
|
||||
(GPIO_READ_PIN(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)) == 0 ? 0 : 1)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -37,46 +37,13 @@
|
|||
*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/nvic.h"
|
||||
#include "reg.h"
|
||||
#include "lpm.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* \brief Pointer to a function to be called when a GPIO interrupt is detected.
|
||||
* Callbacks for Port A, Pins[0:7] are stored in positions [0:7] of this
|
||||
* buffer, Port B callbacks in [8:15] and so on
|
||||
*/
|
||||
static gpio_callback_t gpio_callbacks[32];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_register_callback(gpio_callback_t f, uint8_t port, uint8_t pin)
|
||||
{
|
||||
gpio_callbacks[(port << 3) + pin] = f;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \brief Run through all registered GPIO callbacks and invoke those
|
||||
* associated with the \a port and the pins specified by \a mask
|
||||
* \param mask Search callbacks associated with pins specified by this mask
|
||||
* \param port Search callbacks associated with this port. Here, port is
|
||||
* specified as a number between 0 and 3. Port A: 0, Port B: 1 etc */
|
||||
void
|
||||
notify(uint8_t mask, uint8_t port)
|
||||
{
|
||||
uint8_t i;
|
||||
gpio_callback_t *f = &gpio_callbacks[port << 3];
|
||||
|
||||
for(i = 0; i < 8; i++) {
|
||||
if(mask & (1 << i)) {
|
||||
if((*f) != NULL) {
|
||||
(*f)(port, i);
|
||||
}
|
||||
}
|
||||
f++;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \brief Interrupt service routine for Port \a port
|
||||
* \param port Number between 0 and 3. Port A: 0, Port B: 1, etc.
|
||||
|
@ -93,7 +60,7 @@ gpio_port_isr(uint8_t port)
|
|||
int_status = GPIO_GET_MASKED_INT_STATUS(base);
|
||||
power_up_int_status = GPIO_GET_POWER_UP_INT_STATUS(port);
|
||||
|
||||
notify(int_status | power_up_int_status, port);
|
||||
gpio_hal_event_handler((int_status | power_up_int_status) << (port << 3));
|
||||
|
||||
GPIO_CLEAR_INTERRUPT(base, int_status);
|
||||
GPIO_CLEAR_POWER_UP_INTERRUPT(port, power_up_int_status);
|
||||
|
@ -110,9 +77,4 @@ GPIO_PORT_ISR(b, B)
|
|||
GPIO_PORT_ISR(c, C)
|
||||
GPIO_PORT_ISR(d, D)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_init()
|
||||
{
|
||||
memset(gpio_callbacks, 0, sizeof(gpio_callbacks));
|
||||
}
|
||||
/** @} */
|
||||
|
|
|
@ -42,27 +42,12 @@
|
|||
*/
|
||||
#ifndef GPIO_H_
|
||||
#define GPIO_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "reg.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* \brief Type definition for callbacks invoked by the GPIO ISRs
|
||||
* \param port The port that triggered the GPIO interrupt. \e port is passed
|
||||
* by its numeric representation (Port A:0, B:1 etc). Defines for
|
||||
* these numeric representations are GPIO_x_NUM
|
||||
* \param pin The pin that triggered the interrupt, specified by number
|
||||
* (0, 1, ..., 7)
|
||||
*
|
||||
* This is the prototype of a function pointer passed to
|
||||
* gpio_register_callback(). These callbacks are registered on a port/pin
|
||||
* basis. When a GPIO port generates an interrupt, if a callback has been
|
||||
* registered for the port/pin combination, the ISR will invoke it. The ISR
|
||||
* will pass the port/pin as arguments in that call, so that a developer can
|
||||
* re-use the same callback for multiple port/pin combinations
|
||||
*/
|
||||
typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Base addresses for the GPIO register instances
|
||||
* @{
|
||||
|
@ -612,21 +597,6 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
|
|||
#define GPIO_IRQ_DETECT_UNMASK_PAIACK0 0x00000001 /**< Port A bit 0 */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \brief Initialise the GPIO module */
|
||||
void gpio_init();
|
||||
|
||||
/**
|
||||
* \brief Register GPIO callback
|
||||
* \param f Pointer to a function to be called when \a pin of \a port
|
||||
* generates an interrupt
|
||||
* \param port Associate \a f with this port. \e port must be specified with
|
||||
* its numeric representation (Port A:0, B:1 etc). Defines for these
|
||||
* numeric representations are GPIO_x_NUM
|
||||
* \param pin Associate \a f with this pin, which is specified by number
|
||||
* (0, 1, ..., 7)
|
||||
*/
|
||||
void gpio_register_callback(gpio_callback_t f, uint8_t port, uint8_t pin);
|
||||
|
||||
#endif /* GPIO_H_ */
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,6 +56,12 @@ ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
|
|||
ioc_over[(port << 3) + pin] = over;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint32_t
|
||||
ioc_get_over(uint8_t port, uint8_t pin)
|
||||
{
|
||||
return ioc_over[(port << 3) + pin] & 0x0F;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ioc_set_sel(uint8_t port, uint8_t pin, uint8_t sel)
|
||||
{
|
||||
|
|
|
@ -249,6 +249,22 @@ void ioc_init();
|
|||
*/
|
||||
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over);
|
||||
|
||||
/**
|
||||
* \brief Get Port:Pin override function
|
||||
* \param port The port as a number (PA: 0, PB: 1 etc)
|
||||
* \param pin The pin as a number
|
||||
* \return The override function
|
||||
*
|
||||
* The return value can be one of
|
||||
*
|
||||
* - IOC_OVERRIDE_OE: Output
|
||||
* - IOC_OVERRIDE_PUE: Pull-Up
|
||||
* - IOC_OVERRIDE_PDE: Pull-Down
|
||||
* - IOC_OVERRIDE_ANA: Analog
|
||||
* - IOC_OVERRIDE_DIS: Disabled
|
||||
*/
|
||||
uint32_t ioc_get_over(uint8_t port, uint8_t pin);
|
||||
|
||||
/**
|
||||
* \brief Function select for Port:Pin
|
||||
* \param port The port as a number (PA: 0, PB: 1 etc)
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "dev/ioc.h"
|
||||
#include "dev/nvic.h"
|
||||
#include "dev/sys-ctrl.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "lpm.h"
|
||||
#include "reg.h"
|
||||
#include "soc.h"
|
||||
|
@ -123,7 +124,7 @@ soc_init()
|
|||
clock_init();
|
||||
lpm_init();
|
||||
rtimer_init();
|
||||
gpio_init();
|
||||
gpio_hal_init();
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
|
|
@ -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 += random.c soc-trng.c int-master.c
|
||||
|
||||
|
|
|
@ -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_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup cc26xx-gpio-hal
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation file for the CC13xx/CC26xx GPIO HAL functions
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "ti-lib.h"
|
||||
#include "ti-lib-rom.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define CONFIG_MASK (IOC_IOPULL_M | IOC_INT_M | IOC_IOMODE_OPEN_SRC_INV)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
{
|
||||
uint32_t config;
|
||||
gpio_hal_pin_cfg_t tmp;
|
||||
|
||||
/* Clear settings that we are about to change, keep everything else */
|
||||
config = ti_lib_rom_ioc_port_configure_get(pin);
|
||||
config &= ~CONFIG_MASK;
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_EDGE_NONE) {
|
||||
config |= IOC_NO_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_RISING) {
|
||||
config |= IOC_RISING_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_FALLING) {
|
||||
config |= IOC_FALLING_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_BOTH) {
|
||||
config |= IOC_BOTH_EDGES;
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_PULL_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_PULL_NONE) {
|
||||
config |= IOC_NO_IOPULL;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_DOWN) {
|
||||
config |= IOC_IOPULL_DOWN;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_UP) {
|
||||
config |= IOC_IOPULL_UP;
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_INT_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) {
|
||||
config |= IOC_INT_DISABLE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_ENABLE) {
|
||||
config |= IOC_INT_ENABLE;
|
||||
}
|
||||
|
||||
ti_lib_rom_ioc_port_configure_set(pin, IOC_PORT_GPIO, config);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_cfg_t
|
||||
gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
||||
{
|
||||
gpio_hal_pin_cfg_t cfg;
|
||||
uint32_t tmp;
|
||||
uint32_t config;
|
||||
|
||||
cfg = 0;
|
||||
config = ti_lib_rom_ioc_port_configure_get(pin);
|
||||
|
||||
/* Pull */
|
||||
tmp = config & IOC_IOPULL_M;
|
||||
if(tmp == IOC_IOPULL_UP) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_UP;
|
||||
} else if(tmp == IOC_IOPULL_DOWN) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN;
|
||||
} else if(tmp == IOC_NO_IOPULL) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_NONE;
|
||||
}
|
||||
|
||||
/* Interrupt enable/disable */
|
||||
tmp = config & IOC_INT_ENABLE;
|
||||
if(tmp == IOC_INT_DISABLE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
|
||||
} else if(tmp == IOC_INT_ENABLE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
}
|
||||
|
||||
/* Edge detection */
|
||||
tmp = config & IOC_BOTH_EDGES;
|
||||
if(tmp == IOC_NO_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_NONE;
|
||||
} else if(tmp == IOC_FALLING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING;
|
||||
} else if(tmp == IOC_RISING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING;
|
||||
} else if(tmp == IOC_BOTH_EDGES) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
}
|
||||
|
||||
return cfg;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_mask_t
|
||||
gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
gpio_hal_pin_mask_t oe_pins;
|
||||
|
||||
/* For pins configured as output we need to read DOUT31_0 */
|
||||
oe_pins = ti_lib_gpio_get_output_enable_multi_dio(pins);
|
||||
|
||||
pins &= ~oe_pins;
|
||||
|
||||
return (HWREG(GPIO_BASE + GPIO_O_DOUT31_0) & oe_pins) |
|
||||
ti_lib_gpio_read_multi_dio(pins);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t
|
||||
gpio_hal_arch_read_pin(gpio_hal_pin_t pin)
|
||||
{
|
||||
if(ti_lib_gpio_get_output_enable_dio(pin)) {
|
||||
return (HWREG(GPIO_BASE + GPIO_O_DOUT31_0) >> pin) & 1;
|
||||
}
|
||||
|
||||
return ti_lib_gpio_read_dio(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup cc26xx
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc26xx-gpio-hal CC13xx/CC26xx GPIO HAL implementation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the CC13xx/CC26xx GPIO HAL functions
|
||||
*
|
||||
* \note
|
||||
* Do not include this header directly
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef GPIO_HAL_ARCH_H_
|
||||
#define GPIO_HAL_ARCH_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "ti-lib.h"
|
||||
#include "ti-lib-rom.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_interrupt_enable(p) interrupt_enable(p)
|
||||
#define gpio_hal_arch_interrupt_disable(p) ti_lib_rom_ioc_int_disable(p)
|
||||
|
||||
#define gpio_hal_arch_pin_set_input(p) ti_lib_rom_ioc_pin_type_gpio_input(p)
|
||||
#define gpio_hal_arch_pin_set_output(p) ti_lib_rom_ioc_pin_type_gpio_output(p)
|
||||
|
||||
#define gpio_hal_arch_set_pin(p) ti_lib_gpio_set_dio(p)
|
||||
#define gpio_hal_arch_clear_pin(p) ti_lib_gpio_clear_dio(p)
|
||||
#define gpio_hal_arch_toggle_pin(p) ti_lib_gpio_toggle_dio(p)
|
||||
#define gpio_hal_arch_write_pin(p, v) ti_lib_gpio_write_dio(p, v)
|
||||
|
||||
#define gpio_hal_arch_set_pins(p) ti_lib_gpio_set_multi_dio(p)
|
||||
#define gpio_hal_arch_clear_pins(p) ti_lib_gpio_clear_multi_dio(p)
|
||||
#define gpio_hal_arch_toggle_pins(p) ti_lib_gpio_toggle_multi_dio(p)
|
||||
#define gpio_hal_arch_write_pins(p, v) ti_lib_gpio_write_multi_dio(p, v)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline void
|
||||
interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
ti_lib_gpio_clear_event_dio(pin);
|
||||
ti_lib_rom_ioc_int_enable(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -29,72 +29,33 @@
|
|||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup cc26xx-gpio-interrupts
|
||||
* \addtogroup cc26xx
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of CC13xx/CC26xx GPIO interrupt handling.
|
||||
* CC13xx/CC26xx GPIO interrupt ISR.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "ioc.h"
|
||||
#include "gpio-interrupt.h"
|
||||
#include "lpm.h"
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "ti-lib.h"
|
||||
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_interrupt_isr GPIOIntHandler
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Handler array */
|
||||
static gpio_interrupt_handler_t handlers[NUM_IO_MAX];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_interrupt_register_handler(uint8_t ioid, gpio_interrupt_handler_t f)
|
||||
{
|
||||
uint8_t interrupts_disabled = ti_lib_int_master_disable();
|
||||
|
||||
/* Clear interrupts on specified pins */
|
||||
ti_lib_gpio_clear_event_dio(ioid);
|
||||
|
||||
handlers[ioid] = f;
|
||||
|
||||
/* Re-enable interrupts */
|
||||
if(!interrupts_disabled) {
|
||||
ti_lib_int_master_enable();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_interrupt_init()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < NUM_IO_MAX; i++) {
|
||||
handlers[i] = NULL;
|
||||
}
|
||||
|
||||
ti_lib_int_enable(INT_AON_GPIO_EDGE);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_interrupt_isr(void)
|
||||
{
|
||||
uint32_t pin_mask;
|
||||
uint8_t i;
|
||||
gpio_hal_pin_mask_t pin_mask;
|
||||
|
||||
/* Read interrupt flags */
|
||||
pin_mask = (HWREG(GPIO_BASE + GPIO_O_EVFLAGS31_0) & GPIO_DIO_ALL_MASK);
|
||||
|
||||
gpio_hal_event_handler(pin_mask);
|
||||
|
||||
/* Clear the interrupt flags */
|
||||
HWREG(GPIO_BASE + GPIO_O_EVFLAGS31_0) = pin_mask;
|
||||
|
||||
/* Run custom ISRs */
|
||||
for(i = 0; i < NUM_IO_MAX; i++) {
|
||||
/* Call the handler if there is one registered for this event */
|
||||
if((pin_mask & (1 << i)) && handlers[i] != NULL) {
|
||||
handlers[i](i);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 += .
|
||||
|
||||
|
@ -30,5 +30,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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include "contiki-net.h"
|
||||
#include "leds.h"
|
||||
#include "lpm.h"
|
||||
#include "gpio-interrupt.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/oscillators.h"
|
||||
#include "ieee-addr.h"
|
||||
#include "vims.h"
|
||||
|
@ -138,7 +138,7 @@ platform_init_stage_one()
|
|||
|
||||
board_init();
|
||||
|
||||
gpio_interrupt_init();
|
||||
gpio_hal_init();
|
||||
|
||||
leds_init();
|
||||
fade(LEDS_RED);
|
||||
|
@ -151,6 +151,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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 os/storage/cfs
|
||||
|
||||
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -99,9 +99,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_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
|
|
@ -99,9 +99,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_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
|
|
@ -68,9 +68,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_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
|
@ -124,7 +125,7 @@ rtc_init(void)
|
|||
*/
|
||||
|
||||
/* Get the system date in the following format: wd dd mm yy hh mm ss */
|
||||
PRINTF("Setting RTC from system date: %s\n", DATE);
|
||||
LOG_INFO("Setting RTC from system date: %s\n", DATE);
|
||||
|
||||
/* Configure the RTC with the current values */
|
||||
td.weekdays = (uint8_t)strtol(DATE, &next, 10);
|
||||
|
@ -149,7 +150,7 @@ rtc_init(void)
|
|||
|
||||
/* Set the time and date */
|
||||
if(rtcc_set_time_date(&td) == AB08_ERROR) {
|
||||
PRINTF("Failed to set time and date\n");
|
||||
LOG_ERR("Failed to set time and date\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -103,9 +103,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_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
|
|
@ -106,15 +106,18 @@
|
|||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_RED 1 /**< LED1 (Red) -> PD4 */
|
||||
#define LEDS_RED_PIN_MASK (1 << 4)
|
||||
#define LEDS_RED_PIN 4
|
||||
#define LEDS_RED_PIN_MASK (1 << LEDS_RED_PIN)
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_GREEN 2 /**< LED2 (Green) -> PB7 */
|
||||
#define LEDS_GREEN_PIN_MASK (1 << 7)
|
||||
#define LEDS_GREEN_PIN 7
|
||||
#define LEDS_GREEN_PIN_MASK (1 << LEDS_GREEN_PIN)
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_B_BASE
|
||||
|
||||
#define LEDS_BLUE 4 /**< LED3 (Blue) -> PB6 */
|
||||
#define LEDS_BLUE_PIN_MASK (1 << 6)
|
||||
#define LEDS_BLUE_PIN 6
|
||||
#define LEDS_BLUE_PIN_MASK (1 << LEDS_BLUE_PIN)
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_B_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED) /* 7 */
|
||||
|
|
|
@ -30,11 +30,13 @@
|
|||
|
||||
#include <contiki.h>
|
||||
#include <lib/assert.h>
|
||||
#include <sys/node-id.h>
|
||||
#include <net/mac/tsch/tsch.h>
|
||||
#include <net/mac/tsch/tsch-queue.h>
|
||||
#include <net/mac/tsch/sixtop/sixtop.h>
|
||||
|
||||
/* Hard-coded MAC address of the TSCH coordinator */
|
||||
static linkaddr_t coordinator_addr = {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }};
|
||||
|
||||
extern const sixtop_sf_t test_sf;
|
||||
extern int test_sf_start(const linkaddr_t *addr);
|
||||
|
||||
|
@ -49,7 +51,7 @@ PROCESS_THREAD(sixp_node_process, ev, data)
|
|||
|
||||
sixtop_add_sf(&test_sf);
|
||||
|
||||
if(node_id == COORDINATOR_NODE_ID) {
|
||||
if(linkaddr_cmp(&coordinator_addr, &linkaddr_node_addr)) {
|
||||
tsch_set_coordinator(1);
|
||||
assert(test_sf_start(NULL) == 0);
|
||||
} else {
|
||||
|
|
|
@ -3,9 +3,12 @@ all: $(CONTIKI_PROJECT)
|
|||
|
||||
CONTIKI=../../..
|
||||
|
||||
MAKE_WITH_ORCHESTRA ?= 0 # force Orchestra from command line
|
||||
MAKE_WITH_SECURITY ?= 0 # force Security from command line
|
||||
MAKE_WITH_PERIODIC_ROUTES_PRINT ?= 0 # print #routes periodically, used for regression tests
|
||||
# force Orchestra from command line
|
||||
MAKE_WITH_ORCHESTRA ?= 0
|
||||
# force Security from command line
|
||||
MAKE_WITH_SECURITY ?= 0
|
||||
# print #routes periodically, used for regression tests
|
||||
MAKE_WITH_PERIODIC_ROUTES_PRINT ?= 0
|
||||
|
||||
MAKE_MAC = MAKE_MAC_TSCH
|
||||
MODULES += os/services/shell
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
CONTIKI_PROJECT = gpio-hal-example
|
||||
CONTIKI = ../../..
|
||||
|
||||
include $(CONTIKI)/Makefile.identify-target
|
||||
|
||||
MODULES_REL += $(TARGET)
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
|
@ -0,0 +1,36 @@
|
|||
# GPIO HAL Example
|
||||
This example demonstrates and tests the functionality of the GPIO HAL. You can
|
||||
use it to:
|
||||
|
||||
* Understand the logic of the GPIO HAL.
|
||||
* Test your implementation of arch-specific GPIO HAL components if you are
|
||||
developing a new port.
|
||||
|
||||
This example assumes a device with:
|
||||
|
||||
* 3 output pins (e.g. LEDs).
|
||||
* 1 button.
|
||||
|
||||
# Supported devices
|
||||
This example is expected to work off-the-shelf on the following boards:
|
||||
|
||||
* All CC13xx/CC26xx devices
|
||||
* All CC2538 devices
|
||||
|
||||
# Extending for other platforms
|
||||
Create a sub-directory with the same name as your platform. For example, for
|
||||
platform `my-new-platform` create a subdirectory called `my-new-platform`.
|
||||
Source files in this directory will be compiled automatically. In the most
|
||||
simple case, all you will need is a source file called e.g. `pins.c` (it's OK
|
||||
to use a different filename). In this file, you will need to provide
|
||||
definitions of the variables used by the example to manipulate pins. These
|
||||
variables are:
|
||||
|
||||
* `out_pin1`, `out_pin2` and `out_pin3` for output pins.
|
||||
* `btn_pin` for the button pin.
|
||||
|
||||
Assign to those variables a value that corresponds to the output pin in your
|
||||
board that you wish to test with the example. For example, if you have a LED
|
||||
connected to pin 20, then you will need to
|
||||
|
||||
gpio_hal_pin_t out_pin1 = 20;
|
|
@ -1,10 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* 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
|
||||
|
@ -28,44 +29,23 @@
|
|||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup cc26xx
|
||||
* @{
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* LEDs on the SmartRF06 (EB and BB) are connected as follows:
|
||||
* - LED1 (Red) -> PC0
|
||||
* - LED2 (Yellow) -> PC1 (gpio_hal_pin_t 17)
|
||||
* - LED3 (Green) -> PC2 (gpio_hal_pin_t 18)
|
||||
* - LED4 (Orange) -> PC3 (gpio_hal_pin_t 19)
|
||||
*
|
||||
* \defgroup cc26xx-gpio-interrupts CC13xx/CC26xx GPIO interrupt handling
|
||||
*
|
||||
* The CC13xx/CC26xx GPIO interrupt handler and an API which can be used by
|
||||
* other parts of the code when they wish to be notified of a GPIO interrupt
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the CC13xx/CC26xx GPIO interrupt management
|
||||
* LED1 shares the same pin with the USB pullup, so here we'll use PC1, PC2
|
||||
* and PC3.
|
||||
*/
|
||||
gpio_hal_pin_t out_pin1 = 17;
|
||||
gpio_hal_pin_t out_pin2 = 18;
|
||||
gpio_hal_pin_t out_pin3 = 19;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef GPIO_INTERRUPT_H_
|
||||
#define GPIO_INTERRUPT_H_
|
||||
/* Button pin: Button select, PA3 */
|
||||
gpio_hal_pin_t btn_pin = 3;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef void (*gpio_interrupt_handler_t)(uint8_t ioid);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \brief Initialise the GPIO interrupt handling module */
|
||||
void gpio_interrupt_init(void);
|
||||
|
||||
/**
|
||||
* \brief Register a GPIO interrupt handler
|
||||
* \param f Pointer to a handler to be called when an interrupt is raised on
|
||||
* ioid
|
||||
* \param ioid Associate \a f with this ioid. \e ioid must be specified with
|
||||
* its numeric representation (0, 1, .. 31). Defines for these
|
||||
* numeric representations are IOID_x
|
||||
*/
|
||||
void gpio_interrupt_register_handler(uint8_t ioid, gpio_interrupt_handler_t f);
|
||||
|
||||
#endif /* GPIO_INTERRUPT_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "sys/etimer.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern gpio_hal_pin_t out_pin1, out_pin2, out_pin3;
|
||||
extern gpio_hal_pin_t btn_pin;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct etimer et;
|
||||
static uint8_t counter;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(gpio_hal_example, "GPIO HAL Example");
|
||||
AUTOSTART_PROCESSES(&gpio_hal_example);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(gpio_hal_example, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
counter = 0;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_YIELD();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER && data == &et) {
|
||||
if((counter & 7) == 0) {
|
||||
/* Set output and test write, high */
|
||||
gpio_hal_arch_pin_set_output(out_pin1);
|
||||
gpio_hal_arch_pin_set_output(out_pin2);
|
||||
gpio_hal_arch_pin_set_output(out_pin3);
|
||||
|
||||
gpio_hal_arch_write_pin(out_pin1, 1);
|
||||
gpio_hal_arch_write_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3),
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 1) {
|
||||
/* Test write, low */
|
||||
gpio_hal_arch_write_pin(out_pin1, 0);
|
||||
gpio_hal_arch_write_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3), 0);
|
||||
} else if((counter & 7) == 2) {
|
||||
/* Test set */
|
||||
gpio_hal_arch_set_pin(out_pin1);
|
||||
gpio_hal_arch_set_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 3) {
|
||||
/* Test clear */
|
||||
gpio_hal_arch_clear_pin(out_pin1);
|
||||
gpio_hal_arch_clear_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 4) {
|
||||
/* Test toggle (should go high) */
|
||||
gpio_hal_arch_toggle_pin(out_pin1);
|
||||
gpio_hal_arch_toggle_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 5) {
|
||||
/* Test toggle (should go low) */
|
||||
gpio_hal_arch_toggle_pin(out_pin1);
|
||||
gpio_hal_arch_toggle_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 6) {
|
||||
/* Set to input and then set. Should stay off */
|
||||
gpio_hal_arch_pin_set_input(out_pin1);
|
||||
gpio_hal_arch_pin_set_input(out_pin2);
|
||||
gpio_hal_arch_pin_set_input(out_pin3);
|
||||
gpio_hal_arch_set_pin(out_pin1);
|
||||
gpio_hal_arch_set_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 7) {
|
||||
/* Toggle button interrupt */
|
||||
gpio_hal_pin_cfg_t interrupt;
|
||||
|
||||
interrupt = gpio_hal_arch_pin_cfg_get(btn_pin) &
|
||||
GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
|
||||
if(interrupt == 0) {
|
||||
printf("Enabling button interrupt\n");
|
||||
gpio_hal_arch_interrupt_enable(btn_pin);
|
||||
} else {
|
||||
printf("Disabling button interrupt\n");
|
||||
gpio_hal_arch_interrupt_disable(btn_pin);
|
||||
}
|
||||
}
|
||||
|
||||
/* Test read */
|
||||
printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08lx\n", counter & 7,
|
||||
gpio_hal_arch_read_pin(out_pin1),
|
||||
gpio_hal_arch_read_pin(out_pin2),
|
||||
gpio_hal_arch_read_pin(out_pin3),
|
||||
gpio_hal_arch_read_pins(gpio_hal_pin_to_mask(out_pin1) |
|
||||
gpio_hal_pin_to_mask(out_pin2) |
|
||||
gpio_hal_pin_to_mask(out_pin3)));
|
||||
|
||||
counter++;
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
} else if(ev == sensors_event && data == &button_sensor) {
|
||||
printf("Button event\n");
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* LEDs on the OpenMote-CC2538 are connected as follows:
|
||||
* - LED1 (Red) -> PC4 (gpio_hal_pin_t 20)
|
||||
* - LED2 (Yellow) -> PC6 (gpio_hal_pin_t 22)
|
||||
* - LED3 (Green) -> PC7 (gpio_hal_pin_t 23)
|
||||
* - LED4 (Orange) -> PC5
|
||||
*/
|
||||
gpio_hal_pin_t out_pin1 = 20;
|
||||
gpio_hal_pin_t out_pin2 = 22;
|
||||
gpio_hal_pin_t out_pin3 = 23;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Button pin: PC3 */
|
||||
gpio_hal_pin_t btn_pin = 19;
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if CONTIKI_BOARD_SENSORTAG_CC1350
|
||||
#define PINS2_AND_3 BOARD_IOID_LED_1
|
||||
#else
|
||||
#define PINS2_AND_3 BOARD_IOID_LED_2
|
||||
#endif
|
||||
gpio_hal_pin_t out_pin1 = BOARD_IOID_LED_1;
|
||||
gpio_hal_pin_t out_pin2 = PINS2_AND_3;
|
||||
gpio_hal_pin_t out_pin3 = PINS2_AND_3;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_t btn_pin = BOARD_IOID_KEY_LEFT;
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BASE_TO_PORT_NUM(base) (((base) - GPIO_A_BASE) >> 12)
|
||||
|
||||
gpio_hal_pin_t out_pin1 = (BASE_TO_PORT_NUM(LEDS_GREEN_PORT_BASE) << 3) + LEDS_GREEN_PIN;
|
||||
gpio_hal_pin_t out_pin2 = (BASE_TO_PORT_NUM(LEDS_BLUE_PORT_BASE) << 3) + LEDS_BLUE_PIN;
|
||||
gpio_hal_pin_t out_pin3 = (BASE_TO_PORT_NUM(LEDS_RED_PORT_BASE) << 3) + LEDS_RED_PIN;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_t btn_pin = (BUTTON_USER_PORT << 3) + BUTTON_USER_PIN;
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -37,6 +37,7 @@
|
|||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "services/lwm2m/lwm2m-engine.h"
|
||||
#include "services/lwm2m/lwm2m-rd-client.h"
|
||||
#include "services/lwm2m/lwm2m-device.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "net/netstack.h"
|
||||
#include "net/ipv6/simple-udp.h"
|
||||
#include "net/ipv6/uipbuf.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "App"
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "dev/cc2538-sensors.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* IBM server: messaging.quickstart.internetofthings.ibmcloud.com
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "dev/leds.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* IBM server: quickstart.messaging.internetofthings.ibmcloud.com
|
||||
|
|
|
@ -3,7 +3,7 @@ CONTIKI_PROJECT += test-bmp085-bmp180 test-motion test-rotation-sensor
|
|||
CONTIKI_PROJECT += test-grove-light-sensor test-grove-loudness-sensor
|
||||
CONTIKI_PROJECT += test-weather-meter test-grove-gyro test-lcd test-iaq
|
||||
CONTIKI_PROJECT += test-pm10-sensor test-vac-sensor test-aac-sensor
|
||||
CONTIKI_PROJECT += test-zonik test-dht22.c test-ac-dimmer.c test-servo.c
|
||||
CONTIKI_PROJECT += test-zonik test-dht22.c test-ac-dimmer.c
|
||||
CONTIKI_PROJECT += test-bme280
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += tsl256x.c sht25.c bmpx8x.c motion-sensor.c
|
||||
|
|
|
@ -2,5 +2,5 @@ CONTIKI_PROJECT = at-master-test
|
|||
MODULES = os/services/at-master
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CONTIKI = ../../..
|
||||
CONTIKI = ../../../..
|
||||
include $(CONTIKI)/Makefile.include
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "dev/ioc.h"
|
||||
#include "lib/list.h"
|
||||
#include "dev/sha256.h"
|
||||
#include "net/linkaddr.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
TARGET = zoul
|
||||
BOARD = orion
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
TARGET = zoul
|
||||
BOARD = remote-revb
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* 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 gpio-hal
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the platform-independent aspects of the GPIO HAL
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "lib/list.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
LIST(handlers);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_register_handler(gpio_hal_event_handler_t *handler)
|
||||
{
|
||||
list_add(handlers, handler);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_event_handler(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
gpio_hal_event_handler_t *this;
|
||||
|
||||
for(this = list_head(handlers); this != NULL; this = this->next) {
|
||||
if(pins & this->pin_mask) {
|
||||
if(this->handler != NULL) {
|
||||
this->handler(pins & this->pin_mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_init()
|
||||
{
|
||||
list_init(handlers);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if GPIO_HAL_ARCH_SW_TOGGLE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_toggle_pin(gpio_hal_pin_t pin)
|
||||
{
|
||||
if(pin >= GPIO_HAL_PIN_COUNT) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpio_hal_arch_write_pin(pin, gpio_hal_arch_read_pin(pin) ^ 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_toggle_pins(gpio_hal_pin_mask_t pins)
|
||||
{
|
||||
gpio_hal_arch_write_pins(pins, ~gpio_hal_arch_read_pins(pins));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_SW_TOGGLE */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,495 @@
|
|||
/*
|
||||
* 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 dev
|
||||
* @{
|
||||
*
|
||||
* \defgroup gpio-hal GPIO Hardware Abstraction Layer
|
||||
*
|
||||
* The GPIO HAL provides a set of common functions that can be used in a
|
||||
* platform-independent fashion.
|
||||
*
|
||||
* Internally, the GPIO HAL handles edge detection handling and also provides
|
||||
* fallback functions for GPIO pin toggling if the hardware does not have
|
||||
* a direct method of toggling pins through direct register access.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the GPIO HAL
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef GPIO_HAL_H_
|
||||
#define GPIO_HAL_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Specifies whether software-based pin toggle is required
|
||||
*
|
||||
* Some MCUs allow GPIO pin toggling via direct register access. For these
|
||||
* MCUs, define GPIO_HAL_CONF_ARCH_SW_TOGGLE to 0 and then implement
|
||||
* gpio_hal_arch_toggle_pin() and gpio_hal_arch_toggle_pins()
|
||||
*
|
||||
* \sa gpio_hal_arch_toggle_pin()
|
||||
* \sa gpio_hal_arch_toggle_pins()
|
||||
*/
|
||||
#ifdef GPIO_HAL_CONF_ARCH_SW_TOGGLE
|
||||
#define GPIO_HAL_ARCH_SW_TOGGLE GPIO_HAL_CONF_ARCH_SW_TOGGLE
|
||||
#else
|
||||
#define GPIO_HAL_ARCH_SW_TOGGLE 1
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief GPIO pin number representation
|
||||
*/
|
||||
typedef uint8_t gpio_hal_pin_t;
|
||||
|
||||
/**
|
||||
* \brief GPIO pin configuration
|
||||
*
|
||||
* A logical representation of a pin's configuration. It is an OR combination
|
||||
* of GPIO_HAL_PIN_CFG_xyz macros.
|
||||
*/
|
||||
typedef uint8_t gpio_hal_pin_cfg_t;
|
||||
|
||||
#ifdef GPIO_HAL_CONF_PIN_COUNT
|
||||
#define GPIO_HAL_PIN_COUNT GPIO_HAL_CONF_PIN_COUNT
|
||||
#else
|
||||
#define GPIO_HAL_PIN_COUNT 32
|
||||
#endif
|
||||
|
||||
#if GPIO_HAL_PIN_COUNT > 32
|
||||
typedef uint64_t gpio_hal_pin_mask_t;
|
||||
#else
|
||||
/**
|
||||
* \brief GPIO pin mask representation
|
||||
*/
|
||||
typedef uint32_t gpio_hal_pin_mask_t;
|
||||
#endif
|
||||
|
||||
typedef void (*gpio_hal_callback_t)(gpio_hal_pin_mask_t pin_mask);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define GPIO_HAL_PIN_CFG_PULL_NONE 0x00
|
||||
#define GPIO_HAL_PIN_CFG_PULL_UP 0x01
|
||||
#define GPIO_HAL_PIN_CFG_PULL_DOWN 0x02
|
||||
#define GPIO_HAL_PIN_CFG_PULL_MASK (GPIO_HAL_PIN_CFG_PULL_UP | \
|
||||
GPIO_HAL_PIN_CFG_PULL_DOWN)
|
||||
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_NONE 0x00
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_RISING 0x04
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_FALLING 0x08
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_BOTH (GPIO_HAL_PIN_CFG_EDGE_RISING | \
|
||||
GPIO_HAL_PIN_CFG_EDGE_FALLING)
|
||||
|
||||
#define GPIO_HAL_PIN_CFG_INT_DISABLE 0x00
|
||||
#define GPIO_HAL_PIN_CFG_INT_ENABLE 0x80
|
||||
#define GPIO_HAL_PIN_CFG_INT_MASK 0x80
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Datatype for GPIO event handlers
|
||||
*
|
||||
* A GPIO event handler is a function that gets called whenever a pin triggers
|
||||
* an event. The same handler can be registered to handle events for more than
|
||||
* one pin by setting the respective pin's position but in \e pin_mask.
|
||||
*/
|
||||
typedef struct gpio_hal_event_handler_s {
|
||||
struct gpio_hal_event_handler_s *next;
|
||||
gpio_hal_callback_t handler;
|
||||
gpio_hal_pin_mask_t pin_mask;
|
||||
} gpio_hal_event_handler_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Core GPIO functions
|
||||
*
|
||||
* Functions implemented by the HAL itself
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \brief Initialise the GPIO HAL
|
||||
*/
|
||||
void gpio_hal_init(void);
|
||||
|
||||
/**
|
||||
* \brief Register a function to be called whenever a pin triggers an event
|
||||
* \param handler The handler representation
|
||||
*
|
||||
* The handler must be pre-allocated statically by the caller.
|
||||
*
|
||||
* This function can be used to register a function to be called by the HAL
|
||||
* whenever a GPIO interrupt occurs.
|
||||
*
|
||||
* \sa gpio_hal_event_handler
|
||||
*/
|
||||
void gpio_hal_register_handler(gpio_hal_event_handler_t *handler);
|
||||
|
||||
/**
|
||||
* \brief The platform-independent GPIO event handler
|
||||
* \param pins OR mask of pins that generated an event
|
||||
*
|
||||
* Whenever a GPIO input interrupt occurs (edge or level detection) and an ISR
|
||||
* is triggered, the ISR must call this function, passing as argument an ORd
|
||||
* mask of the pins that triggered the interrupt. This function will then
|
||||
* call the registered event handlers (if any) for the pins that triggered the
|
||||
* event. The platform code should make no assumptions as to the order that
|
||||
* the handlers will be called.
|
||||
*
|
||||
* If a pin set in the mask has an event handler registered, this function
|
||||
* will call the registered handler.
|
||||
*
|
||||
* This function will not clear any CPU interrupt flags, this should be done
|
||||
* by the calling ISR.
|
||||
*
|
||||
* \sa gpio_hal_register_handler
|
||||
*/
|
||||
void gpio_hal_event_handler(gpio_hal_pin_mask_t pins);
|
||||
|
||||
/**
|
||||
* \brief Convert a pin to a pin mask
|
||||
* \param pin The pin
|
||||
* \return The corresponding mask
|
||||
*/
|
||||
#define gpio_hal_pin_to_mask(pin) (1 << (pin))
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Functions to be provided by the platform
|
||||
*
|
||||
* All the functions below must be provided by the platform's developer. The
|
||||
* HAL offers the developer a number of options of how to provide the required
|
||||
* functionality.
|
||||
*
|
||||
* - The developer can provide a symbol. For example, the developer can create
|
||||
* a .c file and implement a function called gpio_hal_arch_set_pin()
|
||||
* - The developer can provide a function-like macro that has the same name as
|
||||
* the function declared here. In this scenario, the declaration here will
|
||||
* be removed by the pre-processor. For example, the developer can do
|
||||
* something like:
|
||||
*
|
||||
* \code
|
||||
* #define gpio_hal_arch_write_pin(p, v) platform_sdk_function(p, v)
|
||||
* \endcode
|
||||
*
|
||||
* - The developer can provide a static inline implementation. For this to
|
||||
* work, the developer can do something like:
|
||||
*
|
||||
* \code
|
||||
* #define gpio_hal_arch_set_pin(p) set_pin(p)
|
||||
* static inline void set_pin(gpio_hal_pin_t pin) { ... }
|
||||
* \endcode
|
||||
*
|
||||
* In the latter two cases, the developer will likely provide implementations
|
||||
* in a header file. In this scenario, one of the platform's configuration
|
||||
* files must define GPIO_HAL_CONF_ARCH_HDR_PATH to the name of this header
|
||||
* file. For example:
|
||||
*
|
||||
* \code
|
||||
* #define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
|
||||
* \endcode
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Include Arch-Specific conf */
|
||||
#ifdef GPIO_HAL_CONF_ARCH_HDR_PATH
|
||||
#include GPIO_HAL_CONF_ARCH_HDR_PATH
|
||||
#endif /* GPIO_HAL_CONF_ARCH_HDR_PATH */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_interrupt_enable
|
||||
/**
|
||||
* \brief Enable interrupts for a gpio pin
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_interrupt_disable
|
||||
/**
|
||||
* \brief Disable interrupts for a gpio pin
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_interrupt_disable(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_pin_cfg_set
|
||||
/**
|
||||
* \brief Configure a gpio pin
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
* \param cfg The configuration
|
||||
*
|
||||
* \e cfg is an OR mask of GPIO_HAL_PIN_CFG_xyz
|
||||
*
|
||||
* The implementation of this function also has to make sure that \e pin is
|
||||
* configured as software-controlled GPIO.
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_pin_cfg_get
|
||||
/**
|
||||
* \brief Read the configuration of a GPIO pin
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
* \return An OR mask of GPIO_HAL_PIN_CFG_xyz
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
gpio_hal_pin_cfg_t gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_pin_set_input
|
||||
/**
|
||||
* \brief Configure a pin as GPIO input
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
*
|
||||
* The implementation of this function also has to make sure that \e pin is
|
||||
* configured as software-controlled GPIO.
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_pin_set_input(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_pin_set_output
|
||||
/**
|
||||
* \brief Configure a pin as GPIO output
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
*
|
||||
* The implementation of this function also has to make sure that \e pin is
|
||||
* configured as software-controlled GPIO.
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_pin_set_output(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_set_pin
|
||||
/**
|
||||
* \brief Set a GPIO pin to logical high
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_set_pin(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_clear_pin
|
||||
/**
|
||||
* \brief Clear a GPIO pin (logical low)
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_clear_pin(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_toggle_pin
|
||||
/**
|
||||
* \brief Toggle a GPIO pin
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
*
|
||||
* Some MCUs allow GPIO pin toggling directly via register access. In this
|
||||
* case, it is a good idea to provide an implementation of this function.
|
||||
* However, a default, software-based implementation is also provided by the
|
||||
* HAL and can be used if the MCU does not have a pin toggle register. To use
|
||||
* the HAL function, define GPIO_HAL_ARCH_SW_TOGGLE as 1. To provide your own
|
||||
* implementation, define GPIO_HAL_ARCH_SW_TOGGLE as 0.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_toggle_pin(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_read_pin
|
||||
/**
|
||||
* \brief Read a GPIO pin
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
* \retval 0 The pin is logical low
|
||||
* \retval 1 The pin is logical high
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
uint8_t gpio_hal_arch_read_pin(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_write_pin
|
||||
/**
|
||||
* \brief Write a GPIO pin
|
||||
* \param pin The GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
|
||||
* \param value 0: Logical low; 1: Logical high
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_write_pin(gpio_hal_pin_t pin, uint8_t value);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_set_pins
|
||||
/**
|
||||
* \brief Set multiple pins to logical high
|
||||
* \param pins An ORd pin mask of the pins to set
|
||||
*
|
||||
* A pin will be set to logical high if its position in \e pins is set. For
|
||||
* example you can set pins 0 and 3 by passing 0x09.
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_set_pins(gpio_hal_pin_mask_t pins);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_clear_pins
|
||||
/**
|
||||
* \brief Clear multiple pins to logical low
|
||||
* \param pins An ORd pin mask of the pins to clear
|
||||
*
|
||||
* A pin will be set to logical low if its position in \e pins is set. For
|
||||
* example you can clear pins 0 and 3 by passing 0x09.
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_clear_pins(gpio_hal_pin_mask_t pins);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_toggle_pins
|
||||
/**
|
||||
* \brief Toggle multiple pins
|
||||
* \param pins An ORd pin mask of the pins to toggle
|
||||
*
|
||||
* A pin will be toggled if its position in \e pins is set. For example you
|
||||
* can toggle pins 0 and 3 by passing 0x09.
|
||||
*
|
||||
* Some MCUs allow GPIO pin toggling directly via register access. In this
|
||||
* case, it is a good idea to provide an implementation of this function.
|
||||
* However, a default, software-based implementation is also provided by the
|
||||
* HAL and can be used if the MCU does not have a pin toggle register. To use
|
||||
* the HAL function, define GPIO_HAL_ARCH_SW_TOGGLE as 1. To provide your own
|
||||
* implementation, define GPIO_HAL_ARCH_SW_TOGGLE as 0.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_toggle_pins(gpio_hal_pin_mask_t pins);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_read_pins
|
||||
/**
|
||||
* \brief Read multiple pins
|
||||
* \param pins An ORd pin mask of the pins to read
|
||||
* \retval An ORd mask of the pins that are high
|
||||
*
|
||||
* If the position of the pin in \e pins is set and the pin is logical high
|
||||
* then the position of the pin in the return value will be set. For example,
|
||||
* if you pass 0x09 as the value of \e pins and the return value is 0x08 then
|
||||
* pin 3 is logical high and pin 0 is logical low.
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
gpio_hal_pin_mask_t gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_write_pins
|
||||
/**
|
||||
* \brief Write multiple pins
|
||||
* \param pins An ORd pin mask of the pins to write
|
||||
* \param value An ORd mask of the value to write
|
||||
*
|
||||
* The function will modify GPIO pins that have their position in the mask set.
|
||||
* pins, the function will write the value specified in the corresponding
|
||||
* position in \e value.
|
||||
|
||||
* For example, you can set pin 3 and clear pin 0 by a single call to this
|
||||
* function. To achieve this, \e pins must be 0x09 and \e value 0x08.
|
||||
*
|
||||
* It is the platform developer's responsibility to provide an implementation.
|
||||
*
|
||||
* There is no guarantee that this function will result in an atomic operation.
|
||||
*
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_write_pins(gpio_hal_pin_mask_t pins,
|
||||
gpio_hal_pin_mask_t value);
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -671,8 +671,8 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
|
|||
int ext_hdr_len;
|
||||
struct uip_udp_hdr *udp_buf;
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
{ uint16_t ndx;
|
||||
if(LOG_DBG_ENABLED) {
|
||||
uint16_t ndx;
|
||||
LOG_DBG("before compression (%d): ", UIP_IP_BUF->len[1]);
|
||||
for(ndx = 0; ndx < UIP_IP_BUF->len[1] + 40; ndx++) {
|
||||
uint8_t data = ((uint8_t *) (UIP_IP_BUF))[ndx];
|
||||
|
@ -680,7 +680,6 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
|
|||
}
|
||||
LOG_DBG("\n");
|
||||
}
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
|
||||
hc06_ptr = PACKETBUF_IPHC_BUF + 2;
|
||||
/*
|
||||
|
@ -996,16 +995,15 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
|
|||
PACKETBUF_IPHC_BUF[0] = iphc0;
|
||||
PACKETBUF_IPHC_BUF[1] = iphc1;
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
{ uint16_t ndx;
|
||||
if(LOG_DBG_ENABLED) {
|
||||
uint16_t ndx;
|
||||
LOG_DBG("after compression %d: ", (int)(hc06_ptr - packetbuf_ptr));
|
||||
for(ndx = 0; ndx < hc06_ptr - packetbuf_ptr; ndx++) {
|
||||
uint8_t data = ((uint8_t *) packetbuf_ptr)[ndx];
|
||||
LOG_DBG("%02x", data);
|
||||
}
|
||||
LOG_DBG("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
packetbuf_hdr_len = hc06_ptr - packetbuf_ptr;
|
||||
}
|
||||
|
@ -1906,8 +1904,7 @@ input(void)
|
|||
LOG_INFO("input: IP packet ready (length %d)\n",
|
||||
uip_len);
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
{
|
||||
if(LOG_DBG_ENABLED) {
|
||||
uint16_t ndx;
|
||||
LOG_DBG("after decompression %u:", UIP_IP_BUF->len[1]);
|
||||
for (ndx = 0; ndx < UIP_IP_BUF->len[1] + 40; ndx++) {
|
||||
|
@ -1916,7 +1913,6 @@ input(void)
|
|||
}
|
||||
LOG_DBG("\n");
|
||||
}
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
|
||||
/* if callback is set then set attributes and call */
|
||||
if(callback) {
|
||||
|
|
|
@ -103,7 +103,6 @@ LIST(notificationlist);
|
|||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if LOG_DBG_ENABLED
|
||||
static void
|
||||
assert_nbr_routes_list_sane(void)
|
||||
{
|
||||
|
@ -131,7 +130,6 @@ assert_nbr_routes_list_sane(void)
|
|||
}
|
||||
#endif /* (UIP_MAX_ROUTES != 0) */
|
||||
}
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if UIP_DS6_NOTIFICATIONS
|
||||
static void
|
||||
|
@ -330,9 +328,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
|||
uip_ds6_route_t *r;
|
||||
struct uip_ds6_route_neighbor_route *nbrr;
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
|
||||
if(ipaddr == NULL || nexthop == NULL) {
|
||||
return NULL;
|
||||
|
@ -473,9 +471,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
|||
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_ADD, ipaddr, nexthop);
|
||||
#endif
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
return r;
|
||||
|
||||
#else /* (UIP_MAX_ROUTES != 0) */
|
||||
|
@ -489,9 +487,11 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
|
|||
{
|
||||
#if (UIP_MAX_ROUTES != 0)
|
||||
struct uip_ds6_route_neighbor_route *neighbor_route;
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
|
||||
if(route != NULL && route->neighbor_routes != NULL) {
|
||||
|
||||
LOG_INFO("Rm: removing route: ");
|
||||
|
@ -541,9 +541,9 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
|
||||
#endif /* (UIP_MAX_ROUTES != 0) */
|
||||
return;
|
||||
|
@ -553,9 +553,10 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
|
|||
static void
|
||||
rm_routelist(struct uip_ds6_route_neighbor_routes *routes)
|
||||
{
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
|
||||
if(routes != NULL && routes->route_list != NULL) {
|
||||
struct uip_ds6_route_neighbor_route *r;
|
||||
r = list_head(routes->route_list);
|
||||
|
@ -565,9 +566,10 @@ rm_routelist(struct uip_ds6_route_neighbor_routes *routes)
|
|||
}
|
||||
nbr_table_remove(nbr_routes, routes);
|
||||
}
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
|
@ -603,9 +605,9 @@ uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
|
|||
{
|
||||
uip_ds6_defrt_t *d;
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
|
||||
if(ipaddr == NULL) {
|
||||
return NULL;
|
||||
|
@ -643,9 +645,9 @@ uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
|
|||
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_ADD, ipaddr, ipaddr);
|
||||
#endif
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
@ -655,9 +657,9 @@ uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt)
|
|||
{
|
||||
uip_ds6_defrt_t *d;
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
|
||||
/* Make sure that the defrt is in the list before we remove it. */
|
||||
for(d = list_head(defaultrouterlist);
|
||||
|
@ -675,10 +677,10 @@ uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt)
|
|||
return;
|
||||
}
|
||||
}
|
||||
#if LOG_DBG_ENABLED
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
|
||||
if(LOG_DBG_ENABLED) {
|
||||
assert_nbr_routes_list_sane();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uip_ds6_defrt_t *
|
||||
|
|
|
@ -217,13 +217,13 @@ uip_sr_periodic(unsigned seconds)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#if LOG_INFO_ENABLED
|
||||
uip_ipaddr_t node_addr;
|
||||
NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, l);
|
||||
LOG_INFO("NS: removing expired node ");
|
||||
LOG_INFO_6ADDR(&node_addr);
|
||||
LOG_INFO_("\n");
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
if(LOG_INFO_ENABLED) {
|
||||
uip_ipaddr_t node_addr;
|
||||
NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, l);
|
||||
LOG_INFO("NS: removing expired node ");
|
||||
LOG_INFO_6ADDR(&node_addr);
|
||||
LOG_INFO_("\n");
|
||||
}
|
||||
/* No child found, deallocate node */
|
||||
list_remove(nodelist, l);
|
||||
memb_free(&nodememb, l);
|
||||
|
|
|
@ -94,9 +94,9 @@ extern struct tsch_asn_divisor_t tsch_hopping_sequence_length;
|
|||
/* TSCH timeslot timing (in rtimer ticks) */
|
||||
extern rtimer_clock_t tsch_timing[tsch_ts_elements_count];
|
||||
/* Statistics on the current session */
|
||||
unsigned long tx_count;
|
||||
unsigned long rx_count;
|
||||
unsigned long sync_count;
|
||||
extern unsigned long tx_count;
|
||||
extern unsigned long rx_count;
|
||||
extern unsigned long sync_count;
|
||||
|
||||
/* TSCH processes */
|
||||
PROCESS_NAME(tsch_process);
|
||||
|
|
|
@ -452,16 +452,15 @@ tsch_schedule_print(void)
|
|||
if(!tsch_is_locked()) {
|
||||
struct tsch_slotframe *sf = list_head(slotframe_list);
|
||||
|
||||
printf("Schedule: slotframe list\n");
|
||||
LOG_PRINT("----- start slotframe list -----\n");
|
||||
|
||||
while(sf != NULL) {
|
||||
struct tsch_link *l = list_head(sf->links_list);
|
||||
|
||||
printf("[Slotframe] Handle %u, size %u\n", sf->handle, sf->size.val);
|
||||
printf("List of links:\n");
|
||||
LOG_PRINT("Slotframe Handle %u, size %u\n", sf->handle, sf->size.val);
|
||||
|
||||
while(l != NULL) {
|
||||
printf("[Link] Options %02x, type %u, timeslot %u, channel offset %u, address %u\n",
|
||||
LOG_PRINT("* Link Options %02x, type %u, timeslot %u, channel offset %u, address %u\n",
|
||||
l->link_options, l->link_type, l->timeslot, l->channel_offset, l->addr.u8[7]);
|
||||
l = list_item_next(l);
|
||||
}
|
||||
|
@ -469,7 +468,7 @@ tsch_schedule_print(void)
|
|||
sf = list_item_next(sf);
|
||||
}
|
||||
|
||||
printf("Schedule: end of slotframe list\n");
|
||||
LOG_PRINT("----- end slotframe list -----\n");
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -185,9 +185,9 @@ rpl_global_repair(const char *str)
|
|||
if(rpl_dag_root_is_root()) {
|
||||
LOG_WARN("initiating global repair (%s), version %u, rank %u)\n",
|
||||
str, curr_instance.dag.version, curr_instance.dag.rank);
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Global repair (before)");
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
if(LOG_INFO_ENABLED) {
|
||||
rpl_neighbor_print_list("Global repair (before)");
|
||||
}
|
||||
|
||||
/* Initiate global repair */
|
||||
RPL_LOLLIPOP_INCREMENT(curr_instance.dag.version); /* New DAG version */
|
||||
|
@ -202,9 +202,9 @@ global_repair_non_root(rpl_dio_t *dio)
|
|||
if(!rpl_dag_root_is_root()) {
|
||||
LOG_WARN("participating in global repair, version %u, rank %u)\n",
|
||||
curr_instance.dag.version, curr_instance.dag.rank);
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Global repair (before)");
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
if(LOG_INFO_ENABLED) {
|
||||
rpl_neighbor_print_list("Global repair (before)");
|
||||
}
|
||||
/* Re-initialize configuration from DIO */
|
||||
init_dag_from_dio(dio);
|
||||
rpl_local_repair("Global repair");
|
||||
|
@ -325,9 +325,9 @@ rpl_dag_update_state(void)
|
|||
rpl_timers_schedule_leaving();
|
||||
}
|
||||
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Parent switch");
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
if(LOG_INFO_ENABLED) {
|
||||
rpl_neighbor_print_list("Parent switch");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,19 +65,7 @@ static int num_parents; /* all nodes that are possible parents */
|
|||
static int num_free;
|
||||
static linkaddr_t *worst_rank_nbr_lladdr; /* lladdr of the the neighbor with the worst rank */
|
||||
static rpl_rank_t worst_rank;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if LOG_DBG_ENABLED
|
||||
/* Print out state periodically */
|
||||
static void update_state(void);
|
||||
static struct ctimer periodic_timer;
|
||||
static int timer_init = 0;
|
||||
static void
|
||||
handle_periodic_timer(void *ptr)
|
||||
{
|
||||
update_state();
|
||||
ctimer_restart(&periodic_timer);
|
||||
}
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
update_state(void)
|
||||
|
@ -87,14 +75,6 @@ update_state(void)
|
|||
rpl_rank_t nbr_rank;
|
||||
int num_used = 0;
|
||||
|
||||
#if LOG_DBG_ENABLED
|
||||
if(!timer_init) {
|
||||
timer_init = 1;
|
||||
ctimer_set(&periodic_timer, 60 * CLOCK_SECOND,
|
||||
&handle_periodic_timer, NULL);
|
||||
}
|
||||
#endif /* LOG_DBG_ENABLED */
|
||||
|
||||
worst_rank = 0;
|
||||
worst_rank_nbr_lladdr = NULL;
|
||||
num_parents = 0;
|
||||
|
|
|
@ -514,9 +514,9 @@ handle_periodic_timer(void *ptr)
|
|||
the meaning of last_advertised_rank changes with time */
|
||||
rpl_dag_update_state();
|
||||
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Periodic");
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
if(LOG_INFO_ENABLED) {
|
||||
rpl_neighbor_print_list("Periodic");
|
||||
}
|
||||
|
||||
ctimer_reset(&periodic_timer);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
struct keyword {
|
||||
char *string;
|
||||
|
|
11
os/sys/log.h
11
os/sys/log.h
|
@ -145,27 +145,36 @@ extern struct log_module all_modules[];
|
|||
} while (0)
|
||||
|
||||
/* More compact versions of LOG macros */
|
||||
#define LOG_PRINT(...) LOG(1, 0, "PRI", __VA_ARGS__)
|
||||
#define LOG_ERR(...) LOG(1, LOG_LEVEL_ERR, "ERR", __VA_ARGS__)
|
||||
#define LOG_WARN(...) LOG(1, LOG_LEVEL_WARN, "WARN", __VA_ARGS__)
|
||||
#define LOG_INFO(...) LOG(1, LOG_LEVEL_INFO, "INFO", __VA_ARGS__)
|
||||
#define LOG_DBG(...) LOG(1, LOG_LEVEL_DBG, "DBG", __VA_ARGS__)
|
||||
|
||||
#define LOG_PRINT_(...) LOG(0, 0, "PRI", __VA_ARGS__)
|
||||
#define LOG_ERR_(...) LOG(0, LOG_LEVEL_ERR, "ERR", __VA_ARGS__)
|
||||
#define LOG_WARN_(...) LOG(0, LOG_LEVEL_WARN, "WARN", __VA_ARGS__)
|
||||
#define LOG_INFO_(...) LOG(0, LOG_LEVEL_INFO, "INFO", __VA_ARGS__)
|
||||
#define LOG_DBG_(...) LOG(0, LOG_LEVEL_DBG, "DBG", __VA_ARGS__)
|
||||
|
||||
#define LOG_PRINT_LLADDR(...) LOG_LLADDR(0, __VA_ARGS__)
|
||||
#define LOG_ERR_LLADDR(...) LOG_LLADDR(LOG_LEVEL_ERR, __VA_ARGS__)
|
||||
#define LOG_WARN_LLADDR(...) LOG_LLADDR(LOG_LEVEL_WARN, __VA_ARGS__)
|
||||
#define LOG_INFO_LLADDR(...) LOG_LLADDR(LOG_LEVEL_INFO, __VA_ARGS__)
|
||||
#define LOG_DBG_LLADDR(...) LOG_LLADDR(LOG_LEVEL_DBG, __VA_ARGS__)
|
||||
|
||||
#define LOG_PRINT_6ADDR(...) LOG_6ADDR(0, __VA_ARGS__)
|
||||
#define LOG_ERR_6ADDR(...) LOG_6ADDR(LOG_LEVEL_ERR, __VA_ARGS__)
|
||||
#define LOG_WARN_6ADDR(...) LOG_6ADDR(LOG_LEVEL_WARN, __VA_ARGS__)
|
||||
#define LOG_INFO_6ADDR(...) LOG_6ADDR(LOG_LEVEL_INFO, __VA_ARGS__)
|
||||
#define LOG_DBG_6ADDR(...) LOG_6ADDR(LOG_LEVEL_DBG, __VA_ARGS__)
|
||||
|
||||
/* For testing log level */
|
||||
/* For checking log level.
|
||||
As this builds on curr_log_level variables, this should not be used
|
||||
in pre-processor macros. Use in a C 'if' statement instead, e.g.:
|
||||
if(LOG_INFO_ENABLED) { ... }
|
||||
Note that most compilers will still be able to strip the code out
|
||||
for low enough log levels configurations. */
|
||||
#define LOG_ERR_ENABLED ((LOG_LEVEL) >= LOG_LEVEL_ERR)
|
||||
#define LOG_WARN_ENABLED ((LOG_LEVEL) >= LOG_LEVEL_WARN)
|
||||
#define LOG_INFO_ENABLED ((LOG_LEVEL) >= LOG_LEVEL_INFO)
|
||||
|
|
|
@ -14,6 +14,13 @@ platform-specific/cc26xx/very-sleepy-demo/srf06-cc26xx \
|
|||
rpl-border-router/srf06-cc26xx:BOARD=launchpad/cc2650 \
|
||||
sensniff/srf06-cc26xx \
|
||||
sensniff/srf06-cc26xx:BOARD=launchpad/cc1310 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=srf06/cc13xx \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=srf06/cc26xx \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=sensortag/cc1350 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=sensortag/cc2650 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=launchpad/cc1310 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=launchpad/cc1350 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=launchpad/cc2650 \
|
||||
6tisch/etsi-plugtest-2017/srf06-cc26xx:BOARD=launchpad/cc2650 \
|
||||
storage/cfs-coffee/cc2538dk \
|
||||
sensniff/cc2538dk \
|
||||
|
@ -22,6 +29,7 @@ coap/cc2538dk \
|
|||
slip-radio/cc2538dk \
|
||||
ipso-objects/cc2538dk \
|
||||
multicast/cc2538dk \
|
||||
dev/gpio-hal/cc2538dk \
|
||||
platform-specific/cc2538-common/cc2538dk \
|
||||
platform-specific/cc2538-common/mqtt-demo/cc2538dk \
|
||||
platform-specific/cc2538-common/crypto/cc2538dk \
|
||||
|
|
|
@ -8,6 +8,10 @@ platform-specific/cc2538-common/mqtt-demo/zoul \
|
|||
platform-specific/cc2538-common/crypto/zoul \
|
||||
platform-specific/cc2538-common/pka/zoul \
|
||||
platform-specific/zoul/orion/ip64-router/zoul:BOARD=orion \
|
||||
platform-specific/zoul/rev-b/zoul:BOARD=remote-revb \
|
||||
platform-specific/zoul/at-test/zoul \
|
||||
platform-specific/zoul/rtcc/zoul \
|
||||
platform-specific/zoul/zoul \
|
||||
coap/zoul \
|
||||
ipso-objects/zoul \
|
||||
ipso-objects/zoul:MAKE_WITH_DTLS=1 \
|
||||
|
@ -30,10 +34,16 @@ libs/trickle-library/zoul \
|
|||
libs/data-structures/zoul \
|
||||
nullnet/zoul \
|
||||
slip-radio/zoul \
|
||||
dev/gpio-hal/zoul:BOARD=remote-reva \
|
||||
dev/gpio-hal/zoul:BOARD=remote-revb \
|
||||
dev/gpio-hal/zoul:BOARD=firefly-reva \
|
||||
dev/gpio-hal/zoul:BOARD=firefly \
|
||||
dev/gpio-hal/zoul:BOARD=orion \
|
||||
storage/cfs-coffee/openmote-cc2538 \
|
||||
sensniff/openmote-cc2538 \
|
||||
hello-world/openmote-cc2538 \
|
||||
rpl-udp/openmote-cc2538 \
|
||||
dev/gpio-hal/openmote-cc2538 \
|
||||
rpl-border-router/openmote-cc2538
|
||||
|
||||
TOOLS=
|
||||
|
|
|
@ -62,10 +62,10 @@
|
|||
##### "TSCH_CONF_DEFAULT_TIMESLOT_LENGTH": _____ -> TSCH_DEFAULT_TIMESLOT_LENGTH
|
||||
#endif
|
||||
|
||||
#ifdef TSCH_CONF_SCHEDULE_DEFAULT_LENGTH
|
||||
##### "TSCH_CONF_SCHEDULE_DEFAULT_LENGTH": _____ == TSCH_CONF_SCHEDULE_DEFAULT_LENGTH
|
||||
#ifdef TSCH_SCHEDULE_CONF_DEFAULT_LENGTH
|
||||
##### "TSCH_SCHEDULE_CONF_DEFAULT_LENGTH": _____ == TSCH_SCHEDULE_CONF_DEFAULT_LENGTH
|
||||
#else
|
||||
##### "TSCH_CONF_SCHEDULE_DEFAULT_LENGTH": _____ -> TSCH_CHEDULE_DEFAULT_LENGTH
|
||||
##### "TSCH_SCHEDULE_CONF_DEFAULT_LENGTH": _____ -> TSCH_SCHEDULE_DEFAULT_LENGTH
|
||||
#endif
|
||||
|
||||
#else /* MAC_CONF_WITH_TSCH */
|
||||
|
|
Loading…
Reference in New Issue