root / trunk / docs / libdragonfly / group__time.html @ 1371
History | View | Annotate | Download (12.3 KB)
1 | 41 | bcoltin | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
---|---|---|---|
2 | 241 | bcoltin | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
3 | 41 | bcoltin | <title>libdragonfly: Time</title> |
4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
||
5 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
||
6 | </head><body> |
||
7 | 1145 | deffi | <!-- Generated by Doxygen 1.5.5 -->
|
8 | <div class="navigation" id="top"> |
||
9 | <div class="tabs"> |
||
10 | <ul>
|
||
11 | <li><a href="index.html"><span>Main Page</span></a></li> |
||
12 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
||
13 | <li><a href="modules.html"><span>Modules</span></a></li> |
||
14 | <li><a href="annotated.html"><span>Data Structures</span></a></li> |
||
15 | <li><a href="files.html"><span>Files</span></a></li> |
||
16 | </ul>
|
||
17 | </div>
|
||
18 | 241 | bcoltin | </div>
|
19 | 1145 | deffi | <div class="contents"> |
20 | 41 | bcoltin | <h1>Time</h1>Time functions. |
21 | <a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0"> |
||
22 | <tr><td></td></tr> |
||
23 | <tr><td colspan="2"><br><h2>Defines</h2></td></tr> |
||
24 | <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gd271145628da4e0e85e3e2486d117713"></a><!-- doxytag: member="time::SIXTEENTH_SECOND" ref="gd271145628da4e0e85e3e2486d117713" args="" --> |
||
25 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#gd271145628da4e0e85e3e2486d117713">SIXTEENTH_SECOND</a> 1</td></tr> |
||
26 | |||
27 | <tr><td class="mdescLeft"> </td><td class="mdescRight">A sixteenth of a second. <br></td></tr> |
||
28 | <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g7bdae984203001070e9abeb3190f844a"></a><!-- doxytag: member="time::EIGTH_SECOND" ref="g7bdae984203001070e9abeb3190f844a" args="" --> |
||
29 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g7bdae984203001070e9abeb3190f844a">EIGTH_SECOND</a> 2</td></tr> |
||
30 | |||
31 | <tr><td class="mdescLeft"> </td><td class="mdescRight">An eighth of a second. <br></td></tr> |
||
32 | <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g0b2a348d9afca1f1182bc2bb2aa6a3d1"></a><!-- doxytag: member="time::QUARTER_SECOND" ref="g0b2a348d9afca1f1182bc2bb2aa6a3d1" args="" --> |
||
33 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g0b2a348d9afca1f1182bc2bb2aa6a3d1">QUARTER_SECOND</a> 4</td></tr> |
||
34 | |||
35 | <tr><td class="mdescLeft"> </td><td class="mdescRight">A quarter of a second. <br></td></tr> |
||
36 | <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gf95f27544f39827250d6bef6fa5fe18e"></a><!-- doxytag: member="time::HALF_SECOND" ref="gf95f27544f39827250d6bef6fa5fe18e" args="" --> |
||
37 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#gf95f27544f39827250d6bef6fa5fe18e">HALF_SECOND</a> 8</td></tr> |
||
38 | |||
39 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Half of a second. <br></td></tr> |
||
40 | <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g94212be2394d2d37d9dfd33d07d82dba"></a><!-- doxytag: member="time::SECOND" ref="g94212be2394d2d37d9dfd33d07d82dba" args="" --> |
||
41 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g94212be2394d2d37d9dfd33d07d82dba">SECOND</a> 16</td></tr> |
||
42 | |||
43 | <tr><td class="mdescLeft"> </td><td class="mdescRight">One second. <br></td></tr> |
||
44 | <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g4c2dc0c899e1571596205f29fcc35cd6"></a><!-- doxytag: member="time::TWO_SECOND" ref="g4c2dc0c899e1571596205f29fcc35cd6" args="" --> |
||
45 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g4c2dc0c899e1571596205f29fcc35cd6">TWO_SECOND</a> 32</td></tr> |
||
46 | |||
47 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Two seconds. <br></td></tr> |
||
48 | <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g335312d1eed285bbc48a7f383ad78d97"></a><!-- doxytag: member="time::FOUR_SECOND" ref="g335312d1eed285bbc48a7f383ad78d97" args="" --> |
||
49 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g335312d1eed285bbc48a7f383ad78d97">FOUR_SECOND</a> 64</td></tr> |
||
50 | |||
51 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Four seconds. <br></td></tr> |
||
52 | <tr><td colspan="2"><br><h2>Functions</h2></td></tr> |
||
53 | <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g8aa473f8ae9a91df4bc9ea700983c72d">delay_ms</a> (int ms)</td></tr> |
||
54 | |||
55 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Delay execution for the specified time. <a href="#g8aa473f8ae9a91df4bc9ea700983c72d"></a><br></td></tr> |
||
56 | <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g4b8a034dd8e994f4a1af612806f7c553">rtc_init</a> (int prescale_opt, void(*rtc_func)(void))</td></tr> |
||
57 | |||
58 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Enable the realtime clock. <a href="#g4b8a034dd8e994f4a1af612806f7c553"></a><br></td></tr> |
||
59 | <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g5c7f2bf39314463dd5f4913e05ca991d">rtc_get</a> (void)</td></tr> |
||
60 | |||
61 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the value of the realtime clock. <a href="#g5c7f2bf39314463dd5f4913e05ca991d"></a><br></td></tr> |
||
62 | <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__time.html#g83ae542199d1c0e964aff89537d686a3">rtc_reset</a> (void)</td></tr> |
||
63 | |||
64 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Reset the counter of the realtime clock. <a href="#g83ae542199d1c0e964aff89537d686a3"></a><br></td></tr> |
||
65 | </table>
|
||
66 | <hr><a name="_details"></a><h2>Detailed Description</h2> |
||
67 | Time functions. |
||
68 | <p>
|
||
69 | Functions dealing with time. <hr><h2>Function Documentation</h2> |
||
70 | 241 | bcoltin | <a class="anchor" name="g8aa473f8ae9a91df4bc9ea700983c72d"></a><!-- doxytag: member="time.c::delay_ms" ref="g8aa473f8ae9a91df4bc9ea700983c72d" args="(int ms)" --> |
71 | <div class="memitem"> |
||
72 | <div class="memproto"> |
||
73 | <table class="memname"> |
||
74 | 41 | bcoltin | <tr>
|
75 | 241 | bcoltin | <td class="memname">void delay_ms </td> |
76 | <td>(</td> |
||
77 | <td class="paramtype">int </td> |
||
78 | <td class="paramname"> <em>ms</em> </td> |
||
79 | <td> ) </td> |
||
80 | <td width="100%"></td> |
||
81 | 41 | bcoltin | </tr>
|
82 | </table>
|
||
83 | 241 | bcoltin | </div>
|
84 | <div class="memdoc"> |
||
85 | 41 | bcoltin | |
86 | <p>
|
||
87 | Delay execution for the specified time. |
||
88 | <p>
|
||
89 | 862 | kwoo | Delays for the specified number of milliseconds. It depends on F_CPU to be defined in order to calculate how many cycles it should delay. If it is not defined, a default clock of 8MHz is assumed.<p>
|
90 | We use _delay_loop_2 which will run assembly instructions that should be 4 cycles long. Optimizations must be enabled for this to be true. That function is called to ensure around 1ms per execution. To generate multiple ms we run a for loop of how many milliseconds are desired.<p>
|
||
91 | The error should be just the skew on the oscillator as the formula to calculate delay cycles should always be a whole number. The is some skew in practice though it is unavoidable. Delaying for less than 1s should make the error negligable.<p>
|
||
92 | 41 | bcoltin | <dl compact><dt><b>Parameters:</b></dt><dd> |
93 | <table border="0" cellspacing="2" cellpadding="0"> |
||
94 | <tr><td valign="top"></td><td valign="top"><em>ms</em> </td><td>the number of milliseconds to delay for </td></tr> |
||
95 | </table>
|
||
96 | </dl>
|
||
97 | 241 | bcoltin | |
98 | 1145 | deffi | <p>Referenced by <a class="el" href="dio_8c-source.html#l00251">button1_wait()</a>, <a class="el" href="dio_8c-source.html#l00294">button2_wait()</a>, <a class="el" href="buzzer_8c-source.html#l00115">buzzer_chirp()</a>, <a class="el" href="dragonfly__lib_8c-source.html#l00120">flash_red()</a>, <a class="el" href="lcd_8c-source.html#l00173">lcd_init()</a>, and <a class="el" href="odometry_8c-source.html#l00048">odometry_init()</a>.</p> |
99 | |||
100 | 241 | bcoltin | </div>
|
101 | </div><p> |
||
102 | <a class="anchor" name="g5c7f2bf39314463dd5f4913e05ca991d"></a><!-- doxytag: member="time.c::rtc_get" ref="g5c7f2bf39314463dd5f4913e05ca991d" args="(void)" --> |
||
103 | <div class="memitem"> |
||
104 | <div class="memproto"> |
||
105 | <table class="memname"> |
||
106 | 41 | bcoltin | <tr>
|
107 | 241 | bcoltin | <td class="memname">int rtc_get </td> |
108 | <td>(</td> |
||
109 | <td class="paramtype">void </td> |
||
110 | <td class="paramname"> </td> |
||
111 | <td> ) </td> |
||
112 | <td width="100%"></td> |
||
113 | 41 | bcoltin | </tr>
|
114 | </table>
|
||
115 | 241 | bcoltin | </div>
|
116 | <div class="memdoc"> |
||
117 | 41 | bcoltin | |
118 | <p>
|
||
119 | Get the value of the realtime clock. |
||
120 | <p>
|
||
121 | Returns the time elapsed in seconds since the last call to rtc_init or rtc_reset.<p>
|
||
122 | 241 | bcoltin | <dl class="return" compact><dt><b>Returns:</b></dt><dd>the number of seconds since the last call to rtc_init or rtc_reset</dd></dl> |
123 | <dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__time.html#g4b8a034dd8e994f4a1af612806f7c553" title="Enable the realtime clock.">rtc_init</a>, <a class="el" href="group__time.html#g83ae542199d1c0e964aff89537d686a3" title="Reset the counter of the realtime clock.">rtc_reset</a> </dd></dl> |
||
124 | |||
125 | </div>
|
||
126 | </div><p> |
||
127 | <a class="anchor" name="g4b8a034dd8e994f4a1af612806f7c553"></a><!-- doxytag: member="time.c::rtc_init" ref="g4b8a034dd8e994f4a1af612806f7c553" args="(int prescale_opt, void(*rtc_func)(void))" --> |
||
128 | <div class="memitem"> |
||
129 | <div class="memproto"> |
||
130 | <table class="memname"> |
||
131 | 41 | bcoltin | <tr>
|
132 | 241 | bcoltin | <td class="memname">void rtc_init </td> |
133 | <td>(</td> |
||
134 | <td class="paramtype">int </td> |
||
135 | <td class="paramname"> <em>prescale_opt</em>, </td> |
||
136 | 41 | bcoltin | </tr>
|
137 | <tr>
|
||
138 | 241 | bcoltin | <td class="paramkey"></td> |
139 | <td></td> |
||
140 | <td class="paramtype">void(*)(void) </td> |
||
141 | <td class="paramname"> <em>rtc_func</em></td><td> </td> |
||
142 | 41 | bcoltin | </tr>
|
143 | <tr>
|
||
144 | 241 | bcoltin | <td></td> |
145 | <td>)</td> |
||
146 | <td></td><td></td><td width="100%"></td> |
||
147 | 41 | bcoltin | </tr>
|
148 | </table>
|
||
149 | 241 | bcoltin | </div>
|
150 | <div class="memdoc"> |
||
151 | 41 | bcoltin | |
152 | <p>
|
||
153 | Enable the realtime clock. |
||
154 | <p>
|
||
155 | 241 | bcoltin | Initializes the real time clock. Prescales are defined in <a class="el" href="time_8h.html" title="Contains time-related functions and definitions.">time.h</a>. For example, SECOND will give 1 second. The specified function is called every clock tick. For the real time clock to activate, interrupts must be enabled. (through sei() )<p> |
156 | 41 | bcoltin | <dl compact><dt><b>Parameters:</b></dt><dd> |
157 | <table border="0" cellspacing="2" cellpadding="0"> |
||
158 | <tr><td valign="top"></td><td valign="top"><em>prescale_opt</em> </td><td>the period with which the timer is triggered </td></tr> |
||
159 | <tr><td valign="top"></td><td valign="top"><em>rtc_func</em> </td><td>the function called when the timer is triggered</td></tr> |
||
160 | </table>
|
||
161 | </dl>
|
||
162 | 241 | bcoltin | <dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__time.html#g5c7f2bf39314463dd5f4913e05ca991d" title="Get the value of the realtime clock.">rtc_get</a>, <a class="el" href="group__time.html#g83ae542199d1c0e964aff89537d686a3" title="Reset the counter of the realtime clock.">rtc_reset</a> </dd></dl> |
163 | |||
164 | </div>
|
||
165 | </div><p> |
||
166 | <a class="anchor" name="g83ae542199d1c0e964aff89537d686a3"></a><!-- doxytag: member="time.c::rtc_reset" ref="g83ae542199d1c0e964aff89537d686a3" args="(void)" --> |
||
167 | <div class="memitem"> |
||
168 | <div class="memproto"> |
||
169 | <table class="memname"> |
||
170 | 41 | bcoltin | <tr>
|
171 | 241 | bcoltin | <td class="memname">void rtc_reset </td> |
172 | <td>(</td> |
||
173 | <td class="paramtype">void </td> |
||
174 | <td class="paramname"> </td> |
||
175 | <td> ) </td> |
||
176 | <td width="100%"></td> |
||
177 | 41 | bcoltin | </tr>
|
178 | </table>
|
||
179 | 241 | bcoltin | </div>
|
180 | <div class="memdoc"> |
||
181 | 41 | bcoltin | |
182 | <p>
|
||
183 | Reset the counter of the realtime clock. |
||
184 | <p>
|
||
185 | Resets the real time clock counter to 0.<p>
|
||
186 | 241 | bcoltin | <dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__time.html#g4b8a034dd8e994f4a1af612806f7c553" title="Enable the realtime clock.">rtc_init</a>, <a class="el" href="group__time.html#g5c7f2bf39314463dd5f4913e05ca991d" title="Get the value of the realtime clock.">rtc_get</a> </dd></dl> |
187 | |||
188 | </div>
|
||
189 | </div><p> |
||
190 | 1145 | deffi | </div>
|
191 | 1371 | chihsiuh | <hr size="1"><address style="text-align: right;"><small>Generated on Wed Sep 2 23:20:09 2009 for libdragonfly by |
192 | 41 | bcoltin | <a href="http://www.doxygen.org/index.html"> |
193 | 1145 | deffi | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address> |
194 | 41 | bcoltin | </body>
|
195 | </html> |