Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.
source/nordic_sdk/components/drivers_nrf/hal/nrf_delay.h@19:47192cb9def7, 2016-04-07 (annotated)
- Committer:
- vcoubard
- Date:
- Thu Apr 07 17:37:40 2016 +0100
- Revision:
- 19:47192cb9def7
- Parent:
- 10:233fefd8162b
- Child:
- 20:a90c48eb1d30
Synchronized with git rev 9251259f
Author: Liyou Zhou
Copy over coresponding files from nordic-sdk 9.0.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 1:ebc0e0ef0a11 | 1 | #ifndef _NRF_DELAY_H |
vcoubard | 1:ebc0e0ef0a11 | 2 | #define _NRF_DELAY_H |
vcoubard | 1:ebc0e0ef0a11 | 3 | |
vcoubard | 1:ebc0e0ef0a11 | 4 | #include "nrf.h" |
vcoubard | 1:ebc0e0ef0a11 | 5 | |
vcoubard | 1:ebc0e0ef0a11 | 6 | /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ |
vcoubard | 1:ebc0e0ef0a11 | 7 | #if defined ( __CC_ARM ) |
vcoubard | 1:ebc0e0ef0a11 | 8 | static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
vcoubard | 1:ebc0e0ef0a11 | 9 | { |
vcoubard | 1:ebc0e0ef0a11 | 10 | loop |
vcoubard | 1:ebc0e0ef0a11 | 11 | SUBS R0, R0, #1 |
vcoubard | 1:ebc0e0ef0a11 | 12 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 13 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 14 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 15 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 16 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 17 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 18 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 19 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 20 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 21 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 22 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 23 | NOP |
vcoubard | 1:ebc0e0ef0a11 | 24 | BNE loop |
vcoubard | 1:ebc0e0ef0a11 | 25 | BX LR |
vcoubard | 1:ebc0e0ef0a11 | 26 | } |
vcoubard | 1:ebc0e0ef0a11 | 27 | #elif defined ( __ICCARM__ ) |
vcoubard | 1:ebc0e0ef0a11 | 28 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
vcoubard | 1:ebc0e0ef0a11 | 29 | { |
vcoubard | 1:ebc0e0ef0a11 | 30 | __ASM ( |
vcoubard | 1:ebc0e0ef0a11 | 31 | "loop:\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 32 | " SUBS R0, R0, #1\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 33 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 34 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 35 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 36 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 37 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 38 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 39 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 40 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 41 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 42 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 43 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 44 | " NOP\n\t" |
vcoubard | 1:ebc0e0ef0a11 | 45 | " BNE loop\n\t"); |
vcoubard | 1:ebc0e0ef0a11 | 46 | } |
vcoubard | 1:ebc0e0ef0a11 | 47 | #elif defined ( __GNUC__ ) |
vcoubard | 1:ebc0e0ef0a11 | 48 | |
vcoubard | 1:ebc0e0ef0a11 | 49 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) __attribute__((always_inline)); |
vcoubard | 1:ebc0e0ef0a11 | 50 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
vcoubard | 1:ebc0e0ef0a11 | 51 | { |
vcoubard | 1:ebc0e0ef0a11 | 52 | register uint32_t delay asm ("r0") = number_of_us; |
vcoubard | 1:ebc0e0ef0a11 | 53 | __ASM volatile ( |
vcoubard | 1:ebc0e0ef0a11 | 54 | ".syntax unified\n" |
vcoubard | 1:ebc0e0ef0a11 | 55 | "1:\n" |
vcoubard | 1:ebc0e0ef0a11 | 56 | " SUBS %0, %0, #1\n" |
vcoubard | 1:ebc0e0ef0a11 | 57 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 58 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 59 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 60 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 61 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 62 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 63 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 64 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 65 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 66 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 67 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 68 | " NOP\n" |
vcoubard | 1:ebc0e0ef0a11 | 69 | " BNE 1b\n" |
vcoubard | 1:ebc0e0ef0a11 | 70 | ".syntax divided\n" |
vcoubard | 1:ebc0e0ef0a11 | 71 | : "+r" (delay)); |
vcoubard | 1:ebc0e0ef0a11 | 72 | } |
vcoubard | 1:ebc0e0ef0a11 | 73 | #endif |
vcoubard | 1:ebc0e0ef0a11 | 74 | |
vcoubard | 1:ebc0e0ef0a11 | 75 | void nrf_delay_ms(uint32_t volatile number_of_ms); |
vcoubard | 1:ebc0e0ef0a11 | 76 | |
vcoubard | 1:ebc0e0ef0a11 | 77 | #endif |