From cac4e9a2221b61fff61331446d0ec326521a7c67 Mon Sep 17 00:00:00 2001 From: David Kopf Date: Mon, 9 Apr 2012 15:49:53 -0400 Subject: [PATCH] Add clock_delay_us and clock_set_seconds to clock.h. Modify clock_wait to use clock_time_t. Remove the troublesome avr/dev/delay.* files. Add PLATFORM_NAME and combine the confusing *_REVISION defines into a single PLATFORM_TYPE --- core/sys/clock.h | 86 ++- cpu/avr/dev/clock.c | 492 ++++++++++++------ cpu/avr/dev/delay.c | 29 -- cpu/avr/dev/delay.h | 9 - cpu/avr/dev/rtl8019.c | 49 +- cpu/avr/radio/rf230/hal.h | 16 +- cpu/avr/radio/rf230bb/hal.h | 52 +- cpu/avr/rtimer-arch.c | 1 - cpu/cc2430/dev/clock.c | 2 +- cpu/cc253x/dev/clock.c | 2 +- cpu/mc1322x/clock.c | 85 ++- cpu/mc1322x/contiki-mc1322x-conf.h | 7 +- cpu/msp430/f1xxx/clock.c | 2 +- cpu/msp430/f5xxx/clock.c | 2 +- cpu/stm32w108/clock.c | 3 +- platform/avr-atmega128rfa1/contiki-conf.h | 53 +- .../apps/raven-lcd-interface/raven-lcd.c | 1 - platform/avr-raven/contiki-conf.h | 61 +-- platform/avr-ravenusb/contiki-conf.h | 53 +- platform/avr-rcb/contiki-conf.h | 39 +- platform/avr-zigbit/contiki-conf.h | 44 +- platform/esb/contiki-conf.h | 2 - platform/esb/dev/beep.c | 1 + platform/exp5438/clock.c | 2 +- platform/iris/contiki-conf.h | 7 - platform/iris/platform-conf.h | 29 +- platform/mb851/dev/acc-sensor.c | 3 +- platform/mbxxx/clock.c | 2 +- platform/mbxxx/dev/acc-sensor.c | 3 +- platform/micaz/contiki-conf.h | 23 +- platform/micaz/contiki-micaz-main.c | 5 +- platform/micaz/dev/clock.c | 4 +- platform/micaz/platform-conf.h | 33 +- platform/redbee-econotag/contiki-conf.h | 5 + platform/stk500/contiki-conf.h | 39 +- platform/stk501/contiki-conf.h | 37 +- platform/stk501/contiki-stk501-main.c | 2 +- platform/z1/contiki-z1-main.c | 2 +- tools/stm32w/uip6_bridge/uip6-bridge-tap.c | 4 +- 39 files changed, 810 insertions(+), 481 deletions(-) delete mode 100644 cpu/avr/dev/delay.c delete mode 100644 cpu/avr/dev/delay.h diff --git a/core/sys/clock.h b/core/sys/clock.h index b14db6112..986f6ae33 100644 --- a/core/sys/clock.h +++ b/core/sys/clock.h @@ -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 * - * $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__ */ diff --git a/cpu/avr/dev/clock.c b/cpu/avr/dev/clock.c index 42a2c00a8..cc50364ec 100644 --- a/cpu/avr/dev/clock.c +++ b/cpu/avr/dev/clock.c @@ -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 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 #include -/* - 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. - - 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. +/* 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 -*/ - -/* 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; @@ -150,6 +352,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 */ @@ -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 */ @@ -334,4 +508,6 @@ ISR( _VECTOR(76)) {while (1) x++;} ISR( _VECTOR(77)) {while (1) x++;} ISR( _VECTOR(78)) {while (1) x++;} ISR( _VECTOR(79)) {while (1) x++;} -#endif \ No newline at end of file +#endif +/** @} */ +/** @} */ diff --git a/cpu/avr/dev/delay.c b/cpu/avr/dev/delay.c deleted file mode 100644 index 01cc3e4e2..000000000 --- a/cpu/avr/dev/delay.c +++ /dev/null @@ -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=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); diff --git a/cpu/avr/radio/rf230/hal.h b/cpu/avr/radio/rf230/hal.h index 0f4ba42ea..f7c80d707 100644 --- a/cpu/avr/radio/rf230/hal.h +++ b/cpu/avr/radio/rf230/hal.h @@ -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< 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(); @@ -98,9 +109,9 @@ void tmr0_isr(void) { /* clear the compare flags */ - clear_bit(*TMR(0,SCTRL),TCF); - clear_bit(*TMR(0,CSCTRL),TCF1); - clear_bit(*TMR(0,CSCTRL),TCF2); + clear_bit(*TMR(0,SCTRL),TCF); + clear_bit(*TMR(0,CSCTRL),TCF1); + clear_bit(*TMR(0,CSCTRL),TCF2); return; } else { /* this timer didn't create an interrupt condition */ @@ -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; } diff --git a/cpu/mc1322x/contiki-mc1322x-conf.h b/cpu/mc1322x/contiki-mc1322x-conf.h index e7fce0aaa..da8f6582a 100644 --- a/cpu/mc1322x/contiki-mc1322x-conf.h +++ b/cpu/mc1322x/contiki-mc1322x-conf.h @@ -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 +#endif \ No newline at end of file diff --git a/cpu/msp430/f1xxx/clock.c b/cpu/msp430/f1xxx/clock.c index 8e0be8728..b17694f2a 100644 --- a/cpu/msp430/f1xxx/clock.c +++ b/cpu/msp430/f1xxx/clock.c @@ -186,7 +186,7 @@ clock_delay(unsigned int i) * */ void -clock_wait(int i) +clock_wait(clock_time_t i) { clock_time_t start; diff --git a/cpu/msp430/f5xxx/clock.c b/cpu/msp430/f5xxx/clock.c index d0cca7e83..3cda89232 100644 --- a/cpu/msp430/f5xxx/clock.c +++ b/cpu/msp430/f5xxx/clock.c @@ -183,7 +183,7 @@ clock_delay(unsigned int i) * */ void -clock_wait(int i) +clock_wait(clock_time_t i) { clock_time_t start; diff --git a/cpu/stm32w108/clock.c b/cpu/stm32w108/clock.c index aa47d39c7..f85073079 100644 --- a/cpu/stm32w108/clock.c +++ b/cpu/stm32w108/clock.c @@ -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; diff --git a/platform/avr-atmega128rfa1/contiki-conf.h b/platform/avr-atmega128rfa1/contiki-conf.h index 5ca971204..0cf995e34 100644 --- a/platform/avr-atmega128rfa1/contiki-conf.h +++ b/platform/avr-atmega128rfa1/contiki-conf.h @@ -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 -/* 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 diff --git a/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c b/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c index 070e5db5f..4cb93813b 100644 --- a/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c +++ b/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c @@ -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< -/* 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 diff --git a/platform/avr-ravenusb/contiki-conf.h b/platform/avr-ravenusb/contiki-conf.h index 663703997..0571502b2 100644 --- a/platform/avr-ravenusb/contiki-conf.h +++ b/platform/avr-ravenusb/contiki-conf.h @@ -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 #include #include -/* 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 */ diff --git a/platform/avr-rcb/contiki-conf.h b/platform/avr-rcb/contiki-conf.h index c02fd0cc1..b2cc0053e 100644 --- a/platform/avr-rcb/contiki-conf.h +++ b/platform/avr-rcb/contiki-conf.h @@ -44,17 +44,39 @@ #include -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__ */ diff --git a/platform/avr-zigbit/contiki-conf.h b/platform/avr-zigbit/contiki-conf.h index 53aa6bf23..03943d991 100644 --- a/platform/avr-zigbit/contiki-conf.h +++ b/platform/avr-zigbit/contiki-conf.h @@ -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 + +/* 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 - /* 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__ */ diff --git a/platform/esb/contiki-conf.h b/platform/esb/contiki-conf.h index 7b3ef0252..ad11e2142 100644 --- a/platform/esb/contiki-conf.h +++ b/platform/esb/contiki-conf.h @@ -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 diff --git a/platform/esb/dev/beep.c b/platform/esb/dev/beep.c index b5b6e6f8b..f16e2a90c 100644 --- a/platform/esb/dev/beep.c +++ b/platform/esb/dev/beep.c @@ -33,6 +33,7 @@ #include "contiki.h" #include "contiki-esb.h" +#include "sys/clock.h" #define ON 1 #define OFF 0 diff --git a/platform/exp5438/clock.c b/platform/exp5438/clock.c index 0b0973c97..f701af9b7 100644 --- a/platform/exp5438/clock.c +++ b/platform/exp5438/clock.c @@ -214,7 +214,7 @@ __delay_cycles(int c) * */ void -clock_wait(int i) +clock_wait(clock_time_t i) { clock_time_t start; diff --git a/platform/iris/contiki-conf.h b/platform/iris/contiki-conf.h index 00a1401c3..1c8c48a7f 100644 --- a/platform/iris/contiki-conf.h +++ b/platform/iris/contiki-conf.h @@ -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 */ diff --git a/platform/iris/platform-conf.h b/platform/iris/platform-conf.h index fc39ea646..f31087944 100644 --- a/platform/iris/platform-conf.h +++ b/platform/iris/platform-conf.h @@ -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 diff --git a/platform/mb851/dev/acc-sensor.c b/platform/mb851/dev/acc-sensor.c index e3e6221c9..032c7465d 100644 --- a/platform/mb851/dev/acc-sensor.c +++ b/platform/mb851/dev/acc-sensor.c @@ -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 diff --git a/platform/mbxxx/clock.c b/platform/mbxxx/clock.c index 5128f639a..145a6fd07 100644 --- a/platform/mbxxx/clock.c +++ b/platform/mbxxx/clock.c @@ -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; diff --git a/platform/mbxxx/dev/acc-sensor.c b/platform/mbxxx/dev/acc-sensor.c index e3e6221c9..93dab123f 100644 --- a/platform/mbxxx/dev/acc-sensor.c +++ b/platform/mbxxx/dev/acc-sensor.c @@ -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 diff --git a/platform/micaz/contiki-conf.h b/platform/micaz/contiki-conf.h index 20ee75a18..493ed08b1 100644 --- a/platform/micaz/contiki-conf.h +++ b/platform/micaz/contiki-conf.h @@ -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__ */ diff --git a/platform/micaz/contiki-micaz-main.c b/platform/micaz/contiki-micaz-main.c index ba60027f8..a2fdba71d 100644 --- a/platform/micaz/contiki-micaz-main.c +++ b/platform/micaz/contiki-micaz-main.c @@ -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 */ @@ -103,7 +104,7 @@ main(void) ctimer_init(); leds_on(LEDS_YELLOW); - + init_net(); printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u\n"), node_id); diff --git a/platform/micaz/dev/clock.c b/platform/micaz/dev/clock.c index d69b7a83d..2ed808637 100644 --- a/platform/micaz/dev/clock.c +++ b/platform/micaz/dev/clock.c @@ -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 diff --git a/platform/micaz/platform-conf.h b/platform/micaz/platform-conf.h index a2521131d..2be1483f8 100644 --- a/platform/micaz/platform-conf.h +++ b/platform/micaz/platform-conf.h @@ -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 diff --git a/platform/redbee-econotag/contiki-conf.h b/platform/redbee-econotag/contiki-conf.h index 1aee86f44..35290dd6d 100644 --- a/platform/redbee-econotag/contiki-conf.h +++ b/platform/redbee-econotag/contiki-conf.h @@ -51,6 +51,8 @@ #include +#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 diff --git a/platform/stk500/contiki-conf.h b/platform/stk500/contiki-conf.h index c0b26336b..169aa6c9c 100644 --- a/platform/stk500/contiki-conf.h +++ b/platform/stk500/contiki-conf.h @@ -3,15 +3,37 @@ #include +/* 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. */ diff --git a/platform/stk501/contiki-conf.h b/platform/stk501/contiki-conf.h index b0fe93b5c..d2ac3da96 100644 --- a/platform/stk501/contiki-conf.h +++ b/platform/stk501/contiki-conf.h @@ -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__ */ diff --git a/platform/stk501/contiki-stk501-main.c b/platform/stk501/contiki-stk501-main.c index 0baf2a259..3223bbfae 100644 --- a/platform/stk501/contiki-stk501-main.c +++ b/platform/stk501/contiki-stk501-main.c @@ -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); diff --git a/platform/z1/contiki-z1-main.c b/platform/z1/contiki-z1-main.c index e721c8cdf..3b6195437 100644 --- a/platform/z1/contiki-z1-main.c +++ b/platform/z1/contiki-z1-main.c @@ -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 diff --git a/tools/stm32w/uip6_bridge/uip6-bridge-tap.c b/tools/stm32w/uip6_bridge/uip6-bridge-tap.c index 02366972b..0f9da30ee 100644 --- a/tools/stm32w/uip6_bridge/uip6-bridge-tap.c +++ b/tools/stm32w/uip6_bridge/uip6-bridge-tap.c @@ -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 #include -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");