2 * Copyright Droids Corporation, Microb Technology, Eirbot (2006)
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: timer_conf_check.c,v 1.1.2.4 2009-01-30 20:18:36 zer0 Exp $
22 #include <aversive/timers.h>
25 #include <timer_definitions.h>
26 #include <timer_prescaler.h>
28 #include <timer_config.h>
31 #if defined TIMER0_ENABLED && ! defined TIMER0_AVAILABLE
32 #error This arch has no TIMER0
35 #if defined TIMER1_ENABLED && ! defined TIMER1_AVAILABLE
36 #error This arch has no TIMER1
39 #if defined TIMER2_ENABLED && ! defined TIMER2_AVAILABLE
40 #error This arch has no TIMER2
43 #if defined TIMER3_ENABLED && ! defined TIMER3_AVAILABLE
44 #error This arch has no TIMER3
47 #if defined TIMER4_ENABLED && ! defined TIMER4_AVAILABLE
48 #error This arch has no TIMER4
51 #if defined TIMER5_ENABLED && ! defined TIMER5_AVAILABLE
52 #error This arch has no TIMER5
56 #if defined TIMER0_ENABLED
58 #if defined TIMER0_PRESCALER_REG_0 && TIMER0_PRESCALER_REG_0 == TIMER0_PRESCALER_DIV
59 #define TIMER0_CONF_OK
62 #if defined TIMER0_PRESCALER_REG_1 && TIMER0_PRESCALER_REG_1 == TIMER0_PRESCALER_DIV
63 #define TIMER0_CONF_OK
66 #if defined TIMER0_PRESCALER_REG_2 && TIMER0_PRESCALER_REG_2 == TIMER0_PRESCALER_DIV
67 #define TIMER0_CONF_OK
70 #if defined TIMER0_PRESCALER_REG_3 && TIMER0_PRESCALER_REG_3 == TIMER0_PRESCALER_DIV
71 #define TIMER0_CONF_OK
74 #if defined TIMER0_PRESCALER_REG_4 && TIMER0_PRESCALER_REG_4 == TIMER0_PRESCALER_DIV
75 #define TIMER0_CONF_OK
78 #if defined TIMER0_PRESCALER_REG_5 && TIMER0_PRESCALER_REG_5 == TIMER0_PRESCALER_DIV
79 #define TIMER0_CONF_OK
82 #if defined TIMER0_PRESCALER_REG_6 && TIMER0_PRESCALER_REG_6 == TIMER0_PRESCALER_DIV
83 #define TIMER0_CONF_OK
86 #if defined TIMER0_PRESCALER_REG_7 && TIMER0_PRESCALER_REG_7 == TIMER0_PRESCALER_DIV
87 #define TIMER0_CONF_OK
90 #if defined TIMER0_PRESCALER_REG_8 && TIMER0_PRESCALER_REG_8 == TIMER0_PRESCALER_DIV
91 #define TIMER0_CONF_OK
94 #if defined TIMER0_PRESCALER_REG_9 && TIMER0_PRESCALER_REG_9 == TIMER0_PRESCALER_DIV
95 #define TIMER0_CONF_OK
98 #if defined TIMER0_PRESCALER_REG_10 && TIMER0_PRESCALER_REG_10 == TIMER0_PRESCALER_DIV
99 #define TIMER0_CONF_OK
102 #if defined TIMER0_PRESCALER_REG_11 && TIMER0_PRESCALER_REG_11 == TIMER0_PRESCALER_DIV
103 #define TIMER0_CONF_OK
106 #if defined TIMER0_PRESCALER_REG_12 && TIMER0_PRESCALER_REG_12 == TIMER0_PRESCALER_DIV
107 #define TIMER0_CONF_OK
110 #if defined TIMER0_PRESCALER_REG_13 && TIMER0_PRESCALER_REG_13 == TIMER0_PRESCALER_DIV
111 #define TIMER0_CONF_OK
114 #if defined TIMER0_PRESCALER_REG_14 && TIMER0_PRESCALER_REG_14 == TIMER0_PRESCALER_DIV
115 #define TIMER0_CONF_OK
118 #if defined TIMER0_PRESCALER_REG_15 && TIMER0_PRESCALER_REG_15 == TIMER0_PRESCALER_DIV
119 #define TIMER0_CONF_OK
122 #ifndef TIMER0_CONF_OK
123 #error TIMER0 has a bad prescaler value
130 #if defined TIMER1_ENABLED
132 #if defined TIMER1_PRESCALER_REG_0 && TIMER1_PRESCALER_REG_0 == TIMER1_PRESCALER_DIV
133 #define TIMER1_CONF_OK
136 #if defined TIMER1_PRESCALER_REG_1 && TIMER1_PRESCALER_REG_1 == TIMER1_PRESCALER_DIV
137 #define TIMER1_CONF_OK
140 #if defined TIMER1_PRESCALER_REG_2 && TIMER1_PRESCALER_REG_2 == TIMER1_PRESCALER_DIV
141 #define TIMER1_CONF_OK
144 #if defined TIMER1_PRESCALER_REG_3 && TIMER1_PRESCALER_REG_3 == TIMER1_PRESCALER_DIV
145 #define TIMER1_CONF_OK
148 #if defined TIMER1_PRESCALER_REG_4 && TIMER1_PRESCALER_REG_4 == TIMER1_PRESCALER_DIV
149 #define TIMER1_CONF_OK
152 #if defined TIMER1_PRESCALER_REG_5 && TIMER1_PRESCALER_REG_5 == TIMER1_PRESCALER_DIV
153 #define TIMER1_CONF_OK
156 #if defined TIMER1_PRESCALER_REG_6 && TIMER1_PRESCALER_REG_6 == TIMER1_PRESCALER_DIV
157 #define TIMER1_CONF_OK
160 #if defined TIMER1_PRESCALER_REG_7 && TIMER1_PRESCALER_REG_7 == TIMER1_PRESCALER_DIV
161 #define TIMER1_CONF_OK
164 #if defined TIMER1_PRESCALER_REG_8 && TIMER1_PRESCALER_REG_8 == TIMER1_PRESCALER_DIV
165 #define TIMER1_CONF_OK
168 #if defined TIMER1_PRESCALER_REG_9 && TIMER1_PRESCALER_REG_9 == TIMER1_PRESCALER_DIV
169 #define TIMER1_CONF_OK
172 #if defined TIMER1_PRESCALER_REG_10 && TIMER1_PRESCALER_REG_10 == TIMER1_PRESCALER_DIV
173 #define TIMER1_CONF_OK
176 #if defined TIMER1_PRESCALER_REG_11 && TIMER1_PRESCALER_REG_11 == TIMER1_PRESCALER_DIV
177 #define TIMER1_CONF_OK
180 #if defined TIMER1_PRESCALER_REG_12 && TIMER1_PRESCALER_REG_12 == TIMER1_PRESCALER_DIV
181 #define TIMER1_CONF_OK
184 #if defined TIMER1_PRESCALER_REG_13 && TIMER1_PRESCALER_REG_13 == TIMER1_PRESCALER_DIV
185 #define TIMER1_CONF_OK
188 #if defined TIMER1_PRESCALER_REG_14 && TIMER1_PRESCALER_REG_14 == TIMER1_PRESCALER_DIV
189 #define TIMER1_CONF_OK
192 #if defined TIMER1_PRESCALER_REG_15 && TIMER1_PRESCALER_REG_15 == TIMER1_PRESCALER_DIV
193 #define TIMER1_CONF_OK
196 #ifndef TIMER1_CONF_OK
197 #error TIMER1 has a bad prescaler value
203 #if defined TIMER2_ENABLED
205 #if defined TIMER2_PRESCALER_REG_0 && TIMER2_PRESCALER_REG_0 == TIMER2_PRESCALER_DIV
206 #define TIMER2_CONF_OK
209 #if defined TIMER2_PRESCALER_REG_1 && TIMER2_PRESCALER_REG_1 == TIMER2_PRESCALER_DIV
210 #define TIMER2_CONF_OK
213 #if defined TIMER2_PRESCALER_REG_2 && TIMER2_PRESCALER_REG_2 == TIMER2_PRESCALER_DIV
214 #define TIMER2_CONF_OK
217 #if defined TIMER2_PRESCALER_REG_3 && TIMER2_PRESCALER_REG_3 == TIMER2_PRESCALER_DIV
218 #define TIMER2_CONF_OK
221 #if defined TIMER2_PRESCALER_REG_4 && TIMER2_PRESCALER_REG_4 == TIMER2_PRESCALER_DIV
222 #define TIMER2_CONF_OK
225 #if defined TIMER2_PRESCALER_REG_5 && TIMER2_PRESCALER_REG_5 == TIMER2_PRESCALER_DIV
226 #define TIMER2_CONF_OK
229 #if defined TIMER2_PRESCALER_REG_6 && TIMER2_PRESCALER_REG_6 == TIMER2_PRESCALER_DIV
230 #define TIMER2_CONF_OK
233 #if defined TIMER2_PRESCALER_REG_7 && TIMER2_PRESCALER_REG_7 == TIMER2_PRESCALER_DIV
234 #define TIMER2_CONF_OK
237 #if defined TIMER2_PRESCALER_REG_8 && TIMER2_PRESCALER_REG_8 == TIMER2_PRESCALER_DIV
238 #define TIMER2_CONF_OK
241 #if defined TIMER2_PRESCALER_REG_9 && TIMER2_PRESCALER_REG_9 == TIMER2_PRESCALER_DIV
242 #define TIMER2_CONF_OK
245 #if defined TIMER2_PRESCALER_REG_10 && TIMER2_PRESCALER_REG_10 == TIMER2_PRESCALER_DIV
246 #define TIMER2_CONF_OK
249 #if defined TIMER2_PRESCALER_REG_11 && TIMER2_PRESCALER_REG_11 == TIMER2_PRESCALER_DIV
250 #define TIMER2_CONF_OK
253 #if defined TIMER2_PRESCALER_REG_12 && TIMER2_PRESCALER_REG_12 == TIMER2_PRESCALER_DIV
254 #define TIMER2_CONF_OK
257 #if defined TIMER2_PRESCALER_REG_13 && TIMER2_PRESCALER_REG_13 == TIMER2_PRESCALER_DIV
258 #define TIMER2_CONF_OK
261 #if defined TIMER2_PRESCALER_REG_14 && TIMER2_PRESCALER_REG_14 == TIMER2_PRESCALER_DIV
262 #define TIMER2_CONF_OK
265 #if defined TIMER2_PRESCALER_REG_15 && TIMER2_PRESCALER_REG_15 == TIMER2_PRESCALER_DIV
266 #define TIMER2_CONF_OK
269 #ifndef TIMER2_CONF_OK
270 #error TIMER2 has a bad prescaler value
276 #if defined TIMER3_ENABLED
278 #if defined TIMER3_PRESCALER_REG_0 && TIMER3_PRESCALER_REG_0 == TIMER3_PRESCALER_DIV
279 #define TIMER3_CONF_OK
282 #if defined TIMER3_PRESCALER_REG_1 && TIMER3_PRESCALER_REG_1 == TIMER3_PRESCALER_DIV
283 #define TIMER3_CONF_OK
286 #if defined TIMER3_PRESCALER_REG_2 && TIMER3_PRESCALER_REG_2 == TIMER3_PRESCALER_DIV
287 #define TIMER3_CONF_OK
290 #if defined TIMER3_PRESCALER_REG_3 && TIMER3_PRESCALER_REG_3 == TIMER3_PRESCALER_DIV
291 #define TIMER3_CONF_OK
294 #if defined TIMER3_PRESCALER_REG_4 && TIMER3_PRESCALER_REG_4 == TIMER3_PRESCALER_DIV
295 #define TIMER3_CONF_OK
298 #if defined TIMER3_PRESCALER_REG_5 && TIMER3_PRESCALER_REG_5 == TIMER3_PRESCALER_DIV
299 #define TIMER3_CONF_OK
302 #if defined TIMER3_PRESCALER_REG_6 && TIMER3_PRESCALER_REG_6 == TIMER3_PRESCALER_DIV
303 #define TIMER3_CONF_OK
306 #if defined TIMER3_PRESCALER_REG_7 && TIMER3_PRESCALER_REG_7 == TIMER3_PRESCALER_DIV
307 #define TIMER3_CONF_OK
310 #if defined TIMER3_PRESCALER_REG_8 && TIMER3_PRESCALER_REG_8 == TIMER3_PRESCALER_DIV
311 #define TIMER3_CONF_OK
314 #if defined TIMER3_PRESCALER_REG_9 && TIMER3_PRESCALER_REG_9 == TIMER3_PRESCALER_DIV
315 #define TIMER3_CONF_OK
318 #if defined TIMER3_PRESCALER_REG_10 && TIMER3_PRESCALER_REG_10 == TIMER3_PRESCALER_DIV
319 #define TIMER3_CONF_OK
322 #if defined TIMER3_PRESCALER_REG_11 && TIMER3_PRESCALER_REG_11 == TIMER3_PRESCALER_DIV
323 #define TIMER3_CONF_OK
326 #if defined TIMER3_PRESCALER_REG_12 && TIMER3_PRESCALER_REG_12 == TIMER3_PRESCALER_DIV
327 #define TIMER3_CONF_OK
330 #if defined TIMER3_PRESCALER_REG_13 && TIMER3_PRESCALER_REG_13 == TIMER3_PRESCALER_DIV
331 #define TIMER3_CONF_OK
334 #if defined TIMER3_PRESCALER_REG_14 && TIMER3_PRESCALER_REG_14 == TIMER3_PRESCALER_DIV
335 #define TIMER3_CONF_OK
338 #if defined TIMER3_PRESCALER_REG_15 && TIMER3_PRESCALER_REG_15 == TIMER3_PRESCALER_DIV
339 #define TIMER3_CONF_OK
342 #ifndef TIMER3_CONF_OK
343 #error TIMER3 has a bad prescaler value
348 #if defined TIMER4_ENABLED
350 #if defined TIMER4_PRESCALER_REG_0 && TIMER4_PRESCALER_REG_0 == TIMER4_PRESCALER_DIV
351 #define TIMER4_CONF_OK
354 #if defined TIMER4_PRESCALER_REG_1 && TIMER4_PRESCALER_REG_1 == TIMER4_PRESCALER_DIV
355 #define TIMER4_CONF_OK
358 #if defined TIMER4_PRESCALER_REG_2 && TIMER4_PRESCALER_REG_2 == TIMER4_PRESCALER_DIV
359 #define TIMER4_CONF_OK
362 #if defined TIMER4_PRESCALER_REG_3 && TIMER4_PRESCALER_REG_3 == TIMER4_PRESCALER_DIV
363 #define TIMER4_CONF_OK
366 #if defined TIMER4_PRESCALER_REG_4 && TIMER4_PRESCALER_REG_4 == TIMER4_PRESCALER_DIV
367 #define TIMER4_CONF_OK
370 #if defined TIMER4_PRESCALER_REG_5 && TIMER4_PRESCALER_REG_5 == TIMER4_PRESCALER_DIV
371 #define TIMER4_CONF_OK
374 #if defined TIMER4_PRESCALER_REG_6 && TIMER4_PRESCALER_REG_6 == TIMER4_PRESCALER_DIV
375 #define TIMER4_CONF_OK
378 #if defined TIMER4_PRESCALER_REG_7 && TIMER4_PRESCALER_REG_7 == TIMER4_PRESCALER_DIV
379 #define TIMER4_CONF_OK
382 #if defined TIMER4_PRESCALER_REG_8 && TIMER4_PRESCALER_REG_8 == TIMER4_PRESCALER_DIV
383 #define TIMER4_CONF_OK
386 #if defined TIMER4_PRESCALER_REG_9 && TIMER4_PRESCALER_REG_9 == TIMER4_PRESCALER_DIV
387 #define TIMER4_CONF_OK
390 #if defined TIMER4_PRESCALER_REG_10 && TIMER4_PRESCALER_REG_10 == TIMER4_PRESCALER_DIV
391 #define TIMER4_CONF_OK
394 #if defined TIMER4_PRESCALER_REG_11 && TIMER4_PRESCALER_REG_11 == TIMER4_PRESCALER_DIV
395 #define TIMER4_CONF_OK
398 #if defined TIMER4_PRESCALER_REG_12 && TIMER4_PRESCALER_REG_12 == TIMER4_PRESCALER_DIV
399 #define TIMER4_CONF_OK
402 #if defined TIMER4_PRESCALER_REG_13 && TIMER4_PRESCALER_REG_13 == TIMER4_PRESCALER_DIV
403 #define TIMER4_CONF_OK
406 #if defined TIMER4_PRESCALER_REG_14 && TIMER4_PRESCALER_REG_14 == TIMER4_PRESCALER_DIV
407 #define TIMER4_CONF_OK
410 #if defined TIMER4_PRESCALER_REG_15 && TIMER4_PRESCALER_REG_15 == TIMER4_PRESCALER_DIV
411 #define TIMER4_CONF_OK
414 #ifndef TIMER4_CONF_OK
415 #error TIMER4 has a bad prescaler value
420 #if defined TIMER5_ENABLED
422 #if defined TIMER5_PRESCALER_REG_0 && TIMER5_PRESCALER_REG_0 == TIMER5_PRESCALER_DIV
423 #define TIMER5_CONF_OK
426 #if defined TIMER5_PRESCALER_REG_1 && TIMER5_PRESCALER_REG_1 == TIMER5_PRESCALER_DIV
427 #define TIMER5_CONF_OK
430 #if defined TIMER5_PRESCALER_REG_2 && TIMER5_PRESCALER_REG_2 == TIMER5_PRESCALER_DIV
431 #define TIMER5_CONF_OK
434 #if defined TIMER5_PRESCALER_REG_3 && TIMER5_PRESCALER_REG_3 == TIMER5_PRESCALER_DIV
435 #define TIMER5_CONF_OK
438 #if defined TIMER5_PRESCALER_REG_4 && TIMER5_PRESCALER_REG_4 == TIMER5_PRESCALER_DIV
439 #define TIMER5_CONF_OK
442 #if defined TIMER5_PRESCALER_REG_5 && TIMER5_PRESCALER_REG_5 == TIMER5_PRESCALER_DIV
443 #define TIMER5_CONF_OK
446 #if defined TIMER5_PRESCALER_REG_6 && TIMER5_PRESCALER_REG_6 == TIMER5_PRESCALER_DIV
447 #define TIMER5_CONF_OK
450 #if defined TIMER5_PRESCALER_REG_7 && TIMER5_PRESCALER_REG_7 == TIMER5_PRESCALER_DIV
451 #define TIMER5_CONF_OK
454 #if defined TIMER5_PRESCALER_REG_8 && TIMER5_PRESCALER_REG_8 == TIMER5_PRESCALER_DIV
455 #define TIMER5_CONF_OK
458 #if defined TIMER5_PRESCALER_REG_9 && TIMER5_PRESCALER_REG_9 == TIMER5_PRESCALER_DIV
459 #define TIMER5_CONF_OK
462 #if defined TIMER5_PRESCALER_REG_10 && TIMER5_PRESCALER_REG_10 == TIMER5_PRESCALER_DIV
463 #define TIMER5_CONF_OK
466 #if defined TIMER5_PRESCALER_REG_11 && TIMER5_PRESCALER_REG_11 == TIMER5_PRESCALER_DIV
467 #define TIMER5_CONF_OK
470 #if defined TIMER5_PRESCALER_REG_12 && TIMER5_PRESCALER_REG_12 == TIMER5_PRESCALER_DIV
471 #define TIMER5_CONF_OK
474 #if defined TIMER5_PRESCALER_REG_13 && TIMER5_PRESCALER_REG_13 == TIMER5_PRESCALER_DIV
475 #define TIMER5_CONF_OK
478 #if defined TIMER5_PRESCALER_REG_14 && TIMER5_PRESCALER_REG_14 == TIMER5_PRESCALER_DIV
479 #define TIMER5_CONF_OK
482 #if defined TIMER5_PRESCALER_REG_15 && TIMER5_PRESCALER_REG_15 == TIMER5_PRESCALER_DIV
483 #define TIMER5_CONF_OK
486 #ifndef TIMER5_CONF_OK
487 #error TIMER5 has a bad prescaler value