Mouse code for the MacroRat
mbed-dev/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/nrf_delay.h@18:6a4db94011d3, 2017-05-14 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sun May 14 23:18:57 2017 +0000
- Revision:
- 18:6a4db94011d3
Publishing again
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | #ifndef _NRF_DELAY_H |
sahilmgandhi | 18:6a4db94011d3 | 2 | #define _NRF_DELAY_H |
sahilmgandhi | 18:6a4db94011d3 | 3 | |
sahilmgandhi | 18:6a4db94011d3 | 4 | // #include "nrf.h" |
sahilmgandhi | 18:6a4db94011d3 | 5 | |
sahilmgandhi | 18:6a4db94011d3 | 6 | /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ |
sahilmgandhi | 18:6a4db94011d3 | 7 | #if defined ( __CC_ARM ) |
sahilmgandhi | 18:6a4db94011d3 | 8 | static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
sahilmgandhi | 18:6a4db94011d3 | 9 | { |
sahilmgandhi | 18:6a4db94011d3 | 10 | loop |
sahilmgandhi | 18:6a4db94011d3 | 11 | SUBS R0, R0, #1 |
sahilmgandhi | 18:6a4db94011d3 | 12 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 13 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 14 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 15 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 16 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 17 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 18 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 19 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 20 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 21 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 22 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 23 | NOP |
sahilmgandhi | 18:6a4db94011d3 | 24 | BNE loop |
sahilmgandhi | 18:6a4db94011d3 | 25 | BX LR |
sahilmgandhi | 18:6a4db94011d3 | 26 | } |
sahilmgandhi | 18:6a4db94011d3 | 27 | #elif defined ( __ICCARM__ ) |
sahilmgandhi | 18:6a4db94011d3 | 28 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
sahilmgandhi | 18:6a4db94011d3 | 29 | { |
sahilmgandhi | 18:6a4db94011d3 | 30 | __ASM ( |
sahilmgandhi | 18:6a4db94011d3 | 31 | "loop:\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 32 | " SUBS R0, R0, #1\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 33 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 34 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 35 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 36 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 37 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 38 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 39 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 40 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 41 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 42 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 43 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 44 | " NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 45 | " BNE loop\n\t"); |
sahilmgandhi | 18:6a4db94011d3 | 46 | } |
sahilmgandhi | 18:6a4db94011d3 | 47 | #elif defined ( __GNUC__ ) |
sahilmgandhi | 18:6a4db94011d3 | 48 | static __INLINE void nrf_delay_us(uint32_t volatile number_of_us) |
sahilmgandhi | 18:6a4db94011d3 | 49 | { |
sahilmgandhi | 18:6a4db94011d3 | 50 | do |
sahilmgandhi | 18:6a4db94011d3 | 51 | { |
sahilmgandhi | 18:6a4db94011d3 | 52 | __ASM volatile ( |
sahilmgandhi | 18:6a4db94011d3 | 53 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 54 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 55 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 56 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 57 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 58 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 59 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 60 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 61 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 62 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 63 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 64 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 65 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 66 | "NOP\n\t" |
sahilmgandhi | 18:6a4db94011d3 | 67 | ); |
sahilmgandhi | 18:6a4db94011d3 | 68 | } while (--number_of_us); |
sahilmgandhi | 18:6a4db94011d3 | 69 | } |
sahilmgandhi | 18:6a4db94011d3 | 70 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 71 | |
sahilmgandhi | 18:6a4db94011d3 | 72 | void nrf_delay_ms(uint32_t volatile number_of_ms); |
sahilmgandhi | 18:6a4db94011d3 | 73 | |
sahilmgandhi | 18:6a4db94011d3 | 74 | #endif |