forked from jheising/node.pcduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplatform.c
executable file
·62 lines (53 loc) · 1.01 KB
/
platform.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Arduino.h"
unsigned long millis()
{
unsigned long m;
struct timeval tv;
gettimeofday (&tv , NULL);
return (tv.tv_sec*1000 + tv.tv_usec/1000);
}
unsigned long micros() {
unsigned long m;
struct timeval tv;
gettimeofday (&tv , NULL);
return (tv.tv_sec * 1000000 + tv.tv_usec);
}
//under construct
//can refine with timer interrupt, but need more implement
void delay(unsigned long ms)
{
/*
unsigned long start = millis();
while (ms > 0) {
if (millis() - start >= ms)
break;
}
*/
usleep(ms*1000);
}
//under construct
//can refine with timer interrupt, but need more implement
void delayMicroseconds(unsigned int us)
{
/*
unsigned long start = micros();
while (us > 0) {
if ( micros() - start >= us)
break;
}
*/
usleep(us);
}
void delaySched(unsigned long ms)
{
usleep(ms*1000);
}
void delayMicrosecondsSched(unsigned int us)
{
usleep(us);
}
void pabort(const char *s)
{
perror(s);
abort();
}