📄 7166csbb.c
字号:
#include <conio.h> /* 此头函数请不要删除 */
#include <dos.h>
#include <stdio.h>
#include <bios.h>
#define IRQ_NUMBER 9
#define F1 0x3B00
#define F2 0x3C00
#define F3 0x3d00
#define ENTER 0x1c0d
void readdat();
int key=0;
int pr=0;
int key1=0;
long far *fptr;
unsigned char data[3]={0,0,0};
static char data1[300]={0,0,0};
/* 开中断*/
/*中断向量表 */
void readdat()
{
printf("Have entered interrupt!\n");
pr=inportb(0x263);
if(pr==0)
{
}
else
{
outportb(0x26f,0x03); /*SEND CNTR TO OL*/
data[0]=inportb(0x26e); /*READ OL*/
data[1]=inportb(0x26e);
data[2]=inportb(0x26e);
outportb(0x26f,0x09); /*RESET CNTR*/
}
// key=1;
}
/*中断处理程序 */
void interrupt far readdata_handler()
{
disable();
// readdat();
key1=1;
outportb(0xA0,0x20);/* 中断结束命令*/
outportb(0x20,0x20);
enable();
}
void (interrupt far *oldhandler)();
void main()
{
int i,j,k,m,cin,CR1,d,d1,ch,f,PR0,PR1,PR2,in,amp=0x00ff;
ch=1;PR0=0;PR1=0,PR2=0; d1=1;
/*INITIALIZE 7166_1*/
printf("INITIALIZE 7166_1 START!!\n");
outportb(0x26d,0x01); /*INITIALIZE MCR*/
outportb(0x26d,0x51); /*INITIALIZE ICR*/
outportb(0x26d,0x80); /*INITIALIZE OCCR*/
outportb(0x26d,0xc0); /*INITIALIZE QR*/
outportb(0x26d,0x01);
outportb(0x26c,0x00); /*INITIALIZE PR0*/
outportb(0x26c,0x00); /*INITIALIZE PR1*/
outportb(0x26c,0x80); /*INITIALIZE PR2*/
outportb(0x26d,0x09); /*SEND PR TO CNTR*/
printf("7166_1 INITIALIZE COMPLETED!!\n");
outportb(0x26d,0x03); /*SEND CNTR TO OL*/
PR0=inportb(0x26c); /*READ PR0*/
PR1=inportb(0x26c); /*READ PR1*/
PR2=inportb(0x26c); /*READ PR2*/
printf("7166_1:PR0=%d, PR1=%d, PR2=%d\n",PR0,PR1,PR2);
/*INITIALIZE 7166_2*/
printf("INITIALIZE 7166_2 START!!\n");
outportb(0x26f,0x01); /*INITIALIZE MCR*/
outportb(0x26f,0x51); /*INITIALIZE ICR*/
outportb(0x26f,0x80); /*INITIALIZE OCCR*/
outportb(0x26f,0xc0); /*INITIALIZE QR*/
outportb(0x26f,0x01);
outportb(0x26e,0x00); /*INITIALIZE PR0*/
outportb(0x26e,0x00); /*INITIALIZE PR1*/
outportb(0x26e,0x80); /*INITIALIZE PR2*/
outportb(0x26f,0x09); /*SEND PR TO CNTR*/
printf("7166_2 INITIALIZE COMPLETED!!\n");
outportb(0x26f,0x03); /*SEND CNTR TO OL*/
PR0=inportb(0x26e); /*READ PR0*/
PR1=inportb(0x26e); /*READ PR1*/
PR2=inportb(0x26e); /*READ PR2*/
printf("7166_2:PR0=%d, PR1=%d, PR2=%d\n",PR0,PR1,PR2);
printf("\n");
while(d1)
{
do
{printf("input the data :\n");
while(bioskey(1)==0);
cin=bioskey(0);
cin=cin&-0x30;
if (cin>0&&cin<6)
{outportb(0x2a8,cin);
printf("\n");
printf("the input is %d\n",cin);
printf("the %d route sigal is selceted !!\n",cin);
}
else
printf("the input is not valid!!!\n");
if(cin>0&&cin<6)
d=0;
else
d=1;
}while(d);
disable();
/*EnableIRQ(irq_number,1);*/
oldhandler=getvect(IRQ2Vector(IRQ_NUMBER));
setvect(IRQ2Vector(IRQ_NUMBER),readdata_handler);
EnableIRQ(IRQ_NUMBER,1);
enable();
ch=1;
while(ch) /* !kbhit() */
{
k=0;
while(k<100)
{
if(key1==1)
{
readdat();
data1[k]=data[0];
data1[k+1]=data[1];
data1[k+2]=data[2];
k=k+1;
key1=0;
}
}
m=0;
printf("PRESS ANY KEY TO SHOW NEXT RESULT!!\n");
while(m<100)
{
printf("the %d result is :%d%d%d\n",m+1,data1[m+2],data1[m+1],data1[m]);
m=m+1;
getch();
}
printf("if you want change the input signal please press F1!!\n");
printf("else press any key\n");
ch=bioskey(0);
if(ch==0x3B00)
ch=0;
else
ch=1;
}
setvect(IRQ2Vector(IRQ_NUMBER),oldhandler);
EnableIRQ(IRQ_NUMBER,0);
printf("\n");
printf("Program is paused!\n");
/*getch();
getch();*/
printf("If you want end program please press F3 !!\n");
printf("CHARNGE THE SIGNAL ROUTE PRESS ANY KEY GO ON!!\n");
f=bioskey(0);
if(f==0x3d00)
d1=0;
else
d1=1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -