aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/delay.h
blob: e4d85c5d8f890a2dbfeb0273e9740cf5f98377b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
 *  @brief Delay implementation
 */

#ifndef _DELAY_H_
#define _DELAY_H_

static inline void delay_us(uint32 us) {
    /* So (2^32)/12 micros max, or less than 6 minutes */
    us *= 12;

    /* fudge for function call overhead  */
    us--;
    asm volatile("   mov r0, %[us]          \n\t"
                 "1: subs r0, #1            \n\t"
                 "   bhi 1b                 \n\t"
                 :
                 : [us] "r" (us)
                 : "r0");
}
#endif