Blame doc/ieee1284_read_control.3

Packit d36e9b
.\"     Title: ieee1284_control
Packit d36e9b
.\"    Author: Tim Waugh <twaugh@redhat.com>
Packit d36e9b
.\" Generator: DocBook XSL Stylesheets v1.72.0 <http://docbook.sf.net/>
Packit d36e9b
.\"      Date: 09/18/2007
Packit d36e9b
.\"    Manual: Functions
Packit d36e9b
.\"    Source: 
Packit d36e9b
.\"
Packit d36e9b
.TH "IEEE1284_CONTROL" "3" "09/18/2007" "" "Functions"
Packit d36e9b
.\" disable hyphenation
Packit d36e9b
.nh
Packit d36e9b
.\" disable justification (adjust text to left margin only)
Packit d36e9b
.ad l
Packit d36e9b
.SH "NAME"
Packit d36e9b
ieee1284_read_control, ieee1284_write_control, ieee1284_frob_control, ieee1284_do_nack_handshake \- manipulate control lines
Packit d36e9b
.SH "SYNOPSIS"
Packit d36e9b
.sp
Packit d36e9b
.ft B
Packit d36e9b
.nf
Packit d36e9b
#include <ieee1284.h>
Packit d36e9b
.fi
Packit d36e9b
.ft
Packit d36e9b
.HP 26
Packit d36e9b
.BI "int ieee1284_read_control(struct\ parport\ *" "port" ");"
Packit d36e9b
.HP 28
Packit d36e9b
.BI "void ieee1284_write_control(struct\ parport\ *" "port" ", unsigned\ char\ " "ct" ");"
Packit d36e9b
.HP 27
Packit d36e9b
.BI "void ieee1284_frob_control(struct\ parport\ *" "port" ", unsigned\ char\ " "mask" ", unsigned\ char\ " "val" ");"
Packit d36e9b
.HP 31
Packit d36e9b
.BI "int ieee1284_do_nack_handshake(struct\ parport\ *" "port" ", unsigned\ char\ " "ct_before" ", unsigned\ char\ " "ct_after" ", struct\ timeval\ *" "timeout" ");"
Packit d36e9b
.SH "DESCRIPTION"
Packit d36e9b
.PP
Packit d36e9b
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:
Packit d36e9b
.sp
Packit d36e9b
.RS 4
Packit d36e9b
.nf
Packit d36e9b
enum ieee1284_control_bits
Packit d36e9b
{
Packit d36e9b
  C1284_NSTROBE   = 0x01,
Packit d36e9b
  C1284_NAUTOFD   = 0x02,
Packit d36e9b
  C1284_NINIT     = 0x04,
Packit d36e9b
  C1284_NSELECTIN = 0x08,
Packit d36e9b
  /* To convert those values into PC\-style register values, use this: */
Packit d36e9b
  C1284_INVERTED = (C1284_NSTROBE|
Packit d36e9b
                    C1284_NAUTOFD|
Packit d36e9b
                    C1284_NSELECTIN),
Packit d36e9b
};
Packit d36e9b
.fi
Packit d36e9b
.RE
Packit d36e9b
.PP
Packit d36e9b
These functions all act on the parallel port associated with
Packit d36e9b
\fIport\fR, which must be claimed.
Packit d36e9b
.PP
Packit d36e9b
The current values on the control lines are available by calling
Packit d36e9b
\fBieee1284_read_control\fR, and may be set by calling
Packit d36e9b
\fBieee1284_write_control\fR.
Packit d36e9b
.PP
Packit d36e9b
To adjust the values on a set of control lines, use
Packit d36e9b
\fBieee1284_frob_control\fR. The effect of this can be expressed by:
Packit d36e9b
ctr = ((ctr & ~mask) ^ val); that is, the bits in
Packit d36e9b
\fImask\fR
Packit d36e9b
are unset, and then those in
Packit d36e9b
\fIval\fR
Packit d36e9b
are inverted.
Packit d36e9b
.PP
Packit d36e9b
The special function
Packit d36e9b
\fBieee1284_do_nack_handshake\fR
Packit d36e9b
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:
Packit d36e9b
.RS 4
Packit d36e9b
\h'-04' 1.\h'+02'Set the control lines as indicated in
Packit d36e9b
\fIct_before\fR.
Packit d36e9b
.RE
Packit d36e9b
.RS 4
Packit d36e9b
\h'-04' 2.\h'+02'Wait for nAck interrupt. If
Packit d36e9b
\fItimeout\fR
Packit d36e9b
elapses, return
Packit d36e9b
\fBE1284_TIMEDOUT\fR.
Packit d36e9b
.RE
Packit d36e9b
.RS 4
Packit d36e9b
\h'-04' 3.\h'+02'Set the control lines as indicated in
Packit d36e9b
\fIct_after\fR.
Packit d36e9b
.RE
Packit d36e9b
.PP
Packit d36e9b
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.
Packit d36e9b
.SH "RETURN VALUE"
Packit d36e9b
.PP
Packit d36e9b
The return value of
Packit d36e9b
\fBieee1284_read_control\fR, if non\-negative, is a number representing the value on the control lines.
Packit d36e9b
.PP
Packit d36e9b
Possible error codes for
Packit d36e9b
\fBieee1284_read_control\fR:
Packit d36e9b
.PP
Packit d36e9b
\fBE1284_NOTAVAIL\fR
Packit d36e9b
.RS 4
Packit d36e9b
The control lines of this port are not accessible by the application.
Packit d36e9b
.RE
Packit d36e9b
.PP
Packit d36e9b
\fBE1284_INVALIDPORT\fR
Packit d36e9b
.RS 4
Packit d36e9b
The
Packit d36e9b
\fIport\fR
Packit d36e9b
parameter is invalid (for instance, perhaps it is not claimed).
Packit d36e9b
.RE
Packit d36e9b
.PP
Packit d36e9b
Possible error codes for
Packit d36e9b
\fBieee1284_do_nack_handshake\fR:
Packit d36e9b
.PP
Packit d36e9b
\fBE1284_OK\fR
Packit d36e9b
.RS 4
Packit d36e9b
The handshake was successful.
Packit d36e9b
.RE
Packit d36e9b
.PP
Packit d36e9b
\fBE1284_NOTAVAIL\fR
Packit d36e9b
.RS 4
Packit d36e9b
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.
Packit d36e9b
.RE
Packit d36e9b
.PP
Packit d36e9b
\fBE1284_INVALIDPORT\fR
Packit d36e9b
.RS 4
Packit d36e9b
The
Packit d36e9b
\fIport\fR
Packit d36e9b
parameter is invalid (for instance, perhaps it is not claimed).
Packit d36e9b
.RE
Packit d36e9b
.SH "AUTHOR"
Packit d36e9b
.PP
Packit d36e9b
\fBTim Waugh\fR <\&twaugh@redhat.com\&>
Packit d36e9b
.sp -1n
Packit d36e9b
.IP "" 4
Packit d36e9b
Author.
Packit d36e9b
.SH "COPYRIGHT"
Packit d36e9b
Copyright \(co 2001\-2003 Tim Waugh
Packit d36e9b
.br
Packit d36e9b