1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-17 22:23:10 +03:00

sam: Optimized delayMicroseconds() (Rob Tillaart)

See #1121
This commit is contained in:
Cristian Maglie
2013-12-30 12:17:50 +01:00
parent 660c7d86fd
commit 825d8c8455
2 changed files with 3 additions and 1 deletions

View File

@ -64,11 +64,12 @@ extern void delay( uint32_t dwMs ) ;
*/
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
static inline void delayMicroseconds(uint32_t usec){
if (usec == 0) return;
uint32_t n = usec * (VARIANT_MCK / 3000000);
asm volatile(
"L_%=_delayMicroseconds:" "\n\t"
"subs %0, #1" "\n\t"
"bge L_%=_delayMicroseconds" "\n"
"bne L_%=_delayMicroseconds" "\n"
: "+r" (n) :
);
}