Nav:  [home][elec][periph][latch16bit] > [software]
Go:  [Latch16Bit] [circuit R2] [circuit R3] [software]
← [What are these? Why?]

Latch16Bit Board: Driver Software / API


I wrote two little C++ code snippets which can be used to access the Latch16Bit board and devices attached to it. The code is not the most performant one but it is easy-to-read and has a clean design.
The code is divided into two files, one for the low level line printer port access (which can be shared among several higher-level interfaces) and one for the Latch16Bit board level. The latter allows you to set channels (non)transparent, switch outputs to High-Z or set data on the data bus. Higher-level functions allow you read/write one channel while keeping a different channel transparent (by temporarily latching the transparent channel).

Download and Build

You may need the following files. These files were written by me and available under the GNU GPL. They are from December 2003 (for users of earlier versions it is strongly recommended to update).

 File Size  License Description   1kb   GNU GPL   Parallel port raw access driver code 
 lpportio.h   6kb   GNU GPL   Parallel port raw access API   5kb   GNU GPL   Latch16BitIO access/driver code 
 l16bitio.h   7kb   GNU GPL   Latch16BitIO driver API 

The source builds natively on Linux ix86 using gcc. Please note that you must pass (at least) -O to gcc when compiling the code (because inline macros like outb(2) won't get substituted otherwise).
There are no detailed build instructions here because this is not a program of its own and I can assume that you are familiar with the compile-and-link procedure anyway and would be bored reading it.

Note, however, that you may need to configure the source and your computer.
You must have a bidirectional port (maybe check the BIOS) and you must know the port's base address (e.g. 0x378).
Also note that it may be necessary to insert wait states (especially on faster computers). Use CONTROL_OUTPORT_DELAY and DATA_OUTPORT_DELAY in lpportio.h for this purpose.
Using a P1 with 100MHz, I do not need wait states for data output (>2us pulse width) but I need a 35-cycle loop for the control output because the control lines seem to be pull-only (with some pull-up resistor to +5V) which means that they cannot react faster than some microseconds!
Note also that you need a bidirectional parallel port. I switched mine to "bidirectional" mode in the BIOS and it works. Don't know about other computers.


There is no extra documentation available here.
Please check the lengthy comments in the header files (and the actual source code, if needed) if you want to know how to use the code.
Feel free to have a look at the Atmel programmer to see some code actually using this API.

[home] [site map]
Valid HTML 4.01!
Copyright © 2003-2007 by Wolfgang Wieser
Last modified: 2007-07-18 15:52:46