-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
57 lines (47 loc) · 1.43 KB
/
example.c
File metadata and controls
57 lines (47 loc) · 1.43 KB
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
#include "timer.h"
//Global Timer Signal Variables
#define TIMER_SIGNAL_1 SIGRTMIN + 1
#define TIMER_SIGNAL_2 SIGRTMIN + 2
#define TIMER_SIGNAL_3 SIGRTMIN + 3
void timerCallback_1(int signal)
{
//(void)signal;
printf("Timer Interrupt %d ------------\n",signal);
}
void timerCallback_2(int signal)
{
//(void)signal;
printf("Timer Interrupt %d ------------\n",signal);
}
void timerCallback_3(int signal)
{
//(void)signal;
printf("Timer Interrupt %d ------------\n",signal);
}
int main(int argc,char **argv)
{
(void)argc;
(void)argv;
//Dynamic Memory Allocate
timerValues_t *timer1 = (timerValues_t *)malloc(sizeof(timerValues_t));
timerValues_t *timer2 = (timerValues_t *)malloc(sizeof(timerValues_t));
timerValues_t *timer3 = (timerValues_t *)malloc(sizeof(timerValues_t));
//Init Signal
timerInit(timer1,TIMER_SIGNAL_1,timerCallback_1);
timerInit(timer2,TIMER_SIGNAL_2,timerCallback_2);
timerInit(timer3,TIMER_SIGNAL_3,timerCallback_3);
//Timer Start
timerStart(timer1, 0 , 1000 ); //-> 1second Periodic Timer
timerStart(timer2, 1000, 1000 ); //-> 1second Periodic Timer
timerStart(timer3, 3000, 0 ); //-> 3second One Shot Timer
//Timer Stop
timerStop(timer1);
timerStop(timer2);
timerStop(timer3);
while(1);
//Dynamic Memory Deallocate
timerDeinit(timer1);
timerDeinit(timer2);
timerDeinit(timer3);
return EXIT_SUCCESS;
}