|
From: Lin Gu <li...@us...> - 2005-04-15 01:53:43
|
Update of /cvsroot/vert/vert-1.3/tos/system In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28430 Modified Files: LedsC.nc TimerM.nc common.h sched.c Removed Files: AM.h Log Message: Synchrinizing a few modules with tinyos-1.x Index: LedsC.nc =================================================================== RCS file: /cvsroot/vert/vert-1.3/tos/system/LedsC.nc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LedsC.nc 29 Jan 2004 02:58:13 -0000 1.1.1.1 --- LedsC.nc 15 Apr 2005 01:53:24 -0000 1.2 *************** *** 60,63 **** --- 60,66 ---- ledsOn = 0; dbg(DBG_BOOT, "LEDS: initialized.\n"); + TOSH_MAKE_RED_LED_OUTPUT(); + TOSH_MAKE_YELLOW_LED_OUTPUT(); + TOSH_MAKE_GREEN_LED_OUTPUT(); TOSH_SET_RED_LED_PIN(); TOSH_SET_YELLOW_LED_PIN(); *************** *** 70,74 **** dbg(DBG_LED, "LEDS: Red on.\n"); atomic { ! TOSH_CLR_RED_LED_PIN(); ledsOn |= RED_BIT; } --- 73,77 ---- dbg(DBG_LED, "LEDS: Red on.\n"); atomic { ! TOSH_CLR_RED_LED_PIN(); ledsOn |= RED_BIT; } *************** *** 91,95 **** rval = call Leds.redOff(); else ! rval = call Leds.redOn(); } return rval; --- 94,99 ---- rval = call Leds.redOff(); else ! rval = call Leds.redOn(); ! ; } return rval; --- AM.h DELETED --- Index: TimerM.nc =================================================================== RCS file: /cvsroot/vert/vert-1.3/tos/system/TimerM.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimerM.nc 18 Jul 2004 16:14:21 -0000 1.2 --- TimerM.nc 15 Apr 2005 01:53:24 -0000 1.3 *************** *** 32,36 **** /* * ! * Authors: Su Ping <sp...@in...> * Revision: $Id$ * This implementation assumes that DEFAULT_SCALE is 3. --- 32,40 ---- /* * ! * Authors: Joe Polastre <pol...@cs...> ! * Rob Szewczyk <sze...@cs...> ! * David Gay <dg...@in...> ! * David Moore ! * * Revision: $Id$ * This implementation assumes that DEFAULT_SCALE is 3. *************** *** 60,63 **** --- 64,68 ---- uint8_t queue_size; uint8_t queue[NUM_TIMERS]; + volatile uint16_t interval_outstanding; struct timer_s { *************** *** 95,99 **** uint8_t diff; if (id >= NUM_TIMERS) return FAIL; ! if (type>1) return FAIL; mTimerList[id].ticks = interval ; mTimerList[id].type = type; --- 100,112 ---- uint8_t diff; if (id >= NUM_TIMERS) return FAIL; ! if (type > TIMER_ONE_SHOT) return FAIL; ! // PAL: ! // The current implementation of TimerM cannot support ! // continuous timers that fire faster than every 3 ticks (3ms). ! // The problem is due to the possibility that the hardware clock ! // could increment while setting the compare value, which would lead ! // to 256 ms until it fires, instead of 1-2. ! if ((type == TIMER_REPEAT) && interval <= 2) return FAIL; ! mTimerList[id].ticks = interval ; mTimerList[id].type = type; *************** *** 122,130 **** } } ! atomic { ! mInterval = val; ! call Clock.setInterval(mInterval); ! setIntervalFlag = 0; ! } } else { --- 135,158 ---- } } ! ! /* DCM: If the interval is set to be less than the current ! * counter value, the timer will count an extra 256 ticks before ! * hitting the interrupt. Thus, we check for this condition ! * and avoid it. */ ! /* PAL: This piece of code sets a maximum interrupt rate ! * that TimerM will request for continuous timers. TimerM ! * will never request an interrupt less than 3ms from the ! * current time; it therefore returns FAIL on continuous ! * timers with an interval <= 2 (see Timer.start()). */ ! ! atomic { ! i = call Clock.readCounter() + 3; ! if (val < i) { ! val = i; ! } ! mInterval = val; ! call Clock.setInterval(mInterval); ! setIntervalFlag = 0; ! } } else { *************** *** 182,207 **** task void HandleFire() { uint8_t i; setIntervalFlag = 1; if (mState) { for (i=0;i<NUM_TIMERS;i++) { if (mState&(0x1L<<i)) { ! mTimerList[i].ticksLeft -= (mInterval+1) ; if (mTimerList[i].ticksLeft<=2) { ! if (mTimerList[i].type==TIMER_REPEAT) { ! mTimerList[i].ticksLeft += mTimerList[i].ticks; ! } else {// one shot timer ! mState &=~(0x1L<<i); } - enqueue(i); - post signalOneTimer(); } } } } ! adjustInterval(); } async event result_t Clock.fire() { ! post HandleFire(); return SUCCESS; } --- 210,271 ---- task void HandleFire() { uint8_t i; + uint16_t int_out; setIntervalFlag = 1; + /* DCM: read the number of ticks elapsed since the last firing + * was handled. */ + atomic { + int_out = interval_outstanding; + interval_outstanding = 0; + } if (mState) { for (i=0;i<NUM_TIMERS;i++) { if (mState&(0x1L<<i)) { ! mTimerList[i].ticksLeft -= int_out; if (mTimerList[i].ticksLeft<=2) { ! /* DCM: only update the timer structure if the ! * signalOneTimer() task was able to be posted. */ ! if (post signalOneTimer()) { ! if (mTimerList[i].type==TIMER_REPEAT) { ! mTimerList[i].ticksLeft += mTimerList[i].ticks; ! } else {// one shot timer ! mState &=~(0x1L<<i); ! } ! enqueue(i); ! } ! else { ! dbg(DBG_ERROR, "TimerM: Have to wait another timer interval.\n"); ! /* DCM: wait another interval in hopes that ! * the task queue will clear out. */ ! mTimerList[i].ticksLeft = mInterval; } } } } } ! /* DCM: don't bother adjusting the interval if another interrupt ! * is hot on our tail. */ ! atomic int_out = interval_outstanding; ! if (int_out == 0) ! adjustInterval(); ! } + // #include "common.h" async event result_t Clock.fire() { ! /* static int n; ! ! showLeds(n++); ! */ ! atomic { ! /* DCM: Once we've posted HandleFire(), don't post it again until ! * the original one is handled. This prevents the task queue ! * from getting flooded when mInterval is small. */ ! if (interval_outstanding == 0) ! post HandleFire(); ! else ! dbg(DBG_ERROR, "Don't post handle fire, we're not ready\n"); ! /* DCM: Keep track of the interval since the last interrupt */ ! interval_outstanding += call Clock.getInterval() + 1; ! } return SUCCESS; } Index: sched.c =================================================================== RCS file: /cvsroot/vert/vert-1.3/tos/system/sched.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sched.c 25 Jul 2004 16:59:29 -0000 1.3 --- sched.c 15 Apr 2005 01:53:24 -0000 1.4 *************** *** 98,101 **** --- 98,106 ---- */ + /////// --lin bool TOS_post(void (*tp) ()) __attribute__((spontaneous)) { + #ifdef TKNL + bool TOS_post(void (*tp) ()) __attribute__ ((section (".secsched"))); + #endif + bool TOS_post(void (*tp) ()) __attribute__((spontaneous)) { __nesc_atomic_t fInterruptFlags; Index: common.h =================================================================== RCS file: /cvsroot/vert/vert-1.3/tos/system/common.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** common.h 4 Dec 2004 00:54:05 -0000 1.3 --- common.h 15 Apr 2005 01:53:24 -0000 1.4 *************** *** 11,14 **** --- 11,20 ---- #include "stdlib.h" + #ifdef TKERNEL + #define TOSH HW + #endif + + // #define NULL 0 + // Macros #define min(x, y) ((x)>(y) ? (y) : (x)) |