DIO-144

The DIO-144 card has 144 bits of digital I/O, and you can configure them as inputs or outputs by 8-bit or (for some ports) 4-bit chunks. This gives you a fair bit of flexibility, but also presents some problems for the driver. There is no analog I/O on this card.

All of the programming for this card is done by reading and writing I/O ports.

Note: For those of you not familiar with the x86 architecture, an x86 CPU maintains two separate address spaces. One is the traditional memory address space that every CPU in the world has, and the second is called an I/O address space. There are special CPU instructions to access this second address space. From C, you can access the I/O address space using the in8() and out8() (and related) functions (see <hw/inout.h> and mmap_device_io()).

The hardest part of the DIO-144 software driver design is setting up the bits to be input or output. Once you have the card configured, reading from it involves calling several in8() functions, and writing involves calling several out8() functions. The only trick to writing is that you often need to change just one bit—so the software will have to keep a current image of the other 7 bits, because the hardware allows only 8-bit-at-a-time writes.