USART#

Introduction#

USART is used in communication through wired medium in both synchronous and asynchronous fashion.

In synchronous mode, both full duplex and half duplex (single wire) modes are supported.

UART Frame FormatUART Frame Format

A USART frame consists of:

  • Start bit: Indicates the beginning of a data frame.

  • Data bits: The actual data to be transmitted (typically 7 or 8 bits).

  • Parity bit: Optional bit for error checking.

  • Stop bit: Indicates the end of a data frame.

USART is widely used in embedded systems due to its simplicity and versatility. Some common applications include:

  • Sensor data acquisition: Reading data from sensors like temperature, humidity, pressure, etc.

  • Actuator control: Sending commands to motors, servos, and other actuators.

  • Human-machine interface (HMI): Communicating with keyboards, displays, and other user interface devices.

  • Debug and logging: Sending diagnostic information to a computer for analysis.

  • Communication with other devices: Interfacing with modules like GPS, Bluetooth, Wi-Fi, etc.

Configuration#

USART can be configured using several parameters, including:

Note

In synchronous mode, USART signals are given out on the interface, and interface signals are given to the USART module, blocking inputs to UART.

In asynchronous mode, UART signals are given out on the interface, and interface signals are given to the UART module, blocking inputs to USART.

For more information on configuring available parameters, see the respective peripheral example readme document.

Usage#

USART has to be initialized and configured first by calling 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:

You can use this in two modes:

  1. Full Duplex Mode:

    • Set synchronous mode.

    • Write data to TX FIFO.

    • Write count to RX_CNT.

    • Set auto_flow_ctrl if controlled transfers on the interface.

  2. Half Duplex Mode:

    1. Transmit Mode:

      • Reset full_duplex_mode.

      • Set tx_mode.

      • Reset rx_mode.

      • Write data to TX_FIFO by polling the FIFO full/afull status.

    2. Receive Mode:

      • Reset full_duplex_mode.

      • Set rx_mode.

      • Reset tx_mode.

      • Write RX_CNT with the number of bytes to be received.

      • Read data from RX_FIFO by polling the RX FIFO empty/aempty status.

The other common functions include the following:

  1. sl_si91x_usart_init

  2. sl_si91x_usart_set_configuration

  3. sl_si91x_usart_register_event_callback

  4. sl_si91x_usart_multiple_instance_register_event_callback

  5. sl_si91x_usart_async_send_data

  6. sl_si91x_usart_async_receive_data

  7. sl_si91x_usart_transfer_data

  8. sl_si91x_usart_get_status

  9. sl_si91x_usart_get_tx_data_count

  10. sl_si91x_usart_get_rx_data_count

  11. sl_si91x_usart_set_modem_control

  12. sl_si91x_usart_deinit

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
}

Enumeration for 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
}

Enumeration for general power states used in this peripheral.

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
}

Enumeration for USART data bits configuration.

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
}

Enumeration for USART 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
}

Enumeration for 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
}

Enumeration for USART stop bits selection.

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
}

Enumeration for 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
}

Enumeration for 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
}

Enumeration for USART miscellaneous control selection.

Typedefs#

typedef ARM_USART_SignalEvent_t

Alias for ARM_USART_SignalEvent_t type.

typedef ARM_USART_STATUS

Alias for ARM_USART_Status type.

typedef ARM_POWER_STATE

Alias for ARM_POWER_STATE type.

typedef ARM_USART_MODEM_CONTROL

Alias for ARM_USART_MODEM_CONTROL type.

typedef ARM_USART_MODEM_STATUS

Alias for ARM_USART_MODEM_STATUS type.

typedef ARM_USART_CAPABILITIES

Alias for ARM_USART_CAPABILITIES type.

typedef ARM_DRIVER_USART

Alias for ARM_DRIVER_USART type.

typedef USART_RESOURCES

Alias for USART_RESOURCES type.

typedef const void *

Alias for a constant void pointer type, used as a handle for USART resources.

Functions#

sl_status_t
sl_si91x_usart_init(usart_peripheral_t usart_instance, sl_usart_handle_t *usart_handle)

To initialize the USART/UART module.

sl_status_t
sl_si91x_usart_deinit(sl_usart_handle_t usart_handle)

To uninitialize the USART/UART module.

sl_status_t
sl_si91x_usart_register_event_callback(sl_usart_signal_event_t callback_event)

To register the user callback function for USART events.

void

To unregister the user callback function for USART events.

sl_status_t
sl_si91x_usart_multiple_instance_register_event_callback(usart_peripheral_t usart_instance, sl_usart_signal_event_t callback_event)

To register the user callback function for multiple USART instances.

void

To unregister the user callback function for multiple USART instances.

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

To 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 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 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 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 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)

To configure the USART interface with non-UC configurations.

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)

To set the USART modem control line.

sl_si91x_usart_get_modem_status(sl_usart_handle_t usart_handle)

To get the USART modem control status.

To get the USART version.

sl_status_t
sl_si91x_usart_get_configurations(uint8_t usart_module, sl_si91x_usart_control_config_t *usart_config)

To get the USART configurations set in the module, such as baud rate, parity bit, stop bits, etc.

Enumeration Documentation#

usart_event_typedef_t#

usart_event_typedef_t

Enumeration for USART/UART events.

This enumeration defines the various events that can occur in the USART/UART interface. Each event corresponds to a specific condition or status change in the USART/UART operation.

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.

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 (Clear to Send) event.

SL_USART_EVENT_DSR

DSR (Data Set Ready) event.

SL_USART_EVENT_DCD

DCD (Data Carrier Detect) event.

SL_USART_EVENT_RI

RI (Ring Indicator) event.


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

power_mode_typedef_t#

power_mode_typedef_t

Enumeration for general power states used in this peripheral.

This enumeration defines the various power states that can be used to control the power mode of the peripheral. Each state corresponds to a specific power configuration.

Enumerator
SL_POWER_OFF

Power off state.

SL_POWER_LOW

Low power state.

SL_POWER_FULL

Full power state.

SL_POWER_MODE_LAST

Last power mode for validation purposes.


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

usart_databits_typedef_t#

usart_databits_typedef_t

Enumeration for USART data bits configuration.

This enumeration defines the possible data bit configurations for the USART interface. The user can select the appropriate data bit setting based on their application requirements.

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 108 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

usart_parity_typedef_t#

usart_parity_typedef_t

Enumeration for USART parity selection.

This enumeration defines the possible parity configurations for the USART interface. The user can select the appropriate parity setting based on their application requirements.

Enumerator
SL_USART_NO_PARITY

No parity.

SL_USART_EVEN_PARITY

Even parity.

SL_USART_ODD_PARITY

Odd parity.


Definition at line 121 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

Enumeration for USART modem control selection.

This enumeration defines the possible modem control configurations for the USART interface. The user can select the appropriate modem control setting based on their application requirements.

Enumerator
SL_USART_RTS_CLEAR

Clear RTS (Request to Send).

SL_USART_RTS_SET

Set RTS (Request to Send).

SL_USART_DTR_CLEAR

Clear DTR (Data Terminal Ready).

SL_USART_DTR_SET

Set DTR (Data Terminal Ready).

SL_USART_MODEM_CONTROL_LAST

Last modem control option for validation purposes.


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

usart_stopbit_typedef_t#

usart_stopbit_typedef_t

Enumeration for USART stop bits selection.

This enumeration defines the possible stop bit configurations for the USART interface, used for asynchronous operation. The user can select the appropriate stop bit setting based on their application requirements.

Enumerator
SL_USART_STOP_BITS_1

1 stop bit.

SL_USART_STOP_BITS_1_5

1.5 stop bits.

SL_USART_STOP_BITS_2

2 stop bits.


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

usart_hwflowcontol_typedef_t#

usart_hwflowcontol_typedef_t

Enumeration for hardware flow control selection.

This enumeration defines the possible hardware flow control configurations for the USART interface. The user can select the appropriate flow control setting based on their application requirements.

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 160 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_usart.h

usart_mode_typedef_t#

usart_mode_typedef_t

Enumeration for USART mode selection.

This enumeration defines the possible modes of operation for the USART interface. It is crucial to tailor the communication channel to the specific requirements of a system.

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 174 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

Enumeration for USART miscellaneous control selection.

Note

  • UART provides the underlying serial communication, while IrDA enables the wireless transmission of that data using infrared light.

This enumeration defines the various miscellaneous control options available for the USART interface. These controls allow for fine-tuning and managing specific USART operations.

Enumerator
SL_USART_MISC_CONTROL_NONE

No miscellaneous control.

SL_USART_SET_DEFAULT_TX_VALUE

Set default TX value.

SL_USART_CONTROL_TX

Control the transfer line.

SL_USART_CONTROL_RX

Control the receive line.

SL_USART_CONTROL_BREAK

Set USART control break.

SL_USART_ABORT_SEND

Abort the send operation.

SL_USART_ABORT_RECEIVE

Abort the receive operation.

SL_USART_ABORT_TRANSFER

Abort the transfer operation.


Definition at line 192 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

Alias for ARM_USART_SignalEvent_t type.


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

Alias for ARM_USART_Status type.


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

Alias for ARM_POWER_STATE type.


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

Alias for ARM_USART_MODEM_CONTROL type.


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

Alias for ARM_USART_MODEM_STATUS type.


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

Alias for ARM_USART_CAPABILITIES type.


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

Alias for ARM_DRIVER_USART type.


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

Alias for USART_RESOURCES type.


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

Alias for a constant void pointer type, used as a handle for USART resources.


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)

To initialize the USART/UART module.

Parameters
[in]usart_instance

The USART instance (USART_0, UART_1, ULPUART).

[in]usart_handle

Pointer to the USART/UART driver.

This function configures the clocks for the USART/UART module and also initializes the DMA for UART/USART if DMA is enabled for data transfers.

Returns

  • sl_status_t Status code indicating the result:

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

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

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

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 260 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)

To uninitialize the USART/UART module.

Parameters
[in]usart_handle

Pointer to the USART/UART driver.

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

Returns

  • sl_status_t Status code indicating the result:

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

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

Note

  • When the USART/UART module is used in combination with other peripherals, while deinitializing in the application, see 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 the below API to power down the particular power domain if other peripherals 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, see 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. See the rsi_power_save.h file for all power gate definitions.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 289 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)

To register the user callback function for USART events.

Parameters
[in]callback_event

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

This API registers a user-defined callback function for USART events. If another callback is registered without unregistering the previous callback, it returns an error code. Therefore, it is mandatory to unregister the callback before registering another callback.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success.

    • SL_STATUS_BUSY (0x0004) - Driver is busy.

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

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 312 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 )

To unregister the user callback function for USART events.

Parameters
N/A

This API unregisters a user-defined callback function for USART events. It is mandatory to unregister the current callback before registering a new one.


Definition at line 321 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)

To register the user callback function for multiple USART instances.

Parameters
[in]usart_instance

The USART instance.

[in]callback_event

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

This function registers a user-defined callback function for multiple USART instances (e.g., USART_0, UART_1, ULP_UART). This API should be used to handle different USART instances.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success.

    • SL_STATUS_BUSY (0x0004) - Driver is busy.

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

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 343 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)

To unregister the user callback function for multiple USART instances.

Parameters
[in]usart_instance

This is the USART instance.

This function unregisters a user-defined callback function for multiple USART instances (e.g., USART_0, UART_1, ULP_UART). This API should be used to handle different USART instances.


Definition at line 355 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)

To 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

Length of the data to be sent.

If DMA mode is set, this function will configure the DMA channel and enable the DMA channel, then transfer the data pointed to it. Otherwise, it fills the data to the transfer FIFO and transfers the data.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success, data transfer completed.

    • SL_STATUS_FAIL (0x0001) - Function failed, data transfer failed.

    • SL_STATUS_BUSY (0x0004) - Busy, data transfer is already in progress.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameter.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 380 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 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 contains the data to be transferred.

[in]data_length

Length of the data to be transferred.

This function returns immediately (non-blocking) and data transfer happens asynchronously. Once the data transfer completes, the registered user callback gets invoked.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success, data transfer completed.

    • SL_STATUS_FAIL (0x0001) - Function failed, data transfer failed.

    • SL_STATUS_BUSY (0x0004) - Busy, data transfer is already in progress.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameter.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 405 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 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

Length of the data to be received.

If DMA mode is set, this function 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

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success, data received successfully.

    • SL_STATUS_FAIL (0x0001) - Function failed, data transfer failed.

    • SL_STATUS_BUSY (0x0004) - Busy, data transfer is already in progress.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameter.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 430 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 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

Length of the data to be received.

This function returns immediately (non-blocking) and data reception happens asynchronously. Once the data reception completes, the registered user callback gets invoked.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success, data received successfully.

    • SL_STATUS_FAIL (0x0001) - Function failed, data transfer failed.

    • SL_STATUS_BUSY (0x0004) - Busy, data transfer is already in progress.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameter.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 455 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 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

Length of the data to be received.

This function sends and receives data to and from the USART transmitter and receiver in synchronous mode of operation. It configures the DMA channel and enables the DMA channel, if DMA mode is set, and transfers the data pointed to it; otherwise, it transfers the data from FIFO.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success, data transfer completed.

    • SL_STATUS_FAIL (0x0001) - Function failed, data transfer failed.

    • SL_STATUS_BUSY (0x0004) - Busy, data transfer is already in progress.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameter.

Note

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 485 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

This is the pointer to the USART/UART driver.

This function returns the number of bytes transferred by the USART/UART. It can be used to check the progress of data transmission.

Returns

  • uint32_t The number of bytes transferred.


Definition at line 501 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

This is the pointer to the USART/UART driver.

This function returns the number of bytes received by the USART/UART. It can be used to check the progress of data reception.

Returns

  • uint32_t The number of bytes received.


Definition at line 514 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 configures 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 a particular instance. When these macros are enabled, configurations are taken directly from the UC and this parameter is not considered.

Returns

  • sl_status_t Status code indicating the result:

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

    • SL_STATUS_BUSY (0x0004) - Busy, data transfer is already in progress.

    • SL_STATUS_NOT_SUPPORTED (0x000F) - Feature not supported.

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

    • SL_STATUS_INVALID_MODE (0x0024) - USART invalid mode of operation.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 539 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)

To configure the USART interface with non-UC configurations.

Parameters
[in]usart_handle

Pointer to the USART/UART driver.

[in]control_configuration

Pointer to the USART configurations.

This internal function configures the USART interface with different configurations, such as USART mode, data bits, parity, stop bits, flow control, and baud rate. This API will not pick the configurations from USART UC.

Returns

  • sl_status_t Status code indicating the result:

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

    • SL_STATUS_BUSY (0x0004) - Busy, data transfer is already in progress.

    • SL_STATUS_NOT_SUPPORTED (0x000F) - Feature not supported.

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

    • SL_STATUS_INVALID_MODE (0x0024) - USART invalid mode of operation.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 562 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 returns the USART/UART transfer and receive status. It provides information about the current state of the USART/UART, including:

  • TX busy

  • RX busy

  • TX underflow

  • RX overflow

  • RX break

  • RX framing error

  • RX parity error

Returns

  • sl_usart_status_t The status of the USART/UART.


Definition at line 583 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)

To set the USART modem control line.

Parameters
[in]usart_handle

Pointer to the USART/UART driver.

[in]control

The USART modem control.

This function sets the USART modem control line based on the provided control parameter.

Returns

  • sl_status_t Status code indicating the result:

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

    • SL_STATUS_NOT_SUPPORTED (0x000F) - Feature not supported.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 600 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)

To get the USART modem control status.

Parameters
[in]usart_handle

Pointer to the USART/UART driver.

This function returns the status of the USART modem control lines, indicating whether the states are active or not.

Returns

  • sl_usart_modem_status_t The status of the USART modem control lines.


Definition at line 612 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 )

To get the USART version.

Parameters
N/A

This function returns the version information of the USART driver. It can be used to check the driver version for compatibility and debugging purposes.

Returns


Definition at line 623 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)

To get the USART configurations set in the module, such as baud rate, 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.

This function retrieves the current configurations of the specified USART module.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success, UART/USART configurations retrieved successfully.

    • SL_STATUS_NULL_POINTER (0x0022) - Invalid NULL pointer received as argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


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