Skip to content

Commit b75ce8c

Browse files
committed
sam: Optimized delayMicroseconds() (Rob Tillaart)
See arduino#1121
1 parent 618aace commit b75ce8c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: cores/arduino/wiring.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ extern void delay( uint32_t dwMs ) ;
6464
*/
6565
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
6666
static inline void delayMicroseconds(uint32_t usec){
67+
if (usec == 0) return;
6768
uint32_t n = usec * (VARIANT_MCK / 3000000);
6869
asm volatile(
6970
"L_%=_delayMicroseconds:" "\n\t"
7071
"subs %0, #1" "\n\t"
71-
"bge L_%=_delayMicroseconds" "\n"
72+
"bne L_%=_delayMicroseconds" "\n"
7273
: "+r" (n) :
7374
);
7475
}

0 commit comments

Comments
 (0)