⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwdrv_apci1516.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/**@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     : APCI-1516       | Compiler   : GCC                      |  | Module name : hwdrv_apci1516.c| Version    : 2.96                     |  +-------------------------------+---------------------------------------+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |  +-------------------------------+---------------------------------------+  | Description :   Hardware Layer Acces For APCI-1516                    |  +-----------------------------------------------------------------------+  |                             UPDATES                                   |  +----------+-----------+------------------------------------------------+  |   Date   |   Author  |          Description of updates                |  +----------+-----------+------------------------------------------------+  |          |           |                                                |  |          |           |                                                |  |          |           |                                                |  +----------+-----------+------------------------------------------------+*//*+----------------------------------------------------------------------------+|                               Included files                               |+----------------------------------------------------------------------------+*/#include "hwdrv_apci1516.h"/*+----------------------------------------------------------------------------+| Function   Name   : int i_APCI1516_Read1DigitalInput                       ||			  (comedi_device *dev,comedi_subdevice *s,               ||                      comedi_insn *insn,lsampl_t *data)                     |+----------------------------------------------------------------------------+| Task              : Return the status of the digital input                 |+----------------------------------------------------------------------------+| Input Parameters  : comedi_device *dev      : Driver handle                ||		       comedi_subdevice *s,   :pointer to subdevice structure                       comedi_insn *insn      :pointer to insn structure     ||                     lsampl_t *data          : Data Pointer to read status  |+----------------------------------------------------------------------------+| Output Parameters :	--													 |+----------------------------------------------------------------------------+| Return Value      : TRUE  : No error occur                                 ||		            : FALSE : Error occur. Return the error          ||			                                                         |+----------------------------------------------------------------------------+*/INT i_APCI1516_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){   UINT ui_TmpValue=0;   UINT ui_Channel;   ui_Channel=CR_CHAN(insn->chanspec);   if  (ui_Channel >= 0 && ui_Channel <=7)      {      ui_TmpValue=(UINT) inw(devpriv->iobase + APCI1516_DIGITAL_IP);      //  since only 1 channel reqd  to bring it to last bit it is rotated       //  8 +(chan - 1) times then ANDed with 1 for last bit.       *data = (ui_TmpValue >> ui_Channel)&0x1 ;      }//if(ui_Channel >= 0 && ui_Channel <=7)   else       {      //comedi_error(dev," \n chan spec wrong\n");      return -EINVAL;   // "sorry channel spec wrong "      }//else if(ui_Channel >= 0 && ui_Channel <=7)  return insn->n;}/*+----------------------------------------------------------------------------+| Function   Name   : int i_APCI1516_ReadMoreDigitalInput                    ||			  (comedi_device *dev,comedi_subdevice *s,               ||                     comedi_insn *insn,lsampl_t *data)                      |+----------------------------------------------------------------------------+| Task              : Return the status of the Requested digital inputs      |+----------------------------------------------------------------------------+| Input Parameters  : comedi_device *dev      : Driver handle                ||                      comedi_subdevice *s,   :pointer to subdevice structure                       comedi_insn *insn      :pointer to insn structure     ||                      lsampl_t *data         : Data Pointer to read status  |+----------------------------------------------------------------------------+| Output Parameters :	--													 |+----------------------------------------------------------------------------+| Return Value      : TRUE  : No error occur                                 ||		            : FALSE : Error occur. Return the error          ||			                                                         |+----------------------------------------------------------------------------+*/INT i_APCI1516_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){    UINT ui_PortValue=data[0];   UINT ui_Mask=0;   UINT ui_NoOfChannels;      ui_NoOfChannels=CR_CHAN(insn->chanspec);         *data=(UINT)inw(devpriv->iobase + APCI1516_DIGITAL_IP );      switch (ui_NoOfChannels)	{	 case 2:ui_Mask=3;               *data=(*data >>(2*ui_PortValue))&ui_Mask;                break;	 case 4:ui_Mask=15;               *data=(*data >>(4*ui_PortValue))&ui_Mask; 	       break;	 case 7:break;                default:	        printk("\nWrong parameters\n");		return -EINVAL;   // "sorry channel spec wrong "                  break;        }//switch(ui_NoOfChannels)           return insn->n;}/*+----------------------------------------------------------------------------+| Function   Name   : int i_APCI1516_ConfigDigitalOutput (comedi_device *dev,                    comedi_subdevice *s comedi_insn *insn,lsampl_t *data)    ||				                                                     |+----------------------------------------------------------------------------+| Task              : Configures The Digital Output Subdevice.               |+----------------------------------------------------------------------------+| Input Parameters  : comedi_device *dev : Driver handle                     ||                     lsampl_t *data         : Data Pointer contains         ||                                          configuration parameters as below ||                      comedi_subdevice *s,   :pointer to subdevice structure                       comedi_insn *insn      :pointer to insn structure                                                           | |					  data[0]  :1:Memory on                          | |					            0:Memory off                         | 	|										                             | |																	 |+----------------------------------------------------------------------------+| Output Parameters :	--													 |+----------------------------------------------------------------------------+| Return Value      : TRUE  : No error occur                                 ||		            : FALSE : Error occur. Return the error          ||			                                                         |+----------------------------------------------------------------------------+*/int i_APCI1516_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){ devpriv->b_OutputMemoryStatus=data[0];return insn->n;}/*+----------------------------------------------------------------------------+| Function   Name   : int i_APCI1516_WriteDigitalOutput                      ||			(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,                     lsampl_t *data)                                         |+----------------------------------------------------------------------------+| Task              : Writes port value  To the selected port                |+----------------------------------------------------------------------------+| Input Parameters  : comedi_device *dev      : Driver handle                ||                     comedi_subdevice *s,   :pointer to subdevice structure                      comedi_insn *insn      :pointer to insn structure      ||                    lsampl_t *data           : Data Pointer to read status  |+----------------------------------------------------------------------------+| Output Parameters :	--													 |+----------------------------------------------------------------------------+| Return Value      : TRUE  : No error occur                                 ||		            : FALSE : Error occur. Return the error          ||			                                                         |+----------------------------------------------------------------------------+*/INT i_APCI1516_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) {UINT ui_Temp,ui_Temp1;UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channelprintk("EL311003 : @=%x\n",devpriv->iobase+APCI1516_DIGITAL_OP);  if(devpriv->b_OutputMemoryStatus )   {   ui_Temp=inw(devpriv->iobase+APCI1516_DIGITAL_OP);    }//if(devpriv->b_OutputMemoryStatus ) else   {   ui_Temp=0;    }//if(devpriv->b_OutputMemoryStatus )if(data[3]==0)  {   if(data[1]==0)    {     data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;     outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP);           printk("EL311003 : d=%d @=%x\n",data[0],devpriv->iobase+APCI1516_DIGITAL_OP);          }//if(data[1]==0)   else    {    if(data[1]==1)       {        switch( ui_NoOfChannel)	 {	 case 2: data[0]=(data[0] << (2*data[2]))|ui_Temp; 	       break;	 case 4:data[0]=(data[0] << (4*data[2]))|ui_Temp;	       break;	 case 7:data[0]=data[0]|ui_Temp;               break;         default: 	          comedi_error(dev," chan spec wrong");		  return -EINVAL;   // "sorry channel spec wrong "                           }//switch(ui_NoOfChannels)        outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP);          printk("EL311003 : d=%d @=%x\n",data[0],devpriv->iobase+APCI1516_DIGITAL_OP);      }// if(data[1]==1)   else     {     printk("\nSpecified channel not supported\n");     }//else if(data[1]==1)   }//elseif(data[1]==0) }//if(data[3]==0)else   {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -