SG RFID nRF51822 fork

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nrf_delay.h Source File

nrf_delay.h

00001 #ifndef _NRF_DELAY_H
00002 #define _NRF_DELAY_H
00003 
00004 // #include "nrf.h"
00005 
00006 /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */
00007 #if defined ( __CC_ARM   )
00008 static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
00009 {
00010 loop
00011         SUBS    R0, R0, #1
00012         NOP
00013         NOP
00014         NOP
00015         NOP
00016         NOP
00017         NOP
00018         NOP
00019         NOP
00020         NOP
00021         NOP
00022         NOP
00023         NOP
00024         BNE    loop
00025         BX     LR
00026 }
00027 #elif defined ( __ICCARM__ )
00028 static void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
00029 {
00030 __ASM (
00031 "loop:\n\t"
00032        " SUBS R0, R0, #1\n\t"
00033        " NOP\n\t"
00034        " NOP\n\t"
00035        " NOP\n\t"
00036        " NOP\n\t"
00037        " NOP\n\t"
00038        " NOP\n\t"
00039        " NOP\n\t"
00040        " NOP\n\t"
00041        " NOP\n\t"
00042        " NOP\n\t"
00043        " NOP\n\t"
00044        " NOP\n\t"
00045        " BNE loop\n\t");
00046 }
00047 #elif defined   (  __GNUC__  )
00048 static void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
00049 {
00050     do
00051     {
00052     __ASM volatile (
00053         "NOP\n\t"
00054         "NOP\n\t"
00055         "NOP\n\t"
00056         "NOP\n\t"
00057         "NOP\n\t"
00058         "NOP\n\t"
00059         "NOP\n\t"
00060         "NOP\n\t"
00061         "NOP\n\t"
00062         "NOP\n\t"
00063         "NOP\n\t"
00064         "NOP\n\t"
00065         "NOP\n\t"
00066         "NOP\n\t"
00067     );
00068     } while (--number_of_us);
00069 }
00070 #endif
00071 
00072 void nrf_delay_ms(uint32_t volatile number_of_ms);
00073 
00074 #endif