We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent afb6d13 commit acb5928Copy full SHA for acb5928
1 file changed
firmware/common/delay.c
@@ -32,11 +32,23 @@ void delay(uint32_t duration)
32
33
void delay_us_at_mhz(uint32_t us, uint32_t mhz)
34
{
35
+#if defined(LPC43XX_M4)
36
// The loop below takes 3 cycles per iteration.
37
uint32_t loop_iterations = (us * mhz) / 3;
38
asm volatile("start%=:\n"
39
" subs %[ITERATIONS], #1\n" // 1 cycle
40
" bpl start%=\n" // 2 cycles
41
:
42
: [ITERATIONS] "r"(loop_iterations));
43
+#elif defined(LPC43XX_M0)
44
+ // The loop below takes 4 cycles per iteration.
45
+ uint32_t loop_iterations = (us * mhz) / 3;
46
+ asm volatile("start%=:\n"
47
+ " sub %[ITERATIONS], #1\n" // 1 cycle
48
+ " bpl start%=\n" // 3 cycles
49
+ :
50
+ : [ITERATIONS] "r"(loop_iterations));
51
+#else
52
+ #error "No delay loop implementation"
53
+#endif
54
}
0 commit comments