[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/telosb/mac/tkn154/timer Alarm62500hz32C.nc, NONE, 1.1 Alarm62500hz32P.nc, NONE, 1.1 Alarm32khzTo62500hzTransformC.nc, 1.2, 1.3

Jan-Hinrich Hauer janhauer at users.sourceforge.net
Tue Nov 25 01:35:11 PST 2008


Update of /cvsroot/tinyos/tinyos-2.x/tos/platforms/telosb/mac/tkn154/timer
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21632/tos/platforms/telosb/mac/tkn154/timer

Modified Files:
	Alarm32khzTo62500hzTransformC.nc 
Added Files:
	Alarm62500hz32C.nc Alarm62500hz32P.nc 
Log Message:
+ modified radio driver (PHY) interfaces: CSMA-CA algorithm is now pushed to radio driver
+ adapted CC2420 driver
+ renamed CsmaP -> FrameDispatchP
+ provided workaround for a problem with virtualized alarms (sometimes they seem to fire 2s too late)
+ updated placeholder components
+ updated debug information

--- NEW FILE: Alarm62500hz32C.nc ---
#include "Timer62500hz.h"
generic configuration Alarm62500hz32C()
{
  provides interface Alarm<T62500hz,uint32_t> as Alarm;
}
implementation
{
  components new Alarm32khz32C(), MainC;
  components new Alarm62500hz32P();

  Alarm = Alarm62500hz32P;

  MainC -> Alarm32khz32C.Init;
  Alarm62500hz32P.AlarmFrom -> Alarm32khz32C;
}

--- NEW FILE: Alarm62500hz32P.nc ---
/*
 * Copyright (c) 2008, Technische Universitaet Berlin
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright 
 *   notice, this list of conditions and the following disclaimer in the 
 *   documentation and/or other materials provided with the distribution.
 * - Neither the name of the Technische Universitaet Berlin nor the names 
 *   of its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * - Revision -------------------------------------------------------------
 * $Date: 2008/11/25 09:35:09 $
 * @author Jan Hauer <hauer at tkn.tu-berlin.de>
 * ========================================================================
 */

generic module Alarm62500hz32P()

{
  provides interface Alarm<T62500hz,uint32_t> as Alarm;
  uses interface Alarm<T32khz,uint32_t> as AlarmFrom;
}
implementation
{
/**
 * TelosB lacks a clock with the precision and accuracy 
 * required by the 802.15.4 standard (62500 Hz, 40 ppm).
 * As a workaround, we cast one tick of the 32768 Hz clock to 
 * two 802.15.4 symbols, which introduces a small (5%) error.
 * Thus the channel access in particular in beacon-enabled PANs 
 * (slotted CSMA-CA) is not be standard-compliant!
 */

  async command void Alarm.start(uint32_t dt){ call AlarmFrom.start(dt >> 1);}
  async command void Alarm.stop(){ call AlarmFrom.stop();}
  async event void AlarmFrom.fired(){ signal Alarm.fired();}
  async command bool Alarm.isRunning(){ return call AlarmFrom.isRunning();}
  async command uint32_t Alarm.getAlarm(){ return call AlarmFrom.getAlarm() << 1;}

  async command uint32_t Alarm.getNow(){ 
    // this might shift out the most significant bit
    // that's why Alarm.startAt() is converted to a Alarm.start()
    return call AlarmFrom.getNow() << 1; 
  }

  async command void Alarm.startAt(uint32_t t0, uint32_t dt){
    // t0 occured before "now"
    atomic {
      uint32_t now = call Alarm.getNow(), elapsed;
      if (t0 < now)
        elapsed = now - t0;
      else
        elapsed = ~(t0 - now) + 1;
      if (elapsed > dt)
        dt = elapsed;
      dt -= elapsed;
      call Alarm.start(dt);
    }
  }

  /******************** Defaults ****************************/

  default async command void AlarmFrom.start(uint32_t dt){ }
  default async command void AlarmFrom.stop(){ }
  default async command bool AlarmFrom.isRunning(){ return FALSE;}
  default async event void Alarm.fired(){}
  default async command void AlarmFrom.startAt(uint32_t t0, uint32_t dt){ }
  default async command uint32_t AlarmFrom.getNow(){ return 0;}
  default async command uint32_t AlarmFrom.getAlarm(){ return 0;}
}

Index: Alarm32khzTo62500hzTransformC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/telosb/mac/tkn154/timer/Alarm32khzTo62500hzTransformC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Alarm32khzTo62500hzTransformC.nc	25 Jun 2008 10:19:04 -0000	1.2
--- Alarm32khzTo62500hzTransformC.nc	25 Nov 2008 09:35:09 -0000	1.3
***************
*** 42,49 ****
  {
  /**
!  * This is the place where we cheat: since we don't have a clock source
!  * running at 62500 Hz, we cast 2 symbols to 1 tick of the 32768
!  * clock, which introduces a small (5%) error.
! */
  #warning "Warning: MAC timing is not standard compliant (the symbol clock is based on the 32768 Hz oscillator)!"
  
--- 42,52 ----
  {
  /**
!  * TelosB lacks a clock with the precision and accuracy 
!  * required by the 802.15.4 standard (62500 Hz, 40 ppm).
!  * As a workaround, we cast one tick of the 32768 Hz clock to 
!  * two 802.15.4 symbols, which introduces a small (5%) error.
!  * Thus the channel access in particular in beacon-enabled PANs 
!  * (slotted CSMA-CA) is not be standard-compliant!
!  */
  #warning "Warning: MAC timing is not standard compliant (the symbol clock is based on the 32768 Hz oscillator)!"
  
***************
*** 62,74 ****
    async command void Alarm.startAt[ uint8_t num ](uint32_t t0, uint32_t dt){
      // t0 occured before "now"
!     uint32_t now = call Alarm.getNow[num](), elapsed;
!     if (t0 <= now)
!       elapsed = now - t0;
!     else
!       elapsed = ~(t0 - now) + 1;
!     if (elapsed > dt)
!       elapsed = dt;
!     dt -= elapsed;
!     call AlarmFrom.start[num](dt >> 1);
    }
  
--- 65,79 ----
    async command void Alarm.startAt[ uint8_t num ](uint32_t t0, uint32_t dt){
      // t0 occured before "now"
!     atomic {
!       uint32_t now = call Alarm.getNow[num](), elapsed;
!       if (t0 < now)
!         elapsed = now - t0;
!       else
!         elapsed = ~(t0 - now) + 1;
!       if (elapsed > dt)
!         dt = elapsed;
!       dt -= elapsed;
!       call Alarm.start[num](dt);
!     }
    }
  



More information about the Tinyos-2-commits mailing list