[PARPORT] reading data from the parport?


Clemens Kirchgatterer (clemens@root.at)
Wed, 05 May 1999 17:44:11 +0200


hi there!

i´m trying to connect a OTREX grafix_lcd-panel to the parallel port, but
ran into some problems.

i have to read the lcd status from the data lines bovor i can write (or
read) data and commands to the panel, but
everytime i read the PORT_BASE+0 i get the last written byte back.

code tells more:

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <asm/io.h>

#define PORT_BASE 0x378
#define PORT_DATA PORT_BASE+0
#define PORT_CTRL PORT_BASE+2

#define PORT_READ outb((inb(PORT_CTRL) | 0x20), PORT_CTRL)
#define PORT_WRITE outb((inb(PORT_CTRL) & 0xdf), PORT_CTRL)

void lcd_write_data(data) {
  PORT_WRITE; //clear bit 5 of parport
control register to enable writing
  outb(data, PORT_DATA);
}

int lcd_read_data(void) {
  PORT_READ; //set bit 5 of parport
control register to enable reading
  return (inb(PORT_DATA));
}

main(void) {
  if (ioperm(PORT_BASE, 3, 1)) {perror("IO ERROR parallel-port");
exit(1);}

  printf("Setting Data-Lines to 0xff ...\n");
  lcd_write_data(0xff);
  printf("Reading Data-Lines ... ");
  printf("%d\n", lcd_read_data());
  printf("Setting Data-Lines to 0x00 ...\n");
  lcd_write_data(0x00);
  printf("Reading Data-Lines ... ");
  printf("%d\n", lcd_read_data());
}

i have activated EPP-Mode in the BIOS setup, so everthing should be OK.

any suggestions?

warm regards

clemens

-- 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 Wed 05 May 1999 - 11:45:20 EDT