 /* @file apci2200.h
  * 
  * @brief Define the public API for the apci2200 ADDI-DATA board. 
  * 
  *
  */

/** @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 __apci2200_H__
#define __apci2200_H__


#define APCI2200_DRIVER_VERSION_MAJOR 2026
#define APCI2200_DRIVER_VERSION_MINOR 06
#define APCI2200_DRIVER_VERSION_PATCH 1

#include <apci.h>

//GENERAL DEFINE

#define APCI2200_BOARD_NAME                      "apci2200"
#define APCI2200_BOARD_VENDOR_ID                 0x15B8
#define APCI2200_BOARD_DEVICE_ID                 0x1005

/* value used for CMD_apci2200_CheckAndGetPCISlotNumber ! DEPRECATED ! */
#ifndef CONFIG_APCI2200_MAX_BOARD_NBR
#define CONFIG_APCI2200_MAX_BOARD_NBR                   (3)
#endif // CONFIG_apci2200_MAX_BOARD_NBR

// for compatibility with older driver (deprecated)
#define APCI2200_MAX_BOARD_NBR CONFIG_APCI2200_MAX_BOARD_NBR

// IOCTL define part
#define APCI2200_MAGIC (char) 'A'

/**
 * @param (char*) area of size CONFIG_apci2200_MAX_BOARD_NBR+1
 * 
 * @deprecated
 * 
 */
#define CMD_apci2200_CheckAndGetPCISlotNumber   _IOR(APCI2200_MAGIC, 1,char*)

#define CMD_apci2200_SetBoardInformation        _IOW(APCI2200_MAGIC, 2,uint16_t)

/**
 * @deprecated
 */
#define CMD_apci2200_GetHardwareInformation     _IOR(APCI2200_MAGIC, 3,str_BaseInformations*)

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

/** Read 8 digital input.
 *
 * @param [in] pdev                       : The device to initialize.
 * @param [out] arg (b_DigitalInputValue) : Digital input channel status <br>
 *                                             0 : Channle is not active <br>
 *                                             1 : Channle is active    
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval -EFAULT : Fail to retrieve user data.             
 */
#define CMD_APCI2200_Read8DigitalInput			_IOWR(APCI2200_MAGIC, 4, uint8_t *)															

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

/** Activates the digital output memory. 
 * 
 * After having called up this function, the output you have previously
 * activated with the function "i_APCI2200_SetXDigitalOutputOn" are not reset.
 * You can reset them with the function "i_APCI2200_SetXDigitalOutputOff".                  
 *
 * @param [in] pdev                  : The device to initialize.
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Output memory is already set on.
 */
#define CMD_APCI2200_SetDigitalOutputMemoryOn			_IO(APCI2200_MAGIC, 5)

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

/** Deactivates the digital output memory.
 *
 * @param [in] pdev                  : The device to initialize.
  * 
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Output memory is already set off.
 */
#define CMD_APCI2200_SetDigitalOutputMemoryOff			_IO(APCI2200_MAGIC, 6)

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

/** Set 1 digital output on. 
 * 
 * Setting an output means setting an ouput high.                                         
 *
 * @param [in] pdev                  : The device to initialize.
 * @param [in] arg (b_DigitalOutput) : Selection from digital output (0 to 15). 
 * 
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Wrong digital output (0 to 15). 
 */
#define CMD_APCI2200_Set1DigitalOutputOn				_IOW(APCI2200_MAGIC, 7, uint8_t)	

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

/** Set 1 digital output off. 
 * 
 * Setting an output means setting an ouput low.                                         
 *
 * @param [in] pdev                  : The device to initialize.
 * @param [in] arg (b_DigitalOutput) : Selection from digital output (0 to 15). 
 * 
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Digital output memory is not activated.
 * @retval 3: Wrong digital output (0 to 15). 
 */
#define CMD_APCI2200_Set1DigitalOutputOff				_IOW(APCI2200_MAGIC, 8, uint8_t)

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

/** Set 8 digital output on.                                        
 *
 * @param [in] pdev                 : The device to initialize.
 * @param [in] arg[0] (b_Port)      : The port to set (0: Port 1, 1: Port 2).
 * @param [in] arg[1] (b_PortValue) : Port value (0 to 0xFF).
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: The port parameter of the board is wrong (has to be 0: Port 1, 1: Port 2).
 * @retval -EFAULT : Fail to retrieve user data. 
 */
#define CMD_APCI2200_Set8DigitalOutputOn				_IOW(APCI2200_MAGIC, 9, uint8_t)	

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

/** Set 8 digital output off.                                        
 *
 * @param [in] pdev                 : The device to initialize.
 * @param [in] arg[0] (b_Port)      : The port to set (0: Port 1, 1: Port 2).
 * @param [in] arg[1] (b_PortValue) : Port value (0 to 0xFF).
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: The port parameter of the board is wrong (has to be 0: Port 1, 1: Port 2).
 * @retval 3: Digital output memory is not activated.
 */
#define CMD_APCI2200_Set8DigitalOutputOff				_IOW(APCI2200_MAGIC, 10, uint8_t)   
	
//------------------------------------------------------------------------------

/** Set 16 digital output on.                                       
 *
 * @param [in] pdev                       : The device to initialize.
 * @param [in] arg (w_DigitalOutputValue) : Port value (0 to 0xFFFF).
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 */
#define CMD_APCI2200_Set16DigitalOutputOn				_IOW(APCI2200_MAGIC, 11, uint16_t)

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

/** Set 16 digital output off.                                       
 *
 * @param [in] pdev                       : The device to initialize.
 * @param [in] arg (w_DigitalOutputValue) : Port value (0 to 0xFFFF).
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Digital output memory is not activated.
 */
#define CMD_APCI2200_Set16DigitalOutputOff				_IOW(APCI2200_MAGIC, 12, uint16_t)   

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

/** Read 16 digital output             
 *
 * @param [in] pdev                        : The device to initialize.
 *
 * @param [out] arg (w_DigitalOutputValue) : Digital output port status.
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wro
 * @retval -EFAULT : Fail to export user data. 
 */
#define CMD_APCI2200_Read16DigitalOutput				_IOWR(APCI2200_MAGIC, 13, uint16_t *)	

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

/** Initialise the watchdog.                                                 
 * 
 * @param [in] pdev               : The device to initialize.
 * @param [in] arg (l_DelayValue) : Watchdog delay value in step of 20ms (1 to 255).
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Wrong watchdog delay value (has to be 1 to 255).
 */
#define CMD_APCI2200_InitWatchdog						_IOW(APCI2200_MAGIC, 14, uint32_t)

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

/** Start the watchdog.                                                 
 * 
 * @param [in] pdev         : The device to initialize.
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Watchdog already started.
 */
#define CMD_APCI2200_StartWatchdog						_IO(APCI2200_MAGIC, 15)		

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

/** Stop the watchdog.                                                 
 * 
 * @param [in] pdev         : The device to initialize.
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Watchdog not started.
 */
#define CMD_APCI2200_StopWatchdog						_IO(APCI2200_MAGIC, 16)						

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

/** Trigger the watchdog.                                                 
 * 
 * @param [in] pdev         : The device to initialize.
 *
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Watchdog not started.
 */
#define CMD_APCI2200_TriggerWatchdog					_IO(APCI2200_MAGIC, 17)   

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

/** Get the watchdog status.                                                 
 * 
 * @param [in] pdev         : The device to initialize.
 * @param [out] b_Status    : Watchdog status:<br>
 *								0 : No overlow occur<br>
 *								1 : Overlow occur
 * 
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Watchdog not started.
 * @retval -EFAULT : Fail to export user data. 
 */
#define CMD_APCI2200_GetWatchdogStatus					_IOR(APCI2200_MAGIC, 18, uint8_t *)

//------------------------------------------------------------------------------
	
/** Get the watchdog software trigger status.                                                 
 * 
 * @param [in] pdev         : The device to initialize.
 * @param [out] b_Status    : Watchdog software trigger status:<br>
 *								0 : No software trigger occur <br>
 *								1 : Software trigger occur
 * 
 * @retval 0: No error.
 * @retval 1: The handle parameter of the board is wrong.
 * @retval 2: Watchdog not started.
 * @retval -EFAULT : Fail to export user data. 
 */
#define CMD_APCI2200_GetWatchdogSoftwareTriggerStatus	_IOR(APCI2200_MAGIC, 19, uint8_t *)

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

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


#endif // __apci2200_H__
