Synchronous Serial Interface#
Introduction#
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.
SPI (Serial Peripheral Interface) 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.
Configuration#
SSI enables 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, which 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; Bit width may be adjusted between 4 and 16, and bit rate between 500000 and 40000000 bits per second. By sending this structure to an API sl_si91x_ssi_set_configuration(), all configuration may be done using a structure sl_ssi_control_config_t. the SSI slave number can be set using sl_ssi_slave_number_t and call the API sl_si91x_ssi_set_slave_number().
For more information on configuring available parameters refer to 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:
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#
renaming arm power state structure
renaming arm SPI status
Renaming SSI driver structure.
SSI Handle to be passed into APIs.
Callback typedef for SSI.
Variables#
Release version number.
SQA version number.
DEV version number.
bit width either 8 or 16 bit
mode such as Master or Slave mode
clock mode such as CPOL0 CPHA1
baud rate for SSI
Delay for receive input signal.
Clock Division Factor.
intf PLL control value
intf PLL clock frequency
intf PLL reference clock frequency
SoC PLL Clock frequency.
SoC PLL reference clock frequency.
SoC PLL count value.
Functions#
This API will configures the SSI clock.
This API will initialize the SSI.
This API will uninitialize the SSI.
This API will control and configure the SSI.
This API will receive data from the secondary device.
This API will send data to the secondary device.
Send and receive data to the secondary device simultaneously.
This API will get the SSI version.
This API will get the transfer status SSI.
This API will get data receive count of the SSI.
This API will get the transmit data count of SSI.
This API will register the user event callback.
This API will unregister the user event callback.
This API will fetch the clock division factor.
This API will fetch the frame length i.e., bit width and also.
This API will fetch the transmit FIFO threshold value, this value controls the level of entries at which the transmit FIFO controller triggers an interrupt.
This API is to fetch the receiver FIFO threshold value, this value controls the level of entries at which the receive FIFO controller triggers an interrupt.
This API is to fetch the receiver sample delay value, it used to delay the sample of the RX input signal.
This API will 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. |
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 | LSAT member of enum for validation. |
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 | LSAT member of enum for validation. |
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. |
Typedef Documentation#
sl_ssi_power_state_t#
typedef ARM_POWER_STATE sl_ssi_power_state_t
renaming arm power state structure
Variable Documentation#
receive_sample_delay#
uint32_t sl_ssi_control_config_t::receive_sample_delay
Delay for receive input signal.
intf_pll_500_control_value#
uint16_t sl_ssi_clock_config_t::intf_pll_500_control_value
intf PLL control value
intf_pll_reference_clock#
uint32_t sl_ssi_clock_config_t::intf_pll_reference_clock
intf PLL reference clock frequency
soc_pll_reference_clock#
uint32_t sl_ssi_clock_config_t::soc_pll_reference_clock
SoC PLL reference clock frequency.
Function Documentation#
sl_si91x_ssi_configure_clock#
sl_status_t sl_si91x_ssi_configure_clock (sl_ssi_clock_config_t * clock_config)
This API will configures the SSI clock.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_clock_config_t * | [in] | clock_config | Pointer to clock config structure sl_ssi_clock_config_t |
To set the clock for the SSI peripheral, Configures the PLL clock and SOC clock with the value set by user in the clock configuration structure.
Returns
status 0 if successful, else error code as follow.
SL_STATUS_OK (0x0000) - Success, timer clock-source parameters configured properly
SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_FAIL (0x0001) - The function is failed
SL_STATUS_NOT_INITIALIZED (0x0011) - Clock is not initialized
sl_si91x_ssi_init#
sl_status_t sl_si91x_ssi_init (sl_ssi_instance_t instance, sl_ssi_handle_t * ssi_handle)
This API will initialize the SSI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_instance_t | [in] | instance | (Primary/Secondary/ULP Primary) ( sl_ssi_instance_t) |
sl_ssi_handle_t * | [in] | ssi_handle | Double Pointer to the SSI driver handle ( sl_ssi_handle_t) |
This will initialize the SSI and if the 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 future for other function calls.
Returns
status 0 if successful, else error code as follow.
SL_STATUS_OK (0x0000) - Success, otherwise fail error code as follow
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_BUSY (0x0004) - Driver is busy
sl_si91x_ssi_deinit#
sl_status_t sl_si91x_ssi_deinit (sl_ssi_handle_t ssi_handle)
This API will uninitialize the SSI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
This will uninitialize the SSI and also if the DMA is enabled, it also uninitializes the DMA module.
Returns
status 0 if successful, else error code as follow.
SL_STATUS_OK (0x0000) - Success, otherwise fail error code as follow
SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer
Note
When the SSI module is used in combination with other peripherals, while de-initializing in the application, refer to the notes below:
Whenever sl_si91x_ssi_deinit() gets called it will power down the domain(PERI_EFUSE) which contains different peripherals mentioned below. 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. Since deinit power downs the PERI_EFUSE doamin, it's recommended to call the sl_si91x_ssi_deinit() API at the end of the application.
Few peripherals (ULP Peripherals, UULP Peripherals, GPDMA and SDIO-SPI) have seperate domains that can be powered down indepedently. For additional details, refer to the Power architecture section in the Hardware Reference Manual e.g., To power down ULP SSI, use the API below: RSI_PS_M4ssPeriPowerDown(ULPSS_PWRGATE_ULP_SSI); Here, ULP_SSI has seperate power domain ULPSS_PWRGATE_ULP_SSI, which can be powered down indepedently. Refer to the rsi_power_save.h file for all power gates definitions.
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)
This API will control and configure the SSI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | pointer to ssi instance handle. ( sl_ssi_handle_t). |
sl_ssi_control_config_t * | [in] | control_configuration | pointer to control config structure. ( sl_ssi_control_config_t). |
sl_ssi_slave_number_t | [in] | slave_number | In the current implementation variable slave_number is un-used ( sl_ssi_slave_number_t). |
This will control and configure the SSI. As part of that, following parameters are configured:
Mode (Primary/Secondary/ULP Primary)
bit_width (4 bit to 16 bit)
clock_mode/Frame format (mode0 to mode3, TI and Microwire)
bitrate (10 Mbps to 40 Mbps)
Rx sample delay (0 to 63).
Returns
status 0 if successful, else error code as follow.
SL_STATUS_OK (0x0000) - Success
SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_FAIL (0x0001) - The function is failed
SL_STATUS_NOT_SUPPORTED (0x000F) - Parameter is not supported
SL_STATUS_BUSY (0x0004) - Driver is busy
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) is not in range
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)
This API will receive data from the secondary device.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t). |
void * | [in] | data | pointer to the variable which will store the received data |
uint32_t | [in] | data_length | (uint32_t) number of data items to receive. |
This 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 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
status 0 if successful, else error code as follow.
SL_STATUS_OK (0x0000) - Success
SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_FAIL (0x0001) - The function is failed
SL_STATUS_BUSY (0x0004) - Driver is busy
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)
This API will send data to the secondary device.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
const void * | [in] | data | pointer to the variable which will store the received data |
uint32_t | [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 send data is equal to 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
status 0 if successful, else error code as follow.
SL_STATUS_OK (0x0000) - Success
SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_FAIL (0x0001) - The function is failed
SL_STATUS_BUSY (0x0004) - Driver is busy
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)
Send and receive data to the secondary device simultaneously.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
const void * | [in] | data_out | const pointer to the variable that has data which needs to be sent |
void * | [in] | data_in | pointer to the variable which will store the received data |
uint32_t | [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 send data is equal to 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
status 0 if successful, else error code
SL_STATUS_OK (0x0000) - Success
SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_FAIL (0x0001) - The function is failed
SL_STATUS_BUSY (0x0004) - Driver is busy
sl_si91x_ssi_get_version#
sl_ssi_version_t sl_si91x_ssi_get_version (void )
This API will get the SSI version.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This will get the SSI version. It returns the API version of SSI.
Returns
driver version.
sl_si91x_ssi_get_status#
sl_ssi_status_t sl_si91x_ssi_get_status (sl_ssi_handle_t ssi_handle)
This API will get the transfer status SSI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
This will get the transfer status 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.
Pre-conditions:
sl_si91x_ssi_set_configurationReturns
( sl_ssi_status_t) type structure
sl_si91x_ssi_get_rx_data_count#
uint32_t sl_si91x_ssi_get_rx_data_count (sl_ssi_handle_t ssi_handle)
This API will get data receive count of the SSI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
This will get data receive count of the SSI and it returns the number of data received at the time of function call.
Returns
uint32_t value of the RX data count
sl_si91x_ssi_get_tx_data_count#
uint32_t sl_si91x_ssi_get_tx_data_count (sl_ssi_handle_t ssi_handle)
This API will get the transmit data count of SSI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
This will get the transmit data count of SSI. It returns the number of data transmit at the time of function call.
Returns
uint32_t value of the tx data count
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)
This API will register the user event callback.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | handle Pointer to the SSI driver handle ( sl_ssi_handle_t) |
sl_ssi_signal_event_t | [in] | callback_event | Pointer to the function which needs to be called at the time of interrupt |
It registers the callback, i.e., stores the callback function address and pass to the variable that is called in Interrupt Handler. If another callback is registered without unregistering previous callback then, it returns an error code as follow, so it is mandatory to unregister the callback before registering another callback.
Returns
status 0 if successful, else error code as follow.
SL_STATUS_BUSY (0x0004) - The callback is already registered, unregister previous callback before registering new one.
SL_STATUS_OK (0x0000) - Success
SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer
sl_si91x_ssi_unregister_event_callback#
void sl_si91x_ssi_unregister_event_callback (void )
This API will unregister the user event callback.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
It unregisters the callback, i.e., clears the callback function address and passes a NULL value to the variable.
Pre-conditions:
sl_si91x_ssi_get_clock_division_factor#
uint32_t sl_si91x_ssi_get_clock_division_factor (sl_ssi_handle_t ssi_handle)
This API will fetch the clock division factor.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [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
factor(int32_t) The value of clock division fac
sl_si91x_ssi_get_frame_length#
uint32_t sl_si91x_ssi_get_frame_length (sl_ssi_handle_t ssi_handle)
This API will fetch the frame length i.e., bit width and also.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | N/A | ssi_handle |
The frame length ranges between 4 and 16.
Returns
frame_length (uint32_t) The value of frame length
sl_si91x_ssi_get_tx_fifo_threshold#
uint32_t sl_si91x_ssi_get_tx_fifo_threshold (sl_ssi_handle_t ssi_handle)
This API will fetch the transmit FIFO threshold value, this value controls the level of entries at which the transmit FIFO controller triggers an interrupt.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
Returns
Transmit fifo threshold (uint32_t) The value of transmit fifo threshold
sl_si91x_ssi_get_rx_fifo_threshold#
uint32_t sl_si91x_ssi_get_rx_fifo_threshold (sl_ssi_handle_t ssi_handle)
This API is to fetch the receiver FIFO threshold value, this value controls the level of entries at which the receive FIFO controller triggers an interrupt.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
Returns
Receiver fifo threshold (uint32_t) The value of receiver fifo threshold
sl_si91x_ssi_get_receiver_sample_delay#
uint32_t sl_si91x_ssi_get_receiver_sample_delay (sl_ssi_handle_t ssi_handle)
This API is to fetch the receiver sample delay value, it used to delay the sample of the RX input signal.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_ssi_handle_t | [in] | ssi_handle | Pointer to the SSI driver handle ( sl_ssi_handle_t) |
Each value represents a single ssi_clk delay on the sample of the rxd signal.
Returns
Receiver sample delay (uint32_t) The value of receiver sample delay
sl_si91x_ssi_set_slave_number#
__STATIC_INLINE sl_status_t sl_si91x_ssi_set_slave_number (uint8_t number)
This API will set the secondary number in multi-secondary operation.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | number | Secondary number ( sl_ssi_slave_number_t ) |
For single secondary also, this API needs to be called before transferring the data.
Returns
none