implementation
{
/**
- * 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.
-*/
+ * 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)!"
async command void Alarm.start[ uint8_t num ](uint32_t dt){ call AlarmFrom.start[num](dt >> 1);}
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);
+ 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);
+ }
}
/******************** Defaults ****************************/