Synchronous Serial Interface#
Introduction#
The Synchronous Serial Interface (SSI) is a communication protocol used to transfer data synchronously over a serial interface between a microcontroller and a peripheral device. A clock signal is used to synchronize the data transfer.
The Serial Peripheral Interface (SPI) or Microwire interfaces are typically used to implement an SSI connection.
The SiWx91x device supports SSI over SPI.
SSI is widely supported in microcontroller architectures and is simple and flexible.
This mode enables serial communication with Master peripheral devices. All serial transfers are initiated and controlled by the serial bus Master. The figure above shows an example of the SSI configured as a serial Slave in a single-Master bus system. All data transfers to and from the serial Slave are regulated by the serial clock line (sclk_in), driven by the serial Master device. Data is propagated from the serial Slave on one edge of the serial clock line and sampled on the opposite edge. The Slave remains in an idle state until selected by the bus Master. When not actively transmitting data, the Slave must hold its txd line in a high-impedance state to avoid interference with serial transfers to other Slave devices.
Configuration#
SSI allows the configuration of several parameters, including the mode of the SSI clock, which can be set using sl_ssi_clock_config_t and then called by the API sl_si91x_ssi_configure_clock(). The mode of the SSI peripheral clock, such as clock polarity and clock phase, can be set using ssi_peripheral_clock_mode_t. The SSI peripheral device mode (SSI master/SSI slave/ULP SSI Master) can be configured using sl_ssi_instance_t. The bit width may be adjusted between 4 and 16, and the bit rate between 500,000 and 40,000,000 bits per second. All configurations may be done using a structure sl_ssi_control_config_t by sending this structure to the API sl_si91x_ssi_set_configuration(). The SSI slave number can be set using sl_ssi_slave_number_t and called through the API sl_si91x_ssi_set_slave_number().
For more information on configuring available parameters, see the respective peripheral example readme document.
Usage#
Most of the SSI functions take sl_ssi_control_config_t as an argument and are invoked in the following order:
Set the clock for the SSI peripheral by configuring the PLL clock and SOC clock with the value set by the user in the clock configuration structure using sl_si91x_ssi_configure_clock.
Initialize the SSI using sl_si91x_ssi_init.
Control and configure the SSI using sl_si91x_ssi_set_configuration.
Register the user event callback using sl_si91x_ssi_register_event_callback.
Send data to the secondary device using sl_si91x_ssi_send_data.
Uninitialize the SSI using sl_si91x_ssi_deinit.
Modules#
Enumerations#
Enumeration for different SSI callback events.
Enumeration for different SSI peripheral clock modes.
Enumeration for different SSI peripheral device modes.
Enumeration for SSI secondary numbers.
Typedefs#
ARM power state structure.
ARM SPI status.
SSI driver structure.
SSI handle to be passed into APIs.
Callback typedef for SSI.
Functions#
To configure the SSI clock.
To initialize the SSI.
To uninitialize the SSI.
To control and configure the SSI.
To receive data from the secondary device.
To send data to the secondary device.
To send and receive data to the secondary device simultaneously.
To get the SSI version.
To get the transfer status of SSI.
To get the data receive count of the SSI.
To get the transmit data count of the SSI.
To register the user event callback.
To unregister the user event callback.
To fetch the clock division factor.
To fetch the frame length (bit width) of the SSI.
To fetch the transmit FIFO threshold value.
To fetch the receiver FIFO threshold value.
To fetch the receiver sample delay value.
To set the secondary number in multi-secondary operation.
Enumeration Documentation#
ssi_event_typedef_t#
ssi_event_typedef_t
Enumeration for different SSI callback events.
Enumerator | |
---|---|
SSI_EVENT_TRANSFER_COMPLETE | Transfer complete event. |
SSI_EVENT_DATA_LOST | Data lost event. |
SSI_EVENT_MODE_FAULT | Mode fault event. |
100
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
ssi_peripheral_clock_mode_t#
ssi_peripheral_clock_mode_t
Enumeration for different SSI peripheral clock modes.
Enumerator | |
---|---|
SL_SSI_PERIPHERAL_CPOL0_CPHA0 | Mode 0 (CPOL = 0, CPHA = 0). |
SL_SSI_PERIPHERAL_CPOL0_CPHA1 | Mode 1 (CPOL = 0, CPHA = 1). |
SL_SSI_PERIPHERAL_CPOL1_CPHA0 | Mode 2 (CPOL = 1, CPHA = 0). |
SL_SSI_PERIPHERAL_CPOL1_CPHA1 | Mode 3 (CPOL = 1, CPHA = 1). |
SL_SSI_PERIPHERAL_TI_SSI | TI mode. |
SL_SSI_PERIPHERAL_MICROWIRE | Microwire/Half-duplex mode. |
SL_SSI_PERIPHERAL_MODE_LAST | Last member of enum for validation. |
110
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_ssi_instance_t#
sl_ssi_instance_t
Enumeration for different SSI peripheral device modes.
Enumerator | |
---|---|
SL_SSI_MASTER_ACTIVE | Primary mode is active. |
SL_SSI_SLAVE_ACTIVE | Secondary mode is active. |
SL_SSI_ULP_MASTER_ACTIVE | ULP primary mode is active. |
SL_SSI_INSTANCE_LAST | Last member of enum for validation. |
124
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_ssi_slave_number_t#
sl_ssi_slave_number_t
Enumeration for SSI secondary numbers.
Enumerator | |
---|---|
SSI_SLAVE_0 | Secondary No. 1. |
SSI_SLAVE_1 | Secondary No. 2. |
SSI_SLAVE_2 | Secondary No. 3. |
SSI_SLAVE_3 | Secondary No. 4. |
SSI_SLAVE_NUMBER_LAST_ENUM | Last member of enum for validation. |
161
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
Typedef Documentation#
sl_ssi_power_state_t#
sl_ssi_power_state_t
ARM power state structure.
Typedef for ARM power state structure.
56
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_ssi_status_t#
sl_ssi_status_t
ARM SPI status.
Typedef for ARM SPI status.
63
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_ssi_driver_t#
sl_ssi_driver_t
SSI driver structure.
Typedef for SSI driver structure.
70
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_ssi_handle_t#
sl_ssi_handle_t
SSI handle to be passed into APIs.
Typedef for SSI handle to be passed into APIs.
77
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_ssi_signal_event_t#
sl_ssi_signal_event_t
Callback typedef for SSI.
Typedef for callback function for SSI.
84
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
Function Documentation#
sl_si91x_ssi_configure_clock#
sl_status_t sl_si91x_ssi_configure_clock (sl_ssi_clock_config_t * clock_config)
To configure the SSI clock.
[in] | clock_config | Pointer to the clock configuration structure sl_ssi_clock_config_t. |
Configures the PLL clock and SOC clock with the values set by the user in the clock configuration structure.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success, timer clock-source parameters configured properly.
SL_STATUS_FAIL (0x0001) - Generic error.
SL_STATUS_NOT_INITIALIZED (0x0011) - Clock is not initialized.
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
186
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_init#
sl_status_t sl_si91x_ssi_init (sl_ssi_instance_t instance, sl_ssi_handle_t * ssi_handle)
To initialize the SSI.
[in] | instance | The instance of the SSI (Primary/Secondary/ULP Primary) ( sl_ssi_instance_t). |
[in] | ssi_handle | Double pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API initializes the SSI. If DMA is enabled, it also initializes the DMA module. Pass the address of the pointer for storing the SSI Primary/Secondary/ULP Primary handle, which can be used in the future for other function calls.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_BUSY (0x0004) - Driver is busy.
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
207
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_deinit#
sl_status_t sl_si91x_ssi_deinit (sl_ssi_handle_t ssi_handle)
To uninitialize the SSI.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API will uninitialize the SSI. If DMA is enabled, it also uninitializes the DMA module.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
Note
When the SSI module is used in combination with other peripherals, see the notes below while deinitializing in the application:
Whenever sl_si91x_ssi_deinit() is 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 following peripherals: 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 following API to power down the particular power domain if other peripherals are not being used: sl_si91x_peri_efuse_power_down(power_down);
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.
235
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_set_configuration#
sl_status_t sl_si91x_ssi_set_configuration (sl_ssi_handle_t ssi_handle, sl_ssi_control_config_t * control_configuration, sl_ssi_slave_number_t slave_number)
To control and configure the SSI.
[in] | ssi_handle | Pointer to the SSI instance handle ( sl_ssi_handle_t). |
[in] | control_configuration | Pointer to the control config structure ( sl_ssi_control_config_t). |
[in] | slave_number | In the current implementation, the variable slave_number is unused ( sl_ssi_slave_number_t). |
This API will control and configure the SSI. As part of that, the following parameters are configured:
Mode (Primary/Secondary/ULP Primary)
Bit width (4 bits to 16 bits)
Clock mode/Frame format (mode0 to mode3, TI, and Microwire)
Bitrate (10 Mbps to 40 Mbps)
Rx sample delay (0 to 63)
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_FAIL (0x0001) - Function failed.
SL_STATUS_BUSY (0x0004) - Driver is busy.
SL_STATUS_NOT_SUPPORTED (0x000F) - Parameter is not supported.
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
SL_STATUS_INVALID_MODE (0x0024) - Slave select mode is invalid.
SL_STATUS_INVALID_TYPE (0x0026) - SPI frame format is not valid.
SL_STATUS_INVALID_RANGE (0x0028) - Data bits (frame length) are not in range.
For more information on status codes, see SL STATUS DOCUMENTATION.
265
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_receive_data#
sl_status_t sl_si91x_ssi_receive_data (sl_ssi_handle_t ssi_handle, void * data, uint32_t data_length)
To receive data from the secondary device.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
[in] | data | Pointer to the variable which will store the received data. |
[in] | data_length | (uint32_t) Number of data items to receive. |
This API will receive data from the secondary device. If DMA is enabled, it configures the DMA channel and required parameters. When the received data is equal to the data_length passed in this function, a callback event is generated which can be registered using sl_si91x_ssi_register_event_callback.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_FAIL (0x0001) - Function failed.
SL_STATUS_BUSY (0x0004) - Driver is busy.
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
295
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_send_data#
sl_status_t sl_si91x_ssi_send_data (sl_ssi_handle_t ssi_handle, const void * data, uint32_t data_length)
To send data to the secondary device.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
[in] | data | Pointer to the variable which will store the data to be sent. |
[in] | data_length | (uint32_t) Number of data items to send. |
This API will send data to the secondary device. If DMA is enabled, it configures the DMA channel and required parameters. When the sent data is equal to the data_length passed in this function, a callback event is generated which can be registered using sl_si91x_ssi_register_event_callback.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_FAIL (0x0001) - Function failed.
SL_STATUS_BUSY (0x0004) - Driver is busy.
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
323
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_transfer_data#
sl_status_t sl_si91x_ssi_transfer_data (sl_ssi_handle_t ssi_handle, const void * data_out, void * data_in, uint32_t data_length)
To send and receive data to the secondary device simultaneously.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
[in] | data_out | Const pointer to the variable that has data which needs to be sent. |
[in] | data_in | Pointer to the variable which will store the received data. |
[in] | data_length | (uint32_t) Number of data items to receive. |
If DMA is enabled, it configures the DMA channel and required parameters. When the received data and sent data are equal to the data_length passed in this function, a callback event is generated which can be registered using sl_si91x_ssi_register_event_callback.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_FAIL (0x0001) - Function failed.
SL_STATUS_BUSY (0x0004) - Driver is busy.
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
353
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_version#
sl_ssi_version_t sl_si91x_ssi_get_version (void )
To get the SSI version.
N/A |
This API retrieves the SSI version. It returns the API version of SSI.
Returns
sl_ssi_version_t Structure containing the driver version.
366
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_status#
sl_ssi_status_t sl_si91x_ssi_get_status (sl_ssi_handle_t ssi_handle)
To get the transfer status of SSI.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API retrieves the transfer status of SSI. It returns the sl_ssi_status_t type structure. The members are:
Busy
Data Lost
Mode Fault It is generally used to poll the busy status of SSI Master/ULP Master.
Returns
sl_ssi_status_t Structure containing the transfer status.
388
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_rx_data_count#
uint32_t sl_si91x_ssi_get_rx_data_count (sl_ssi_handle_t ssi_handle)
To get the data receive count of the SSI.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API retrieves the data receive count of the SSI and returns the number of data items received at the time of the function call.
Returns
uint32_t Value of the RX data count.
406
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_tx_data_count#
uint32_t sl_si91x_ssi_get_tx_data_count (sl_ssi_handle_t ssi_handle)
To get the transmit data count of the SSI.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API retrieves the transmit data count of the SSI. It returns the number of data items transmitted at the time of the function call.
Returns
uint32_t Value of the TX data count.
424
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_register_event_callback#
sl_status_t sl_si91x_ssi_register_event_callback (sl_ssi_handle_t ssi_handle, sl_ssi_signal_event_t callback_event)
To register the user event callback.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
[in] | callback_event | Pointer to the function which needs to be called at the time of interrupt. |
This API registers the callback (that is, stores the callback function address and passes it to the variable that is called in the Interrupt Handler). If another callback is registered without unregistering the previous callback, it returns an error code as follows. 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) - The callback is already registered, unregister the previous callback before registering a new one.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
446
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_unregister_event_callback#
void sl_si91x_ssi_unregister_event_callback (void )
To unregister the user event callback.
N/A |
This API unregisters the callback, i.e., clears the callback function address and passes a NULL value to the variable.
Pre-conditions:
458
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_clock_division_factor#
uint32_t sl_si91x_ssi_get_clock_division_factor (sl_ssi_handle_t ssi_handle)
To fetch the clock division factor.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
The clock division factor is calculated based on the peripheral clock configured. It decides the baud rate of SSI.
Returns
uint32_t The value of the clock division factor.
471
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_frame_length#
uint32_t sl_si91x_ssi_get_frame_length (sl_ssi_handle_t ssi_handle)
To fetch the frame length (bit width) of the SSI.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API retrieves the frame length, which ranges between 4 and 16 bits.
Returns
uint32_t The value of the frame length.
483
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_tx_fifo_threshold#
uint32_t sl_si91x_ssi_get_tx_fifo_threshold (sl_ssi_handle_t ssi_handle)
To fetch the transmit FIFO threshold value.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API retrieves the transmit FIFO threshold value, which controls the level of entries at which the transmit FIFO controller triggers an interrupt.
Returns
uint32_t The value of the transmit FIFO threshold.
496
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_rx_fifo_threshold#
uint32_t sl_si91x_ssi_get_rx_fifo_threshold (sl_ssi_handle_t ssi_handle)
To fetch the receiver FIFO threshold value.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API retrieves the receiver FIFO threshold value, which controls the level of entries at which the receive FIFO controller triggers an interrupt.
Returns
uint32_t The value of the receiver FIFO threshold.
509
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_get_receiver_sample_delay#
uint32_t sl_si91x_ssi_get_receiver_sample_delay (sl_ssi_handle_t ssi_handle)
To fetch the receiver sample delay value.
[in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
This API is used to delay the sample of the RX input signal. Each value represents a single ssi_clk delay on the sample of the rxd signal.
Returns
uint32_t The value of the receiver sample delay.
522
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h
sl_si91x_ssi_set_slave_number#
__STATIC_INLINE sl_status_t sl_si91x_ssi_set_slave_number (uint8_t number)
To set the secondary number in multi-secondary operation.
[in] | number | Secondary number ( sl_ssi_slave_number_t ) |
For single secondary operation, this API also needs to be called before transferring the data.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameter
For more information on status codes, see SL STATUS DOCUMENTATION.
538
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h