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

📄 apci1710_inccpt.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
				BYTE          b_CounterRange,				BYTE          b_FirstCounterModus,				BYTE          b_FirstCounterOption,				BYTE          b_SecondCounterModus,				BYTE          b_SecondCounterOption)	{	INT    i_ReturnValue = 0;			/*******************************/	/* Test if incremental counter */	/*******************************/	if ((devpriv->s_BoardInfos.	     dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER)	   {	   /**************************/	   /* Test the counter range */	   /**************************/	   if (b_CounterRange == APCI1710_16BIT_COUNTER || b_CounterRange == APCI1710_32BIT_COUNTER)	      {	      /********************************/	      /* Test the first counter modus */	      /********************************/	      if (b_FirstCounterModus == APCI1710_QUADRUPLE_MODE ||		  b_FirstCounterModus == APCI1710_DOUBLE_MODE    ||		  b_FirstCounterModus == APCI1710_SIMPLE_MODE    ||		  b_FirstCounterModus == APCI1710_DIRECT_MODE)		 {		 /*********************************/		 /* Test the first counter option */		 /*********************************/		 if ((b_FirstCounterModus   == APCI1710_DIRECT_MODE   &&		      (b_FirstCounterOption == APCI1710_INCREMENT     ||		       b_FirstCounterOption == APCI1710_DECREMENT))   ||		     (b_FirstCounterModus   != APCI1710_DIRECT_MODE   &&		      (b_FirstCounterOption == APCI1710_HYSTERESIS_ON ||		       b_FirstCounterOption == APCI1710_HYSTERESIS_OFF)))		    {		    /**************************/		    /* Test if 16-bit counter */		    /**************************/		    if (b_CounterRange == APCI1710_16BIT_COUNTER)		       {		       /*********************************/		       /* Test the second counter modus */		       /*********************************/		       if ((b_FirstCounterModus != APCI1710_DIRECT_MODE      &&			    (b_SecondCounterModus == APCI1710_QUADRUPLE_MODE ||			     b_SecondCounterModus == APCI1710_DOUBLE_MODE    ||			     b_SecondCounterModus == APCI1710_SIMPLE_MODE))  ||			   (b_FirstCounterModus == APCI1710_DIRECT_MODE &&			    b_SecondCounterModus == APCI1710_DIRECT_MODE))			  {			  /**********************************/			  /* Test the second counter option */			  /**********************************/			  if ((b_SecondCounterModus   == APCI1710_DIRECT_MODE   &&			       (b_SecondCounterOption == APCI1710_INCREMENT     ||				b_SecondCounterOption == APCI1710_DECREMENT))   ||			      (b_SecondCounterModus   != APCI1710_DIRECT_MODE   &&			       (b_SecondCounterOption == APCI1710_HYSTERESIS_ON ||				b_SecondCounterOption == APCI1710_HYSTERESIS_OFF)))			     {			     i_ReturnValue = 0;			     }			  else			     {			     /*********************************************************/			     /* The selected second counter operating option is wrong */			     /*********************************************************/                        DPRINTK("The selected second counter operating option is wrong\n");			     i_ReturnValue = -7;			     }			  }		       else			  {			  /*******************************************************/			  /* The selected second counter operating mode is wrong */			  /*******************************************************/			  DPRINTK("The selected second counter operating mode is wrong\n");			  i_ReturnValue = -6;			  }		       }		    }		 else		    {		    /********************************************************/		    /* The selected first counter operating option is wrong */		    /********************************************************/                   DPRINTK("The selected first counter operating option is wrong\n");		    i_ReturnValue = -5;		    }		 }	      else		 {		 /******************************************************/		 /* The selected first counter operating mode is wrong */		 /******************************************************/                 DPRINTK("The selected first counter operating mode is wrong\n");		 i_ReturnValue = -4;		 }	      }	   else	      {	      /***************************************/	      /* The selected counter range is wrong */	      /***************************************/             DPRINTK("The selected counter range is wrong\n");	      i_ReturnValue = -3;	      }	   /*************************/	   /* Test if a error occur */	   /*************************/	   if (i_ReturnValue == 0)	      {	      /**************************/	      /* Test if 16-Bit counter */	      /**************************/	      if (b_CounterRange == APCI1710_32BIT_COUNTER)		 {		 devpriv->		 s_ModuleInfo [b_ModulNbr].		 s_SiemensCounterInfo.		 s_ModeRegister.		 s_ByteModeRegister.		 b_ModeRegister1 = b_CounterRange      |				   b_FirstCounterModus |				   b_FirstCounterOption;		 }	      else		 {		 devpriv->		 s_ModuleInfo [b_ModulNbr].		 s_SiemensCounterInfo.		 s_ModeRegister.		 s_ByteModeRegister.		 b_ModeRegister1 = b_CounterRange                 |				   (b_FirstCounterModus   & 0x5)  |				   (b_FirstCounterOption  & 0x20) |				   (b_SecondCounterModus  & 0xA)  |				   (b_SecondCounterOption & 0x40);		 /***********************/		 /* Test if direct mode */		 /***********************/		 if (b_FirstCounterModus == APCI1710_DIRECT_MODE)		    {		    devpriv->		    s_ModuleInfo [b_ModulNbr].		    s_SiemensCounterInfo.		    s_ModeRegister.		    s_ByteModeRegister.		    b_ModeRegister1 = devpriv->				      s_ModuleInfo [b_ModulNbr].				      s_SiemensCounterInfo.				      s_ModeRegister.				      s_ByteModeRegister.				      b_ModeRegister1 | APCI1710_DIRECT_MODE;		    }		 }	      /***************************/	      /* Write the configuration */	      /***************************/	   		  outl(devpriv->s_ModuleInfo [b_ModulNbr].		      s_SiemensCounterInfo.		      s_ModeRegister.		      dw_ModeRegister1_2_3_4,			  devpriv->s_BoardInfos.		      ui_Address + 20 + (64 * b_ModulNbr));	      devpriv->	      s_ModuleInfo [b_ModulNbr].	      s_SiemensCounterInfo.	      s_InitFlag.	      b_CounterInit = 1;	      }	   }	else	   {	   /**************************************/	   /* The module is not a counter module */	   /**************************************/          DPRINTK("The module is not a counter module\n");	   i_ReturnValue = -2;	   }	return (i_ReturnValue);	}/*+----------------------------------------------------------------------------+| Function Name     : _INT_ i_APCI1710_CounterAutoTest                       ||                                               (BYTE_     b_BoardHandle,    ||                                                PBYTE_   pb_TestStatus)     |+----------------------------------------------------------------------------+| Task              : A test mode is intended for testing the component and  ||                     the connected periphery. All the 8-bit counter chains  ||                     are operated internally as down counters.              ||                     Independently from the external signals,               ||                     all the four 8-bit counter chains are decremented in   ||                     parallel by each negative clock pulse edge of CLKX.    ||                                                                            ||                       Counter auto test conclusion                         ||                       ----------------------------                         ||              +-----------------+-----------------------------+             ||              | pb_TestStatus   |    Error description        |             ||              |     mask        |                             |             ||              |-----------------+-----------------------------|             ||              |    0000         |     No error detected       |             ||              |-----------------|-----------------------------|             ||              |    0001         | Error detected of counter 0 |             ||              |-----------------|-----------------------------|             ||              |    0010         | Error detected of counter 1 |             ||              |-----------------|-----------------------------|             ||              |    0100         | Error detected of counter 2 |             ||              |-----------------|-----------------------------|             ||              |    1000         | Error detected of counter 3 |             ||              +-----------------+-----------------------------+             |+----------------------------------------------------------------------------+| Input Parameters  : BYTE_   b_BoardHandle : Handle of board APCI-1710      |  |+----------------------------------------------------------------------------+| Output Parameters : PBYTE_ pb_TestStatus  : Auto test conclusion. See table|+----------------------------------------------------------------------------+| Return Value      :  0: No error                                           ||                     -1: The handle parameter of the board is wrong         ||                     -2: No counter module found                            |+----------------------------------------------------------------------------+*/INT  i_APCI1710_CounterAutoTest  (comedi_device *dev,PBYTE   pb_TestStatus)	{	BYTE   b_ModulCpt    = 0;	INT    i_ReturnValue = 0;	DWORD dw_LathchValue;			*pb_TestStatus = 0;	/********************************/	/* Test if counter module found */	/********************************/	if ((devpriv->	     s_BoardInfos.	     dw_MolduleConfiguration [0] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER ||	    (devpriv->	     s_BoardInfos.	     dw_MolduleConfiguration [1] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER ||	    (devpriv->	     s_BoardInfos.	     dw_MolduleConfiguration [2] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER||	    (devpriv->	     s_BoardInfos.	     dw_MolduleConfiguration [3] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER)	   {	   for (b_ModulCpt = 0; b_ModulCpt < 4 ; b_ModulCpt ++)	      {	      /*******************************/	      /* Test if incremental counter */	      /*******************************/	      if ((devpriv->		   s_BoardInfos.		   dw_MolduleConfiguration [b_ModulCpt] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER)		 {		 /******************/		 /* Start the test */		 /******************/		 			outl(3,devpriv->s_BoardInfos.			 ui_Address + 16 + (64 * b_ModulCpt));		 /*********************/		 /* Tatch the counter */		 /*********************/		 			outl(1,devpriv->s_BoardInfos.			 ui_Address + (64 * b_ModulCpt));		 /************************/		 /* Read the latch value */		 /************************/					dw_LathchValue=inl(devpriv->s_BoardInfos.			ui_Address + 4 + (64 * b_ModulCpt));		 if ((dw_LathchValue & 0xFF) != ((dw_LathchValue >> 8)  & 0xFF) &&		     (dw_LathchValue & 0xFF) != ((dw_LathchValue >> 16) & 0xFF) &&		     (dw_LathchValue & 0xFF) != ((dw_LathchValue >> 24) & 0xFF))		    {		    *pb_TestStatus = *pb_TestStatus | (1 << b_ModulCpt);		    }		 /*****************/		 /* Stop the test */

⌨️ 快捷键说明

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