[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: [rtl] linux push-button



Dear Paul,

The first, you should check your BIOS and put the LPT to EPP mode and
addres 0x378.
As we know the EPP port have 5 ports,
BASE = 0x378 (WR_only, but some PC can R/W)
STATUS = BASE + 1 (R)
CTRL = BASE + 2 (R/W)
ADDRESS = BASE + 3 (R/W)
DATA = BASE + 4 (R/W)

And if you want to activate one subroutine through signal on pin 10
(ACK), you should use Interrupt process handling.

Regards,


<adolf@ratelindo.co.id>
OMC Switching Div
Wisma Bakrie Lt. 5,
Jl. HR. Rasuna Said Kav B1
Jakarta
Telp. 9101112 ext. 411

> ----------
> From: 	Paul Kienzle[SMTP:pkienzle@kienzle.powernet.co.uk]
> Sent: 	Wednesday, July 15, 1998 11:18 PM
> To: 	rtl@rtlinux.cs.nmt.edu
> Subject: 	[rtl] linux push-button
> 
> 
> 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/