mbed library
Fork of mbed by
TARGET_RBLAB_NRF51822/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nrf-sdk/nrf_delay.h@89:552587b429a1, 2014-09-12 (annotated)
- Committer:
- bogdanm
- Date:
- Fri Sep 12 16:41:52 2014 +0100
- Revision:
- 89:552587b429a1
Release 89 of the mbed library
Main changes:
- low power optimizations for Nordic targets
- code structure changes for Freescale K64F targets
- bug fixes in various backends
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 89:552587b429a1 | 1 | #ifndef _NRF_DELAY_H |
bogdanm | 89:552587b429a1 | 2 | #define _NRF_DELAY_H |
bogdanm | 89:552587b429a1 | 3 | |
bogdanm | 89:552587b429a1 | 4 | // #include "nrf.h" |
bogdanm | 89:552587b429a1 | 5 | |
bogdanm | 89:552587b429a1 | 6 | /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ |
bogdanm | 89:552587b429a1 | 7 | #if defined ( __CC_ARM ) |
bogdanm | 89:552587b429a1 | 8 | static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
bogdanm | 89:552587b429a1 | 9 | { |
bogdanm | 89:552587b429a1 | 10 | loop |
bogdanm | 89:552587b429a1 | 11 | SUBS R0, R0, #1 |
bogdanm | 89:552587b429a1 | 12 | NOP |
bogdanm | 89:552587b429a1 | 13 | NOP |
bogdanm | 89:552587b429a1 | 14 | NOP |
bogdanm | 89:552587b429a1 | 15 | NOP |
bogdanm | 89:552587b429a1 | 16 | NOP |
bogdanm | 89:552587b429a1 | 17 | NOP |
bogdanm | 89:552587b429a1 | 18 | NOP |
bogdanm | 89:552587b429a1 | 19 | NOP |
bogdanm | 89:552587b429a1 | 20 | NOP |
bogdanm | 89:552587b429a1 | 21 | NOP |
bogdanm | 89:552587b429a1 | 22 | NOP |
bogdanm | 89:552587b429a1 | 23 | NOP |
bogdanm | 89:552587b429a1 | 24 | BNE loop |
bogdanm | 89:552587b429a1 | 25 | BX LR |
bogdanm | 89:552587b429a1 | 26 | } |
bogdanm | 89:552587b429a1 | 27 | #elif defined ( __ICCARM__ ) |
bogdanm | 89:552587b429a1 | 28 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
bogdanm | 89:552587b429a1 | 29 | { |
bogdanm | 89:552587b429a1 | 30 | __ASM ( |
bogdanm | 89:552587b429a1 | 31 | "loop:\n\t" |
bogdanm | 89:552587b429a1 | 32 | " SUBS R0, R0, #1\n\t" |
bogdanm | 89:552587b429a1 | 33 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 34 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 35 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 36 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 37 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 38 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 39 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 40 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 41 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 42 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 43 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 44 | " NOP\n\t" |
bogdanm | 89:552587b429a1 | 45 | " BNE loop\n\t"); |
bogdanm | 89:552587b429a1 | 46 | } |
bogdanm | 89:552587b429a1 | 47 | #elif defined ( __GNUC__ ) |
bogdanm | 89:552587b429a1 | 48 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
bogdanm | 89:552587b429a1 | 49 | { |
bogdanm | 89:552587b429a1 | 50 | do |
bogdanm | 89:552587b429a1 | 51 | { |
bogdanm | 89:552587b429a1 | 52 | __ASM volatile ( |
bogdanm | 89:552587b429a1 | 53 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 54 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 55 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 56 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 57 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 58 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 59 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 60 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 61 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 62 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 63 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 64 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 65 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 66 | "NOP\n\t" |
bogdanm | 89:552587b429a1 | 67 | ); |
bogdanm | 89:552587b429a1 | 68 | } while (--number_of_us); |
bogdanm | 89:552587b429a1 | 69 | } |
bogdanm | 89:552587b429a1 | 70 | #endif |
bogdanm | 89:552587b429a1 | 71 | |
bogdanm | 89:552587b429a1 | 72 | void nrf_delay_ms(uint32_t volatile number_of_ms); |
bogdanm | 89:552587b429a1 | 73 | |
bogdanm | 89:552587b429a1 | 74 | #endif |