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

📄 apci1710_dig_io.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	}/*+----------------------------------------------------------------------------+    |INT i_APCI1710_InsnBitsDigitalIOPortOnOff(comedi_device *dev,comedi_subdevice 	*s,	comedi_insn *insn,lsampl_t *data)+----------------------------------------------------------------------------+| Task              : write:					  Sets or resets one or several outputs from port.                 ||                     Setting an output means setting an output high.        ||                     If you have switched OFF the digital output memory     ||                     (OFF), all the other output are set to "0".            |                      read:					  Read the status from digital input port                ||                     from selected digital I/O module (b_ModulNbr)   +----------------------------------------------------------------------------+| Input Parameters  : 	BYTE_ b_BoardHandle   : Handle of board APCI-1710      ||   BYTE_ b_ModulNbr  CR_AREF(aref)    : Selected module number (0 to 3)||   BYTE_ b_PortValue CR_CHAN(chanspec) : Output Value ( 0 To 7 )        |                       data[0]           read or write port                        data[1]            if write then indicate ON or OFF                        if read : data[1] will return port status.+----------------------------------------------------------------------------+| Output Parameters : -                                                      |+----------------------------------------------------------------------------+| Return Value      :                INPUT :   					  0: No error                                            ||                    -1: The handle parameter of the board is wrong          ||                    -2: The module parameter is wrong                       ||                    -3: The module is not a digital I/O module              ||                    -4: Digital I/O not initialised                           				OUTPUT:	  0: No error                                            ||                    -1: The handle parameter of the board is wrong          ||                    -2: The module parameter is wrong                       ||                    -3: The module is not a digital I/O module              ||                    -4: Output value wrong                                  ||                    -5: digital I/O not initialised see function            ||                        " i_APCI1710_InitDigitalIO"                         ||                    -6: The digital channel A is used for input             ||                    -7: The digital channel B is used for input 					-8: Digital Output Memory OFF.                          ||                        Use previously the function                         ||                        "i_APCI1710_SetDigitalIOMemoryOn".               |+----------------------------------------------------------------------------+*///_INT_   i_APCI1710_SetDigitalIOPortOn   (BYTE_ b_BoardHandle,//					 BYTE_ b_ModulNbr,//					 BYTE_ b_PortValue)INT i_APCI1710_InsnBitsDigitalIOPortOnOff(comedi_device *dev,comedi_subdevice *s,	comedi_insn *insn,lsampl_t *data)	{	INT    i_ReturnValue = 0;	DWORD dw_WriteValue = 0;	DWORD dw_StatusReg;	BYTE b_ModulNbr,b_PortValue;        BYTE b_PortOperation,b_PortOnOFF;       PBYTE pb_PortValue;              	b_ModulNbr		= (BYTE) CR_AREF(insn->chanspec);	b_PortOperation = (BYTE) data[0];// Input or output 	b_PortOnOFF		= (BYTE) data[1];// if output then On or Off	b_PortValue		= (BYTE) data[2];// if out put then Value	i_ReturnValue	= insn->n;        pb_PortValue    = (PBYTE) &data[0];// if input then read value	    switch(b_PortOperation)	{    case APCI1710_INPUT  :	/**************************/	/* Test the module number */	/**************************/	if (b_ModulNbr < 4)	   {	   /*******************************/	   /* Test if digital I/O counter */	   /*******************************/	   if ((devpriv->s_BoardInfos.		dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_DIGITAL_IO)	      {	      /**********************************************/	      /* Test if the digital I/O module initialised */	      /**********************************************/	      if (devpriv->s_ModuleInfo [b_ModulNbr].		  s_DigitalIOInfo.b_DigitalInit == 1)		 {		 /**************************/		 /* Read all digital input */		 /**************************/		 //INPDW (ps_APCI1710Variable->		//	s_Board [b_BoardHandle].		//	s_BoardInfos.		//	ui_Address + (64 * b_ModulNbr),		//	&dw_StatusReg);          dw_StatusReg=inl(devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));		 *pb_PortValue = (BYTE) (dw_StatusReg ^ 0x1C);				 }	      else		 {		 /*******************************/		 /* Digital I/O not initialised */		 /*******************************/		 i_ReturnValue = -4;		 }	      }	   else	      {	      /******************************************/	      /* The module is not a digital I/O module */	      /******************************************/	      i_ReturnValue = -3;	      }	   }	else	   {	   /***********************/	   /* Module number error */	   /***********************/	   i_ReturnValue = -2;	   }       	  break;	case APCI1710_OUTPUT :	/**************************/	/* Test the module number */	/**************************/	if (b_ModulNbr < 4)	   {	   /*******************************/	   /* Test if digital I/O counter */	   /*******************************/	   if ((devpriv->s_BoardInfos.		dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_DIGITAL_IO)	      {	      /**********************************************/	      /* Test if the digital I/O module initialised */	      /**********************************************/	      if (devpriv->s_ModuleInfo [b_ModulNbr].		  s_DigitalIOInfo.		  b_DigitalInit == 1)		 {		 /***********************/		 /* Test the port value */		 /***********************/		 if (b_PortValue <= 7)		    {		    /***********************************/		    /* Test the digital output channel */		    /***********************************/		    /**************************/		    /* Test if channel A used */		    /**************************/		    if ((b_PortValue & 2) == 2)		       {		       if (devpriv->s_ModuleInfo [b_ModulNbr].			   s_DigitalIOInfo.			   b_ChannelAMode != 1)			  {			  /*******************************************/			  /* The digital channel A is used for input */			  /*******************************************/			  i_ReturnValue = -6;			  }		       } // if ((b_PortValue & 2) == 2)		    /**************************/		    /* Test if channel B used */		    /**************************/		    if ((b_PortValue & 4) == 4)		       {		       if (devpriv->s_ModuleInfo [b_ModulNbr].			   s_DigitalIOInfo.			   b_ChannelBMode != 1)			  {			  /*******************************************/			  /* The digital channel B is used for input */			  /*******************************************/			  i_ReturnValue = -7;			  }		       } // if ((b_PortValue & 4) == 4)		    /***********************/		    /* Test if error occur */		    /***********************/		    if (i_ReturnValue >= 0)		       {			   			  //if(data[1])			  //{               switch(b_PortOnOFF)               { 			   /*********************************/		       /* Test if set Port ON			*/		       /*********************************/			   case APCI1710_ON :		       /*********************************/		       /* Test if output memory enabled */		       /*********************************/		       if (devpriv->s_ModuleInfo [b_ModulNbr].			   s_DigitalIOInfo.			   b_OutputMemoryEnabled == 1)			  {			  dw_WriteValue = devpriv->s_ModuleInfo [b_ModulNbr].					  s_DigitalIOInfo.					  dw_OutputMemory | b_PortValue;			  devpriv->s_ModuleInfo [b_ModulNbr].			  s_DigitalIOInfo.dw_OutputMemory = dw_WriteValue;			  }		       else			  {			  dw_WriteValue = b_PortValue;			  }              break;			// If Set PORT  OFF  			case APCI1710_OFF:						   /*********************************/		       /* Test if output memory enabled */		       /*********************************/		       if (devpriv->s_ModuleInfo [b_ModulNbr].			   s_DigitalIOInfo.b_OutputMemoryEnabled == 1)			  {			  dw_WriteValue = devpriv->s_ModuleInfo [b_ModulNbr].					  s_DigitalIOInfo.					  dw_OutputMemory & (0xFFFFFFFFUL - b_PortValue);			  devpriv->s_ModuleInfo [b_ModulNbr].			  s_DigitalIOInfo.			  dw_OutputMemory = dw_WriteValue;			  }		       else			  {			  /*****************************/			  /* Digital Output Memory OFF */			  /*****************************/			  i_ReturnValue = -8;			  }			} // switch		       /*******************/		       /* Write the value */		       /*******************/		     //  OUTPDW (ps_APCI1710Variable->			 //      s_Board [b_BoardHandle].			 //      s_BoardInfos.			 //      ui_Address + (64 * b_ModulNbr),			 //      dw_WriteValue);				outl(dw_WriteValue,devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));		       }		    }		 else		    {		    /**********************/		    /* Output value wrong */		    /**********************/		    i_ReturnValue = -4;		    }		 }	      else		 {		 /*******************************/		 /* Digital I/O not initialised */		 /*******************************/		 i_ReturnValue = -5;		 }	      }	   else	      {	      /******************************************/	      /* The module is not a digital I/O module */	      /******************************************/	      i_ReturnValue = -3;	      }	   }	else	   {	   /***********************/	   /* Module number error */	   /***********************/	   i_ReturnValue = -2;	   }	break;	default:		i_ReturnValue = -9;		DPRINTK("NO INPUT/OUTPUT specified\n");  } //switch INPUT / OUTPUT	return (i_ReturnValue);}

⌨️ 快捷键说明

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