X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fplatforms%2Fmulle%2Ftimers%2FBusyWaitMicroC.nc;h=82aae0a8dec61fc759cab58d664c54ee0f917ed7;hb=2d74d98ec380d6cf237814287406c993977a60e3;hp=8dedf6c2b0092106b919eda109c7d9d9e4e38f5d;hpb=e0397b07a5a6ca7d8d0e9e6d33f317e4459327c6;p=tinyos-2.x.git diff --git a/tos/platforms/mulle/timers/BusyWaitMicroC.nc b/tos/platforms/mulle/timers/BusyWaitMicroC.nc index 8dedf6c2..82aae0a8 100755 --- a/tos/platforms/mulle/timers/BusyWaitMicroC.nc +++ b/tos/platforms/mulle/timers/BusyWaitMicroC.nc @@ -40,15 +40,31 @@ * * @author Henrik Makitaavola */ -configuration BusyWaitMicroC +module BusyWaitMicroC { provides interface BusyWait; } 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) + ); + } + } }