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

Page 112

Advertising
background image

102

Serial I/O Models

io-object-name

Specifies a name for the I/O object, in the ANSI C format for variable
identifiers.

You can call the io_set_baud(

io-obj-name

,

rate

) function to change the bit rate for

the SCI interface. The specified

rate

must be one of the enumeration values

listed above.

Usage

unsigned short

buffer-size

;

unsigned short

buffer

[

buffer-size

];

unsigned short io_in_request(

io-object-name, buffer

,

buffer-size

);

unsigned short io_out_request(

io-object-name, buffer

,

buffer-size

);

unsigned short io_in_ready(

io-object-name

);

unsigned short io_out_ready(

io-object-name

);

unsigned short sci_get_error(

io-object-name

);

void sci_abort(

io-object-name

);

The SCI I/O object uses pins IO_8 for RX data (in) and IO_10 for TX data (out).
The io_in( ) and io_out( ) functions are not available with the hardware SCI
model. Instead, use the io_in_request() and io_out_request() functions:

• For input, call io_in_request(

io-object-name

, void *

buf

, unsigned

len

) to

set up and initiate an input operation.

• For output, call io_out_request(

io-object-name

, void *

buf

, unsigned

len

) to

set up and initiate an output operation.

A call to either io_in_request( ) or io_out_request( ) clears any previous SCI error

code – see sci_get_error( ).

You can use the io_in_ready(

io-object-name

) and io_out_ready(

io-object-name

)

event functions to test the state of the SCI interface. You can use these events to

determine when the transmission is complete. The io_out_ready event returns
TRUE after the Neuron firmware loads the output data into the hardware UART.

The UART then continues transmitting the remaining data. The io_in_ready

event returns the number of bytes read in as an unsigned short, so when this
value matches the

len

parameter from the call to io_in_request( ) the input

operation is complete.
You can use the sci_get_error(

io-object-name

) function to test for SCI errors,

including parity errors. Calling the sci_get_error( ) function clears the SCI error

code after it is returned. This function returns a cumulative OR of the following

bits that reflect data errors:

0x02

Parity error

0x04

Framing error

0x08

Noise detected

0x10

Receive overrun detected

You can use the sci_abort(

io-object-name

) function to terminate any reception in

progress. After an abort, the io_in_ready( ) function returns the number of

characters read up to the abort.

Advertising