.\"Generated by db2man.xsl. Don't modify this, modify the source.
.de Sh \" Subsection
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.TH "IEEE1284_CONTROL" 3 "" "" ""
.SH NAME
ieee1284_read_control, ieee1284_write_control, ieee1284_frob_control, ieee1284_do_nack_handshake \- manipulate control lines
.SH "SYNOPSIS"
.ad l
.hy 0

#include <ieee1284\&.h>
.sp
.HP 27
int\ \fBieee1284_read_control\fR\ (struct\ parport\ *\fIport\fR);
.HP 29
void\ \fBieee1284_write_control\fR\ (struct\ parport\ *\fIport\fR, unsigned\ char\ \fIct\fR);
.HP 28
void\ \fBieee1284_frob_control\fR\ (struct\ parport\ *\fIport\fR, unsigned\ char\ \fImask\fR, unsigned\ char\ \fIval\fR);
.HP 43
int \ \ \ \ \ \ \fBieee1284_do_nack_handshake\fR\ (struct\ parport\ *\fIport\fR, unsigned\ char\ \fIct_before\fR, unsigned\ char\ \fIct_after\fR, struct\ timeval\ *\fItimeout\fR);
.ad
.hy

.SH "DESCRIPTION"

.PP
There are four control lines, three of which are usually inverted on PC\-style ports\&. Where they differ, libieee1284 operates on the IEEE 1284 values, not the PC\-style inverted values\&. The control lines are represented by the following enumeration:

.nf
enum ieee1284_control_bits
{
  C1284_NSTROBE   = 0x01,
  C1284_NAUTOFD   = 0x02,
  C1284_NINIT     = 0x04,
  C1284_NSELECTIN = 0x08,
  /* To convert those values into PC\-style register values, use this: */
  C1284_INVERTED = (C1284_NSTROBE|
                    C1284_NAUTOFD|
                    C1284_NSELECTIN),
};
.fi

.PP
These functions all act on the parallel port associated with \fIport\fR, which must be claimed\&.

.PP
The current values on the control lines are available by calling \fBieee1284_read_control\fR, and may be set by calling \fBieee1284_write_control\fR\&.

.PP
To adjust the values on a set of control lines, use \fBieee1284_frob_control\fR\&. The effect of this can be expressed by: ctr = ((ctr & ~mask) ^ val); that is, the bits in \fImask\fR are unset, and then those in \fIval\fR are inverted\&.

.PP
The special function \fBieee1284_do_nack_handshake\fR is for responding very quickly in a protocol where the peripheral sets nAck and the host must respond by setting a control line\&. Its operation, which relies on the host machine knowing which interrupt nAck generates, is as follows:

.TP 3
1.
Set the control lines as indicated in \fIct_before\fR\&.
.TP
2.
Wait for nAck interrupt\&. If \fItimeout\fR elapses, return \fBE1284_TIMEDOUT\fR\&.
.TP
3.
Set the control lines as indicated in \fIct_after\fR\&.
.LP

.PP
On Linux using the ppdev driver, this is performed by the device driver in the kernel, and so is faster than normally possible in a user\-space library\&.

.SH "RETURN VALUE"

.PP
The return value of \fBieee1284_read_control\fR, if non\-negative, is a number representing the value on the control lines\&.

.PP
Possible error codes for \fBieee1284_read_control\fR:

.TP
\fBE1284_NOTAVAIL\fR
The control lines of this port are not accessible by the application\&.

.TP
\fBE1284_INVALIDPORT\fR
The \fIport\fR parameter is invalid (for instance, perhaps it is not claimed)\&.

.PP
Possible error codes for \fBieee1284_do_nack_handshake\fR:

.TP
\fBE1284_OK\fR
The handshake was successful\&.

.TP
\fBE1284_NOTAVAIL\fR
This operation is not available on this port type or system\&. This could be because port interrupts are not available, or because the underlying device driver does not support the operation\&.

.TP
\fBE1284_INVALIDPORT\fR
The \fIport\fR parameter is invalid (for instance, perhaps it is not claimed)\&.

.SH AUTHOR
Tim Waugh <twaugh@redhat\&.com>.
