#if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__) || defined (__AVR_ATmega32U4__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__)
/* Timer1 for the masses */
// busy waiting for compare match interrupt flag
#if defined (__AVR_ATmega48__) || \
defined(__AVR_ATmega48P__)|| \
defined(__AVR_ATmega88__)|| \
defined(__AVR_ATmega88P__)|| \
defined(__AVR_ATmega168__)|| \
defined(__AVR_ATmega168P__)|| \
defined(__AVR_ATmega328__)|| \
defined(__AVR_ATmega328P__)|| \
defined(__AVR_ATmega164__)|| \
defined(__AVR_ATmega164P__)|| \
defined(__AVR_ATmega324__)|| \
defined(__AVR_ATmega324P__)|| \
defined(__AVR_ATmega644__)|| \
defined(__AVR_ATmega644P__)|| \
defined(__AVR_ATmega1284__)|| \
defined(__AVR_ATmega1284P__)|| \
defined(__AVR_ATmega32U4__)|| \
defined(__AVR_ATmega1280__)|| \
defined(__AVR_ATmega2560__)
# ifndef USER_TIMER0_FOR_WAIT
/* Timer1 for the masses */
while(!(TIFR1&_BV(OCF1A)));// wait for compare match flag
TIFR1|=_BV(OCF1A);//reset flag
/* Timer0 for e.g. Arduino/LoL Shield */
TIFR1|=_BV(OCF1A);// reset that flag
# else
/* Timer0 for e.g. Arduino/LoL Shield */
while(!(TIFR0&_BV(OCF0A)));// wait for compare match flag
TIFR0|=_BV(OCF0A);//reset flag
TIFR0|=_BV(OCF0A);//reset that flag
# endif
#else
while(!(TIFR&(1<<OCF1A)));//wait for compare match flag
TIFR=(1<<OCF1A);//reset flag
# ifndef USER_TIMER0_FOR_WAIT
/* Timer1 for the masses */
while(!(TIFR&_BV(OCF1A)));// wait for compare match flag
TIFR|=_BV(OCF1A);// reset that flag
# elif !defined(__AVR_ATmega8__)
/* Timer0 */
while(!(TIFR&_BV(OCF0)));// wait for compare match flag
TIFR|=_BV(OCF0);// reset that flag
# else
# error Timer0 for wait() is not supported on ATmega8