0
|
1 |
/*
|
|
2 |
This file is part of CanFestival, a library implementing CanOpen Stack.
|
|
3 |
|
|
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN
|
|
5 |
|
|
6 |
See COPYING file for copyrights details.
|
|
7 |
|
|
8 |
This library is free software; you can redistribute it and/or
|
|
9 |
modify it under the terms of the GNU Lesser General Public
|
|
10 |
License as published by the Free Software Foundation; either
|
|
11 |
version 2.1 of the License, or (at your option) any later version.
|
|
12 |
|
|
13 |
This library is distributed in the hope that it will be useful,
|
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16 |
Lesser General Public License for more details.
|
|
17 |
|
|
18 |
You should have received a copy of the GNU Lesser General Public
|
|
19 |
License along with this library; if not, write to the Free Software
|
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 |
*/
|
|
22 |
|
|
23 |
#ifndef __timer_h__
|
|
24 |
#define __timer_h__
|
|
25 |
|
|
26 |
#include <applicfg.h>
|
|
27 |
|
|
28 |
#define TIMER_HANDLE INTEGER16
|
|
29 |
|
|
30 |
#include "data.h"
|
|
31 |
|
71
|
32 |
/* --------- types and constants definitions --------- */
|
0
|
33 |
#define TIMER_FREE 0
|
|
34 |
#define TIMER_ARMED 1
|
|
35 |
#define TIMER_TRIG 2
|
|
36 |
#define TIMER_TRIG_PERIOD 3
|
|
37 |
|
|
38 |
#define TIMER_NONE -1
|
|
39 |
|
|
40 |
typedef void (*TimerCallback_t)(CO_Data* d, UNS32 id);
|
|
41 |
|
|
42 |
struct struct_s_timer_entry {
|
|
43 |
UNS8 state;
|
|
44 |
CO_Data* d;
|
71
|
45 |
TimerCallback_t callback; /* The callback func. */
|
|
46 |
UNS32 id; /* The callback func. */
|
0
|
47 |
TIMEVAL val;
|
71
|
48 |
TIMEVAL interval; /* Periodicity */
|
0
|
49 |
};
|
|
50 |
|
|
51 |
typedef struct struct_s_timer_entry s_timer_entry;
|
|
52 |
|
71
|
53 |
/* --------- prototypes --------- */
|
|
54 |
/*#define SetAlarm(d, id, callback, value, period) printf("%s, %d, SetAlarm(%s, %s, %s, %s, %s)\n",__FILE__, __LINE__, #d, #id, #callback, #value, #period); _SetAlarm(d, id, callback, value, period)*/
|
0
|
55 |
TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period);
|
|
56 |
TIMER_HANDLE DelAlarm(TIMER_HANDLE handle);
|
|
57 |
void TimeDispatch(void);
|
|
58 |
|
71
|
59 |
/* --------- to be defined in user app ---------*/
|
0
|
60 |
void setTimer(TIMEVAL value);
|
|
61 |
TIMEVAL getElapsedTime(void);
|
|
62 |
|
71
|
63 |
#endif /* #define __timer_h__ */
|