X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Flib%2Ftosboot%2Fmicaz%2Fhardware.h;h=01fc2d1d4ebfa83f03c852edaba8d164ba990616;hb=62b84950912c1c033c401fb0b2a1efaceec78280;hp=8f7a1c7f3003923073c03441c964df7dc07132f2;hpb=a887d42035d66e33374c484606bbb11cafec6c31;p=tinyos-2.x.git diff --git a/tos/lib/tosboot/micaz/hardware.h b/tos/lib/tosboot/micaz/hardware.h index 8f7a1c7f..01fc2d1d 100644 --- a/tos/lib/tosboot/micaz/hardware.h +++ b/tos/lib/tosboot/micaz/hardware.h @@ -80,8 +80,16 @@ 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