/*
////////////////////////////////////////////////////////////////////////////////
// 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);
    }
/var/www/sites/dokuwiki-2011-05-25a/data/pages/projects/libmdedriver/runner.c.txt · Last modified: 2009/04/11 22:23 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki