Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
63725eff36
|
@ -69,3 +69,4 @@ env:
|
|||
- BUILD_TYPE='compile-8051-ports' BUILD_CATEGORY='compile' BUILD_ARCH='8051'
|
||||
- BUILD_TYPE='compile-arm-ports' BUILD_CATEGORY='compile' BUILD_ARCH='arm'
|
||||
- BUILD_TYPE='compile-6502-ports' BUILD_CATEGORY='compile' BUILD_ARCH='6502'
|
||||
- BUILD_TYPE='slip-radio' MAKE_TARGETS='cooja'
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
CONTIKI_SOURCEFILES += cxmac.c xmac.c nullmac.c lpp.c frame802154.c sicslowmac.c nullrdc.c nullrdc-noframer.c mac.c
|
||||
CONTIKI_SOURCEFILES += cxmac.c nullmac.c frame802154.c sicslowmac.c nullrdc.c nullrdc-noframer.c mac.c
|
||||
CONTIKI_SOURCEFILES += framer-nullmac.c framer-802154.c csma.c contikimac.c phase.c mac-sequence.c
|
||||
|
|
1054
core/net/mac/lpp.c
1054
core/net/mac/lpp.c
File diff suppressed because it is too large
Load diff
1009
core/net/mac/xmac.c
1009
core/net/mac/xmac.c
File diff suppressed because it is too large
Load diff
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A simple power saving MAC protocol based on X-MAC [SenSys 2006]
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef XMAC_H_
|
||||
#define XMAC_H_
|
||||
|
||||
#include "sys/rtimer.h"
|
||||
#include "net/mac/rdc.h"
|
||||
#include "dev/radio.h"
|
||||
|
||||
#define XMAC_RECEIVER "xmac.recv"
|
||||
#define XMAC_STROBES "xmac.strobes"
|
||||
#define XMAC_SEND_WITH_ACK "xmac.send.ack"
|
||||
#define XMAC_SEND_WITH_NOACK "xmac.send.noack"
|
||||
|
||||
|
||||
struct xmac_config {
|
||||
rtimer_clock_t on_time;
|
||||
rtimer_clock_t off_time;
|
||||
rtimer_clock_t strobe_time;
|
||||
rtimer_clock_t strobe_wait_time;
|
||||
};
|
||||
|
||||
extern const struct rdc_driver xmac_driver;
|
||||
|
||||
void xmac_set_announcement_radio_txpower(int txpower);
|
||||
|
||||
#endif /* XMAC_H_ */
|
|
@ -1832,8 +1832,12 @@ uip_process(uint8_t flag)
|
|||
UIP_TCP_BUF->seqno[2] != uip_connr->rcv_nxt[2] ||
|
||||
UIP_TCP_BUF->seqno[3] != uip_connr->rcv_nxt[3])) {
|
||||
|
||||
if(UIP_TCP_BUF->flags & TCP_SYN) {
|
||||
goto tcp_send_synack;
|
||||
if((UIP_TCP_BUF->flags & TCP_SYN)) {
|
||||
if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) {
|
||||
goto tcp_send_synack;
|
||||
} else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) {
|
||||
goto tcp_send_syn;
|
||||
}
|
||||
}
|
||||
goto tcp_send_ack;
|
||||
}
|
||||
|
@ -2315,12 +2319,23 @@ uip_send(const void *data, int len)
|
|||
{
|
||||
int copylen;
|
||||
#define MIN(a,b) ((a) < (b)? (a): (b))
|
||||
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN -
|
||||
(int)((char *)uip_sappdata - (char *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN]));
|
||||
|
||||
if(uip_sappdata != NULL) {
|
||||
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN -
|
||||
(int)((char *)uip_sappdata -
|
||||
(char *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN]));
|
||||
} else {
|
||||
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN);
|
||||
}
|
||||
if(copylen > 0) {
|
||||
uip_slen = copylen;
|
||||
if(data != uip_sappdata) {
|
||||
memcpy(uip_sappdata, (data), uip_slen);
|
||||
if(uip_sappdata == NULL) {
|
||||
memcpy((char *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN],
|
||||
(data), uip_slen);
|
||||
} else {
|
||||
memcpy(uip_sappdata, (data), uip_slen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,11 @@
|
|||
*
|
||||
* This should normally not be changed.
|
||||
*/
|
||||
#ifdef UIP_CONF_TTL
|
||||
#define UIP_TTL UIP_CONF_TTL
|
||||
#else /* UIP_CONF_TTL */
|
||||
#define UIP_TTL 64
|
||||
#endif /* UIP_CONF_TTL */
|
||||
|
||||
/**
|
||||
* The maximum time an IP fragment should wait in the reassembly
|
||||
|
@ -378,7 +382,10 @@
|
|||
* UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
|
||||
*/
|
||||
#ifdef UIP_CONF_TCP_MSS
|
||||
#define UIP_TCP_MSS (UIP_CONF_TCP_MSS)
|
||||
#if UIP_CONF_TCP_MSS < (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
|
||||
#error UIP_CONF_TCP_MSS is too large for the current UIP_BUFSIZE
|
||||
#endif /* UIP_CONF_TCP_MSS < (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) */
|
||||
#define UIP_TCP_MSS (UIP_CONF_TCP_MSS)
|
||||
#else
|
||||
#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
|
||||
#endif
|
||||
|
|
|
@ -34,17 +34,22 @@
|
|||
* ld script, which is called cc2538.ld and will be in the project directory
|
||||
*/
|
||||
#if (LPM_CONF_MAX_PM==2) && (LPM_CONF_ENABLE != 0)
|
||||
#define SRAM_START 0x20004000
|
||||
#define SRAM_LEN 0x00004000
|
||||
#define NRSRAM_START 0x20000000
|
||||
#define NRSRAM_LEN 0x00004000
|
||||
#define SRAM_START 0x20004000
|
||||
#define SRAM_LEN 0x00004000
|
||||
#else
|
||||
#define SRAM_START 0x20000000
|
||||
#define SRAM_LEN 0x00008000
|
||||
#define SRAM_START 0x20000000
|
||||
#define SRAM_LEN 0x00008000
|
||||
#endif
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x200000, LENGTH = 0x0007FFD4
|
||||
FLASH_CCA (RX) : ORIGIN = 0x0027FFD4, LENGTH = 12
|
||||
FLASH_CCA (RX) : ORIGIN = 0x0027FFD4, LENGTH = 44
|
||||
#if (LPM_CONF_MAX_PM==2) && (LPM_CONF_ENABLE != 0)
|
||||
NRSRAM (RWX) : ORIGIN = NRSRAM_START, LENGTH = NRSRAM_LEN
|
||||
#endif
|
||||
SRAM (RWX) : ORIGIN = SRAM_START, LENGTH = SRAM_LEN
|
||||
}
|
||||
|
||||
|
@ -80,6 +85,15 @@ SECTIONS
|
|||
_ebss = .;
|
||||
} > SRAM
|
||||
|
||||
#if (LPM_CONF_MAX_PM==2) && (LPM_CONF_ENABLE != 0)
|
||||
.nrdata :
|
||||
{
|
||||
_nrdata = .;
|
||||
*(.nrdata*)
|
||||
_enrdata = .;
|
||||
} > NRSRAM
|
||||
#endif
|
||||
|
||||
.flashcca :
|
||||
{
|
||||
KEEP(*(.flashcca))
|
||||
|
|
93
cpu/cc2538/dev/flash-cca.h
Normal file
93
cpu/cc2538/dev/flash-cca.h
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2013, ADVANSEE - http://www.advansee.com/
|
||||
* Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup cc2538
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc2538-flash-cca cc2538 flash CCA
|
||||
*
|
||||
* Definitions for the cc2538 flash lock bit page and customer configuration
|
||||
* area
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Header file for the flash lock bit page and CCA definitions
|
||||
*/
|
||||
#ifndef FLASH_CCA_H_
|
||||
#define FLASH_CCA_H_
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Bootloader backdoor configuration bit fields
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_CCA_BOOTLDR_CFG_DISABLE 0xEFFFFFFF /**< Disable backdoor function */
|
||||
#define FLASH_CCA_BOOTLDR_CFG_ENABLE 0xF0FFFFFF /**< Enable backdoor function */
|
||||
#define FLASH_CCA_BOOTLDR_CFG_ACTIVE_HIGH 0x08000000 /**< Selected pin on pad A active high */
|
||||
#define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_M 0x07000000 /**< Selected pin on pad A mask */
|
||||
#define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S 24 /**< Selected pin on pad A shift */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Image valid definitions
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_CCA_IMAGE_VALID 0x00000000 /**< Indicates valid image in flash */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Lock page / debug definitions
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_CCA_LOCKED 0 /**< Page or debug locked if bit == 0 */
|
||||
#define FLASH_CCA_LOCK_DEBUG_BYTE 31 /**< Lock byte containing the debug lock bit */
|
||||
#define FLASH_CCA_LOCK_DEBUG_BIT 7 /**< Debug lock bit position in the corresponding lock byte */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name Flash lock bit page and CCA layout
|
||||
* @{
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t bootldr_cfg; /**< Bootloader backdoor configuration (page bytes 2004 - 2007) */
|
||||
uint32_t image_valid; /**< Image valid (page bytes 2008 - 2011) */
|
||||
const void *app_entry_point; /**< Flash vector table address (page bytes 2012 - 2015) */
|
||||
uint8_t lock[32]; /**< Page and debug lock bits (page bytes 2016 - 2047) */
|
||||
} flash_cca_lock_page_t;
|
||||
/** @} */
|
||||
|
||||
#endif /* FLASH_CCA_H_ */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
|
@ -83,13 +83,14 @@ notify(uint8_t mask, uint8_t port)
|
|||
void
|
||||
gpio_port_a_isr()
|
||||
{
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
lpm_exit();
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
notify(REG(GPIO_A_BASE | GPIO_MIS), GPIO_A_NUM);
|
||||
|
||||
GPIO_CLEAR_INTERRUPT(GPIO_A_BASE, 0xFF);
|
||||
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_A_NUM, 0xFF);
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
}
|
||||
|
@ -98,13 +99,14 @@ gpio_port_a_isr()
|
|||
void
|
||||
gpio_port_b_isr()
|
||||
{
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
lpm_exit();
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
notify(REG(GPIO_B_BASE | GPIO_MIS), GPIO_B_NUM);
|
||||
|
||||
GPIO_CLEAR_INTERRUPT(GPIO_B_BASE, 0xFF);
|
||||
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_B_NUM, 0xFF);
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
}
|
||||
|
@ -113,13 +115,14 @@ gpio_port_b_isr()
|
|||
void
|
||||
gpio_port_c_isr()
|
||||
{
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
lpm_exit();
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
notify(REG(GPIO_C_BASE | GPIO_MIS), GPIO_C_NUM);
|
||||
|
||||
GPIO_CLEAR_INTERRUPT(GPIO_C_BASE, 0xFF);
|
||||
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_C_NUM, 0xFF);
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
}
|
||||
|
@ -128,13 +131,14 @@ gpio_port_c_isr()
|
|||
void
|
||||
gpio_port_d_isr()
|
||||
{
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
lpm_exit();
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
notify(REG(GPIO_D_BASE | GPIO_MIS), GPIO_D_NUM);
|
||||
|
||||
GPIO_CLEAR_INTERRUPT(GPIO_D_BASE, 0xFF);
|
||||
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_D_NUM, 0xFF);
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
}
|
||||
|
|
|
@ -214,6 +214,51 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
|
|||
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK) \
|
||||
do { REG((PORT_BASE) | GPIO_AFSEL) &= ~(PIN_MASK); } while(0)
|
||||
|
||||
/** \brief Set pins with PIN_MASK of port PORT to trigger a power-up interrupt
|
||||
* on rising edge.
|
||||
* \param PORT GPIO Port (not port base address)
|
||||
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
|
||||
*/
|
||||
#define GPIO_POWER_UP_ON_RISING(PORT, PIN_MASK) \
|
||||
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_P_EDGE_CTRL) &= \
|
||||
~((PIN_MASK) << ((PORT) << 3)); } while(0)
|
||||
|
||||
/** \brief Set pins with PIN_MASK of port PORT to trigger a power-up interrupt
|
||||
* on falling edge.
|
||||
* \param PORT GPIO Port (not port base address)
|
||||
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
|
||||
*/
|
||||
#define GPIO_POWER_UP_ON_FALLING(PORT, PIN_MASK) \
|
||||
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_P_EDGE_CTRL) |= \
|
||||
(PIN_MASK) << ((PORT) << 3); } while(0)
|
||||
|
||||
/** \brief Enable power-up interrupt triggering for pins with PIN_MASK of port
|
||||
* PORT.
|
||||
* \param PORT GPIO Port (not port base address)
|
||||
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
|
||||
*/
|
||||
#define GPIO_ENABLE_POWER_UP_INTERRUPT(PORT, PIN_MASK) \
|
||||
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_PI_IEN) |= \
|
||||
(PIN_MASK) << ((PORT) << 3); } while(0)
|
||||
|
||||
/** \brief Disable power-up interrupt triggering for pins with PIN_MASK of port
|
||||
* PORT.
|
||||
* \param PORT GPIO Port (not port base address)
|
||||
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
|
||||
*/
|
||||
#define GPIO_DISABLE_POWER_UP_INTERRUPT(PORT, PIN_MASK) \
|
||||
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_PI_IEN) &= \
|
||||
~((PIN_MASK) << ((PORT) << 3)); } while(0)
|
||||
|
||||
/** \brief Clear power-up interrupt triggering for pins with PIN_MASK of port
|
||||
* PORT.
|
||||
* \param PORT GPIO Port (not port base address)
|
||||
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
|
||||
*/
|
||||
#define GPIO_CLEAR_POWER_UP_INTERRUPT(PORT, PIN_MASK) \
|
||||
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_IRQ_DETECT_ACK) = \
|
||||
(PIN_MASK) << ((PORT) << 3); } while(0)
|
||||
|
||||
/**
|
||||
* \brief Converts a pin number to a pin mask
|
||||
* \param The pin number in the range [0..7]
|
||||
|
|
|
@ -42,6 +42,15 @@
|
|||
#include "dev/ssi.h"
|
||||
#include "dev/gpio.h"
|
||||
|
||||
#define SPI_CLK_PORT_BASE GPIO_PORT_TO_BASE(SPI_CLK_PORT)
|
||||
#define SPI_CLK_PIN_MASK GPIO_PIN_MASK(SPI_CLK_PIN)
|
||||
#define SPI_MOSI_PORT_BASE GPIO_PORT_TO_BASE(SPI_MOSI_PORT)
|
||||
#define SPI_MOSI_PIN_MASK GPIO_PIN_MASK(SPI_MOSI_PIN)
|
||||
#define SPI_MISO_PORT_BASE GPIO_PORT_TO_BASE(SPI_MISO_PORT)
|
||||
#define SPI_MISO_PIN_MASK GPIO_PIN_MASK(SPI_MISO_PIN)
|
||||
#define SPI_SEL_PORT_BASE GPIO_PORT_TO_BASE(SPI_SEL_PORT)
|
||||
#define SPI_SEL_PIN_MASK GPIO_PIN_MASK(SPI_SEL_PIN)
|
||||
|
||||
/* Default: Motorola mode 3 with 8-bit data words */
|
||||
#ifndef SPI_CONF_PHASE
|
||||
#define SPI_CONF_PHASE SSI_CR0_SPH
|
||||
|
@ -61,10 +70,10 @@
|
|||
* \brief Initialize the SPI bus.
|
||||
*
|
||||
* This SPI init() function uses the following #defines to set the pins:
|
||||
* CC2538_SPI_CLK_PORT_NUM CC2538_SPI_CLK_PIN_NUM
|
||||
* CC2538_SPI_MOSI_PORT_NUM CC2538_SPI_MOSI_PIN_NUM
|
||||
* CC2538_SPI_MISO_PORT_NUM CC2538_SPI_MISO_PIN_NUM
|
||||
* CC2538_SPI_SEL_PORT_NUM CC2538_SPI_SEL_PIN_NUM
|
||||
* SPI_CLK_PORT SPI_CLK_PIN
|
||||
* SPI_MOSI_PORT SPI_MOSI_PIN
|
||||
* SPI_MISO_PORT SPI_MISO_PIN
|
||||
* SPI_SEL_PORT SPI_SEL_PIN
|
||||
*
|
||||
* This sets the mode to Motorola SPI with the following format options:
|
||||
* SPI_CONF_PHASE: 0 or SSI_CR0_SPH
|
||||
|
@ -83,22 +92,22 @@ spi_init(void)
|
|||
REG(SSI0_BASE + SSI_CC) = 1;
|
||||
|
||||
/* Set the mux correctly to connect the SSI pins to the correct GPIO pins */
|
||||
ioc_set_sel(CC2538_SPI_CLK_PORT_NUM, CC2538_SPI_CLK_PIN_NUM, IOC_PXX_SEL_SSI0_CLKOUT);
|
||||
ioc_set_sel(CC2538_SPI_MOSI_PORT_NUM, CC2538_SPI_MOSI_PIN_NUM, IOC_PXX_SEL_SSI0_TXD);
|
||||
REG(IOC_SSIRXD_SSI0) = (CC2538_SPI_MISO_PORT_NUM * 8) + CC2538_SPI_MISO_PIN_NUM;
|
||||
ioc_set_sel(CC2538_SPI_SEL_PORT_NUM, CC2538_SPI_SEL_PIN_NUM, IOC_PXX_SEL_SSI0_FSSOUT);
|
||||
ioc_set_sel(SPI_CLK_PORT, SPI_CLK_PIN, IOC_PXX_SEL_SSI0_CLKOUT);
|
||||
ioc_set_sel(SPI_MOSI_PORT, SPI_MOSI_PIN, IOC_PXX_SEL_SSI0_TXD);
|
||||
REG(IOC_SSIRXD_SSI0) = (SPI_MISO_PORT * 8) + SPI_MISO_PIN;
|
||||
ioc_set_sel(SPI_SEL_PORT, SPI_SEL_PIN, IOC_PXX_SEL_SSI0_FSSOUT);
|
||||
|
||||
/* Put all the SSI gpios into peripheral mode */
|
||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_CLK_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_CLK_PIN_NUM));
|
||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_MOSI_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_MOSI_PIN_NUM));
|
||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_MISO_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_MISO_PIN_NUM));
|
||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_SEL_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_SEL_PIN_NUM));
|
||||
GPIO_PERIPHERAL_CONTROL(SPI_CLK_PORT_BASE, SPI_CLK_PIN_MASK);
|
||||
GPIO_PERIPHERAL_CONTROL(SPI_MOSI_PORT_BASE, SPI_MOSI_PIN_MASK);
|
||||
GPIO_PERIPHERAL_CONTROL(SPI_MISO_PORT_BASE, SPI_MISO_PIN_MASK);
|
||||
GPIO_PERIPHERAL_CONTROL(SPI_SEL_PORT_BASE, SPI_SEL_PIN_MASK);
|
||||
|
||||
/* Disable any pull ups or the like */
|
||||
ioc_set_over(CC2538_SPI_CLK_PORT_NUM, CC2538_SPI_CLK_PIN_NUM, IOC_OVERRIDE_DIS);
|
||||
ioc_set_over(CC2538_SPI_MOSI_PORT_NUM, CC2538_SPI_MOSI_PIN_NUM, IOC_OVERRIDE_DIS);
|
||||
ioc_set_over(CC2538_SPI_MISO_PORT_NUM, CC2538_SPI_MISO_PIN_NUM, IOC_OVERRIDE_DIS);
|
||||
ioc_set_over(CC2538_SPI_SEL_PORT_NUM, CC2538_SPI_SEL_PIN_NUM, IOC_OVERRIDE_DIS);
|
||||
ioc_set_over(SPI_CLK_PORT, SPI_CLK_PIN, IOC_OVERRIDE_DIS);
|
||||
ioc_set_over(SPI_MOSI_PORT, SPI_MOSI_PIN, IOC_OVERRIDE_DIS);
|
||||
ioc_set_over(SPI_MISO_PORT, SPI_MISO_PIN, IOC_OVERRIDE_DIS);
|
||||
ioc_set_over(SPI_SEL_PORT, SPI_SEL_PIN, IOC_OVERRIDE_DIS);
|
||||
|
||||
/* Configure the clock */
|
||||
REG(SSI0_BASE + SSI_CPSR) = 2;
|
||||
|
|
|
@ -50,6 +50,18 @@
|
|||
|
||||
static int (* input_handler)(unsigned char c);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define UART_RX_PORT_BASE GPIO_PORT_TO_BASE(UART_RX_PORT)
|
||||
#define UART_RX_PIN_MASK GPIO_PIN_MASK(UART_RX_PIN)
|
||||
|
||||
#define UART_TX_PORT_BASE GPIO_PORT_TO_BASE(UART_TX_PORT)
|
||||
#define UART_TX_PIN_MASK GPIO_PIN_MASK(UART_TX_PIN)
|
||||
|
||||
#define UART_CTS_PORT_BASE GPIO_PORT_TO_BASE(UART_CTS_PORT)
|
||||
#define UART_CTS_PIN_MASK GPIO_PIN_MASK(UART_CTS_PIN)
|
||||
|
||||
#define UART_RTS_PORT_BASE GPIO_PORT_TO_BASE(UART_RTS_PORT)
|
||||
#define UART_RTS_PIN_MASK GPIO_PIN_MASK(UART_RTS_PIN)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Once we know what UART we're on, configure correct values to be written to
|
||||
* the correct registers
|
||||
|
@ -138,8 +150,8 @@ uart_init(void)
|
|||
ioc_set_over(UART_TX_PORT, UART_TX_PIN, IOC_OVERRIDE_OE);
|
||||
|
||||
/* Set RX and TX pins to peripheral mode */
|
||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(UART_TX_PORT), GPIO_PIN_MASK(UART_TX_PIN));
|
||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(UART_RX_PORT), GPIO_PIN_MASK(UART_RX_PIN));
|
||||
GPIO_PERIPHERAL_CONTROL(UART_TX_PORT_BASE, UART_TX_PIN_MASK);
|
||||
GPIO_PERIPHERAL_CONTROL(UART_RX_PORT_BASE, UART_RX_PIN_MASK);
|
||||
|
||||
/*
|
||||
* UART Interrupt Masks:
|
||||
|
|
|
@ -158,16 +158,28 @@ enter_pm0(void)
|
|||
static void
|
||||
select_32_mhz_xosc(void)
|
||||
{
|
||||
/*First, make sure there is no ongoing clock source change */
|
||||
while((REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_SOURCE_CHANGE) != 0);
|
||||
|
||||
/* Turn on the 32 MHz XOSC and source the system clock on it. */
|
||||
REG(SYS_CTRL_CLOCK_CTRL) &= ~SYS_CTRL_CLOCK_CTRL_OSC;
|
||||
|
||||
/* Wait for the switch to take place */
|
||||
while((REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_OSC) != 0);
|
||||
|
||||
/* Power down the unused oscillator. */
|
||||
REG(SYS_CTRL_CLOCK_CTRL) |= SYS_CTRL_CLOCK_CTRL_OSC_PD;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
select_16_mhz_rcosc(void)
|
||||
{
|
||||
/*
|
||||
* Power up both oscillators in order to speed up the transition to the 32-MHz
|
||||
* XOSC after wake up.
|
||||
*/
|
||||
REG(SYS_CTRL_CLOCK_CTRL) &= ~SYS_CTRL_CLOCK_CTRL_OSC_PD;
|
||||
|
||||
/*First, make sure there is no ongoing clock source change */
|
||||
while((REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_SOURCE_CHANGE) != 0);
|
||||
|
||||
|
@ -187,6 +199,16 @@ lpm_exit()
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* When returning from PM1/2, the sleep timer value (used by RTIMER_NOW()) is
|
||||
* not up-to-date until a positive edge on the 32-kHz clock has been detected
|
||||
* after the system clock restarted. To ensure an updated value is read, wait
|
||||
* for a positive transition on the 32-kHz clock by polling the
|
||||
* SYS_CTRL_CLOCK_STA.SYNC_32K bit, before reading the sleep timer value.
|
||||
*/
|
||||
while(REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_SYNC_32K);
|
||||
while(!(REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_SYNC_32K));
|
||||
|
||||
LPM_STATS_ADD(REG(SYS_CTRL_PMCTL) & SYS_CTRL_PMCTL_PM3,
|
||||
RTIMER_NOW() - sleep_enter_time);
|
||||
|
||||
|
@ -301,6 +323,11 @@ lpm_enter()
|
|||
select_32_mhz_xosc();
|
||||
|
||||
REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0;
|
||||
|
||||
/* Remember IRQ energest for next pass */
|
||||
ENERGEST_IRQ_SAVE(irq_energest);
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
||||
} else {
|
||||
/* All clear. Assert WFI and drop to PM1/2. This is now un-interruptible */
|
||||
assert_wfi();
|
||||
|
|
|
@ -126,6 +126,12 @@ void lpm_init(void);
|
|||
* lpm_exit(), which will always be called from within the Sleep Timer ISR
|
||||
* context.
|
||||
*
|
||||
* \note Dropping to PM2 means that data in the SRAM non-retention area will
|
||||
* be lost. It is recommended to disable PM2 if the total RAM footprint is
|
||||
* larger than what will fit in the retention area.
|
||||
* .nrdata* sections can be used to place uninitialized data in the SRAM
|
||||
* non-retention area.
|
||||
*
|
||||
* \sa main(), rtimer_arch_next_trigger(), lpm_exit(), lpm_set_max_pm()
|
||||
*/
|
||||
void lpm_enter(void);
|
||||
|
@ -144,6 +150,12 @@ void lpm_enter(void);
|
|||
* interrupt. This may lead to other parts of the code trying to use the RF,
|
||||
* so we need to switch the clock source \e before said code gets executed.
|
||||
*
|
||||
* This function also makes sure that the sleep timer value is up-to-date
|
||||
* following wake-up from PM1/2 so that RTIMER_NOW() works.
|
||||
*
|
||||
* \note This function should be called at the very beginning of ISRs waking up
|
||||
* the SoC in order to restore all clocks and timers.
|
||||
*
|
||||
* \sa lpm_enter(), rtimer_isr()
|
||||
*/
|
||||
void lpm_exit(void);
|
||||
|
|
|
@ -136,13 +136,6 @@ rtimer_arch_now()
|
|||
void
|
||||
rtimer_isr()
|
||||
{
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
next_trigger = 0;
|
||||
|
||||
nvic_interrupt_unpend(NVIC_INT_SM_TIMER);
|
||||
nvic_interrupt_disable(NVIC_INT_SM_TIMER);
|
||||
|
||||
/*
|
||||
* If we were in PM1+, call the wake-up sequence first. This will make sure
|
||||
* that the 32MHz OSC is selected as the clock source. We need to do this
|
||||
|
@ -150,6 +143,13 @@ rtimer_isr()
|
|||
*/
|
||||
lpm_exit();
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
next_trigger = 0;
|
||||
|
||||
nvic_interrupt_unpend(NVIC_INT_SM_TIMER);
|
||||
nvic_interrupt_disable(NVIC_INT_SM_TIMER);
|
||||
|
||||
rtimer_run_next();
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
|
|
|
@ -54,6 +54,13 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef USB_PULLUP_PORT
|
||||
#define USB_PULLUP_PORT_BASE GPIO_PORT_TO_BASE(USB_PULLUP_PORT)
|
||||
#endif
|
||||
#ifdef USB_PULLUP_PIN
|
||||
#define USB_PULLUP_PIN_MASK GPIO_PIN_MASK(USB_PULLUP_PIN)
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* EP max FIFO sizes without double buffering */
|
||||
#if CTRL_EP_SIZE > 32
|
||||
#error Control endpoint size too big
|
||||
|
@ -329,9 +336,11 @@ usb_arch_setup(void)
|
|||
/* Wait until USB PLL is stable */
|
||||
while(!(REG(USB_CTRL) & USB_CTRL_PLL_LOCKED));
|
||||
|
||||
/* Enable pull-up on usb port */
|
||||
GPIO_SET_OUTPUT(USB_PULLUP_PORT, USB_PULLUP_PIN_MASK);
|
||||
GPIO_SET_PIN(USB_PULLUP_PORT, USB_PULLUP_PIN_MASK);
|
||||
/* Enable pull-up on usb port if driven by GPIO */
|
||||
#if defined(USB_PULLUP_PORT_BASE) && defined(USB_PULLUP_PIN_MASK)
|
||||
GPIO_SET_OUTPUT(USB_PULLUP_PORT_BASE, USB_PULLUP_PIN_MASK);
|
||||
GPIO_SET_PIN(USB_PULLUP_PORT_BASE, USB_PULLUP_PIN_MASK);
|
||||
#endif
|
||||
|
||||
for(i = 0; i < USB_MAX_ENDPOINTS; i++) {
|
||||
usb_endpoints[i].flags = 0;
|
||||
|
|
|
@ -410,7 +410,6 @@ LPM is highly related to the operations of the Radio Duty Cycling (RDC) driver o
|
|||
|
||||
* With ContikiMAC, PMs 0/1/2 are supported subject to user configuration.
|
||||
* When NullRDC is in use, the radio will be always on. As a result, the algorithm discussed above will always choose PM0 and will never attempt to drop to PM1/2.
|
||||
* The LPP driver is also supported but in order to use it, one needs to set `LPM_CONF_MAX_PM` to 0. Setting a higher value will result in "Sleep Forever" situations. This is inefficient and as a result LPP is not recommended for situations requiring low energy consumption. The main reason for this behaviour is a [bug in LPP][lpp-rf-off-bug]. Once this has been resolved, simple modifications to the LPM module will be implemented to support all three PMs under LPP.
|
||||
|
||||
Build headless nodes
|
||||
--------------------
|
||||
|
@ -458,4 +457,3 @@ More Reading
|
|||
[cc2538]: http://www.ti.com/product/cc2538 "CC2538"
|
||||
[uniflash]: http://processors.wiki.ti.com/index.php/Category:CCS_UniFlash "UniFlash"
|
||||
[pandoc]: http://johnmacfarlane.net/pandoc/ "Pandoc - a universal document converter"
|
||||
[lpp-rf-off-bug]: https://github.com/contiki-os/contiki/issues/104 "LPP RF off() bug"
|
||||
|
|
|
@ -112,6 +112,7 @@ typedef uint32_t rtimer_clock_t;
|
|||
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1
|
||||
#define SLIP_RADIO_CONF_NO_PUTCHAR 1
|
||||
|
||||
#ifndef SLIP_ARCH_CONF_ENABLED
|
||||
/*
|
||||
* Determine whether we need SLIP
|
||||
* This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
|
||||
|
@ -120,6 +121,7 @@ typedef uint32_t rtimer_clock_t;
|
|||
#if defined (UIP_FALLBACK_INTERFACE) || defined (CMD_CONF_OUTPUT)
|
||||
#define SLIP_ARCH_CONF_ENABLED 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When set, the radio turns off address filtering and sends all captured
|
||||
|
|
|
@ -97,9 +97,8 @@
|
|||
*
|
||||
* The USB pullup is driven by PC0 and is shared with LED1
|
||||
*/
|
||||
#define USB_PULLUP_PORT GPIO_C_BASE
|
||||
#define USB_PULLUP_PORT GPIO_C_NUM
|
||||
#define USB_PULLUP_PIN 0
|
||||
#define USB_PULLUP_PIN_MASK GPIO_PIN_MASK(USB_PULLUP_PIN)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name UART configuration
|
||||
|
@ -140,38 +139,28 @@
|
|||
* @{
|
||||
*/
|
||||
/** BUTTON_SELECT -> PA3 */
|
||||
#define BUTTON_SELECT_PORT_NO GPIO_A_NUM
|
||||
#define BUTTON_SELECT_PORT GPIO_A_NUM
|
||||
#define BUTTON_SELECT_PIN 3
|
||||
#define BUTTON_SELECT_PORT GPIO_A_BASE
|
||||
#define BUTTON_SELECT_PIN_MASK GPIO_PIN_MASK(BUTTON_SELECT_PIN)
|
||||
#define BUTTON_SELECT_VECTOR NVIC_INT_GPIO_PORT_A
|
||||
|
||||
/** BUTTON_LEFT -> PC4 */
|
||||
#define BUTTON_LEFT_PORT_NO GPIO_C_NUM
|
||||
#define BUTTON_LEFT_PORT GPIO_C_NUM
|
||||
#define BUTTON_LEFT_PIN 4
|
||||
#define BUTTON_LEFT_PORT GPIO_C_BASE
|
||||
#define BUTTON_LEFT_PIN_MASK GPIO_PIN_MASK(BUTTON_LEFT_PIN)
|
||||
#define BUTTON_LEFT_VECTOR NVIC_INT_GPIO_PORT_C
|
||||
|
||||
/** BUTTON_RIGHT -> PC5 */
|
||||
#define BUTTON_RIGHT_PORT_NO GPIO_C_NUM
|
||||
#define BUTTON_RIGHT_PORT GPIO_C_NUM
|
||||
#define BUTTON_RIGHT_PIN 5
|
||||
#define BUTTON_RIGHT_PORT GPIO_C_BASE
|
||||
#define BUTTON_RIGHT_PIN_MASK GPIO_PIN_MASK(BUTTON_RIGHT_PIN)
|
||||
#define BUTTON_RIGHT_VECTOR NVIC_INT_GPIO_PORT_C
|
||||
|
||||
/** BUTTON_UP -> PC6 */
|
||||
#define BUTTON_UP_PORT_NO GPIO_C_NUM
|
||||
#define BUTTON_UP_PORT GPIO_C_NUM
|
||||
#define BUTTON_UP_PIN 6
|
||||
#define BUTTON_UP_PORT GPIO_C_BASE
|
||||
#define BUTTON_UP_PIN_MASK GPIO_PIN_MASK(BUTTON_UP_PIN)
|
||||
#define BUTTON_UP_VECTOR NVIC_INT_GPIO_PORT_C
|
||||
|
||||
/** BUTTON_DOWN -> PC7 */
|
||||
#define BUTTON_DOWN_PORT_NO GPIO_C_NUM
|
||||
#define BUTTON_DOWN_PORT GPIO_C_NUM
|
||||
#define BUTTON_DOWN_PIN 7
|
||||
#define BUTTON_DOWN_PORT GPIO_C_BASE
|
||||
#define BUTTON_DOWN_PIN_MASK GPIO_PIN_MASK(BUTTON_DOWN_PIN)
|
||||
#define BUTTON_DOWN_VECTOR NVIC_INT_GPIO_PORT_C
|
||||
|
||||
/* Notify various examples that we have Buttons */
|
||||
|
@ -184,14 +173,14 @@
|
|||
* These values configure which CC2538 pins to use for the SPI lines.
|
||||
* @{
|
||||
*/
|
||||
#define CC2538_SPI_CLK_PORT_NUM GPIO_A_NUM
|
||||
#define CC2538_SPI_CLK_PIN_NUM 2
|
||||
#define CC2538_SPI_MOSI_PORT_NUM GPIO_A_NUM
|
||||
#define CC2538_SPI_MOSI_PIN_NUM 4
|
||||
#define CC2538_SPI_MISO_PORT_NUM GPIO_A_NUM
|
||||
#define CC2538_SPI_MISO_PIN_NUM 5
|
||||
#define CC2538_SPI_SEL_PORT_NUM GPIO_B_NUM
|
||||
#define CC2538_SPI_SEL_PIN_NUM 5
|
||||
#define SPI_CLK_PORT GPIO_A_NUM
|
||||
#define SPI_CLK_PIN 2
|
||||
#define SPI_MOSI_PORT GPIO_A_NUM
|
||||
#define SPI_MOSI_PIN 4
|
||||
#define SPI_MISO_PORT GPIO_A_NUM
|
||||
#define SPI_MISO_PIN 5
|
||||
#define SPI_SEL_PORT GPIO_B_NUM
|
||||
#define SPI_SEL_PIN 5
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,21 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BUTTON_SELECT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_SELECT_PORT)
|
||||
#define BUTTON_SELECT_PIN_MASK GPIO_PIN_MASK(BUTTON_SELECT_PIN)
|
||||
|
||||
#define BUTTON_LEFT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_LEFT_PORT)
|
||||
#define BUTTON_LEFT_PIN_MASK GPIO_PIN_MASK(BUTTON_LEFT_PIN)
|
||||
|
||||
#define BUTTON_RIGHT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_RIGHT_PORT)
|
||||
#define BUTTON_RIGHT_PIN_MASK GPIO_PIN_MASK(BUTTON_RIGHT_PIN)
|
||||
|
||||
#define BUTTON_UP_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_UP_PORT)
|
||||
#define BUTTON_UP_PIN_MASK GPIO_PIN_MASK(BUTTON_UP_PIN)
|
||||
|
||||
#define BUTTON_DOWN_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_DOWN_PORT)
|
||||
#define BUTTON_DOWN_PIN_MASK GPIO_PIN_MASK(BUTTON_DOWN_PIN)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct timer debouncetimer;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -124,14 +139,13 @@ btn_callback(uint8_t port, uint8_t pin)
|
|||
static int
|
||||
config_select(int type, int value)
|
||||
{
|
||||
config(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN_MASK);
|
||||
config(BUTTON_SELECT_PORT_BASE, BUTTON_SELECT_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_SELECT_PORT_NO, BUTTON_SELECT_PIN, IOC_OVERRIDE_PUE);
|
||||
ioc_set_over(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
nvic_interrupt_enable(BUTTON_SELECT_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_SELECT_PORT_NO,
|
||||
BUTTON_SELECT_PIN);
|
||||
gpio_register_callback(btn_callback, BUTTON_SELECT_PORT, BUTTON_SELECT_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -149,14 +163,13 @@ config_select(int type, int value)
|
|||
static int
|
||||
config_left(int type, int value)
|
||||
{
|
||||
config(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN_MASK);
|
||||
config(BUTTON_LEFT_PORT_BASE, BUTTON_LEFT_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_LEFT_PORT_NO, BUTTON_LEFT_PIN, IOC_OVERRIDE_PUE);
|
||||
ioc_set_over(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
nvic_interrupt_enable(BUTTON_LEFT_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_LEFT_PORT_NO,
|
||||
BUTTON_LEFT_PIN);
|
||||
gpio_register_callback(btn_callback, BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -174,14 +187,13 @@ config_left(int type, int value)
|
|||
static int
|
||||
config_right(int type, int value)
|
||||
{
|
||||
config(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN_MASK);
|
||||
config(BUTTON_RIGHT_PORT_BASE, BUTTON_RIGHT_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_RIGHT_PORT_NO, BUTTON_RIGHT_PIN, IOC_OVERRIDE_PUE);
|
||||
ioc_set_over(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
nvic_interrupt_enable(BUTTON_RIGHT_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_RIGHT_PORT_NO,
|
||||
BUTTON_RIGHT_PIN);
|
||||
gpio_register_callback(btn_callback, BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -199,14 +211,13 @@ config_right(int type, int value)
|
|||
static int
|
||||
config_up(int type, int value)
|
||||
{
|
||||
config(BUTTON_UP_PORT, BUTTON_UP_PIN_MASK);
|
||||
config(BUTTON_UP_PORT_BASE, BUTTON_UP_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_UP_PORT_NO, BUTTON_UP_PIN, IOC_OVERRIDE_PUE);
|
||||
ioc_set_over(BUTTON_UP_PORT, BUTTON_UP_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
nvic_interrupt_enable(BUTTON_UP_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_UP_PORT_NO,
|
||||
BUTTON_UP_PIN);
|
||||
gpio_register_callback(btn_callback, BUTTON_UP_PORT, BUTTON_UP_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -224,14 +235,13 @@ config_up(int type, int value)
|
|||
static int
|
||||
config_down(int type, int value)
|
||||
{
|
||||
config(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN_MASK);
|
||||
config(BUTTON_DOWN_PORT_BASE, BUTTON_DOWN_PIN_MASK);
|
||||
|
||||
ioc_set_over(BUTTON_DOWN_PORT_NO, BUTTON_DOWN_PIN, IOC_OVERRIDE_PUE);
|
||||
ioc_set_over(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN, IOC_OVERRIDE_PUE);
|
||||
|
||||
nvic_interrupt_enable(BUTTON_DOWN_VECTOR);
|
||||
|
||||
gpio_register_callback(btn_callback, BUTTON_DOWN_PORT_NO,
|
||||
BUTTON_DOWN_PIN);
|
||||
gpio_register_callback(btn_callback, BUTTON_DOWN_PORT, BUTTON_DOWN_PIN);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -38,13 +38,11 @@
|
|||
*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "flash-cca.h"
|
||||
#include "sys-ctrl.h"
|
||||
#include "uart.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define FLASH_START_ADDR 0x00200000
|
||||
#define BOOTLOADER_BACKDOOR_DISABLE 0xEFFFFFFF
|
||||
#define SYS_CTRL_EMUOVR 0x400D20B4
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern int main(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -92,22 +90,19 @@ void uart_isr(void);
|
|||
/* Allocate stack space */
|
||||
static unsigned long stack[512];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Customer Configuration Area in the Lock Page
|
||||
* Holds Image Vector table address (bytes 2012 - 2015) and
|
||||
* Image Valid bytes (bytes 2008 -2011)
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned long bootldr_cfg;
|
||||
unsigned long image_valid;
|
||||
unsigned long image_vector_addr;
|
||||
} lock_page_cca_t;
|
||||
/* Linker construct indicating .text section location */
|
||||
extern uint8_t _text[0];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
__attribute__ ((section(".flashcca"), used))
|
||||
const lock_page_cca_t __cca = {
|
||||
BOOTLOADER_BACKDOOR_DISABLE, /* Bootloader backdoor disabled */
|
||||
0, /* Image valid bytes */
|
||||
FLASH_START_ADDR /* Vector table located at the start of flash */
|
||||
const flash_cca_lock_page_t __cca = {
|
||||
FLASH_CCA_BOOTLDR_CFG_DISABLE, /* Bootloader backdoor disabled */
|
||||
FLASH_CCA_IMAGE_VALID, /* Image valid */
|
||||
&_text, /* Vector table located at the start of .text */
|
||||
/* Unlock all pages and debug */
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
__attribute__ ((section(".vectors"), used))
|
||||
|
|
|
@ -28,7 +28,7 @@ sky-shell-exec/sky \
|
|||
sky-shell-webserver/sky \
|
||||
telnet-server/minimal-net \
|
||||
webserver/minimal-net \
|
||||
webserver-ipv6/sky \
|
||||
webserver-ipv6/exp5438 \
|
||||
wget/minimal-net \
|
||||
z1/z1 \
|
||||
settings-example/avr-raven \
|
||||
|
|
|
@ -2,12 +2,7 @@ EXAMPLESDIR=../../examples
|
|||
TOOLSDIR=../../tools
|
||||
|
||||
EXAMPLES = \
|
||||
hello-world/sensinode \
|
||||
hello-world/cc2530dk \
|
||||
sensinode/sensinode \
|
||||
sensinode/border-router/sensinode \
|
||||
sensinode/udp-ipv6/sensinode \
|
||||
sensinode/sniffer/sensinode \
|
||||
cc2530dk/cc2530dk \
|
||||
cc2530dk/border-router/cc2530dk \
|
||||
cc2530dk/udp-ipv6/cc2530dk \
|
||||
|
|
190
regression-tests/17-slip-radio/01-sky-slip-radio-dio.csc
Normal file
190
regression-tests/17-slip-radio/01-sky-slip-radio-dio.csc
Normal file
|
@ -0,0 +1,190 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>slip radio 1</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
se.sics.cooja.radiomediums.UDGM
|
||||
<transmitting_range>15.0</transmitting_range>
|
||||
<interference_range>15.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>slip radio</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/slip-radio/slip-radio.c</source>
|
||||
<commands EXPORT="discard">make slip-radio.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/slip-radio/slip-radio.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<motetype>
|
||||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky2</identifier>
|
||||
<description>wait-dag</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/regression-tests/17-slip-radio/code/wait-dag.c</source>
|
||||
<commands EXPORT="discard">make wait-dag.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/regression-tests/17-slip-radio/code/wait-dag.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>43.565500781711165</x>
|
||||
<y>14.697933087406794</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
se.sics.cooja.interfaces.Position
|
||||
<x>53.849666651434326</x>
|
||||
<y>14.629826028666905</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky2</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>315</width>
|
||||
<z>1</z>
|
||||
<height>175</height>
|
||||
<location_x>433</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>se.sics.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>se.sics.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>se.sics.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>14.682765905648006 0.0 0.0 14.682765905648006 -512.6620495401903 -96.80631081927221</viewport>
|
||||
</plugin_config>
|
||||
<width>432</width>
|
||||
<z>4</z>
|
||||
<height>291</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
</plugin_config>
|
||||
<width>758</width>
|
||||
<z>3</z>
|
||||
<height>289</height>
|
||||
<location_x>748</location_x>
|
||||
<location_y>159</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Slip-radio Tests, 01-sky-slip-radio-dio
|
||||
|
||||
Test that we can send a packet over a slip-radio.
|
||||
In this basic test, we send a DIO from mote 1, and wait for "DAG Found" in mote 2.</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>928</width>
|
||||
<z>5</z>
|
||||
<height>159</height>
|
||||
<location_x>749</location_x>
|
||||
<location_y>-1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<script>TIMEOUT(30000, log.log("last msg: " + msg + "\n")); /* print last msg at timeout */
|
||||
|
||||
YIELD_THEN_WAIT_UNTIL(msg.contains("Slip Radio started..."));
|
||||
|
||||
//Wait for 5 sec
|
||||
GENERATE_MSG(5000, "sleep");
|
||||
YIELD_THEN_WAIT_UNTIL(msg.equals("sleep"));
|
||||
|
||||
//Configure 802.15.4 Channel (checks that we can detect commands on serial input)
|
||||
write(sim.getMoteWithID(1), String.fromCharCode(0x21,67,26,192));
|
||||
YIELD_THEN_WAIT_UNTIL(msg.contains("setting channel: 26"));
|
||||
|
||||
/*Send a DIO over SLIP with !S... ugly, but enough to test the radio
|
||||
note: 192 = SLIP_END */
|
||||
write(sim.getMoteWithID(1), String.fromCharCode(192,0x21,0x53,0x1,0x3,0x9,0x0,0x5,0xa,0x0,0xd0,0xb,0x0,0x1,0x41,0xc8,0xd0,0xcd,0xab,0xff,0xff,0x1,0x1,0x1,0x0,0x1,0x74,0x12,0x0,0x7a,0x1b,0x3a,0x4,0x1,0x0,0xff,0xff,0x1,0x1,0x1,0x1a,0x9b,0x1,0x24,0x7c,0xa0,0x78,0x1,0x0,0x10,0xf0,0x0,0x0,0xfe,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x12,0x74,0x1,0x0,0x1,0x1,0x1,0x2,0x6,0x7,0x4,0x0,0x2,0x0,0x0,0x4,0xe,0x0,0x8,0xc,0xa,0x7,0x0,0x1,0x0,0x0,0x1,0x0,0x1e,0x1,0x0,0x8,0x1e,0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xaa,0xaa,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,192));
|
||||
|
||||
//Check that the other mote receives the DIO and joins the DAG
|
||||
YIELD_THEN_WAIT_UNTIL(msg.equals("DAG Found"));
|
||||
|
||||
log.testOK();</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>758</width>
|
||||
<z>2</z>
|
||||
<height>502</height>
|
||||
<location_x>749</location_x>
|
||||
<location_y>449</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
</plugin_config>
|
||||
<width>746</width>
|
||||
<z>0</z>
|
||||
<height>657</height>
|
||||
<location_x>3</location_x>
|
||||
<location_y>294</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
1
regression-tests/17-slip-radio/Makefile
Normal file
1
regression-tests/17-slip-radio/Makefile
Normal file
|
@ -0,0 +1 @@
|
|||
include ../Makefile.simulation-test
|
9
regression-tests/17-slip-radio/code/Makefile
Normal file
9
regression-tests/17-slip-radio/code/Makefile
Normal file
|
@ -0,0 +1,9 @@
|
|||
all: wait-dag
|
||||
APPS=servreg-hack
|
||||
CONTIKI=../../..
|
||||
|
||||
WITH_UIP6=1
|
||||
UIP_CONF_IPV6=1
|
||||
CFLAGS+= -DUIP_CONF_IPV6_RPL
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
12
regression-tests/17-slip-radio/code/project-conf.h
Normal file
12
regression-tests/17-slip-radio/code/project-conf.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
|
||||
#undef NETSTACK_CONF_RDC
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NULLRDC_CONF_802154_AUTOACK 1
|
||||
|
||||
#define RPL_CONF_DAO_ACK 1
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, Swedish Institute of Computer Science.
|
||||
* Copyright (c) 2013, CETIC, www.cetic.be.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -30,22 +30,45 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Low power probing (R. Musaloiu-Elefteri, C. Liang,
|
||||
* A. Terzis. Koala: Ultra-Low Power Data Retrieval in
|
||||
* Wireless Sensor Networks, IPSN 2008)
|
||||
*
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
#include "contiki.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "contiki-net.h"
|
||||
#include "net/rpl/rpl.h"
|
||||
#include "net/uip.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef LPP_H_
|
||||
#define LPP_H_
|
||||
#define DEBUG DEBUG_FULL
|
||||
#include "net/uip-debug.h"
|
||||
|
||||
#include "net/mac/rdc.h"
|
||||
#include "dev/radio.h"
|
||||
#define INTERVAL 5 * CLOCK_SECOND
|
||||
|
||||
extern const struct rdc_driver lpp_driver;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(wait_for_dag, "Wait for DAG process");
|
||||
AUTOSTART_PROCESSES(&wait_for_dag);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
timeout_handler(void)
|
||||
{
|
||||
rpl_dag_t *dag = rpl_get_any_dag();
|
||||
if (dag != NULL) {
|
||||
PRINTF("DAG Found\n");
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(wait_for_dag, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
|
||||
#endif /* LPP_H_ */
|
||||
PROCESS_BEGIN();
|
||||
PRINTF("Wait for DAG process started\n");
|
||||
etimer_set(&et, INTERVAL);
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
if(etimer_expired(&et)) {
|
||||
timeout_handler();
|
||||
etimer_restart(&et);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
Loading…
Reference in a new issue