]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/tosboot/micaz/hardware.h
Merge of the latest Deluge T2.
[tinyos-2.x.git] / tos / lib / tosboot / micaz / hardware.h
index 8f7a1c7f3003923073c03441c964df7dc07132f2..01fc2d1d4ebfa83f03c852edaba8d164ba990616 100644 (file)
 typedef uint32_t in_flash_addr_t;
 typedef uint32_t ex_flash_addr_t;
 
-void wait( uint16_t t ) {
-  for ( ; t; t-- );
+static inline void wait( uint16_t dt ) {
+  /* In most cases (constant arg), the test is elided at compile-time */
+  if (dt)
+    /* loop takes 8 cycles. this is 1uS if running on an internal 8MHz
+       clock, and 1.09uS if running on the external crystal. */
+    asm volatile (
+      "1:       sbiw    %0,1\n"
+      " adiw    %0,1\n"
+      " sbiw    %0,1\n"
+      " brne    1b" : "+w" (dt));
 }
 
 // LED assignments