USART#


Introduction#

The USART/UART driver offers a robust set of functionalities to enable seamless communication over the USART/UART interface. This driver supports various features, including DMA (Direct Memory Access) for efficient data transfer, event callback mechanisms for interrupt handling, etc. The driver simplifies the implementation of serial communication protocols and enhances the overall performance and reliability of the system.


Configuration#

To configure the USART/UART driver, user can utilize a comprehensive set of parameters and functions tailored to their specific requirements. This configuration process involves setting up various aspects of the USART/UART module, such as baud rate, data bits, parity, stop bits, flow control, and DMA settings if DMA is enabled. Additionally, register callback functions can be used to handle events and interrupts, ensuring timely and efficient communication. The driver also supports multiple USART/UART instances, allowing for versatile usage across different peripherals.

  • For more information on configuring available parameters refer to the respective peripheral example readme document.


Usage#

USART has to be initialized and configured first by calling the sl_si91x_usart_init. The DMA (Direct Memory Access) controller in the USART driver will enable efficient data transfer, thus reducing CPU overhead. Initialization of the DMA for UART/USART will also be done with the same USART init function, if DMA is enabled for data transfers. The other common functions include the following:

  • Once initialised, you can configure the module using sl_si91x_usart_set_configuration. Here you can set appropriate configurations such as USART module Recieve-transfer configuration (flow control), data bits, parity and baud rate.

There are a total of three instances of USART - USART, UART2, ULP UART. USART can be used synchronously as well as asynchronously. For USART in synchronous mode use the function sl_si91x_usart_transfer_data. Here, data transfer is done with a shared clock signal between the sender and receiver. On the other hand, to use USART in asynchronous mode, for UART2, ULP UART use sl_si91x_usart_async_send_data and sl_si91x_usart_async_receive_data to send and receive data asynchronously. Here, data transfer will happen asynchronously i.e., in non-blocking. Once the data transfer is complete, user event callback function will be called.

User can also use sl_si91x_usart_get_tx_data_count and sl_si91x_usart_get_rx_data_count to get the number of bytes transferred and received, respectively.

  • sl_si91x_usart_deinit can be used to deinitialize the module. Similar to initialization, de-initialization of the DMA for UART/USART will also be done with the USART de-init function, if DMA is enabled for data transfers.

Modules#

sl_si91x_usart_control_config_t

sl_usart_version_t

Enumerations#

enum
SL_USART_EVENT_SEND_COMPLETE = ARM_USART_EVENT_SEND_COMPLETE
SL_USART_EVENT_RECEIVE_COMPLETE = ARM_USART_EVENT_RECEIVE_COMPLETE
SL_USART_EVENT_TRANSFER_COMPLETE = ARM_USART_EVENT_TRANSFER_COMPLETE
SL_USART_EVENT_TX_COMPLETE = ARM_USART_EVENT_TX_COMPLETE
SL_USART_EVENT_TX_UNDERFLOW = ARM_USART_EVENT_TX_UNDERFLOW
SL_USART_EVENT_RX_OVERFLOW = ARM_USART_EVENT_RX_OVERFLOW
SL_USART_EVENT_RX_TIMEOUT = ARM_USART_EVENT_RX_TIMEOUT
SL_USART_EVENT_RX_BREAK = ARM_USART_EVENT_RX_BREAK
SL_USART_EVENT_RX_FRAMING_ERROR = ARM_USART_EVENT_RX_FRAMING_ERROR
SL_USART_EVENT_RX_PARITY_ERROR = ARM_USART_EVENT_RX_PARITY_ERROR
SL_USART_EVENT_CTS = ARM_USART_EVENT_CTS
SL_USART_EVENT_DSR = ARM_USART_EVENT_DSR
SL_USART_EVENT_DCD = ARM_USART_EVENT_DCD
SL_USART_EVENT_RI = ARM_USART_EVENT_RI
}

USART/UART Events.

enum
SL_POWER_OFF = ARM_POWER_OFF
SL_POWER_LOW = ARM_POWER_LOW
SL_POWER_FULL = ARM_POWER_FULL
SL_POWER_MODE_LAST
}

General power states.

enum
SL_USART_DATA_BITS_5 = ARM_USART_DATA_BITS_5
SL_USART_DATA_BITS_6 = ARM_USART_DATA_BITS_6
SL_USART_DATA_BITS_7 = ARM_USART_DATA_BITS_7
SL_USART_DATA_BITS_8 = ARM_USART_DATA_BITS_8
}

Databit selection.

enum
SL_USART_NO_PARITY = ARM_USART_PARITY_NONE
SL_USART_EVEN_PARITY = ARM_USART_PARITY_EVEN
SL_USART_ODD_PARITY = ARM_USART_PARITY_ODD
}

Parity selection.

enum
SL_USART_RTS_CLEAR = ARM_USART_RTS_CLEAR
SL_USART_RTS_SET = ARM_USART_RTS_SET
SL_USART_DTR_CLEAR = ARM_USART_DTR_CLEAR
SL_USART_DTR_SET = ARM_USART_DTR_SET
SL_USART_MODEM_CONTROL_LAST
}

USART Modem control selection.

enum
SL_USART_STOP_BITS_1 = ARM_USART_STOP_BITS_1
SL_USART_STOP_BITS_1_5 = ARM_USART_STOP_BITS_1_5
SL_USART_STOP_BITS_2 = ARM_USART_STOP_BITS_2
}

Stop bits selection, used for asynchronous operation.

enum
SL_USART_FLOW_CONTROL_NONE = ARM_USART_FLOW_CONTROL_NONE
SL_USART_FLOW_CONTROL_CTS = ARM_USART_FLOW_CONTROL_CTS
SL_USART_FLOW_CONTROL_RTS = ARM_USART_FLOW_CONTROL_RTS
SL_USART_FLOW_CONTROL_RTS_CTS = ARM_USART_FLOW_CONTROL_RTS_CTS
}

Hardware Flow Control Selection.

enum
SL_USART_MODE_ASYNCHRONOUS = ARM_USART_MODE_ASYNCHRONOUS
SL_USART_MODE_SYNCHRONOUS_MASTER = ARM_USART_MODE_SYNCHRONOUS_MASTER
SL_USART_MODE_SYNCHRONOUS_SLAVE = ARM_USART_MODE_SYNCHRONOUS_SLAVE
SL_USART_MODE_SINGLE_WIRE = ARM_USART_MODE_SINGLE_WIRE
SL_USART_MODE_IRDA = ARM_USART_MODE_IRDA
}

USART Mode selection.

enum
SL_USART_MISC_CONTROL_NONE
SL_USART_SET_DEFAULT_TX_VALUE = ARM_USART_SET_DEFAULT_TX_VALUE
SL_USART_CONTROL_TX = ARM_USART_CONTROL_TX
SL_USART_CONTROL_RX = ARM_USART_CONTROL_RX
SL_USART_CONTROL_BREAK = ARM_USART_CONTROL_BREAK
SL_USART_ABORT_SEND = ARM_USART_ABORT_SEND
SL_USART_ABORT_RECEIVE = ARM_USART_ABORT_RECEIVE
SL_USART_ABORT_TRANSFER = ARM_USART_ABORT_TRANSFER
}

USART misc control selection.

Typedefs#

typedef ARM_USART_SignalEvent_t
typedef ARM_USART_STATUS
typedef ARM_POWER_STATE
typedef ARM_USART_MODEM_CONTROL
typedef ARM_USART_MODEM_STATUS
typedef ARM_USART_CAPABILITIES
typedef ARM_DRIVER_USART
typedef USART_RESOURCES
typedef const void *

Functions#

sl_status_t
sl_si91x_usart_init(usart_peripheral_t usart_instance, sl_usart_handle_t *usart_handle)

Initilize the USART/UART module.

sl_status_t
sl_si91x_usart_deinit(sl_usart_handle_t usart_handle)

Uninitialize the USART/UART module.

sl_status_t
sl_si91x_usart_register_event_callback(sl_usart_signal_event_t callback_event)

Register the user callback function.

void

Unregister the user callback function.

sl_status_t
sl_si91x_usart_multiple_instance_register_event_callback(usart_peripheral_t usart_instance, sl_usart_signal_event_t callback_event)

This function registers the user callback function for multiple USART instances i.e., to use different instance (USART_O, UART_1, ULP_UART) this API need to use.

void

Unregister the user callback function in case of multiple USART instances.

sl_status_t
sl_si91x_usart_send_data(sl_usart_handle_t usart_handle, const void *data, uint32_t data_length)

Send the USART data when USART/UART is configured.

sl_status_t
sl_si91x_usart_async_send_data(sl_usart_handle_t usart_handle, const void *data, uint32_t data_length)

To Send the data in async mode when USART/UART is configured.

sl_status_t
sl_si91x_usart_receive_data(sl_usart_handle_t usart_handle, void *data, uint32_t data_length)

To receive the data when USART/UART is configured.

sl_status_t
sl_si91x_usart_async_receive_data(sl_usart_handle_t usart_handle, void *data, uint32_t data_length)

To receive the data in async mode when USART/UART is configured.

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)

To send and receive the data when USART in Synchronous mode is enabled.

uint32_t
sl_si91x_usart_get_tx_data_count(sl_usart_handle_t usart_handle)

To get the TX data count of USART/UART.

uint32_t
sl_si91x_usart_get_rx_data_count(sl_usart_handle_t usart_handle)

To get the RX data count of USART/UART.

sl_status_t
sl_si91x_usart_set_configuration(sl_usart_handle_t usart_handle, sl_si91x_usart_control_config_t *control_configuration)

To control and configure the USART/UART module in different configurations.

sl_status_t
sli_si91x_usart_set_non_uc_configuration(sl_usart_handle_t usart_handle, sl_si91x_usart_control_config_t *control_configuration)
sl_usart_status_t
sl_si91x_usart_get_status(sl_usart_handle_t usart_handle)

To get the USART/UART status.

sl_status_t
sl_si91x_usart_set_modem_control(sl_usart_handle_t usart_handle, sl_usart_modem_control_t control)

This function will set the USART modem control line.

sl_usart_modem_status_t
sl_si91x_usart_get_modem_status(sl_usart_handle_t usart_handle)

This function return USART modem control status.

This function is used to know the USART version.

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 in the module such as baudrate, parity bit stop bits etc.

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.


Definition at line 67 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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

Definition at line 85 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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


Definition at line 93 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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.


Definition at line 101 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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

Definition at line 108 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

usart_stopbit_typedef_t#

usart_stopbit_typedef_t

Stop bits selection, used for asynchronous operation.

Enumerator
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


Definition at line 117 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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.


Definition at line 124 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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.


Definition at line 133 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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.


Definition at line 142 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

Typedef Documentation#

sl_usart_signal_event_t#

typedef ARM_USART_SignalEvent_t sl_usart_signal_event_t

Definition at line 53 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_usart_status_t#

typedef ARM_USART_STATUS sl_usart_status_t

Definition at line 54 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_usart_power_state_t#

typedef ARM_POWER_STATE sl_usart_power_state_t

Definition at line 55 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_usart_modem_control_t#

typedef ARM_USART_MODEM_CONTROL sl_usart_modem_control_t

Definition at line 56 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_usart_modem_status_t#

typedef ARM_USART_MODEM_STATUS sl_usart_modem_status_t

Definition at line 57 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_usart_capabilities_t#

typedef ARM_USART_CAPABILITIES sl_usart_capabilities_t

Definition at line 58 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_usart_driver_t#

typedef ARM_DRIVER_USART sl_usart_driver_t

Definition at line 59 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

usart_resources_t#

typedef USART_RESOURCES usart_resources_t

Definition at line 60 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_usart_handle_t#

typedef const void* sl_usart_handle_t

Definition at line 61 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

Function Documentation#

sl_si91x_usart_init#

sl_status_t sl_si91x_usart_init (usart_peripheral_t usart_instance, sl_usart_handle_t * usart_handle)

Initilize the USART/UART module.

Parameters
[in]usart_instance

USART Instance (USART_0, UART_1, ULPUART)

[in]usart_handle

Pointer to the USART/UART driver

This function will configure the clocks for USART/UART module and also initialization of the DMA for UART/USART, if DMA is enabled for data transfers.

This function will configure the clocks for USART/UART module and also initialize the DMA for UART/USART if DMA is enabled for data transfers. Returns

  • status 0 if successful, else error code as follows:

    • SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer

    • SL_STATUS_FAIL (0x0001) - Fail, UART/USART initialization failed

    • SL_STATUS_OK (0x0000) - Success, UART/USART initialization done properly


Definition at line 192 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_deinit#

sl_status_t sl_si91x_usart_deinit (sl_usart_handle_t usart_handle)

Uninitialize the USART/UART module.

Parameters
[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 as follows:

    • SL_STATUS_FAIL (0x0001) - Fail, UART/USART Deinitialization failed

    • SL_STATUS_OK (0x0000) - Success, UART/USART Deinitialization done properly

Note

  • When USART/UART module is used in combination with other peripherals, while deinitializing in the application, refer to the notes below:

    1. Whenever sl_si91x_usart_deinit() gets called, it will disable the clock for the peripheral. To power off the peripheral we have to power down the power domain (PERI_EFUSE) which contains the different peripherals mentioned below. i.e USART, UART, I2C, SSI Master, SSI Slave, Generic-SPI Master, I2S Master, I2S Slave, Micro-DMA Controller, Config Timer, Random-Number Generator, CRC Accelerator, SIO, QEI, MCPWM and EFUSE. Use below API to power down the particular power doamin if other periherals are not being used: sl_si91x_peri_efuse_power_down(power_down);

    2. A few peripherals(ULP Peripherals, UULP Peripherals, GPDMA and SDIO-SPI) have separate domains; those can be powered down independently. For additional details, refer to the Power architecture section in the Hardware Reference Manual. Here ULP_UART has a separate power domain ULPSS_PWRGATE_ULP_UART, which can be powered down independently. Refer to rsi_power_save.h file for all power gates definitions.


Definition at line 216 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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.

Parameters
[in]callback_event

Pointer to the function which needs to be called at the time of interrupt

If another callback is registered without unregistering previous callback then, it returns an error code, so it is mandatory to unregister the callback before registering to another callback.

Returns

  • status 0 if successful, else error code as follows:

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer

    • SL_STATUS_BUSY (0x0004) - Driver is busy


Definition at line 233 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_unregister_event_callback#

void sl_si91x_usart_unregister_event_callback (void )

Unregister the user callback function.

Parameters
[in]

Unregister the user callback function before regsitering new callback function.

Returns

  • none


Definition at line 243 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_multiple_instance_register_event_callback#

sl_status_t sl_si91x_usart_multiple_instance_register_event_callback (usart_peripheral_t usart_instance, sl_usart_signal_event_t callback_event)

This function registers the user callback function for multiple USART instances i.e., to use different instance (USART_O, UART_1, ULP_UART) this API need to use.

Parameters
[in]usart_instance

USART Instance

[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


Definition at line 257 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_multiple_instance_unregister_event_callback#

void sl_si91x_usart_multiple_instance_unregister_event_callback (usart_peripheral_t usart_instance)

Unregister the user callback function in case of multiple USART instances.

Parameters
[in]usart_instance

USART Instance

Returns

  • none


Definition at line 265 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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)

Send the USART data when USART/UART is configured.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

[in]data

Pointer to the variable which contains transfer data

[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 transfers 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


Definition at line 283 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_async_send_data#

sl_status_t sl_si91x_usart_async_send_data (sl_usart_handle_t usart_handle, const void * data, uint32_t data_length)

To Send the data in async mode when USART/UART is configured.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

[in]data

Pointer to the variable which will store the transferred data

[in]data_length

Data_length to transfer

This function returns immediately(non blocking) and data transfer happens asyncronously. Once the data transfer compeletes, registered user callback get invoked

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


Definition at line 302 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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)

To receive the data when USART/UART is configured.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

[in]data

Pointer to the variable which will store the received data

[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 as follows:

    • SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument

    • SL_STATUS_FAIL (0x0001) - Fail, Data transfer failed

    • SL_STATUS_BUSY (0x0004) - Busy, already data transfer is going on

    • SL_STATUS_OK (0x0000) - Success, UART/USART initialization done properly


Definition at line 320 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_async_receive_data#

sl_status_t sl_si91x_usart_async_receive_data (sl_usart_handle_t usart_handle, void * data, uint32_t data_length)

To receive the data in async mode when USART/UART is configured.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

[in]data

Pointer to the variable which will store the received data

[in]data_length

Data_length to receive

This function returns immediately(Non blocking) and data reception happens asyncronously. Once the data reception compeletes, registered user callback get invoked

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


Definition at line 339 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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)

To send and receive the data when USART in Synchronous mode is enabled.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

[in]data_out

Pointer to the variable which will store the data to be transferred

[in]data_in

Pointer to the variable which will store the received data

[in]data_length

Data_length to receive

This function sends and receives the data to and from usart transmitter and receiver in synchronous mode of operation. Configure the DMA channel and enables the DMA channel, if DMA mode is set and transfer's the data pointed to it else transfer the data from fifo.

Returns

  • status 0 if successful, else error code as follows:

    • SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument

    • SL_STATUS_FAIL (0x0001) - Fail, Data transfer failed

    • SL_STATUS_BUSY (0x0004) - Busy, already data transfer is going on

    • SL_STATUS_OK (0x0000) - Success, UART/USART initialization done properly

Note


Definition at line 363 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_get_tx_data_count#

uint32_t sl_si91x_usart_get_tx_data_count (sl_usart_handle_t usart_handle)

To get the TX data count of USART/UART.

Parameters
[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


Definition at line 376 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_get_rx_data_count#

uint32_t sl_si91x_usart_get_rx_data_count (sl_usart_handle_t usart_handle)

To get the RX data count of USART/UART.

Parameters
[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


Definition at line 386 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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)

To control and configure the USART/UART module in different configurations.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

[in]control_configuration

pointer to the USART configurations

This function configure the USART in different configurations such as USART mode, Data Bits, Parity , stop bits, flow control and baud rate.

Note

  • control_configuration - This parameter is used to pass the respective peripheral configuration when
    USART_UC, UART_UC, ULP_UART_UC macros are disabled for particular instance. When this macros are enabled configuration are taken directly from the UC and this parameter is not considered.

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


Definition at line 407 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sli_si91x_usart_set_non_uc_configuration#

sl_status_t sli_si91x_usart_set_non_uc_configuration (sl_usart_handle_t usart_handle, sl_si91x_usart_control_config_t * control_configuration)
Parameters
N/Ausart_handle
N/Acontrol_configuration

Definition at line 427 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_get_status#

sl_usart_status_t sl_si91x_usart_get_status (sl_usart_handle_t usart_handle)

To get the USART/UART status.

Parameters
[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


Definition at line 438 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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)

This function will set the USART modem control line.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

[in]control

usart modem control

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


Definition at line 448 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_get_modem_status#

sl_usart_modem_status_t sl_si91x_usart_get_modem_status (sl_usart_handle_t usart_handle)

This function return USART modem control status.

Parameters
[in]usart_handle

Pointer to the USART/UART driver

Returns

  • usart modem status states are active or not


Definition at line 455 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

sl_si91x_usart_get_version#

sl_usart_version_t sl_si91x_usart_get_version (void )

This function is used to know the USART version.

Parameters
[in]

Returns


Definition at line 462 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

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 in the module such as baudrate, parity bit stop bits etc.

Parameters
[in]usart_module

USART peripheral type

  • 0 - USART0

  • 1 - UART1

  • 2 - ULP_UART

[in]usart_config

Pointer to the USART configurations structure

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 \


Definition at line 477 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h