beautypg.com

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

Page 83

background image

I/O Model Reference

73

Example

The following example shows how to use the io_in_ready and io_out_ready

events, in conjunction with the io_out_request( ) function, to handle parallel I/O
processing.

#define DATA_SIZE 255
struct parallel_io_interface {
unsigned int length; // length of data field
unsigned int data [DATA_SIZE]; // data field
} piofc;
IO_0 parallel slave slaveBus;

// ready to input data
when (io_in_ready(slaveBus)) {
piofc.length = DATA_SIZE; // number of bytes to read
io_in(slaveBus, &piofc); // get 10 bytes of incoming data
}

// ready to output data
when (io_out_ready(slaveBus)) {
piofc.length = 10; // number of bytes to write
io_out(slaveBus, &piofc); // output 10 bytes from buffer
}

// user defined event
when (...) {
io_out_request(slaveBus); // post the write request
}