//I-8024U, I-8028U, I-9028U
#define NO_ERROR		0
#define ID_ERROR 		-1
#define FRAM_ERROR 		-2
#define MODULE_STATUS_ERROR 	-3
#define WDTTIMEOUT    		-7


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


	#define	i9028U_Init			i8028U_Init	
	#define i9028U_GetFirmwareVersion	i8028U_GetFirmwareVersion	
	#define i9028U_GetLibVersion		i8028U_GetLibVersion
	#define i9028U_ReadAO_GainOffset	i8028U_ReadAO_GainOffset
	#define i9028U_WriteAOHex		i8028U_WriteAOHex
	#define i9028U_WriteAO			i8028U_WriteAO
	#define i9028U_ReadAOHex		i8028U_ReadAOHex  
	#define i9028U_SetPowerOnEnStatus	i8028U_SetPowerOnEnStatus
	#define i9028U_GetPowerOnEnStatus	i8028U_GetPowerOnEnStatus
	#define i9028U_WritePowerOnHex_AO	i8028U_WritePowerOnHex_AO
	#define i9028U_WritePowerOn_AO		i8028U_WritePowerOn_AO
	#define i9028U_WriteSafeHex_AO		i8028U_WriteSafeHex_AO 
	#define i9028U_ReadPowerOnHex_AO	i8028U_ReadPowerOnHex_AO  
	#define i9028U_ReadPowerOn_AO		i8028U_ReadPowerOn_AO
	#define i9028U_WriteSafe_AO		i8028U_WriteSafe_AO
	#define i9028U_ReadSafeHex_AO		i8028U_ReadSafeHex_AO	
	#define i9028U_ReadSafe_AO		i8028U_ReadSafe_AO
	#define i9028U_SetModuleWDTConfig	i8028U_SetModuleWDTConfig
	#define i9028U_GetModuleWDTConfig	i8028U_GetModuleWDTConfig
	#define i9028U_SetModuleWDTStatus	i8028U_SetModuleWDTStatus	
	#define i9028U_ResetModuleWDT		i8028U_ResetModuleWDT
	#define i9028U_RefreshModuleWDT		i8028U_RefreshModuleWDT		
	#define i9028U_GetModuleWDTStatus	i8028U_GetModuleWDTStatus

short i8028U_GetLibVersion(void);
void i8028U_GetLibDate(char libDate[]);
short i8028U_GetFirmwareVersion(int slot, short* ver);
short i8028U_Init(int slot);

// get the module last output status
// 1 module startup as power on value, and does not have any output 
// 2 module startup as safe value, and does not have any output 
// 3 module startup as normal output
short i8028U_GetModuleLastOutputStatus(int slot);


// basic AO output API
short i8028U_WriteAO(int slot, int ch, short gain, float aoData);
void i8028U_ReadAO(int slot, int ch, short *gain,  float *aoData);
short i8028U_WriteAOHex(int slot, int ch, short gain, short aoHex);
void i8028U_ReadAOHex(int slot, int ch, short *gain,  short *aoHex);


// Power on value API
// Power on enable status 1: 
//		Module enter power on value state when PAC reset the power. 
//		Module clear all output when program restart. (if want to keep the last output status, set power on enable status = 2 )
// Power on enable status 2:
//		Module enter last output value state when PAC reset the power or restart the program. 
short i8028U_SetPowerOnEnStatus(int slot, short status);
short i8028U_GetPowerOnEnStatus(int slot, short* status);

short i8028U_WritePowerOn_AO(int slot, int ch ,short gain, float aoData);
void i8028U_ReadPowerOn_AO(int slot, int ch ,short *gain, float *aoData);
short i8028U_WritePowerOnHex_AO(int slot, int ch ,short gain, short aoHex);
void i8028U_ReadPowerOnHex_AO(int slot, int ch ,short *gain, short *aoHex);

// Safe value and module watchdog configuration
// Step 1: To Set module Safe Value with pac_i8028U_WriteSafe_AO API
// Step 2: To Enable module watchdog with pac_i8028U_SetModuleWDTConfig
// Step 3: Call pac_i8028U_RefreshModuleWDT to reset the WDT timer in timer ISR or main loop
// Step 4: Get the WDT status with pac_i8028U_GetModuleWDTStatus in timer ISR or main loop
// Step 5: Call pac_i8028U_ResetModuleWDT to reset the WDT timeout status

//Note 1: Avoid System hang up and enter dead lock status, 
// 		use pac_i8028U_SetModuleWDTConfig with pac_EnableWatchDog(osWDT, wdtTimeout + lagTime); (osWDT = 1, wdtTimeout is module WDT timeout value)
// 		when System hang up and enter dead lock status, module will enter safe value first, and after lag time, OS will restart by pac_EnableWatchDog
// 		when use pac_EnableWatchDog, program must call pac_RefreshWatchDog(osWDT); in timer ISR or main loop to avoid OS reset.
short i8028U_WriteSafe_AO(int slot, int ch ,short gain, float aoData);
void i8028U_ReadSafe_AO(int slot, int ch ,short *gain, float *aoData);
short i8028U_WriteSafeHex_AO(int slot, int ch ,short gain, short aoHex);
void i8028U_ReadSafeHex_AO(int slot, int ch ,short *gain, short *aoHex);

short i8028U_SetModuleWDTConfig(int slot, short enStatus, unsigned long wdtTimeout,int ifWDT_Overwrite);
short i8028U_GetModuleWDTConfig(int slot, short* enStatus, unsigned long *wdtTimeout,int *ifWDT_Overwrite);

void i8028U_RefreshModuleWDT(int slot); 

short i8028U_GetModuleWDTStatus(int slot); 
void i8028U_ResetModuleWDT(int slot); 

// for calibration
void i8028U_ReadAO_GainOffset(int slot,int ch,short gain,unsigned short *gVal, short *oVal);


#ifdef	__cplusplus
}
#endif	/*	__cplusplus	*/
