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

📄 hwdrv_apci3200.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/**@verbatimCopyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.                 ADDI-DATA GmbH         Dieselstrasse 3         D-77833 Ottersweier         Tel: +19(0)7223/9493-0         Fax: +49(0)7223/9493-92         http://www.addi-data-com         info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAYou shoud also find the complete GPL in the COPYING file accompanying this source code.@endverbatim*//*      +-----------------------------------------------------------------------+  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |  +-----------------------------------------------------------------------+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |  +-------------------------------+---------------------------------------+  | Project     : APCI-3200       | Compiler   : GCC                      |  | Module name : hwdrv_apci3200.c| Version    : 2.96                     |  +-------------------------------+---------------------------------------+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |  +-------------------------------+---------------------------------------+  | Description :   Hardware Layer Acces For APCI-3200                    |  +-----------------------------------------------------------------------+  |                             UPDATES                                   |  +----------+-----------+------------------------------------------------+  |   Date   |   Author  |          Description of updates                |  +----------+-----------+------------------------------------------------+  | 02.07.04 | J. Krauth | Modification from the driver in order to       |  |          |           | correct some errors when using several boards. |  |          |           |                                                |  |          |           |                                                |  +----------+-----------+------------------------------------------------+  | 26.10.04 | J. Krauth | - Update for COMEDI 0.7.68                     |  |          |           | - Read eeprom value                            |  |          |           | - Append APCI-3300                             |  +----------+-----------+------------------------------------------------+  *//*  +----------------------------------------------------------------------------+  |                               Included files                               |  +----------------------------------------------------------------------------+*/#include "hwdrv_apci3200.h"//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values#include "addi_amcc_S5920.h"//#define PRINT_INFO//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values//BEGIN JK 06.07.04: Management of sevrals boards/*  INT i_CJCAvailable=1;   INT i_CJCPolarity=0;  INT i_CJCGain=2;//changed from 0 to 2   INT i_InterruptFlag=0;  INT i_ADDIDATAPolarity;  INT i_ADDIDATAGain;                    INT i_AutoCalibration=0;   //: auto calibration    INT i_ADDIDATAConversionTime;  INT i_ADDIDATAConversionTimeUnit;   INT i_ADDIDATAType;  INT i_ChannelNo;  INT i_ChannelCount=0;  INT i_ScanType;  INT i_FirstChannel;  INT i_LastChannel;  INT i_Sum=0;  INT i_Offset;  UINT ui_Channel_num=0;  static int i_Count=0;  INT i_Initialised=0;  UINT ui_InterruptChannelValue[96]; //Buffer*/str_BoardInfos s_BoardInfos [100]; // 100 will be the max number of boards to be used//END JK 06.07.04: Management of sevrals boards//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values/*+----------------------------------------------------------------------------+*//*| Function   Name   : INT i_AddiHeaderRW_ReadEeprom                          |*//*|                               (INT    i_NbOfWordsToRead,                   |*/ /*|                                DWORD dw_PCIBoardEepromAddress,             |*//*|                                WORD   w_EepromStartAddress,                |*//*|                                PWORD pw_DataRead)                          |*//*+----------------------------------------------------------------------------+*//*| Task              : Read word from the 5920 eeprom.                        |*//*+----------------------------------------------------------------------------+*//*| Input Parameters  : INT    i_NbOfWordsToRead : Nbr. of word to read        |*/ /*|                     DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*//*|                     WORD   w_EepromStartAddress : Eeprom strat address     |*//*+----------------------------------------------------------------------------+*//*| Output Parameters : PWORD pw_DataRead : Read data                          |*/                                                     /*+----------------------------------------------------------------------------+*//*| Return Value      : -                                                      |*//*+----------------------------------------------------------------------------+*/INT i_AddiHeaderRW_ReadEeprom (INT    i_NbOfWordsToRead,                               DWORD dw_PCIBoardEepromAddress,                               WORD   w_EepromStartAddress,                               PWORD pw_DataRead){  DWORD dw_eeprom_busy=0;      INT i_Counter=0;	  INT i_WordCounter;  INT i;  BYTE pb_ReadByte[1];  BYTE b_ReadLowByte = 0;  BYTE b_ReadHighByte = 0;  BYTE b_SelectedAddressLow = 0;  BYTE b_SelectedAddressHigh = 0;  WORD w_ReadWord = 0;     for (i_WordCounter = 0;i_WordCounter<i_NbOfWordsToRead;i_WordCounter++)    {      do	{                           	  dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);	  dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;	}      while (dw_eeprom_busy==EEPROM_BUSY);      for(i_Counter=0;i_Counter<2;i_Counter++)        {	  b_SelectedAddressLow=(w_EepromStartAddress+i_Counter) % 256; //Read the low 8 bit part	  b_SelectedAddressHigh=(w_EepromStartAddress+i_Counter)/256;  //Read the high 8 bit part	  //Select the load low address mode	  outb (NVCMD_LOAD_LOW, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);	  //Wait on busy	  do	    {	      dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);	      dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;	    }	  while(dw_eeprom_busy==EEPROM_BUSY);	  //Load the low address	  outb(b_SelectedAddressLow, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);	  //Wait on busy	  do	    {	      dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);	      dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;	    }	  while(dw_eeprom_busy== EEPROM_BUSY);	  //Select the load high address mode	  outb(NVCMD_LOAD_HIGH, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);	  //Wait on busy	  do	    {	      dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);	      dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;	    }	  while(dw_eeprom_busy== EEPROM_BUSY);	  //Load the high address	  outb (b_SelectedAddressHigh, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);	  //Wait on busy	  do	    {	      dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);	      dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;	    }	  while(dw_eeprom_busy== EEPROM_BUSY);	  //Select the READ mode	  outb (NVCMD_BEGIN_READ, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);	  //Wait on busy	  do	    {	      dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);	      dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;	    }	  while(dw_eeprom_busy== EEPROM_BUSY);	  //Read data into the EEPROM	  *pb_ReadByte = inb (dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);	  //Wait on busy	  do	    {	      dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);	      dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;	    }	  while(dw_eeprom_busy== EEPROM_BUSY);	  //Select the upper address part	  if(i_Counter==0)	    {   b_ReadLowByte=pb_ReadByte[0];	    }else	    {   b_ReadHighByte=pb_ReadByte[0];	    }                	  //Sleep	  for (i=0; i < 10000; i++);   	}      w_ReadWord=(b_ReadLowByte|( ( (unsigned short) b_ReadHighByte) *256) );            pw_DataRead[i_WordCounter]=w_ReadWord;      w_EepromStartAddress +=2; // to read the next word	       } // for (...) i_NbOfWordsToRead  return (0);}/*+----------------------------------------------------------------------------+*//*| Function   Name   : VOID v_GetAPCI3200EepromCalibrationValue (VOID)        |*//*+----------------------------------------------------------------------------+*//*| Task              : Read calibration value from the APCI-3200 eeprom.      |*//*+----------------------------------------------------------------------------+*//*| Input Parameters  : -                                                      |*//*+----------------------------------------------------------------------------+*//*| Output Parameters : -                                                      |*//*+----------------------------------------------------------------------------+*//*| Return Value      : -                                                      |*//*+----------------------------------------------------------------------------+*/VOID v_GetAPCI3200EepromCalibrationValue (DWORD dw_PCIBoardEepromAddress,					  str_BoardInfos *BoardInformations){  WORD w_AnalogInputMainHeaderAddress;  WORD w_AnalogInputComponentAddress;  WORD w_NumberOfModuls = 0;  WORD w_CurrentSources [2];  WORD w_ModulCounter = 0;  WORD w_FirstHeaderSize = 0;  WORD w_NumberOfInputs = 0;  WORD w_CJCFlag = 0;  WORD w_NumberOfGainValue = 0;  WORD w_SingleHeaderAddress = 0;  WORD w_SingleHeaderSize = 0;  WORD w_Input = 0;  WORD w_GainFactorAddress = 0;  WORD w_GainFactorValue [2];  WORD w_GainIndex = 0;  WORD w_GainValue = 0;     /*****************************************/  /** Get the Analog input header address **/  /*****************************************/   i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead			     dw_PCIBoardEepromAddress,			     0x116,//w_EepromStartAddress: Analog input header address			     &w_AnalogInputMainHeaderAddress);          /*******************************************/  /** Compute the real analog input address **/  /*******************************************/  w_AnalogInputMainHeaderAddress = w_AnalogInputMainHeaderAddress + 0x100;   /******************************/  /** Get the number of moduls **/  /******************************/    i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead			     dw_PCIBoardEepromAddress,			     w_AnalogInputMainHeaderAddress + 0x02,//w_EepromStartAddress: Number of conponment			     &w_NumberOfModuls);  for (w_ModulCounter = 0; w_ModulCounter < w_NumberOfModuls; w_ModulCounter ++)    {      /***********************************/      /** Compute the component address **/      /***********************************/      w_AnalogInputComponentAddress = w_AnalogInputMainHeaderAddress + (w_FirstHeaderSize * w_ModulCounter) + 0x04;          	         /****************************/      /** Read first header size **/      /****************************/      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead				 dw_PCIBoardEepromAddress,				 w_AnalogInputComponentAddress, // Address of the first header  				 &w_FirstHeaderSize);                 w_FirstHeaderSize = w_FirstHeaderSize >> 4;      /***************************/      /** Read number of inputs **/      /***************************/      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead				 dw_PCIBoardEepromAddress,				 w_AnalogInputComponentAddress + 0x06, // Number of inputs for the first modul  				 &w_NumberOfInputs);      w_NumberOfInputs = w_NumberOfInputs >> 4;      /***********************/      /** Read the CJC flag **/      /***********************/      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead				 dw_PCIBoardEepromAddress,				 w_AnalogInputComponentAddress + 0x08, // CJC flag				 &w_CJCFlag);	         w_CJCFlag = (w_CJCFlag >> 3) & 0x1; // Get only the CJC flag

⌨️ 快捷键说明

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