Echelon FT 3150 Smart Transceiver User Manual
Page 56
Chapter 3 - Input/Output Interfaces
50
FT 3120 / FT 3150 Smart Transceiver Data Book
filled with 0s. The master program writes once to the slave and reads once from the slave. To implement continuous
writes and reads, add an io_out_request() function call after the io_in() function call in the master program.
/* This is the master program. After reset, the buffer is filled with 1s and then the
buffer is written to the slave. The master then reads the slave’s buffer. The master’s
output buffer should contain [5,1,1,1,1,1]; the input buffer should contain
[7,1,2,3,4,5,6,7,0,0,0,0,0,0].
*/
IO_0 parallel master parallel_bus;
#define TEST_DATA 1
// data to be written in output buffer
#define MAX_IN 13
// maximum length of input data expected
#define OUT_LEN 5
// output length can be equal to or less than the
// max
#define MAX_OUT 5
// maximum array length
struct parallel_out
// output structure
{
unsigned int len;
// actual length of data to be output
unsigned int buffer[MAX_OUT];
// array setup for max length of
// data to be output
}p_out;
// output structure name
struct parallel_in
// input structure
{
unsigned int len;
// actual buffer length to be input
unsigned int buffer[MAX_IN];
// maximum input array
}p_in;
// input structure name
unsigned int i;
when (reset)
{
p_out.len=OUT_LEN;
// assign output length
for(i=0; i // fill output buffer with 1s p_out.buffer[i]=TEST_DATA; // request to output buffer } io_out(parallel_bus, &p_out); // output buffer when slave is ready } p_in.len=MAX_IN; // declare the maximum input io_in(parallel_bus, &p_in); // store input data in buffer } // end of program
io_out_request(parallel_bus);
when (io_out_ready(parallel_bus))
{
when (io_in_ready(parallel_bus))
{
// buffer acceptable