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