]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/tda5250/mac/CsmaMacP.nc
refactor MAC protocols:
[tinyos-2.x.git] / tos / chips / tda5250 / mac / CsmaMacP.nc
index 46c19d3f00ade28edadea12a44a6d46a3bf95847..ec790e743cddf87a9fbe930b175d470b446bf753 100644 (file)
@@ -72,6 +72,7 @@ module CsmaMacP {
 
         interface Timer<TMilli> as ReRxTimer;
         interface Duplicate;
+        interface TimeDiff16;
         
         interface Alarm<T32khz, uint16_t> as Timer;
         async command am_addr_t amAddress();
@@ -303,17 +304,9 @@ implementation
     }
 
     void interruptBackoffTimer() {
-        uint16_t now;
         if(call Timer.isRunning()) {
-            restLaufzeit = call Timer.getAlarm();
+            restLaufzeit = call TimeDiff16.computeDelta(call Timer.getAlarm(), call Timer.getNow());
             call Timer.stop();
-            now = call Timer.getNow();
-            if(restLaufzeit >= now) {
-                restLaufzeit = restLaufzeit - now;
-            }
-            else {
-                restLaufzeit =  (uint16_t)(-1) - restLaufzeit + now;
-            }
             if(restLaufzeit > BACKOFF_MASK) {
                 restLaufzeit = call Random.rand16() & 0xFF;
             }