]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/platforms/mulle/timers/BusyWaitMicroC.nc
mulle platfor modification, flsh storage, more lowpower, softi2c improvements
[tinyos-2.x.git] / tos / platforms / mulle / timers / BusyWaitMicroC.nc
index 8dedf6c2b0092106b919eda109c7d9d9e4e38f5d..82aae0a8dec61fc759cab58d664c54ee0f917ed7 100755 (executable)
  *
  * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
  */
-configuration BusyWaitMicroC
+module BusyWaitMicroC
 {
   provides interface BusyWait<TMicro, uint16_t>;
 }
 implementation
 {
-  components CounterMicro16C,
-      new BusyWaitCounterC(TMicro, uint16_t);
-
-  BusyWait = BusyWaitCounterC;
-  BusyWaitCounterC.Counter -> CounterMicro16C;
+  // TODO(henrik) This will now only work on 10Mhz speed, easy to
+  //              add a signal from the control module of the mcu
+  //              to signal the change of speed and the wait function
+  //              can adjust to it.
+  inline async command void BusyWait.wait(uint16_t dt)
+  {
+    atomic {
+      asm volatile (
+          // The call and return of the Busywait takes about 1us
+          "sub.w #1,%[t]\n\t"
+          "1:\n\t"
+          "nop\n\t"
+          "add.w #1,%[t]\n\t"
+          "sub.w #1,%[t]\n\t"
+          "sub.w #1,%[t]\n\t"
+          "jgtu 1b"
+          :
+          : [t] "r" (dt)
+          );
+    }
+  }
 }