Skip to content

Commit 825d8c8

Browse files
committed
sam: Optimized delayMicroseconds() (Rob Tillaart)
See #1121
1 parent 660c7d8 commit 825d8c8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

build/shared/revisions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ARDUINO 1.5.6 BETA
1111
[core]
1212
* sam: Fixed wrap-around bug in delay() (Mark Tillotson)
1313
* sam: Fixed regression in analogRead() (fails to read multiple channels) (Mark Tillotson)
14+
* sam: Optimized delayMicroseconds() (Rob Tillaart) #1121
1415
* Optimized Print::print(String&) method, now uses internal string buffer to perform block write
1516

1617
ARDUINO 1.5.5 BETA 2013.11.28

hardware/arduino/sam/cores/arduino/wiring.h

Lines changed: 2 additions & 1 deletion
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)