www.pudn.com > paratest.rar > paratest.c
#include#include #include #include #include #include #include #include /* #define DATA_PORT 0x378 #define STATUS_PORT 0x379 #define CONTROL_PPORT 0x37a #define DEV_IRQ 0x7 */ char ch; void PrintprortInit(); void readpara(); /*void Parall_Send_Data(unsigned char data_parall); */ unsigned char print_state(); int print_ch(char ch); int print_ch(char ch) /*向并口中写入数据*/ { int ret; if(print_state()!=0) { sysOutByte(0x37a,sysInByte(0x37a)|0x1); sysOutByte(0x378,ch); sysOutByte(0x37a,sysInByte(0x37a)&0xfe);/*?????怎么是读控制口呢?应该是状态口吧0x379??*/ ret=0; } else ret=-1; return ret; } unsigned char print_state() { unsigned char state; state=sysInByte(0x379) & 0x80; return state; } void readpara() { char ch; sysOutByte(0x37a,0x20|(sysInByte(0x37a))); ch=sysInByte(0x378); printf("\nin123\n"); printf("\nch=%x\n",ch); sysOutByte(0x37a,0xdf &(sysInByte(0x37a))); sysInByte(0x379); } void PrintprortInit() { intConnect(INUM_TO_IVEC(0x20+0x7),readpara,0); printf("\njello\n"); sysOutByte(0x37a,0X10 |(sysInByte(0x37a))); } /* void Output() { int i; for(i=0; i<1000;i++) { sysOutByte(0x37a,0x10 |(sysInByte(0x37a))); sysOutByte(0x378,i); taskDelay(sysClkRateGet()*1); sysOutByte(0x37a,0xf0 &(sysInByte(0x37a))); } }*/