root / branches / encoders / code / projects / libdragonfly / time.h @ 731
History | View | Annotate | Download (1.6 KB)
1 | 8 | bcoltin | /**
|
---|---|---|---|
2 | * @file time.h
|
||
3 | * @brief Contains time-related functions and definitions
|
||
4 | *
|
||
5 | * Contains functions and definitions for dealing with time,
|
||
6 | * namely delay_ms and the realtime clock.
|
||
7 | *
|
||
8 | * @author Colony Project, CMU Robotics Club
|
||
9 | **/
|
||
10 | |||
11 | #ifndef _TIME_H_
|
||
12 | #define _TIME_H_
|
||
13 | |||
14 | 184 | ayeager | /*Maximum # of functions*/
|
15 | #define MAX_FUNCTIONS 10 |
||
16 | |||
17 | |||
18 | 8 | bcoltin | /* Predefined times for prescale_opt in time.c.
|
19 | To make you own, know that a pulse is 1/16th of a second. You cannot get less than this. To get more, you need
|
||
20 | to know how many 16ths of a second are in the time you want. (Time_desired * 16 = prescaler_opt)
|
||
21 | */
|
||
22 | /**
|
||
23 | * @addtogroup time
|
||
24 | * @{
|
||
25 | **/
|
||
26 | /** @brief A sixteenth of a second **/
|
||
27 | #define SIXTEENTH_SECOND 1 |
||
28 | /** @brief An eighth of a second **/
|
||
29 | #define EIGTH_SECOND 2 |
||
30 | /** @brief A quarter of a second **/
|
||
31 | #define QUARTER_SECOND 4 |
||
32 | /** @brief Half of a second **/
|
||
33 | #define HALF_SECOND 8 |
||
34 | /** @brief One second **/
|
||
35 | #define SECOND 16 |
||
36 | /** @brief Two seconds **/
|
||
37 | #define TWO_SECOND 32 |
||
38 | /** @brief Four seconds **/
|
||
39 | #define FOUR_SECOND 64 |
||
40 | |||
41 | /** @brief Delay execution for the specified time **/
|
||
42 | void delay_ms(int ms) ; |
||
43 | /** @brief Enable the realtime clock **/
|
||
44 | 184 | ayeager | int rtc_multi_init(int* prescale_opt, void (*rtc_fun[])(void), int argc); |
45 | 8 | bcoltin | /** @brief Reset the counter of the realtime clock **/
|
46 | void rtc_reset(void); |
||
47 | /** @brief Get the value of the realtime clock. **/
|
||
48 | int rtc_get(void); |
||
49 | |||
50 | 257 | ayeager | int rtc_add_function(void (*rtc_f) (void), int prescale_opt); |
51 | 184 | ayeager | |
52 | 257 | ayeager | int rtc_remove_function(void (*rtc_func)(void)); |
53 | int rtc_get_function_count(void); |
||
54 | 184 | ayeager | |
55 | 257 | ayeager | int rtc_init(int prescale_opt, void (*rtc_func)(void)); |
56 | |||
57 | 8 | bcoltin | /** @} **/
|
58 | |||
59 | #endif
|