Neuron c resources – Echelon I/O Model Reference for Smart Transceivers and Neuron Chips User Manual

Page 81

Advertising
background image

I/O Model Reference

71

Neuron C Resources

In order to use the parallel I/O model of the Neuron Chip or Smart Transceiver,

the io_in( ) and io_out( ) functions require a pointer to the parallel_io_interface
structure:

struct parallel_io_interface {
unsigned length; // length of data field
unsigned data[MAXLENGTH]; // data field
} piofc;

The parallel_io_interface structure must be declared in the application program,
with an appropriate definition of MAXLENGTH to signify the largest expected

buffer size for any data transfer, up to a maximum value of 255.
For the io_out( ) function, length is the number of bytes to be transferred out and
is set by the application program. For the io_in( ) function, length is the number

of bytes to be transferred in. If the incoming length is larger than length, then

the incoming data stream is flushed, and length is set to zero. Otherwise, length
is set to the number of data bytes read. The length field must be set before

calling the io_in( ) or io_out( ) function. The maximum value for the length field

is 255.

The following functions and events are provided specifically for use with the

parallel I/O object:

io_in_ready

This event becomes TRUE whenever a message arrives on the parallel bus

that must be read. The application must then call the io_in( ) function to
retrieve the data.

io_out_request( )

This function is used to request an io_out_ready indication for a parallel I/O
object. It is up to the application to buffer the data until the io_out_ready

event is TRUE. This function acquires the token for the parallel I/O

interface.

io_out_ready

This event becomes TRUE whenever the parallel bus is in a state where it

can be written to and the io_out_request( ) function was previously called.
The application must then call the io_out( ) function to write the data to the

parallel port. This function relinquishes the token for the parallel I/O
interface.

Neuron C applications can also use the parallel bus in a unidirectional manner

(that is, applications don't need to use both the when(io_in_ready) or
when(io_out_ready) clauses if they only need to use one).
See

Performing I/O: Functions and Events

on page 18, the

Neuron C

Programmer's Guide

, and the

Parallel I/O Interface to the Neuron Chip

engineering bulletin (part no. 005-0021-01) for additional information.
To prevent contention for the data bus, a virtual write token is passed back and

forth between the master device and the slave device (in both slave A and slave B
modes). The master device has the write token initially after a reset. The

parallel I/O object automatically manages the write token; no specific application
code is needed.

Advertising