back

ppi

Description:

user-space interface to ppbus parallel 'geek' port under FreeBSD

Author:

Michal Dybizbanski

Version:

Usage:

(require-extension ppi)

Download:

ppi.egg

Documentation:

This extension uses C functions from FreeBSD's ppi to implement simple procedures for handling Parallel Port's input and output.

[procedure] (ppi-in DEVICE REQUEST)
gets the contents of the corresponding register on the given device

[procedure] (ppi-out DEVICE REQUEST NUMBER)
sets the contents of the corresponding register on the given device

where
DEVICE is a string indicating a path to the device's file (eg. "/dev/ppi0")
REQUEST is one of
	PPIGDATA	  
	PPISDATA

	PPIGSTATUS
	PPISSTATUS

	PPIGCTRL
	PPISCTRL

	PPIGEPPD
	PPISEPPD

	PPIGEPPA
	PPISEPPA

	PPIGECR
	PPISECR

	PPIGFIFO
	PPISFIFO
with a meaning as described in man ppi.


There are predefined procedures to set and get various registers

ppi-data-in 
ppi-data-out

ppi-status-in
ppi-status-out

ppi-control-in
ppi-control-out

ppi-eppd-in 
ppi-eppd-out

ppi-eppa-in
ppi-eppa-out

ppi-ecr-in
ppi-ecr-out

ppi-fifo-in
ppi-fifo-out

Each  ppi-***-in  procedure is a procedure of no arguments.
Each  ppi-***-out  procedure is a procedure of one argument being the number to send to register.

For example:
[procedure] (ppi-data-out NUMBER)
sets the contents of the data register to given number
There are 8 bits in the data register so range of numbers available to set is 0 - 255

Example :
(ppi-data-out 5) sets D2 and D0 to logical 1


[procedure] (ppi-status-in) -> 8 * S3 + 16 * S4 + 32 * S5 + 64 * S6 + 128 * ~S7
reads the contents of the status register.

Example :
For S3 and S5 set to 1 and the rest to 0
(ppi-status-in) -> 40


The predefined procedures make usage of the device /dev/ppi0 as the
parallel port. If you want them to use another device, you can change
it, as the device's name to use is bound with ppi-device variable.

Example:
To read control register on /dev/ppi1 device you can use either
(ppi-in "/dev/ppi1" PPIGCTRL)
or
(set! ppi-device "/dev/ppi1")
(ppi-control-in)

In the latter case, consequent calls to ppi-***-in/out procedures will
obviously refer to "/dev/ppi1" device.


For further reference on ppi see 'man ppi'

There are many sites devoted to parallel port operations, for example:
http://www.beyondlogic.org/spp/parallel.htm
http://www.doc.ic.ac.uk/~ih/doc/par/

License:

Copyright (c) 2005 Michal Dybizbanski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


back