]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/nrf_delay.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[qmk_firmware.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_NORDIC / TARGET_MCU_NRF51822 / nrf_delay.h
1 #ifndef _NRF_DELAY_H
2 #define _NRF_DELAY_H
3
4 // #include "nrf.h"
5
6 /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */
7 #if defined ( __CC_ARM   )
8 static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
9 {
10 loop
11         SUBS    R0, R0, #1
12         NOP
13         NOP
14         NOP
15         NOP
16         NOP
17         NOP
18         NOP
19         NOP
20         NOP
21         NOP
22         NOP
23         NOP
24         BNE    loop
25         BX     LR
26 }
27 #elif defined ( __ICCARM__ )
28 static void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
29 {
30 __ASM (
31 "loop:\n\t"
32        " SUBS R0, R0, #1\n\t"
33        " NOP\n\t"
34        " NOP\n\t"
35        " NOP\n\t"
36        " NOP\n\t"
37        " NOP\n\t"
38        " NOP\n\t"
39        " NOP\n\t"
40        " NOP\n\t"
41        " NOP\n\t"
42        " NOP\n\t"
43        " NOP\n\t"
44        " NOP\n\t"
45        " BNE loop\n\t");
46 }
47 #elif defined   (  __GNUC__  )
48 static void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
49 {
50     do 
51     {
52     __ASM volatile (
53         "NOP\n\t"
54         "NOP\n\t"
55         "NOP\n\t"
56         "NOP\n\t"
57         "NOP\n\t"
58         "NOP\n\t"
59         "NOP\n\t"
60         "NOP\n\t"
61         "NOP\n\t"
62         "NOP\n\t"
63         "NOP\n\t"
64         "NOP\n\t"
65         "NOP\n\t"
66         "NOP\n\t"
67     );
68     } while (--number_of_us);
69 }
70 #endif
71
72 void nrf_delay_ms(uint32_t volatile number_of_ms);
73
74 #endif