Removing platform wismote

This commit is contained in:
Simon Duquennoy 2017-05-17 13:37:27 +02:00
parent 3eefb4e10f
commit e7088ec6c4
36 changed files with 3 additions and 5616 deletions

View File

@ -1,871 +0,0 @@
/*
* Copyright (c) 2011, 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.
*/
/*
* This code is almost device independent and should be easy to port.
*/
#include "contiki.h"
#include "dev/spi.h"
#include "dev/cc2520/cc2520.h"
#include "dev/cc2520/cc2520_const.h"
#include "net/netstack.h"
#include "net/packetbuf.h"
#include <string.h>
#ifndef CC2520_CONF_AUTOACK
#define CC2520_CONF_AUTOACK 0
#endif /* CC2520_CONF_AUTOACK */
#define WITH_SEND_CCA 1
#define FOOTER_LEN 2
#define FOOTER1_CRC_OK 0x80
#define FOOTER1_CORRELATION 0x7f
#ifdef CC2520_CONF_RSSI_OFFSET
#define RSSI_OFFSET CC2520_CONF_RSSI_OFFSET
#else /* CC2520_CONF_RSSI_OFFSET */
/* The RSSI_OFFSET is approximate 76 (see CC2520 specification) */
#define RSSI_OFFSET 76
#endif /* CC2520_CONF_RSSI_OFFSET */
#include <stdio.h>
#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...) do {} while(0)
#endif
#if 0 && DEBUG
#include "dev/leds.h"
#define LEDS_ON(x) leds_on(x)
#define LEDS_OFF(x) leds_off(x)
#else
#define LEDS_ON(x)
#define LEDS_OFF(x)
#endif
void cc2520_arch_init(void);
/* XXX hack: these will be made as Chameleon packet attributes */
rtimer_clock_t cc2520_time_of_arrival, cc2520_time_of_departure;
int cc2520_authority_level_of_sender;
int cc2520_packets_seen, cc2520_packets_read;
#define BUSYWAIT_UNTIL(cond, max_time) \
do { \
rtimer_clock_t t0; \
t0 = RTIMER_NOW(); \
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
} while(0)
volatile uint8_t cc2520_sfd_counter;
volatile uint16_t cc2520_sfd_start_time;
volatile uint16_t cc2520_sfd_end_time;
static volatile uint16_t last_packet_timestamp;
/*---------------------------------------------------------------------------*/
PROCESS(cc2520_process, "CC2520 driver");
/*---------------------------------------------------------------------------*/
int cc2520_on(void);
int cc2520_off(void);
static int cc2520_read(void *buf, unsigned short bufsize);
static int cc2520_prepare(const void *data, unsigned short len);
static int cc2520_transmit(unsigned short len);
static int cc2520_send(const void *data, unsigned short len);
static int cc2520_receiving_packet(void);
static int pending_packet(void);
static int cc2520_cca(void);
/* static int detected_energy(void); */
signed char cc2520_last_rssi;
uint8_t cc2520_last_correlation;
static uint8_t receive_on;
static int channel;
static radio_result_t
get_value(radio_param_t param, radio_value_t *value)
{
if(!value) {
return RADIO_RESULT_INVALID_VALUE;
}
switch(param) {
case RADIO_PARAM_POWER_MODE:
*value = receive_on ? RADIO_POWER_MODE_ON : RADIO_POWER_MODE_OFF;
return RADIO_RESULT_OK;
case RADIO_PARAM_CHANNEL:
*value = cc2520_get_channel();
return RADIO_RESULT_OK;
case RADIO_CONST_CHANNEL_MIN:
*value = 11;
return RADIO_RESULT_OK;
case RADIO_CONST_CHANNEL_MAX:
*value = 26;
return RADIO_RESULT_OK;
default:
return RADIO_RESULT_NOT_SUPPORTED;
}
}
static radio_result_t
set_value(radio_param_t param, radio_value_t value)
{
switch(param) {
case RADIO_PARAM_POWER_MODE:
if(value == RADIO_POWER_MODE_ON) {
cc2520_on();
return RADIO_RESULT_OK;
}
if(value == RADIO_POWER_MODE_OFF) {
cc2520_off();
return RADIO_RESULT_OK;
}
return RADIO_RESULT_INVALID_VALUE;
case RADIO_PARAM_CHANNEL:
if(value < 11 || value > 26) {
return RADIO_RESULT_INVALID_VALUE;
}
cc2520_set_channel(value);
return RADIO_RESULT_OK;
default:
return RADIO_RESULT_NOT_SUPPORTED;
}
}
static radio_result_t
get_object(radio_param_t param, void *dest, size_t size)
{
return RADIO_RESULT_NOT_SUPPORTED;
}
static radio_result_t
set_object(radio_param_t param, const void *src, size_t size)
{
return RADIO_RESULT_NOT_SUPPORTED;
}
const struct radio_driver cc2520_driver =
{
cc2520_init,
cc2520_prepare,
cc2520_transmit,
cc2520_send,
cc2520_read,
/* cc2520_set_channel, */
/* detected_energy, */
cc2520_cca,
cc2520_receiving_packet,
pending_packet,
cc2520_on,
cc2520_off,
get_value,
set_value,
get_object,
set_object
};
/*---------------------------------------------------------------------------*/
static void
getrxdata(void *buf, int len)
{
CC2520_READ_FIFO_BUF(buf, len);
}
static void
getrxbyte(uint8_t *byte)
{
CC2520_READ_FIFO_BYTE(*byte);
}
static void
flushrx(void)
{
uint8_t dummy;
CC2520_READ_FIFO_BYTE(dummy);
/* read and discard dummy to avoid "variable set but not used" warning */
(void)dummy;
CC2520_STROBE(CC2520_INS_SFLUSHRX);
CC2520_STROBE(CC2520_INS_SFLUSHRX);
}
/*---------------------------------------------------------------------------*/
static void
strobe(uint8_t regname)
{
CC2520_STROBE(regname);
}
/*---------------------------------------------------------------------------*/
static unsigned int
status(void)
{
uint8_t status;
CC2520_GET_STATUS(status);
return status;
}
/*---------------------------------------------------------------------------*/
static uint8_t locked, lock_on, lock_off;
static void
on(void)
{
CC2520_ENABLE_FIFOP_INT();
strobe(CC2520_INS_SRXON);
BUSYWAIT_UNTIL(status() & (BV(CC2520_XOSC16M_STABLE)), RTIMER_SECOND / 100);
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
receive_on = 1;
}
static void
off(void)
{
/* PRINTF("off\n");*/
receive_on = 0;
/* Wait for transmission to end before turning radio off. */
BUSYWAIT_UNTIL(!(status() & BV(CC2520_TX_ACTIVE)), RTIMER_SECOND / 10);
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
strobe(CC2520_INS_SRFOFF);
CC2520_DISABLE_FIFOP_INT();
if(!CC2520_FIFOP_IS_1) {
flushrx();
}
}
/*---------------------------------------------------------------------------*/
#define GET_LOCK() locked++
static void
RELEASE_LOCK(void)
{
if(locked == 1) {
if(lock_on) {
on();
lock_on = 0;
}
if(lock_off) {
off();
lock_off = 0;
}
}
locked--;
}
/*---------------------------------------------------------------------------*/
static uint8_t
getreg(uint16_t regname)
{
uint8_t reg;
CC2520_READ_REG(regname, reg);
return reg;
}
/*---------------------------------------------------------------------------*/
static void
setreg(uint16_t regname, uint8_t value)
{
CC2520_WRITE_REG(regname, value);
}
/*---------------------------------------------------------------------------*/
static void
set_txpower(uint8_t power)
{
setreg(CC2520_TXPOWER, power);
}
/*---------------------------------------------------------------------------*/
#define AUTOCRC (1 << 6)
#define AUTOACK (1 << 5)
#define FRAME_MAX_VERSION ((1 << 3) | (1 << 2))
#define FRAME_FILTER_ENABLE (1 << 0)
#define CORR_THR(n) (((n) & 0x1f) << 6)
#define FIFOP_THR(n) ((n) & 0x7f)
/*---------------------------------------------------------------------------*/
int
cc2520_init(void)
{
{
int s = splhigh();
cc2520_arch_init(); /* Initalize ports and SPI. */
CC2520_DISABLE_FIFOP_INT();
CC2520_FIFOP_INT_INIT();
splx(s);
}
SET_VREG_INACTIVE();
clock_delay(250);
/* Turn on voltage regulator and reset. */
SET_VREG_ACTIVE();
clock_delay(250);
SET_RESET_ACTIVE();
clock_delay(127);
SET_RESET_INACTIVE();
clock_delay(125);
/* Turn on the crystal oscillator. */
strobe(CC2520_INS_SXOSCON);
clock_delay(125);
BUSYWAIT_UNTIL(status() & (BV(CC2520_XOSC16M_STABLE)), RTIMER_SECOND / 100);
/* Change default values as recommended in the data sheet, */
/* correlation threshold = 20, RX bandpass filter = 1.3uA.*/
setreg(CC2520_TXCTRL, 0x94);
setreg(CC2520_TXPOWER, 0x13); /* Output power 1 dBm */
/*
valeurs de TXPOWER
0x03 -> -18 dBm
0x2C -> -7 dBm
0x88 -> -4 dBm
0x81 -> -2 dBm
0x32 -> 0 dBm
0x13 -> 1 dBm
0x32 -> 0 dBm
0x13 -> 1 dBm
0xAB -> 2 dBm
0xF2 -> 3 dBm
0xF7 -> 5 dBm
*/
setreg(CC2520_CCACTRL0, 0xF8); /* CCA treshold -80dBm */
/* Recommended RX settings */
setreg(CC2520_MDMCTRL0, 0x84); /* Controls modem */
setreg(CC2520_MDMCTRL1, 0x14); /* Controls modem */
setreg(CC2520_RXCTRL, 0x3F); /* Adjust currents in RX related analog modules */
setreg(CC2520_FSCTRL, 0x5A); /* Adjust currents in synthesizer. */
setreg(CC2520_FSCAL1, 0x2B); /* Adjust currents in VCO */
setreg(CC2520_AGCCTRL1, 0x11); /* Adjust target value for AGC control loop */
setreg(CC2520_AGCCTRL2, 0xEB);
/* Disable external clock */
setreg(CC2520_EXTCLOCK, 0x00);
/* Tune ADC performance */
setreg(CC2520_ADCTEST0, 0x10);
setreg(CC2520_ADCTEST1, 0x0E);
setreg(CC2520_ADCTEST2, 0x03);
/* Set auto CRC on frame. */
#if CC2520_CONF_AUTOACK
setreg(CC2520_FRMCTRL0, AUTOCRC | AUTOACK);
setreg(CC2520_FRMFILT0, FRAME_MAX_VERSION | FRAME_FILTER_ENABLE);
#else
/* setreg(CC2520_FRMCTRL0, 0x60); */
setreg(CC2520_FRMCTRL0, AUTOCRC);
/* Disable filter on @ (remove if you want to address specific wismote) */
setreg(CC2520_FRMFILT0, 0x00);
#endif /* CC2520_CONF_AUTOACK */
/* SET_RXENMASK_ON_TX */
setreg(CC2520_FRMCTRL1, 1);
/* Set FIFOP threshold to maximum .*/
setreg(CC2520_FIFOPCTRL, FIFOP_THR(0x7F));
cc2520_set_pan_addr(0xffff, 0x0000, NULL);
cc2520_set_channel(26);
flushrx();
process_start(&cc2520_process, NULL);
return 1;
}
/*---------------------------------------------------------------------------*/
static int
cc2520_transmit(unsigned short payload_len)
{
int i;
GET_LOCK();
/* The TX FIFO can only hold one packet. Make sure to not overrun
* FIFO by waiting for transmission to start here and synchronizing
* with the CC2520_TX_ACTIVE check in cc2520_send.
*
* Note that we may have to wait up to 320 us (20 symbols) before
* transmission starts.
*/
#ifndef CC2520_CONF_SYMBOL_LOOP_COUNT
#error CC2520_CONF_SYMBOL_LOOP_COUNT needs to be set!!!
#else
#define LOOP_20_SYMBOLS CC2520_CONF_SYMBOL_LOOP_COUNT
#endif
#if WITH_SEND_CCA
strobe(CC2520_INS_SRXON);
BUSYWAIT_UNTIL(status() & BV(CC2520_RSSI_VALID), RTIMER_SECOND / 10);
strobe(CC2520_INS_STXONCCA);
#else /* WITH_SEND_CCA */
strobe(CC2520_INS_STXON);
#endif /* WITH_SEND_CCA */
for(i = LOOP_20_SYMBOLS; i > 0; i--) {
if(CC2520_SFD_IS_1) {
if(!(status() & BV(CC2520_TX_ACTIVE))) {
/* SFD went high but we are not transmitting. This means that
we just started receiving a packet, so we drop the
transmission. */
RELEASE_LOCK();
return RADIO_TX_COLLISION;
}
if(receive_on) {
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
}
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
/* We wait until transmission has ended so that we get an
accurate measurement of the transmission time.*/
/* BUSYWAIT_UNTIL(getreg(CC2520_EXCFLAG0) & TX_FRM_DONE , RTIMER_SECOND / 100); */
BUSYWAIT_UNTIL(!(status() & BV(CC2520_TX_ACTIVE)), RTIMER_SECOND / 10);
#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS
ENERGEST_OFF_LEVEL(ENERGEST_TYPE_TRANSMIT, cc2520_get_txpower());
#endif
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
if(receive_on) {
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
} else {
/* We need to explicitly turn off the radio,
* since STXON[CCA] -> TX_ACTIVE -> RX_ACTIVE */
off();
}
RELEASE_LOCK();
return RADIO_TX_OK;
}
}
/* If we are using WITH_SEND_CCA, we get here if the packet wasn't
transmitted because of other channel activity. */
RIMESTATS_ADD(contentiondrop);
PRINTF("cc2520: do_send() transmission never started\n");
RELEASE_LOCK();
return RADIO_TX_COLLISION;
}
/*---------------------------------------------------------------------------*/
static int
cc2520_prepare(const void *payload, unsigned short payload_len)
{
uint8_t total_len;
GET_LOCK();
PRINTF("cc2520: sending %d bytes\n", payload_len);
/*int i;
for(i = 0; i < payload_len;i++)
printf("%x",((uint8_t *) payload)[i]);
printf("\n");*/
RIMESTATS_ADD(lltx);
/* Wait for any previous transmission to finish. */
/* while(status() & BV(CC2520_TX_ACTIVE));*/
/* Write packet to TX FIFO. */
strobe(CC2520_INS_SFLUSHTX);
total_len = payload_len + FOOTER_LEN;
CC2520_WRITE_FIFO_BUF(&total_len, 1);
CC2520_WRITE_FIFO_BUF(payload, payload_len);
RELEASE_LOCK();
return 0;
}
/*---------------------------------------------------------------------------*/
static int
cc2520_send(const void *payload, unsigned short payload_len)
{
cc2520_prepare(payload, payload_len);
return cc2520_transmit(payload_len);
}
/*---------------------------------------------------------------------------*/
int
cc2520_off(void)
{
/* Don't do anything if we are already turned off. */
if(receive_on == 0) {
return 1;
}
/* If we are called when the driver is locked, we indicate that the
radio should be turned off when the lock is unlocked. */
if(locked) {
/* printf("Off when locked (%d)\n", locked);*/
lock_off = 1;
return 1;
}
GET_LOCK();
/* If we are currently receiving a packet (indicated by SFD == 1),
we don't actually switch the radio off now, but signal that the
driver should switch off the radio once the packet has been
received and processed, by setting the 'lock_off' variable. */
if(status() & BV(CC2520_TX_ACTIVE)) {
lock_off = 1;
} else {
off();
}
RELEASE_LOCK();
return 1;
}
/*---------------------------------------------------------------------------*/
int
cc2520_on(void)
{
if(receive_on) {
return 1;
}
if(locked) {
lock_on = 1;
return 1;
}
GET_LOCK();
on();
RELEASE_LOCK();
return 1;
}
/*---------------------------------------------------------------------------*/
int
cc2520_get_channel(void)
{
return channel;
}
/*---------------------------------------------------------------------------*/
int
cc2520_set_channel(int c)
{
uint16_t f;
GET_LOCK();
/*
* Subtract the base channel (11), multiply by 5, which is the
* channel spacing. 357 is 2405-2048 and 0x4000 is LOCK_THR = 1.
*/
channel = c;
f = MIN_CHANNEL + ((channel - MIN_CHANNEL) * CHANNEL_SPACING);
/*
* Writing RAM requires crystal oscillator to be stable.
*/
BUSYWAIT_UNTIL((status() & (BV(CC2520_XOSC16M_STABLE))), RTIMER_SECOND / 10);
/* Wait for any transmission to end. */
BUSYWAIT_UNTIL(!(status() & BV(CC2520_TX_ACTIVE)), RTIMER_SECOND / 10);
/* Define radio channel (between 11 and 25) */
setreg(CC2520_FREQCTRL, f);
/* If we are in receive mode, we issue an SRXON command to ensure
that the VCO is calibrated. */
if(receive_on) {
strobe(CC2520_INS_SRXON);
}
RELEASE_LOCK();
return 1;
}
/*---------------------------------------------------------------------------*/
void
cc2520_set_pan_addr(unsigned pan,
unsigned addr,
const uint8_t *ieee_addr)
{
uint8_t tmp[2];
GET_LOCK();
/*
* Writing RAM requires crystal oscillator to be stable.
*/
BUSYWAIT_UNTIL(status() & (BV(CC2520_XOSC16M_STABLE)), RTIMER_SECOND / 10);
tmp[0] = pan & 0xff;
tmp[1] = pan >> 8;
CC2520_WRITE_RAM(&tmp, CC2520RAM_PANID, 2);
tmp[0] = addr & 0xff;
tmp[1] = addr >> 8;
CC2520_WRITE_RAM(&tmp, CC2520RAM_SHORTADDR, 2);
if(ieee_addr != NULL) {
int f;
uint8_t tmp_addr[8];
/* LSB first, MSB last for 802.15.4 addresses in CC2520 */
for(f = 0; f < 8; f++) {
tmp_addr[7 - f] = ieee_addr[f];
}
CC2520_WRITE_RAM(tmp_addr, CC2520RAM_IEEEADDR, 8);
}
RELEASE_LOCK();
}
/*---------------------------------------------------------------------------*/
/*
* Interrupt leaves frame intact in FIFO.
*/
int
cc2520_interrupt(void)
{
CC2520_CLEAR_FIFOP_INT();
process_poll(&cc2520_process);
last_packet_timestamp = cc2520_sfd_start_time;
cc2520_packets_seen++;
return 1;
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc2520_process, ev, data)
{
int len;
PROCESS_BEGIN();
PRINTF("cc2520_process: started\n");
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
PRINTF("cc2520_process: calling receiver callback\n");
packetbuf_clear();
packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, last_packet_timestamp);
len = cc2520_read(packetbuf_dataptr(), PACKETBUF_SIZE);
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
/* flushrx(); */
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
static int
cc2520_read(void *buf, unsigned short bufsize)
{
uint8_t footer[2];
uint8_t len;
if(!CC2520_FIFOP_IS_1) {
return 0;
}
GET_LOCK();
cc2520_packets_read++;
getrxbyte(&len);
if(len > CC2520_MAX_PACKET_LEN) {
/* Oops, we must be out of sync. */
flushrx();
RIMESTATS_ADD(badsynch);
RELEASE_LOCK();
return 0;
}
if(len <= FOOTER_LEN) {
flushrx();
RIMESTATS_ADD(tooshort);
RELEASE_LOCK();
return 0;
}
if(len - FOOTER_LEN > bufsize) {
flushrx();
RIMESTATS_ADD(toolong);
RELEASE_LOCK();
return 0;
}
getrxdata(buf, len - FOOTER_LEN);
getrxdata(footer, FOOTER_LEN);
if(footer[1] & FOOTER1_CRC_OK) {
cc2520_last_rssi = footer[0] - RSSI_OFFSET;
cc2520_last_correlation = footer[1] & FOOTER1_CORRELATION;
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, cc2520_last_rssi);
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, cc2520_last_correlation);
RIMESTATS_ADD(llrx);
} else {
RIMESTATS_ADD(badcrc);
len = FOOTER_LEN;
}
if(CC2520_FIFOP_IS_1) {
if(!CC2520_FIFO_IS_1) {
/* Clean up in case of FIFO overflow! This happens for every
* full length frame and is signaled by FIFOP = 1 and FIFO =
* 0. */
flushrx();
} else {
/* Another packet has been received and needs attention. */
process_poll(&cc2520_process);
}
}
RELEASE_LOCK();
if(len < FOOTER_LEN) {
return 0;
}
return len - FOOTER_LEN;
}
/*---------------------------------------------------------------------------*/
void
cc2520_set_txpower(uint8_t power)
{
GET_LOCK();
set_txpower(power);
RELEASE_LOCK();
}
/*---------------------------------------------------------------------------*/
int
cc2520_get_txpower(void)
{
uint8_t power;
GET_LOCK();
power = getreg(CC2520_TXPOWER);
RELEASE_LOCK();
return power;
}
/*---------------------------------------------------------------------------*/
int
cc2520_rssi(void)
{
int rssi;
int radio_was_off = 0;
if(locked) {
return 0;
}
GET_LOCK();
if(!receive_on) {
radio_was_off = 1;
cc2520_on();
}
BUSYWAIT_UNTIL(status() & BV(CC2520_RSSI_VALID), RTIMER_SECOND / 100);
rssi = (int)((signed char)getreg(CC2520_RSSI));
rssi -= RSSI_OFFSET;
if(radio_was_off) {
cc2520_off();
}
RELEASE_LOCK();
return rssi;
}
/*---------------------------------------------------------------------------*/
/*
static int
detected_energy(void)
{
return cc2520_rssi();
}
*/
/*---------------------------------------------------------------------------*/
int
cc2520_cca_valid(void)
{
int valid;
if(locked) {
return 1;
}
GET_LOCK();
valid = !!(status() & BV(CC2520_RSSI_VALID));
RELEASE_LOCK();
return valid;
}
/*---------------------------------------------------------------------------*/
static int
cc2520_cca(void)
{
int cca;
int radio_was_off = 0;
/* If the radio is locked by an underlying thread (because we are
being invoked through an interrupt), we preted that the coast is
clear (i.e., no packet is currently being transmitted by a
neighbor). */
if(locked) {
return 1;
}
GET_LOCK();
if(!receive_on) {
radio_was_off = 1;
cc2520_on();
}
/* Make sure that the radio really got turned on. */
if(!receive_on) {
RELEASE_LOCK();
if(radio_was_off) {
cc2520_off();
}
return 1;
}
BUSYWAIT_UNTIL(status() & BV(CC2520_RSSI_VALID), RTIMER_SECOND / 100);
cca = CC2520_CCA_IS_1;
if(radio_was_off) {
cc2520_off();
}
RELEASE_LOCK();
return cca;
}
/*---------------------------------------------------------------------------*/
int
cc2520_receiving_packet(void)
{
return CC2520_SFD_IS_1;
}
/*---------------------------------------------------------------------------*/
static int
pending_packet(void)
{
return CC2520_FIFOP_IS_1;
}
/*---------------------------------------------------------------------------*/
void
cc2520_set_cca_threshold(int value)
{
GET_LOCK();
setreg(CC2520_CCACTRL0, value & 0xff);
RELEASE_LOCK();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,199 +0,0 @@
/*
* Copyright (c) 2011, 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
* CC2520 driver header file
* \author
* Adam Dunkels <adam@sics.se>
* Joakim Eriksson <joakime@sics.se>
*/
#ifndef CC2520_H_
#define CC2520_H_
#include "contiki.h"
#include "dev/spi.h"
#include "dev/radio.h"
#include "dev/cc2520/cc2520_const.h"
int cc2520_init(void);
#define CC2520_MAX_PACKET_LEN 127
int cc2520_set_channel(int channel);
int cc2520_get_channel(void);
void cc2520_set_pan_addr(unsigned pan,
unsigned addr,
const uint8_t *ieee_addr);
extern signed char cc2520_last_rssi;
extern uint8_t cc2520_last_correlation;
int cc2520_rssi(void);
extern const struct radio_driver cc2520_driver;
/**
* \param power Between 1 and 31.
*/
void cc2520_set_txpower(uint8_t power);
int cc2520_get_txpower(void);
#define CC2520_TXPOWER_MAX 31
#define CC2520_TXPOWER_MIN 0
/**
* Interrupt function, called from the simple-cc2520-arch driver.
*
*/
int cc2520_interrupt(void);
/* XXX hack: these will be made as Chameleon packet attributes */
extern rtimer_clock_t cc2520_time_of_arrival,
cc2520_time_of_departure;
extern int cc2520_authority_level_of_sender;
int cc2520_on(void);
int cc2520_off(void);
void cc2520_set_cca_threshold(int value);
/************************************************************************/
/* Additional SPI Macros for the CC2520 */
/************************************************************************/
/* Send a strobe to the CC2520 */
#define CC2520_STROBE(s) \
do { \
CC2520_SPI_ENABLE(); \
SPI_WRITE(s); \
CC2520_SPI_DISABLE(); \
} while (0)
/* Write to a register in the CC2520 */
/* Note: the SPI_WRITE(0) seems to be needed for getting the */
/* write reg working on the Z1 / MSP430X platform */
#define CC2520_WRITE_REG(adr,data) \
do { \
CC2520_SPI_ENABLE(); \
SPI_WRITE_FAST(CC2520_INS_MEMWR | ((adr>>8)&0xFF)); \
SPI_WRITE_FAST(adr & 0xff); \
SPI_WRITE_FAST((uint8_t) data); \
SPI_WAITFORTx_ENDED(); \
CC2520_SPI_DISABLE(); \
} while(0)
/* Read a register in the CC2520 */
#define CC2520_READ_REG(adr,data) \
do { \
CC2520_SPI_ENABLE(); \
SPI_WRITE((CC2520_INS_MEMRD | ((adr>>8)&0xFF))); \
SPI_WRITE((adr & 0xFF)); \
(void)SPI_RXBUF; \
SPI_READ(data); \
CC2520_SPI_DISABLE(); \
} while(0)
#define CC2520_READ_FIFO_BYTE(data) \
do { \
CC2520_SPI_ENABLE(); \
SPI_WRITE(CC2520_INS_RXBUF); \
(void)SPI_RXBUF; \
SPI_READ(data); \
clock_delay(1); \
CC2520_SPI_DISABLE(); \
} while(0)
#define CC2520_READ_FIFO_BUF(buffer,count) \
do { \
uint8_t i; \
CC2520_SPI_ENABLE(); \
SPI_WRITE(CC2520_INS_RXBUF); \
(void)SPI_RXBUF; \
for(i = 0; i < (count); i++) { \
SPI_READ(((uint8_t *)(buffer))[i]); \
} \
clock_delay(1); \
CC2520_SPI_DISABLE(); \
} while(0)
#define CC2520_WRITE_FIFO_BUF(buffer,count) \
do { \
uint8_t i; \
CC2520_SPI_ENABLE(); \
SPI_WRITE_FAST(CC2520_INS_TXBUF); \
for(i = 0; i < (count); i++) { \
SPI_WRITE_FAST(((uint8_t *)(buffer))[i]); \
SPI_WAITFORTxREADY(); \
} \
SPI_WAITFORTx_ENDED(); \
CC2520_SPI_DISABLE(); \
} while(0)
/* Write to RAM in the CC2520 */
#define CC2520_WRITE_RAM(buffer,adr,count) \
do { \
uint8_t i; \
CC2520_SPI_ENABLE(); \
SPI_WRITE_FAST(CC2520_INS_MEMWR | (((adr)>>8) & 0xFF)); \
SPI_WRITE_FAST(((adr) & 0xFF)); \
for(i = 0; i < (count); i++) { \
SPI_WRITE_FAST(((uint8_t*)(buffer))[i]); \
} \
SPI_WAITFORTx_ENDED(); \
CC2520_SPI_DISABLE(); \
} while(0)
/* Read from RAM in the CC2520 */
#define CC2520_READ_RAM(buffer,adr,count) \
do { \
uint8_t i; \
CC2520_SPI_ENABLE(); \
SPI_WRITE(CC2520_INS_MEMRD | (((adr)>>8) & 0xFF)); \
SPI_WRITE(((adr) & 0xFF)); \
SPI_RXBUF; \
for(i = 0; i < (count); i++) { \
SPI_READ(((uint8_t*)(buffer))[i]); \
} \
CC2520_SPI_DISABLE(); \
} while(0)
/* Read status of the CC2520 */
#define CC2520_GET_STATUS(s) \
do { \
CC2520_SPI_ENABLE(); \
SPI_WRITE(CC2520_INS_SNOP); \
s = SPI_RXBUF; \
CC2520_SPI_DISABLE(); \
} while (0)
#endif /* CC2520_H_ */

View File

@ -1,216 +0,0 @@
/*
* Copyright (c) 2011, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef CC2520_CONST_H
#define CC2520_CONST_H
/*
* All constants are from the Chipcon cc2520 Data Sheet that at one
* point in time could be found at
* http://www.chipcon.com/files/cc2520_Data_Sheet_1_4.pdf
*
* The page numbers below refer to pages in this document.
*/
/* Page 27. */
enum cc2520_status_byte {
CC2520_XOSC16M_STABLE = 7,
CC2520_RSSI_VALID = 6,
CC2520_EXCEPTION_CHA = 5,
CC2520_EXCEPTION_CHB = 4,
CC2520_DPU_H = 3,
CC2520_DPU_L = 2,
CC2520_TX_ACTIVE = 1,
CC2520_RX_ACTIVE = 0,
};
#define TX_FRM_DONE 0x02
#define RX_FRM_DONE 0x01
#define RX_FRM_ABORTED 0x20
#define RX_FRM_UNDERFLOW 0x20
/* Page 27. */
enum cc2520_memory_size {
CC2520_RAM_SIZE = 640,
CC2520_FIFO_SIZE = 128,
};
/* Page 29. */
enum cc2520_address {
CC2520RAM_TXFIFO = 0x100,
CC2520RAM_RXFIFO = 0x180,
CC2520RAM_IEEEADDR = 0x3EA,
CC2520RAM_PANID = 0x3F2,
CC2520RAM_SHORTADDR = 0x3F4,
};
// IEEE 802.15.4 defined constants (2.4 GHz logical channels)
#define MIN_CHANNEL 11 // 2405 MHz
#define MAX_CHANNEL 26 // 2480 MHz
#define CHANNEL_SPACING 5 // MHz
// FREG definitions (BSET/BCLR supported)
#define CC2520_FRMFILT0 0x000
#define CC2520_FRMFILT1 0x001
#define CC2520_SRCMATCH 0x002
#define CC2520_SRCSHORTEN0 0x004
#define CC2520_SRCSHORTEN1 0x005
#define CC2520_SRCSHORTEN2 0x006
#define CC2520_SRCEXTEN0 0x008
#define CC2520_SRCEXTEN1 0x009
#define CC2520_SRCEXTEN2 0x00A
#define CC2520_FRMCTRL0 0x00C
#define CC2520_FRMCTRL1 0x00D
#define CC2520_RXENABLE0 0x00E
#define CC2520_RXENABLE1 0x00F
#define CC2520_EXCFLAG0 0x010
#define CC2520_EXCFLAG1 0x011
#define CC2520_EXCFLAG2 0x012
#define CC2520_EXCMASKA0 0x014
#define CC2520_EXCMASKA1 0x015
#define CC2520_EXCMASKA2 0x016
#define CC2520_EXCMASKB0 0x018
#define CC2520_EXCMASKB1 0x019
#define CC2520_EXCMASKB2 0x01A
#define CC2520_EXCBINDX0 0x01C
#define CC2520_EXCBINDX1 0x01D
#define CC2520_EXCBINDY0 0x01E
#define CC2520_EXCBINDY1 0x01F
#define CC2520_GPIOCTRL0 0x020
#define CC2520_GPIOCTRL1 0x021
#define CC2520_GPIOCTRL2 0x022
#define CC2520_GPIOCTRL3 0x023
#define CC2520_GPIOCTRL4 0x024
#define CC2520_GPIOCTRL5 0x025
#define CC2520_GPIOPOLARITY 0x026
#define CC2520_GPIOCTRL 0x028
#define CC2520_DPUCON 0x02A
#define CC2520_DPUSTAT 0x02C
#define CC2520_FREQCTRL 0x02E
#define CC2520_FREQTUNE 0x02F
#define CC2520_TXPOWER 0x030
#define CC2520_TXCTRL 0x031
#define CC2520_FSMSTAT0 0x032
#define CC2520_FSMSTAT1 0x033
#define CC2520_FIFOPCTRL 0x034
#define CC2520_FSMCTRL 0x035
#define CC2520_CCACTRL0 0x036
#define CC2520_CCACTRL1 0x037
#define CC2520_RSSI 0x038
#define CC2520_RSSISTAT 0x039
#define CC2520_TXFIFO_BUF 0x03A
#define CC2520_RXFIRST 0x03C
#define CC2520_RXFIFOCNT 0x03E
#define CC2520_TXFIFOCNT 0x03F
// SREG definitions (BSET/BCLR unsupported)
#define CC2520_CHIPID 0x040
#define CC2520_VERSION 0x042
#define CC2520_EXTCLOCK 0x044
#define CC2520_MDMCTRL0 0x046
#define CC2520_MDMCTRL1 0x047
#define CC2520_FREQEST 0x048
#define CC2520_RXCTRL 0x04A
#define CC2520_FSCTRL 0x04C
#define CC2520_FSCAL0 0x04E
#define CC2520_FSCAL1 0x04F
#define CC2520_FSCAL2 0x050
#define CC2520_FSCAL3 0x051
#define CC2520_AGCCTRL0 0x052
#define CC2520_AGCCTRL1 0x053
#define CC2520_AGCCTRL2 0x054
#define CC2520_AGCCTRL3 0x055
#define CC2520_ADCTEST0 0x056
#define CC2520_ADCTEST1 0x057
#define CC2520_ADCTEST2 0x058
#define CC2520_MDMTEST0 0x05A
#define CC2520_MDMTEST1 0x05B
#define CC2520_DACTEST0 0x05C
#define CC2520_DACTEST1 0x05D
#define CC2520_ATEST 0x05E
#define CC2520_DACTEST2 0x05F
#define CC2520_PTEST0 0x060
#define CC2520_PTEST1 0x061
#define CC2520_RESERVED 0x062
#define CC2520_DPUBIST 0x07A
#define CC2520_ACTBIST 0x07C
#define CC2520_RAMBIST 0x07E
// Instruction implementation
#define CC2520_INS_SNOP 0x00
#define CC2520_INS_IBUFLD 0x02
#define CC2520_INS_SIBUFEX 0x03
#define CC2520_INS_SSAMPLECCA 0x04
#define CC2520_INS_SRES 0x0F
#define CC2520_INS_MEMRD 0x10
#define CC2520_INS_MEMWR 0x20
#define CC2520_INS_RXBUF 0x30
#define CC2520_INS_RXBUFCP 0x38
#define CC2520_INS_RXBUFMOV 0x32
#define CC2520_INS_TXBUF 0x3A
#define CC2520_INS_TXBUFCP 0x3E
#define CC2520_INS_RANDOM 0x3C
#define CC2520_INS_SXOSCON 0x40
#define CC2520_INS_STXCAL 0x41
#define CC2520_INS_SRXON 0x42
#define CC2520_INS_STXON 0x43
#define CC2520_INS_STXONCCA 0x44
#define CC2520_INS_SRFOFF 0x45
#define CC2520_INS_SXOSCOFF 0x46
#define CC2520_INS_SFLUSHRX 0x47
#define CC2520_INS_SFLUSHTX 0x48
#define CC2520_INS_SACK 0x49
#define CC2520_INS_SACKPEND 0x4A
#define CC2520_INS_SNACK 0x4B
#define CC2520_INS_SRXMASKBITSET 0x4C
#define CC2520_INS_SRXMASKBITCLR 0x4D
#define CC2520_INS_RXMASKAND 0x4E
#define CC2520_INS_RXMASKOR 0x4F
#define CC2520_INS_MEMCP 0x50
#define CC2520_INS_MEMCPR 0x52
#define CC2520_INS_MEMXCP 0x54
#define CC2520_INS_MEMXWR 0x56
#define CC2520_INS_BCLR 0x58
#define CC2520_INS_BSET 0x59
#define CC2520_INS_CTR 0x60
#define CC2520_INS_CBCMAC 0x64
#define CC2520_INS_UCBCMAC 0x66
#define CC2520_INS_CCM 0x68
#define CC2520_INS_UCCM 0x6A
#define CC2520_INS_ECB 0x70
#define CC2520_INS_ECBO 0x72
#define CC2520_INS_ECBX 0x74
#define CC2520_INS_ECBXO 0x76
#define CC2520_INS_INC 0x78
#define CC2520_INS_ABORT 0x7F
#define CC2520_INS_REGRD 0x80
#define CC2520_INS_REGWR 0xC0
#endif /* CC2520_CONST_H */

View File

@ -1,50 +0,0 @@
CONTIKI_TARGET_SOURCEFILES += contiki-wismote-platform.c \
sht11.c sht11-sensor.c light-sensor.c battery-sensor.c \
button-sensor.c radio-sensor.c
#ARCH=spi.c ds2411.c xmem.c i2c.c node-id.c sensors.c cfs-coffee.c \
cc2520.c cc2520-arch.c cc2520-arch-sfd.c \
sky-sensors.c uip-ipchksum.c \
uart1.c slip_uart1.c uart1-putchar.c
ARCH=spi.c xmem.c i2c.c node-id.c sensors.c cfs-coffee.c sht15.c \
cc2520.c cc2520-arch.c cc2520-arch-sfd.c \
sky-sensors.c uip-ipchksum.c \
uart1.c slip_uart1.c uart1-putchar.c
CONTIKI_TARGET_DIRS = . dev apps net
ifndef CONTIKI_TARGET_MAIN
CONTIKI_TARGET_MAIN = contiki-wismote-main.c
endif
ifdef IAR
SMALL = 0
CFLAGS += -D__MSP430F5437__=1 -e --vla -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X --double=32
endif
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
MCU=msp430f5437
# Platform has a MSP430X MCU with 20-bit support
CPU_HAS_MSP430X=1
include $(CONTIKI)/drivers/cpu/msp430/Makefile.msp430
ifdef IAR
LDFLAGSNO += -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl"
LDFLAGS += $(LDFLAGSNO) -Felf -yn
endif
%.hex: %.ihex
mv $< $@
%.upload: %.hex
msp430flasher -n msp430x5437 -e ERASE_MAIN -w $< -v -z [VCC]
%.upload-clean: %.hex
msp430flasher -n msp430x5437 -w $< -v -z [VCC]
MODULES += core/net core/net/mac \
drivers/dev/cc2520 drivers/dev/sht11

View File

@ -1,80 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* A program for burning a node ID into the external flash of a Wismote.
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "dev/leds.h"
#include "dev/watchdog.h"
#include "sys/node-id.h"
#include "contiki.h"
#include "sys/etimer.h"
#include <stdio.h>
static struct etimer etimer;
PROCESS(burn_process, "Burn node id");
AUTOSTART_PROCESSES(&burn_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(burn_process, ev, data)
{
PROCESS_BEGIN();
etimer_set(&etimer, 5 * CLOCK_SECOND);
PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
watchdog_stop();
leds_on(LEDS_RED);
#if NODEID
printf("Burning node id %d\n", NODEID);
node_id_burn(NODEID);
leds_on(LEDS_BLUE);
node_id_restore();
printf("Restored node id %d\n", node_id);
#else
#error "burn-nodeid must be compiled with nodeid=<the ID of the node>"
node_id_restore();
printf("Restored node id %d\n", node_id);
#endif
leds_off(LEDS_RED + LEDS_BLUE);
watchdog_start();
while(1) {
PROCESS_WAIT_EVENT();
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,77 +0,0 @@
/*
* Copyright (c) 2008, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* Coffee architecture-dependent header for the Tmote Sky platform.
* \author
* Nicolas Tsiftes <nvt@sics.se>
*/
#ifndef CFS_COFFEE_ARCH_H
#define CFS_COFFEE_ARCH_H
#include "contiki-conf.h"
#include "dev/xmem.h"
#include "dev/watchdog.h"
/* Coffee configuration parameters. */
#define COFFEE_SECTOR_SIZE 65536UL
#define COFFEE_PAGE_SIZE 256UL
#define COFFEE_START COFFEE_SECTOR_SIZE
#define COFFEE_SIZE (1024UL * 1024UL - COFFEE_START)
#define COFFEE_NAME_LENGTH 16
#define COFFEE_MAX_OPEN_FILES 6
#define COFFEE_FD_SET_SIZE 8
#define COFFEE_LOG_TABLE_LIMIT 256
#define COFFEE_DYN_SIZE 4*1024
#define COFFEE_LOG_SIZE 1024
#define COFFEE_MICRO_LOGS 1
#define COFFEE_WATCHDOG_START() watchdog_start()
#define COFFEE_WATCHDOG_STOP() watchdog_stop()
/* Flash operations. */
#define COFFEE_WRITE(buf, size, offset) \
xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_READ(buf, size, offset) \
xmem_pread((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_ERASE(sector) \
xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE)
/* Coffee types. */
typedef int16_t coffee_page_t;
#endif /* !COFFEE_ARCH_H */

View File

@ -1,144 +0,0 @@
/* -*- C -*- */
#ifndef CONTIKI_CONF_H
#define CONTIKI_CONF_H
#include "platform-conf.h"
#ifndef NETSTACK_CONF_MAC
#define NETSTACK_CONF_MAC csma_driver
#endif /* NETSTACK_CONF_MAC */
#ifndef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC nullrdc_driver
#endif /* NETSTACK_CONF_RDC */
#ifndef NETSTACK_CONF_RADIO
#define NETSTACK_CONF_RADIO cc2520_driver
#endif /* NETSTACK_CONF_RADIO */
#ifndef NETSTACK_CONF_FRAMER
#define NETSTACK_CONF_FRAMER framer_802154
#endif /* NETSTACK_CONF_FRAMER */
#ifndef CC2520_CONF_AUTOACK
#define CC2520_CONF_AUTOACK 1
#endif /* CC2520_CONF_AUTOACK */
#define NULLRDC_CONF_802154_AUTOACK 1
#if NETSTACK_CONF_WITH_IPV6
/* Network setup for IPv6 */
#define NETSTACK_CONF_NETWORK sicslowpan_driver
/* Specify a minimum packet size for 6lowpan compression to be
enabled. This is needed for ContikiMAC, which needs packets to be
larger than a specified size, if no ContikiMAC header should be
used. */
#define SICSLOWPAN_CONF_COMPRESSION_THRESHOLD 63
#ifndef QUEUEBUF_CONF_NUM
#define QUEUEBUF_CONF_NUM 8
#endif
#endif /* NETSTACK_CONF_WITH_IPV6 */
#define PACKETBUF_CONF_ATTRS_INLINE 1
#ifndef RF_CHANNEL
#define RF_CHANNEL 26
#endif /* RF_CHANNEL */
#define IEEE802154_CONF_PANID 0xABCD
#define SHELL_VARS_CONF_RAM_BEGIN 0x1100
#define SHELL_VARS_CONF_RAM_END 0x2000
#define PROFILE_CONF_ON 0
#define ENERGEST_CONF_ON 1
#define AODV_COMPLIANCE
#define AODV_NUM_RT_ENTRIES 32
#define WITH_ASCII 1
#define PROCESS_CONF_NUMEVENTS 8
#define PROCESS_CONF_STATS 1
/*#define PROCESS_CONF_FASTPOLL 4*/
#define UART1_CONF_RX_WITH_DMA 0
#ifdef NETSTACK_CONF_WITH_IPV6
#define LINKADDR_CONF_SIZE 8
#define UIP_CONF_LL_802154 1
#define UIP_CONF_LLH_LEN 0
#define UIP_CONF_ROUTER 1
/* configure number of neighbors and routes */
#ifndef NBR_TABLE_CONF_MAX_NEIGHBORS
#define NBR_TABLE_CONF_MAX_NEIGHBORS 30
#endif /* NBR_TABLE_CONF_MAX_NEIGHBORS */
#ifndef UIP_CONF_MAX_ROUTES
#define UIP_CONF_MAX_ROUTES 30
#endif /* UIP_CONF_MAX_ROUTES */
#define UIP_CONF_ND6_SEND_RA 0
#define UIP_CONF_ND6_REACHABLE_TIME 600000
#define UIP_CONF_ND6_RETRANS_TIMER 10000
#define NETSTACK_CONF_WITH_IPV6 1
#ifndef UIP_CONF_IPV6_QUEUE_PKT
#define UIP_CONF_IPV6_QUEUE_PKT 0
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
#define UIP_CONF_IPV6_CHECKS 1
#define UIP_CONF_IPV6_REASSEMBLY 0
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
#define UIP_CONF_IP_FORWARD 0
#ifndef UIP_CONF_BUFFER_SIZE
#define UIP_CONF_BUFFER_SIZE 240
#endif
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
#ifndef SICSLOWPAN_CONF_FRAG
#define SICSLOWPAN_CONF_FRAG 1
#define SICSLOWPAN_CONF_MAXAGE 8
#endif /* SICSLOWPAN_CONF_FRAG */
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
#else /* NETSTACK_CONF_WITH_IPV6 */
#define UIP_CONF_IP_FORWARD 1
#define UIP_CONF_BUFFER_SIZE 108
#endif /* NETSTACK_CONF_WITH_IPV6 */
#define UIP_CONF_ICMP_DEST_UNREACH 1
#define UIP_CONF_DHCP_LIGHT
#define UIP_CONF_LLH_LEN 0
#ifndef UIP_CONF_RECEIVE_WINDOW
#define UIP_CONF_RECEIVE_WINDOW 48
#endif
#ifndef UIP_CONF_TCP_MSS
#define UIP_CONF_TCP_MSS 48
#endif
#define UIP_CONF_MAX_CONNECTIONS 4
#define UIP_CONF_MAX_LISTENPORTS 8
#define UIP_CONF_UDP_CONNS 12
#define UIP_CONF_FWCACHE_SIZE 30
#define UIP_CONF_BROADCAST 1
#define UIP_ARCH_IPCHKSUM 1
#define UIP_CONF_UDP 1
#define UIP_CONF_UDP_CHECKSUMS 1
#define UIP_CONF_PINGADDRCONF 0
#define UIP_CONF_LOGGING 0
#define UIP_CONF_TCP_SPLIT 0
/* include the project config */
/* PROJECT_CONF_H might be defined in the project Makefile */
#ifdef PROJECT_CONF_H
#include PROJECT_CONF_H
#endif /* PROJECT_CONF_H */
#endif /* CONTIKI_CONF_H */

View File

@ -1,459 +0,0 @@
/*
* Copyright (c) 2011, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "contiki.h"
#include <stdio.h>
#include <string.h>
#include "dev/cc2520/cc2520.h"
//#include "dev/ds2411.h"
#include "dev/leds.h"
#include "dev/serial-line.h"
#include "dev/slip.h"
#include "dev/uart1.h"
#include "dev/watchdog.h"
#include "dev/xmem.h"
#include "lib/random.h"
#include "net/netstack.h"
#include "net/queuebuf.h"
#include "net/mac/frame802154.h"
#if NETSTACK_CONF_WITH_IPV6
#include "net/ipv6/uip-ds6.h"
#endif /* NETSTACK_CONF_WITH_IPV6 */
#include "sys/node-id.h"
#include "sys/autostart.h"
#if UIP_CONF_ROUTER
#ifndef UIP_ROUTER_MODULE
#ifdef UIP_CONF_ROUTER_MODULE
#define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE
#else /* UIP_CONF_ROUTER_MODULE */
#define UIP_ROUTER_MODULE rimeroute
#endif /* UIP_CONF_ROUTER_MODULE */
#endif /* UIP_ROUTER_MODULE */
extern const struct uip_router UIP_ROUTER_MODULE;
#endif /* UIP_CONF_ROUTER */
#ifndef NETSTACK_CONF_WITH_IPV4
#define NETSTACK_CONF_WITH_IPV4 0
#endif
#if NETSTACK_CONF_WITH_IPV4
#include "net/ip/uip.h"
#include "net/ipv4/uip-fw.h"
#include "net/ipv4/uip-fw-drv.h"
#include "net/ipv4/uip-over-mesh.h"
static struct uip_fw_netif slipif =
{UIP_FW_NETIF(192,168,1,2, 255,255,255,255, slip_send)};
static struct uip_fw_netif meshif =
{UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
#endif /* NETSTACK_CONF_WITH_IPV4 */
#define UIP_OVER_MESH_CHANNEL 8
#if NETSTACK_CONF_WITH_IPV4
static uint8_t is_gateway;
#endif /* NETSTACK_CONF_WITH_IPV4 */
#ifdef EXPERIMENT_SETUP
#include "experiment-setup.h"
#endif
void init_platform(void);
/*---------------------------------------------------------------------------*/
#if 0
int
force_float_inclusion()
{
extern int __fixsfsi;
extern int __floatsisf;
extern int __mulsf3;
extern int __subsf3;
return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
}
#endif
/*---------------------------------------------------------------------------*/
void uip_log(char *msg) { puts(msg); }
/*---------------------------------------------------------------------------*/
#ifndef RF_CHANNEL
#define RF_CHANNEL 26
#endif
/*---------------------------------------------------------------------------*/
#if 0
void
force_inclusion(int d1, int d2)
{
snprintf(NULL, 0, "%d", d1 % d2);
}
#endif
/*---------------------------------------------------------------------------*/
#ifndef NODE_ID
#define NODE_ID 0x03
#endif /* NODE_ID */
static void
set_rime_addr(void)
{
linkaddr_t n_addr;
int i;
memset(&n_addr, 0, sizeof(linkaddr_t));
// Set node address
#if NETSTACK_CONF_WITH_IPV6
//memcpy(addr.u8, ds2411_id, sizeof(addr.u8));
n_addr.u8[7] = node_id & 0xff;
n_addr.u8[6] = node_id >> 8;
#else
/* if(node_id == 0) {
for(i = 0; i < sizeof(linkaddr_t); ++i) {
addr.u8[i] = ds2411_id[7 - i];
}
} else {
addr.u8[0] = node_id & 0xff;
addr.u8[1] = node_id >> 8;
}*/
n_addr.u8[0] = node_id & 0xff;
n_addr.u8[1] = node_id >> 8;
#endif
linkaddr_set_node_addr(&n_addr);
printf("Rime started with address ");
for(i = 0; i < sizeof(n_addr.u8) - 1; i++) {
printf("%d.", n_addr.u8[i]);
}
printf("%d\n", n_addr.u8[i]);
}
/*---------------------------------------------------------------------------*/
#if !PROCESS_CONF_NO_PROCESS_NAMES
static void
print_processes(struct process * const processes[])
{
/* const struct process * const * p = processes;*/
printf("Starting");
while(*processes != NULL) {
printf(" '%s'", (*processes)->name);
processes++;
}
putchar('\n');
}
#endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
/*--------------------------------------------------------------------------*/
#if NETSTACK_CONF_WITH_IPV4
static void
set_gateway(void)
{
if(!is_gateway) {
leds_on(LEDS_RED);
//printf("%d.%d: making myself the IP network gateway.\n\n",
// linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1]);
//printf("IPv4 address of the gateway: %d.%d.%d.%d\n\n",
// uip_ipaddr_to_quad(&uip_hostaddr));
uip_over_mesh_set_gateway(&linkaddr_node_addr);
uip_over_mesh_make_announced_gateway();
is_gateway = 1;
}
}
#endif /* NETSTACK_CONF_WITH_IPV4 */
/*---------------------------------------------------------------------------*/
int
main(int argc, char **argv)
{
/*
* Initalize hardware.
*/
msp430_cpu_init();
clock_init();
leds_init();
leds_on(LEDS_RED);
clock_wait(2);
uart1_init(115200); /* Must come before first printf */
#if NETSTACK_CONF_WITH_IPV4
slip_arch_init(115200);
#endif /* NETSTACK_CONF_WITH_IPV4 */
clock_wait(1);
leds_on(LEDS_GREEN);
//ds2411_init();
/* XXX hack: Fix it so that the 802.15.4 MAC address is compatible
with an Ethernet MAC address - byte 0 (byte 2 in the DS ID)
cannot be odd. */
//ds2411_id[2] &= 0xfe;
leds_on(LEDS_BLUE);
xmem_init();
leds_off(LEDS_RED);
rtimer_init();
/*
* Hardware initialization done!
*/
/* Restore node id if such has been stored in external mem */
node_id_restore();
if(!node_id) {
node_id = NODE_ID;
}
/* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
#ifdef IEEE_802154_MAC_ADDRESS
{
uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
//memcpy(ds2411_id, ieee, sizeof(uip_lladdr.addr));
//ds2411_id[7] = node_id & 0xff;
}
#endif
//random_init(ds2411_id[0] + node_id);
leds_off(LEDS_BLUE);
/*
* Initialize Contiki and our processes.
*/
process_init();
process_start(&etimer_process, NULL);
ctimer_init();
init_platform();
set_rime_addr();
random_init(linkaddr_node_addr.u8[LINKADDR_SIZE-2] + linkaddr_node_addr.u8[LINKADDR_SIZE-1]);
cc2520_init();
{
uint8_t longaddr[8];
uint16_t shortaddr;
shortaddr = (linkaddr_node_addr.u8[0] << 8) +
linkaddr_node_addr.u8[1];
memset(longaddr, 0, sizeof(longaddr));
linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
longaddr[0], longaddr[1], longaddr[2], longaddr[3],
longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
cc2520_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
}
cc2520_set_channel(RF_CHANNEL);
printf(CONTIKI_VERSION_STRING " started. ");
if(node_id > 0) {
printf("Node id is set to %u.\n", node_id);
} else {
printf("Node id is not set.\n");
}
#if NETSTACK_CONF_WITH_IPV6
/* memcpy(&uip_lladdr.addr, ds2411_id, sizeof(uip_lladdr.addr)); */
memcpy(&uip_lladdr.addr, linkaddr_node_addr.u8,
UIP_LLADDR_LEN > LINKADDR_SIZE ? LINKADDR_SIZE : UIP_LLADDR_LEN);
/* Setup nullmac-like MAC for 802.15.4 */
/* sicslowpan_init(sicslowmac_init(&cc2520_driver)); */
/* printf(" %s channel %u\n", sicslowmac_driver.name, RF_CHANNEL); */
/* Setup X-MAC for 802.15.4 */
queuebuf_init();
NETSTACK_RDC.init();
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();
printf("%s %s, channel check rate %lu Hz, radio channel %u\n",
NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
NETSTACK_RDC.channel_check_interval()),
RF_CHANNEL);
process_start(&tcpip_process, NULL);
printf("Tentative link-local IPv6 address ");
{
uip_ds6_addr_t *lladdr;
int i;
lladdr = uip_ds6_get_link_local(-1);
for(i = 0; i < 7; ++i) {
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
lladdr->ipaddr.u8[i * 2 + 1]);
}
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
}
if(!UIP_CONF_IPV6_RPL) {
uip_ipaddr_t ipaddr;
int i;
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
printf("Tentative global IPv6 address ");
for(i = 0; i < 7; ++i) {
printf("%02x%02x:",
ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
}
printf("%02x%02x\n",
ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
}
#else /* NETSTACK_CONF_WITH_IPV6 */
NETSTACK_RDC.init();
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();
printf("%s %s, channel check rate %lu Hz, radio channel %u\n",
NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
NETSTACK_RDC.channel_check_interval()),
RF_CHANNEL);
#endif /* NETSTACK_CONF_WITH_IPV6 */
#if !NETSTACK_CONF_WITH_IPV4 && !NETSTACK_CONF_WITH_IPV6
uart1_set_input(serial_line_input_byte);
serial_line_init();
#endif
leds_off(LEDS_GREEN);
#if TIMESYNCH_CONF_ENABLED
timesynch_init();
timesynch_set_authority_level((linkaddr_node_addr.u8[0] << 4) + 16);
#endif /* TIMESYNCH_CONF_ENABLED */
#if NETSTACK_CONF_WITH_IPV4
process_start(&tcpip_process, NULL);
process_start(&uip_fw_process, NULL); /* Start IP output */
process_start(&slip_process, NULL);
slip_set_input_callback(set_gateway);
{
uip_ipaddr_t hostaddr, netmask;
uip_init();
uip_ipaddr(&hostaddr, 172,16,
linkaddr_node_addr.u8[0],linkaddr_node_addr.u8[1]);
uip_ipaddr(&netmask, 255,255,0,0);
uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
uip_sethostaddr(&hostaddr);
uip_setnetmask(&netmask);
uip_over_mesh_set_net(&hostaddr, &netmask);
/* uip_fw_register(&slipif);*/
uip_over_mesh_set_gateway_netif(&slipif);
uip_fw_default(&meshif);
uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
printf("uIP started with IP address %d.%d.%d.%d\n",
uip_ipaddr_to_quad(&hostaddr));
}
#endif /* NETSTACK_CONF_WITH_IPV4 */
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
watchdog_start();
/* Stop the watchdog */
watchdog_stop();
#if !PROCESS_CONF_NO_PROCESS_NAMES
print_processes(autostart_processes);
#else /* !PROCESS_CONF_NO_PROCESS_NAMES */
putchar('\n'); /* include putchar() */
#endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
autostart_start(autostart_processes);
/*
* This is the scheduler loop.
*/
while(1) {
int r;
do {
/* Reset watchdog. */
watchdog_periodic();
r = process_run();
} while(r > 0);
/*
* Idle processing.
*/
int s = splhigh(); /* Disable interrupts. */
/* uart1_active is for avoiding LPM3 when still sending or receiving */
if(process_nevents() != 0 || uart1_active()) {
splx(s); /* Re-enable interrupts. */
} else {
static unsigned long irq_energest = 0;
/* Re-enable interrupts and go to sleep atomically. */
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
/* We only want to measure the processing done in IRQs when we
are asleep, so we discard the processing time done when we
were awake. */
energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
watchdog_stop();
_BIS_SR(GIE | SCG0 | SCG1 | CPUOFF); /* LPM3 sleep. This
statement will block
until the CPU is
woken up by an
interrupt that sets
the wake up flag. */
/* We get the current processing time for interrupts that was
done during the LPM and store it for next time around. */
dint();
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
eint();
watchdog_start();
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
}
}
}
/*---------------------------------------------------------------------------*/
#if LOG_CONF_ENABLED
void
log_message(char *m1, char *m2)
{
printf("%s%s\n", m1, m2);
}
#endif /* LOG_CONF_ENABLED */

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2011, 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.
*
* Author: Niclas Finne <nfi@sics.se>, Joakim Eriksson <joakime@sics.se>
*/
#include "dev/button-sensor.h"
SENSORS(&button_sensor);
void
init_platform(void)
{
process_start(&sensors_process, NULL);
}

View File

@ -1,129 +0,0 @@
/*
* Copyright (c) 2010, 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.
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2005-11-01
*/
#include "dev/acc-sensor.h"
const struct sensors_sensor acc_sensor;
static uint8_t active;
/*---------------------------------------------------------------------------*/
static void
activate(void)
{
/* This assumes that some other sensor system already did setup the ADC
* (in the case of the sky platform it is sensors_light_init that does it) */
#if 0
P6SEL |= 0x70;
P6DIR = 0x00;
P6OUT = 0x00;
P2DIR |= 0x48;
P2OUT |= 0x48;
/* stop converting immediately */
ADC12CTL0 &= ~ENC;
ADC12CTL1 &= ~CONSEQ_3;
/* Configure ADC12_2 to sample channel 11 (voltage) and use
* the Vref+ as reference (SREF_1) since it is a stable reference */
ADC12MCTL2 = (INCH_4 + SREF_1);
ADC12MCTL3 = (INCH_5 + SREF_1);
ADC12MCTL4 = (INCH_6 + SREF_1);
/* internal temperature can be read as value(3) */
ADC12MCTL5 = (INCH_10 + SREF_1);
ADC12CTL1 |= CONSEQ_3;
ADC12CTL0 |= ENC | ADC12SC;
Irq_adc12_activate(&acc_sensor, 6, (INCH_11 + SREF_1));
#endif /* 0 */
active = 1;
}
/*---------------------------------------------------------------------------*/
static void
deactivate(void)
{
#if 0
irq_adc12_deactivate(&acc_sensor, 6);
acc_value = 0;
#endif /* 0 */
active = 0;
}
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
#if 0
switch(type) {
case 0:
return ADC12MEM2;
case 1:
return ADC12MEM3;
case 2:
return ADC12MEM4;
case 3:
return ADC12MEM5;
}
#endif /* 0 */
return 0;
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int value)
{
if(type == SENSORS_ACTIVE) {
if(value) {
activate();
} else {
deactivate();
}
return 1;
}
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
switch (type) {
case SENSORS_ACTIVE:
case SENSORS_READY:
return active;
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(acc_sensor, ACC_SENSOR, value, configure, status);

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2005-11-01
*/
#ifndef ACC_SENSOR_H_
#define ACC_SENSOR_H_
#include "lib/sensors.h"
extern const struct sensors_sensor acc_sensor;
#define ACC_SENSOR "Acc"
#endif /* ACC_SENSOR_H_ */

View File

@ -1,101 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne, Sumankumar Panchal
* Created : 2005-11-01
* Updated : $Date: 2016/09/17 11:30:00 $
* $Revision: 1.11 $
*/
#include "dev/battery-sensor.h"
#include "dev/sky-sensors.h"
const struct sensors_sensor battery_sensor;
static uint8_t active;
/*---------------------------------------------------------------------------*/
static void
activate(void)
{
/* Setup ADC12, ref., sampling time */
ADC12CTL0 = ADC12REF2_5V + ADC12SHT0_6 + ADC12SHT1_6 + ADC12MSC + ADC12REFON;
/* Use sampling timer, repeat-sequence-of-channels */
ADC12CTL1 = ADC12SHP + ADC12CONSEQ_3 + ADC12CSTARTADD_1;
/* Configure ADC12_2 to sample channel 11 (voltage) and use */
/* the Vref+ as reference (SREF_1) since it is a stable reference */
ADC12MCTL2 = (ADC12INCH_11 + ADC12SREF_1);
ADC12CTL0 |= ADC12ON;
ADC12CTL0 |= ADC12ENC; /* enable conversion */
ADC12CTL0 |= ADC12SC; /* sample & convert */
active = 1;
}
/*---------------------------------------------------------------------------*/
static void
deactivate(void)
{
active = 0;
}
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
return ADC12MEM2; /*battery_value*/
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
{
switch(type) {
case SENSORS_ACTIVE:
if(c) {
activate();
} else {
deactivate();
}
}
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
switch(type) {
case SENSORS_ACTIVE:
case SENSORS_READY:
return active;
}
return 0;
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(battery_sensor, BATTERY_SENSOR,
value, configure, status);

View File

@ -1,101 +0,0 @@
/*
* Copyright (c) 2011, 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.
*/
#include "lib/sensors.h"
#include "dev/hwconf.h"
#include "dev/button-sensor.h"
#include "isr_compat.h"
const struct sensors_sensor button_sensor;
static struct timer debouncetimer;
static int status(int type);
HWCONF_PIN(BUTTON, 2, 7);
HWCONF_IRQ(BUTTON, 2, 7);
/*---------------------------------------------------------------------------*/
ISR(PORT2, irq_p2)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(BUTTON_CHECK_IRQ() && timer_expired(&debouncetimer)) {
timer_set(&debouncetimer, CLOCK_SECOND / 4);
sensors_changed(&button_sensor);
LPM4_EXIT;
}
P2IFG = 0x00;
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
return BUTTON_READ() || !timer_expired(&debouncetimer);
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int value)
{
if(type == SENSORS_ACTIVE) {
if(value == 0) {
/* Deactivate button sensor */
BUTTON_DISABLE_IRQ();
} else {
/* Activate button sensor */
if(!status(SENSORS_ACTIVE)) {
timer_set(&debouncetimer, 0);
BUTTON_IRQ_EDGE_SELECTD();
BUTTON_SELECT();
BUTTON_MAKE_INPUT();
BUTTON_ENABLE_IRQ();
}
}
return 1;
}
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
switch(type) {
case SENSORS_ACTIVE:
case SENSORS_READY:
return BUTTON_IRQ_ENABLED();
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
value, configure, status);

View File

@ -1,107 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne, Marcus Lundén,
* Jesper Karlsson
* Created : 2005-11-01
*/
#include "contiki.h"
#include "dev/ext-sensor.h"
#include "dev/sky-sensors.h"
const struct sensors_sensor ext_sensor;
static uint8_t active;
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
#if 0
/* ADC0 corresponds to the port under the logo,
* ADC1 to the port over the logo,
* ADC2 and ADC3 corresponds to port on the JCreate bottom expansion port) */
switch(type) {
case ADC0:
return ADC12MEM6;
case ADC1:
return ADC12MEM7;
case ADC2:
return ADC12MEM8;
case ADC3:
return ADC12MEM9;
}
#endif /* 0 */
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
switch(type) {
case SENSORS_ACTIVE:
case SENSORS_READY:
return active;
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
{
switch(type) {
case SENSORS_ACTIVE:
if(c) {
if(!status(SENSORS_ACTIVE)) {
#if 0
/* SREF_1 is Vref+ */
/* MemReg6 == P6.0/A0 == port "under" logo */
ADC12MCTL6 = (INCH_0 + SREF_0);
/* MemReg7 == P6.1/A1 == port "over" logo */
ADC12MCTL7 = (INCH_1 + SREF_0);
/* MemReg8 == P6.2/A2, bottom expansion port */
ADC12MCTL8 = (INCH_2 + SREF_0);
/* MemReg9 == P6.1/A3, bottom expansion port, End Of (ADC-)Sequence */
ADC12MCTL9 = (INCH_3 + SREF_0);
#endif /* 0 */
sky_sensors_activate(0x0F);
active = 1;
}
} else {
sky_sensors_deactivate(0x0F);
active = 0;
}
return 1;
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(ext_sensor, "Ext", value, configure, status);

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* -----------------------------------------------------------------
*
* Author : Marcus Lundén
* Created : 2005-11-01
*/
#ifndef EXT_SENSOR_H_
#define EXT_SENSOR_H_
#include "lib/sensors.h"
#define ADC0 0
#define ADC1 1
#define ADC2 2
#define ADC3 3
extern const struct sensors_sensor ext_sensor;
#define EXT_SENSOR "Ext"
#endif /* EXT_SENSOR_H_ */

View File

@ -1,223 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Small and portable implementation of a bit-banging I2C bus master.
*
* The code should port really easily to platforms other than the
* msp430 but has some hardcoded constants in it.
*
* More info at:
* http://i2c-bus.org/
* http://www.esacademy.com/faq/i2c/
*/
#include <contiki.h>
#include <dev/spi.h>
#include <dev/leds.h>
#include "dev/i2c.h"
/*
* On the Tmote sky access to I2C/SPI/UART0 must always be exclusive.
*/
void i2c_enable(void);
void i2c_disable(void);
int i2c_start(void);
unsigned i2c_read(int send_ack);
int i2c_write(unsigned);
void i2c_stop(void);
#define I2C_PxDIR P3DIR
#define I2C_PxIN P3IN
#define I2C_PxOUT P3OUT
#define I2C_PxSEL P3SEL
/*
* SDA == P3.1
* SCL == P3.3
*/
#define SDA 1
#define SCL 3
#define SDA_0() (I2C_PxDIR |= BV(SDA)) /* SDA Output */
#define SDA_1() (I2C_PxDIR &= ~BV(SDA)) /* SDA Input */
#define SDA_IS_1 (I2C_PxIN & BV(SDA))
#define SCL_0() (I2C_PxDIR |= BV(SCL)) /* SCL Output */
#define SCL_1() (I2C_PxDIR &= ~BV(SCL)) /* SCL Input */
#define SCL_IS_1 (I2C_PxIN & BV(SCL))
/*
* Should avoid infinite looping while waiting for SCL_IS_1. xxx/bg
*/
#define SCL_WAIT_FOR_1() do{}while (!SCL_IS_1)
#define delay_4_7us() do{ _NOP(); _NOP(); _NOP(); _NOP(); \
_NOP(); _NOP(); _NOP(); _NOP(); \
_NOP(); _NOP(); _NOP(); _NOP(); }while(0)
#define delay_4us() do{ _NOP(); _NOP(); _NOP(); _NOP(); \
_NOP(); _NOP(); _NOP(); _NOP(); \
_NOP(); _NOP(); }while(0)
static unsigned char old_pxsel, old_pxout, old_pxdir;
/*
* Grab SDA and SCL pins for exclusive use but remember old
* configuration so that it may be restored when we are done.
*/
void
i2c_enable(void)
{
unsigned char sda_scl = BV(SDA)|BV(SCL);
old_pxsel = I2C_PxSEL & sda_scl;
old_pxout = I2C_PxOUT & sda_scl;
old_pxdir = I2C_PxDIR & sda_scl;
spi_busy = 1;
I2C_PxSEL &= ~sda_scl;
I2C_PxOUT &= ~sda_scl;
I2C_PxDIR |= BV(SCL); /* SCL Output */
I2C_PxDIR &= ~BV(SDA); /* SDA Input */
}
/*
* Restore bus to what it was before i2c_enable.
*
*/
void
i2c_disable(void)
{
unsigned char not_sda_scl = ~(BV(SDA)|BV(SCL));
I2C_PxDIR = (I2C_PxDIR & not_sda_scl) | old_pxdir;
I2C_PxOUT = (I2C_PxOUT & not_sda_scl) | old_pxout;
I2C_PxSEL = (I2C_PxSEL & not_sda_scl) | old_pxsel;
spi_busy = 0;
}
int
i2c_start(void)
{
SDA_1();
SCL_1();
#if 1
SCL_WAIT_FOR_1();
#else
{
unsigned long n;
for (n = 0; n < 100000 && !SCL_IS_1; n++)
;
if (!SCL_IS_1)
return -1;
}
#endif
delay_4_7us();
SDA_0();
delay_4us();
SCL_0();
return 0;
}
void
i2c_stop(void)
{
SDA_0();
delay_4us();
SCL_1();
SCL_WAIT_FOR_1();
SDA_1();
}
/*
* Return true if we received an ACK.
*/
int
i2c_write(unsigned _c)
{
unsigned char c = _c;
unsigned long n;
int i;
int ret;
for (i = 0; i < 8; i++, c <<= 1) {
if (c & 0x80)
SDA_1();
else
SDA_0();
SCL_1();
SCL_WAIT_FOR_1();
SCL_0();
}
SDA_1();
SCL_1();
ret = 0; /* Loop waiting for an ACK to arrive. */
for (n = 0; n < 250000; n++) {
if (!SDA_IS_1) {
ret = 1;
break;
}
}
SCL_WAIT_FOR_1(); /* clock stretching? */
SCL_0();
return ret;
}
unsigned
i2c_read(int send_ack)
{
int i;
unsigned char c = 0x00;
SDA_1();
for (i = 0; i < 8; i++) {
c <<= 1;
SCL_1();
SCL_WAIT_FOR_1();
if (SDA_IS_1)
c |= 0x1;
SCL_0();
}
if (send_ack)
SDA_0();
SCL_1();
SCL_WAIT_FOR_1();
SCL_0();
return c;
}

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef I2C_H
#define I2C_H
/*
* On the Tmote sky access to I2C/SPI/UART0 must always be exclusive.
*/
#define I2C_ENABLE() (i2c_enable())
#define I2C_DISABLE() (i2c_disable())
void i2c_enable(void);
void i2c_disable(void);
int i2c_start(void);
void i2c_stop(void);
int i2c_write(unsigned);
unsigned i2c_read(int send_ack);
#endif /* I2C_H */

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2005-2010, 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.
*/
#include "contiki.h"
#include "lib/sensors.h"
#include "dev/sky-sensors.h"
#include "dev/light-sensor.h"
const struct sensors_sensor light_sensor;
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
/* switch(type) { */
/* case LIGHT_SENSOR_PHOTOSYNTHETIC: */
/* /\* Photosynthetically Active Radiation. *\/ */
/* return ADC12MEM0; */
/* case LIGHT_SENSOR_TOTAL_SOLAR: */
/* /\* Total Solar Radiation. *\/ */
/* return ADC12MEM1; */
/* } */
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
/*
switch(type) {
case SENSORS_ACTIVE:
case SENSORS_READY:
return (ADC12CTL0 & (ADC12ON + REFON)) == (ADC12ON + REFON);
}
*/
return 0;
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
{
switch(type) {
case SENSORS_ACTIVE:
if(c) {
if(!status(SENSORS_ACTIVE)) {
// ADC12MCTL0 = (INCH_4 + SREF_0); // photodiode 1 (P64)
// ADC12MCTL1 = (INCH_5 + SREF_0); // photodiode 2 (P65)
sky_sensors_activate(0x30);
}
} else {
sky_sensors_deactivate(0x30);
}
}
return 0;
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(light_sensor, "Light",
value, configure, status);

View File

@ -1,50 +0,0 @@
/*
* Copyright (c) 2010, 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.
*
*
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2010-01-08
* Updated : $Date: 2010/01/14 20:23:02 $
* $Revision: 1.2 $
*/
#ifndef LIGHT_SENSOR_H_
#define LIGHT_SENSOR_H_
#include "lib/sensors.h"
extern const struct sensors_sensor light_sensor;
#define LIGHT_SENSOR_PHOTOSYNTHETIC 0
#define LIGHT_SENSOR_TOTAL_SOLAR 1
#endif /* LIGHT-SENSOR_H_ */

View File

@ -1,65 +0,0 @@
/*
* Copyright (c) 2005, 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.
*
*/
#include "lib/sensors.h"
#include "dev/cc2520/cc2520.h"
#include "dev/radio-sensor.h"
const struct sensors_sensor radio_sensor;
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
switch(type) {
case RADIO_SENSOR_LAST_PACKET:
return cc2520_last_correlation;
case RADIO_SENSOR_LAST_VALUE:
default:
return cc2520_last_rssi;
}
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
return 0;
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(radio_sensor, RADIO_SENSOR,
value, configure, status);

View File

@ -1,53 +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
* Architecture-specific definitions for the SHT11 sensor on Tmote Sky.
* \author
* Niclas Finne <nfi@sics.se>
*/
#ifndef SHT11_ARCH_H
#define SHT11_ARCH_H
#define SHT11_ARCH_SDA 5 /* P1.5 */
#define SHT11_ARCH_SCL 6 /* P1.6 */
#define SHT11_ARCH_PWR 7 /* P1.7 */
#define SHT11_PxDIR P1DIR
#define SHT11_PxIN P1IN
#define SHT11_PxOUT P1OUT
#define SHT11_PxSEL P1SEL
#define SHT11_PxREN P1REN
#endif

View File

@ -1,330 +0,0 @@
/* Copyright (c) 2009 ARAGO SYSTEMS
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the names of
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 OWNER 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 "dev/sht15.h"
#define DATA_OUT() P3DIR |= BIT7
#define DATA_IN() P3DIR &= ~BIT7
#define DATA_SET() P3OUT |= BIT7; halMcuWaitUs(10)
#define DATA_CLR() P3OUT &= ~BIT7; halMcuWaitUs(10)
#define DATA_VAL() (P3IN & BIT7)
#define SCK_OUT() P5DIR |= BIT4
#define SCK_SET() P5OUT |= BIT4; halMcuWaitUs(10)
#define SCK_CLR() P5OUT &= ~BIT4; halMcuWaitUs(10)
/***********************************************************************************
* @fn halMcuWaitUs
*
* @brief Busy wait function. Waits the specified number of microseconds. Use
* assumptions about number of clock cycles needed for the various
* instructions. The duration of one cycle depends on MCLK. In this HAL
* , it is set to 8 MHz, thus 8 cycles per usec.
*
* NB! This function is highly dependent on architecture and compiler!
*
* @param uint16 usec - number of microseconds delay
*
* @return none
*/
/* #pragma optimize=none */
void
halMcuWaitUs(uint16_t usec) /* 5 cycles for calling */
{
/* The least we can wait is 3 usec: */
/* ~1 usec for call, 1 for first compare and 1 for return */
while(usec > 3) /* 2 cycles for compare */
{ /* 2 cycles for jump */
nop(); /* 1 cycles for nop */
nop(); /* 1 cycles for nop */
nop(); /* 1 cycles for nop */
nop(); /* 1 cycles for nop */
nop(); /* 1 cycles for nop */
nop(); /* 1 cycles for nop */
nop(); /* 1 cycles for nop */
nop(); /* 1 cycles for nop */
usec -= 2; /* 1 cycles for optimized decrement */
}
} /* 4 cycles for returning */
/**
SHT15/75 Driver
!!! be advise that the SHT15 and SHT75 are not i2C compliant sensors
they are just designed to not disturb i2C devices on a 2 wire bus
this driver allow to drive the sensor with GPIO and delay
*/
/***********************************************************************************
* @fn sht15_send_start
*
* @brief This function perform the start sequence asked by SHT15 and SHT75
*
*
*
* @param none
*
* @return none
*/
void
sht15_send_start(void)
{
/* Sequence is to set data line to 1 then clock line to 1
then set data line to 0, clock line to 0
then set clock line to 1 and data line to 1
___________ ________
data line : _____/ \___________/
___________ ____________
clock line : _________/ \___/
*/
DATA_OUT();
DATA_SET();
SCK_SET();
DATA_CLR();
SCK_CLR();
SCK_SET();
DATA_SET();
SCK_CLR();
}
/***********************************************************************************
* @fn sht15_read16()
*
* @brief
*
*
*
* @param none
*
* @return uint16_t
*/
uint16_t
sht15_read16(void)
{
uint16_t i;
DATA_IN();
SCK_CLR();
uint16_t val = 0;
for(i = 0; i < 18; i++) {
if((i != 8) && (i != 17)) {
SCK_SET();
if(DATA_VAL()) {
val |= 1;
}
val <<= 1;
SCK_CLR();
} else if(i == 8) { /* Wait for first ACK from SHT15 */
DATA_OUT();
DATA_CLR();
SCK_SET();
SCK_CLR();
DATA_IN();
} else if(i == 17) { /* Wait for second ACK from SHT15 */
DATA_OUT();
DATA_SET();
SCK_SET();
SCK_CLR();
}
}
return val;
}
/***********************************************************************************
* @fn sht15_write8
*
* @brief
*
*
*
* @param uint8 val
*
* @return none
*/
void
sht15_write8(uint8_t val)
{
uint16_t i;
DATA_OUT();
for(i = 0; i < 8; i++) {
halMcuWaitUs(4);
SCK_CLR();
if(val & 0x80) {
DATA_SET();
} else {
DATA_CLR();
}
val <<= 1;
SCK_SET();
}
DATA_IN();
SCK_CLR();
while(DATA_VAL());
SCK_SET();
SCK_CLR();
}
/***********************************************************************************
* @fn sht15_wait_measure
*
* @brief
*
*
*
* @param none
*
* @return none
*/
void
sht15_wait_measure(void)
{
while(DATA_VAL());
}
/***********************************************************************************
* @fn sht15_init
*
* @brief
*
*
*
* @param none
*
* @return none
*/
void
sht15_init(void)
{
/* DATA and SCK lines are I/O */
P3SEL &= ~BIT7;
P5SEL &= ~BIT4;
/* Set SCK and DATA as output */
DATA_OUT();
SCK_OUT();
DATA_SET();
SCK_SET();
}
/***********************************************************************************
* @fn sht15_measure_temp
*
* @brief
*
*
*
* @param none
*
* @return none
*/
void
sht15_measure_temp(void)
{
sht15_send_start();
sht15_write8(3);
}
/***********************************************************************************
* @fn sht15_measure_hum
*
* @brief
*
*
*
* @param none
*
* @return none
*/
void sht15_measure_hum()
{
sht15_send_start();
sht15_write8(5);
}
/***********************************************************************************
* @fn sht15_read_status
*
* @brief
*
*
*
* @param none
*
* @return none
*/
void
sht15_read_status()
{
sht15_send_start();
sht15_write8(7);
}
/***********************************************************************************
* @fn sht15_write_status
*
* @brief
*
*
*
* @param none
*
* @return none
*/
void
sht15_write_status(void)
{
sht15_send_start();
sht15_write8(6);
}
/***********************************************************************************
* @fn sht15_soft_reset
*
* @brief
*
*
*
* @param none
*
* @return none
*/
void
sht15_soft_reset(void)
{
sht15_send_start();
sht15_write8(30);
}

View File

@ -1,53 +0,0 @@
/* Copyright (c) 2009 ARAGO SYSTEMS
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the names of
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 OWNER 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.
*/
/*
*/
/**
SHT15/75 Driver
!!! be advise that the SHT15 and SHT75 are not i2C compliant sensors
they are just designed to not disturb i2C devices on a 2 wire bus
this driver allow to drive the sensor with GPIO and delay
*/
#include "contiki.h"
/***********************************************************************************
* SHT15 functions
*/
void sht15_init();
void sht15_measure_temp();
void sht15_measure_hum();
void sht15_wait_measure();
void sht15_read_status();
void sht15_write_status();
void sht15_soft_reset();
uint16_t sht15_read16();
void sht15_write8(uint8_t val);

View File

@ -1,91 +0,0 @@
/*
* Copyright (c) 2010, 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.
*
*
* -----------------------------------------------------------------
*
* Author : Joakim Eriksson
* Created : 2010-02-02
* Updated : $Date: 2010/02/06 18:28:26 $
* $Revision: 1.2 $
*/
#include "contiki.h"
static uint8_t adc_on;
/*---------------------------------------------------------------------------*/
void
sky_sensors_activate(uint8_t type)
{
uint8_t pre = adc_on;
adc_on |= type;
P6SEL |= type;
if(pre == 0 && adc_on > 0) {
P6DIR = 0xff;
P6OUT = 0x00;
/* if nothing was started before, start up the ADC system */
/* Set up the ADC. */
/* ADC12CTL0 = REF2_5V + SHT0_6 + SHT1_6 + MSC; /\* Setup ADC12, ref., sampling time *\/ */
/* ADC12CTL1 = SHP + CONSEQ_3 + CSTARTADD_0; /\* Use sampling timer, repeat-sequenc-of-channels */
/* /\* convert up to MEM4 *\/ */
/* ADC12MCTL9 |= EOS; */
/* ADC12CTL0 |= ADC12ON + REFON; */
/* ADC12CTL0 |= ENC; /\* enable conversion *\/ */
/* ADC12CTL0 |= ADC12SC; /\* sample & convert *\/ */
}
}
/*---------------------------------------------------------------------------*/
void
sky_sensors_deactivate(uint8_t type)
{
adc_on &= ~type;
if(adc_on == 0) {
/* stop converting immediately, turn off reference voltage, etc. */
/* wait for conversion to stop */
/* ADC12CTL0 &= ~ENC; */
/* /\* need to remove CONSEQ_3 if not EOS is configured *\/ */
/* ADC12CTL1 &= ~CONSEQ_3; */
/* while(ADC12CTL1 & ADC12BUSY); */
/* ADC12CTL0 = 0; */
/* ADC12CTL1 = 0; */
/* P6DIR = 0x00; */
/* P6OUT = 0x00; */
/* P6SEL = 0x00; */
}
}
/*---------------------------------------------------------------------------*/

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2010, 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.
*
* -----------------------------------------------------------------
*
* Author : Joakim Eriksson
* Created : 2010-02-02
* Updated : $Date: 2010/02/02 20:59:45 $
* $Revision: 1.1 $
*/
#ifndef SKY_SENSORS_H_
#define SKY_SENSORS_H_
void sky_sensors_activate(uint8_t);
void sky_sensors_deactivate(uint8_t);
#endif /* SKY_SENSORS_H_ */

View File

@ -1,273 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \file
* Device driver for the ST M25P80 40MHz 1Mbyte external memory.
* \author
* Björn Grönvall <bg@sics.se>
* Sumankumar Panchal <suman@ece.iisc.ernet.in>
*
*
* Data is written bit inverted (~-operator) to flash so that
* unwritten data will read as zeros (UNIX style).
*/
#include "contiki.h"
#include <stdio.h>
#include <string.h>
#include "dev/spi.h"
#include "dev/xmem.h"
#include "dev/watchdog.h"
#if 0
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...) do {} while (0)
#endif
#define SPI_FLASH_INS_WREN 0x06
#define SPI_FLASH_INS_WRDI 0x04
#define SPI_FLASH_INS_RDSR 0x05
#define SPI_FLASH_INS_WRSR 0x01
#define SPI_FLASH_INS_READ 0x03
#define SPI_FLASH_INS_FAST_READ 0x0b
#define SPI_FLASH_INS_PP 0x02
#define SPI_FLASH_INS_SE 0xd8
#define SPI_FLASH_INS_BE 0xc7
#define SPI_FLASH_INS_DP 0xb9
#define SPI_FLASH_INS_RES 0xab
/*---------------------------------------------------------------------------*/
static void
write_enable(void)
{
int s;
s = splhigh();
SPI_FLASH_ENABLE();
SPI_WRITE(SPI_FLASH_INS_WREN);
SPI_FLASH_DISABLE();
splx(s);
}
/*---------------------------------------------------------------------------*/
static unsigned
read_status_register(void)
{
unsigned char u;
int s;
s = splhigh();
SPI_FLASH_ENABLE();
SPI_WRITE(SPI_FLASH_INS_RDSR);
SPI_FLUSH();
SPI_READ(u);
SPI_FLASH_DISABLE();
splx(s);
return u;
}
/*---------------------------------------------------------------------------*/
/*
* Wait for a write/erase operation to finish.
*/
static unsigned
wait_ready(void)
{
unsigned u;
do {
u = read_status_register();
watchdog_periodic();
} while(u & 0x01); /* WIP=1, write in progress */
return u;
}
/*---------------------------------------------------------------------------*/
/*
* Erase 64k bytes of data. It takes about 1s before WIP goes low!
*/
static void
erase_sector(unsigned long offset)
{
int s;
wait_ready();
write_enable();
s = splhigh();
SPI_FLASH_ENABLE();
SPI_WRITE_FAST(SPI_FLASH_INS_SE);
SPI_WRITE_FAST(offset >> 16); /* MSB */
SPI_WRITE_FAST(offset >> 8);
SPI_WRITE_FAST(offset >> 0); /* LSB */
SPI_WAITFORTx_ENDED();
SPI_FLASH_DISABLE();
splx(s);
}
/*---------------------------------------------------------------------------*/
/*
* Initialize external flash *and* SPI bus!
*/
void
xmem_init(void)
{
int s;
spi_init();
P4DIR |= BIT0;
/* Release from Deep Power-down */
s = splhigh();
SPI_FLASH_ENABLE();
SPI_WRITE_FAST(SPI_FLASH_INS_RES);
SPI_WAITFORTx_ENDED();
SPI_FLASH_DISABLE(); /* Unselect flash. */
splx(s);
SPI_FLASH_UNHOLD();
}
/*---------------------------------------------------------------------------*/
int
xmem_pread(void *_p, int size, unsigned long offset)
{
unsigned char *p = _p;
const unsigned char *end = p + size;
int s;
wait_ready();
ENERGEST_ON(ENERGEST_TYPE_FLASH_READ);
s = splhigh();
SPI_FLASH_ENABLE();
SPI_WRITE_FAST(SPI_FLASH_INS_READ);
SPI_WRITE_FAST(offset >> 16); /* MSB */
SPI_WRITE_FAST(offset >> 8);
SPI_WRITE_FAST(offset >> 0); /* LSB */
SPI_WAITFORTx_ENDED();
SPI_FLUSH();
for(; p < end; p++) {
unsigned char u;
SPI_READ(u);
*p = ~u;
}
SPI_FLASH_DISABLE();
splx(s);
ENERGEST_OFF(ENERGEST_TYPE_FLASH_READ);
return size;
}
/*---------------------------------------------------------------------------*/
static const unsigned char *
program_page(unsigned long offset, const unsigned char *p, int nbytes)
{
const unsigned char *end = p + nbytes;
int s;
wait_ready();
write_enable();
s = splhigh();
SPI_FLASH_ENABLE();
SPI_WRITE_FAST(SPI_FLASH_INS_PP);
SPI_WRITE_FAST(offset >> 16); /* MSB */
SPI_WRITE_FAST(offset >> 8);
SPI_WRITE_FAST(offset >> 0); /* LSB */
for(; p < end; p++) {
SPI_WRITE_FAST(~*p);
}
SPI_WAITFORTx_ENDED();
SPI_FLASH_DISABLE();
splx(s);
return p;
}
/*---------------------------------------------------------------------------*/
int
xmem_pwrite(const void *_buf, int size, unsigned long addr)
{
const unsigned char *p = _buf;
const unsigned long end = addr + size;
unsigned long i, next_page;
ENERGEST_ON(ENERGEST_TYPE_FLASH_WRITE);
for(i = addr; i < end;) {
next_page = (i | 0xff) + 1;
if(next_page > end) {
next_page = end;
}
p = program_page(i, p, next_page - i);
i = next_page;
}
ENERGEST_OFF(ENERGEST_TYPE_FLASH_WRITE);
return size;
}
/*---------------------------------------------------------------------------*/
int
xmem_erase(long size, unsigned long addr)
{
unsigned long end = addr + size;
if(size % XMEM_ERASE_UNIT_SIZE != 0) {
PRINTF("xmem_erase: bad size\n");
return -1;
}
if(addr % XMEM_ERASE_UNIT_SIZE != 0) {
PRINTF("xmem_erase: bad offset\n");
return -1;
}
for (; addr < end; addr += XMEM_ERASE_UNIT_SIZE) {
erase_sector(addr);
}
return size;
}
/*---------------------------------------------------------------------------*/

View File

@ -1,102 +0,0 @@
/**
* \file
* Functions for reading and writing flash ROM.
* \author Adam Dunkels <adam@sics.se>
*/
/* Copyright (c) 2004 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#include "contiki.h"
#include "dev/flash.h"
#include "dev/watchdog.h"
#define FLASH_TIMEOUT 30
#define FLASH_REQ_TIMEOUT 150
static uint16_t sfrie;
/*---------------------------------------------------------------------------*/
void
flash_setup(void)
{
/* disable all interrupts to protect CPU
during programming from system crash */
dint();
/* Clear interrupt flag1. */
SFRIFG1 = 0;
/* The IFG1 = 0; statement locks up contikimac - not sure if this
statement needs to be here at all. I've removed it for now, since
it seems to work, but leave this little note here in case someone
stumbles over this code at some point. */
/* Stop watchdog. */
watchdog_stop();
/* disable all NMI-Interrupt sources */
sfrie = SFRIE1;
SFRIE1 = 0x00;
}
/*---------------------------------------------------------------------------*/
void
flash_done(void)
{
/* Enable interrupts. */
SFRIE1 = sfrie;
eint();
watchdog_start();
}
/*---------------------------------------------------------------------------*/
void
flash_clear(unsigned short *ptr)
{
uint8_t r;
FCTL3 = 0xA500; /* Lock = 0 */
while(FCTL3 & 0x0001) r++; /* Wait for BUSY = 0, not needed
unless run from RAM */
FCTL1 = 0xA502; /* ERASE = 1 */
*ptr = 0; /* erase Flash segment */
FCTL1 = 0xA500; /* ERASE = 0 automatically done?! */
FCTL3 = 0xA510; /* Lock = 1 */
}
/*---------------------------------------------------------------------------*/
void
flash_write(unsigned short *ptr, unsigned short word)
{
uint8_t r;
FCTL3 = 0xA500; /* Lock = 0 */
while(FCTL3 & 0x0001) r++; /* Wait for BUSY = 0, not needed unless
run from RAM */
FCTL1 = 0xA540; /* WRT = 1 */
*ptr = word; /* program Flash word */
FCTL1 = 0xA500; /* WRT = 0 */
FCTL3 = 0xA510; /* Lock = 1 */
}
/*---------------------------------------------------------------------------*/

View File

@ -1,83 +0,0 @@
/*
* Copyright (c) 2011, 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
* Leds arch specific file for the WiSMote platform
* \author
* Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
*/
#include "contiki.h"
#include "dev/leds.h"
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
P2DIR |= BIT4;
P2OUT |= BIT4;
P5OUT |= BIT2;
P5DIR |= BIT2;
P8DIR |= BIT6;
P8OUT |= BIT6;
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_arch_get(void)
{
return ((P2OUT & BIT4) ? 0 : LEDS_GREEN)
| ((P5OUT & BIT2) ? 0 : LEDS_YELLOW)
| ((P8OUT & BIT6) ? 0 : LEDS_RED);
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
{
if(leds & LEDS_GREEN) {
P2OUT &= ~BIT4;
} else {
P2OUT |= BIT4;
}
if(leds & LEDS_YELLOW) {
P5OUT &= ~BIT2;
} else {
P5OUT |= BIT2;
}
if(leds & LEDS_RED) {
P8OUT &= ~BIT6;
} else {
P8OUT |= BIT6;
}
}
/*---------------------------------------------------------------------------*/

View File

@ -1,71 +0,0 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* Utility to store a node id in the external flash
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "sys/node-id.h"
#include "contiki-conf.h"
#include "dev/xmem.h"
unsigned short node_id = 0;
/*---------------------------------------------------------------------------*/
void
node_id_restore(void)
{
unsigned char buf[4];
xmem_pread(buf, 4, NODE_ID_XMEM_OFFSET);
if(buf[0] == 0xad &&
buf[1] == 0xde) {
node_id = (buf[2] << 8) | buf[3];
} else {
node_id = 0;
}
}
/*---------------------------------------------------------------------------*/
void
node_id_burn(unsigned short id)
{
unsigned char buf[4];
buf[0] = 0xad;
buf[1] = 0xde;
buf[2] = id >> 8;
buf[3] = id & 0xff;
xmem_erase(XMEM_ERASE_UNIT_SIZE, NODE_ID_XMEM_OFFSET);
xmem_pwrite(buf, 4, NODE_ID_XMEM_OFFSET);
}
/*---------------------------------------------------------------------------*/

View File

@ -1,202 +0,0 @@
/*
* Copyright (c) 2010, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/**
* \file
* Platform configuration for the wismote platform.
*/
#ifndef PLATFORM_CONF_H_
#define PLATFORM_CONF_H_
/*
* Definitions below are dictated by the hardware and not really
* changeable!
*/
#define PLATFORM_HAS_LEDS 1
#define PLATFORM_HAS_BUTTON 1
/* CPU target speed in Hz */
#define F_CPU 16000000uL
/* Our clock resolution, this is the same as Unix HZ. */
#define CLOCK_CONF_SECOND 128UL
#define RTIMER_CONF_SECOND (4096U*8)
#define BAUD2UBR(baud) (baud)
#define CCIF
#define CLIF
#define HAVE_STDINT_H
#include "msp430def.h"
/* Types for clocks and uip_stats */
typedef unsigned short uip_stats_t;
typedef unsigned long clock_time_t;
typedef unsigned long off_t;
/* the low-level radio driver */
#define NETSTACK_CONF_RADIO cc2520_driver
#define ROM_ERASE_UNIT_SIZE 512
#define XMEM_ERASE_UNIT_SIZE (64*1024L)
#define CFS_CONF_OFFSET_TYPE long
/* Use the first 64k of external flash for node configuration */
#define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE)
/* Use the second 64k of external flash for codeprop. */
#define EEPROMFS_ADDR_CODEPROP (1 * XMEM_ERASE_UNIT_SIZE)
#define CFS_XMEM_CONF_OFFSET (2 * XMEM_ERASE_UNIT_SIZE)
#define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE)
#define CFS_RAM_CONF_SIZE 4096
/*
* SPI bus configuration for the wismote
*/
/* SPI input/output registers. */
#define SPI_TXBUF UCB0TXBUF
#define SPI_RXBUF UCB0RXBUF
/* USART0 Tx ready? */
#define SPI_WAITFOREOTx() while ((UCB0STAT & UCBUSY) != 0)
/* USART0 Rx ready? */
#define SPI_WAITFOREORx() while ((UCB0IFG & UCRXIFG) == 0)
/* USART0 Tx buffer ready? */
#define SPI_WAITFORTxREADY() while ((UCB0IFG & UCTXIFG) == 0)
/* /\* USART0 Tx ready? *\/ */
/* #define SPI_WAITFOREOTx() while (!(UCB0IFG & UCRXIFG)) */
/* /\* USART0 Rx ready? *\/ */
/* #define SPI_WAITFOREORx() while (!(UCB0IFG & UCRXIFG)) */
/* /\* USART0 Tx buffer ready? *\/ */
/* #define SPI_WAITFORTxREADY() while (!(UCB0IFG & UCRXIFG)) */
/* #define SPI_BUSY_WAIT() while ((UCB0STAT & UCBUSY) == 1) */
#define MOSI 1 /* P3.1 - Output: SPI Master out - slave in (MOSI) */
#define MISO 2 /* P3.2 - Input: SPI Master in - slave out (MISO) */
#define SCK 3 /* P3.3 - Output: SPI Serial Clock (SCLK) */
/* #define SCK 1 /\* P3.1 - Output: SPI Serial Clock (SCLK) *\/ */
/* #define MOSI 2 /\* P3.2 - Output: SPI Master out - slave in (MOSI) *\/ */
/* #define MISO 3 /\* P3.3 - Input: SPI Master in - slave out (MISO) *\/ */
/*
* SPI bus - M25P80 external flash configuration.
*/
#define FLASH_PWR //3 /* P4.3 Output */
#define FLASH_CS //4 /* P4.4 Output */
#define FLASH_HOLD //7 /* P4.7 Output */
/* Enable/disable flash access to the SPI bus (active low). */
/* ENABLE CSn (active low) */
#define SPI_FLASH_ENABLE() do{ UCB0CTL1 &= ~UCSWRST; clock_delay(5); P4OUT &= ~BIT0;clock_delay(5);}while(0)
/* DISABLE CSn (active low) */
#define SPI_FLASH_DISABLE() do{clock_delay(5);UCB0CTL1 |= UCSWRST;clock_delay(1); P4OUT |= BIT0;clock_delay(5);}while(0)
#define SPI_FLASH_HOLD() // ( P4OUT &= ~BV(FLASH_HOLD) )
#define SPI_FLASH_UNHOLD() //( P4OUT |= BV(FLASH_HOLD) )
/*
* SPI bus - CC2520 pin configuration.
*/
#define CC2520_CONF_SYMBOL_LOOP_COUNT 2604 /* 326us msp430X @ 16MHz */
/* P1.6 - Input: FIFOP from CC2520 */
#define CC2520_FIFOP_PORT(type) P1##type
#define CC2520_FIFOP_PIN 6
/* P1.5 - Input: FIFO from CC2520 */
#define CC2520_FIFO_PORT(type) P1##type
#define CC2520_FIFO_PIN 5
/* P1.7 - Input: CCA from CC2520 */
#define CC2520_CCA_PORT(type) P1##type
#define CC2520_CCA_PIN 7
/* P2.0 - Input: SFD from CC2520 */
#define CC2520_SFD_PORT(type) P2##type
#define CC2520_SFD_PIN 0
/* P3.0 - Output: SPI Chip Select (CS_N) */
#define CC2520_CSN_PORT(type) P3##type
#define CC2520_CSN_PIN 0
/* P4.3 - Output: VREG_EN to CC2520 */
#define CC2520_VREG_PORT(type) P4##type
#define CC2520_VREG_PIN 3
/* P4.4 - Output: RESET_N to CC2520 */
#define CC2520_RESET_PORT(type) P4##type
#define CC2520_RESET_PIN 4
#define CC2520_IRQ_VECTOR PORT1_VECTOR
/* Pin status.CC2520 */
#define CC2520_FIFOP_IS_1 (!!(CC2520_FIFOP_PORT(IN) & BV(CC2520_FIFOP_PIN)))
#define CC2520_FIFO_IS_1 (!!(CC2520_FIFO_PORT(IN) & BV(CC2520_FIFO_PIN)))
#define CC2520_CCA_IS_1 (!!(CC2520_CCA_PORT(IN) & BV(CC2520_CCA_PIN)))
#define CC2520_SFD_IS_1 (!!(CC2520_SFD_PORT(IN) & BV(CC2520_SFD_PIN)))
/* The CC2520 reset pin. */
#define SET_RESET_INACTIVE() (CC2520_RESET_PORT(OUT) |= BV(CC2520_RESET_PIN))
#define SET_RESET_ACTIVE() (CC2520_RESET_PORT(OUT) &= ~BV(CC2520_RESET_PIN))
/* CC2520 voltage regulator enable pin. */
#define SET_VREG_ACTIVE() (CC2520_VREG_PORT(OUT) |= BV(CC2520_VREG_PIN))
#define SET_VREG_INACTIVE() (CC2520_VREG_PORT(OUT) &= ~BV(CC2520_VREG_PIN))
/* CC2520 rising edge trigger for external interrupt 0 (FIFOP). */
#define CC2520_FIFOP_INT_INIT() do { \
CC2520_FIFOP_PORT(IES) &= ~BV(CC2520_FIFOP_PIN); \
CC2520_CLEAR_FIFOP_INT(); \
} while(0)
/* FIFOP on external interrupt 0. */
/* FIFOP on external interrupt 0. */
#define CC2520_ENABLE_FIFOP_INT() do { P1IE |= BV(CC2520_FIFOP_PIN); } while (0)
#define CC2520_DISABLE_FIFOP_INT() do { P1IE &= ~BV(CC2520_FIFOP_PIN); } while (0)
#define CC2520_CLEAR_FIFOP_INT() do { P1IFG &= ~BV(CC2520_FIFOP_PIN); } while (0)
/*
* Enables/disables CC2520 access to the SPI bus (not the bus).
* (Chip Select)
*/
/* ENABLE CSn (active low) */
#define CC2520_SPI_ENABLE() do{ UCB0CTL1 &= ~UCSWRST; clock_delay(5); P3OUT &= ~BIT0;clock_delay(5);}while(0)
/* DISABLE CSn (active low) */
#define CC2520_SPI_DISABLE() do{clock_delay(5);UCB0CTL1 |= UCSWRST;clock_delay(1); P3OUT |= BIT0;clock_delay(5);}while(0)
#define CC2520_SPI_IS_ENABLED() ((CC2520_CSN_PORT(OUT) & BV(CC2520_CSN_PIN)) != BV(CC2520_CSN_PIN))
#endif /* PLATFORM_CONF_H_ */

View File

@ -1,171 +0,0 @@
<?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>LWM2M &amp; IPSO Objects Example</title>
<speedlimit>1.0</speedlimit>
<randomseed>123456</randomseed>
<motedelay_us>1000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>100.0</interference_range>
<success_ratio_tx>1.0</success_ratio_tx>
<success_ratio_rx>1.0</success_ratio_rx>
</radiomedium>
<events>
<logoutput>40000</logoutput>
</events>
<motetype>
org.contikios.cooja.mspmote.WismoteMoteType
<identifier>wismote1</identifier>
<description>Wismote Border Router #border-router</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.c</source>
<commands EXPORT="discard">make border-router.wismote TARGET=wismote DEFINES=NETSTACK_RDC=nullrdc_driver,NETSTACK_MAC=nullmac_driver</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.wismote</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<motetype>
org.contikios.cooja.mspmote.WismoteMoteType
<identifier>wismote2</identifier>
<description>Wismote IPSO Objects #ipso-example</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipso-objects/example-ipso-objects.c</source>
<commands EXPORT="discard">make example-ipso-objects.wismote TARGET=wismote</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipso-objects/example-ipso-objects.wismote</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>56.362361976162035</x>
<y>11.826023799100883</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>wismote1</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>60.1539674439426</x>
<y>11.827942168467365</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>wismote2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>280</width>
<z>2</z>
<height>160</height>
<location_x>400</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<moterelations>true</moterelations>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.LEDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin</skin>
<viewport>53.336918739504526 0.0 0.0 53.336918739504526 -2924.9161170527295 -473.3614543395965</viewport>
</plugin_config>
<width>400</width>
<z>4</z>
<height>400</height>
<location_x>1</location_x>
<location_y>1</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter>ID:2</filter>
<formatted_time />
<coloring />
</plugin_config>
<width>1286</width>
<z>1</z>
<height>240</height>
<location_x>400</location_x>
<location_y>160</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Notes
<plugin_config>
<notes>OMA LWM2M &amp; IPSO Object example
1. Start a LWM2M server, for example Leshan
2. Run the example and bridge Cooja using tunslip with the prefix aaaa::1/64:
(cd contiki/examples/ipso-objects &amp;&amp; make connect-router-cooja)
After a short time, the example node should register with the LWM2M server at [aaaa::1]:5683.</notes>
<decorations>true</decorations>
</plugin_config>
<width>1006</width>
<z>0</z>
<height>160</height>
<location_x>680</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.serialsocket.SerialSocketServer
<mote_arg>0</mote_arg>
<plugin_config>
<port>60001</port>
<bound>true</bound>
</plugin_config>
<width>362</width>
<z>3</z>
<height>116</height>
<location_x>1</location_x>
<location_y>399</location_y>
</plugin>
</simconf>

View File

@ -1,187 +0,0 @@
<?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>OMA LWM2M and IPSO Object example</title>
<speedlimit>2.0</speedlimit>
<randomseed>123456</randomseed>
<motedelay_us>1000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>500.0</transmitting_range>
<interference_range>500.0</interference_range>
<success_ratio_tx>1.0</success_ratio_tx>
<success_ratio_rx>1.0</success_ratio_rx>
</radiomedium>
<events>
<logoutput>40000</logoutput>
</events>
<motetype>
org.contikios.cooja.mspmote.WismoteMoteType
<identifier>wismote1</identifier>
<description>Wismote Router #wismote1</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipso-objects/example-server.c</source>
<commands EXPORT="discard">make example-server.wismote TARGET=wismote</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipso-objects/example-server.wismote</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<motetype>
org.contikios.cooja.mspmote.WismoteMoteType
<identifier>wismote2</identifier>
<description>Wismote Mote Type #wismote2</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipso-objects/example-ipso-objects.c</source>
<commands EXPORT="discard">make example-ipso-objects.wismote TARGET=wismote</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipso-objects/example-ipso-objects.wismote</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>30.243188653185154</x>
<y>29.963547412144486</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspDefaultSerial
<history>s aaaa::200:0:0:3 /3311/0/5850 0~;s aaaa::200:0:0:3 /3311/0/5850 1~;g aaaa::200:0:0:3 /3311/1/5850~;g aaaa::200:0:0:3 /3311/0/5850~;g aaaa::200:0:0:3 /3311/1/5850~;g aaaa::200:0:0:3 /3311/0/5850~;s aaaa::200:0:0:3 /3311/0/5850 1~;s aaaa::200:0:0:2 /3311/0/5850 1~;h~;s aaaa::200:0:0:2 /3311/0/5850 1~;s aaaa::200:0:0:2 /3311/0/5850 0~;g aaaa::200:0:0:2 /3311/0/5850~;g aaaa::200:0:0:2 /3311/1/5850~;g aaaa::200:0:0:2 /3311/2/5850~;l~;</history>
</interface_config>
<motetype_identifier>wismote1</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>59.75123136831088</x>
<y>29.84506209179908</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>wismote2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>60.30742753391745</x>
<y>59.35092511889063</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>3</id>
</interface_config>
<motetype_identifier>wismote2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>280</width>
<z>0</z>
<height>160</height>
<location_x>400</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<moterelations>true</moterelations>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.LEDVisualizerSkin</skin>
<viewport>4.593848158957425 0.0 0.0 4.593848158957425 13.734375417550426 -121.37641081710846</viewport>
</plugin_config>
<width>400</width>
<z>3</z>
<height>400</height>
<location_x>1</location_x>
<location_y>1</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter />
<formatted_time />
<coloring />
</plugin_config>
<width>959</width>
<z>2</z>
<height>447</height>
<location_x>400</location_x>
<location_y>160</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Notes
<plugin_config>
<notes>Enter notes here</notes>
<decorations>true</decorations>
</plugin_config>
<width>679</width>
<z>1</z>
<height>160</height>
<location_x>680</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.MoteInterfaceViewer
<mote_arg>0</mote_arg>
<plugin_config>
<interface>Serial port</interface>
<scrollpos>0,0</scrollpos>
</plugin_config>
<width>579</width>
<z>4</z>
<height>300</height>
<location_x>49</location_x>
<location_y>414</location_y>
</plugin>
</simconf>

View File

@ -34,9 +34,9 @@
#define LWM2M_DEVICE_MODEL_NUMBER BOARD_STRING
#elif defined(CONTIKI_TARGET_WISMOTE)
#include "dev/watchdog.h"
#define LWM2M_DEVICE_MODEL_NUMBER "wismote"
#define LWM2M_DEVICE_MANUFACTURER "Arago Systems"
#define LWM2M_DEVICE_SERIAL_NO "001"
#define LWM2M_DEVICE_MODEL_NUMBER "LWM2M_DEVICE_MODEL_NUMBER"
#define LWM2M_DEVICE_MANUFACTURER "LWM2M_DEVICE_MANUFACTURER"
#define LWM2M_DEVICE_SERIAL_NO "LWM2M_DEVICE_SERIAL_NO"
#define PLATFORM_REBOOT watchdog_reboot
#endif

View File

@ -1,721 +0,0 @@
<?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>RPL up and downstream scaleability test network using IPv6 and RPL</title>
<randomseed>generated</randomseed>
<motedelay_us>5000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>150.0</transmitting_range>
<interference_range>150.0</interference_range>
<success_ratio_tx>1.0</success_ratio_tx>
<success_ratio_rx>1.0</success_ratio_rx>
</radiomedium>
<events>
<logoutput>40000</logoutput>
</events>
<motetype>
org.contikios.cooja.mspmote.WismoteMoteType
<identifier>sky1</identifier>
<description>WisMote Type #sky1</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.c</source>
<commands EXPORT="discard">make SERVER_REPLY=1 clean udp-server.wismote TARGET=wismote DEFINES=TEST_MORE_ROUTES=1</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-server.wismote</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<motetype>
org.contikios.cooja.mspmote.WismoteMoteType
<identifier>sky2</identifier>
<description>WisMote Type #sky2</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.c</source>
<commands EXPORT="discard">make SERVER_REPLY=1 clean udp-client.wismote TARGET=wismote</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-udp/udp-client.wismote</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>48.435974731198804</x>
<y>-66.16503914182063</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>sky1</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-65.3176930733124</x>
<y>17.4304162608286</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>2</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>127.9689727848476</x>
<y>91.71883780610729</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>3</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>154.92605604103275</x>
<y>40.97896551774433</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>4</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.34887596588397</x>
<y>-30.341495695501195</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>5</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>47.13486576528276</x>
<y>32.944481932122315</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>6</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-11.42091423859419</x>
<y>17.879870626121914</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>7</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>118.92746659954325</x>
<y>57.05973076244069</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>8</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>56.66768196114595</x>
<y>74.35652008990945</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>9</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>16.45706316609417</x>
<y>23.9075414163248</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>10</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-13.423161364506493</x>
<y>-38.483037144768275</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>11</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-9.034961217472201</x>
<y>44.411389162165406</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>12</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>35.60049910164592</x>
<y>87.95154356223047</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>13</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>66.93880603404335</x>
<y>-42.39683727590697</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>14</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.81678343873172</x>
<y>26.921376811426246</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>15</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-49.449656689283934</x>
<y>57.924813144367945</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>16</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-34.02467970185502</x>
<y>-24.313824905298304</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>17</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-28.750467760427494</x>
<y>48.01822457713635</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>18</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>124.95513738974614</x>
<y>20.140247172447996</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>19</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>14.85247487703553</x>
<y>-34.478542892943686</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>20</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>154.43072661267115</x>
<y>-3.279765376986134</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>21</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>99.90960713878738</x>
<y>-21.76043658444847</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>22</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>88.4612185198951</x>
<y>-49.763990463932714</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>23</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>24.745110502623138</x>
<y>-1.7100594420374744</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>24</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>94.06332458995635</x>
<y>-2.4635182908128352</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>25</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-4.639784599615941</x>
<y>-10.849236218849724</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>26</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>2.4901685804620115</x>
<y>-60.89843789583528</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>27</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>100.55144245441083</x>
<y>97.41861446767646</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>28</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>-12.355761328741393</x>
<y>82.72616691655692</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>29</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>57.79962925723111</x>
<y>0.6828700499064966</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>30</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>76.5550413097159</x>
<y>77.33875258624342</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspClock
<deviation>1.0</deviation>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>31</id>
</interface_config>
<motetype_identifier>sky2</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>289</width>
<z>4</z>
<height>184</height>
<location_x>31</location_x>
<location_y>41</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<moterelations>true</moterelations>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.AttributeVisualizerSkin</skin>
<viewport>2.349818846983307 0.0 0.0 2.349818846983307 187.19773526533345 190.95275613586946</viewport>
</plugin_config>
<width>659</width>
<z>2</z>
<height>622</height>
<location_x>296</location_x>
<location_y>11</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter>ID:22.*DAO</filter>
<formatted_time />
<coloring />
</plugin_config>
<width>937</width>
<z>3</z>
<height>442</height>
<location_x>20</location_x>
<location_y>297</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.ScriptRunner
<plugin_config>
<script>TIMEOUT(12000000, log.log("Total PRR " + totalPRR + "\n"));
packetsReceived= new Array();
packetsSent = new Array();
serverID = 1;
nodeCount = 31;
totalPRR = 0;
for(i = 0; i &lt;= nodeCount; i++) {
packetsReceived[i] = 0;
packetsSent[i] = 0;
}
while(1) {
YIELD();
msgArray = msg.split(' ');
if(msgArray[0].equals("#A")) {
if(msgArray[1].charAt(0) == 'r') {
// Received packet
senderID = id;
arr2 = msgArray[1].split(',')[0].slice(2).split('/');
recv = parseInt(arr2[0]);
sent = parseInt(arr2[1]);
log.log("Sent:" + sent + " Recv:" + recv + "\n");
packetsSent[senderID] = sent;
packetsReceived[senderID] = recv;
log.log("SenderID " + senderID + " PRR " + packetsReceived[senderID] / packetsSent[senderID] + "\n");
totalReceived = totalSent = 0;
for(i = serverID + 1; i &lt;= nodeCount; i++) {
totalReceived += packetsReceived[i];
totalSent += packetsSent[i];
}
totalPRR = totalReceived / totalSent;
log.log("Total PRR " + totalPRR + " recv " + totalReceived + " sent " + totalSent + "\n");
}
}
}</script>
<active>true</active>
</plugin_config>
<width>600</width>
<z>5</z>
<height>700</height>
<location_x>946</location_x>
<location_y>6</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.MoteInterfaceViewer
<mote_arg>3</mote_arg>
<plugin_config>
<interface>Position</interface>
<scrollpos>0,0</scrollpos>
</plugin_config>
<width>350</width>
<z>6</z>
<height>300</height>
<location_x>976</location_x>
<location_y>36</location_y>
</plugin>
</simconf>

View File

@ -4,11 +4,8 @@ TOOLSDIR=../../tools
EXAMPLES = \
hello-world/native \
hello-world/sky \
hello-world/wismote \
hello-world/z1 \
eeprom-test/native \
ipv6/er-rest-example/wismote \
ipso-objects/wismote \
platform-specific/zolertia/z1/z1 \
ipv6/multicast/sky \
sensniff/z1 \

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<simulation>
<title>Hello World (Wismote)</title>
<randomseed>generated</randomseed>
<motedelay_us>1000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>100.0</interference_range>
<success_ratio_tx>1.0</success_ratio_tx>
<success_ratio_rx>1.0</success_ratio_rx>
</radiomedium>
<events>
<logoutput>40000</logoutput>
</events>
<motetype>
org.contikios.cooja.mspmote.WismoteMoteType
<identifier>wismote1</identifier>
<description>Wismote Mote Type #wismote1</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/hello-world/hello-world.c</source>
<commands EXPORT="discard">make hello-world.wismote TARGET=wismote</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/hello-world/hello-world.wismote</firmware>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
</motetype>
<mote>
<breakpoints />
<interface_config>
org.contikios.cooja.interfaces.Position
<x>36.76551518369201</x>
<y>29.330591009779383</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<motetype_identifier>wismote1</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>280</width>
<z>2</z>
<height>160</height>
<location_x>22</location_x>
<location_y>14</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter />
</plugin_config>
<width>680</width>
<z>1</z>
<height>240</height>
<location_x>84</location_x>
<location_y>408</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.ScriptRunner
<plugin_config>
<scriptfile>[CONFIG_DIR]/hello-world.js</scriptfile>
<active>true</active>
</plugin_config>
<width>600</width>
<z>0</z>
<height>548</height>
<location_x>335</location_x>
<location_y>22</location_y>
</plugin>
</simconf>