00001 /* 00002 * Copyright Droids Corporation, Microb Technology, Eirbot (2005) 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Revision : $Id: wait.h,v 1.2 2007-05-24 13:08:44 zer0 Exp $ 00019 * 00020 */ 00021 00027 /**********************************************************/ 00028 00029 #ifndef _AVERSIVE_WAIT_H_ 00030 #define _AVERSIVE_WAIT_H_ 00031 00032 #include <aversive.h> 00033 00034 #ifdef HOST_VERSION 00035 00036 #define wait_3cyc(n) do {} while(0) 00037 #define wait_4cyc(n) do {} while(0) 00038 #define wait_ms(n) do {} while(0) 00039 00040 #else /* HOST_VERSION */ 00041 00042 #if __AVR_LIBC_VERSION__ < 10403UL 00043 #include <avr/delay.h> 00044 #else 00045 #include <util/delay.h> 00046 #endif 00047 00050 #define wait_3cyc(n) _delay_loop_1(n) 00051 00054 #define wait_4cyc(n) _delay_loop_2(n) 00055 00059 static inline void wait_ms(uint16_t n) 00060 { 00061 while ( n -- ) 00062 wait_4cyc(F_CPU/4000); 00063 } 00064 00065 #endif /* else HOST_VERSION */ 00066 00067 #endif /* _AVERSIVE_WAIT_ */