Tim Waugh (tim@cyberelk.demon.co.uk)
Tue, 4 Jan 2000 21:02:46 +0000 (GMT)
On Tue, 4 Jan 2000, chris wrote:
> I would like to know whether or not if there is a way to use the
> ppdev in EPP mode utilizing interrupts or is it only in ECP mode.
I don't think EPP really provides interrupts, though I'm not looking at a
spec so I might be wrong.
> If it is in only in ECP mode, I would like to know where I could
> find an example of an interrupt service routine with the ppdev
> user-spaced driver.
The closest you can get is PPWCTLONIRQ -- it sets up a trigger response.
Basically, you tell ppdev what you want the control lines to do when an
interrupt occurs. The ISR is inside the ppdev driver, and it just sets
the lines as requested. You can use PPCLRIRQ to check whether an
interrupt has arrived (or you can use select()).
Like this:
/* Wait for an interrupt, or until tv has elapsed. */
static int await_irq (int fd, struct timeval *tv)
{
fd_set rfds;
FD_ZERO (&rfds);
FD_SET (fd, &rfds);
return !select (fd + 1, &rfds, NULL, NULL, tv);
}
[...]
for (;;)
{
int irqc;
int busy = nAck | nFault;
int acking = nFault;
int ready = Busy | nAck | nFault;
char ch;
/* Set up the control lines when an interrupt happens. */
ioctl (fd, PPWCTLONIRQ, &busy);
/* Now we're ready. */
ioctl (fd, PPWCONTROL, &ready);
if (await_irq (fd, NULL))
/* Caught a signal? */
continue;
/* We are now marked as busy. */
/* Fetch the data. */
ioctl (fd, PPRDATA, &ch);
/* Clear the interrupt. */
ioctl (fd, PPCLRIRQ, &irqc);
if (irqc > 1)
fprintf (stderr, "Arghh! Missed %d interrupt%s!\n", irqc - 1,
irqc == 2 ? "s" : "");
/* Ack it. */
ioctl (fd, PPWCONTROL, &acking);
usleep (2);
ioctl (fd, PPWCONTROL, &busy);
putchar (ch);
}
-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2.0b3 on Tue 04 Jan 2000 - 16:25:31 EST