USART#
Modules#
sl_si91x_usart_control_config_t
Enumerations#
USART/UART Events.
General power states.
Databit selection.
Parity selection.
USART Modem control selection.
Stop bits selection, used for asynchronous operation.
Hardware Flow Control Selection.
USART Mode selection.
USART misc control selection.
Typedefs#
Functions#
Initialize USART/UART interface.
Deinit USART/UART interface.
Set the USART/UART power mode.
Register the user callback function.
Un-register the user callback function.
Start sending data to USART transmitter.
Start receiving data from USART receiver.
Start sending/receiving data to/from USART transmitter/receiver.
Get the USART/UART transfer data count.
Get the USART/UART received data count.
Configure the different configurations of USART Interface.
Get USART status.
Set USART Modem Control line state.
Get USART Modem Control line state.
Get the USART version.
Get the USART configurations set.
Enumeration Documentation#
usart_event_typedef_t#
usart_event_typedef_t
USART/UART Events.
Enumerator | |
---|---|
SL_USART_EVENT_SEND_COMPLETE | Send complete event. |
SL_USART_EVENT_RECEIVE_COMPLETE | Receive complete event. |
SL_USART_EVENT_TRANSFER_COMPLETE | Transfer complete event. |
SL_USART_EVENT_TX_COMPLETE | Tx complete event event. |
SL_USART_EVENT_TX_UNDERFLOW | TX underflow event. |
SL_USART_EVENT_RX_OVERFLOW | RX overflow event. |
SL_USART_EVENT_RX_TIMEOUT | RX timeout event. |
SL_USART_EVENT_RX_BREAK | RX break event. |
SL_USART_EVENT_RX_FRAMING_ERROR | RX Framing error event. |
SL_USART_EVENT_RX_PARITY_ERROR | RX parity error event. |
SL_USART_EVENT_CTS | CTS event. |
SL_USART_EVENT_DSR | DSR EVENT. |
SL_USART_EVENT_DCD | DCD event. |
SL_USART_EVENT_RI | RI Event. |
power_mode_typedef_t#
power_mode_typedef_t
General power states.
Enumerator | |
---|---|
SL_POWER_OFF | Power Off. |
SL_POWER_LOW | Power low. |
SL_POWER_FULL | Power Full. |
SL_POWER_MODE_LAST |
usart_databits_typedef_t#
usart_databits_typedef_t
Databit selection.
Enumerator | |
---|---|
SL_USART_DATA_BITS_5 | 5 data bits |
SL_USART_DATA_BITS_6 | 6 data bits |
SL_USART_DATA_BITS_7 | 7 data bits |
SL_USART_DATA_BITS_8 | 8 data bits |
SL_USART_DATA_BITS_9 | 9 data bits |
usart_parity_typedef_t#
usart_parity_typedef_t
Parity selection.
Enumerator | |
---|---|
SL_USART_NO_PARITY | No parity. |
SL_USART_EVEN_PARITY | Even parity. |
SL_USART_ODD_PARITY | Odd parity. |
usart_modem_control_typedef_t#
usart_modem_control_typedef_t
USART Modem control selection.
Enumerator | |
---|---|
SL_USART_RTS_CLEAR | RTS clear. |
SL_USART_RTS_SET | RTS Set. |
SL_USART_DTR_CLEAR | DTR Clear. |
SL_USART_DTR_SET | Activate DTR. |
SL_USART_MODEM_CONTROL_LAST |
usart_stopbit_typedef_t#
usart_stopbit_typedef_t
Stop bits selection, used for asynchronous operation.
Enumerator | |
---|---|
SL_USART_STOP_BITS_0_5 | 0.5 stop bits. |
SL_USART_STOP_BITS_1 | 1 stop bits. |
SL_USART_STOP_BITS_1_5 | 1.5 stop bits. |
SL_USART_STOP_BITS_2 | 2 stop bits |
usart_hwflowcontol_typedef_t#
usart_hwflowcontol_typedef_t
Hardware Flow Control Selection.
Enumerator | |
---|---|
SL_USART_FLOW_CONTROL_NONE | No hardware flow control. |
SL_USART_FLOW_CONTROL_CTS | CTS signal is enabled for TX flow control. |
SL_USART_FLOW_CONTROL_RTS | RTS signal is enabled for RX flow control. |
SL_USART_FLOW_CONTROL_RTS_CTS | CTS and RTS signals are enabled for TX and RX flow control. |
usart_mode_typedef_t#
usart_mode_typedef_t
USART Mode selection.
Enumerator | |
---|---|
SL_USART_MODE_ASYNCHRONOUS | Asynchronous mode. |
SL_USART_MODE_SYNCHRONOUS_MASTER | Synchronous mode master. |
SL_USART_MODE_SYNCHRONOUS_SLAVE | Synchronous mode slave. |
SL_USART_MODE_SINGLE_WIRE | UART Single-wire (half-duplex); arg = Baudrate. |
SL_USART_MODE_IRDA | UART IrDA; arg = Baudrate. |
usart_misc_control_typedef_t#
usart_misc_control_typedef_t
USART misc control selection.
Enumerator | |
---|---|
SL_USART_MISC_CONTROL_NONE | |
SL_USART_SET_DEFAULT_TX_VALUE | Set default TX value. |
SL_USART_CONTROL_TX | Set transfer line. |
SL_USART_CONTROL_RX | Set receive line. |
SL_USART_CONTROL_BREAK | Set USART control break. |
SL_USART_ABORT_SEND | Abort send. |
SL_USART_ABORT_RECEIVE | Abort receive. |
SL_USART_ABORT_TRANSFER | Abort transfer. |
Typedef Documentation#
Function Documentation#
sl_si91x_usart_init#
sl_status_t sl_si91x_usart_init (usart_peripheral_t usart_instance, sl_usart_handle_t * usart_handle)
Initialize USART/UART interface.
Type | Direction | Argument Name | Description |
---|---|---|---|
usart_peripheral_t | [in] | usart_instance | Pointer to the USART/UART driver |
sl_usart_handle_t * | [in] | usart_handle | Callback function which need to be called on data transfer |
This function will configure the clocks for USART/UART module and also initialization the DMA for UART/USART if DMA is enabled for data transfers.
Returns
status 0 if successful, else error code SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer SL_STATUS_FAIL (0x0001) - Fail , UART/USART initialization failed SL_STATUS _OK (0X000) - Success ,UART/USART initialization done properly
sl_si91x_usart_deinit#
sl_status_t sl_si91x_usart_deinit (sl_usart_handle_t usart_handle)
Deinit USART/UART interface.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
This function will disable the clocks for USART/UART module and also Deinit the DMA for UART/USART if DMA is enabled for data transfers.
Returns
status 0 if successful, else error code SL_STATUS_FAIL (0x0001) - Fail , UART/USART Deinitialization failed SL_STATUS _OK (0X000) - Success ,UART/USART Deinitialization done properly
rsi
sl_si91x_usart_set_power_mode#
sl_status_t sl_si91x_usart_set_power_mode (sl_usart_handle_t usart_handle, power_mode_typedef_t state)
Set the USART/UART power mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
power_mode_typedef_t | [in] | state | power state
|
This function will set UART/USART power mode of operation . In poweroff power state will disable the interrupt , disable DMA channel if DMA mode disable the power to the USART block.So no usart operations are possible when set this mode In powerFull power state will enable the intterupt and set the flags initialization and power on flag so that USART data transfer can takes place
Returns
status 0 if successful, else error code SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument SL_STATUS_FAIL (0x0001) - Fail , UART/USART initialization failed SL_STATUS _OK (0X000) - Success ,UART/USART initialization done properly
Note
powerLow power state is not supported
sl_si91x_usart_register_event_callback#
sl_status_t sl_si91x_usart_register_event_callback (sl_usart_signal_event_t callback_event)
Register the user callback function.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_signal_event_t | [in] | callback_event | Pointer to the function which needs to be called at the time of interrupt |
Returns
status 0 if successful, else error code SL_STATUS_OK (0x0000) - Success SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer SL_STATUS_BUSY (0x0004) - Driver is busy
sl_si91x_usart_unregister_event_callback#
void sl_si91x_usart_unregister_event_callback (void )
Un-register the user callback function.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] |
Returns
none
sl_si91x_usart_send_data#
sl_status_t sl_si91x_usart_send_data (sl_usart_handle_t usart_handle, const void * data, uint32_t data_length)
Start sending data to USART transmitter.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
const void * | [in] | data | Pointer to the variable which contains transfer data |
uint32_t | [in] | data_length | Data_length to Send |
if DMA mode is set this function will configure the DMA channel and enables the DMA channel , then transfer's the data pointed to it else it fill the data to the transfer FIFO and transfer the data
Returns
status 0 if successful, else error code SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument SL_STATUS_FAIL (0x0001) - Fail , Data transfer failed SL_STATUS_BUSY (0x0004) - Busy ,already data transfer is going on SL_STATUS _OK (0X000) - Success ,UART/USART initialization done properly
sl_si91x_usart_receive_data#
sl_status_t sl_si91x_usart_receive_data (sl_usart_handle_t usart_handle, void * data, uint32_t data_length)
Start receiving data from USART receiver.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
void * | [in] | data | Pointer to the variable which will store the received data |
uint32_t | [in] | data_length | Data_length to receive |
If DMA mode is set, it configures the DMA channel, enables the DMA channel, and receives data via DMA. If DMA mode is not set, it receives the data from FIFO.
Returns
status 0 if successful, else error code SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument SL_STATUS_FAIL (0x0001) - Fail , Data transfer failed SL_STATUS_BUSY (0x0004) - Busy ,already data transfer is going on SL_STATUS _OK (0X000) - Success ,UART/USART initialization done properly
sl_si91x_usart_transfer_data#
sl_status_t sl_si91x_usart_transfer_data (sl_usart_handle_t usart_handle, const void * data_out, void * data_in, uint32_t data_length)
Start sending/receiving data to/from USART transmitter/receiver.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
const void * | [in] | data_out | Pointer to the variable which will store the data to be transferred |
void * | [in] | data_in | Pointer to the variable which will store the received data |
uint32_t | [in] | data_length | Data_length to receive |
This function will configure the DMA channel and enables the DMA channel , DMA if DMA mode is set and transfer's the data pointed to it
Returns
status 0 if successful, else error code SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument SL_STATUS_FAIL (0x0001) - Fail , Data transfer failed SL_STATUS_BUSY (0x0004) - Busy ,already data transfer is going on SL_STATUS _OK (0X000) - Success ,UART/USART initialization done properly
Note
This function to be use in USART mode only i.e synchronous mode only in asynchronous mode use sl_si91x_usart_receive_data() and sl_si91x_usart_send_data()
sl_si91x_usart_get_tx_data_count#
uint32_t sl_si91x_usart_get_tx_data_count (sl_usart_handle_t usart_handle)
Get the USART/UART transfer data count.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
This function will return the USART data transferred count.
Returns
return the no of bytes transferred
sl_si91x_usart_get_rx_data_count#
uint32_t sl_si91x_usart_get_rx_data_count (sl_usart_handle_t usart_handle)
Get the USART/UART received data count.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
This function will return the USART/UART data received count
Returns
return the no of bytes received
sl_si91x_usart_set_configuration#
sl_status_t sl_si91x_usart_set_configuration (sl_usart_handle_t usart_handle, sl_si91x_usart_control_config_t * control_configuration, uint32_t baud_rate)
Configure the different configurations of USART Interface.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
sl_si91x_usart_control_config_t * | [in] | control_configuration | pointer to the USART configurations |
uint32_t | [in] | baud_rate | baud rate to data transfer |
This function configure the USART in different configurations such as USART mode, Data Bits, Parity , stop bits, flow control and baud rate.
Returns
status 0 if successful, else error code SL_STATUS_BUSY (0x0004) - Busy ,already data transfer is going on SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument SL_STATUS_INVALID_MODE (0x0024) - USART Invalid mode of operation SL_STATUS_NOT_SUPPORTED(0x000F) - Feature not supported SL_STATUS _OK (0X000) - Success ,UART/USART initialization done properly
sl_si91x_usart_get_status#
sl_usart_status_t sl_si91x_usart_get_status (sl_usart_handle_t usart_handle)
Get USART status.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
This function will return USART/UART transfer and receive status
Returns
usart line status * tx busy ,rx_busy, tx_underflow ,rx overflow, rx break, rx framing error rx parity error
sl_si91x_usart_set_modem_control#
sl_status_t sl_si91x_usart_set_modem_control (sl_usart_handle_t usart_handle, sl_usart_modem_control_t control)
Set USART Modem Control line state.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
sl_usart_modem_control_t | [in] | control | usart modem control |
This function will set the USART modem control line
Returns
status 0 if successful, else error code SL_STATUS_NOT_SUPPORTED(0x000F) - Feature not supported SL_STATUS _OK (0x000) - Success ,UART/USART initialization done properly
sl_si91x_usart_get_modem_status#
sl_usart_modem_status_t sl_si91x_usart_get_modem_status (sl_usart_handle_t usart_handle)
Get USART Modem Control line state.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_usart_handle_t | [in] | usart_handle | Pointer to the USART/UART driver |
This function return USART modem control status
Returns
usart modem status states are active or not
sl_si91x_usart_get_version#
sl_usart_version_t sl_si91x_usart_get_version (void )
Get the USART version.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] |
This function is used to know the USART version
Returns
sl_usart_version_t type version
sl_si91x_usart_get_configurations#
sl_status_t sl_si91x_usart_get_configurations (uint8_t usart_module, sl_si91x_usart_control_config_t * usart_config)
Get the USART configurations set.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | usart_module | USART peripheral type
|
sl_si91x_usart_control_config_t * | [in] | usart_config | Pointer to the USART configurations structure |
Get the USART configurations set in the module such as baudrate ,parity bit stop bits etc
Returns
status 0 if successful, else error code SL_STATUS_NULL_POINTER(0x0022) - Invalid NULL pointer received as argument SL_STATUS _OK (0x000) - Success ,UART/USART configurations retrieved successfully