The IOTester® functions
The IOTester® tool and external I/O hardware is operated via a few functions for basic I/O register access plus a few initialization functions:
// I/O register access functions
unsigned long iot_rd( unsigned long addr); // Read from I/O register
void iot_wr( unsigned long addr, unsigned long dat); // Write to I/O register
void iot_or( unsigned long addr, unsigned long dat); // Do OR operation on I/O register (set bit)
void iot_and( unsigned long addr, unsigned long dat); // Do AND operation on I/O register (clear bit)
void iot_xor( unsigned long addr, unsigned long dat); // Do XOR operation on I/O register (invert bit)
// I/O register array access functions (buffer access functions)
unsigned long iot_rdbuf( unsigned long addr, unsigned long index);
void iot_wrbuf( unsigned long addr, unsigned long index, unsigned long dat);
void iot_orbuf( unsigned long addr, unsigned long index, unsigned long dat);
void iot_andbuf( unsigned long addr, unsigned long index, unsigned long dat);
void iot_xorbuf( unsigned long addr, unsigned long index, unsigned long dat);
// Initialization and exit functions
int iot_init(unsigned long device); // Init connection to IOTester device
void iot_exit(void); // Close connection to IOTester device (optional)
Use of these functions are illustrated in the following examples.
Note: All IOTester specific functions have the name prefix iot_.
The portable iohw syntax for I/O register access is supported as well.
Example: "Single chip mode"
The program example configures IOTester for "single-chip mode", and do some pin read and write operations.
All 45 IOTester signals are I/O pins.
Only internal IOTester registers are accessible from the PC application.
In the example 1 pin is configured as output. The other pins are inputs (default).
Register names and addresses for all internal IOTester devices are predefined in <iotester.h>
#include <iotester.h> // Define IOTester functions and symbolic names for internal registers
#include <stdio.h> // printf(..) used for test message on the PC screen
// Define connector pins for the test
#define TEST_OUT_PIN IOT_J1_PIN1
#define TEST_IN_PIN IOT_J1_PIN2
// Read pins and use the PC screen to monitor the "embedded" hardware states
void report_pin_levels(void)
{
unsigned long J1pins;
// Read pin levels directly (independent of wether a pin is input or output)
J1pins = iot_rd( IOT_INPUT_REG1 );
// Show pin values on PC screen.
// Test pins: Short circuit pins on the connector and see the Out and In values track
printf("\nOut pin = %d, In pin = %d",
(J1pins & TEST_OUT_PIN) ? 1 : 0,
(J1pins & TEST_IN_PIN) ? 1 : 0);
}
int main(void)
{
int i;
// Init IOTESTER driver, search for any IOTester connected to the PC
if ( iot_init(0) )
return 1; // Could not connect
// IOTester connection OK
// Configure IOTester for I/O mode only (no devices or external bus)
iot_wr( IOT_PIN_MODE_REG, 0);
// All pins are input as default
// Configure test pin for output without pull up.
iot_wr( IOT_IOSET_REG1, TEST_OUT_PIN ); // Logic high, but no drive yet
iot_wr( IOT_IODIRSET_REG1, TEST_OUT_PIN ); // Pin = output, drive active
iot_wr( IOT_IOPUPCLR_REG1,~TEST_OUT_PIN ); // Clear passive pull up
// Loop toggling pin low and high
for (i=0; i<1000; i--)
{
// Test Pin is active low
iot_wr( IOT_IOCLR_REG1,~TEST_OUT_PIN );
report_pin_levels();
// Test Pin is active high
iot_wr( IOT_IOSET_REG1, TEST_OUT_PIN );
report_pin_levels();
}
// Release all IOTester resources
iot_exit();
return 0;
}
Links to:
IOTester tool description
Example 1: Start using IOTester I/O port pins - "Single chip mode"
Example 2: Enabling the External bus
Example 3: Using Internal Devices and External bus.
Example 4: Using Target Interrupt.
Example 5: Writing portable I/O driver source code with <iohw.h>
Example 6: <iohw.h> implementation methods and definition of I/O registers
Example 7: Swapping source code between PC and target platforms