timer.h

Go to the documentation of this file.
00001 /*
00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
00003 
00004 Copyright (C): Edouard TISSERANT and Francis DUPIN
00005 
00006 See COPYING file for copyrights details.
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Lesser General Public
00010 License as published by the Free Software Foundation; either
00011 version 2.1 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Lesser General Public License for more details.
00017 
00018 You should have received a copy of the GNU Lesser General Public
00019 License along with this library; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef __timer_h__
00024 #define __timer_h__
00025 
00026 #include <timerscfg.h>
00027 #include <applicfg.h>
00028 
00029 #define TIMER_HANDLE INTEGER16
00030 
00031 #include "data.h"
00032 
00033 /* --------- types and constants definitions --------- */
00034 #define TIMER_FREE 0
00035 #define TIMER_ARMED 1
00036 #define TIMER_TRIG 2
00037 #define TIMER_TRIG_PERIOD 3
00038 
00039 #define TIMER_NONE -1
00040 
00041 typedef void (*TimerCallback_t)(CO_Data* d, UNS32 id);
00042 
00043 struct struct_s_timer_entry {
00044         UNS8 state;
00045         CO_Data* d;
00046         TimerCallback_t callback; /* The callback func. */
00047         UNS32 id; /* The callback func. */
00048         TIMEVAL val;
00049         TIMEVAL interval; /* Periodicity */
00050 };
00051 
00052 typedef struct struct_s_timer_entry s_timer_entry;
00053 
00054 /* ---------  prototypes --------- */
00055 /*#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)*/
00056 TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period);
00057 TIMER_HANDLE DelAlarm(TIMER_HANDLE handle);
00058 void TimeDispatch(void);
00059 
00060 /* ---------  to be defined in user app ---------*/
00061 void setTimer(TIMEVAL value);
00062 TIMEVAL getElapsedTime(void);
00063 
00064 #endif /* #define __timer_h__ */

Generated on Fri Jun 8 08:51:39 2007 for CanFestival by  doxygen 1.5.1