The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_SEEED_TINY_BLE/TARGET_NORDIC/TARGET_MCU_NRF51822/device/nrf_delay.h@157:e7ca05fa8600, 2017-11-09 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 09 11:14:10 2017 +0000
- Revision:
- 157:e7ca05fa8600
- Parent:
- 128:9bcdf88f62b0
Release 155 of the mbed library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 128:9bcdf88f62b0 | 1 | #ifndef _NRF_DELAY_H |
<> | 128:9bcdf88f62b0 | 2 | #define _NRF_DELAY_H |
<> | 128:9bcdf88f62b0 | 3 | |
<> | 128:9bcdf88f62b0 | 4 | // #include "nrf.h" |
<> | 128:9bcdf88f62b0 | 5 | |
<> | 128:9bcdf88f62b0 | 6 | /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ |
<> | 128:9bcdf88f62b0 | 7 | #if defined ( __CC_ARM ) |
<> | 128:9bcdf88f62b0 | 8 | static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
<> | 128:9bcdf88f62b0 | 9 | { |
<> | 128:9bcdf88f62b0 | 10 | loop |
<> | 128:9bcdf88f62b0 | 11 | SUBS R0, R0, #1 |
<> | 128:9bcdf88f62b0 | 12 | NOP |
<> | 128:9bcdf88f62b0 | 13 | NOP |
<> | 128:9bcdf88f62b0 | 14 | NOP |
<> | 128:9bcdf88f62b0 | 15 | NOP |
<> | 128:9bcdf88f62b0 | 16 | NOP |
<> | 128:9bcdf88f62b0 | 17 | NOP |
<> | 128:9bcdf88f62b0 | 18 | NOP |
<> | 128:9bcdf88f62b0 | 19 | NOP |
<> | 128:9bcdf88f62b0 | 20 | NOP |
<> | 128:9bcdf88f62b0 | 21 | NOP |
<> | 128:9bcdf88f62b0 | 22 | NOP |
<> | 128:9bcdf88f62b0 | 23 | NOP |
<> | 128:9bcdf88f62b0 | 24 | BNE loop |
<> | 128:9bcdf88f62b0 | 25 | BX LR |
<> | 128:9bcdf88f62b0 | 26 | } |
<> | 128:9bcdf88f62b0 | 27 | #elif defined ( __ICCARM__ ) |
<> | 128:9bcdf88f62b0 | 28 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) |
<> | 128:9bcdf88f62b0 | 29 | { |
<> | 128:9bcdf88f62b0 | 30 | __ASM ( |
<> | 128:9bcdf88f62b0 | 31 | "loop:\n\t" |
<> | 128:9bcdf88f62b0 | 32 | " SUBS R0, R0, #1\n\t" |
<> | 128:9bcdf88f62b0 | 33 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 34 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 35 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 36 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 37 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 38 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 39 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 40 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 41 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 42 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 43 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 44 | " NOP\n\t" |
<> | 128:9bcdf88f62b0 | 45 | " BNE loop\n\t"); |
<> | 128:9bcdf88f62b0 | 46 | } |
<> | 128:9bcdf88f62b0 | 47 | #elif defined ( __GNUC__ ) |
<> | 128:9bcdf88f62b0 | 48 | static __INLINE void nrf_delay_us(uint32_t volatile number_of_us) |
<> | 128:9bcdf88f62b0 | 49 | { |
<> | 128:9bcdf88f62b0 | 50 | do |
<> | 128:9bcdf88f62b0 | 51 | { |
<> | 128:9bcdf88f62b0 | 52 | __ASM volatile ( |
<> | 128:9bcdf88f62b0 | 53 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 54 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 55 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 56 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 57 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 58 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 59 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 60 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 61 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 62 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 63 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 64 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 65 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 66 | "NOP\n\t" |
<> | 128:9bcdf88f62b0 | 67 | ); |
<> | 128:9bcdf88f62b0 | 68 | } while (--number_of_us); |
<> | 128:9bcdf88f62b0 | 69 | } |
<> | 128:9bcdf88f62b0 | 70 | #endif |
<> | 128:9bcdf88f62b0 | 71 | |
<> | 128:9bcdf88f62b0 | 72 | void nrf_delay_ms(uint32_t volatile number_of_ms); |
<> | 128:9bcdf88f62b0 | 73 | |
<> | 128:9bcdf88f62b0 | 74 | #endif |