?? epp_io.c
字號:
/*epp_io.c*/
/*Set of Routines for Digital I/O using the Enhanced Parallel
Port. The routines invoke EPP BIOS calls.
Uses Turbo C 2.0 or better
Typical results:
Block transfer rates: 65 Mbytes in 73 secs on 486/66
*/
#include<dos.h>
#include<time.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define FALSE 0
#define TRUE 1
void far (*pointr)();
int epp_config(void);
int epp_write_byte(unsigned char tx_value);
int epp_write_block(unsigned char *source_ptr, int count);
int epp_read_byte(unsigned char *rx_value);
int epp_read_block(unsigned char *dest_ptr, int count);
int epp_config(void)
{
unsigned char temp_ah, temp_al, temp_cl, temp_ch;
_AX=0x0200;
_DX=0;
_CH='E';
_BL='P';
_BH='P';
geninterrupt(0x17);
temp_ah=_AH;
temp_al=_AL;
temp_ch=_CH;
temp_cl=_CL;
if(temp_ah != 0) return FALSE;
if(temp_al != 0x45) return FALSE;
if(temp_ch != 0x50) return FALSE;
if(temp_cl != 0x50) return FALSE;
pointr = MK_FP(_DX , _BX);
_AH=1;
_DL=0;
_AL=0x04;
pointr();
temp_ah=_AH;
if(temp_ah != 0) return FALSE;
return TRUE;
}
int epp_write_byte(unsigned char tx_value)
{
unsigned char temp_ah;
_AH=7;
_DL=0;
_AL=tx_value;
pointr();
temp_ah=_AH;
if(temp_ah != 0) {return FALSE;}
return TRUE;
}
int epp_write_block(unsigned char *source_ptr, int count)
{
unsigned char temp_ah;
_SI=FP_OFF(source_ptr);
_ES=FP_SEG(source_ptr);
_AH=8;
_DL=0;
_CX=count;
pointr();
temp_ah=_AH;
if(temp_ah != 0)
{printf("\nBlock write timeout error"); return FALSE;}
return TRUE;
}
int epp_read_byte(unsigned char *rx_value)
{
unsigned char temp_ah;
_AH=9;
_DL=0;
pointr();
*rx_value=_AL;
temp_ah=_AH;
if(temp_ah != 0) {return FALSE;}
return TRUE;
}
int epp_read_block(unsigned char *dest_ptr, int count)
{
unsigned char temp_ah;
_DI=FP_OFF(dest_ptr);
_ES=FP_SEG(dest_ptr);
_AH=0x0a;
_DL=0;
_CX=count;
pointr();
temp_ah=_AH;
if(temp_ah != 0) {return FALSE;}
return TRUE;
}
main()
{
int ret_value, ret_val;
time_t start, end;
unsigned char buf_out[10000], buf_in[10000], rx_in;
clrscr();
printf("Fast Digital I/O using the Enhanced Parallel Port");
printf("\nUses EPP BIOS Calls\nDhananjay V. Gadre\nJuly 1996");
ret_value = epp_config();
if(ret_value == FALSE) { printf("\nNo EPP"); exit(1);}
printf("\nEPP Present");
printf("\n\nWriting Data Byte");
ret_val = epp_write_byte(0xa5);
if (ret_val == TRUE) printf("\nWrite Byte Successful");
else printf("\nTimeout error");
printf("\n\nWriting Data Block");
start=time(NULL);
for(ret_value=0; ret_value<1000; ret_value++)
ret_val=epp_write_block(buf_out, 52428);
end=time(NULL);
printf("\nTime taken= %d seconds for 50 Mbytes", end-start);
printf("\n\nReading Data Byte..");
ret_val=epp_read_byte(&rx_in);
if (ret_val == TRUE)
printf("\nRead Data Byte Successful, %x", rx_in);
else printf("\nRead Data byte failed");
printf("\n\nReading Data Block..");
ret_val=epp_read_block(buf_in, 1000);
if (ret_val == TRUE) printf("\nRead Data Block Successful");
else printf("\nRead Data block failed");
return 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -