[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with lp0



On Tuesday 05 November 2002 14.33, Jonathan Wilkinson wrote:
> Hi Thanks for that
>
> >If you don't enable the parallel ports the pins are accessable using the
> >/dev/gpiog driver.
>
> Could you please point me in the right direction for the documentation (or
> code example) for the gpiog driver.  My application only has to set and
> read the lpt pins.  I see the hwtestio software uses the driver but i can't
> see how it would access lp0.
>
> Thanks once again
>
> Jonathan


Look in chapter 20 Electrical information for the assignment of port G,
e.g. lp0 data bits are g8-g15.

Also note that some bits are assigned to different pins depending on if it is 
used as an input or output - i.e. it can be used for both at the same time 
but different pins are used.
You must use 2.4.19 and the patch from developer.axis.com for /dev/gpiog to 
work.
Also note that new ioct()'s are added to include/asm/etraxgpio.h:
/* The following 4 ioctl's take a pointer as argument and handles
 * 32 bit ports (port G) properly.
 * These replaces IO_READBITS,IO_SETINPUT AND IO_SETOUTPUT
 */
#define IO_READ_INBITS   0x10 /* *arg is result of reading the input pins */
#define IO_READ_OUTBITS  0x11 /* *arg is result of reading the output shadow 
*/
#define IO_SETGET_INPUT  0x12 /* bits set in *arg is set to input,
                               * *arg updated with current input pins.
                               */
#define IO_SETGET_OUTPUT 0x13 /* bits set in *arg is set to output,
                               * *arg updated with current output pins.
                               */

That should/could be used instead of the old ones.
Unless you are using g31 the old ones work fine though, but the new ones
is more "standard" and takes a pointer argument.
Example usage:
 ioctl(devfd, _IO(ETRAXGPIO_IOCTYPE, IO_READ_OUTBITS), &value);

 ioctl(devfd, _IO(ETRAXGPIO_IOCTYPE, IO_READ_INBITS), &value); /* pointer */

 mask = 0xFF << 8; /* lp0 data */
 ioctl(devfd, _IO(ETRAXGPIO_IOCTYPE, IO_SETGET_OUTPUT),&mask); /* pointer */
 
 mask = 0xFF << 8; /* lp0 data */
 ioctl(devfd, _IO(ETRAXGPIO_IOCTYPE, IO_CLRBITS),mask); /* no pointer */
 sleep(1);
 ioctl(devfd, _IO(ETRAXGPIO_IOCTYPE, IO_SETBITS),mask); /* no pointer */