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

📄 apci1710_dig_io.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
		 /* Test if the digital I/O module initialised */		 /**********************************************/		 if (devpriv->s_ModuleInfo[b_ModulNbr].s_DigitalIOInfo.b_DigitalInit == 1)		    {		    /**********************************/		    /* Test if channel A or channel B */		    /**********************************/		    if (b_InputChannel > 4)		       {		       /*********************/		       /* Test if channel A */		       /*********************/		       if (b_InputChannel == 5)			  {			  /***************************/			  /* Test the channel A mode */			  /***************************/			  if (devpriv->s_ModuleInfo [b_ModulNbr].s_DigitalIOInfo.b_ChannelAMode != 0)			     {			     /********************************************/			     /* The digital channel A is used for output */			     /********************************************/			     i_ReturnValue = -6;			     }			  } // if (b_InputChannel == 5)		       else			  {			  /***************************/			  /* Test the channel B mode */			  /***************************/			  if (devpriv->s_ModuleInfo [b_ModulNbr].s_DigitalIOInfo.b_ChannelBMode != 0)			     {			     /********************************************/			     /* The digital channel B is used for output */			     /********************************************/			     i_ReturnValue = -7;			     }			  } // if (b_InputChannel == 5)		       } // if (b_InputChannel > 4)		    /***********************/		    /* Test if error occur */		    /***********************/		    if (i_ReturnValue >= 0)		       {		       /**************************/		       /* 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_ChannelStatus = (BYTE) ((dw_StatusReg ^ 0x1C) >> b_InputChannel) & 1;                        		       } // if (i_ReturnValue == 0)		    }		 else		    {		    /*******************************/		    /* Digital I/O not initialised */		    /*******************************/			DPRINTK("Digital I/O not initialised\n");		    i_ReturnValue = -5;		    }		 }	      else		 {		 /********************************/		 /* Selected digital input error */		 /********************************/         	 DPRINTK("Selected digital input error\n"); 		 i_ReturnValue = -4;		 }	      }	   else	      {	      /******************************************/	      /* The module is not a digital I/O module */	      /******************************************/		  DPRINTK("The module is not a digital I/O module\n"); 	      i_ReturnValue = -3;	      }	   }	else	   {	   /***********************/	   /* Module number error */	   /***********************/		DPRINTK("Module number error\n"); 	   i_ReturnValue = -2;	   }	return (i_ReturnValue);	}/*+----------------------------------------------------------------------------+|                            OUTPUT FUNCTIONS                                |+----------------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+| Function Name     : INT i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device |*dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)+----------------------------------------------------------------------------+| Task              : Sets or resets the output witch has been passed with the         ||                     parameter b_Channel. Setting an output means setting   ||                     an ouput high.                                         |+----------------------------------------------------------------------------+| Input Parameters  : BYTE_ b_BoardHandle   : Handle of board APCI-1710      ||                     BYTE_ b_ModulNbr (aref )    : Selected module number (0 to 3)||                     BYTE_ b_OutputChannel (CR_CHAN) : Selection from digital output  ||                                             channel (0 to 2)               ||                                                0 : Channel H               ||                                                1 : Channel A               ||                                                2 : Channel B               |+----------------------------------------------------------------------------+| 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 digital I/O module              ||                    -4: The selected digital output is 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_SetDigitalIOChlOn    (BYTE_ b_BoardHandle,//					 BYTE_ b_ModulNbr,//					 BYTE_ b_OutputChannel)INT i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device *dev,comedi_subdevice *s,	comedi_insn *insn,lsampl_t *data)	{	INT    i_ReturnValue = 0;	DWORD dw_WriteValue  = 0;	BYTE b_ModulNbr,b_OutputChannel;	i_ReturnValue	=	insn->n; 	b_ModulNbr		=   CR_AREF(insn->chanspec);  	b_OutputChannel =   CR_CHAN(insn->chanspec);  			/**************************/	/* 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 digital output channel number */		 /******************************************/		 switch (b_OutputChannel)		    {		    /*************/		    /* Channel H */		    /*************/		    case 0:			 break;		    /*************/		    /* Channel A */		    /*************/		    case 1:			 if (devpriv->s_ModuleInfo [b_ModulNbr].			     s_DigitalIOInfo.			     b_ChannelAMode != 1)			    {			    /*******************************************/			    /* The digital channel A is used for input */			    /*******************************************/			    i_ReturnValue = -6;			    }			 break;		    /*************/		    /* Channel B */		    /*************/		    case 2:			 if (devpriv->s_ModuleInfo [b_ModulNbr].			     s_DigitalIOInfo.			     b_ChannelBMode != 1)			    {			    /*******************************************/			    /* The digital channel B is used for input */			    /*******************************************/			    i_ReturnValue = -7;			    }			 break;		    default :			 /****************************************/			 /* The selected digital output is wrong */			 /****************************************/			 i_ReturnValue = -4;			 break;		    }		 /***********************/		 /* Test if error occur */		 /***********************/		 if (i_ReturnValue >= 0)		    {            			 			/*********************************/		    /* Test if set channel ON        */		    /*********************************/				 if(data[0])			 {		 		    /*********************************/		    /* 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 | (1 << b_OutputChannel);		       devpriv->s_ModuleInfo [b_ModulNbr].		       s_DigitalIOInfo.		       dw_OutputMemory = dw_WriteValue;		       }		    else		       {		       dw_WriteValue = 1 << b_OutputChannel;		       }			 } // set channel off             else			 {				if (devpriv->s_ModuleInfo [b_ModulNbr].			s_DigitalIOInfo.			b_OutputMemoryEnabled == 1)		       {		       dw_WriteValue = devpriv->s_ModuleInfo [b_ModulNbr].				       s_DigitalIOInfo.				       dw_OutputMemory & (0xFFFFFFFFUL - (1 << b_OutputChannel));		       devpriv->s_ModuleInfo [b_ModulNbr].s_DigitalIOInfo.dw_OutputMemory = dw_WriteValue;		       }		    else		       {		       /*****************************/		       /* Digital Output Memory OFF */		       /*****************************/			   // +Use previously the function "i_APCI1710_SetDigitalIOMemoryOn"		       i_ReturnValue = -8;		       }             }		    /*******************/		    /* 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		 {		 /*******************************/		 /* 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;	   }	return (i_ReturnValue);

⌨️ 快捷键说明

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