/* * This file is part of the coreboot project. * * Copyright (C) 2008 Joseph Smith * * 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 */ /* This is a simple program that tests the data lines by turning on * LED's attached to it starting at 0 and ending at 7. * * build test program with: * gcc -O2 -o para_led para_led.c */ #include #include #include #include #include #include int main() { int fd, mode, i; unsigned char status, data; /* Get the file descriptor for the parallel port */ fd = open("/dev/parport0",O_RDWR); if (fd == -1) { perror("open"); exit(1); } /* Request access to the port */ if (ioctl(fd,PPCLAIM)) { perror("PPCLAIM"); close(fd); exit(1); } /* Configure the port for SPP mode */ mode = IEEE1284_MODE_COMPAT; if (ioctl(fd, PPNEGOT, &mode)) { perror ("PPNEGOT"); close (fd); return 1; } /* Clear the data lines just in case */ ioctl (fd, PPWDATA, 0); /* Set the data lines */ for (i = 0; i < 7; i++) { data = i + 1; ioctl (fd, PPWDATA, &data); sleep(2); data = 0; ioctl (fd, PPWDATA, &data); } /* Release the port */ ioctl (fd, PPRELEASE); /* Close the device file */ close(fd); }