2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: time.h,v 1.3.4.2 2007-05-23 17:18:11 zer0 Exp $
22 /* Droids-corp, Eirbot, Microb Technology 2005 - Zer0
23 * Interface of the time module
27 * This module can be used to get a human readable time. It uses the
28 * scheduler module. Its goal is not to be very precise, but just
29 * simple to use. provides two timers: one in s and us, and one in
30 * us which doesn't overflow on seconds (better to substract two
39 /* a 16 bit variable cannot cover one day */
40 typedef int32_t seconds;
41 typedef int32_t microseconds;
44 /** the time structure */
53 /**********************************************************/
55 /** init time module : schedule the event with the givent priority */
56 void time_init(uint8_t priority);
58 /**********************************************************/
60 /** get time in second since last init/reset */
61 seconds time_get_s(void);
63 /**********************************************************/
65 /** get time in microsecond since last init/reset */
66 microseconds time_get_us(void);
68 /**********************************************************/
70 /** get the complete time struct since last init/reset */
71 time_h time_get_time(void);
73 /**********************************************************/
75 /** reset time counter */
76 void time_reset(void);
78 /**********************************************************/
81 void time_set(seconds s, microseconds us);
83 /**********************************************************/
85 /** This is an equivalent of 'wait_ms(x)', but uses time value, so it
86 * is independant of CPU load. Warning, you should not use this
87 * function in a irq locked context, or in a scheduled function with
88 * higher priority than time module */
89 void time_wait_ms(uint16_t ms);
91 /**********************************************************/
93 /** get a microsecond timer that overflows naturally */
94 microseconds time_get_us2(void);