/* //////////////////////////////////////////////////////////////////////////////// // Example usage of the MDE 8255 lab trainer // This program displays a light that runs back and forth // // Created by: Travis Sidelinger // Version History: // 2005Oct20 : created // 2005Oct23 : removed unused include // //////////////////////////////////////////////////////////////////////////////// */ /* Includes */ #include <stdio.h> #include <unistd.h> #include <mdedriverdll.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 */ MDEOpenLPTPort(0x378); /* Open LPT1 port */ MDEConfigPort(0x378, BaseConfig); /* Send command 80H to 8255 */ while(1) { MDEOutPB(0x378, c); /* Output to port B */ usleep(60000); if(c == 128) { m = 0; } if(c == 1) { m = 1; } if(m == 1) { c = c<<1; } if(m == 0) { c = c>>1; } } MDECloseDriver(); /* Close the driver */ /* End */ return(0); } /* SIGALRM Signal Handler */ void sigcatch(int signum) { printf("Closing the port\n"); MDECloseDriver(); /* Close the driver */ exit(0); }