sub_rs_set_config

Top  Previous  Next
Got to SUB-20 page

Synopsis

int sub_rs_set_config( sub_handle hndl, int config, int baud)

 

Configure SUB-20 UART (Universal Asynchronous Receiver Transmitter).    

Parameters

config - UART configuration. Config should be assembled as a combination of the following flags

 

RS_RX_ENABLE

Enable UART receiver

RS_TX_ENABLE

Enable UART transmitter

RS_CHAR_5

Data Bits

RS_CHAR_6

RS_CHAR_7

RS_CHAR_8

RS_CHAR_9

RS_PARITY_NONE

Parity

RS_PARITY_EVEN

RS_PARITY_ODD

RS_STOP_1

Stop Bits

RS_STOP_2

 

To disable UART provide configuration without RS_RX_ENABLE and RS_TX_ENABLE.

 

baud - Desired baudrate. Maximum baudrate is 2Mbps. The actual baudrate may slightly differ from the desired as actual baudrate is an integer quotient from dividing the 16MHz reference clock.

Return value

On success function returns 0. Otherwise error code.

Example

/* Set 9660 bps, 8 data bits, no parity, 1 stop bit */

sub_rs_set_config( hndl, RS_RX_ENABLE|RS_TX_ENABLE|RS_CHAR_8|RS_PARITY_NONE|RS_STOP_1, 9600 );