[an error occurred while processing this directive]
|
У меня под досом, взято из д-ра Доббса:
(в принципе, под нт тоже должно работать, если переделать под dpmi)
кстати, у атмела есть avr325 на эту тему
#include { 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)
E-mail:
info@telesys.ru
#include
#include
#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);
/*printf("\nEntry Address is %Fp", pointr);*/
_AH=1;
_DL=0;
_AL=0x04;
pointr();
temp_ah=_AH;
if(temp_ah != 0) return FALSE;
return TRUE;
}
{
unsigned char temp_ah;
_AH=7;
_DL=0;
_AL=tx_value;
pointr();
temp_ah=_AH;
if(temp_ah != 0) {return FALSE;}
return TRUE;
}
{
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;
}
{
unsigned char temp_ah;
_AH=9;
_DL=0;
pointr();
*rx_value=_AL;
temp_ah=_AH;
if(temp_ah != 0) {return FALSE;}
return TRUE;
}
{
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");
}
Ответы
Перейти к списку ответов
|||
Конференция
|||
Архив
|||
Главная страница
|||
Содержание