#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 */ short i8028UW_Init(int slot); short i8028UW_GetLibVersion(void); void i8028UW_GetLibDate(char libDate[]); short i8028UW_GetFirmwareVersion(int slot, short* ver); // 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 i8028UW_GetModuleLastOutputStatus(int slot); // basic AO output API short i8028UW_WriteAO(int slot, int ch, short gain, float aoData); void i8028UW_ReadAO(int slot, int ch, short *gain, float *aoData); short i8028UW_WriteAOHex(int slot, int ch, short gain, short aoHex); void i8028UW_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 i8028UW_SetPowerOnEnStatus(int slot, short status); short i8028UW_GetPowerOnEnStatus(int slot, short* status); short i8028UW_WritePowerOn_AO(int slot, int ch ,short gain, float aoData); void i8028UW_ReadPowerOn_AO(int slot, int ch ,short *gain, float *aoData); short i8028UW_WritePowerOnHex_AO(int slot, int ch ,short gain, short aoHex); void i8028UW_ReadPowerOnHex_AO(int slot, int ch ,short *gain, short *aoHex); // Safe value and module watchdog configuration // Step 1: To Set module Safe Value with i8028UW_WriteSafe_AO API // Step 2: To Enable module watchdog with i8028UW_SetModuleWDTConfig // Step 3: Call i8028UW_RefreshModuleWDT to reset the WDT timer in timer ISR or main loop // Step 4: Get the WDT status with i8028UW_GetModuleWDTStatus in timer ISR or main loop // Step 5: Call i8028UW_ResetModuleWDT to reset the WDT timeout status //Note 1: Avoid System hang up and enter dead lock status, // use i8028UW_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 i8028UW_WriteSafe_AO(int slot, int ch ,short gain, float aoData); void i8028UW_ReadSafe_AO(int slot, int ch ,short *gain, float *aoData); short i8028UW_WriteSafeHex_AO(int slot, int ch ,short gain, short aoHex); void i8028UW_ReadSafeHex_AO(int slot, int ch ,short *gain, short *aoHex); short i8028UW_SetModuleWDTConfig(int slot, short enStatus, unsigned long wdtTimeout,int ifWDT_Overwrite); short i8028UW_GetModuleWDTConfig(int slot, short* enStatus, unsigned long *wdtTimeout,int *ifWDT_Overwrite); void i8028UW_RefreshModuleWDT(int slot); short i8028UW_GetModuleWDTStatus(int slot); void i8028UW_ResetModuleWDT(int slot); // When Enable Module WDT function, it must call i8028UW_UnInstallWDT before program exit. // If Enable Module WDT function and does not call i8028UW_UnInstallWDT before program exit, it will hang up when program restart. //void i8028UW_UnInstallWDT(int slot); // for calibration void i8028UW_ReadAO_GainOffset(int slot,int ch,short gain,unsigned short *gVal, short *oVal); #ifdef __cplusplus } #endif /* __cplusplus */