Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki

This commit is contained in:
nvt 2012-04-12 21:35:02 +02:00
commit d3fee514b3
63 changed files with 1470 additions and 535 deletions

View file

@ -1057,7 +1057,6 @@ PT_THREAD(ajax_call(struct httpd_state *s, char *ptr))
static int iter;
static char buf[128];
static uint8_t numprinted;
uint16_t dt;
PSOCK_BEGIN(&s->sout);
#if WEBSERVER_CONF_PASSQUERY

View file

@ -3,7 +3,7 @@
function e(el){return document.getElementById(el);}
function ls(){try{r=new XMLHttpRequest();}catch(e){alert("Browswer does not support Ajax");return false;}r.open("GET","/ajaxdata.shtml",true);
x=0;r.onreadystatechange=function(){e('date').innerHTML=(new Date()).toTimeString();if(r.readyState>0){j=r.responseText.substr(x);x+=j.length;eval(j);}};r.send(null);}
function tb(x){var t=e('ss');if(x||t.value=="RUN"){t.value="STOP";ls();}else{t.value="RUN";r.abort();}}
function tb(x){var t=e('ss');try{r.abort();}if(x||t.value=="RUN"){t.value="STOP";ls();}else t.value="RUN";}
function s(el,n,max,text){e(el).innerHTML='<table width=504 border=0 cellpadding=1 cellspacing=0>'+'<tr><td width=200>'+text+'</td>'+'<td width='+(10+300*n/max)+' bgcolor="gray">&nbsp;</td>'+'<td width='+(310-300*n/max)+' bgcolor="lightgray">&nbsp;</td>'+'</table>';}
function wt(m){document.title=m;e('v').innerHTML=m;}
function dc(n,d){return n.toFixed(d);}

View file

@ -6,17 +6,28 @@
* \defgroup clock Clock library
*
* The clock library is the interface between Contiki and the platform
* specific clock functionality. The clock library performs a single
* function: measuring time. Additionally, the clock library provides
* a macro, CLOCK_SECOND, which corresponds to one second of system
* time.
* specific clock functionality. The clock library defines a macro,
* CLOCK_SECOND, to convert seconds into the tick resolution of the platform.
* Typically this is 1-10 milliseconds, e.g. 4*CLOCK_SECOND could be 512.
* A 16 bit counter would thus overflow every 1-10 minutes.
* Platforms use the tick interrupt to maintain a long term count
* of seconds since startup.
*
* Platforms may also implement rtimers for greater time resolution
* and for real-time interrupts, These use a corresponding RTIMER_SECOND.
*
* \note These timers do not necessarily have a common divisor or are phase locked.
* One may be crystal controlled and the other may not. Low power operation
* or sleep will often use one for wake and disable the other, then give
* it a tick correction after wakeup.
*
* \note The clock library need in many cases not be used
* directly. Rather, the \ref timer "timer library" or the \ref etimer
* "event timers" should be used.
* directly. Rather, the \ref timer "timer library", \ref etimer
* "event timers", or \ref trimer "rtimer library" should be used.
*
* \sa \ref timer "Timer library"
* \sa \ref etimer "Event timers"
* \sa \ref rtimer "Realtime library"
*
* @{
*/
@ -53,24 +64,22 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: clock.h,v 1.11 2009/01/24 15:20:11 adamdunkels Exp $
*/
#ifndef __CLOCK_H__
#define __CLOCK_H__
#include "contiki-conf.h"
#if 0 /* XXX problems with signedness and use in timer_expired(). #if:ed it out for now. */
/**
* Check if a clock time value is less than another clock time value.
*
* This macro checks if a clock time value is less than another clock
* time value. This macro is needed to correctly handle wrap-around of
* clock time values.
* A second, measured in system clock time.
*
* \hideinitializer
*/
#define CLOCK_LT(a, b) ((clock_time_t)((a) - (b)) < ((clock_time_t)(~((clock_time_t)0)) >> 1))
#endif /* 0 */
#ifdef CLOCK_CONF_SECOND
#define CLOCK_SECOND CLOCK_CONF_SECOND
#else
#define CLOCK_SECOND (clock_time_t)32
#endif
/**
* Initialize the clock library.
@ -90,24 +99,45 @@ void clock_init(void);
*/
CCIF clock_time_t clock_time(void);
void clock_delay(unsigned int);
/**
* A second, measured in system clock time.
* Get the current value of the platform seconds.
*
* \hideinitializer
* This could be the number of seconds since startup, or
* since a standard epoch.
*
* \return The value.
*/
#ifdef CLOCK_CONF_SECOND
#define CLOCK_SECOND CLOCK_CONF_SECOND
#else
#define CLOCK_SECOND (clock_time_t)32
#endif
int clock_fine_max(void);
unsigned short clock_fine(void);
CCIF unsigned long clock_seconds(void);
/**
* Set the value of the platform seconds.
* \param sec The value to set.
*
*/
void clock_set_seconds(unsigned long sec);
/**
* Wait for a given number of ticks.
* \param t How many ticks.
*
*/
void clock_wait(clock_time_t t);
/**
* Delay a given number of microseconds.
* \param dt How many microseconds to delay.
*
* \note Interrupts could increase the delay by a variable amount.
*/
void clock_delay_usec(uint16_t dt);
/**
* Deprecated platform-specific routines.
*
*/
int clock_fine_max(void);
unsigned short clock_fine(void);
void clock_delay(unsigned int delay);
#endif /* __CLOCK_H__ */

View file

@ -1,4 +1,69 @@
/*
* Copyright (c) 2012, 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.
*
*/
/**
* \brief This module contains AVR-specific code to implement
* the Contiki core clock functions.
*
* \author David Kopf <dak664@embarqmail.com> and others.
*
*/
/** \addtogroup avr
* @{
*/
/**
* \defgroup avrclock AVR clock implementation
* @{
*/
/**
* \file
* This file contains AVR-specific code to implement the Contiki core clock functions.
*
*/
/**
* These routines define the AVR-specific calls declared in /core/sys/clock.h
* CLOCK_SECOND is the number of ticks per second.
* It is defined through CONF_CLOCK_SECOND in the contiki-conf.h for each platform.
* The usual AVR defaults are 128 or 125 ticks per second, counting a prescaled CPU clock
* using the 8 bit timer0.
*
* clock_time_t is usually declared by the platform as an unsigned 16 bit data type,
* thus intervals up to 512 or 524 seconds can be measured with ~8 millisecond precision.
* For longer intervals the 32 bit clock_seconds() is available.
*
* Since a carry to a higer byte can occur during an interrupt, declaring them non-static
* for direct examination can cause occasional time reversals!
*
* clock-avr.h contains the specific setup code for each mcu.
*/
#include "sys/clock.h"
#include "dev/clock-avr.h"
#include "sys/etimer.h"
@ -6,25 +71,18 @@
#include <avr/io.h>
#include <avr/interrupt.h>
/*
CLOCK_SECOND is the number of ticks per second.
It is defined through CONF_CLOCK_SECOND in the contiki-conf.h for each platform.
The usual AVR defaults are 128 or 125 ticks per second, counting a prescaled CPU clock
using the 8 bit timer0.
/* Two tick counters avoid a software divide when CLOCK_SECOND is not a power of two. */
#if CLOCK_SECOND && (CLOCK_SECOND - 1)
#define TWO_COUNTERS 1
#endif
As clock_time_t is an unsigned 16 bit data type, intervals up to 512 or 524 seconds
can be measured with ~8 millisecond precision.
For longer intervals a 32 bit global is incremented every second.
clock-avr.h contains the specific setup code for each mcu.
*/
/* count is a 16 bit tick counter that wraps every ~10 minutes, returned by clock_time() */
/* count is usually a 16 bit variable, although the platform can declare it otherwise */
static volatile clock_time_t count;
#if TWO_COUNTERS
/* scount is the 8 bit counter that counts ticks modulo CLOCK_SECONDS */
static volatile uint8_t scount;
/* seconds is the number of seconds since startup, returned by clock_seconds() */
#endif
/* seconds is available globally but non-atomic update during interrupt can cause time reversals */
volatile unsigned long seconds;
/* sleepseconds is the number of seconds sleeping since startup, available globally */
long sleepseconds;
@ -50,99 +108,243 @@ extern volatile uint8_t rf230_calibrate;
static uint8_t calibrate_interval;
#endif
/*---------------------------------------------------------------------------*/
/**
* Start the clock by enabling the timer comparison interrupts.
*/
void
clock_init(void)
{
cli ();
OCRSetup();
sei ();
}
/*---------------------------------------------------------------------------*/
/**
* Return the tick counter. When 16 bit it typically wraps every 10 minutes.
* The comparison avoids the need to disable clock interrupts for an atomic
* read of the multi-byte variable.
*/
clock_time_t
clock_time(void)
{
clock_time_t tmp;
do {
tmp = count;
} while(tmp != count);
return tmp;
}
/*---------------------------------------------------------------------------*/
/**
* Return seconds, default is time since startup.
* The comparison avoids the need to disable clock interrupts for an atomic
* read of the four-byte variable.
*/
unsigned long
clock_seconds(void)
{
unsigned long tmp;
do {
tmp = seconds;
} while(tmp != seconds);
return tmp;
}
/*---------------------------------------------------------------------------*/
/**
* Set seconds, e.g. to a standard epoch for an absolute date/time.
*/
void
clock_set_seconds(unsigned long sec)
{
seconds = sec;
}
/*---------------------------------------------------------------------------*/
/**
* Wait for a number of clock ticks.
*/
void
clock_wait(clock_time_t t)
{
clock_time_t endticks = clock_time() + t;
if (sizeof(clock_time_t) == 1) {
while ((signed char )(clock_time() - endticks) < 0) {;}
} else if (sizeof(clock_time_t) == 2) {
while ((signed short)(clock_time() - endticks) < 0) {;}
} else {
while ((signed long )(clock_time() - endticks) < 0) {;}
}
}
/*---------------------------------------------------------------------------*/
/**
* Delay the CPU for up to 65535*(4000000/F_CPU) microseconds.
* Copied from _delay_loop_2 in AVR library delay_basic.h, 4 clocks per loop.
* For accurate short delays, inline _delay_loop_2 in the caller, use a constant
* value for the delay, and disable interrupts if necessary.
*/
static inline void my_delay_loop_2(uint16_t __count) __attribute__((always_inline));
void
my_delay_loop_2(uint16_t __count)
{
__asm__ volatile (
"1: sbiw %0,1" "\n\t"
"brne 1b"
: "=w" (__count)
: "0" (__count)
);
}
void
clock_delay_usec(uint16_t howlong)
{
#if 0
/* Accurate delay at any frequency, but introduces a 64 bit intermediate
* and has a 279 clock overhead.
*/
if(howlong<=(uint16_t)(279000000UL/F_CPU)) return;
howlong-=(uint16_t) (279000000UL/F_CPU);
my_delay_loop_2(((uint64_t)(howlong) * (uint64_t) F_CPU) / 4000000ULL);
/* Remaining numbers tweaked for the breakpoint CPU frequencies */
/* Add other frequencies as necessary */
#elif F_CPU>=16000000UL
if(howlong<1) return;
my_delay_loop_2((howlong*(uint16_t)(F_CPU/3250000)));
#elif F_CPU >= 12000000UL
if(howlong<2) return;
howlong-=(uint16_t) (3*12000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/3250000)));
#elif F_CPU >= 8000000UL
if(howlong<4) return;
howlong-=(uint16_t) (3*8000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/2000000))/2);
#elif F_CPU >= 4000000UL
if(howlong<5) return;
howlong-=(uint16_t) (4*4000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/2000000))/2);
#elif F_CPU >= 2000000UL
if(howlong<11) return;
howlong-=(uint16_t) (10*2000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/1000000))/4);
#elif F_CPU >= 1000000UL
if(howlong<=17) return;
howlong-=(uint16_t) (17*1000000/F_CPU);
my_delay_loop_2((howlong*(uint16_t)(F_CPU/1000000))/4);
#else
howlong >> 5;
if (howlong < 1) return;
my_delay_loop_2(howlong);
#endif
}
#if 0
/*---------------------------------------------------------------------------*/
/* This routine can be called to add seconds to the clock after a sleep
* of an integral number of seconds.
/**
* Legacy delay. The original clock_delay for the msp430 used a granularity
* of 2.83 usec. This approximates that delay for values up to 1456 usec.
* (The largest core call in leds.c uses 400).
*/
void clock_adjust_seconds(uint8_t howmany) {
seconds += howmany;
sleepseconds +=howmany;
count += howmany * CLOCK_SECOND;
#if RADIOSTATS
if (RF230_receive_on) radioontime += howmany;
#endif
void
clock_delay(unsigned int howlong)
{
if(howlong<2) return;
clock_delay_usec((45*howlong)>>4);
}
#endif
/*---------------------------------------------------------------------------*/
/**
* Delay up to 65535 milliseconds.
* \param dt How many milliseconds to delay.
*
* Neither interrupts nor the watchdog timer is disabled over the delay.
* Platforms are not required to implement this call.
* \note This will break for CPUs clocked above 260 MHz.
*/
void
clock_delay_msec(uint16_t howlong)
{
/*---------------------------------------------------------------------------*/
/* This routine can be called to add ticks to the clock after a sleep.
* Leap ticks or seconds can (rarely) be introduced if the ISR is not blocked.
*/
void clock_adjust_ticks(uint16_t howmany) {
// uint8_t sreg = SREG;cli();
count += howmany;
howmany+= scount;
while(howmany >= CLOCK_SECOND) {
howmany -= CLOCK_SECOND;
seconds++;
sleepseconds++;
#if RADIOSTATS
if (RF230_receive_on) radioontime += 1;
#if F_CPU>=16000000
while(howlong--) clock_delay_usec(1000);
#elif F_CPU>=8000000
uint16_t i=996;
while(howlong--) {clock_delay_usec(i);i=999;}
#elif F_CPU>=4000000
uint16_t i=992;
while(howlong--) {clock_delay_usec(i);i=999;}
#elif F_CPU>=2000000
uint16_t i=989;
while(howlong--) {clock_delay_usec(i);i=999;}
#else
uint16_t i=983;
while(howlong--) {clock_delay_usec(i);i=999;}
#endif
}
scount = howmany;
// SREG=sreg;
}
/*---------------------------------------------------------------------------*/
//SIGNAL(SIG_OUTPUT_COMPARE0)
/**
* Adjust the system current clock time.
* \param dt How many ticks to add
*
* Typically used to add ticks after an MCU sleep
* clock_seconds will increment if necessary to reflect the tick addition.
* Leap ticks or seconds can (rarely) be introduced if the ISR is not blocked.
*/
void
clock_adjust_ticks(clock_time_t howmany)
{
uint8_t sreg = SREG;cli();
count += howmany;
#if TWO_COUNTERS
howmany+= scount;
#endif
while(howmany >= CLOCK_SECOND) {
howmany -= CLOCK_SECOND;
seconds++;
sleepseconds++;
#if RADIOSTATS
if (RF230_receive_on) radioontime += 1;
#endif
}
#if TWO_COUNTERS
scount = howmany;
#endif
SREG=sreg;
}
/*---------------------------------------------------------------------------*/
/* This it the timer comparison match interrupt.
* It maintains the tick counter, clock_seconds, and etimer updates.
*
* If the interrupts derive from an external crystal, the CPU instruction
* clock can optionally be phase locked to it. This allows accurate rtimer
* interrupts for strobe detection during radio duty cycling.
* Phase lock is accomplished by adjusting OSCCAL based on the phase error
* since the last interrupt.
*/
/*---------------------------------------------------------------------------*/
#if defined(DOXYGEN)
/** \brief ISR for the TIMER0 or TIMER2 interrupt as defined in
* clock-avr.h for the particular MCU.
*/
void AVR_OUTPUT_COMPARE_INT(void);
#else
ISR(AVR_OUTPUT_COMPARE_INT)
{
count++;
count++;
#if TWO_COUNTERS
if(++scount >= CLOCK_SECOND) {
scount = 0;
#else
if(count%CLOCK_SECOND==0) {
#endif
seconds++;
}
#if F_CPU == 0x800000 && USE_32K_CRYSTAL
/* Special routine to phase lock CPU to 32768 watch crystal.
We are interrupting 128 times per second.
If RTIMER_ARCH_SECOND is a multiple of 128 we can use the residual modulo
128 to determine whether the clock is too fast or too slow.
E.g. for 8192 the phase should be constant modulo 0x40
OSCCAL is started in the lower range at 90, allowed to stabilize, then
rapidly raised or lowered based on the phase comparison.
It gives less phase noise to do this every tick and doesn't seem to hurt anything.
*/
#include "rtimer-arch.h"
{
volatile static uint8_t lockcount;
volatile static int16_t last_phase;
volatile static uint8_t osccalhigh,osccallow;
if (seconds < 60) { //give a minute to stabilize
if(++lockcount >= 8192UL*128/RTIMER_ARCH_SECOND) {
lockcount=0;
rtimer_phase = TCNT3 & 0x0fff;
if (seconds < 2) OSCCAL=100;
if (last_phase > rtimer_phase) osccalhigh=++OSCCAL; else osccallow=--OSCCAL;
last_phase = rtimer_phase;
}
} else {
#if TICK_MODULO
static uint8_t lock_clock;
if (++lock_clock>=TICK_MODULO) {
lock_clock=0;
#endif
uint8_t error = (TCNT3 - last_phase) & 0x3f;
if (error == 0) {
} else if (error<32) {
OSCCAL=osccallow-1;
} else {
OSCCAL=osccalhigh+1;
}
#if TICK_MODULO
}
#endif
}
}
#endif
#if RADIO_CONF_CALIBRATE_INTERVAL
if (++calibrate_interval==0) {
rf230_calibrate=1;
}
/* Force a radio PLL frequency calibration every 256 seconds */
if (++calibrate_interval==0) {
rf230_calibrate=1;
}
#endif
}
#if RADIOSTATS
/* Sample radio on time. Less accurate than ENERGEST but a smaller footprint */
if (RF230_receive_on) {
if (++rcount >= CLOCK_SECOND) {
rcount=0;
@ -151,6 +353,41 @@ volatile static uint8_t osccalhigh,osccallow;
}
#endif
#if F_CPU == 0x800000 && USE_32K_CRYSTAL
/* Special routine to phase lock CPU to 32768 watch crystal.
* We are interrupting 128 times per second.
* If RTIMER_ARCH_SECOND is a multiple of 128 we can use the residual modulo
* 128 to determine whether the clock is too fast or too slow.
* E.g. for 8192 the phase should be constant modulo 0x40
* OSCCAL is started in the lower range at 90, allowed to stabilize, then
* rapidly raised or lowered based on the phase comparison.
* It gives less phase noise to do this every tick and doesn't seem to hurt anything.
*/
#include "rtimer-arch.h"
{
volatile static uint8_t lockcount;
volatile static int16_t last_phase;
volatile static uint8_t osccalhigh,osccallow;
if (seconds < 60) { //give a minute to stabilize
if(++lockcount >= 8192UL*128/RTIMER_ARCH_SECOND) {
lockcount=0;
rtimer_phase = TCNT3 & 0x0fff;
if (seconds < 2) OSCCAL=100;
if (last_phase > rtimer_phase) osccalhigh=++OSCCAL; else osccallow=--OSCCAL;
last_phase = rtimer_phase;
}
} else {
uint8_t error = (TCNT3 - last_phase) & 0x3f;
if (error == 0) {
} else if (error<32) {
OSCCAL=osccallow-1;
} else {
OSCCAL=osccalhigh+1;
}
}
}
#endif
#if 1
/* gcc will save all registers on the stack if an external routine is called */
if(etimer_pending()) {
@ -166,80 +403,17 @@ volatile static uint8_t osccalhigh,osccallow;
#define PROCESS_STATE_CALLED 2
if (timerlist) {
if(etimer_process.state == PROCESS_STATE_RUNNING ||
etimer_process.state == PROCESS_STATE_CALLED) {
if(etimer_process.state == PROCESS_STATE_RUNNING || etimer_process.state == PROCESS_STATE_CALLED) {
etimer_process.needspoll = 1;
poll_requested = 1;
}
}
#endif
}
#endif /* defined(DOXYGEN) */
/*---------------------------------------------------------------------------*/
void
clock_init(void)
{
cli ();
OCRSetup();
//scount = count = 0;
sei ();
}
/* Debugging aids */
/*---------------------------------------------------------------------------*/
clock_time_t
clock_time(void)
{
clock_time_t tmp;
do {
tmp = count;
} while(tmp != count);
return tmp;
}
#if 0
/*---------------------------------------------------------------------------*/
/**
* Delay the CPU for a multiple of TODO
*/
void
clock_delay(unsigned int i)
{
for (; i > 0; i--) { /* Needs fixing XXX */
unsigned j;
for (j = 50; j > 0; j--)
asm volatile("nop");
}
}
/*---------------------------------------------------------------------------*/
/**
* Wait for a number of clock ticks.
*
*/
void
clock_wait(int i)
{
clock_time_t start;
start = clock_time();
while(clock_time() - start < (clock_time_t)i);
}
/*---------------------------------------------------------------------------*/
void
clock_set_seconds(unsigned long sec)
{
seconds = sec;
}
#endif
unsigned long
clock_seconds(void)
{
unsigned long tmp;
do {
tmp = seconds;
} while(tmp != seconds);
return tmp;
}
#ifdef HANDLE_UNSUPPORTED_INTERRUPTS
/* Ignore unsupported interrupts, optionally hang for debugging */
/* BADISR is a gcc weak symbol that matches any undefined interrupt */
@ -335,3 +509,5 @@ ISR( _VECTOR(77)) {while (1) x++;}
ISR( _VECTOR(78)) {while (1) x++;}
ISR( _VECTOR(79)) {while (1) x++;}
#endif
/** @} */
/** @} */

View file

@ -1,29 +0,0 @@
#include "delay.h"
//----------------------------------------------------------------------------
// Wait for a specific time in 100 uSec
// (15 + t*( ((K_DELAY_100us-1)*6)+5 ))
//----------------------------------------------------------------------------
void Delay_100us(unsigned char t) {
unsigned int i;
if (t==0) return;
while (t--) for(i=0;i<K_DELAY_100us; i++);
}
//----------------------------------------------------------------------------
// Wait for a specific time in 1 mSec
// (15 + t*( ((K_DELAY_1ms-1)*6)+5 ))
//----------------------------------------------------------------------------
void Delay_1ms(unsigned char t) {
unsigned int i;
if (t==0) return;
while (t--) for(i=0;i<K_DELAY_1ms; i++);
}
//----------------------------------------------------------------------------
// Wait for a specific time in 10 mSec
// (15 + t*( ((K_DELAY_10ms-1)*6)+5 ))
//----------------------------------------------------------------------------
void Delay_10ms(unsigned char t) {
unsigned int i;
if (t==0) return;
while (t--) for(i=0;i<K_DELAY_10ms; i++);
}

View file

@ -1,9 +0,0 @@
#define F_CPU 15000000
#define K_DELAY_100us F_CPU/61349
#define K_DELAY_1ms F_CPU/6013
#define K_DELAY_10ms F_CPU/600
void Delay_100us(unsigned char t);
void Delay_1ms(unsigned char t);
void Delay_10ms(unsigned char t);

View file

@ -1,5 +1,4 @@
#include "rtl8019.h"
#include "delay.h"
#include "debug.h"
#include "avr/pgmspace.h"
#include "rtlregs.h"
@ -36,6 +35,8 @@
* Corrected the overrun function - overrun flag was not reset after overrun
* Added support for the Imagecraft Compiler
* Added support to communicate with the NIC using general I/O ports
* March 10, 2012 - David Kopf
* Use contiki clock_delay_usec call.
*
*****************************************************************************/
@ -85,7 +86,25 @@ void writeRTL(unsigned char address, unsigned char data)
#endif
void
delay_msec(uint16_t howlong)
{
#if F_CPU>=16000000
while(howlong--) clock_delay_usec(1000);
#elif F_CPU>=8000000
uint16_t i=996;
while(howlong--) {clock_delay_usec(i);i=999;}
#elif F_CPU>=4000000
uint16_t i=992;
while(howlong--) {clock_delay_usec(i);i=999;}
#elif F_CPU>=2000000
uint16_t i=989;
while(howlong--) {clock_delay_usec(i);i=999;}
#else
uint16_t i=983;
while(howlong--) {clock_delay_usec(i);i=999;}
#endif
}
/*****************************************************************************
* readRTL(RTL_ADDRESS)
* Args: unsigned char RTL_ADDRESS - register offset of RTL register
@ -191,7 +210,7 @@ volatile unsigned char *base = (unsigned char *)0x8300;
* Description: Simply toggles the pin that resets the NIC
*****************************************************************************/
/*#define HARD_RESET_RTL8019() do{ sbi(RTL8019_RESET_PORT, RTL8019_RESET_PIN); \
Delay_10ms(1); \
delay_msec(10); \
cbi(RTL8019_RESET_PORT, RTL8019_RESET_PIN);} \
while(0)*/
@ -503,7 +522,7 @@ void overrun(void)
data_L = readRTL(CR);
writeRTL(CR, 0x21);
Delay_1ms(2);
delay_msec(2);
writeRTL(RBCR0, 0x00);
writeRTL(RBCR1, 0x00);
if(!(data_L & 0x04))
@ -686,7 +705,11 @@ void initRTL8019(void)
*/
nic_write(NIC_PG3_EECR, 0);
/* NutSleep(WAIT500);*/
Delay_10ms(50);
delay_msec(500);
/*
* Switch to register page 0 and set data configuration register
@ -772,7 +795,10 @@ void initRTL8019(void)
nic_write(NIC_PG0_TCR, 0);
/* NutSleep(WAIT500);*/
Delay_10ms(50);
delay_msec(500);
#endif /* 0 */
@ -788,7 +814,8 @@ void initRTL8019(void)
nic_write(NIC_PG3_CONFIG2, NIC_CONFIG2_BSELB);
nic_write(NIC_PG3_EECR, 0);
/* Delay(50000);*/
Delay_10ms(200);
delay_msec(2000);
nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2);
nic_write(NIC_PG0_DCR, NIC_DCR_LS | NIC_DCR_FT1);
nic_write(NIC_PG0_RBCR0, 0);
@ -813,7 +840,7 @@ void initRTL8019(void)
nic_write(NIC_CR, NIC_CR_STA | NIC_CR_RD2);
nic_write(NIC_PG0_TCR, 0);
/* Delay(1000000)*/
Delay_10ms(200);
delay_msec(2000);
nic_write(NIC_CR, NIC_CR_STA | NIC_CR_RD2 | NIC_CR_PS0 | NIC_CR_PS1);
@ -874,10 +901,10 @@ void initRTL8019(void)
// do soft reset
writeRTL( ISR, readRTL(ISR) ) ;
Delay_10ms(5);
delay_msec(50);
writeRTL(CR,0x21); // stop the NIC, abort DMA, page 0
Delay_1ms(2); // make sure nothing is coming in or going out
delay_msec(2); // make sure nothing is coming in or going out
writeRTL(DCR, DCR_INIT); // 0x58
writeRTL(RBCR0,0x00);
writeRTL(RBCR1,0x00);
@ -888,7 +915,7 @@ void initRTL8019(void)
writeRTL(BNRY, RXSTART_INIT);
writeRTL(PSTOP, RXSTOP_INIT);
writeRTL(CR, 0x61);
Delay_1ms(2);
delay_msec(2);
writeRTL(CURR, RXSTART_INIT);
writeRTL(PAR0+0, MYMAC_0);

View file

@ -76,16 +76,16 @@
// RCB_B : RZ200 kit from Atmel based on 1281V
// ZIGBIT : Zigbit module from Meshnetics
// IRIS : IRIS Mote from MEMSIC
#define RAVEN_D 4
#define RAVENUSB_C 1
#define RCB_B 2
#define ZIGBIT 3
#define RAVEN_D 1
#define RAVENUSB_C 2
#define RCB_B 3
#define ZIGBIT 4
#define IRIS 5
#if RCB_REVISION == RCB_B
#if PLATFORM_TYPE == RCB_B
/* 1281 rcb */
# define SSPORT B
# define SSPIN (0x00)
@ -104,7 +104,7 @@
# define TICKTIMER 3
# define HAS_SPARE_TIMER
#elif HARWARE_REVISION == ZIGBIT
#elif PLATFORM_TYPE == ZIGBIT
/* 1281V Zigbit */
# define SSPORT B
# define SSPIN (0x00)
@ -170,7 +170,7 @@
# define HAS_CW_MODE
# define HAS_SPARE_TIMER
#elif HARWARE_REVISION == IRIS
#elif PLATFORM_TYPE == IRIS
/* 1281 IRIS */
# define SSPORT B
# define SSPIN (0x00)
@ -296,7 +296,7 @@
#error "Clock speed not supported."
#endif
#if HARWARE_REVISION == ZIGBIT
#if PLATFORM_TYPE == ZIGBIT
// IRQ E5 for Zigbit example
#define RADIO_VECT INT5_vect
#define HAL_ENABLE_RADIO_INTERRUPT( ) { ( EIMSK |= ( 1 << INT5 ) ) ; EICRB |= 0x0C ; PORTE &= ~(1<<PE5); DDRE &= ~(1<<DDE5); }

View file

@ -53,6 +53,8 @@
#define SR_TX_AUTO_CRC_ON 0x144, 0x20, 5
#define SR_TRAC_STATUS 0x142, 0xe0, 5
#define SR_CHANNEL 0x148, 0x1f, 0
#define SR_CCA_MODE 0x148, 0x60, 5
#define SR_CCA_REQUEST 0x148, 0x80, 7
#define RG_PAN_ID_0 PAN_ID_0
#define RG_PAN_ID_1 PAN_ID_1
#define RG_SHORT_ADDR_0 SHORT_ADDR_0
@ -69,19 +71,17 @@
#define RG_PHY_ED_LEVEL PHY_ED_LEVEL
#define RG_RX_SYN RX_SYN
#define SR_RSSI 0x146, 0x1f, 0
#define SR_PLL_CF_START 0x1a, 0x80, 7
#define SR_PLL_DCU_START 0x1b, 0x80, 7
#define SR_MAX_CSMA_RETRIES 0x2c, 0x0e, 1
#define SR_PLL_CF_START 0x15a, 0x80, 7
#define SR_PLL_DCU_START 0x15b, 0x80, 7
#define SR_MAX_CSMA_RETRIES 0x16c, 0x0e, 1
#define RG_CSMA_BE CSMA_BE
#define RG_CSMA_SEED_0 CSMA_SEED_0
#define RG_PHY_RSSI PHY_RSSI
#define SR_CCA_MODE 0x08, 0x60, 5
//#define SR_CCA_CS_THRES 0x09, 0xf0, 4
#define SR_CCA_ED_THRES 0x09, 0x0f, 0
#define SR_CCA_REQUEST 0x08, 0x80, 7
#define SR_CCA_DONE 0x01, 0x80, 7
#define SR_CCA_STATUS 0x01, 0x40, 6
#define SR_AACK_SET_PD 0x2e, 0x20, 5
//#define SR_CCA_CS_THRES 0x149, 0xf0, 4
#define SR_CCA_ED_THRES 0x149, 0x0f, 0
#define SR_CCA_DONE 0x141, 0x80, 7
#define SR_CCA_STATUS 0x141, 0x40, 6
#define SR_AACK_SET_PD 0x16e, 0x20, 5
/* RF230 register assignments, for reference */

View file

@ -9,6 +9,7 @@
* Mike Vidales mavida404@gmail.com
* Kevin Brown kbrown3@uccs.edu
* Nate Bohlmann nate@elfwerks.com
* David Kopf dak664@embarqmail.com
*
* All rights reserved.
*
@ -67,25 +68,22 @@
* \brief Change these values to port to other platforms.
* \{
*/
/* Define all possible revisions here */
/* Define all possible platform types/revisions here. */
// Don't use zero, it will match if undefined!
// RAVEN_D : Raven kit with LCD display
// RAVENUSB_C : used for USB key or Raven card
// RAVENUSB_C : used for RZRAVEN USB key
// RCB_B : RZ200 kit from Atmel based on 1281V
// ZIGBIT : Zigbit module from Meshnetics
// ATMEGA128RFA1 : Bare chip with internal radio
// IRIS : IRIS Mote from MEMSIC
#define RAVEN_D 4
#define RAVENUSB_C 1
#define RCB_B 2
#define ZIGBIT 3
#define ATMEGA128RFA1 4
#define RAVENUSB_C 1
#define RAVEN_D 2
#define RCB_B 3
#define ZIGBIT 4
#define IRIS 5
#define ATMEGA128RFA1 6
/* TODO: Move to platform (or CPU specific) */
#if RCB_REVISION == RCB_B
#if PLATFORM_TYPE == RCB_B
/* 1281 rcb */
# define SSPORT B
# define SSPIN (0x00)
@ -104,7 +102,7 @@
# define TICKTIMER 3
# define HAS_SPARE_TIMER
#elif HARWARE_REVISION == ZIGBIT
#elif PLATFORM_TYPE == ZIGBIT
/* 1281V Zigbit */
# define SSPORT B
# define SSPIN (0x00)
@ -126,7 +124,7 @@
//# define HAS_SPARE_TIMER // Not used
#elif RAVEN_REVISION == RAVEN_D
#elif PLATFORM_TYPE == RAVEN_D
/* 1284 raven */
# define SSPORT B
# define SSPIN (0x04)
@ -148,7 +146,7 @@
# define HAS_CW_MODE
# define HAS_SPARE_TIMER
#elif RAVEN_REVISION == RAVENUSB_C
#elif PLATFORM_TYPE == RAVENUSB_C
/* 1287USB raven */
# define SSPORT B
# define SSPIN (0x00)
@ -170,24 +168,8 @@
# define HAS_CW_MODE
# define HAS_SPARE_TIMER
#elif HARWARE_REVISION == ATMEGA128RFA1
#elif PLATFORM_TYPE == ATMEGA128RFA1
/* ATmega1281 with internal AT86RF231 radio */
#if 0
# define SSPORT B
# define SSPIN (0x04)
# define SPIPORT B
# define MOSIPIN (0x05)
# define MISOPIN (0x06)
# define SCKPIN (0x07)
# define RSTPORT B
# define RSTPIN (0x01)
# define IRQPORT D
# define IRQPIN (0x06)
# define SLPTRPORT B
# define SLPTRPIN (0x03)
# define TXCWPORT B
# define TXCWPIN (0x00)
#endif
# define SLPTRPORT TRXPR
# define SLPTRPIN 1
# define USART 1
@ -198,7 +180,6 @@
#elif CONTIKI_TARGET_MULLE
/* mulle 5.2 (TODO: move to platform specific) */
# define SSPORT 3
# define SSPIN 5
# define MOSIPORT 1
@ -215,8 +196,7 @@
# define SLPTRPIN 7
# define HAS_SPARE_TIMER
#elif HARWARE_REVISION == IRIS
#elif PLATFORM_TYPE == IRIS
/* 1281 IRIS */
# define SSPORT B
# define SSPIN (0x00)
@ -238,7 +218,7 @@
//# define HAS_SPARE_TIMER // Not used
#else
#error "Platform undefined in hal.h"
#error "PLATFORM_TYPE undefined in hal.h"
#endif
@ -427,7 +407,7 @@
#error "Clock speed not supported."
#endif
#if HARWARE_REVISION == ZIGBIT
#if PLATFORM_TYPE == ZIGBIT
// IRQ E5 for Zigbit example
#define RADIO_VECT INT5_vect
#define HAL_ENABLE_RADIO_INTERRUPT( ) { ( EIMSK |= ( 1 << INT5 ) ) ; EICRB |= 0x0C ; PORTE &= ~(1<<PE5); DDRE &= ~(1<<DDE5); }

View file

@ -317,7 +317,6 @@ uint32_t longhowlong;
watchdog_start();
/* Adjust clock.c for the time spent sleeping */
extern void clock_adjust_ticks(uint16_t howmany);
longhowlong=CLOCK_CONF_SECOND;
longhowlong*=howlong;
clock_adjust_ticks(longhowlong/RTIMER_ARCH_SECOND);

View file

@ -73,7 +73,7 @@ clock_delay(unsigned int len)
* Wait for a multiple of ~8 ms (a tick)
*/
void
clock_wait(int i)
clock_wait(clock_time_t i)
{
clock_time_t start;

View file

@ -75,7 +75,7 @@ clock_delay(unsigned int len)
* Wait for a multiple of ~8 ms (a tick)
*/
void
clock_wait(int i)
clock_wait(clock_time_t i)
{
clock_time_t start;

View file

@ -78,7 +78,12 @@ clock_init()
*TMR_ENBL = 0xf; /* enable all the timers --- why not? */
enable_irq(TMR);
/* Do startup scan of the ADC */
#if CLOCK_CONF_SAMPLEADC
adc_reading[8]=0;
adc_init();
while (adc_reading[8]==0) adc_service();
#endif
}
void tmr0_isr(void) {
@ -88,9 +93,15 @@ void tmr0_isr(void) {
seconds++;
#if BLINK_SECONDS
leds_toggle(LEDS_GREEN);
#endif
/* ADC can be serviced every tick or every second */
#if CLOCK_CONF_SAMPLEADC > 1
adc_service();
#endif
}
#if CLOCK_CONF_SAMPLEADC == 1
adc_service();
#endif
if(etimer_pending() &&
(etimer_next_expiration_time() - current_clock - 1) > MAX_TICKS) {
etimer_request_poll();
@ -120,13 +131,63 @@ clock_seconds(void)
return seconds;
}
/* clock delay from cc2430 */
/* I don't see any documentation about how this routine is suppose to behave */
void
clock_delay(unsigned int len)
clock_wait(clock_time_t t)
{
unsigned int i;
for(i = 0; i< len; i++) {
asm("nop");
}
clock_time_t endticks = current_clock + t;
while ((signed long)(current_clock - endticks) < 0) {;}
}
/*---------------------------------------------------------------------------*/
/**
* Delay the CPU for up to 65535 microseconds.
* Use the 250KHz MACA clock for longer delays to avoid interrupt effects.
* However that can't be used if the radio is being power cycled!
*/
void
clock_delay_usec(uint16_t howlong)
{
if(howlong<2) return;
#if 0
if(howlong>400) {
volatile register uint32_t i=*MACA_CLK+howlong/4;
while (i > *MACA_CLK) ;
return;
}
#endif
/* These numbers at 25MHz, gcc -Os */
volatile register uint32_t i=4000*howlong/2301;
while(--i);
}
/*---------------------------------------------------------------------------*/
/**
* Delay the CPU for up to 65535 milliseconds. The watchdog is NOT disabled.
*/
void
clock_delay_msec(uint16_t howlong)
{
while(howlong--) clock_delay_usec(1000);
}
/*---------------------------------------------------------------------------*/
/**
* Legacy delay. The original clock_delay for the msp430 used a granularity
* of 2.83 usec. This approximates that delay for values up to 1456 usec.
* (The largest core call in leds.c uses 400).
*/
void
clock_delay(unsigned int howlong)
{
if(howlong--) return;
clock_delay_usec((283*howlong)/100);
}
/*---------------------------------------------------------------------------*/
/**
* Adjust clock ticks after a cpu sleep.
*/
void clock_adjust_ticks(clock_time_t howmany) {
/* Add seconds */
seconds+=howmany/CLOCK_CONF_SECOND;
/* Handle tick overflow */
if(((current_clock % CLOCK_CONF_SECOND) + (howmany % CLOCK_CONF_SECOND)) >= CLOCK_CONF_SECOND) seconds++;
/* Add ticks */
current_clock+=howmany;
}

View file

@ -55,9 +55,4 @@ typedef unsigned short uip_stats_t;
typedef uint32_t clock_time_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
#endif

View file

@ -11,19 +11,24 @@ CONTIKI_CPU=$(CONTIKI)/cpu/msp430
### Define the source files we have in the MSP430 port
ifneq (,$(findstring msp430x1,$(MCU)))
CONTIKI_CPU_FAM_DIR = f1xxx
else
ifneq (,$(findstring msp430x5,$(MCU)))
CONTIKI_CPU_FAM_DIR = f5xxx
else
ifneq (,$(findstring msp430x2,$(MCU)))
CONTIKI_CPU_FAM_DIR = f2xxx f1xxx
else
${error Unhandled MSP430 family: "$(MCU)"}
endif
ifndef CONTIKI_CPU_FAM_DIR
ifneq (,$(findstring msp430f1,$(MCU)))
CONTIKI_CPU_FAM_DIR = f1xxx
endif
endif
ifndef CONTIKI_CPU_FAM_DIR
ifneq (,$(findstring msp430f5,$(MCU)))
CONTIKI_CPU_FAM_DIR = f5xxx
endif
endif
ifndef CONTIKI_CPU_FAM_DIR
ifneq (,$(findstring msp430f2,$(MCU)))
CONTIKI_CPU_FAM_DIR = f2xxx f1xxx
endif
endif
ifndef CONTIKI_CPU_FAM_DIR
${error Unhandled MSP430 family: "$(MCU)"}
endif
CONTIKI_CPU_DIRS = $(CONTIKI_CPU_FAM_DIR) . dev
@ -54,9 +59,9 @@ STRIP = strip
ifndef IAR_PATH
# This works with cygwin...
IAR_BIN_PATH = $(shell dirname "`which $(CC)`")
IAR_PATH_C = $(shell dirname "$(IAR_BIN_PATH)")
IAR_PATH = $(shell cygpath -m "$(IAR_PATH_C)")
IAR_BIN_PATH := $(shell dirname "`which $(CC)`")
IAR_PATH_C := $(shell dirname "$(IAR_BIN_PATH)")
IAR_PATH := $(shell cygpath -m "$(IAR_PATH_C)")
endif
CFLAGS += --diag_suppress=Pa050 --silent
@ -101,11 +106,33 @@ NM = msp430-nm
OBJCOPY = msp430-objcopy
STRIP = msp430-strip
BSL = msp430-bsl
# From version 4.6.x, mspgcc does not support generic MCU identifiers such as
# msp430x1611 in contrast to msp430f1611
ifndef CC_MCU
ifndef MSPGCC_VERSION
MSPGCC_VERSION := ${shell $(CC) -dumpversion}
endif
endif
ifndef CC_MCU
ifneq (,$(findstring 4.4.,$(MSPGCC_VERSION)))
CC_MCU := ${subst msp430f,msp430x,$(MCU)}
endif
endif
ifndef CC_MCU
ifneq (,$(findstring 3.2.,$(MSPGCC_VERSION)))
CC_MCU := ${subst msp430f,msp430x,$(MCU)}
endif
endif
ifndef CC_MCU
CC_MCU := $(MCU)
endif
ifndef CFLAGSNO
CFLAGSNO = -Wall -mmcu=$(MCU) -g $(CFLAGSWERROR)
CFLAGSNO = -Wall -mmcu=$(CC_MCU) -g $(CFLAGSWERROR)
endif
CFLAGS += -Os -fno-strict-aliasing
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map
LDFLAGS += -mmcu=$(CC_MCU) -Wl,-Map=contiki-$(TARGET).map
### These flags can reduce the code size and RAM usage with up to 10%
ifeq ($(SMALL),1)
@ -141,7 +168,7 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
ifdef IAR
%.ihex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
$(LD) $(LDFLAGSNO) -Fintel-extended -yn $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
$(LD) $(LDFLAGSNO) -Fintel-extended $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
else
%.ihex: %.$(TARGET)
$(OBJCOPY) $^ -O ihex $@

View file

@ -186,7 +186,7 @@ clock_delay(unsigned int i)
*
*/
void
clock_wait(int i)
clock_wait(clock_time_t i)
{
clock_time_t start;

View file

@ -183,7 +183,7 @@ clock_delay(unsigned int i)
*
*/
void
clock_wait(int i)
clock_wait(clock_time_t i)
{
clock_time_t start;

View file

@ -46,6 +46,7 @@
#include "dev/stm32w_systick.h"
#include "contiki.h"
#include "sys/clock.h"
#include "uart1.h"
#include "dev/leds.h"
@ -122,7 +123,7 @@ void clock_delay(unsigned int i)
* Wait for a multiple of 1 ms.
*
*/
void clock_wait(int i)
void clock_wait(clock_timt_t i)
{
clock_time_t start;

View file

@ -1,6 +1,9 @@
#include <avr/eeprom.h>
/* Link layer ipv6 address will become fe80::2 */
uint8_t mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
uint8_t server_name[16] EEMEM = "huginn";
uint8_t domain_name[30] EEMEM = "localhost";
uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
uint8_t default_server_name[16] PROGMEM = "huginn";
uint8_t default_domain_name[30] PROGMEM = "localhost";
uint8_t eemem_mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
uint8_t eemem_server_name[16] EEMEM = "huginn";
uint8_t eemem_domain_name[30] EEMEM = "localhost";

View file

@ -5,7 +5,7 @@ APPS=raven-webserver raven-lcd-interface
TARGET=avr-raven
UIP_CONF_IPV6=1
#WITH_RPL=1 //RPL is not yet the default.
#UIP_CONF_RPL=0 //RPL is now the default.
#RF230BB=1 //Use radio driver that communicates with the core MAC layer. Now the default.
#COFFEE_FILES=1 //Static coffee file system in EEPROM
#COFFEE_FILES=2 //Dynamic coffee file system in EEPROM

View file

@ -1,6 +1,9 @@
#include <avr/eeprom.h>
/* Link layer ipv6 address will become fe80::1 */
uint8_t mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
uint8_t server_name[16] EEMEM = "muninn";
uint8_t domain_name[30] EEMEM = "localhost";
uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
uint8_t default_server_name[16] PROGMEM = "muninn";
uint8_t default_domain_name[30] PROGMEM = "localhost";
uint8_t eemem_mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
uint8_t eemem_server_name[16] EEMEM = "muninn";
uint8_t eemem_domain_name[30] EEMEM = "localhost";

View file

@ -41,8 +41,8 @@ so requires PERL. A bare $make after that will not regenerate httpd-fsdata.c.
Use $make WEBDIR=default to switch back to the default /http-fs/ content.
See Makefile.webserver for optional switches for RPL or a coffee file system.
$make WITH_RPL=1 for a RPL node, or if rpl has become the contiki default,
$make WITH_RPL=0 to override
$make UIP_CONF_RPL=1 for a RPL node, or if rpl has become the contiki default,
$make UIP_CONF_RPL=0 to override
Much headbanging can result if you do not $make clean when changing make options,
as the normal build dependencies are bypassed and the needed object modules

View file

@ -41,38 +41,36 @@
#ifndef __CONTIKI_CONF_H__
#define __CONTIKI_CONF_H__
/* MCU and clock rate */
#define PLATFORM PLATFORM_AVR
#define HARWARE_REVISION ATMEGA128RFA1
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "RFA1"
#define PLATFORM_TYPE ATMEGA128RFA1
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
#include <stdint.h>
/* These names are deprecated, use C99 names. */
typedef int32_t s32_t;
typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned long u32_t;
typedef unsigned short clock_time_t;
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
/* Maximum timer interval for 16 bit clock_time_t */
#define INFINITE_TIME 0xffff
/* Clock ticks per second */
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 128
/* Maximum tick interval is 0xffff/128 = 511 seconds */
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* Michael Hartman's atmega128rfa1 board has an external 32768Hz crystal connected to TOSC1 and 2 pins similar to the Raven 1284p */
/* and theoretically can use TIMER2 with it to keep time. Else TIMER0 is used. */
@ -94,7 +92,8 @@ unsigned long clock_seconds(void);
/* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
//#define MMEM_CONF_SIZE 256
/* Starting address for code received via the codeprop facility. Not tested on Raven */
/* Starting address for code received via the codeprop facility. Not tested. */
typedef unsigned long off_t;
//#define EEPROMFS_ADDR_CODEPROP 0x8000
/* Logging adds 200 bytes to program size. RS232 output slows down webserver. */
@ -107,6 +106,10 @@ unsigned long clock_seconds(void);
/* More extensive stats, via main loop printfs or webserver status pages */
#define ENERGEST_CONF_ON 1
/* Packet statistics */
typedef unsigned short uip_stats_t;
#define UIP_STATISTICS 0
/* Available watchdog timeouts depend on mcu. Default is WDTO_2S. -1 Disables the watchdog. */
/* AVR Studio simulator tends to reboot due to clocking the WD 8 times too fast */
//#define WATCHDOG_CONF_TIMEOUT -1

View file

@ -215,7 +215,6 @@ void micro_sleep(uint8_t howlong)
sleep_mode(); // Sleep
/* Adjust clock.c for the time spent sleeping */
extern void clock_adjust_ticks(uint16_t howmany);
clock_adjust_ticks(howlong * CLOCK_SECOND);
// if (TIMSK2&(1<<OCIE2A)) break; // Exit sleep if not awakened by TIMER2

View file

@ -43,43 +43,40 @@
#ifndef __CONTIKI_CONF_H__
#define __CONTIKI_CONF_H__
/* MCU and clock rate */
#define PLATFORM PLATFORM_AVR
#define RAVEN_REVISION RAVEN_D
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "Raven"
#define PLATFORM_TYPE RAVEN_D
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
/* MCU_CONF_LOW_WEAR will remove the signature and eeprom from the .elf file */
/* This reduces reprogramming wear during development */
#define MCU_CONF_LOW_WEAR 0
//#define MCU_CONF_LOW_WEAR 1
#include <stdint.h>
/* These names are deprecated, use C99 names. */
typedef int32_t s32_t;
typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned long u32_t;
typedef unsigned short clock_time_t;
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
/* Maximum timer interval for 16 bit clock_time_t */
#define INFINITE_TIME 0xffff
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 128
/* Maximum tick interval is 0xffff/128 = 511 seconds */
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* The 1284p can use TIMER2 with the external 32768Hz crystal to keep time. Else TIMER0 is used. */
/* The sleep timer in raven-lcd.c also uses the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
@ -100,6 +97,7 @@ unsigned long clock_seconds(void);
//#define MMEM_CONF_SIZE 256
/* Starting address for code received via the codeprop facility. Not tested on Raven */
typedef unsigned long off_t;
//#define EEPROMFS_ADDR_CODEPROP 0x8000
/* RADIO_CONF_CALIBRATE_INTERVAL is used in rf230bb and clock.c. If nonzero a 256 second interval is used */
@ -112,6 +110,11 @@ unsigned long clock_seconds(void);
/* More extensive stats */
#define ENERGEST_CONF_ON 1
/* Packet statistics */
typedef unsigned short uip_stats_t;
#define UIP_STATISTICS 0
/* Possible watchdog timeouts depend on mcu. Default is WDTO_2S. -1 Disables the watchdog. */
/* AVR Studio simulator tends to reboot due to clocking the WD 8 times too fast */
//#define WATCHDOG_CONF_TIMEOUT -1
@ -143,7 +146,7 @@ unsigned long clock_seconds(void);
/* TX routine does automatic cca and optional backoff */
#define RDC_CONF_HARDWARE_CSMA 1
/* Allow MCU sleeping between channel checks */
#define RDC_CONF_MCU_SLEEP 1
#define RDC_CONF_MCU_SLEEP 0
#else
#define PACKETBUF_CONF_HDR_SIZE 0 //RF230 combined driver/mac handles headers internally
#endif /*RF230BB */
@ -270,11 +273,11 @@ unsigned long clock_seconds(void);
#define QUEUEBUF_CONF_REF_NUM 2
/* Allocate remaining RAM. Not much left due to queuebuf increase */
#define UIP_CONF_MAX_CONNECTIONS 2
#define UIP_CONF_MAX_LISTENPORTS 4
#define UIP_CONF_UDP_CONNS 5
#define UIP_CONF_DS6_NBR_NBU 4
#define UIP_CONF_MAX_LISTENPORTS 2
#define UIP_CONF_UDP_CONNS 4
#define UIP_CONF_DS6_NBR_NBU 10
#define UIP_CONF_DS6_DEFRT_NBU 2
#define UIP_CONF_DS6_PREFIX_NBU 3
#define UIP_CONF_DS6_PREFIX_NBU 2
#define UIP_CONF_DS6_ROUTE_NBU 4
#define UIP_CONF_DS6_ADDR_NBU 3
#define UIP_CONF_DS6_MADDR_NBU 0

View file

@ -47,40 +47,38 @@
//#pragma mark Basic Configuration
/* ************************************************************************** */
/* MCU and clock rate */
#define PLATFORM PLATFORM_AVR
#define RAVEN_REVISION RAVENUSB_C
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "RAVENUSB"
#define PLATFORM_TYPE RAVENUSB_C
#ifndef F_CPU
#define F_CPU 8000000UL
#define F_CPU 8000000UL
#endif
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
/* These names are deprecated, use C99 names. */
typedef int32_t s32_t;
typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned long u32_t;
typedef unsigned short clock_time_t;
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
/* Maximum timer interval for 16 bit clock_time_t */
#define INFINITE_TIME 0xffff
/* Clock ticks per second */
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 125
/* Maximum tick interval is 0xffff/125 = 524 seconds */
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* Use EEPROM settings manager, or hard-coded EEPROM reads? */
/* Generate random MAC address on first startup? */
@ -98,6 +96,7 @@ unsigned long clock_seconds(void);
//#define MMEM_CONF_SIZE 256
/* Starting address for code received via the codeprop facility. Not tested on Jackdaw */
typedef unsigned long off_t;
//#define EEPROMFS_ADDR_CODEPROP 0x8000
/* Simple stack monitor. Status is displayed from the USB menu with 'm' command */
@ -265,6 +264,8 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len);
#define UIP_CONF_UDP_CHECKSUMS 1
#define UIP_CONF_TCP_SPLIT 0
typedef unsigned short uip_stats_t;
#define UIP_CONF_STATISTICS 1
/* Network setup */

View file

@ -44,17 +44,39 @@
#include <stdint.h>
typedef int32_t s32_t;
//typedef int32_t s32_t;
/*
* MCU and clock rate
*/
#define MCU_MHZ 8
#define PLATFORM PLATFORM_AVR
#define RCB_REVISION RCB_B
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "RCB"
#define PLATFORM_TYPE RCB_B
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 125
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* COM port to be used for SLIP connection */
#define SLIP_PORT RS232_PORT_0
@ -114,18 +136,13 @@ typedef int32_t s32_t;
#define UIP_CONF_TCP_SPLIT 0
typedef unsigned short clock_time_t;
/* These names are deprecated, use C99 names. */
typedef unsigned char u8_t;
/*typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned long u32_t;
*/
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
#endif /* __CONTIKI_CONF_H__ */

View file

@ -42,18 +42,36 @@
#ifndef __CONTIKI_CONF_H__
#define __CONTIKI_CONF_H__
/* MCU and clock rate */
#define PLATFORM PLATFORM_AVR
#define HARWARE_REVISION ZIGBIT
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "Zigbit"
#define PLATFORM_TYPE ZIGBIT
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
#include <stdint.h>
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 125
/* Since clock_time_t is 16 bits, maximum interval is 524 seconds */
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /*Default uses 600*/
/* Maximum time interval (used for timers) */
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* COM port to be used for SLIP connection */
#define SLIP_PORT RS232_PORT_0
@ -143,21 +161,15 @@
#define UIP_CONF_TCP_SPLIT 1
#include <stdint.h>
/* These names are deprecated, use C99 names. */
typedef unsigned short clock_time_t;
/*
typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned long u32_t;
typedef int32_t s32_t;
*/
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
#endif /* __CONTIKI_CONF_H__ */

View file

@ -50,7 +50,7 @@ endif
include $(CONTIKI)/platform/$(TARGET)/apps/Makefile.apps
MCU=msp430x149
MCU=msp430f149
include $(CONTIKI)/cpu/msp430/Makefile.msp430
ifdef IAR

View file

@ -42,8 +42,6 @@
typedef unsigned long clock_time_t;
void clock_wait(int ms10);
#define LOG_CONF_ENABLED 0
#define PACKETBUF_CONF_ATTRS_INLINE 1

View file

@ -33,6 +33,7 @@
#include "contiki.h"
#include "contiki-esb.h"
#include "sys/clock.h"
#define ON 1
#define OFF 0

View file

@ -47,9 +47,9 @@ endif
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
ifdef IAR
MCU=msp430x5438a
MCU=msp430f5438a
else
MCU=msp430x5438
MCU=msp430f5438
endif
include $(CONTIKI)/cpu/msp430/Makefile.msp430

View file

@ -214,7 +214,7 @@ __delay_cycles(int c)
*
*/
void
clock_wait(int i)
clock_wait(clock_time_t i)
{
clock_time_t start;

View file

@ -188,16 +188,9 @@
#define UIP_CONF_TCP_SPLIT 0
typedef unsigned short clock_time_t;
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
#ifdef PROJECT_CONF_H
#include PROJECT_CONF_H
#endif /* PROJECT_CONF_H */

View file

@ -44,13 +44,34 @@
* Definitions below are dictated by the hardware and not really
* changeable!
*/
#define PLATFORM PLATFORM_AVR
#define HARWARE_REVISION IRIS
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "Iris"
#define PLATFORM_TYPE IRIS
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 128
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* LED ports */
#define LEDS_PxDIR DDRA // port direction register

View file

@ -43,8 +43,7 @@
#include "dev/acc-sensor.h"
#include "mems.h"
void clock_wait(int i);
#include "sys/clock.h"
#define FALSE 0
#define TRUE 1

View file

@ -130,7 +130,7 @@ void clock_delay(unsigned int i)
* Wait for a multiple of 1 ms.
*
*/
void clock_wait(int i)
void clock_wait(clock_time_t i)
{
clock_time_t start;

View file

@ -42,10 +42,9 @@
#include "dev/acc-sensor.h"
#include "sys/clock.h"
#include "mems.h"
void clock_wait(int i);
#define FALSE 0
#define TRUE 1

View file

@ -47,12 +47,17 @@
#include "platform-conf.h"
#if WITH_UIP6
#if UIP_CONF_IPV6
#define WITH_UIP6 1
#endif
#if WITH_UIP6
/* Network setup for IPv6 */
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_RDC nullrdc_driver
//#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_MAC nullmac_driver
//#define NETSTACK_CONF_RDC nullrdc_driver
#define NETSTACK_CONF_RDC sicslowmac_driver
#define NETSTACK_CONF_FRAMER framer_802154
#define CC2420_CONF_AUTOACK 1
@ -66,6 +71,7 @@
#define NETSTACK_CONF_NETWORK rime_driver
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_MAC nullmac_driver
#define NETSTACK_CONF_RDC cxmac_driver
#define NETSTACK_CONF_FRAMER framer_802154
@ -109,8 +115,8 @@
#define UIP_CONF_LL_802154 1
#define UIP_CONF_LLH_LEN 0
#define UIP_CONF_ROUTER 1
#define UIP_CONF_IPV6_RPL 1
#define UIP_CONF_ROUTER 0
#define UIP_CONF_IPV6_RPL 0
/* configure number of neighbors and routes */
#define UIP_CONF_DS6_NBR_NBU 5
@ -188,14 +194,7 @@
#define UIP_CONF_TCP_SPLIT 0
typedef unsigned short clock_time_t;
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
#endif /* __CONTIKI_CONF_H__ */

View file

@ -64,7 +64,8 @@ init_usart(void)
USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
#if WITH_UIP || WITH_UIP6
slip_arch_init(USART_BAUD_115200);
// slip_arch_init(USART_BAUD_115200);
rs232_redirect_stdout(RS232_PORT_0);
#else
rs232_redirect_stdout(RS232_PORT_0);
#endif /* WITH_UIP */

View file

@ -134,12 +134,12 @@ clock_delay(unsigned int i)
*
*/
void
clock_wait(int i)
clock_wait(clock_time_t i)
{
clock_time_t start;
start = clock_time();
while(clock_time() - start < (clock_time_t)i);
while(clock_time() - start < i);
}
/*---------------------------------------------------------------------------*/
void

View file

@ -44,17 +44,34 @@
* Definitions below are dictated by the hardware and not really
* changeable!
*/
#define PLATFORM PLATFORM_AVR
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "MicaZ"
#define PLATFORM_TYPE MICAZ
#ifndef F_CPU
#define F_CPU 7372800UL
#endif
/*
* MCU and clock rate.
* MICAZ runs on 7.3728 MHz clock.
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
#define MCU_MHZ 7
/* Clock ticks per second */
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 128
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* LED ports */
#define LEDS_PxDIR DDRA // port direction register

View file

@ -12,7 +12,7 @@ endif
CONTIKI_TARGET_SOURCEFILES += $(SENSORS) $(MSB) $(CONTIKI_TARGET_MAIN)
MCU=msp430x1612
MCU=msp430f1612
include $(CONTIKI)/cpu/msp430/Makefile.msp430
contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}

View file

@ -51,6 +51,8 @@
#include <stdint.h>
#define PLATFORM_NAME "Econotag"
#define PLATFORM_TYPE MC1322X
/* mc1322x files */
#include "contiki-mc1322x-conf.h"
/* this is from cpu/mc1322x/board */
@ -62,6 +64,9 @@
/* FIXME setting this will break the sensor button (and other gpio) */
/* since leds_arch hits the entire gpio_data */
#define BLINK_SECONDS 0
/* Set to 1 to sample an ADC channel every second, 9 second refresh */
/* Set >1 to sample an ADC channel every tick, 90 msec refresh */
#define CLOCK_CONF_SAMPLEADC 1
#define CCIF
#define CLIF

View file

@ -21,7 +21,7 @@ endif
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
MCU=msp430x1611
MCU=msp430f1611
include $(CONTIKI)/cpu/msp430/Makefile.msp430
contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}

View file

@ -3,15 +3,37 @@
#include<stdint.h>
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "STK500"
#define PLATFORM_TYPE STK500
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
#define CCIF
#define CLIF
typedef unsigned short clock_time_t;
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 125
/* Maximum tick interval is 0xffff/125 = 524 seconds */
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
#define SLIP_PORT 0
@ -56,13 +78,6 @@ typedef unsigned short clock_time_t;
#define NETSTACK_CONF_NETWORK rime_driver
#endif /* UIP_CONF_IPV6 */
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
typedef unsigned short uip_stats_t;
/* These names are deprecated, use C99 names. */

View file

@ -45,17 +45,40 @@
/*
* MCU and clock rate. Various MCUs can be inserted in the ZIF socket.
*/
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "STK501"
#define PLATFORM_TYPE STK501
#ifndef MCU
#define MCU atmega128
#endif
#ifndef F_CPU
#define F_CPU 16000000UL
#define F_CPU 16000000UL
#endif
#define PLATFORM PLATFORM_AVR
/* Cock ticks per second */
#define HAVE_STDINT_H
#include "avrdef.h"
/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
* 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
* clock_time_t.
*/
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 125
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /*Default uses 600*/
#if 1
/* 16 bit counter overflows every ~10 minutes */
typedef unsigned short clock_time_t;
#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define INFINITE_TIME 0xffff
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
#else
typedef unsigned long clock_time_t;
#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define INFINITE_TIME 0xffffffff
#endif
/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
void clock_delay_msec(uint16_t howlong);
void clock_adjust_ticks(clock_time_t howmany);
/* COM port to be used for SLIP connection */
#define SLIP_PORT RS232_PORT_0
@ -83,13 +106,7 @@
#define HAVE_STDINT_H
#include "avrdef.h"
typedef unsigned short clock_time_t;
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
void clock_delay(unsigned int us2);
void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
#endif /* __CONTIKI_CONF_H__ */

View file

@ -138,7 +138,7 @@ main(void)
/* Perform rest of initializations */
process_start(&contiki_stk501_main_init_process, NULL);
PRINTF"Initialized.\n");
PRINTF("Initialized.\n");
#ifdef MT_DEMO
mt_start (&threads[0], thread_handler1, &d1);

View file

@ -30,7 +30,7 @@ endif
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
MCU=msp430x5437
MCU=msp430f5437
include $(CONTIKI)/cpu/msp430/Makefile.msp430
ifdef IAR

View file

@ -36,7 +36,7 @@ endif
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
CONTIKI_TARGET_SOURCEFILES += i2cmaster.c adxl345.c
MCU=msp430x2617
MCU=msp430f2617
include $(CONTIKI)/cpu/msp430/Makefile.msp430
# Add LDFLAGS after IAR_PATH is set

View file

@ -46,6 +46,7 @@
#include "net/mac/frame802154.h"
#include "dev/button-sensor.h"
#include "dev/adxl345.h"
#include "sys/clock.h"
#if WITH_UIP6
#include "net/uip-ds6.h"
@ -105,7 +106,6 @@ static uint8_t is_gateway;
#endif
void init_platform(void);
void clock_wait(int i);
/*---------------------------------------------------------------------------*/
#if 0

View file

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<project name="Cooja: Power Tracker" default="jar" basedir=".">
<property name="cooja" location="../.."/>
<property name="cooja_jar" value="${cooja}/dist/cooja.jar"/>
<target name="init">
<tstamp/>
</target>
<target name="compile" depends="init">
<available file="${cooja_jar}" type="file" property="cooja_jar_exists"/>
<fail message="COOJA jar not found at '${cooja_jar}'. Please compile COOJA first." unless="cooja_jar_exists"/>
<mkdir dir="build"/>
<javac srcdir="java" destdir="build" debug="on" includeantruntime="false">
<classpath>
<pathelement path="."/>
<pathelement location="${cooja_jar}"/>
</classpath>
</javac>
</target>
<target name="clean" depends="init">
<delete dir="build"/>
</target>
<target name="jar" depends="clean, init, compile">
<mkdir dir="lib"/>
<jar destfile="lib/powertracker.jar" basedir="build">
<manifest>
<attribute name="Class-Path" value="."/>
</manifest>
</jar>
</target>
<target name="jar_and_cooja_run">
<ant antfile="build.xml" dir="${cooja}" target="jar" inheritAll="false"/>
<ant antfile="build.xml" dir="." target="jar" inheritAll="false"/>
<ant antfile="build.xml" dir="${cooja}" target="run" inheritAll="false"/>
</target>
</project>

View file

@ -0,0 +1,2 @@
se.sics.cooja.GUI.PLUGINS = + PowerTracker
se.sics.cooja.GUI.JARFILES = + powertracker.jar

View file

@ -0,0 +1,524 @@
/*
* Copyright (c) 2012, 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.
*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Observable;
import java.util.Observer;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.Timer;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import org.apache.log4j.Logger;
import org.jdom.Element;
import se.sics.cooja.ClassDescription;
import se.sics.cooja.GUI;
import se.sics.cooja.Mote;
import se.sics.cooja.PluginType;
import se.sics.cooja.SimEventCentral.MoteCountListener;
import se.sics.cooja.Simulation;
import se.sics.cooja.VisPlugin;
import se.sics.cooja.interfaces.Radio;
/**
* Tracks radio events to sum up transmission, reception, and radio on times.
* This plugin can be run without visualization, i.e. from a Contiki test.
*
* @author Fredrik Osterlind, Adam Dunkels
*/
@ClassDescription("PowerTracker")
@PluginType(PluginType.SIM_PLUGIN)
public class PowerTracker extends VisPlugin {
private static Logger logger = Logger.getLogger(PowerTracker.class);
private static final int POWERTRACKER_UPDATE_INTERVAL = 100; /* ms */
private static final int COLUMN_MOTE = 0;
private static final int COLUMN_RADIOON = 1;
private static final int COLUMN_RADIOTX = 2;
private static final int COLUMN_RADIORX = 3;
private Simulation simulation;
private MoteCountListener moteCountListener;
private ArrayList<MoteTracker> moteTrackers = new ArrayList<MoteTracker>();
private JTable table;
private int tableMaxRadioOnIndex = -1;
public PowerTracker(final Simulation simulation, final GUI gui) {
super("PowerTracker", gui, false);
this.simulation = simulation;
/* Automatically add/delete motes */
simulation.getEventCentral().addMoteCountListener(moteCountListener = new MoteCountListener() {
public void moteWasAdded(Mote mote) {
addMote(mote);
table.invalidate();
table.repaint();
}
public void moteWasRemoved(Mote mote) {
removeMote(mote);
table.invalidate();
table.repaint();
}
});
for (Mote m: simulation.getMotes()) {
addMote(m);
}
if (!GUI.isVisualized()) {
return;
}
AbstractTableModel model = new AbstractTableModel() {
public int getRowCount() {
return moteTrackers.size()+1;
}
public int getColumnCount() {
return 4;
}
public String getColumnName(int col) {
if (col == COLUMN_MOTE) {
return "Mote";
}
if (col == COLUMN_RADIOON) {
return "Radio on (%)";
}
if (col == COLUMN_RADIOTX) {
return "Radio TX (%)";
}
if (col == COLUMN_RADIORX) {
return "Radio RX (%)";
}
return null;
}
public Object getValueAt(int rowIndex, int col) {
if (rowIndex < 0 || rowIndex >= moteTrackers.size()+1) {
return null;
}
if (rowIndex == moteTrackers.size()) {
/* Average */
long radioOn = 0;
long radioTx = 0;
long radioRx = 0;
long duration = 0;
for (MoteTracker mt: moteTrackers) {
radioOn += mt.radioOn;
radioTx += mt.radioTx;
radioRx += mt.radioRx;
duration += mt.duration;
}
if (col == COLUMN_MOTE) {
return "AVERAGE";
}
if (col == COLUMN_RADIOON) {
return String.format("%2.2f%%", 100.0*radioOn/duration);
}
if (col == COLUMN_RADIOTX) {
return String.format("%2.2f%%", 100.0*radioTx/duration);
}
if (col == COLUMN_RADIORX) {
return String.format("%2.2f%%", 100.0*radioRx/duration);
}
return null;
}
MoteTracker rule = moteTrackers.get(rowIndex);
if (col == COLUMN_MOTE) {
return rule.mote.toString();
}
if (col == COLUMN_RADIOON) {
return String.format("%2.2f%%", 100.0*rule.getRadioOnRatio());
}
if (col == COLUMN_RADIOTX) {
return String.format("%2.2f%%", 100.0*rule.getRadioTxRatio());
}
if (col == COLUMN_RADIORX) {
return String.format("%2.2f%%", 100.0*rule.getRadioRxRatio());
}
return null;
}
};
table = new JTable(model) {
public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint();
int rowIndex = table.rowAtPoint(p);
if (rowIndex < 0 || rowIndex >= moteTrackers.size()) {
return null;
}
MoteTracker mt = moteTrackers.get(rowIndex);
return "<html><pre>" + mt.toString() + "</html>";
}
};
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (row == tableMaxRadioOnIndex) {
setBackground(isSelected ? table.getSelectionBackground():Color.RED);
setForeground(isSelected ? table.getSelectionForeground():Color.WHITE);
} else {
setBackground(isSelected ? table.getSelectionBackground():table.getBackground());
setForeground(isSelected ? table.getSelectionForeground():table.getForeground());
}
return c;
}
});
Box control = Box.createHorizontalBox();
control.add(Box.createHorizontalGlue());
control.add(new JButton(printAction));
control.add(new JButton(resetAction));
this.getContentPane().add(BorderLayout.CENTER, new JScrollPane(table));
this.getContentPane().add(BorderLayout.SOUTH, control);
setSize(400, 400);
repaintTimer.start();
}
private Action resetAction = new AbstractAction("Reset") {
public void actionPerformed(ActionEvent e) {
Runnable r = new Runnable() {
public void run() {
reset();
}
};
if (simulation.isRunning()) {
simulation.invokeSimulationThread(r);
} else {
r.run();
}
}
};
private Action printAction = new AbstractAction("Print to console/Copy to clipboard") {
public void actionPerformed(ActionEvent e) {
String output = radioStatistics(true, true, false);
logger.info("PowerTracker output:\n\n" + output);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(output);
clipboard.setContents(stringSelection, null);
}
};
public String radioStatistics() {
return radioStatistics(true, true, false);
}
public String radioStatistics(boolean radioHW, boolean radioRXTX, boolean onlyAverage) {
StringBuilder sb = new StringBuilder();
/* Average */
long radioOn = 0;
long radioTx = 0;
long radioRx = 0;
long radioInterfered = 0;
long duration = 0;
for (MoteTracker mt: moteTrackers) {
radioOn += mt.radioOn;
radioTx += mt.radioTx;
radioRx += mt.radioRx;
radioInterfered += mt.radioInterfered;
duration += mt.duration;
}
if (radioHW) {
sb.append(String.format("AVG" + " ON " + (radioOn + " us ") + "%2.2f %%", 100.0*radioOn/duration) + "\n");
}
if (radioRXTX) {
sb.append(String.format("AVG" + " TX " + (radioTx + " us ") + "%2.2f %%", 100.0*radioTx/duration) + "\n");
sb.append(String.format("AVG" + " RX " + (radioRx + " us ") + "%2.2f %%", 100.0*radioRx/duration) + "\n");
sb.append(String.format("AVG" + " INT " + (radioInterfered + " us ") + "%2.2f %%", 100.0*radioInterfered/duration) + "\n");
}
if (onlyAverage) {
return sb.toString();
}
for (MoteTracker mt: moteTrackers) {
sb.append(mt.toString(radioHW, radioRXTX));
}
return sb.toString();
}
private static class MoteTracker implements Observer {
/* last radio state */
private boolean radioWasOn;
private RadioState lastRadioState;
private long lastUpdateTime;
/* accumulating radio state durations */
long duration = 0;
long radioOn = 0;
long radioTx = 0;
long radioRx = 0;
long radioInterfered = 0;
private Simulation simulation;
private Mote mote;
private Radio radio;
public MoteTracker(Mote mote) {
this.simulation = mote.getSimulation();
this.mote = mote;
this.radio = mote.getInterfaces().getRadio();
radioWasOn = radio.isReceiverOn();
if (radio.isTransmitting()) {
lastRadioState = RadioState.TRANSMITTING;
} else if (radio.isReceiving()) {
lastRadioState = RadioState.RECEIVING;
} else if (radio.isInterfered()){
lastRadioState = RadioState.INTERFERED;
} else {
lastRadioState = RadioState.IDLE;
}
lastUpdateTime = simulation.getSimulationTime();
radio.addObserver(this);
}
public void update(Observable o, Object arg) {
update();
}
public void update() {
long now = simulation.getSimulationTime();
accumulateDuration(now - lastUpdateTime);
/* Radio on/off */
if (radioWasOn) {
accumulateRadioOn(now - lastUpdateTime);
}
/* Radio tx/rx */
if (lastRadioState == RadioState.TRANSMITTING) {
accumulateRadioTx(now - lastUpdateTime);
} else if (lastRadioState == RadioState.RECEIVING) {
accumulateRadioRx(now - lastUpdateTime);
} else if (lastRadioState == RadioState.INTERFERED) {
accumulateRadioIntefered(now - lastUpdateTime);
}
/* Await next radio event */
if (radio.isTransmitting()) {
lastRadioState = RadioState.TRANSMITTING;
} else if (!radio.isReceiverOn()) {
lastRadioState = RadioState.IDLE;
} else if (radio.isInterfered()) {
lastRadioState = RadioState.INTERFERED;
} else if (radio.isReceiving()) {
lastRadioState = RadioState.RECEIVING;
} else {
lastRadioState = RadioState.IDLE;
}
radioWasOn = radio.isReceiverOn();
lastUpdateTime = now;
}
protected void accumulateDuration(long t) {
duration += t;
}
protected void accumulateRadioOn(long t) {
radioOn += t;
}
protected void accumulateRadioTx(long t) {
radioTx += t;
}
protected void accumulateRadioRx(long t) {
radioRx += t;
}
protected void accumulateRadioIntefered(long t) {
radioInterfered += t;
}
protected double getRadioOnRatio() {
return 1.0*radioOn/duration;
}
protected double getRadioTxRatio() {
return 1.0*radioTx/duration;
}
protected double getRadioInterferedRatio() {
return 1.0*radioInterfered/duration;
}
protected double getRadioRxRatio() {
return 1.0*radioRx/duration;
}
public Mote getMote() {
return mote;
}
public void dispose() {
radio.deleteObserver(this);
radio = null;
mote = null;
}
public String toString() {
return toString(true, true);
}
public String toString(boolean radioHW, boolean radioRXTX) {
StringBuilder sb = new StringBuilder();
String moteString = mote.toString().replace(' ', '_');
sb.append(moteString + " MONITORED " + duration + " us\n");
if (radioHW) {
sb.append(String.format(moteString + " ON " + (radioOn + " us ") + "%2.2f %%", 100.0*getRadioOnRatio()) + "\n");
}
if (radioRXTX) {
sb.append(String.format(moteString + " TX " + (radioTx + " us ") + "%2.2f %%", 100.0*getRadioTxRatio()) + "\n");
sb.append(String.format(moteString + " RX " + (radioRx + " us ") + "%2.2f %%", 100.0*getRadioRxRatio()) + "\n");
sb.append(String.format(moteString + " INT " + (radioInterfered + " us ") + "%2.2f %%", 100.0*getRadioInterferedRatio()) + "\n");
}
return sb.toString();
}
}
private MoteTracker createMoteTracker(Mote mote) {
final Radio moteRadio = mote.getInterfaces().getRadio();
if (moteRadio == null) {
return null;
}
/* Radio observer */
MoteTracker tracker = new MoteTracker(mote);
tracker.update(null, null);
return tracker;
}
public void reset() {
while (moteTrackers.size() > 0) {
removeMote(moteTrackers.get(0).mote);
}
for (Mote m: simulation.getMotes()) {
addMote(m);
}
}
private void addMote(Mote mote) {
if (mote == null) {
return;
}
MoteTracker t = createMoteTracker(mote);
if (t != null) {
moteTrackers.add(t);
}
setTitle("PowerTracker: " + moteTrackers.size() + " motes");
}
private void removeMote(Mote mote) {
/* Remove mote tracker(s) */
MoteTracker[] trackers = moteTrackers.toArray(new MoteTracker[0]);
for (MoteTracker t: trackers) {
if (t.getMote() == mote) {
t.dispose();
moteTrackers.remove(t);
}
}
setTitle("PowerTracker: " + moteTrackers.size() + " motes");
}
public void closePlugin() {
/* Remove repaint timer */
repaintTimer.stop();
simulation.getEventCentral().removeMoteCountListener(moteCountListener);
/* Remove mote trackers */
for (Mote m: simulation.getMotes()) {
removeMote(m);
}
if (!moteTrackers.isEmpty()) {
logger.fatal("Mote observers not cleaned up correctly");
for (MoteTracker t: moteTrackers.toArray(new MoteTracker[0])) {
t.dispose();
}
}
}
public enum RadioState {
IDLE, RECEIVING, TRANSMITTING, INTERFERED
}
private Timer repaintTimer = new Timer(POWERTRACKER_UPDATE_INTERVAL, new ActionListener() {
public void actionPerformed(ActionEvent e) {
/* Identify max radio on */
double maxRadioOn = 0;
int maxRadioOnIndex = -1;
for (int i=0; i < moteTrackers.size(); i++) {
MoteTracker mt = moteTrackers.get(i);
if (mt.getRadioOnRatio() > maxRadioOn) {
maxRadioOn = mt.getRadioOnRatio();
maxRadioOnIndex = i;
}
}
if (maxRadioOnIndex >= 0) {
tableMaxRadioOnIndex = maxRadioOnIndex;
}
table.repaint();
}
});
public Collection<Element> getConfigXML() {
return null;
}
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
return true;
}
}

View file

@ -96,6 +96,7 @@ The COOJA Simulator
<ant antfile="build.xml" dir="apps/avrora" target="clean" inheritAll="false"/>
<ant antfile="build.xml" dir="apps/serial_socket" target="clean" inheritAll="false"/>
<ant antfile="build.xml" dir="apps/collect-view" target="clean" inheritAll="false"/>
<ant antfile="build.xml" dir="apps/powertracker" target="clean" inheritAll="false"/>
</target>
<target name="run" depends="init, compile, jar, copy configs">
@ -189,6 +190,7 @@ The COOJA Simulator
<ant antfile="build.xml" dir="apps/avrora" target="jar" inheritAll="false"/>
<ant antfile="build.xml" dir="apps/serial_socket" target="jar" inheritAll="false"/>
<ant antfile="build.xml" dir="apps/collect-view" target="jar" inheritAll="false"/>
<ant antfile="build.xml" dir="apps/powertracker" target="jar" inheritAll="false"/>
</target>
<target name="run_nogui" depends="init, compile, jar, copy configs">

View file

@ -22,7 +22,7 @@ AR_COMMAND_2 =
CONTIKI_STANDARD_PROCESSES = sensors_process;etimer_process
CORECOMM_TEMPLATE_FILENAME = corecomm_template.java
PATH_JAVAC = javac
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view;[CONTIKI_DIR]/tools/cooja/apps/powertracker
PARSE_WITH_COMMAND=false
PARSE_COMMAND=nm -a $(LIBFILE)

View file

@ -22,7 +22,7 @@ AR_COMMAND_2 =
CONTIKI_STANDARD_PROCESSES = sensors_process;etimer_process
CORECOMM_TEMPLATE_FILENAME = corecomm_template.java
PATH_JAVAC = javac
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view;[CONTIKI_DIR]/tools/cooja/apps/powertracker
PARSE_WITH_COMMAND=false
PARSE_COMMAND=nm -a $(LIBFILE)

View file

@ -22,7 +22,7 @@ AR_COMMAND_2 =
CONTIKI_STANDARD_PROCESSES = sensors_process;etimer_process
CORECOMM_TEMPLATE_FILENAME = corecomm_template.java
PATH_JAVAC = javac
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view;[CONTIKI_DIR]/tools/cooja/apps/powertracker
PARSE_WITH_COMMAND=false
PARSE_COMMAND=nm -a $(LIBFILE)

View file

@ -22,7 +22,7 @@ AR_COMMAND_2 =
CONTIKI_STANDARD_PROCESSES = sensors_process;etimer_process
CORECOMM_TEMPLATE_FILENAME = corecomm_template.java
PATH_JAVAC = javac
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view;[CONTIKI_DIR]/tools/cooja/apps/powertracker
PARSE_WITH_COMMAND = true
PARSE_COMMAND = /opt/contiki-2.x/tools/cooja/examples/jni_test/mac_users/nmandsize $(LIBFILE)

View file

@ -22,7 +22,7 @@ AR_COMMAND_2 =
CONTIKI_STANDARD_PROCESSES = sensors_process;etimer_process
CORECOMM_TEMPLATE_FILENAME = corecomm_template.java
PATH_JAVAC = javac
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view;[CONTIKI_DIR]/tools/cooja/apps/powertracker
PARSE_WITH_COMMAND = true
PARSE_COMMAND=nm -n -C $(LIBFILE)

View file

@ -38,16 +38,18 @@ while (counter<10) {
GENERATE_MSG(1000, "wait");
YIELD_THEN_WAIT_UNTIL(msg.equals("wait"));
/* Extract Timeline statistics */
plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.TimeLine");
/* Extract PowerTracker statistics */
plugin = mote.getSimulation().getGUI().getStartedPlugin("PowerTracker");
if (plugin != null) {
plugins++;
stats = plugin.extractStatistics();
stats = plugin.radioStatistics();
if (stats.length() > 40) {
/* Stripping */
stats = stats.substring(0, 40) + "...";
}
log.log("Timeline: Extracted statistics:\n" + stats + "\n");
log.log("PowerTracker: Extracted statistics:\n" + stats + "\n");
} else {
log.log("No PowerTracker plugin\n");
}
GENERATE_MSG(1000, "wait");

View file

@ -26,7 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uip6-bridge-tap.c,v 1.2 2011/01/19 09:13:06 salvopitru Exp $
*
*/
@ -43,6 +42,7 @@
#include "dev/slip.h"
#include "dev/leds.h"
#include "sicslow_ethernet.h"
#include "sys/clock.h"
#include "net/packetbuf.h"
@ -50,8 +50,6 @@
#include <stdio.h>
#include <string.h>
void clock_wait(int i);
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
PROCESS(uip6_bridge, "IPv6/6lowpan TAP bridge");