📄 apci1710_ttl.c
字号:
/**@verbatimCopyright (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 program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program 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 General Public License for more details.You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAYou shoud also find the complete GPL in the COPYING file accompanying this source code.@endverbatim*//* +-----------------------------------------------------------------------+ | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | +-----------------------------------------------------------------------+ | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | +-----------------------------------------------------------------------+ | Project : API APCI1710 | Compiler : gcc | | Module name : TTL.C | Version : 2.96 | +-------------------------------+---------------------------------------+ | Project manager: Eric Stolz | Date : 02/12/2002 | +-----------------------------------------------------------------------+ | Description : APCI-1710 TTL I/O module | | | | | +-----------------------------------------------------------------------+ | UPDATES | +-----------------------------------------------------------------------+ | Date | Author | Description of updates | +----------+-----------+------------------------------------------------+ | 13/05/98 | S. Weber | TTL digital input / output implementation | |----------|-----------|------------------------------------------------| | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | | | | available | +-----------------------------------------------------------------------+ | | | | | | | | +-----------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+| Included files |+----------------------------------------------------------------------------+*/#include "APCI1710_Ttl.h"/*+----------------------------------------------------------------------------+| Function Name : _INT_ i_APCI1710_InitTTLIODirection || (BYTE_ b_BoardHandle, || BYTE_ b_ModulNbr, || BYTE_ b_PortAMode, || BYTE_ b_PortBMode, || BYTE_ b_PortCMode, || BYTE_ b_PortDMode) |+----------------------------------------------------------------------------+| Task APCI1710_TTL_INIT (using defaults) : Configure the TTL I/O operating mode from selected || module (b_ModulNbr). You must calling this function be|| for you call any other function witch access of TTL. | APCI1710_TTL_INITDIRECTION(user inputs for direction) +----------------------------------------------------------------------------+| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|| BYTE_ b_ModulNbr : Module number to || configure (0 to 3) b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); b_InitType = (BYTE) data[0]; b_PortAMode = (BYTE) data[1]; b_PortBMode = (BYTE) data[2]; b_PortCMode = (BYTE) data[3]; b_PortDMode = (BYTE) data[4];|+----------------------------------------------------------------------------+| Output Parameters : - |+----------------------------------------------------------------------------+| Return Value : 0: No error || -1: The handle parameter of the board is wrong || -2: The module parameter is wrong || -3: The module is not a TTL module || -4: Function not available for this version || -5: Port A mode selection is wrong || -6: Port B mode selection is wrong || -7: Port C mode selection is wrong || -8: Port D mode selection is wrong |+----------------------------------------------------------------------------+*/INT i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data) { INT i_ReturnValue = 0; BYTE b_ModulNbr; BYTE b_InitType; BYTE b_PortAMode; BYTE b_PortBMode; BYTE b_PortCMode; BYTE b_PortDMode; b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); b_InitType = (BYTE) data[0]; i_ReturnValue = insn->n; /**************************/ /* Test the module number */ /**************************/ if (b_ModulNbr < 4) { /**************************/ /* Test if TTL I/O module */ /**************************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_TTL_IO) { switch(b_InitType) { case APCI1710_TTL_INIT : devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo.b_TTLInit = 1; /***************************/ /* Set TTL port A to input */ /***************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [0] = 0; /***************************/ /* Set TTL port B to input */ /***************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [1] = 0; /***************************/ /* Set TTL port C to input */ /***************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [2] = 0; /****************************/ /* Set TTL port D to output */ /****************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [3] = 1; /*************************/ /* Set the configuration */ /*************************/ outl(0x8,devpriv->s_BoardInfos.ui_Address + 20 + (64 * b_ModulNbr)); break; case APCI1710_TTL_INITDIRECTION : b_PortAMode = (BYTE) data[1]; b_PortBMode = (BYTE) data[2]; b_PortCMode = (BYTE) data[3]; b_PortDMode = (BYTE) data[4]; /********************/ /* Test the version */ /********************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3230) { /************************/ /* Test the port A mode */ /************************/ if ((b_PortAMode == 0) || (b_PortAMode == 1)) { /************************/ /* Test the port B mode */ /************************/ if ((b_PortBMode == 0) || (b_PortBMode == 1)) { /************************/ /* Test the port C mode */ /************************/ if ((b_PortCMode == 0) || (b_PortCMode == 1)) { /************************/ /* Test the port D mode */ /************************/ if ((b_PortDMode == 0) || (b_PortDMode == 1)) { devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_TTLInit = 1; /***********************/ /* Set TTL port A mode */ /***********************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [0] = b_PortAMode; /***********************/ /* Set TTL port B mode */ /***********************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [1] = b_PortBMode; /***********************/ /* Set TTL port C mode */ /***********************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [2] = b_PortCMode; /***********************/ /* Set TTL port D mode */ /***********************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TTLIOInfo. b_PortConfiguration [3] = b_PortDMode; /*************************/ /* Set the configuration */ /*************************/ outl((b_PortAMode << 0) | (b_PortBMode << 1) | (b_PortCMode << 2) | (b_PortDMode << 3),devpriv->s_BoardInfos. ui_Address + 20 + (64 * b_ModulNbr)); } else { /**********************************/ /* Port D mode selection is wrong */ /**********************************/ DPRINTK("Port D mode selection is wrong\n"); i_ReturnValue = -8; } } else { /**********************************/ /* Port C mode selection is wrong */ /**********************************/ DPRINTK("Port C mode selection is wrong\n"); i_ReturnValue = -7; } } else { /**********************************/ /* Port B mode selection is wrong */ /**********************************/ DPRINTK("Port B mode selection is wrong\n"); i_ReturnValue = -6; } } else { /**********************************/ /* Port A mode selection is wrong */ /**********************************/ DPRINTK("Port A mode selection is wrong\n"); i_ReturnValue = -5; } } else { /*******************************************/ /* Function not available for this version */ /*******************************************/ DPRINTK("Function not available for this version\n"); i_ReturnValue = -4; } break; DPRINTK("\n"); default: printk("Bad Config Type\n"); }// switch end } else { /**********************************/ /* The module is not a TTL module */ /**********************************/ DPRINTK("The module is not a TTL module\n"); i_ReturnValue = -3; } } else { /***********************/ /* Module number error */ /***********************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -