[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: [rtl] linux push-button
You should probably read http://www.doc.ic.ac.uk/~ih/doc/par
Peter
Paul Kienzle wrote:
>
> First, let me thank all those who responded to my request for keyboard
> control under RTL. Now I know the I don't need to use RTL.
>
> I'm still having problems implementing a parallel port push button as
> suggested. From what I've read, if I write 1 to bit 8 of the data port
> and short pin 9 to pin 10, this should raise 1 on bit 7 of the status
> port (ACK), leaving the resto of the bits low. However, bits 1-7 are
> all high regardless of the button state. My button does indeed connect
> pin 9 to pin 10 when it is pressed, so that's not the problem. My
> program agrees with the BIOS setting for the port number, so I don't
> think that's the problem. I'm including the code here just in case
> I've done something obviously stupid. I've tried the three standard
> port numbers (378, 278, 3bc). The status byte reads 7f regardless of
> whether the button is pushed (at least for port 378 --- for the other
> ports it reads ff).
>
> I haven't ever used the parallel port on this computer, and certainly
> not under linux. Is this possibly a configuration problem?
>
> ---------------------------------------------------------------------
> /* Program to test a parallel port push button. */
> #include <stdio.h>
> #include <unistd.h>
> #include <asm/io.h>
>
> #define LPT_BASE 0x378
> #define LPT_DATA (LPT_BASE)
> #define LPT_STATUS (LPT_BASE+1)
> #define LPT_CONTROL (LPT_BASE+2)
>
> main()
> {
> int old, new;
>
> /* Permit access to parallel port. */
> ioperm(LPT_BASE, 3, 1);
>
> /* Set data bit 8 high so closing circuit between pin 9 and 10 powers ACK */
> outb(0x80, LPT_DATA);
>
> /* Process press/release events */
> old = inb(LPT_STATUS); /* Grab base status byte. */
> printf("Button is %s\n", old&0x40?"pressed":"released");
> for (;;) {
> new = inb(LPT_STATUS); /* Grab current status byte. */
> if ((new^old)&0x40) { /* Look for activity on bit 6. */
> printf("Button is %s\n", new&0x40?"pressed":"released");
> old = new;
> }
> }
> }
>
> --- [rtl] ---
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
--- [rtl] ---
For more information on Real-Time Linux see:
http://www.rtlinux.org/