The IOTester software interface essentially consists of initialization functions, interrupt handling functions,
and a few access functions for the most basic operations on I/O registers: READ, WRITE, AND, OR, XOR
on either individual registers or register
arrays. The C/C++ function prototypes are defined in the header
file iotester.h
// Basic IOTester initialization and release (called once by application)
int iot_init(unsigned short lptport);
int iot_init_initerrupt(unsigned short lptport, void (*intr_func)(void), unsigned short irq_number);
void iot_set_buswait(unsigned char wr_waits, unsigned char rd_waits);
void iot_exit(void);
// Basic functions for interrupt handling
unsigned char iot_intr_enable(unsigned char enable);
unsigned char iot_intr_poll(void);
// Functions to access single I/O registers (sizes: 8, 16, 24, or 32 bits)
unsigned long iot_rd( ACCESS_SPEC adr);
void iot_wr( ACCESS_SPEC adr, unsigned long dat);
void iot_and( ACCESS_SPEC adr, unsigned long dat);
void iot_or( ACCESS_SPEC adr, unsigned long dat);
void iot_xor( ACCESS_SPEC adr, unsigned long dat);
// Functions to access I/O register arrays
unsigned long iot_rdbuf( ACCESS_SPEC adr, unsigned long index);
void iot_wrbuf( ACCESS_SPEC adr, unsigned long index, unsigned long dat);
void iot_andbuf(ACCESS_SPEC adr, unsigned long index, unsigned long dat);
void iot_orbuf( ACCESS_SPEC adr, unsigned long index, unsigned long dat);
void iot_xorbuf(ACCESS_SPEC adr, unsigned long index, unsigned long dat);
|
|
The IOTester access functions are universal in the sense that the same functions can be used with any logical register
size from 8 to 32 bits (modulo 8).
The ACCESS_SPEC adr parameter used in the above functions provides a complete description of an I/O register
and how it should be accessed. It combines the following I/O register characteristics into one parameter:
- Logical register size (8, 16, 24 or 32 bits)
- Register endian (Used if the I/O register is larger than 8 bits on an 8 bit databus, or larger than 16 bits
on a 16 bit databus. Identify whether the MSB register data is located at high or low address)
- Register address (External 20-bit byte aligned address range: 0x00000-0xFFFFF)
- IOTester device (i.e. which device the register is located on if more than one IOTester device is used on the LPT bus)
The default is an 8-bit register located on the external IOTester
bus of the first IOTester device. Therefore in most cases it is
the address of the I/O register.
Names for the internal IOTester registers are predefined in the iotester.h
header file. These names map to access specifications which can be used directly
in the application program as shown later.
|
| | IOT_MODE_REG | | Bus mode register | | 8-bit |
Bus_mode: 20, 18, 16, 8, 2 bit address bus, 8 or 16 bit data bus, or IO_mode. Interrupt enable control |
| | IOT_IODIR_REG | | I/O port direction register | | 32-bit | 1=Output, 0=Input |
| | IOT_INPUT_REG | | Input port register | | 32-bit | Read pin level directly |
| | IOT_IOSET_REG | | Output port set register | | 32-bit | 1=set pin, 0=pin is unmodified |
| | IOT_IOCLT_REG | | Output port clear register | | 32-bit | 0=clear pin, 1=pin is unmodified |
|
Configuring the IOTester target interface is similar
to the I/O port initialization procedure used with embedded
processors. The IOTester box is initialized
with a call to iot_init or iot_init_interrupt followed by a few simple
register write operations to the internal IOTester registers.
For instance:
// Typical IOTester initialization steps
// 1. Define IOTester functions and internal registers
#include "iotester.h"
//..
// 2. Establish connection to IOTester device on the LPT port
iot_init(IOT_LPTSEEK);
// 3. Configure IOTester mode
iot_wr(IOT_MODE_REG, IOT_MODE_RDWR_ADR8); // "8080 bus mode", 8-bit addr. bus
// 4. Configure direction of remaining I/O pins
iot_wr(IOT_IODIR_REG, 0x0000ff00); // 8 output pins, 2 input pins
// 5. Set "reset level" for output pins
iot_wr(IOT_IOSET_REG, 0x0000f000 ); // Set pins to be '1'
iot_wr(IOT_IOCLR_REG, 0x0000f000 ); // Clear pins to be '0'
IOTester can be used with both console applications (programs starting from main like most embedded programs), and with
Windows applications (programs starting from WinMain). IOTester status and debug messages from the driver can use stdio or
can be rerouted to some user defined output output function. This makes it very easy to incoorporate use of IOTester
in your own Windows program application.
|