/*============ pp_access.c ===================================== See pp_access.h for details. */ #include #include #include "pp_access.h" /*-------- init() -------------------------------------------- PURPOSE - given lp number 0-2, get lp base address, save registers, disable interrupts. */ void lp_init(short lp_num) { switch ( lp_num) { case 2 : lp_base_addr = 0x3BC ; break ; case 1 : lp_base_addr = 0x278 ; break ; default: lp_base_addr = 0x378 ; break ; } image_data = save_data = inb( lp_base_addr) ; image_control = save_control = inb( lp_base_addr+2) ; outb( (image_control &= 0xEF), lp_base_addr + control_offset) ; } /*--------- lp_restore() ------------------------------------ PURPOSE - restore lp port to previous state. */ void lp_restore() { outb( save_data, lp_base_addr) ; outb( save_control, lp_base_addr + control_offset) ; } //---------------- lp_base ----------------------------------- int lp_base() { return( lp_base_addr); } //--------- main : example code ------------------------------ /* int main(int argc, char *argv[]) { //--- save all registers and disable interrupts. lp_init( 0) ; //--- clear data bit 0 and set data bit 1, keep image updated. outb( (image_data &= 0xFE), lp_base_addr) ; outb( (image_data |= 0x02), lp_base_addr) ; printf(" Pin 2 (d0) is now low, pin 3 (d1) is now high.\n") ; //--- test if select or busy (inverted) is high. if ( inb( lp_base_addr+status_offset) & 0x10) printf(" Input bit select ( pin 13) is low.\n") ; else printf(" Input bit select ( pin 13) is high.\n") ; if ( inb( lp_base_addr+status_offset) & 0x80) printf(" Input bit busy ( pin 11) is high.\n") ; else printf(" Input bit busy ( pin 11) is low.\n") ; //--- pause till key pressed so can measure outputs. printf(" Press enter to continue ===> ") ; getchar() ; //--- restore control and data registers and exit. lp_restore() ; exit(0) ; } */