Description | |||
---|---|---|---|
PHDIO_OR | reg, Value | Read register, OR with value, and write back. Use to set bit(s) | |
PHDIO_AND | reg, Value | Read register, AND with value, and write back. Use to clear bit(s) | |
PHDIO_XOR | reg, Value | Read register, XOR with value, and write back. Use to toggle bit(s) | |
PHDIO_WRITE | reg, Value | Write value to a register | |
PHDIO_READ | reg | Value | Read value from a register |
PHDIO_DELAY | delay | Delay for given microseconds. Delay must be 60µs or less | |
PHDIO_WRITES | reg, count, Values, delay | Write values to same register with delay (<=60µs) | |
PHDIO_READS | reg, count, delay | Values | Read values from same register with delay (<=60µs) |
PHDIO_IRQ_CONNECT | reg, mask, Value | Connect to interrupt | |
PHDIO_TIMEOUT | seconds | Specify time-out for reads and writes | |
PHDIO_WRITE_NEXT | reg | Write next value from write buffer | |
PHDIO_READ_NEXT | reg | Store next value in read buffer |
LPT Printer Driver Application
The
A parallel port responds at three addresses in I/O space in an x86 PC. It also generates an interrupt (when enabled) on one interrupt line. The LPT1 port traditionally lives at I/O space addresses 0x378 to 0x37A and generates ISA interrupt IRQ7.
A basic parallel port has the three registers as listed in Table 15.3. Signals with #at the end of their name use negative logic. For example, if the Status BUSY# bit is read as zero (low), the printer is busy.
The printer is ready to accept data if the Status BUSY# and ONLINE bits are high.
To write data to the printer, write the byte to the Data port. Wait 1µs for the data lines to settle. Set the Control port STROBE output high for at least 0.5µs. The printer signals that it is busy as BUSY# is read as low. When it is ready for another byte, it pulses ACK# low briefly and BUSY# goes high again.
The ACK# pulse signals the parallel port electronics to interrupt the processor (provided ENABLE_INT is high). I have no clear documentation to say what is exactly supposed to happen now. One source says that bit 2 of the Status register is set low to indicate that it has caused the interrupt. However, the two printers that I tried did not set this bit low. It seems that you just have to assume that if the right interrupt arrives (e.g., IRQ7), the correct parallel port caused the interrupt. It seems that reading the Status register clears the interrupt.
A printer may sometimes also pulse ACK# low and so generate an interrupt at other times, such as when it has finished initializing itself, when it is switched off, when it goes off-line, or when it runs out of paper. A dedicated parallel port driver might well take special action for these circumstances. The code here just needs to ensure that the WdmIo driver reads the Status port to clear the interrupt.
As you may be aware, more sophisticated versions of the parallel port are available. For example, when configured in the appropriate mode, a parallel port can input information via the Data port. In addition, some non-standard devices can be connected to a basic parallel port. These might allow input of 4-bits at a time using the Status port. Dongles are hardware devices that are used to