ICP DAS USA PCI-P16POR16 User Manual

Page of 48
 
 
Please refer to the following program code to get these six base addresses for 
PCI-P16R16 and PCI-P8R8. These codes are based on PCI Plug & Play 
mechanism 2. 
 
/******************************************************/ 
/* Reading PCI card's configuration address space                          */ 
/******************************************************/ 
WORD   GetAddress(void) 

  DWORD   dConfigAddress,dBaseAddress; 
  WORD    HiWord,LoWord; 
  WORD    ReturnCode; 
  UCHAR   Bus,Device,Function,WhichLong; 
  WORD    VendorID,DeviceID; 
  WORD    wIrqNumber; 
 
  wTotalBoards=0;   /* initial board number is 0 */ 
  Bus=0; 
  for(Bus=0; Bus<10;  Bus++) 
  { 
    Function=0; 
    WhichLong=1; 
    for(Device=0;  Device<32;  Device++) 
    { 
       WhichLong=0; 
       WriteAddress(Bus,Device,Function,WhichLong); 
       VendorID=inport(0xcfc); 
       DeviceID=inport(0xcfe); 
 
       if( VendorID==0x1234 && DeviceID==0x1616 ) 
       {  /*----------- PCI-P16R16 --------------* 
   WhichLong=4;   // Base Address 0 
 
 
  WriteAddress(Bus,Device,Function,WhichLong); 
   dBaseAddress=_inpd(0xcfc); 
 
 
  wBaseAddr0=(WORD)(dBaseAddress&0xfffe); 
 wConfigSpace[wTotalBoards][0]=wBaseAddr0; 
 
PCI-P8R8/P16R16/P16C16/P16POR16 User’s Manual  (Ver.2.2, 2005/5/5) …
30