Blob Blame History Raw
.\"     Title: ieee1284_control
.\"    Author: Tim Waugh <twaugh@redhat.com>
.\" Generator: DocBook XSL Stylesheets v1.72.0 <http://docbook.sf.net/>
.\"      Date: 09/18/2007
.\"    Manual: Functions
.\"    Source: 
.\"
.TH "IEEE1284_CONTROL" "3" "09/18/2007" "" "Functions"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
ieee1284_read_control, ieee1284_write_control, ieee1284_frob_control, ieee1284_do_nack_handshake \- manipulate control lines
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <ieee1284.h>
.fi
.ft
.HP 26
.BI "int ieee1284_read_control(struct\ parport\ *" "port" ");"
.HP 28
.BI "void ieee1284_write_control(struct\ parport\ *" "port" ", unsigned\ char\ " "ct" ");"
.HP 27
.BI "void ieee1284_frob_control(struct\ parport\ *" "port" ", unsigned\ char\ " "mask" ", unsigned\ char\ " "val" ");"
.HP 31
.BI "int ieee1284_do_nack_handshake(struct\ parport\ *" "port" ", unsigned\ char\ " "ct_before" ", unsigned\ char\ " "ct_after" ", struct\ timeval\ *" "timeout" ");"
.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:
.sp
.RS 4
.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
.RE
.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:
.RS 4
\h'-04' 1.\h'+02'Set the control lines as indicated in
\fIct_before\fR.
.RE
.RS 4
\h'-04' 2.\h'+02'Wait for nAck interrupt. If
\fItimeout\fR
elapses, return
\fBE1284_TIMEDOUT\fR.
.RE
.RS 4
\h'-04' 3.\h'+02'Set the control lines as indicated in
\fIct_after\fR.
.RE
.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:
.PP
\fBE1284_NOTAVAIL\fR
.RS 4
The control lines of this port are not accessible by the application.
.RE
.PP
\fBE1284_INVALIDPORT\fR
.RS 4
The
\fIport\fR
parameter is invalid (for instance, perhaps it is not claimed).
.RE
.PP
Possible error codes for
\fBieee1284_do_nack_handshake\fR:
.PP
\fBE1284_OK\fR
.RS 4
The handshake was successful.
.RE
.PP
\fBE1284_NOTAVAIL\fR
.RS 4
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.
.RE
.PP
\fBE1284_INVALIDPORT\fR
.RS 4
The
\fIport\fR
parameter is invalid (for instance, perhaps it is not claimed).
.RE
.SH "AUTHOR"
.PP
\fBTim Waugh\fR <\&twaugh@redhat.com\&>
.sp -1n
.IP "" 4
Author.
.SH "COPYRIGHT"
Copyright \(co 2001\-2003 Tim Waugh
.br