2011-10-07 19:18:23 -03:00
|
|
|
#include <stdio.h>
|
2011-10-09 06:41:03 -03:00
|
|
|
#include <unistd.h>
|
2011-10-07 19:18:23 -03:00
|
|
|
#include <time.h>
|
|
|
|
#include <sys/time.h>
|
2011-10-11 03:37:19 -03:00
|
|
|
#include <sched.h>
|
|
|
|
#include <wiring.h>
|
2011-10-07 19:18:23 -03:00
|
|
|
|
|
|
|
void setup(void);
|
|
|
|
void loop(void);
|
|
|
|
|
|
|
|
struct timeval sketch_start_time;
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
gettimeofday(&sketch_start_time, NULL);
|
|
|
|
setup();
|
2011-10-09 06:41:03 -03:00
|
|
|
while (true) {
|
2011-10-11 03:37:19 -03:00
|
|
|
struct timeval tv;
|
|
|
|
unsigned long t1, t2;
|
|
|
|
t1 = micros();
|
2011-10-09 06:41:03 -03:00
|
|
|
loop();
|
2011-10-11 03:37:19 -03:00
|
|
|
t2 = micros();
|
|
|
|
if (t2 - t1 < 2) {
|
|
|
|
tv.tv_sec = 0;
|
|
|
|
tv.tv_usec = 1;
|
|
|
|
select(0, NULL, NULL, NULL, &tv);
|
|
|
|
}
|
2011-10-09 06:41:03 -03:00
|
|
|
}
|
2011-10-07 19:18:23 -03:00
|
|
|
return 0;
|
|
|
|
}
|