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

📄 hwdrv_apci3200.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
      /*******************************/      /** Read number of gain value **/      /*******************************/      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead				 dw_PCIBoardEepromAddress,				 w_AnalogInputComponentAddress + 0x44, // Number of gain value				 &w_NumberOfGainValue);      w_NumberOfGainValue = w_NumberOfGainValue & 0xFF;      /***********************************/      /** Compute single header address **/      /***********************************/      w_SingleHeaderAddress = w_AnalogInputComponentAddress + 0x46 + (((w_NumberOfGainValue / 16) + 1) * 2) + (6 * w_NumberOfGainValue) + (4 * (((w_NumberOfGainValue / 16) + 1) * 2));      /********************************************/      /** Read current sources value for input 1 **/      /********************************************/      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead				 dw_PCIBoardEepromAddress,				 w_SingleHeaderAddress ,//w_EepromStartAddress: Single header address				 &w_SingleHeaderSize);      w_SingleHeaderSize = w_SingleHeaderSize >> 4;      /*************************************/      /** Read gain factor for the module **/      /*************************************/      w_GainFactorAddress = w_AnalogInputComponentAddress;       for (w_GainIndex = 0; w_GainIndex < w_NumberOfGainValue; w_GainIndex++)	{	  /************************************/	  /** Read gain value for the module **/ 	  /************************************/	  i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead				     dw_PCIBoardEepromAddress,				     w_AnalogInputComponentAddress + 70 + (2 * (1 + ( w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex), // Gain value				     &w_GainValue);	  BoardInformations->s_Module [w_ModulCounter].w_GainValue [w_GainIndex] = w_GainValue;               #             ifdef PRINT_INFO 	  printk ("\n Gain value = %d", BoardInformations->s_Module [w_ModulCounter].w_GainValue [w_GainIndex]);#             endif	  /*************************************/	  /** Read gain factor for the module **/	  /*************************************/	  i_AddiHeaderRW_ReadEeprom (2, //i_NbOfWordsToRead				     dw_PCIBoardEepromAddress,				     w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + ( w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex), // Gain factor				     w_GainFactorValue);                       	  BoardInformations->s_Module [w_ModulCounter].ul_GainFactor [w_GainIndex] = (w_GainFactorValue [1] << 16) + w_GainFactorValue [0]; #             ifdef PRINT_INFO               	  printk ("\n w_GainFactorValue [%d] = %lu", w_GainIndex, BoardInformations->s_Module [w_ModulCounter].ul_GainFactor [w_GainIndex]);                                   #             endif	}      /***************************************************************/      /** Read current source value for each channels of the module **/      /***************************************************************/      for (w_Input = 0; w_Input < w_NumberOfInputs; w_Input++)	{	  /********************************************/	  /** Read current sources value for input 1 **/	  /********************************************/	  i_AddiHeaderRW_ReadEeprom (2, //i_NbOfWordsToRead				     dw_PCIBoardEepromAddress,				     (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress + 0x0C,				     w_CurrentSources);              	  /************************************/	  /** Save the current sources value **/	  /************************************/	  BoardInformations->s_Module [w_ModulCounter].ul_CurrentSource [w_Input] = (w_CurrentSources [0] + ((w_CurrentSources [1] & 0xFFF) << 16));   #             ifdef PRINT_INFO 	  printk ("\n Current sources [%d] = %lu", w_Input, BoardInformations->s_Module [w_ModulCounter].ul_CurrentSource [w_Input]);                      #             endif 	}                  /***************************************/      /** Read the CJC current source value **/      /***************************************/      i_AddiHeaderRW_ReadEeprom (2, //i_NbOfWordsToRead				 dw_PCIBoardEepromAddress,				 (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress + 0x0C,				 w_CurrentSources);	         /************************************/      /** Save the current sources value **/      /************************************/      BoardInformations->s_Module [w_ModulCounter].ul_CurrentSourceCJC = (w_CurrentSources [0] + ((w_CurrentSources [1] & 0xFFF) << 16));   	       #          ifdef PRINT_INFO       printk ("\n Current sources CJC = %lu", BoardInformations->s_Module [w_ModulCounter].ul_CurrentSourceCJC);                      #          endif    }}INT i_APCI3200_GetChannelCalibrationValue (comedi_device *dev, unsigned int ui_Channel_num, lsampl_t *CJCCurrentSource, 					   lsampl_t *ChannelCurrentSource, 					   lsampl_t *ChannelGainFactor) {   int i_DiffChannel = 0;  int i_Module = 0; #ifdef PRINT_INFO   printk ("\n Channel = %u", ui_Channel_num);#endif  //Test if single or differential mode     if (s_BoardInfos [dev->minor].i_ConnectionType == 1)    {             //if diff         if((ui_Channel_num >=0) && (ui_Channel_num <=1))	i_DiffChannel=ui_Channel_num, i_Module = 0;       else	if((ui_Channel_num >=2) && (ui_Channel_num <=3))	  i_DiffChannel=ui_Channel_num-2, i_Module = 1; 	else	  if((ui_Channel_num >=4) && (ui_Channel_num <=5))	    i_DiffChannel=ui_Channel_num-4, i_Module = 2; 	  else	    if((ui_Channel_num >=6) && (ui_Channel_num <=7))	      i_DiffChannel=ui_Channel_num-6, i_Module = 3;           }  else    {            // if single      if((ui_Channel_num == 0) || (ui_Channel_num == 1))	i_DiffChannel=0, i_Module = 0;       else	if((ui_Channel_num == 2) || (ui_Channel_num == 3))	  i_DiffChannel=1, i_Module = 0; 	else      	  if((ui_Channel_num == 4) || (ui_Channel_num == 5))	    i_DiffChannel=0, i_Module = 1; 	  else	    if((ui_Channel_num == 6) || (ui_Channel_num == 7))	      i_DiffChannel=1, i_Module = 1;       	    else      	      if((ui_Channel_num == 8) || (ui_Channel_num == 9))		i_DiffChannel=0, i_Module = 2; 	      else		if((ui_Channel_num == 10) || (ui_Channel_num == 11))		  i_DiffChannel=1, i_Module = 2;   		else      		  if((ui_Channel_num == 12) || (ui_Channel_num == 13))		    i_DiffChannel=0, i_Module = 3; 		  else		    if((ui_Channel_num == 14) || (ui_Channel_num == 15))		      i_DiffChannel=1, i_Module = 3;                      }                                    //Test if thermocouple or RTD mode  *CJCCurrentSource = s_BoardInfos [dev->minor].s_Module[i_Module].ul_CurrentSourceCJC;#ifdef PRINT_INFO   printk ("\n CJCCurrentSource = %lu", *CJCCurrentSource);#endif        *ChannelCurrentSource = s_BoardInfos [dev->minor].s_Module[i_Module].ul_CurrentSource [i_DiffChannel];#ifdef PRINT_INFO 	   printk ("\n ChannelCurrentSource = %lu", *ChannelCurrentSource);#endif	   //      }      //   }                  //Channle gain factor   *ChannelGainFactor = s_BoardInfos [dev->minor].s_Module[i_Module].ul_GainFactor [s_BoardInfos [dev->minor].i_ADDIDATAGain];	  #ifdef PRINT_INFO      printk ("\n ChannelGainFactor = %lu", *ChannelGainFactor);  #endif     //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values        return (0);      }//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values/*  +----------------------------------------------------------------------------+  | Function   Name   : int i_APCI3200_ReadDigitalInput                       |  |			  (comedi_device *dev,comedi_subdevice *s,               |   |                      comedi_insn *insn,lsampl_t *data)                     |  +----------------------------------------------------------------------------+  | Task              : Read  value  of the selected channel or port           |  +----------------------------------------------------------------------------+  | Input Parameters  : comedi_device *dev      : Driver handle                |  |                     UINT ui_NoOfChannels    : No Of Channels To read  for Port     Channel Numberfor single channel  |                     UINT data[0]            : 0: Read single channel  1: Read port value     data[1]              Port number         +----------------------------------------------------------------------------+  | Output Parameters :	--	data[0] :Read status value  +----------------------------------------------------------------------------+  | Return Value      : TRUE  : No error occur                                 |  |		            : FALSE : Error occur. Return the error          |  |			                                                         |  +----------------------------------------------------------------------------+*/INT i_APCI3200_ReadDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) {   UINT ui_Temp=0;  UINT ui_NoOfChannel=0;  ui_NoOfChannel=CR_CHAN(insn->chanspec);  ui_Temp=data[0];  *data=inl(devpriv->i_IobaseReserved);      if  (ui_Temp==0)    {      *data=(*data >> ui_NoOfChannel)&0x1;     } //if  (ui_Temp==0)  else    {      if  (ui_Temp==1)	{	  if(data[1] < 0 || data[1] >1)	    {	      printk("\nThe port number is in error\n");	      return -EINVAL;	    }//if(data[1] < 0 || data[1] >1)	  switch( ui_NoOfChannel)	    {	    case 2:	      *data=(*data >>(2*data[1]))&0x3;  	      break;	    case 3:	      *data=(*data & 15 ); 	      break;	    default:	      comedi_error(dev," chan spec wrong");	      return -EINVAL;   // "sorry channel spec wrong "                   	    }//switch(ui_NoOfChannels)    	}//if  (ui_Temp==1)      else	{	  printk("\nSpecified channel not supported \n");	}//elseif  (ui_Temp==1)    }    return insn->n;}/*  +----------------------------------------------------------------------------+  | Function   Name   : int i_APCI3200_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                     |  |			  data[0]  :1  Memory enable  0  Memory Disable														   +----------------------------------------------------------------------------+  | Output Parameters :	--													 |  +----------------------------------------------------------------------------+  | Return Value      : TRUE  : No error occur                                 |  |		            : FALSE : Error occur. Return the error			 |  |																	 |  +----------------------------------------------------------------------------+*/int i_APCI3200_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){   if  ( (data[0]!=0) && (data[0]!=1) )     {         comedi_error(dev,"Not a valid Data !!! ,Data should be 1 or 0\n");        return -EINVAL;    }//if  ( (data[0]!=0) && (data[0]!=1) )   if  (data[0])    {      devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE ;     }// if  (data[0])  else    {      devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;    }//else if  (data[0])  return insn->n;}/*  +----------------------------------------------------------------------------+  | Function   Name   : int i_APCI3200_WriteDigitalOutput                      |  |			  (comedi_device *dev,comedi_subdevice *s,				 |   |                      comedi_insn *insn,lsampl_t *data)                     |  +----------------------------------------------------------------------------+  | Task              : writes To the digital Output Subdevice                 |  +----------------------------------------------------------------------------+  | Input Parameters  : comedi_device *dev      : Driver handle                |  |                     comedi_subdevice *s     : Subdevice Pointer            |    |                     comedi_insn *insn       : Insn Structure Pointer       |    |                     lsampl_t *data          : Data Pointer contains        |  |                                          configuration parameters as below |  |                     data[0]             :Value to output  data[1]             : 0 o/p single channel  1 o/p port  data[2]             : port no  data[3]             :0 set the digital o/p on  1 set the digital o/p off 	  +----------------------------------------------------------------------------+  | Output Parameters :	--													 |  +----------------------------------------------------------------------------+

⌨️ 快捷键说明

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