/* ################################################################################ # Basic example of MDE8255-1 LPT usage # This program flashes the LEDs on port B # # Created by: Travis Sidelinger <travis@ilive4code.net> # # Version History: # 2005Oct22 : initial release # # Copyright: # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################################################################################ */ #define PORT0 0x378 #define PORT2 0x37A // Includes #include <stdio.h> #include <unistd.h> #include <sys/io.h> #include <signal.h> /* Fucntion Declarations */ static void sigcatch(int signum); /* SIGALRM Signal Handler */ int main(void) { /* Variables */ static unsigned char c = 1; static char m = 1; /* Main */ signal(SIGINT, sigcatch); /* set the timer catch */ printf("Opening the port\n"); ioperm(PORT0,3,1); printf("Setting the hardware mode to output on B\n"); outb(0x80, PORT0); /* put the device in output mode */ outb(0x0F, PORT2); /* control bits */ outb(0x07, PORT2); /* control bits */ outb(0x0F, PORT2); /* control bits */ while(1) { printf("Toggling B\n"); outb(0x55, PORT0); /* data 55h */ outb(0x0E, PORT2); /* control bits */ outb(0x06, PORT2); /* control bits */ outb(0x0E, PORT2); /* control bits */ sleep(1); printf("Toggling B\n"); outb(0xAA, PORT0); /* data AAh */ outb(0x0E, PORT2); /* control bits */ outb(0x06, PORT2); /* control bits */ outb(0x0E, PORT2); /* control bits */ sleep(1); } /* End */ return(0); } /* SIGALRM Signal Handler */ void sigcatch(int signum) { printf("Closing the port\n"); ioperm(PORT0,3,0); exit(0); }