File tree Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ extern "C" {
2525
2626#include <stdint.h>
2727
28+ #include "nrf_delay.h"
29+
2830#include "variant.h"
2931
3032/**
@@ -69,33 +71,7 @@ static __inline__ void delayMicroseconds( uint32_t usec )
6971 return ;
7072 }
7173
72- /*
73- * The following loop:
74- *
75- * for (; ul; ul--) {
76- * __asm__ volatile("");
77- * }
78- *
79- * produce the following assembly code:
80- *
81- * loop:
82- * subs r3, #1 // 1 Core cycle
83- * bne.n loop // 1 Core cycle + 1 if branch is taken
84- */
85-
86- // VARIANT_MCK / 1000000 == cycles needed to delay 1uS
87- // 3 == cycles used in a loop
88- uint32_t n = usec * (VARIANT_MCK / 1000000 ) / 3 ;
89- __asm__ __volatile__(
90- "1: \n"
91- " sub %0, #1 \n" // substract 1 from %0 (n)
92- " bne 1b \n" // if result is not 0 jump to 1
93- : "+r" (n ) // '%0' is n variable with RW constraints
94- : // no input
95- : // no clobber
96- );
97- // https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
98- // https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile
74+ nrf_delay_us (usec );
9975}
10076
10177#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments