SDIO Secondary#

Introduction#

Secure Digital Input/Output (SDIO) is an extension of the SD (Secure Digital) card standard that adds support for input and output functions.

SDIO demonstrates the SDIO Secondary transmitting and receiving data to and from the external SDIO primary.

The following figure illustrates the framework for reading data in Multi-Block SDIO :

SDIO Read Frame FormatSDIO Read Frame Format

The following figure illustrates the framework for writing data in Multi-Block SDIO :

SDIO Write Frame FormatSDIO Write Frame Format

  • Command Initiation: A command (CMD) is received or generated to start.

  • Data Acquisition: Data is taken from different inputs (DATA0, DATA1, DATA2, DATA3).

  • Data Processing: The collected data undergoes various operations involving functions like Calla, CNC, Dala, Det, and E.

  • Output Generation: The processed data is potentially converted into a specific format (4-bit mode) and outputted.

Note

  • In Non-block mode, the Block Mode bit is set to zero in CMD53. The size of the data payload is in the range of 1-256 bytes (due to FIFO size restriction in SDIO Secondary) in non-block mode. The byte count for this transfer is set in the command (CMD53), rather than the fixed block size.

Configuration#

  • Most SDIO configurations take place on the primary side, where it enables read, write, and read-write operations.

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

Usage#

The initialization and configuration of the SDIO Secondary will be completed, transitioning it to a waiting state. It will remain in this state until an interrupt is triggered from the primary. Subsequently, the send and receive APIs will configure all GPDMA descriptors and initiate the GPDMA to transmit and receive data. Continuous data reception will commence after two seconds.

The SDIO can be initialized by multiple functions:

  1. sl_si91x_sdio_secondary_init : To initialize the SDIO secondary.

  2. sl_si91x_sdio_secondary_register_event_callback : To register the SDIO secondary user callback function.

  3. sl_si91x_sdio_secondary_send : To trigger the sequence to send data from the SDIO secondary in non-blocking mode to the host/primary device.

  4. sl_si91x_sdio_secondary_receive : To receive data on the SDIO secondary in non-blocking mode from the host/primary device using GPDMA.

Modules#

sl_sdio_secondary_version_t

Enumerations#

enum
HOST_INTR_NOT_RECEIVED = 0
HOST_INTR_RECEIVED = 1
HOST_INTR_NOT_RECEIVED = 0
HOST_INTR_RECEIVED = 1
}

Enumeration for SDIO slave receive interrupt status.

Typedefs#

typedef void(*

Callback function for SDIO secondary interface events.

typedef void(*

Callback function for SDIO secondary interface GPDMA transfers.

Functions#

sl_status_t

To initialize the SDIO secondary.

void
sl_si91x_sdio_secondary_send(uint8_t num_of_blocks, uint8_t *data_buf)

To trigger the sequence to send data from the SDIO secondary in non-blocking mode to the host/primary device.

void

To receive data on the SDIO secondary in non-blocking mode from the host/primary device using GPDMA.

sl_status_t
sl_si91x_sdio_secondary_register_event_callback(sl_sdio_secondary_callback_t callback_event, uint32_t flag)

To register the SDIO secondary user callback function.

void

To unregister the SDIO secondary user callback function.

sl_status_t
sl_si91x_sdio_secondary_gpdma_register_event_callback(sl_sdio_secondary_gpdma_callback_t callback_event)

To register the SDIO secondary GPDMA user callback function.

void

To unregister the SDIO secondary GPDMA user callback function.

To get the SDIO Secondary Driver version.

void

To initialize the SDIO Secondary at peripheral layer.

__STATIC_INLINE void

To enable the SDIO interrupts.

__STATIC_INLINE void

To disable the SDIO interrupts.

__INLINE void

To set the interrupts i.e., unmask according to the flags passed in the parameter.

__INLINE void

To clear the interrupts i.e., mask according to the flags passed in the parameter.

__INLINE uint32_t

To get the pending function interrupt.

__INLINE uint32_t

To get all the enabled interrupts in function1.

__INLINE uint32_t

To get all the enabled interrupts in function1 and pending interrupts.

__INLINE uint32_t

To get block count for the last received CMD53.

__INLINE uint32_t

To get the length of each for the last received CMD53.

__INLINE void

To set no of blocks to be transferred.

Macros#

#define
NUMGPDMADESC 10

Number of GPDMA Descriptors.

#define
HOST_INTR_RECEIVE_EVENT BIT(0)

Events for HIF irq handler.

#define
SDIO SDIO0

SDIO Base Address.

#define
SDIO_Handler HIF1_IRQHandler

HIF1 interrrupt handler.

#define
GPDMA_Handler IRQ031_Handler

GPDMA interrupt handler.

#define
RX_SOURCE_ADDR 0x20200080

SDIO Write FIFO Data Register.

#define
TX_SOURCE_ADDR 0x20200040

SDIO Read FIFO Data Register.

#define
SDIO_MODE_SELECT 0x0705

SDIO Mode Select.

#define
MASK_HOST_INTERRUPT 0xF0

MASK Host Interrupt.

#define
M4_MISC_CONFIG_BASE 0x46008000

SDIO MISC Configuration.

#define
SDIO_BASE 0x20200000

SDIO BASE Address.

#define
SL_SDIO_WR_INT_EN BIT(0)

This bit is used to enable CMD53 write interrupt.

#define
SL_SDIO_RD_INT_EN BIT(1)

This bit is used to enable CMD53 read interrupt.

#define
SL_SDIO_CSA_INT_EN BIT(2)

This bit is used to enable CMD53 CSA interrupt.

#define
SL_SDIO_CMD52_INT_EN BIT(3)

This bit is used to enable CMD52 interrupt.

#define
SL_SDIO_PWR_LEV_INT_EN BIT(4)

This bit is used to enable power level change interrupt.

#define
SL_SDIO_CRC_ERR_INT_EN BIT(5)

This bit is used to enable CRC error interrupt.

#define
SL_SDIO_ABORT_INT_EN BIT(6)

This bit is used to enable abort interrupt.

#define
SL_SDIO_TOUT_INT_EN BIT(7)

This bit is used to enable "read FIFO wait time over" interrupt.

#define
SL_SDIO_WR_INT_MSK BIT(0)

This bit is used to mask CMD53 write interrupt.

#define
SL_SDIO_RD_INT_MSK BIT(1)

This bit is used to mask CMD53 read interrupt.

#define
SL_SDIO_CSA_INT_MSK BIT(2)

This bit is used to mask CMD53 CSA interrupt.

#define
SL_SDIO_CMD52_INT_MSK BIT(3)

This bit is used to mask CMD52 interrupt.

#define
SL_SDIO_PWR_LEV_INT_MSK BIT(4)

This bit is used to mask power level change interrupt.

#define
SL_SDIO_CRC_ERR_INT_MSK BIT(5)

This bit is used to mask CRC error interrupt.

#define
SL_SDIO_ABORT_INT_MSK BIT(6)

This bit is used to mask abort interrupt.

#define
SL_SDIO_TOUT_INT_MSK BIT(7)

This bit is used to mask "read FIFO wait time over" interrupt.

#define
SL_SDIO_WR_INT_UNMSK BIT(0)

This bit is used to unmask CMD53 write interrupt.

#define
SL_SDIO_RD_INT_UNMSK BIT(1)

This bit is used to unmask CMD53 read interrupt.

#define
SL_SDIO_CSA_INT_UNMSK BIT(2)

This bit is used to unmask CMD53 CSA interrupt.

#define
SL_SDIO_CMD52_INT_UNMSK BIT(3)

This bit is used to unmask CMD52 interrupt.

#define
SL_SDIO_PWR_LEV_INT_UNMSK BIT(4)

This bit is used to unmask power level change interrupt.

#define
SL_SDIO_CRC_ERR_INT_UNMSK BIT(5)

This bit is used to unmask CRC error interrupt.

#define
SL_SDIO_ABORT_INT_UNMSK BIT(6)

This bit is used to unmask abort interrupt.

#define
SL_SDIO_TOUT_INT_UNMSK BIT(7)

This bit is used to unmask "read FIFO wait time over" interrupt.

Enumeration Documentation#

sl_sdio_slave_rx_intr_status_t#

sl_sdio_slave_rx_intr_status_t

Enumeration for SDIO slave receive interrupt status.

This enumeration defines the possible statuses for SDIO secondary receive interrupts, indicating whether an interrupt from the host has been received or not.

Enumerator
HOST_INTR_NOT_RECEIVED

Host interrupt not received.

HOST_INTR_RECEIVED

Host interrupt received.

HOST_INTR_NOT_RECEIVED

Host interrupt not received.

HOST_INTR_RECEIVED

Host interrupt received.


Typedef Documentation#

sl_sdio_secondary_callback_t#

typedef void(* sl_sdio_secondary_callback_t) (uint8_t events) )(uint8_t events)

Callback function for SDIO secondary interface events.

Parameters
TypeDirectionArgument NameDescription
[in]events

The SDIO 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 SDIO secondary interface events occur.


sl_sdio_secondary_gpdma_callback_t#

typedef void(* sl_sdio_secondary_gpdma_callback_t) (uint8_t dma_ch) )(uint8_t dma_ch)

Callback function for SDIO 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 SDIO secondary interface GPDMA transfer completes.


Function Documentation#

sl_si91x_sdio_secondary_init#

sl_status_t sl_si91x_sdio_secondary_init (void )

To initialize the SDIO secondary.

Parameters
TypeDirectionArgument NameDescription
voidN/A

This API initializes the SDIO secondary interface. By default, the SDIO pin access is with NWP. This API gives the pin access to M4, selects the SDIO mode, and enables the SDIO primary interrupts.

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_sdio_secondary_send#

void sl_si91x_sdio_secondary_send (uint8_t num_of_blocks, uint8_t * data_buf)

To trigger the sequence to send data from the SDIO secondary in non-blocking mode to the host/primary device.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]num_of_blocks

Number of blocks to be sent.

uint8_t *[in]data_buf

Reference to the source buffer.

This API accepts the number of blocks, where one block will have a block length (1 to 1024) bytes, and a pointer to the data buffer to be transferred.


sl_si91x_sdio_secondary_receive#

void sl_si91x_sdio_secondary_receive (uint8_t * data_buf)

To receive data on the SDIO secondary in non-blocking mode from the host/primary device using GPDMA.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]data_buf

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

This API receives data from the host/primary device and stores it in the provided destination buffer. The transfer is done in non-blocking mode using GPDMA.


sl_si91x_sdio_secondary_register_event_callback#

sl_status_t sl_si91x_sdio_secondary_register_event_callback (sl_sdio_secondary_callback_t callback_event, uint32_t flag)

To register the SDIO secondary user callback function.

Parameters
TypeDirectionArgument NameDescription
sl_sdio_secondary_callback_t[in]callback_event

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

uint32_t[in]flag

Interrupt flag to be registered.

This API registers a user-defined callback function for the SDIO secondary interface. The callback function will be called when an interrupt occurs, based on the specified interrupt flag.

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_sdio_secondary_unregister_event_callback#

void sl_si91x_sdio_secondary_unregister_event_callback (uint32_t flag)

To unregister the SDIO secondary user callback function.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]flag

Interrupt flag to be unregistered.

This API unregisters a user-defined callback function for the SDIO secondary interface. The callback function will no longer be called when an interrupt occurs for the specified interrupt flag.


sl_si91x_sdio_secondary_gpdma_register_event_callback#

sl_status_t sl_si91x_sdio_secondary_gpdma_register_event_callback (sl_sdio_secondary_gpdma_callback_t callback_event)

To register the SDIO secondary GPDMA user callback function.

Parameters
TypeDirectionArgument NameDescription
sl_sdio_secondary_gpdma_callback_t[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 the SDIO secondary interface. The callback function will be called when a GPDMA interrupt occurs.

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_sdio_secondary_gpdma_unregister_event_callback#

void sl_si91x_sdio_secondary_gpdma_unregister_event_callback (void )

To unregister the SDIO secondary GPDMA user callback function.

Parameters
TypeDirectionArgument NameDescription
voidN/A

This API unregisters a user-defined callback function for the SDIO secondary interface. The callback function will no longer be called when a GPDMA interrupt occurs.


sl_si91x_sdio_secondary_get_version#

sl_sdio_secondary_version_t sl_si91x_sdio_secondary_get_version (void )

To get the SDIO Secondary Driver version.

Parameters
TypeDirectionArgument NameDescription
voidN/A

This function retrieves the version of the SDIO Secondary Driver. It can be used to verify compatibility and ensure the correct version of the driver is being used.

Returns


sl_si91x_sdio_secondary_peripheral_init#

void sl_si91x_sdio_secondary_peripheral_init (void )

To initialize the SDIO Secondary at peripheral layer.

Parameters
TypeDirectionArgument NameDescription
voidN/A

This API initializes the SDIO secondary, by default SDIO pin access with NWP this API gives the pin access to M4, selects the SDIO mode and enable the sdio primary interrupts


sl_si91x_sdio_secondary_enable_interrupts#

__STATIC_INLINE void sl_si91x_sdio_secondary_enable_interrupts (uint32_t flags)

To enable the SDIO interrupts.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]flags

Interrupt Flag which needs to be enabled. Different interrupts flag which can be enabled are: SL_SDIO_WR_INT_EN

SL_SDIO_RD_INT_EN

SL_SDIO_CSA_INT_EN

SL_SDIO_CMD52_INT_EN

SL_SDIO_PWR_LEV_INT_EN

SL_SDIO_CRC_ERR_INT_EN

SL_SDIO_ABORT_INT_EN

SL_SDIO_TOUT_INT_EN


sl_si91x_sdio_secondary_disable_interrupts#

__STATIC_INLINE void sl_si91x_sdio_secondary_disable_interrupts (uint32_t flags)

To disable the SDIO interrupts.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]flags

Interrupt Flag which needs to be disabled. Different interrupts flags which can be disabled are: SL_SDIO_WR_INT_EN

SL_SDIO_RD_INT_EN

SL_SDIO_CSA_INT_EN

SL_SDIO_CMD52_INT_EN

SL_SDIO_PWR_LEV_INT_EN

SL_SDIO_CRC_ERR_INT_EN

SL_SDIO_ABORT_INT_EN

SL_SDIO_TOUT_INT_EN


sl_si91x_sdio_secondary_set_interrupts#

__INLINE void sl_si91x_sdio_secondary_set_interrupts (uint32_t flags)

To set the interrupts i.e., unmask according to the flags passed in the parameter.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]flags

Interrupt flags which needs to be set. Different interrupts flags which needs to be set: SL_SDIO_WR_INT_UNMSK

SL_SDIO_RD_INT_UNMSK

SL_SDIO_CSA_INT_UNMSK

SL_SDIO_CMD52_INT_UNMSK

SL_SDIO_PWR_LEV_INT_UNMSK

SL_SDIO_CRC_ERR_INT_UNMSK

SL_SDIO_ABORT_INT_UNMSK

SL_SDIO_TOUT_INT_UNMSK


sl_si91x_sdio_secondary_clear_interrupts#

__INLINE void sl_si91x_sdio_secondary_clear_interrupts (uint32_t flags)

To clear the interrupts i.e., mask according to the flags passed in the parameter.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]flags

Interrupt flags which needs to be masked. SL_SDIO_WR_INT_MSK

SL_SDIO_RD_INT_MSK

SL_SDIO_CSA_INT_MSK

SL_SDIO_CMD52_INT_MSK

SL_SDIO_PWR_LEV_INT_MSK

SL_SDIO_CRC_ERR_INT_MSK

SL_SDIO_ABORT_INT_MSK

SL_SDIO_TOUT_INT_MSK


sl_si91x_sdio_secondary_get_pending_interrupts#

__INLINE uint32_t sl_si91x_sdio_secondary_get_pending_interrupts (void )

To get the pending function interrupt.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Return the pending interrupt status.


sl_si91x_sdio_secondary_get_enabled_interrupts#

__INLINE uint32_t sl_si91x_sdio_secondary_get_enabled_interrupts (void )

To get all the enabled interrupts in function1.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • No of interrupts enabled.


sl_si91x_sdio_secondary_get_enabled_pending_interrupts#

__INLINE uint32_t sl_si91x_sdio_secondary_get_enabled_pending_interrupts (void )

To get all the enabled interrupts in function1 and pending interrupts.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • No of interrupts enabled.


sl_si91x_sdio_secondary_get_block_cnt#

__INLINE uint32_t sl_si91x_sdio_secondary_get_block_cnt (void )

To get block count for the last received CMD53.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • No of block counts.


sl_si91x_sdio_secondary_get_block_len#

__INLINE uint32_t sl_si91x_sdio_secondary_get_block_len (void )

To get the length of each for the last received CMD53.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Length of each block.


sl_si91x_sdio_secondary_set_tx_blocks#

__INLINE void sl_si91x_sdio_secondary_set_tx_blocks (uint8_t no_of_blocks)

To set no of blocks to be transferred.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]no_of_blocks

no of blocks to be transfered.

This API is used when transferring the data from secondary to primary in block mode.