-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.c
49 lines (40 loc) · 766 Bytes
/
main.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
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include "ztask.h"
void tick_poll(void)
{
static unsigned long old_msec;
struct timeval tv;
gettimeofday(&tv, NULL);
unsigned long msec = tv.tv_usec / 1000;
if(old_msec != msec) {
zt_tick();
old_msec = msec;
}
}
void hello(void)
{
static int count = 0;
printf("Hello, world. %d\n", count++);
fflush(stdout);
}
void hello2(void)
{
static int count = 0;
printf("\t\t\tHello, world2. %d\n", count++);
fflush(stdout);
}
int main(void)
{
char zt_mem[64];
zt_init(zt_mem, 64);
zt_bind(hello, 50, 1);
zt_bind(hello2, 80, 1);
while(1) {
zt_poll();
tick_poll();
usleep(500);
}
return 0;
}