/********************************************************************/ /* XW310 API Functions for uPAC-5000 Series */ /* */ /* [Mar 29, 2012] by Liam version 1.00 */ /********************************************************************/ #ifndef __XW310_H #define __XW310_H #ifdef __cplusplus extern "C" { #endif int XW310_Init(void); /* Initiate the XW310 library Return On success, returns zero On error, returns a non-zero value Bit0: 1 => Read A/D Gain falure Bit1: 1 => Read A/D Offset falure Bit2: 1 => Read D/A Gain falure (channel 0) Bit3: 1 => Read D/A Offset falure (channel 0) Bit4: 1 => Read D/A Gain falure (channel 1) Bit5: 1 => Read D/A Offset falure (channel 1) Bit7: 1 => XW310 cannot be found */ unsigned XW310_GetLibVersion(void); /* Get the version number of XW310 library Return It always returns a non-zero value to indicate the current version 0x100 indicates the version is 1.00 */ void XW310_GetLibDate(char *date); /* Get the build date of the current version of XW310 library Argument date: Buffer where function writes the string */ float XW310_Read_AD_Gain(void); /* Read the calibration data stored in the EEPROM Return On error, returns 10.0 if there was no setting in the EEPROM */ float XW310_Read_AD_Offset(void); /* Read the calibration data stored in the EEPROM Return On error, returns 10.0 if there was no setting in the EEPROM */ float XW310_Read_DA_Gain(int channel); /* Read the calibration data stored in the EEPROM Argument channel: Channel number, represented as 0 and 1 Return On error, returns 10.0 if there was no setting in the EEPROM */ float XW310_Read_DA_Offset(int channel); /* Read the calibration data stored in the EEPROM Argument channel: Channel number, represented as 0 and 1 Return On error, returns 10.0 if there was no setting in the EEPROM */ void XW310_SetDelay(unsigned delay); /* Specify a short time delay, in milliseconds, to wait before obtaining the raw data from the analog to digital converter chip Argument delay: Delay time, represented as a integer in the range [0, 1000] (unit: 0.01 ms) */ unsigned XW310_GetDelay(void); /* Read back the time delay */ float XW310_AnalogIn(int channel); /* Read the current input voltage, represented as a float in the range [-10, 10] Argument channel: Channel number, represented as 0, 1, 2 and 3 Return Return the voltage supplied by a voltage source */ void XW310_AnalogInSetChannel(int channel); /* Specify the input channel number before the call of XW310_AnalogInHex() Argument channel: Channel number, represented as 0, 1, 2, and 3 */ int XW310_AnalogInHex(void); /* Read a raw data from the analog to digital converter chip Return A raw data obtained from the analog to digital converter chip, represented as a hex value in the range [0, 0xFFF] */ float XW310_AnalogInHexToFloat(int value); /* Convert a raw data reading into a voltage reading Argument value: The raw data returned by XW310_AnalogInHex() Return Return the voltage, represented as a float */ void XW310_AnalogOut(int channel, float value); /* Set the output voltage Argument channel: Channel number, represented as 0 and 1 value: Set the output voltage, represented as a float in the range [-10, 10] */ int XW310_Read_All_DI(void); /* Read the input status of all channels Return All digital inputs are packed as one channel per bit of the return data. Status is indicated as 0=ON (short to GND) and 1=OFF (Open) For example: The status of inputs is shown as the byte value 05 hex, or binary 0000 0101. DI2 is in the sixth bit position from the left, and DI0 is the LSB of this byte. The five remaining high order bits are zero filled. */ int XW310_Read_One_DI(int channel); /* Read the input status of the specified channel Argument channel: Channel number, represented as 0, 1 and 2 Return 0 for ON (short to GND) and 1 for OFF (Open) */ void XW310_Write_All_DO(int value); /* Set the output status for all channels Argument value: All digital outputs are packed as one channel per bit of the writing value */ void XW310_Write_One_DO(int channel, int status); /* Set the output status for the specified channel Argument channel: Channel number, represented as 0, 1 and 2 status: An integer specifying the output value, 0 for OFF and 1 for ON */ int XW310_Read_All_DO(void); /* Read back the current status of all channels Return All digital outputs are packed as one channel per bit of the return data. Status is indicated as 1=ON and 0=OFF For example: The status of inputs is shown as the byte value 05 hex, or binary 0000 0101. DO2 is in the sixth bit position from the left, and DO0 is the LSB of this byte. The five remaining high order bits are zero filled. */ int XW310_Read_One_DO(int channel); /* Read back the current status of the specified channel Argument channel: Channel number, represented as 0, 1 and 2 Return An integer representing the output state, 0 for OFF and 1 for ON */ #ifdef __cplusplus } #endif #endif