UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
delay.c
Go to the documentation of this file.
1 
11 #include "../delay.h"
12 
13 #include <time.h>
14 #include <inttypes.h>
15 #include <asm/errno.h>
16 
19 void Delay_ms(uint32_t milliseconds)
20 {
21  Delay_us(1000 * milliseconds);
22 }
23 
24 void Delay_us(uint32_t microseconds)
25 {
26  struct timespec req, rem;
27  req.tv_sec = microseconds / (1000 * 1000);
28  req.tv_nsec = (microseconds - (req.tv_sec*1000*1000))*1000;
29 
30  while(nanosleep(&req, &rem) == EINTR)
31  {
32  /* Interrupted by signal, shallow copy remaining time into request, and resume */
33  req = rem;
34  }
35 }
36 
void Delay_ms(uint32_t milliseconds)
Definition: delay.c:19
void Delay_us(uint32_t microseconds)
Definition: delay.c:24