📄 pci.all
字号:
}
else
{
ucTotalMask = inportb(0xa1);
ucIrqMask = ucTotalMask & ~(0x01 << (iIrqNum-8));
outportb(0xa1, ucTotalMask & ~(0x01<<(iIrqNum-8)));
}
//
// 5. ENABLE PC INTERRUPT
//
enable();
return(ucIrqMask);
}//InitInterrupt
/**************************************************************
* Function: Restore system ISR.
* Paramater: iIrqNum, IN, IRQ number
* ucIrqMask, IN, IRQ mask before install ISR
* pOldIsr, IN, Old ISR. restore it as service routine.
*
**************************************************************/
void RestoreOldIsr( int iIrqNum,
byte ucIrqMask,
void interrupt (*pOldIsr)() )
{
byte ucTotalMask;
disable();
if ( iIrqNum < 8 )
{
ucTotalMask = (inportb(0x21) & ~(0x01<<iIrqNum)) | ucIrqMask;
outportb(0x21, ucTotalMask);
setvect(iIrqNum+8, pOldIsr);
}
else
{
ucTotalMask = (inportb(0xa0) & ~(0x01<<(iIrqNum-8))) | ucIrqMask;
outportb(0xa1, ucTotalMask);
setvect(iIrqNum-8+0x70, pOldIsr);
}
enable();
}
/**************************************************************
* Function : IrqHandler
* Interrupt service routine for pDAQ-722 DI interrupt.
* fucntion.
**************************************************************/
void interrupt IrqHandler(void)
{
byte ucRegVal;
//Clear Interrupt
outportb(gdwBaseAddrCs1, 0x00);
disable();
//Determined this interrupt source.
ucRegVal = inportb( gdwBaseAddr+giIntControlRegAddr);
if( ucRegVal & giIrqFlagBit)
glIntCount++;
//Clear interrupt
outportb(gdwBaseAddr+giIntControlRegAddr, ucRegVal);
//Enable system to accept next interrupt
outportb(0x20,0x20);
if ( giIrqNum > 7 )
outportb(0xa0,0x20);
enable();
}//IrqHandler
/*
'**********************************************************************
'* Program : DI.C *
'* Revision : 1.00 *
'* Date : 6/17/2002 Arbor Technology Co., Ltd. *
'*====================================================================*
'* *
'* This demo program performs Digital Input of pDAQ-720/722/722E *
'* *
'**********************************************************************
*/
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include "PCI.C"
#include "pDAQ722.h"
void main(void)
{
word wVendorId, wDeviceId, wIndex;
int iErrCode;
byte ucBusNumber, ucDevAndFunc;
dword dwData, dwBaseAddr;
int i;
int iPort;
wVendorId = VENDOR_ID;
wDeviceId = DEVICE_ID;
//Description
clrscr();
printf("Arbor Technolog Corp.\n");
printf("\npDAQ-720/722/722E Digital Input DOS demo program.");
printf("\nFirst, connect desired signal to CN1");
printf("\n DI0: DI_A0 (pin 30) and DI_B0 (pin 12)");
printf("\n DI1: DI_A1 (pin 31) and DI_B1 (pin 13)");
printf("\n DI2: DI_A2 (pin 32) and DI_B2 (pin 14)");
printf("\n DI3: DI_A3 (pin 33) and DI_B3 (pin 15)");
printf("\n DI4: DI_A4 (pin 34) and DI_B4 (pin 16)");
printf("\n DI5: DI_A5 (pin 35) and DI_B5 (pin 17)");
printf("\n DI6: DI_A6 (pin 36) and DI_B6 (pin 18)");
printf("\n DI7: DI_A7 (pin 37) and DI_B7 (pin 19)\n");
printf("\n DIn means digital input channel n.\n\n");
printf("Press any key to continue...");
getch();
clrscr();
/***************************
* Get pDAQ-72x's resource
***************************/
//
// Search pDAQ-72x
//
for( wIndex=0; wIndex < 32; wIndex++)
{
iErrCode = find_pci_device(
wDeviceId,
wVendorId,
wIndex,
&ucBusNumber,
&ucDevAndFunc );
if (iErrCode == NOT_SUCCESSFUL )
{
printf("\n pDAQ-720/722 search fail.\n");
exit(1);
}
iErrCode = read_configuration_dword(
ucBusNumber,
ucDevAndFunc,
PCI_CS_SUBSYSTEM_ID,
&dwData);
if(dwData == SUBSYSTEM_ID)
break;
}
//
//Get base address, from PCI base address range 2
//
iErrCode = read_configuration_dword(
ucBusNumber,
ucDevAndFunc,
PCI_CS_BASE_ADDRESS_2,
&dwData);
if (iErrCode == NOT_SUCCESSFUL)
{
printf("\npDAQ-72x gets base address failure.\n");
exit(1);
}
else
dwBaseAddr = dwData & 0xfffffffc;
/************
* Read DI data from port
************/
//Select pDAQ-72x card number 0-3
do
{
printf("Choose the Input digital data from port[0-3]:");
scanf("%d",&iPort);
}while(iPort > 3 || iPort < 0);
//Read Relay Status
printf("\nCheck current Relay status.");
outportb(dwBaseAddr+(iPort+4), 0);
for (i=0; i < 2 ; i++)
{
printf("\nPress any key to test Relay output and readback...");
getch();
outportb(dwBaseAddr+(iPort*2), 0x55 << i);
delay(100);
printf("\nRelay Port %d data = %xh", iPort, inportb(dwBaseAddr+(iPort*2)));
}
printf("\n\nPress any key to start DI reading...");
getch();
//Read data from digital isolation in
printf("\nPress any key to stop DI funciton....\n");
while(!kbhit())
{
gotoxy(1, wherey());
printf("Digital in Port %d data = %xh", iPort, inportb(dwBaseAddr+(iPort*2+1)));
delay(300);
}
getch();
}
/*
'**********************************************************************
'* Program : DO.C *
'* Revision : 1.00 *
'* Date : 6/17/2002 Arbor Technology Corp. *
'*====================================================================*
'* *
'* This demo program performs pDAQ-720/722/722E *
'* *
'**********************************************************************
*/
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include "pDAQ722.h"
#include "PCI.C"
#define STR_INFO "Current relay output: "
void main(void)
{
word wVendorId, wDeviceId, wIndex;
int iErrCode, i;
byte ucBusNumber, ucDevAndFunc;
dword dwData, dwBaseAddr;
int iOffset;
word wOutData;
wVendorId = VENDOR_ID;
wDeviceId = DEVICE_ID;
clrscr();
//Description
printf("Arbor Technology Corp.\n");
printf("\npDAQ-720/722/722E Digital Out DOS demo program.");
printf("\nBefore running this program you should:");
printf("\nConnect desired signal to CN1");
printf("\n RELAY1 : NO0 (pin 1), COM0 (pin 2) and NC0 (pin 3)");
printf("\n RELAY2 : NO1 (pin 4), COM1 (pin 5) and NC1 (pin 6)");
printf("\n RELAY3 : NO2 (pin 7), COM2 (pin 8) and NC2 (pin 9)");
printf("\n RELAY4 : NO3 (pin 20), COM3 (pin 21) and NC3 (pin 22)");
printf("\n RELAY5 : NO4 (pin 23), COM4 (pin 24)");
printf("\n RELAY6 : NO5 (pin 25), COM5 (pin 26)");
printf("\n RELAY7 : NO6 (pin 27), COM6 (pin 28)");
printf("\n RELAY8 : NO7 (pin 10), COM7 (pin 11)");
printf("\n\nNCx, x=0-3: Normal close pin of relay x.");
printf("\nNOx, x=0-7: Normal open pin of relay x.");
printf("\nCOMx, x=0-7: Common pin of relay x.");
printf("\n\n");
/***************************
* Get pDAQ-72x's resource
***************************/
//
// Search pDAQ-72x
//
for( wIndex=0; wIndex < 32; wIndex++)
{
iErrCode = find_pci_device(
wDeviceId,
wVendorId,
wIndex,
&ucBusNumber,
&ucDevAndFunc );
if (iErrCode == NOT_SUCCESSFUL )
{
printf("\n pDAQ-720/722 search fail.\n");
exit(1);
}
iErrCode = read_configuration_dword(
ucBusNumber,
ucDevAndFunc,
PCI_CS_SUBSYSTEM_ID,
&dwData);
if(dwData == SUBSYSTEM_ID)
break;
}
//
//Get base address, from PCI base address range 2
//
iErrCode = read_configuration_dword(
ucBusNumber,
ucDevAndFunc,
PCI_CS_BASE_ADDRESS_2,
&dwData);
if (iErrCode == NOT_SUCCESSFUL)
{
printf("\npDAQ-72x gets base address failure.\n");
exit(1);
}
else
dwBaseAddr = dwData & 0xfffffffc;
/************
* Output data to DO port
************/
//
// Select pDAQ-722 card number 0-3
//
do
{
printf("\nChoose the Output digital data to port [0-3]:");
scanf("%d",&iOffset);
}while(iOffset > 3 || iOffset < 0);
iOffset += iOffset;
printf("Press ESC key to quit this program.\n");
//
// Output data to relay cyclicly
//
printf("\n%s", STR_INFO);
wIndex = 0;
do{
wOutData = inportb(dwBaseAddr+iOffset)+1;
outportb(dwBaseAddr+iOffset, wOutData);
//The relay action needs 10ms.
//DOS system support 100ms delay min.
delay(10);
wOutData = inportb(dwBaseAddr+iOffset);
gotoxy(sizeof(STR_INFO), wherey());
for(i=0; i < 8; i++)
{
if(wOutData & 0x80)
putch('1');
else
putch('0');
wOutData <<= 1;
}
delay(500);
if(kbhit())
wIndex = getch();
}while(wIndex != ESC);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -