/********************************
	i8093 Error Code definition	
*******************************/

#define OK 		 				0	
#define ID_ERROR 				-1
#define SLOT_OUT_RANGE			-2
#define CHANNEL_OUT_RANGE		-3
#define MODE_ERROR				-4

     

	
#ifdef	__cplusplus  // for C++ compile use
extern "C" {
#endif	/*	__cplusplus	*/

/********************************
	i8093_GetFirmwareVersion can get the Firmware version 
	1. slot: 0 ~ 7
	
	return Lattice version	
*******************************/
 
short i8093_GetFirmwareVersion(int slot);


/********************************
	i8093_GetLibVersion can get the version i8093 Lib
	return Lib version	
*******************************/

	

short i8093_GetLibVersion(void);
          
          
/********************************
	i8093_GetLibDate can get the builded date of i8093 Lib
	1.*LibDate: library date	
*******************************/  

	

void i8093_GetLibDate(char *LibDate);


/********************************
	i8093_Init can initialize i-8093
	1. slot: 0 ~ 7 
	
	return value: please refer to i8093 Error Code definition		
*******************************/

	

int i8093_Init(int slot);


/********************************
	i8093_SetMode can set encoder counting mode
	1. slot: 0 ~ 7
	2. ch: 0 ~ 2
	3. Mode value:
	   1 ==> CW/CCW counting mode
	   2 ==> Pulse/Direction counting mode
	   3 ==> Quadrant counting mode
	return value: please refer to i8093 Error Code definition
*******************************/

	

int i8093_SetMode(int slot, int ch, int Mode);


/********************************
	i8093_GetMode can get encoder counting mode
	1. slot: 0 ~ 7
	2. ch: 0 ~ 2
	3. *Mode value:
	   *Mode=1 ==> CW/CCW counting mode
	   *Mode=2 ==> Pulse/Direction counting mode
	   *Mode=3 ==> Quadrant counting mode

	return value: please refer to i8093 Error Code definition
*******************************/

	

int i8093_GetMode(int slot, int ch, int* Mode);


/********************************
	i8093_GetLineStatus can read A/B/Z status
	1. slot: 0 ~ 7
	2. ch: 0 ~ 2
	3. *A_Status: 0/1
	4. *B_Status: 0/1
  	5. *C_Status: 0/1 
  	
	return value: please refer to i8093 Error Code definition
*******************************/

	

int i8093_GetLineStatus(int slot, int ch, int* A_Status,int* B_Status,int* C_Status);


/********************************
	i8093_GetIndex can read Index(Z) value
	1. slot: 0 ~ 7
	2. ch: 0 ~ 2
	3. *index: 0/1

	return value: please refer to i8093 Error Code definition	
*******************************/

	

int i8093_GetIndex(int slot, int ch,int* index);


/********************************
	i8093_SetXOR can set XOR value 
	1. slot: 0 ~ 7
	2. ch: 0 ~ 2
	3. Xor: 0/1
	
	return value: please refer to i8093 Error Code definition
*******************************/

	

int i8093_SetXOR(int slot, int ch, int Xor);


/********************************
	i8093_GetXOR can get XOR value
	1. slot: 0 ~ 7
	2. ch: 0 ~ 2
	3. *Xor: 0/1
	
	return value: please refer to i8093 Error Code definition
*******************************/

	

int i8093_GetXOR(int slot, int ch, int* Xor);


/********************************
	i8093_Read32BitEncoder can read 32-bit counter value
	1. slot: 0 ~ 7
	2. ch: 0 ~ 2
	3. *EnCode32: 32-bit counter value
	
	return value: please refer to i8093 Error Code definition
*******************************/

	

int i8093_Read32BitEncoder(int slot,int ch, long* EnCode32);


/********************************
	i8093_ResetEncoder can clear A/B/Z and 32 bit counter
	1. slot 0 ~ 7
	2. ch 0 ~ 2
*******************************/

	

int i8093_ResetEncoder(int slot, int ch);


#ifdef	__cplusplus
}
#endif	/*	__cplusplus	*/
