/** @file apci3200.h

Contains defines and IOCTL commands of the APCI-3200.

@par CREATION
@author Krauth Julien
@date   06.06.05

@par VERSION
@verbatim
$LastChangedRevision$
$LastChangedDate$
@endverbatim

@par COMPILER
@verbatim
Compiler	: gcc
Version	: gcc (GCC) 3.3.6 (Debian 1:3.3.6-5)
kernel	: 2.4.26
@endverbatim

@par UPDATES
@verbatim
Date			:
Author		:
Description	:
@endverbatim

@par LICENCE
@verbatim
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.

ADDI-DATA GmbH
Dieselstrasse 3
D-77833 Ottersweier
Tel: +19(0)7223/9493-0
Fax: +49(0)7223/9493-92
http://www.addi-data-com
info@addi-data.com

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of the License,
or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

You also shoud find the complete LGPL in the LGPL.txt file accompanying
this source code.
@endverbatim
*/


#ifndef __APCI3200_H__
#define __APCI3200_H__


#define APCI3200_DRIVER_VERSION_MAJOR 2026
#define APCI3200_DRIVER_VERSION_MINOR 06
#define APCI3200_DRIVER_VERSION_PATCH 1

#include <apci.h>

#define APCI3200_BOARD_NAME                      "APCI3200"
#define APCI3200_BOARD_VENDOR_ID                 0x15B8
#define APCI3200_BOARD_DEVICE_ID                 0x3000

// timeout while waiting for the hardware, in jiffies
#define APCI3200_TIMEOUT (HZ/10)

/**@def APCI3200_OTHER
* To tell at conversion function what type of values have to be treated.
*/
#define APCI3200_OTHER								0

/**@def APCI3200_SCAN
* To tell at conversion function what type of values have to be treated.
*/
#define APCI3200_SCAN								1

/** SCAN type */
enum
{
	APCI3200_SINGLE_SCAN, 			/**< Only one SCAN is started after calling up the function. */
	APCI3200_DEFINED_SCAN_NUMBER,	/**< A predefined number of SCANs is started after calling up the function. */
	APCI3200_CONTINUOUS_SCAN 	/**< An undefined number of SCANs is started after calling up the function. */
};

/** Type of trigger signal */
enum
{
	APCI3200_FIRST_LOW_EDGE_START_ALL_SCAN=1,
	APCI3200_FIRST_HIGH_EDGE_START_ALL_SCAN,
	APCI3200_FIRST_EDGE_START_ALL_SCAN
};

enum
{
	APCI3200_DISABLE,
	APCI3200_ENABLE
};

//------------------------------------------------------------------------------
/** Sensor class */
enum
{
	ADDIDATA_THERMOCOUPLE=0,
	ADDIDATA_RTD
};

/** Known thermo-couple types */
enum
{
	ADDIDATA_THERMOCOUPLE_TYPE_B=0,
	ADDIDATA_THERMOCOUPLE_TYPE_E,
	ADDIDATA_THERMOCOUPLE_TYPE_J,
	ADDIDATA_THERMOCOUPLE_TYPE_K,
	ADDIDATA_THERMOCOUPLE_TYPE_N,
	ADDIDATA_THERMOCOUPLE_TYPE_R,
	ADDIDATA_THERMOCOUPLE_TYPE_S,
	ADDIDATA_THERMOCOUPLE_TYPE_T
};

/** known RTD type */
enum
{
	ADDIDATA_RTD_TYPE_PT=0,
	ADDIDATA_RTD_TYPE_Ni
};

//------------------------------------------------------------------------------
/** Diagnostic mode */
enum
{
	APCI3200_DIAGNOSTIC_NONE=0,
	APCI3200_DIAGNOSTIC_SHORT_CIRCUIT,
	APCI3200_DIAGNOSTIC_OPEN_CONNECTION
};

//------------------------------------------------------------------------------
/** delay mode */
enum
{
	APCI3200_DELAY_NOT_USED=0,	/**< Delay mode is not used. */
	APCI3200_DELAY_MODE1_USED 	/**< The delay between two SCANs is used. The conversion is started at once, and the delay is used after the first SCAN */
};

enum
{
	APCI3200_UNIT_MS=2, /**< value is in milliseconds. */
	APCI3200_UNIT_S=3	/**< value is in seconds. */
};

/** polarity */
enum
{
	APCI3200_POLARITY_UNIPOLAR=1,	/**< 0 to 2.5 V. Valid only with RTD sensors. */
	APCI3200_POLARITY_BIPOLAR=2		/**< -2.5 to 2.5 V. Valid only with thermo-couple sensors. */
};

/** Type of connection */
enum
{
	APCI3200_CONNECTION_TYPE_SINGLE=0, /**< Valid only with thermocouple sensors. */
	APCI3200_CONNECTION_TYPE_DIFFERENTIAL /**< Valid with both RTD and thermocouple. */
};

enum
{
	APCI3200_GAIN_1=0,	/**< measured value range is 0 - 2.5 V.    */
	APCI3200_GAIN_2,	/**< measured value range is 0 - 1.25 V.   */
	APCI3200_GAIN_4,	/**< measured value range is 0 - 0.625 V.  */
	APCI3200_GAIN_8,	/**< measured value range is 0 - 0.312 V.  */
	APCI3200_GAIN_16,	/**< measured value range is 0 - 0.156 V.  */
	APCI3200_GAIN_32,	/**< measured value range is 0 - 0.0781 V. */
	APCI3200_GAIN_64,	/**< measured value range is 0 - 0.0390 V. */
	APCI3200_GAIN_128	/**< measured value range is 0 - 0.0195 V. */
};

/** Frequency */
enum
{
	APCI3200_FREQUENCE_20_HZ=20,	/**< 20Hz or 50 ms		*/
	APCI3200_FREQUENCE_40_HZ=40,	/**< 40 Hz or 25 ms.	*/
	APCI3200_FREQUENCE_80_HZ=80,	/**< 80 Hz or 12.5 ms.	*/
	APCI3200_FREQUENCE_160_HZ=160	/**< 160 Hz or 6.25 ms. */
};

/** Frequency unit
* The conversion unit is always Hertz with the APCI-3200.
*/
#define APCI3200_UNIT_HZ	(2)

/** Voltage units */
enum
{
	APCI3200_NANOVOLT=0,
	APCI3200_MICROVOLT,
	APCI3200_MILLIVOLT,
	APCI3200_VOLT,
	APCI3200_NANOAMPERE=4,
	APCI3200_MICROAMPERE,
	APCI3200_MILLIAMPERE,
	APCI3200_AMPERE,
};



//------------------------------------------------------------------------------

/* value used for CMD_APCI3200_CheckAndGetPCISlotNumber ! DEPRECATED ! */
#ifndef CONFIG_APCI3200_MAX_BOARD_NBR
#define CONFIG_APCI3200_MAX_BOARD_NBR                   (3)
#endif // CONFIG_APCI3200_MAX_BOARD_NBR

// for compatibility with older driver (deprecated)
#define APCI3200_MAX_BOARD_NBR CONFIG_APCI3200_MAX_BOARD_NBR

// BEGIN IOCTL -----------------------------------------------------------------
// IOCTL define part
#define APCI3200_MAGIC (char) 'A'

/**
* @param (char*) area of size CONFIG_APCI3200_MAX_BOARD_NBR+1
*
* @deprecated
*
*/
#define CMD_APCI3200_CheckAndGetPCISlotNumber   _IOR(APCI3200_MAGIC, 1,char*)

#define CMD_APCI3200_SetBoardInformation        _IOW(APCI3200_MAGIC, 2,USHORT)

/**
* @deprecated
*/
#define CMD_APCI3200_GetHardwareInformation     _IOR(APCI3200_MAGIC, 3,str_BaseInformations*)

/** Read 1 digital input channel.
*
* @param 			arg		This is the digital input channel number (0 to 3).
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EINVAL	The channel number is false.
*/
#define CMD_APCI3200_Read1DigitalInput			_IOWR(APCI3200_MAGIC, 4, uint8_t*)

/** Read 4 digital inputs channel.
*
* @param 			arg		arg can be a value from 0 up to 15.
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
*/
#define CMD_APCI3200_Read4DigitalInputs			_IOR(APCI3200_MAGIC, 5, uint8_t*)

/** Set the digital output memory on.
*
* When output memory is setting on. Output state is holding, and <br>
* the new output(s) is(are) set or reset.
*
* @param 			arg		Not used, can be set to NULL.
* @retval 0		No error.
*/
#define CMD_APCI3200_SetDigitalOutputMemoryOn	_IO(APCI3200_MAGIC, 6)

/** Set the digital output memory off.
*
* @param 			arg		Not used, can be set to NULL.
* @retval 0		No error.
*/
#define CMD_APCI3200_SetDigitalOutputMemoryOff	_IO(APCI3200_MAGIC, 7)

/** Set 1 digital output channel on.
*
* @param 			arg		This is the digital output channel number (0 to 2).
*
* @retval 0		No error.
* @retval -EINVAL	The output number is wrong.
*/
#define CMD_APCI3200_Set1DigitalOutputOn		_IOW(APCI3200_MAGIC, 8, uint8_t)

/** Set 1 digital output channel off.
*
* @param 			arg		This is the digital output channel number (0 to 2).
*
* @remark			This function has to be called only if output memory is on!
*
* @retval 0		No error.
* @retval -EINVAL	The output number is wrong.
* @retval -EINVAL	The output memory is off.
*/
#define CMD_APCI3200_Set1DigitalOutputOff		_IOW(APCI3200_MAGIC, 9, uint8_t)

/** Set 3 digital outputs channel on.
*
* @param 			arg		This is the digital output channel number (0 to 7).<br>
* 							Example:
* 							Output 0: arg=1
* 							Output 1: arg=2
* 							Output 2: arg=4
* 							Output 1 and 2: arg=3
*
* @retval 0		No error.
* @retval -EINVAL	The output number is wrong.
*/
#define CMD_APCI3200_Set3DigitalOutputsOn		_IOW(APCI3200_MAGIC, 10, uint8_t)

/** Set 3 digital outputs channel off.
*
* @param 			arg		digital output channel number (0 to 7).<br>
* 							Example:
* 							Output 0: arg=1
* 							Output 1: arg=2
* 							Output 2: arg=4
* 							Output 1 and 2: arg=3
*
* @remark			This function has to be called only if output memory is on!
*
* @retval 0		No error.
* @retval -EINVAL	The output number is wrong.
* @retval -EINVAL	The output memory is off.
*/
#define CMD_APCI3200_Set3DigitalOutputsOff		_IOW(APCI3200_MAGIC, 11, uint8_t)

/**@struct InitAnalogInputChannel_t
* This structure is used to give initialization parameters to CMD_APCI3200_InitAnalogInputChannel function.
*
* @note The parameter b_DiffSingSelected configures the board, but must relate to the actual physical setup.
*/
struct InitAnalogInputChannel_t
{
	unsigned char	b_Channel; /**< [in] Channel to acquire. Its allowed range depends on connection type.
									b_DiffSingSelected = APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
									b_DiffSingSelected = APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7) */
	unsigned char	b_PolaritySelected; /**< [in] Voltage range to measure.
											 ADDIDATA_THERMOCOUPLE => b_PolaritySelected = APCI3200_POLARITY_BIPOLAR
											 ADDIDATA_RTD => b_PolaritySelected = APCI3200_POLARITY_UNIPOLAR */
	unsigned int	w_GainSelected; 	/**< [in] Gain to use: (APCI3200_GAIN_1, APCI3200_GAIN_2, APCI3200_GAIN_4, APCI3200_GAIN_8, APCI3200_GAIN_16, APCI3200_GAIN_32, APCI3200_GAIN_128) */
	unsigned char	b_DiffSingSelected; /**< [in] Connection type :
											 ADDIDATA_THERMOCOUPLE => b_DiffSingSelected : (APCI3200_CONNECTION_TYPE_SINGLE,APCI3200_CONNECTION_TYPE_DIFFERENTIAL)
											 ADDIDATA_RTD => b_DiffSingSelected = APCI3200_CONNECTION_TYPE_DIFFERENTIAL */
};

/** Initialize an analog input.
*
* @param[in]		arg		InitAnalogInputChannel_t
*
* @retval 0		No error.
* @retval EFAULT	Fail to get user parameters.
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_InitAnalogInputChannel		_IOW(APCI3200_MAGIC, 12, struct InitAnalogInputChannel_t)


/**@struct Read1AnalogInputChannel_t
* This structure is used to set read functions parameters and to get the read value.
*/
struct Read1AnalogInputChannel_t
{
	unsigned char b_Channel; /**<	[in] Channel to acquire. Its allowed range depends on connection type.
									APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
									APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7) */
	unsigned long dw_TimerReloadValue; /**< [in] Conversion frequency : : (APCI3200_FREQUENCE_20_HZ,APCI3200_FREQUENCE_40_HZ,APCI3200_FREQUENCE_80_HZ,APCI3200_FREQUENCE_160_HZ) */
	unsigned char b_ConvertingTimeUnit; /**< [in] The conversion time unit : APCI3200_UNIT_HZ (Always this value with the APCI-3200) */
	unsigned long dw_ChannelValue; /**< [out] The channel value read by the board. */
};


/** Read the specified analog input channel.
*
* @param[in,out]	arg	Read1AnalogInputChannel_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_Read1AnalogInputChannel	_IOWR(APCI3200_MAGIC, 13, struct Read1AnalogInputChannel_t*)

/** Read the calibration gain value on the specified analog input channel.
*
* @param[in,out]	arg	Read1AnalogInputChannel_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCalibrationGainValue	_IOWR(APCI3200_MAGIC, 14, struct Read1AnalogInputChannel_t*)

/** Read the calibration offset value on the specified analog input channel.
*
* @param[in,out]	arg	Read1AnalogInputChannel_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCalibrationOffsetValue	_IOWR(APCI3200_MAGIC, 15, struct Read1AnalogInputChannel_t*)


/**@struct Read1CJCInputChannel_t
* This structure is used to set read CJC functions parameters and to get the read value.
*/
struct Read1CJCInputChannel_t
{
	unsigned long dw_TimerReloadValue; /**< [in] Conversion frequency : (APCI3200_FREQUENCE_20_HZ,APCI3200_FREQUENCE_40_HZ,APCI3200_FREQUENCE_80_HZ,APCI3200_FREQUENCE_160_HZ) */
	unsigned char b_ConvertingTimeUnit; /**< [in] The conversion time unit: APCI3200_UNIT_HZ (Always this value with the APCI-3200). */
	unsigned long dw_ChannelValue; /**< [out] The CJC value read by the board. */
};


/** Read the CJC value.
*
* @param[in,out]	arg	Read1CJCInputChannel_t
*
* @retval 0		No error.
* @retval EFAULT	Fail to get user parameters.
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCJCValue					_IOWR(APCI3200_MAGIC, 16, struct Read1CJCInputChannel_t*)

/** Read the CJC calibration gain value.
*
* @param[in,out]	arg	Read1CJCInputChannel_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCJCCalibrationGainValue	_IOWR(APCI3200_MAGIC, 17, struct Read1CJCInputChannel_t*)

/** Read the CJC calibration offset value.
*
* @param[in,out]	arg	Read1CJCInputChannel_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCJCCalibrationOffsetValue	_IOWR(APCI3200_MAGIC, 18, struct Read1CJCInputChannel_t*)

/**@struct ReadCalibrationValue_t
* This structure is used to set read calibration functions parameters and to get the calibration value.
*/
struct ReadCalibrationValue_t
{
	unsigned char b_Channel; /**< 	[in] Channel to acquire. Its allowed range depends on connection type.
									w_ConnectionType = APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
									w_ConnectionType = APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7) */
	unsigned int w_ConnectionType; /**<	[in] Type of connection. Depend of the sensor:
									ADDIDATA_THERMOCOUPLE => b_DiffSingSelected : (APCI3200_CONNECTION_TYPE_SINGLE,APCI3200_CONNECTION_TYPE_DIFFERENTIAL)
									ADDIDATA_RTD => b_DiffSingSelected = APCI3200_CONNECTION_TYPE_DIFFERENTIAL */
	unsigned int w_Gain; /**< [in] Gain to use: (APCI3200_GAIN_1, APCI3200_GAIN_2, APCI3200_GAIN_4, APCI3200_GAIN_8, APCI3200_GAIN_16, APCI3200_GAIN_32, APCI3200_GAIN_128) */
	unsigned long dw_CJCCurrentSource; /**< [out] The CJC current source value reading in the eeprom. */
	unsigned long dw_ChannelCurrentSource; /**< [out] The channel current source value reading in the eeprom. */
	unsigned long dw_ChannelGainFactor;	/**< [out] The channel gain factor value. */
};


/** Read the calibration values of the specified analog input channel.
*
* @param[in,out]	arg	ReadCalibrationValue_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadChannelCalibrationValue	_IOWR(APCI3200_MAGIC, 19, struct ReadCalibrationValue_t*)

/** @note The parameter b_DiffSingSelected configures the board, but must relate to the actual physical setup. */
struct InitTemperatureModule_t {

	long l_Module; /**< [in] 0 to 3 */
	long l_SensorType; /**< [in] ADDIDATA_THERMOCOUPLE, ADDIDATA_RTD */
	BYTE pl_SensorValue[4]; /** 	[in] Sensor type:
	l_SensorType = ADDIDATA_THERMOCOUPLE => forall i: (0,3) . pl_SensorValue[i] : (ADDIDATA_THERMOCOUPLE_TYPE_B,
																					ADDIDATA_THERMOCOUPLE_TYPE_E,
																					ADDIDATA_THERMOCOUPLE_TYPE_J,
																					ADDIDATA_THERMOCOUPLE_TYPE_K,
																					ADDIDATA_THERMOCOUPLE_TYPE_N,
																					ADDIDATA_THERMOCOUPLE_TYPE_R,
																					ADDIDATA_THERMOCOUPLE_TYPE_S,
																					ADDIDATA_THERMOCOUPLE_TYPE_T)
	l_SensorType = ADDIDATA_RTD => forall i: (0,3) . pl_SensorValue[i] : (ADDIDATA_RTD_TYPE_PT, ADDIDATA_RTD_TYPE_Ni) */
	long l_DiffSingSelected; /**< 	[in] Connection type :
									l_SensorType = ADDIDATA_THERMOCOUPLE => l_DiffSingSelected : (APCI3200_CONNECTION_TYPE_SINGLE, APCI3200_CONNECTION_TYPE_DIFFERENTIAL)
									l_SensorType = ADDIDATA_RTD => l_DiffSingSelected = APCI3200_CONNECTION_TYPE_DIFFERENTIAL */
};

/** Initialize the temperature module.
*
* @param[in]	arg	InitTemperatureModule_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_InitScanModuleAcquisitionSensor			_IOW(APCI3200_MAGIC, 20, struct InitTemperatureModule_t)

struct InitTemperatureChannelSCAN_t
{
	unsigned int w_Module;				/**< [in] Module number : 0 to 3 */
	unsigned long dw_ConversionTime;	/**< [in] Conversion frequency : (APCI3200_FREQUENCE_20_HZ, APCI3200_FREQUENCE_40_HZ, APCI3200_FREQUENCE_80_HZ, APCI3200_FREQUENCE_160_HZ) */
	unsigned char b_SCANTimeMode;		/**< [in] Delay mode : (APCI3200_DELAY_NOT_USED, APCI3200_DELAY_MODE1_USED) */
	unsigned long dw_SCANTime; 			/**< [in] Total time of the SCAN (including delay). */
	unsigned char b_SCANTimeUnit; 		/**< [in] Unit of dw_SCANTime: (APCI3200_UNIT_MS, APCI3200_UNIT_S) */
	unsigned char b_ExternTriggerMode; 	/**< [in] External Trigger action: (APCI3200_DISABLE, APCI3200_FIRST_LOW_EDGE_START_ALL_SCAN, APCI3200_FIRST_HIGH_EDGE_START_ALL_SCAN, APCI3200_FIRST_EDGE_START_ALL_SCAN) */
	unsigned char b_SCANMode; 			/**< [in] Scan mode :(APCI3200_SINGLE_SCAN, APCI3200_DEFINED_SCAN_NUMBER, APCI3200_CONTINUOUS_SCAN) */
	unsigned long dw_SCANCounter;		/**< Number of scans when b_SCANMode = APCI3200_DEFINED_SCAN_NUMBER */
};

/** Initialize the temperature scan channel.
*
* @param[in]	arg	InitTemperatureChannelSCAN_t
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_InitScanModuleAcquisition		_IOW(APCI3200_MAGIC, 21, struct InitTemperatureChannelSCAN_t)

/** Start the scan acquisition on the specified module.
*
* @param[in]	arg	uint16_t (Module number 0 - 3)
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_StartScanModuleAcquisition		_IOW(APCI3200_MAGIC, 22, uint16_t)

/** Stop the scan acquisition on the specified module.
*
* @param[in]	arg	uint16_t (Module number 0 - 3)
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_StopScanModuleAcquisition		_IOW(APCI3200_MAGIC, 23, uint16_t)

/**@struct ReadReferenceVoltage_t
* This structure is used to set read the reference voltage for a channel.
*/
struct ReadReferenceVoltage_t
{
	unsigned char b_Channel; /**<  	[in] Channel to acquire. Its allowed range depends on connection type.
									APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
									APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7) */
	unsigned int dw_ReferenceVoltage; 	/** [out] < 2500 mV or 1250 mV */
	unsigned int Unit;					/**< [out] APCI3200_MILLIVOLT */
};
/** Read the reference voltage for a given channel
*
* @param[in,out]	unsigned long
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
*/
#define CMD_APCI3200_ReadReferenceVoltage			_IOWR(APCI3200_MAGIC, 24, struct ReadReferenceVoltage_t*)

/** CMD_APCI3200_SetConvertingTime() allows to set the timer reload value once for a given module. */
struct SetConvertingTime_t
{
	unsigned char b_Channel; /**<	[in] Channel to acquire. Its allowed range depends on connection type.
									APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
									APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7) */
	unsigned long dw_TimerReloadValue; /**< [in] Conversion frequency : : (APCI3200_FREQUENCE_20_HZ,APCI3200_FREQUENCE_40_HZ,APCI3200_FREQUENCE_80_HZ,APCI3200_FREQUENCE_160_HZ) */
	unsigned char b_ConvertingTimeUnit; /**< [in] The conversion time unit : APCI3200_UNIT_HZ (Always this value with the APCI-3200) */
};
#define CMD_APCI3200_SetConvertingTime				_IOR(APCI3200_MAGIC, 25, struct SetConvertingTime_t*)


/** Same as CMD_APCI3200_Read1AnalogInputChannel, but does not configure timing/frequency
 *
 * This function does not configure timing/frequency, use CMD_APCI3200_SetConvertingTime for that.
*
* @param[in]	arg	Channel to acquire. Its allowed range depends on connection type.
*					APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
*					APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7)
* @param[out]	arg Value returned by hardware.
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_Read1AnalogInputChannelFast	_IOWR(APCI3200_MAGIC, 26, unsigned long*)

/** Same as CMD_APCI3200_ReadCJCValue, but does not configure timing/frequency
*
* This function does not configure timing/frequency, use CMD_APCI3200_SetConvertingTime for that.
*
* @param[out]	arg	The CJC value read by the board.
*
* @retval 0		No error.
* @retval EFAULT	Fail to get user parameters.
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCJCValueFast				_IOWR(APCI3200_MAGIC, 27, unsigned long*)

/** Same as CMD_APCI3200_ReadCalibrationOffsetValue, but does not configure timing/frequency.
*
* This function does not configure timing/frequency, use CMD_APCI3200_SetConvertingTime for that.
*
* @param[in]	arg	Channel to acquire. Its allowed range depends on connection type.
*					APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
*					APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7)
* @param[out]	arg Value returned by hardware.
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCalibrationOffsetValueFast	_IOWR(APCI3200_MAGIC, 28, unsigned long*)

/** Same as CMD_APCI3200_ReadCalibrationGainValue, but does not configure timing/frequency.
*
* This function does not configure timing/frequency, use CMD_APCI3200_SetConvertingTime for that.
*
* @param[in]	arg	Channel to acquire. Its allowed range depends on connection type.
*					APCI3200_CONNECTION_TYPE_SINGLE => b_Channel : (0..15)
*					APCI3200_CONNECTION_TYPE_DIFFERENTIAL => b_Channel : (0..7)
* @param[out]	arg Value returned by hardware.
*
* @retval 0		No error.
* @retval -EFAULT	parameter references an inaccessible memory area
* @retval -EIO 	Board access timeout
*/
#define CMD_APCI3200_ReadCalibrationGainValueFast	_IOWR(APCI3200_MAGIC, 29, unsigned long*)

/** Set / Reset the diagnostic mode.
 *
 * This function permits to enable disable diagnostic test.
 *
 * @param [in]		cmd		IOCTL command. The command is <br>
 * 							CMD_APCI3200_SetDiagnosticMode when using the IOCTL funktion.<br>
 * 							To call the function in kernel mode, cmd must be 0.
 * @param [in]		arg[0]	mode:
 *  					- APCI3200_DIAGNOSTIC_NONE:				Disable diagnostic test.
 * 						- APCI3200_DIAGNOSTIC_OPEN_CONNECTION:	Open connection test.
 * @param [in]		arg[1] channel: The channel to test (single 0 - 15, differential 0 - 7).
 *
 * @retval 0		No error.
 * @retval -EINVAL	Incorrect parameter.
 * @retval -EFAULT	Fail to get user parameters.
 */
#define CMD_APCI3200_SetDiagnosticMode	_IOR(APCI3200_MAGIC, 30, unsigned char*)

/** Get the diagnostic mode.
 *
 * This function permits to get the configured diagnostic test.
 *
 * @param [in]		cmd		IOCTL command. The command is <br>
 * 							CMD_APCI3200_SetDiagnosticMode when using the IOCTL funktion.<br>
 * 							To call the function in kernel mode, cmd must be 0.
 * @param [in]		arg channel: The channel to test (single 0 - 15, differential 0 - 7).
 * @param [out]		arg	mode:
 *  					- APCI3200_DIAGNOSTIC_NONE:				Disable diagnostic test.
 * 						- APCI3200_DIAGNOSTIC_OPEN_CONNECTION:	Open connection test.
 *
 * @retval -EINVAL	Incorrect parameter.
 * @retval -EFAULT	Fail to return user parameters.
 */
#define CMD_APCI3200_GetDiagnosticMode	_IOWR(APCI3200_MAGIC, 31, unsigned char*)

/** Empty event FIFO of all pending events.
 *
 * @param arg None (Use NULL)
 *
 * @return 0 on success, -1 on failure (see errno then)
 *
 */
#define CMD_APCI3200_EventEmpty         			_IOW(APCI3200_MAGIC, 32,void*)

/** Wait for an event.
 *
 * @param[in] arg apci3200_event_t*
 * }
 *
 * @return 0 on success, -1 on failure (see errno then)
 *
 */
#define CMD_APCI3200_EventWait         			_IOW(APCI3200_MAGIC, 33,apci3200_event_t*)


/** Used internally. This is the ioctl CMD with the highest number.
* @internal
*/
#define __APCI3200_UPPER_IOCTL_CMD 33



#endif // __APCI3200_H__
