File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,20 @@ static __inline__ void delayMicroseconds( uint32_t usec )
68
68
return ;
69
69
}
70
70
71
+ #if defined(__SAMD51__ )
72
+ uint32_t n = usec * (VARIANT_MCK / 1000000 ) / 12 ;
73
+
74
+ __asm__ __volatile__(
75
+ "1: \n"
76
+ " sub %0, #1 \n" // substract 1 from %0 (n)
77
+ " cmp %0, #0 \n" // compare to 0
78
+ " bne 1b \n" // if result is not 0 jump to 1
79
+ : "+r" (n ) // '%0' is n variable with RW constraints
80
+ : // no input
81
+ : // no clobber
82
+ );
83
+
84
+ #else
71
85
/*
72
86
* The following loop:
73
87
*
@@ -85,6 +99,7 @@ static __inline__ void delayMicroseconds( uint32_t usec )
85
99
// VARIANT_MCK / 1000000 == cycles needed to delay 1uS
86
100
// 3 == cycles used in a loop
87
101
uint32_t n = usec * (VARIANT_MCK / 1000000 ) / 3 ;
102
+
88
103
__asm__ __volatile__(
89
104
"1: \n"
90
105
" sub %0, #1 \n" // substract 1 from %0 (n)
@@ -93,6 +108,7 @@ static __inline__ void delayMicroseconds( uint32_t usec )
93
108
: // no input
94
109
: // no clobber
95
110
);
111
+ #endif
96
112
// https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
97
113
// https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile
98
114
}
You can’t perform that action at this time.
0 commit comments