#include <stdio.h>
void main() {
int fd;
fd=open("/dev/lpv", O_RDWR); [ See NOTE ]
// Enable interrupt
while(1) {
// Wait for irq (blocking read)
}
// Disable interrupt
close(fd);
}
[ NOTE ]
//
// irq.c
//
#include <fcntl.h>
#include <sys/ioctl.h>
#include "lpv.h"
int i,j;
unsigned char buff;
if(fd<0){
perror("/dev/lpv: could not open ");
exit(-1);
}
ioctl(fd,LPV_IRQ,LPV_ENABLE);
read(fd,&buff,1);
// Generate pulse in bit 1 of LPV_OUT
write(fd,"1",1);
for(j=0;j<10000;j++);
write(fd,"3",1);
ioctl(fd,LPV_IRQ,LPV_DISABLE);
/dev/lpv is a very simple parallel port driver.
See code.