/*
################################################################################
# Basic example of MDE8255-1 LPT usage
# This program read the data from port A
#
# Created by: Travis Sidelinger <travis@ilive4code.net>
#
# Version History:
#   2005Oct23 : 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 = 0;
    static unsigned int  i = 0;
 
    /* Main */
    signal(SIGINT, sigcatch);           /* set the timer catch */
 
    printf("Opening the port\n");
    ioperm(PORT0,3,1);
 
    printf("Setting the hardware to read from port C\n");
    outb(0x8F, PORT0);  /* put the device in input mode on all ports */
    outb(0x0F, PORT2);  /* control bits */
    outb(0x07, PORT2);  /* control bits */
    outb(0x0F, PORT2);  /* control bits */
 
    while(1)
    {
        /* Get data from A */
        //outb(0x0C, PORT2); /* control bits */
        //outb(0x28, PORT2); /* control bits */
        //c = inb(PORT0);    /* read port c  */
        //outb(0x2C, PORT2); /* control bits */
        //outb(0x0C, PORT2); /* control bits */
 
        /* Get data from C */
        outb(0x0D, PORT2);
        outb(0x29, PORT2);
        c = inb(PORT0);
        outb(0x2D, PORT2);
        outb(0x0D, PORT2);
 
        printf("Reading port C: %x\n", c);
        sleep(1);
        }
 
    /* End */
    return(0);
    }
 
/* SIGALRM Signal Handler */
void sigcatch(int signum)
{
    printf("Closing the port\n");
    ioperm(PORT0,3,0);
    exit(0);
    }
 
/var/www/sites/dokuwiki/data/pages/projects/libmdedriver/raw-read.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