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:

  1. sl_si91x_hspi_secondary_init : To initialize the HSPI secondary.

  2. sl_si91x_hspi_secondary_register_event_callback : To register the HSPI secondary user callback function.

  3. 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.

  4. 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#

sl_hspi_secondary_version_t

Typedefs#

typedef void(*

Callback function for HSPI secondary interface events.

typedef void(*

Callback function for HSPI secondary interface GPDMA transfers.

Functions#

sl_status_t

Initializes the HSPI secondary.

sl_status_t

Sends data from the HSPI secondary to the host/primary device in non-blocking mode.

sl_status_t

Receives data on the HSPI secondary in non-blocking mode from the host/primary device.

uint32_t

Writes data into HSPI FIFO in blocking mode.

uint32_t

Receives data from SPI FIFO in blocking mode.

sl_status_t
sl_si91x_hspi_secondary_register_event_callback(sl_hspi_secondary_callback_t callback_event)

Registers the HSPI secondary user callback function.

void

Unregisters the HSPI secondary user callback function.

Retrieves the HSPI Secondary Driver version.

Macros#

#define
SL_HSPI_NUM_GPDMA_DESC 30

Number of GPDMA Descriptors.

#define
SL_HSPI_IRQHandler HIF1_IRQHandler

HIF1 interrupt handler.

#define
SL_GPDMA_IRQHandler IRQ031_Handler

GPDMA interrupt handler.

#define
SL_HSPI_RX_SOURCE_ADDR 0x20200380

HSPI Write FIFO Data Register.

#define
SL_HSPI_TX_SOURCE_ADDR 0x202003C0

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.

Parameters
TypeDirectionArgument NameDescription
[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.

Parameters
TypeDirectionArgument NameDescription
[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.

Parameters
TypeDirectionArgument NameDescription
voidN/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.

Parameters
TypeDirectionArgument NameDescription
void *[in]data_buf

Pointer to the source data buffer.

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.

Parameters
TypeDirectionArgument NameDescription
void *[in]data_buf

Reference to the destination buffer where the received data will be stored.

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.

Parameters
TypeDirectionArgument NameDescription
const void *[in]data

Data to be written in HSPI FIFO register.

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.

Parameters
TypeDirectionArgument NameDescription
void *[in]data

Data pointer in which read data from HSPI FIFO register is copied.

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.

Parameters
TypeDirectionArgument NameDescription
sl_hspi_secondary_callback_t[in]callback_event

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

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.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]flag

Interrupt flag to be unregistered.


sl_si91x_hspi_secondary_get_version#

sl_hspi_secondary_version_t sl_si91x_hspi_secondary_get_version (void )

Retrieves the HSPI Secondary Driver version.

Parameters
TypeDirectionArgument NameDescription
voidN/A
  • Pre-condition:

    • None.

Returns