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

📄 apci1710_inp_cpt.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
		       /****************************************************/			   DPRINTK("Digital TRIGGER output action selection is wrong\n"); 			       i_ReturnValue = -5;		       }		    }		 else		    {		    /**********************************/		    /* Input level selection is wrong */		    /**********************************/		    DPRINTK("Input level selection is wrong\n");		    i_ReturnValue = -4;		    }		 }	      else		 {		 /************************************/		 /* Pulse encoder selection is wrong */		 /************************************/		 DPRINTK("Pulse encoder selection is wrong\n");		 i_ReturnValue = -3;		 }	      }	   else	      {	      /********************************************/	      /* The module is not a pulse encoder module */	      /********************************************/	      DPRINTK("The module is not a pulse encoder module\n");		      i_ReturnValue = -2;	      }	   }	else	   {	   /********************************************/	   /* The module is not a pulse encoder module */	   /********************************************/	   DPRINTK("The module is not a pulse encoder module\n");		   i_ReturnValue = -2;	   }	return (i_ReturnValue);	}/*+----------------------------------------------------------------------------+| Function Name     : _INT_ i_APCI1710_EnablePulseEncoder                    ||                                       (BYTE_  b_BoardHandle,               ||                                        BYTE_  b_ModulNbr,                  ||                                        BYTE_  b_PulseEncoderNbr,           ||                                        BYTE_  b_CycleSelection,            ||                                        BYTE_  b_InterruptHandling)         |+----------------------------------------------------------------------------+| Task              : Enableor disable  the selected pulse encoder (b_PulseEncoderNbr)  ||                     from selected module (b_ModulNbr). Each input pulse    ||                     decrement the pulse encoder counter value from 1.      ||                     If you enabled the interrupt (b_InterruptHandling), a  ||                     interrupt is generated when the pulse encoder has run  ||                     down.                                                  |+----------------------------------------------------------------------------+| Input Parameters  : BYTE_   b_BoardHandle       : Handle of board APCI-1710||                     BYTE_   b_ModulNbr          : Module number to         ||                                                   configure (0 to 3)       ||                     BYTE_   b_PulseEncoderNbr   : Pulse encoder selection  ||                                                   (0 to 3)                 ||                     BYTE_   b_CycleSelection    : APCI1710_CONTINUOUS:     ||                                                       Each time the        ||                                                       counting value is set||                                                       on "0", the pulse    ||                                                       encoder load the     ||                                                       start value after    ||                                                       the next pulse.      ||                                                   APCI1710_SINGLE:         ||                                                       If the counter is set||                                                       on "0", the pulse    ||                                                       encoder is stopped.  ||                     BYTE_   b_InterruptHandling : Interrupts can be        ||                                                   generated, when the pulse||                                                   encoder has run down.    ||                                                   With this parameter the  ||                                                   user decides if          ||                                                   interrupts are used or   ||                                                   not.                     ||                                                     APCI1710_ENABLE:       ||                                                     Interrupts are enabled ||                                                     APCI1710_DISABLE:      ||                                                     Interrupts are disabled  	b_ModulNbr			=(BYTE) CR_AREF(insn->chanspec);	b_Action			=(BYTE) data[0];	b_PulseEncoderNbr	=(BYTE) data[1];	b_CycleSelection	=(BYTE) data[2];	b_InterruptHandling	=(BYTE) data[3];|+----------------------------------------------------------------------------+| Output Parameters : -                                                      |+----------------------------------------------------------------------------+| Return Value      :  0: No error                                           ||                     -1: The handle parameter of the board is wrong         ||                     -2: Module selection is wrong                          ||                     -3: Pulse encoder selection is wrong                   ||                     -4: Pulse encoder not initialised.                     ||                         See function "i_APCI1710_InitPulseEncoder"         ||                     -5: Cycle selection mode is wrong                      ||                     -6: Interrupt handling mode is wrong                   ||                     -7: Interrupt routine not installed.                   ||                         See function "i_APCI1710_SetBoardIntRoutineX"      |+----------------------------------------------------------------------------+*/ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(comedi_device *dev,comedi_subdevice *s,	comedi_insn *insn,lsampl_t *data)	{	INT    i_ReturnValue = 0;	BYTE  b_ModulNbr;	BYTE  b_PulseEncoderNbr	;	BYTE  b_CycleSelection	;	BYTE  b_InterruptHandling;	BYTE  b_Action;	i_ReturnValue		=insn->n;	b_ModulNbr			=(BYTE) CR_AREF(insn->chanspec);	b_Action			=(BYTE) data[0];	b_PulseEncoderNbr	=(BYTE) data[1];	b_CycleSelection	=(BYTE) data[2];	b_InterruptHandling	=(BYTE) data[3];       	/***********************************/	/* Test the selected module number */	/***********************************/	if (b_ModulNbr <= 3)	   {	   /******************************************/	   /* Test the selected pulse encoder number */	   /******************************************/	   if (b_PulseEncoderNbr <= 3)	      {	      /*************************************/	      /* Test if pulse encoder initialised */	      /*************************************/	      if (devpriv->s_ModuleInfo [b_ModulNbr].		  s_PulseEncoderModuleInfo.		  s_PulseEncoderInfo [b_PulseEncoderNbr].		  b_PulseEncoderInit == 1)		 {			switch(b_Action)			{			case APCI1710_ENABLE:		 /****************************/		 /* Test the cycle selection */		 /****************************/		 if (b_CycleSelection == APCI1710_CONTINUOUS || b_CycleSelection == APCI1710_SINGLE)		    {		    /*******************************/		    /* Test the interrupt handling */		    /*******************************/		    if (b_InterruptHandling == APCI1710_ENABLE || b_InterruptHandling == APCI1710_DISABLE)		       {		       /******************************/		       /* Test if interrupt not used */		       /******************************/		       if (b_InterruptHandling == APCI1710_DISABLE)			  {			  /*************************/			  /* Disable the interrupt */			  /*************************/			  devpriv->s_ModuleInfo [b_ModulNbr].			  s_PulseEncoderModuleInfo.			  dw_SetRegister = devpriv->s_ModuleInfo [b_ModulNbr].					   s_PulseEncoderModuleInfo.					   dw_SetRegister & (0xFFFFFFFFUL - (1UL << b_PulseEncoderNbr));			  }		       else			  {									     /************************/			     /* Enable the interrupt */			     /************************/			     devpriv->s_ModuleInfo [b_ModulNbr].			     s_PulseEncoderModuleInfo.			     dw_SetRegister = devpriv->s_ModuleInfo [b_ModulNbr].					      s_PulseEncoderModuleInfo.					      dw_SetRegister | (1UL << b_PulseEncoderNbr);				devpriv->tsk_Current=current; // Save the current process task structure			   			  }		       if (i_ReturnValue>=0)			  {			  /***********************************/			  /* Enable or disable the interrupt */			  /***********************************/			  				outl(devpriv->s_ModuleInfo [b_ModulNbr].				  s_PulseEncoderModuleInfo.				  dw_SetRegister,devpriv->s_BoardInfos.				  ui_Address + 20 + (64 * b_ModulNbr));			  /****************************/			  /* Enable the pulse encoder */			  /****************************/			  devpriv->s_ModuleInfo [b_ModulNbr].			  s_PulseEncoderModuleInfo.			  dw_ControlRegister = devpriv->s_ModuleInfo [b_ModulNbr].					       s_PulseEncoderModuleInfo.					       dw_ControlRegister | (1UL << b_PulseEncoderNbr);			  /**********************/			  /* Set the cycle mode */			  /**********************/			  devpriv->s_ModuleInfo [b_ModulNbr].			  s_PulseEncoderModuleInfo.			  dw_ControlRegister = (devpriv->s_ModuleInfo [b_ModulNbr].						s_PulseEncoderModuleInfo.						dw_ControlRegister & (0xFFFFFFFFUL - (1 << (b_PulseEncoderNbr + 4)))) |						((b_CycleSelection & 1UL) << (4 + b_PulseEncoderNbr));			  /****************************/			  /* Enable the pulse encoder */			  /****************************/			  			  outl(devpriv->s_ModuleInfo [b_ModulNbr].				  s_PulseEncoderModuleInfo.				  dw_ControlRegister,devpriv->s_BoardInfos.				  ui_Address + 16 + (64 * b_ModulNbr));			  }		       }		    else		       {		       /************************************/		       /* Interrupt handling mode is wrong */		       /************************************/			   DPRINTK("Interrupt handling mode is wrong\n");		       i_ReturnValue = -6;		       }		    }		 else		    {		    /*********************************/		    /* Cycle selection mode is wrong */		    /*********************************/			DPRINTK("Cycle selection mode is wrong\n");		    i_ReturnValue = -5;		    }		 break;

⌨️ 快捷键说明

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