⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8255_epp.c

📁 _计算实用教程Visual C++6.0实用教程
💻 C
字号:
/*8255_epp.c*/          /*Set of Routines for Parallel Port expander using the Enhanced Parallel Port protocol for 8255-PPIO. The routines invoke EPP BIOS calls.     Dhananjay V. Gadre*/     #include<dos.h>#include<time.h>#include<stdio.h>#include<process.h>#include<conio.h>     #define FALSE 0#define TRUE 1     /*Define the Port addresses of the 8255-PPIO*/     #define PORT_A  0x04#define PORT_B  0x0c#define PORT_C  0x14#define CON_PORT    0x1c          void far (*pointr)();int epp_config(void);int epp_write_block(unsigned char *source_ptr, int count);int epp_writea_writed(unsigned char port_address, unsigned char tx_value); int epp_writea(unsigned char port_address);int epp_write_byte(unsigned char tx_value);          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_writea(unsigned char port_address) {unsigned char temp_ah;_AH=5;_DL=0;_AL=port_address;pointr();temp_ah=_AH;if(temp_ah != 0) {return FALSE;}return TRUE;}          int epp_writea_writed(unsigned char port_address, unsigned char tx_value) {unsigned char temp_ah;_AH=0x0c;_DL=0;_AL=port_address;_DH= tx_value;pointr();temp_ah=_AH;if(temp_ah != 0) {return FALSE;}return TRUE;}     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_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;}     main(){int  ret_value, ret_val;time_t start, end;unsigned char buf_out[10000], rx_in;     clrscr();printf("\nPort Expander using 8255-PPIO and EPP protocol\n"); ret_value = epp_config();if(ret_value == FALSE) { printf("\nNo EPP BIOS"); exit(1);} printf("\nEPP BIOS Present");          printf("\nGenerating a Square wave on Port C bits of the PPIO");     printf("\nSetting address and transmitting a data byte");     if( epp_writea(CON_PORT) == FALSE ){printf("\nSet address failed.."); exit(1);}     /*writing 0x80 to Control port puts all the three port of the 8255 in Output mode */if(epp_write_byte(0x80) == FALSE){printf("\nWrite command byte failed.."); exit(1);}     while(!kbhit()){          if(epp_writea_writed(PORT_C, 0) == FALSE) {printf("\nWrite data byte failed.."); exit(1);}          if(epp_writea_writed(PORT_C, 0xff) == FALSE) {printf("\nWrite data byte failed.."); exit(1);}     }          /*Another way to access the 8255 data ports. Set the destination address once and then keeping writing data to the destination port*/     /*Set Port B Address*/if( epp_writea(PORT_B) == FALSE ){printf("\nSet address failed.."); exit(1);}     while(!kbhit()){     /*write 0x00 to the Port B of the 8255*/ if(epp_write_byte(0) == FALSE){printf("\nWrite data byte failed.."); exit(1);}          /*Write 0xff to the Port B of the 8255*/ if(epp_write_byte(0xff) == FALSE){printf("\nWrite data byte failed.."); exit(1); }     }     /*Transferring data to Port B using block transfer mode*/ printf("\n\nWriting Data Block to the last address");if (epp_write_block(buf_out, 10000) == TRUE ) printf("\nBlock write successful");else printf("\nBlock write failed");     return 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -