//
// Wait.h
// 22/12/2004

#ifndef WAIT_H
#define WAIT_H

#include <delays.h>

// Wait macros
// crystal 7.2MHz : 555ns/cycle
#if 0 // 7.2MHz
#define Wait_7us() \
  { Delay10TCYx (1); Delay1TCY(); Nop(); } // 12 cycles

#define Wait_70us() \
{ Delay100TCYx (1); Delay10TCYx(2); Nop();Nop();Nop();Nop();Nop();Nop(); } // 126 cycles

#define Wait_500us() \
{ Delay100TCYx (9); } // 900 cycles

#define Wait_1s() \
{ Delay10KTCYx (165); } // 1650000 cycles ?!

#define Wait_250ms() \
{ Delay10KTCYx (45); } // 450000 cycles

#endif // 7.2MHz

// crystal 3.59 MHz : 1.18us/cycle
#if 0 // 3.59 MHz
#define Wait_7us() \
  { Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); } // 6 cycles

#define Wait_70us() \
{ Delay10TCYx(6); } // 60 cycles

#define Wait_500us() \
{ Delay100TCYx (4); Delay10TCYx(2);} // 420 cycles

#define Wait_1s() \
{ Delay10KTCYx (84); } // 840000 cycles ?!

#endif // 3.59MHz

// crystal 4.0 MHz : 1us/cycle
#if 1 // 4MHz
#define Wait_7us() \
  { Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); } // 7 cycles

#define Wait_70us() \
{ Delay10TCYx(7); } // 70 cycles

#define Wait_500us() \
{ Delay100TCYx (5); } // 500 cycles

#define Wait_1s() \
{ Delay10KTCYx (100); } // 1000000 cycles ?!

#define Wait_250ms() \
{ Delay10KTCYx (25); } // 250000 cycles

#endif // 4MHz
