📄 drivers.lyx
字号:
#LyX 1.3 created this file. For more info see http://www.lyx.org/\lyxformat 221\textclass book\begin_preamble\usepackage[plainpages=false,pdfpagelabels,colorlinks=true,linkcolor=blue]{hyperref}\end_preamble\language english\inputencoding default\fontscheme bookman\graphics default\float_placement !htbp\paperfontsize default\spacing single \papersize letterpaper\paperpackage a4\use_geometry 1\use_amsmath 1\use_natbib 0\use_numerical_citations 0\paperorientation portrait\leftmargin 1in\topmargin 1in\rightmargin 0.8in\bottommargin 0.8in\secnumdepth 1\tocdepth 5\paragraph_separation skip\defskip smallskip\quotes_language english\quotes_times 2\papercolumns 1\papersides 1\paperpagestyle default\layout ChapterHardware Drivers\layout Section\begin_inset LatexCommand \label{sec:Parport}\end_inset Parport\begin_inset LatexCommand \index{parallel port}\end_inset \layout StandardParport is a driver for the traditional PC parallel port. The port has a total of 17 physical pins. The original parallel port divided those pins into three groups: data, control, and status. The data group consists of 8 output pins, the control group consists of 4 pins, and the status group consists of 5 input pins.\layout StandardIn the early 1990's, the bidirectional parallel port was introduced, which allows the data group to be used for output or input. The HAL driver supports the bidirectional port, and allows the user to set the data group as either input or output. If configured as output, a port provides a total of 12 outputs and 5 inputs. If configured as input, it provides 4 outputs and 13 inputs. \layout StandardIn some parallel ports, the control group pins are open collectors, which may also be driven low by an external gate. On a board with open collector control pins, the \begin_inset Quotes eld\end_inset x\begin_inset Quotes erd\end_inset mode allows a more flexible mode with 8 dedicated outputs, 5 dedicated inputs, and 4 open collector pins. In other parallel ports, the control group has push-pull drivers and cannot be used as an input.\begin_inset Footcollapsed false\layout StandardHAL cannot automatically determine if the \begin_inset Quotes eld\end_inset x\begin_inset Quotes erd\end_inset mode bidirectional pins are actually open collectors (OC). If they are not, they cannot be used as inputs, and attempting to drive them LOW from an external source can damage the hardware.\layout StandardTo determine whether your port has \begin_inset Quotes eld\end_inset open collector\begin_inset Quotes erd\end_inset pins, load hal_parport in \begin_inset Quotes eld\end_inset x\begin_inset Quotes erd\end_inset mode, output a HIGH value on the pin. HAL should read the pin as TRUE. Next, insert a 470\begin_inset Formula $\Omega$\end_inset resistor from one of the control pins to GND. If the resulting voltage on the control pin is close to 0V, and HAL now reads the pin as FALSE, then you have an OC port. If the resulting voltage is far from 0V, or HAL does not read the pin as FALSE, then your port cannot be used in \begin_inset Quotes eld\end_inset x\begin_inset Quotes erd\end_inset mode.\layout StandardThe external hardware that drives the control pins should also use open collector gates (e.g., 74LS05). Generally, the -out HAL pins should be set to TRUE when the physical pin is being used as an input.\layout StandardOn some machines, BIOS settings may affect whether \begin_inset Quotes eld\end_inset x\begin_inset Quotes erd\end_inset mode can be used. \begin_inset Quotes eld\end_inset SPP\begin_inset Quotes erd\end_inset mode is most most likely to work.\end_inset \layout StandardNo other combinations are supported, and a port cannot be changed from input to output once the driver is installed. Figure \begin_inset LatexCommand \ref{fig:Parport-block-diag}\end_inset shows two block diagrams, one showing the driver when the data group is configured for output, and one showing it configured for input.\layout StandardThe parport driver can control up to 8 ports (defined by MAX_PORTS in hal_parport.c). The ports are numbered starting at zero.\layout SubsectionInstalling\layout LyX-Codeloadrt hal_parport cfg="<config-string>"\layout StandardThe config string consists of a hex port address, followed by an optional direction, repeated for each port. The direction is \begin_inset Quotes eld\end_inset in\begin_inset Quotes erd\end_inset , \begin_inset Quotes eld\end_inset out\begin_inset Quotes erd\end_inset , or \begin_inset Quotes eld\end_inset x\begin_inset Quotes erd\end_inset and determines the direction of the physical pins 2 through 9, and whether to create input HAL pins for the physical control pins. If the direction is not specified, the data group defaults to output. For example:\layout LyX-Codeloadrt hal_parport cfg="0x278 0x378 in 0x20A0 out"\layout StandardThis example installs drivers for one port at 0x0278, with pins 2-9 as outputs (by default, since neither \begin_inset Quotes eld\end_inset in\begin_inset Quotes erd\end_inset nor \begin_inset Quotes eld\end_inset out\begin_inset Quotes erd\end_inset was specified), one at 0x0378, with pins 2-9 as inputs, and one at 0x20A0, with pins 2-9 explicitly specified as outputs. Note that you must know the base address of the parallel port to properly configure the driver. For ISA bus ports, this is usually not a problem, since the port is almost always at a \begin_inset Quotes eld\end_inset well known\begin_inset Quotes erd\end_inset address, like 0278 or 0378 which is typically configured in the system BIOS. The address for a PCI card is usally shown in \begin_inset Quotes eld\end_inset lspci -v\begin_inset Quotes erd\end_inset in an \begin_inset Quotes eld\end_inset I/O ports\begin_inset Quotes erd\end_inset line, or in the kernel message log after executing \family typewriter \begin_inset Quotes eld\end_inset sudo modprobe -a parport_pc\family default \begin_inset Quotes erd\end_inset . There is no default address; if \family typewriter <config-string>\family default does not contain at least one address, it is an error.\layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics filename parport-block-diag.eps width 8in height 10in keepAspectRatio rotateAngle 90 rotateOrigin center\end_inset \layout Caption\begin_inset LatexCommand \label{fig:Parport-block-diag}\end_inset Parport Block Diagram\end_inset \layout SubsectionPins\layout Itemize\family typewriter \noun on (bit) \noun default parport.<portnum>.pin-<pinnum>-out\family default -- Drives a physical output pin.\layout Itemize\family typewriter \noun on (bit) \noun default parport.<portnum>.pin-<pinnum>-in\family default -- Tracks a physical input pin.\layout Itemize\family typewriter \noun on (bit) \noun default parport.<portnum>.pin-<pinnum>-in-not\family default -- Tracks a physical input pin, but inverted.\layout StandardFor each pin, \family typewriter <portnum>\family default is the port number, and \family typewriter <pinnum>\family default is the physical pin number in the 25 pin D-shell connector.\layout StandardFor each physical output pin, the driver creates a single HAL pin, for example \family typewriter parport.0.pin-14-out\family default . Pins 2 through 9 are part of the data group and are output pins if the port is defined as an output port. (Output is the default.) Pins 1, 14, 16, and 17 are outputs in all modes. These HAL pins control the state of the corresponding physical pins.\layout StandardFor each physical input pin, the driver creates two HAL pins, for example \family typewriter parport.0.pin-12-in\family default and \family typewriter parport.0.pin-12-in-not\family default . Pins 10, 11, 12, 13, and 15 are always input pins. Pins 2 through 9 are input pins only if the port is defined as an input port. The \family typewriter -in\family default HAL pin is TRUE if the physical pin is high, and FALSE if the physical pin is low. The \family typewriter -in-not\family default HAL pin is inverted -- it is FALSE if the physical pin is high. By connecting a signal to one or the other, the user can determine the state of the input. In \begin_inset Quotes eld\end_inset x\begin_inset Quotes erd\end_inset mode, pins 1, 14, 16, and 17 are also input pins.\layout SubsectionParameters\layout Itemize\family typewriter \noun on (bit) \noun default parport.<portnum>.pin-<pinnum>-out-invert\family default -- Inverts an output pin.\layout Itemize\family typewriter \noun on (bit) \noun default parport.<portnum>.pin-<pinnum>-out-reset \family default (only for pins 2..9) -- TRUE if this pin should be reset when the \family typewriter -reset\family default function is executed.\layout Itemize\family typewriter (U32) parport.<portnum>.reset-time\family default -- The time (in nanoseconds) between a pin is set by \family typewriter write\family default and reset by \family typewriter reset\family default HAL functions.\layout StandardThe \family typewriter -invert\family default parameter determines whether an output pin is active high or active low. If \family typewriter -invert\family default is FALSE, setting the HAL \family typewriter -out\family default pin TRUE drives the physical pin high, and FALSE drives it low. If \family typewriter -invert\family default is TRUE, then setting the HAL \family typewriter -out\family default pin TRUE will drive the physical pin low.\layout StandardIf \family typewriter -reset\family default is TRUE, then the \family typewriter reset\family default function will set the pin to the value of \family typewriter -out-invert\family default . This can be used in conjunction with stepgen's \family typewriter doublefreq\family default to produce one step per period.\layout SubsectionFunctions\layout Itemize\family typewriter \noun on (funct) \noun default parport.<portnum>.read\family default -- Reads physical input pins of port \family typewriter <portnum>\family default and updates HAL \family typewriter -in\family default and \family typewriter -in-not\family default pins.\layout Itemize\family typewriter \noun on (funct) \noun default parport.read-all\family default -- Reads physical input pins of all ports and updates HAL \family typewriter -in\family default and \family typewriter -in-not\family default pins.\layout Itemize\family typewriter \noun on (funct) \noun default parport.<portnum>.write\family default -- Reads HAL \family typewriter -out\family default pins of port \family typewriter <portnum>\family default and updates that port's physical output pins.\layout Itemize\family typewriter \noun on (funct) \noun default parport.write-all\family default -- Reads HAL \family typewriter -out\family default pins of all ports and updates all physical output pins.\layout Itemize\family typewriter \noun on (funct) \noun default parport.<portnum>.reset\family default -- Waits until \family typewriter reset-time\family default has elapsed since the associated \family typewriter write\family default , then resets pins to values indicated by \family typewriter -out-invert\family default and \family typewriter -out-invert\family default settings. \family typewriter reset\family default must be later in the same thread as \family typewriter write\layout StandardThe individual functions are provided for situations where one port needs to be updated in a very fast thread, but other ports can be updated in a slower thread to save CPU time. It is probably not a good idea to use both an \family typewriter -all\family default function and an individual function at the same time.\layout SubsectionCommon problems\layout StandardIf loading the module reports\layout LyX-Codeinsmod: error inserting '/home/jepler/emc2/rtlib/hal_parport.ko':\newline -1 Device or resource busy \layout Standardthen ensure that the standard kernel module \family typewriter parport_pc\family default is not loaded\begin_inset Footcollapsed false\layout StandardIn the emc packages for Ubuntu, the file /etc/modprobe.d/emc2 generally prevents \family typewriter parport_pc\family default from being automatically loaded.\end_inset and that no other device in the system has claimed the I/O ports.\layout StandardIf the module loads but does not appear to function, then the port address is incorrect or the \family typewriter probe_parport\family default module is required.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -