include/timer.h
changeset 71 95cd3376cc9f
parent 0 4472ee7c6c3e
child 145 e747d2e26af0
equal deleted inserted replaced
70:f36f09f08b62 71:95cd3376cc9f
    27 
    27 
    28 #define TIMER_HANDLE INTEGER16
    28 #define TIMER_HANDLE INTEGER16
    29 
    29 
    30 #include "data.h"
    30 #include "data.h"
    31 
    31 
    32 // --------- types et constants definitions ---------
    32 /* --------- types and constants definitions --------- */
    33 #define TIMER_FREE 0
    33 #define TIMER_FREE 0
    34 #define TIMER_ARMED 1
    34 #define TIMER_ARMED 1
    35 #define TIMER_TRIG 2
    35 #define TIMER_TRIG 2
    36 #define TIMER_TRIG_PERIOD 3
    36 #define TIMER_TRIG_PERIOD 3
    37 
    37 
    40 typedef void (*TimerCallback_t)(CO_Data* d, UNS32 id);
    40 typedef void (*TimerCallback_t)(CO_Data* d, UNS32 id);
    41 
    41 
    42 struct struct_s_timer_entry {
    42 struct struct_s_timer_entry {
    43 	UNS8 state;
    43 	UNS8 state;
    44 	CO_Data* d;
    44 	CO_Data* d;
    45 	TimerCallback_t callback; // The callback func.
    45 	TimerCallback_t callback; /* The callback func. */
    46 	UNS32 id; // The callback func.
    46 	UNS32 id; /* The callback func. */
    47 	TIMEVAL val;
    47 	TIMEVAL val;
    48 	TIMEVAL interval; // Periodicity
    48 	TIMEVAL interval; /* Periodicity */
    49 };
    49 };
    50 
    50 
    51 typedef struct struct_s_timer_entry s_timer_entry;
    51 typedef struct struct_s_timer_entry s_timer_entry;
    52 
    52 
    53 // ---------  prototypes ---------
    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)
    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)*/
    55 TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period);
    55 TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period);
    56 TIMER_HANDLE DelAlarm(TIMER_HANDLE handle);
    56 TIMER_HANDLE DelAlarm(TIMER_HANDLE handle);
    57 void TimeDispatch(void);
    57 void TimeDispatch(void);
    58 
    58 
    59 // ---------  to be defined in user app ---------
    59 /* ---------  to be defined in user app ---------*/
    60 void setTimer(TIMEVAL value);
    60 void setTimer(TIMEVAL value);
    61 TIMEVAL getElapsedTime(void);
    61 TIMEVAL getElapsedTime(void);
    62 
    62 
    63 #endif // #define __timer_h__
    63 #endif /* #define __timer_h__ */