High Speed SPI Secondary#
Introduction#
HSPI demonstrates the HSPI Secondary transmitting and receiving data to and from the external SPI primary.
Configuration#
The HSPI primary side drives the majority of HSPI configurations, specifically initialization, speed mode, and all data transfer operations (read, write, read-write).
For more information on configuring available parameters, see the respective HSPI Primary example.
Usage#
The HSPI Secondary undergoes initialization and configuration, and then enters a waiting state. It remains in this state until an interrupt from the primary triggers data transfer, at which point the send and receive APIs configure the GPDMA descriptors for further transmissions.
The HSPI can be initialized by multiple functions:
sl_si91x_hspi_secondary_init : To initialize the HSPI secondary.
sl_si91x_hspi_secondary_register_event_callback : To register the HSPI secondary user callback function.
sl_si91x_hspi_secondary_send_non_blocking : To trigger the sequence to send data from the HSPI secondary in non-blocking mode to the host/primary device.
sl_si91x_hspi_secondary_receive_non_blocking : To receive data on the HSPI secondary in non-blocking mode from the host/primary device using GPDMA.
Modules#
Typedefs#
Callback function for HSPI secondary interface events.
Callback function for HSPI secondary interface GPDMA transfers.
Functions#
Initializes the HSPI secondary.
Sends data from the HSPI secondary to the host/primary device in non-blocking mode.
Receives data on the HSPI secondary in non-blocking mode from the host/primary device.
Writes data into HSPI FIFO in blocking mode.
Receives data from SPI FIFO in blocking mode.
Registers the HSPI secondary user callback function.
Unregisters the HSPI secondary user callback function.
Retrieves the HSPI Secondary Driver version.
Macros#
Number of GPDMA Descriptors.
HIF1 interrupt handler.
GPDMA interrupt handler.
HSPI Write FIFO Data Register.
HSPI Read FIFO Data Register.
Typedef Documentation#
sl_hspi_secondary_callback_t#
typedef void(* sl_hspi_secondary_callback_t) (uint8_t events) )(uint8_t events)
Callback function for HSPI secondary interface events.
Type | Direction | Argument Name | Description |
---|---|---|---|
[in] | events | The HSPI secondary interface events that triggered the callback. This parameter is a bitmask representing one or more events. |
This function pointer defines the prototype for a callback function that will be invoked when HSPI secondary interface events occur.
sl_hspi_secondary_gpdma_callback_t#
typedef void(* sl_hspi_secondary_gpdma_callback_t) (uint8_t dma_ch) )(uint8_t dma_ch)
Callback function for HSPI secondary interface GPDMA transfers.
Type | Direction | Argument Name | Description |
---|---|---|---|
[in] | dma_ch | The GPDMA channel used for the transfer. |
This function pointer defines the prototype for a callback function that will be invoked when HSPI secondary interface GPDMA transfer completes.
Function Documentation#
sl_si91x_hspi_secondary_init#
sl_status_t sl_si91x_hspi_secondary_init (void )
Initializes the HSPI secondary.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Pre-condition:
The system clock must be configured.
The HSPI peripheral clock must be enabled.
Returns
sl_status_t Initialization status:
SL_STATUS_OK - Initialization successful.
SL_STATUS_FAIL - Initialization failed.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_hspi_secondary_send_non_blocking#
sl_status_t sl_si91x_hspi_secondary_send_non_blocking (void * data_buf)
Sends data from the HSPI secondary to the host/primary device in non-blocking mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
void * | [in] | data_buf | Pointer to the source data buffer. |
Pre-condition:
sl_si91x_hspi_secondary_init must be called prior.
The GPDMA must be configured and enabled.
Returns
sl_status_t Status of the send operation.
sl_si91x_hspi_secondary_receive_non_blocking#
sl_status_t sl_si91x_hspi_secondary_receive_non_blocking (void * data_buf)
Receives data on the HSPI secondary in non-blocking mode from the host/primary device.
Type | Direction | Argument Name | Description |
---|---|---|---|
void * | [in] | data_buf | Reference to the destination buffer where the received data will be stored. |
Pre-condition:
sl_si91x_hspi_secondary_init must be called prior.
The GPDMA must be configured and enabled.
Returns
sl_status_t Status of the receive operation.
sl_si91x_hspi_secondary_send_blocking#
uint32_t sl_si91x_hspi_secondary_send_blocking (const void * data)
Writes data into HSPI FIFO in blocking mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
const void * | [in] | data | Data to be written in HSPI FIFO register. |
Pre-condition:
sl_si91x_hspi_secondary_init must be called prior.
Returns
Number of bytes written in HSPI FIFO register.
sl_si91x_hspi_secondary_receive_blocking#
uint32_t sl_si91x_hspi_secondary_receive_blocking (void * data)
Receives data from SPI FIFO in blocking mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
void * | [in] | data | Data pointer in which read data from HSPI FIFO register is copied. |
Pre-condition:
sl_si91x_hspi_secondary_init must be called prior.
Returns
The number of bytes read from SPI FIFO register.
sl_si91x_hspi_secondary_register_event_callback#
sl_status_t sl_si91x_hspi_secondary_register_event_callback (sl_hspi_secondary_callback_t callback_event)
Registers the HSPI secondary user callback function.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_hspi_secondary_callback_t | [in] | callback_event | Pointer to the function which needs to be called at the time of interrupt. |
Pre-condition:
sl_si91x_hspi_secondary_init must be called prior.
Returns
sl_status_t Registration status:
SL_STATUS_OK - Success.
SL_STATUS_BUSY - Driver is busy.
SL_STATUS_NULL_POINTER - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_hspi_secondary_unregister_event_callback#
void sl_si91x_hspi_secondary_unregister_event_callback (uint32_t flag)
Unregisters the HSPI secondary user callback function.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flag | Interrupt flag to be unregistered. |
Pre-condition:
sl_si91x_hspi_secondary_init must be called prior.
sl_si91x_hspi_secondary_register_event_callback must be called prior.
sl_si91x_hspi_secondary_get_version#
sl_hspi_secondary_version_t sl_si91x_hspi_secondary_get_version (void )
Retrieves the HSPI Secondary Driver version.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Pre-condition:
None.
Returns
sl_hspi_secondary_version_t Driver version.