📄 hwdrv_apci16xx.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 APCI1648 | Compiler : gcc | | Module name : TTL.C | Version : 2.96 | +-------------------------------+---------------------------------------+ | Project manager: S. Weber | Date : 25/05/2005 | +-----------------------------------------------------------------------+ | Description : APCI-16XX TTL I/O module | | | | | +-----------------------------------------------------------------------+ | UPDATES | +-----------------------------------------------------------------------+ | Date | Author | Description of updates | +----------+-----------+------------------------------------------------+ |25.05.2005| S.Weber | Creation | | | | | +-----------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+| Included files |+----------------------------------------------------------------------------+*/#include "hwdrv_apci16xx.h"/*+----------------------------------------------------------------------------+| Function Name : INT i_APCI16XX_InsnConfigInitTTLIO || (comedi_device *dev, || comedi_subdevice *s, || comedi_insn *insn, || lsampl_t *data) |+----------------------------------------------------------------------------+| Task APCI16XX_TTL_INIT (using defaults) : || Configure the TTL I/O operating mode from all ports || You must calling this function be || for you call any other function witch access of TTL. || APCI16XX_TTL_INITDIRECTION(user inputs for direction) |+----------------------------------------------------------------------------+| Input Parameters : b_InitType = (BYTE) data[0]; || b_Port0Mode = (BYTE) data[1]; || b_Port1Mode = (BYTE) data[2]; || b_Port2Mode = (BYTE) data[3]; || b_Port3Mode = (BYTE) data[4]; || ........ |+----------------------------------------------------------------------------+| Output Parameters : - |+----------------------------------------------------------------------------+| Return Value :>0: No error || -1: Port 0 mode selection is wrong || -2: Port 1 mode selection is wrong || -3: Port 2 mode selection is wrong || -4: Port 3 mode selection is wrong || -X: Port X-1 mode selection is wrong || .... || -100 : Config command error || -101 : Data size error |+----------------------------------------------------------------------------+*/int i_APCI16XX_InsnConfigInitTTLIO(comedi_device *dev, comedi_subdevice *s, comedi_insn *insn, lsampl_t *data) { INT i_ReturnValue = insn->n; BYTE b_Command = 0; BYTE b_Cpt = 0; BYTE b_NumberOfPort = (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8); /************************/ /* Test the buffer size */ /************************/ if (insn->n >= 1) { /*******************/ /* Get the command */ /* *****************/ b_Command = (BYTE) data[0]; /********************/ /* Test the command */ /********************/ if ((b_Command == APCI16XX_TTL_INIT) || (b_Command == APCI16XX_TTL_INITDIRECTION) || (b_Command == APCI16XX_TTL_OUTPUTMEMORY)) { /***************************************/ /* Test the initialisation buffer size */ /***************************************/ if ((b_Command == APCI16XX_TTL_INITDIRECTION) && ((BYTE) (insn->n - 1) != b_NumberOfPort)) { /*******************/ /* Data size error */ /*******************/ printk("\nBuffer size error"); i_ReturnValue = -101; } if ((b_Command == APCI16XX_TTL_OUTPUTMEMORY) && ((BYTE) (insn->n) != 2)) { /*******************/ /* Data size error */ /*******************/ printk("\nBuffer size error"); i_ReturnValue = -101; } } else { /************************/ /* Config command error */ /************************/ printk("\nCommand selection error"); i_ReturnValue = -100; } } else { /*******************/ /* Data size error */ /*******************/ printk("\nBuffer size error"); i_ReturnValue = -101; } /**************************************************************************/ /* Test if no error occur and APCI16XX_TTL_INITDIRECTION command selected */ /**************************************************************************/ if ((i_ReturnValue >= 0) && (b_Command == APCI16XX_TTL_INITDIRECTION)) { memset (devpriv->ul_TTLPortConfiguration, 0, sizeof(devpriv->ul_TTLPortConfiguration)); /*************************************/ /* Test the port direction selection */ /*************************************/ for (b_Cpt = 1; (b_Cpt <= b_NumberOfPort) && (i_ReturnValue >= 0); b_Cpt ++) { /**********************/ /* Test the direction */ /**********************/ if ((data[b_Cpt] != 0) && (data[b_Cpt] != 0xFF)) { /************************/ /* Port direction error */ /************************/ printk("\nPort %d direction selection error", (INT) b_Cpt); i_ReturnValue = - (INT) b_Cpt; } /**************************/ /* Save the configuration */ /**************************/ devpriv->ul_TTLPortConfiguration[(b_Cpt - 1) / 4] = devpriv->ul_TTLPortConfiguration[(b_Cpt - 1) / 4] | (data[b_Cpt] << (8 * ((b_Cpt - 1) % 4))); } } /**************************/ /* Test if no error occur */ /**************************/ if (i_ReturnValue >= 0) { /***********************************/ /* Test if TTL port initilaisation */ /***********************************/ if ((b_Command == APCI16XX_TTL_INIT) || (b_Command == APCI16XX_TTL_INITDIRECTION)) { /******************************/ /* Set all port configuration */ /******************************/ for (b_Cpt = 0; b_Cpt <= b_NumberOfPort; b_Cpt ++) { if ((b_Cpt % 4) == 0) { /*************************/ /* Set the configuration */ /*************************/ outl(devpriv->ul_TTLPortConfiguration[b_Cpt / 4],devpriv->iobase + 32 + b_Cpt); } } } } /************************************************/ /* Test if output memory initialisation command */ /************************************************/ if (b_Command == APCI16XX_TTL_OUTPUTMEMORY) { if (data[1]) { devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; } else { devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; } } return (i_ReturnValue); }/*+----------------------------------------------------------------------------+| INPUT FUNCTIONS |+----------------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+| Function Name : INT i_APCI16XX_InsnBitsReadTTLIO || (comedi_device *dev, || comedi_subdevice *s, || comedi_insn *insn, || lsampl_t *data) |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -