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
34 #ifndef _CLOCK_TIME_H_
35 #define _CLOCK_TIME_H_
39 /* a 16 bit variable cannot cover one day */
40 typedef int32_t seconds;
41 typedef int32_t microseconds;
43 /** the time structure */
52 /**********************************************************/
54 /** init time module : schedule the event with the givent priority */
55 void time_init(uint8_t priority);
57 /**********************************************************/
59 /** get time in second since last init/reset */
60 seconds time_get_s(void);
62 /**********************************************************/
64 /** get time in microsecond since last init/reset */
65 microseconds time_get_us(void);
67 /**********************************************************/
69 /** get the complete time struct since last init/reset */
70 time_h time_get_time(void);
72 /**********************************************************/
74 /** reset time counter */
75 void time_reset(void);
77 /**********************************************************/
80 void time_set(seconds s, microseconds us);
82 /**********************************************************/
84 /** This is an equivalent of 'wait_ms(x)', but uses time value, so it
85 * is independant of CPU load. Warning, you should not use this
86 * function in a irq locked context, or in a scheduled function with
87 * higher priority than time module */
88 void time_wait_ms(uint16_t ms);
90 /**********************************************************/
92 /** get a microsecond timer that overflows naturally */
93 microseconds time_get_us2(void);