/* * example.c: very simple example of port I/O * * This code does nothing useful, just a port write, a pause, * and a port read. Compile with `gcc -O2 -o example example.c', * and run as root with `./example'. */ #include #include #include #define BASEPORT 0x2a2 /* PLC-730 card LED Output */ int main() { int x; unsigned char y[] = {0x76,0x79,0x38,0x38,0x3f}; /* Get access to the ports */ if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);} for(x=0;x<500;x++) { /* Set the data signals (D0-7) of the port to all low (0) */ outb(y[x%5], BASEPORT+1); /* Sleep for a while (100 ms) */ usleep(1000000); outb(0, BASEPORT+1); usleep(2000); } /* We don't need the ports anymore */ if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);} exit(0); } /* end of example.c */