#define NO_ERROR #define ID_ERROR -1 #define FRAM_ERROR -2 #define MODULE_STATUS_ERROR -3 #define WDTTIMEOUT -7 #ifdef _I8028UW_EXPORTS #define I8028UAPI __declspec(dllexport) #else #define I8028UAPI __declspec(dllimport) #endif #ifdef __cplusplus // for C++ compile use extern "C" { #endif /* __cplusplus */ I8028UAPI short pac_i8028U_Init(int slot); I8028UAPI short pac_i8028U_GetLibVersion(void); I8028UAPI void pac_i8028U_GetLibDate(char libDate[]); I8028UAPI short pac_i8028U_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 I8028UAPI short pac_i8028U_GetModuleLastOutputStatus(int slot); // basic AO output API I8028UAPI short pac_i8028U_WriteAO(int slot, int ch, short gain, float aoData); I8028UAPI void pac_i8028U_ReadAO(int slot, int ch, short *gain, float *aoData); I8028UAPI short pac_i8028U_WriteAOHex(int slot, int ch, short gain, short aoHex); I8028UAPI void pac_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. I8028UAPI short pac_i8028U_SetPowerOnEnStatus(int slot, short status); I8028UAPI short pac_i8028U_GetPowerOnEnStatus(int slot, short* status); I8028UAPI short pac_i8028U_WritePowerOn_AO(int slot, int ch ,short gain, float aoData); I8028UAPI void pac_i8028U_ReadPowerOn_AO(int slot, int ch ,short *gain, float *aoData); I8028UAPI short pac_i8028U_WritePowerOnHex_AO(int slot, int ch ,short gain, short aoHex); I8028UAPI void pac_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. I8028UAPI short pac_i8028U_WriteSafe_AO(int slot, int ch ,short gain, float aoData); I8028UAPI void pac_i8028U_ReadSafe_AO(int slot, int ch ,short *gain, float *aoData); I8028UAPI short pac_i8028U_WriteSafeHex_AO(int slot, int ch ,short gain, short aoHex); I8028UAPI void pac_i8028U_ReadSafeHex_AO(int slot, int ch ,short *gain, short *aoHex); I8028UAPI short pac_i8028U_SetModuleWDTConfig(int slot, short enStatus, unsigned long wdtTimeout,int ifWDT_Overwrite); I8028UAPI short pac_i8028U_GetModuleWDTConfig(int slot, short* enStatus, unsigned long *wdtTimeout,int *ifWDT_Overwrite); I8028UAPI void pac_i8028U_RefreshModuleWDT(int slot); I8028UAPI short pac_i8028U_GetModuleWDTStatus(int slot); I8028UAPI void pac_i8028U_ResetModuleWDT(int slot); // for calibration I8028UAPI void pac_i8028U_ReadAO_GainOffset(int slot,int ch,short gain,unsigned short *gVal, short *oVal); #ifdef __cplusplus } #endif /* __cplusplus */