#ifndef _MOTION
#define _MOTION

//舊式U16版本停用,改用新式I32版本
//#define SOFT_VERSION     10901  // Y=1 means 2007 (YMMDD), Y=2 means 2008, Y=3 means 2009, Y=1 means 2010

//新式I32版本
#define SOFT_VERSION_EX 100903  // YYMMDD 2010/09/03

//#define REG_LOG
//#define HOME_LOG
//#define _DEBUGLOG

// =========== Choose Board Interface ================
#define _PCI		// PCI Bus
//#define _MPC		// ISA Bus

// =========== Choose OS =================
#define _MYWIN32
//#define _MSDOS
//#define _MYLINUX
//#define _MYWINCE
//#define _MYRTX
//#define _MYHYPERK

// =========== Choose Compiler =============
#define _MSC
//#define _BC31
//#define _MYWATCOMC
//#define _PLATFORMBUILDER

// =========== Choose IO method =============
#define _IO_HAL
//#define _IO_DIRECT

/////////////////////////////////////////////////////////////////////

#if defined(_MYWIN32)
	#if defined( _MSC )
		#define FNTYPE PASCAL
		#define _SLEEP Sleep

		#if defined( _IO_HAL )

			void Win32_outb(unsigned short  address, unsigned char  RegSelCmd);
			void Win32_outw(unsigned short  address, unsigned short  RegSelCmd);
			void Win32_outl(unsigned short  address, unsigned long  RegSelCmd);
			unsigned char  Win32_inb(unsigned short  address);
			unsigned short Win32_inw(unsigned short  address);
			unsigned long  Win32_inl(unsigned short  address);

			#define _OUTPORTB(s,t) Win32_outb(s,t)
			#define _OUTPORTW(s,t) Win32_outw(s,t)
			#define _OUTPORTD(s,t) Win32_outl(s,t)
			#define _INPORTB(s) Win32_inb(s)
			#define _INPORTW(s) Win32_inw(s)
			#define _INPORTD(s) Win32_inl(s)
		#else
			#define _OUTPORTB _outp
			#define _OUTPORTW _outpw
			#define _OUTPORTD _outpd
			#define _INPORTB _inp
			#define _INPORTW _inpw
			#define _INPORTD _inpd
		#endif

	#endif

#elif defined (_MSDOS)

	#if defined( _BC31 )
	  #define FNTYPE
	  #define _OUTPORTB outportb
	  #define _OUTPORTW outport
	  #define _INPORTB inportb
	  #define _INPORTW inport
	  #define _SLEEP   delay
	#elif defined (_MYWATCOMC)
	  #define _ADLINK
	  #define FNTYPE
	  #define _OUTPORTB outp
	  #define _OUTPORTW outpw
	  #define _INPORTB inp
	  #define _INPORTW inpw
	  #define _SLEEP   delay
	#endif
#elif defined ( _MYLINUX)

  #define FNTYPE
  #define _SLEEP(t) usleep(1000*t)

void Linux_outb(unsigned short address, unsigned short RegSelCmd);
void Linux_outw(unsigned short address, unsigned short RegSelCmd);
void Linux_outl(unsigned short address, unsigned short RegSelCmd);
unsigned short Linux_inb(unsigned short address);
unsigned short Linux_inw(unsigned short address);
unsigned short Linux_inl(unsigned short address);

  #define _OUTPORTB(s,t) Linux_outb(s,t)   //Mark 2006/11/30
  #define _OUTPORTW(s,t) Linux_outw(s,t)   //Mark 2006/11/30
  #define _OUTPORTD(s,t) Linux_outl(s,t)   //Mark 2006/11/30
  #define _INPORTB(s) Linux_inb(s)   //Mark 2006/11/30
  #define _INPORTW(s) Linux_inw(s)   //Mark 2006/11/30
  #define _INPORTD(s) Linux_inl(s)   //Mark 2006/11/30

#elif defined (_MYWINCE )

	#ifdef _PLATFORMBUILDER
	  #define FNTYPE
	  #define _OUTPORTB _outp
	  #define _OUTPORTW _outpw
	  #define _OUTPORTD _outpd
	  #define _INPORTB _inp
	  #define _INPORTW _inpw
	  #define _INPORTD _inpd
	  #define _SLEEP Sleep
	#endif
#elif defined (_MYRTX)

	  #define FNTYPE

	  #define _OUTPORTB RtWritePortUchar
	  #define _OUTPORTW RtWritePortUshort
	  #define _OUTPORTD RtWritePortUlong
	  #define _INPORTB RtReadPortUchar
	  #define _INPORTW RtReadPortUshort
	  #define _INPORTD RtReadPortUlong
	  #define _SLEEP Sleep

#elif defined (_MYHYPERK)

	  #define FNTYPE
	  #define _OUTPORTB hkOutp
	  #define _OUTPORTW hkOutpw
	  #define _OUTPORTD hkOutpd
	  #define _INPORTB hkInp
	  #define _INPORTW hkInpw
	  #define _INPORTD hkInpd
	  #define _SLEEP hkSleep

#endif

#endif
