2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
\r
4 * This program is free software; you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation; either version 2 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program; if not, write to the Free Software
\r
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
18 * Revision : $Id: wait.h,v 1.1.2.1 2007-05-23 17:18:09 zer0 Exp $
\r
23 * This file is an interface for wait functions, in order to put the
\r
24 * microcontroller in a loop state.
\r
27 /**********************************************************/
\r
29 #ifndef _AVERSIVE_WAIT_H_
\r
30 #define _AVERSIVE_WAIT_H_
\r
32 #include <aversive.h>
\r
38 #define wait_3cyc(n) do { volatile int a = 0; a++; } while (0)
\r
39 #define wait_4cyc(n) do { volatile int a = 0; a++; } while (0)
\r
40 #define wait_ms(n) host_wait_ms(n)
\r
42 #else /* HOST_VERSION */
\r
44 #if __AVR_LIBC_VERSION__ < 10403UL
\r
45 #include <avr/delay.h>
\r
47 #include <util/delay.h>
\r
50 /** wait n "3 cycles time"
\r
52 #define wait_3cyc(n) _delay_loop_1(n)
\r
54 /** wait n "4 cycles time"
\r
56 #define wait_4cyc(n) _delay_loop_2(n)
\r
58 /** wait n milliseconds
\r
61 static inline void wait_ms(uint16_t n)
\r
64 wait_4cyc(F_CPU/4000);
\r
67 #endif /* else HOST_VERSION */
\r
69 #endif /* _AVERSIVE_WAIT_ */
\r