forked from Traumflug/Teacup_Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelay.c
More file actions
32 lines (25 loc) · 632 Bytes
/
delay.c
File metadata and controls
32 lines (25 loc) · 632 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "delay.h"
/** \file
\brief Delay routines
*/
#define TEACUP_C_INCLUDE
#include "delay-avr.c"
#include "delay-arm.c"
#undef TEACUP_C_INCLUDE
#include "watchdog.h"
/** Delay in milliseconds.
\param delay Time to wait in milliseconds.
Accuracy on AVR, 20 MHz: delay < 0.04% too long over the whole range.
Accuracy on AVR, 16 MHz: delay < 0.8% too short over the whole range.
Accuracy on ARM, 48 MHz: delay < 0.1% too long over the whole range.
*/
void delay_ms(uint32_t delay) {
wd_reset();
while (delay > 65) {
delay_us(64999);
delay -= 65;
wd_reset();
}
delay_us(delay * 1000 - 2);
wd_reset();
}