High level interface to the Secure Digital Input Output (SDIO).
The SDIO protocol is an extension of the SD interface for general I/O functions. Refer to the SD Specifications Part 1 SDIO Specifications Version 4.10 for more information on the SDIO protocol and specifications.
The host functionality of this driver allows commands to be sent over the SDIO bus; the supported commands can be found in cyhal_sdio_host_command_t. Bulk data transfer is supported via cyhal_sdio_bulk_transfer().
The device functionality of this driver allows configuring the SDIO device for receiving commands from the host. Data can be sent and received from/to application buffers.
cyhal_sdio_init initializes the SDIO peripheral and passes a pointer to the SDIO block through the obj object of type cyhal_sdio_t.
The following snippet shows how to initialize the SDIO host interface with a pre-defined configuration
The following snippet shows how to configure an interrupt to handle host specific events. Refer cyhal_sdio_event_t for different types of events.
The following snippet shows how to send a particular command. Some steps of the card initialization have been provided for reference. Refer to cyhal_sdio_host_command_t for different commands.
The following snippet shows how to start a bulk data transfer.
The following snippet shows how to start an async data transfer.
The following snippet shows how to initialize the SDIO device interface with a pre-defined configuration
The following snippet shows how to configure an interrupt to handle device specific events. Refer cyhal_sdio_event_t for different types of events.
The following snippet shows how to start an async read.
The following snippet shows how to write to the mailbox.
API Reference | |
SDIO HAL Results | |
SDIO specific return codes. | |
Data Structures | |
struct | cyhal_sdio_cfg_t |
SDIO initial configuration. More... | |
Macros | |
#define | cyhal_sdio_send_cmd cyhal_sdio_host_send_cmd |
Deprecated. More... | |
#define | cyhal_sdio_bulk_transfer cyhal_sdio_host_bulk_transfer |
Deprecated. More... | |
#define | cyhal_sdio_transfer_async cyhal_sdio_host_transfer_async |
Deprecated. More... | |
#define | cyhal_sdio_set_io_voltage cyhal_sdio_host_set_io_voltage |
Deprecated. More... | |
Typedefs | |
typedef void(* | cyhal_sdio_event_callback_t) (void *callback_arg, cyhal_sdio_event_t event) |
Callback for SDIO events. | |
Functions | |
cy_rslt_t | cyhal_sdio_init (cyhal_sdio_t *obj, cyhal_gpio_t cmd, cyhal_gpio_t clk, cyhal_gpio_t data0, cyhal_gpio_t data1, cyhal_gpio_t data2, cyhal_gpio_t data3) |
Initialize the SDIO peripheral. More... | |
void | cyhal_sdio_free (cyhal_sdio_t *obj) |
Release the SDIO block. More... | |
cy_rslt_t | cyhal_sdio_configure (cyhal_sdio_t *obj, const cyhal_sdio_cfg_t *config) |
Configure the SDIO block. More... | |
bool | cyhal_sdio_is_busy (const cyhal_sdio_t *obj) |
Check if the specified SDIO is in use. More... | |
cy_rslt_t | cyhal_sdio_abort_async (cyhal_sdio_t *obj) |
Abort an SDIO transfer. More... | |
void | cyhal_sdio_register_callback (cyhal_sdio_t *obj, cyhal_sdio_event_callback_t callback, void *callback_arg) |
Register an SDIO event callback handler. More... | |
void | cyhal_sdio_enable_event (cyhal_sdio_t *obj, cyhal_sdio_event_t event, uint8_t intr_priority, bool enable) |
Configure the callback event. More... | |
cy_rslt_t | cyhal_sdio_init_cfg (cyhal_sdio_t *obj, const cyhal_sdio_configurator_t *cfg) |
Initialize the SDIO peripheral using a configurator generated configuration struct. More... | |
cy_rslt_t | cyhal_sdio_host_send_cmd (cyhal_sdio_t *obj, cyhal_sdio_host_transfer_type_t direction, cyhal_sdio_host_command_t command, uint32_t argument, uint32_t *response) |
Send command to the SDIO device. More... | |
cy_rslt_t | cyhal_sdio_host_bulk_transfer (cyhal_sdio_t *obj, cyhal_sdio_host_transfer_type_t direction, uint32_t argument, const uint32_t *data, uint16_t length, uint32_t *response) |
Perform a bulk data transfer. More... | |
cy_rslt_t | cyhal_sdio_host_transfer_async (cyhal_sdio_t *obj, cyhal_sdio_host_transfer_type_t direction, uint32_t argument, const uint32_t *data, uint16_t length) |
Perform a bulk asynchronous data transfer. More... | |
cy_rslt_t | cyhal_sdio_host_set_io_voltage (cyhal_sdio_t *obj, cyhal_gpio_t io_volt_sel, cyhal_sdio_host_io_voltage_t io_voltage, cyhal_sdio_host_io_volt_action_type_t io_switch_type) |
Set the voltage level of the I/O line. More... | |
struct cyhal_sdio_cfg_t |
#define cyhal_sdio_send_cmd cyhal_sdio_host_send_cmd |
Deprecated.
Send command to the SDIO device
See cyhal_sdio_host_command_t for list of available commands. This will block until the command is completed.
[in,out] | obj | The SDIO host object |
[in] | direction | The direction of transfer (read/write) |
[in] | command | The command to send to the SDIO device |
[in] | argument | The argument to the command |
[out] | response | The response from the SDIO device |
Returns CY_RSLT_SUCCESS on successful operation. Refer Snippet3: Sending Host Commands for more information.
#define cyhal_sdio_bulk_transfer cyhal_sdio_host_bulk_transfer |
Deprecated.
Perform a bulk data transfer
Sends CYHAL_SDIO_CMD_IO_RW_EXTENDED command (CMD=53) which allows writing and reading of a large number of I/O registers with a single command. This will block until the transfer is completed.
If D-cache is enabled and data Cache line is 32 bytes, the user needs to make sure that the data pointer passed to the cyhal_sdio_bulk_transfer function points to a 32 byte aligned array of words that contains the buffer data. The size of buffer data must be a multiple of 32 bytes to ensure cache coherency. CY_ALIGN(__SCB_DCACHE_LINE_SIZE) macro can be used for 32 byte alignment.
Refer to DCACHE_Management for more information.
[in,out] | obj | The SDIO host object |
[in] | direction | The direction of transfer (read/write) |
[in] | argument | The argument to the command |
[in] | data | The data to send to the SDIO device. A bulk transfer is done in block size (default: 64 bytes) chunks for better performance. Therefore, the size of the data buffer passed into this function must be at least length bytes and a multiple of the block size. For example, when requesting to read 100 bytes of data with a block size 64 bytes, the data buffer needs to be at least 128 bytes. The first 100 bytes of data in the buffer will be the requested data. |
[in] | length | The number of bytes to send |
[out] | response | The response from the SDIO device |
Returns CY_RSLT_SUCCESS on successful operation. Refer Snippet4: Host Bulk Data Transfer for more information.
#define cyhal_sdio_transfer_async cyhal_sdio_host_transfer_async |
Deprecated.
Perform a bulk asynchronous data transfer
Transfer by issuing CYHAL_SDIO_CMD_IO_RW_EXTENDED command(CMD=53) to the SDIO block. After exiting this function, CYHAL_SDIO_CMD_COMPLETE and CYHAL_SDIO_XFER_COMPLETE events are not asserted.
The CYHAL_SDIO_CMD_COMPLETE and CYHAL_SDIO_XFER_COMPLETE events are enabled after the asynchronous transfer completes and in the condition they were enabled in before the transfer operation started. Handle these events in the interrupt callback.
When the transfer is complete, the CYHAL_SDIO_XFER_COMPLETE event will be raised. See cyhal_sdio_register_callback and cyhal_sdio_enable_event.
If D-cache is enabled and data Cache line is 32 bytes, the user needs to make sure that the data pointer passed to the cyhal_sdio_transfer_async function points to a 32 byte aligned array of words that contains the buffer data. The size of buffer data must be a multiple of 32 bytes to ensure cache coherency. CY_ALIGN(__SCB_DCACHE_LINE_SIZE) macro can be used for 32 byte alignment.
Refer to DCACHE_Management for more information.
[in,out] | obj | The SDIO host object |
[in] | direction | The direction of transfer (read/write) |
[in] | argument | The argument to the command |
[in] | data | The data to send to the SDIO device |
[in] | length | The number of bytes to send |
Returns CY_RSLT_SUCCESS on successful operation. Refer Snippet5: Host Async Data Transfer for more information.
#define cyhal_sdio_set_io_voltage cyhal_sdio_host_set_io_voltage |
Deprecated.
Set the voltage level of the I/O line
This function changes the logic level on the io_volt_sel pin. It assumes that this line is used to control a regulator connected to the VDDIO of the MCU. This regulator allows for switching between the 3.3V and 1.8V signaling. High level on the pin stands for 1.8V signaling, while low - for 3.3V.
[in] | obj | The SDIO host object |
[in] | io_volt_sel | The pin connected to the io_volt_sel signal (This pin can be NC). |
[in] | io_voltage | I/O voltage to be set on lines |
[in] | io_switch_type | Defines how I/O voltage will be switched |
enum cyhal_sdio_event_t |
Types of events that could be asserted by SDIO.
Commands that can be issued.
SDIO I/O voltage select principle.
cy_rslt_t cyhal_sdio_init | ( | cyhal_sdio_t * | obj, |
cyhal_gpio_t | cmd, | ||
cyhal_gpio_t | clk, | ||
cyhal_gpio_t | data0, | ||
cyhal_gpio_t | data1, | ||
cyhal_gpio_t | data2, | ||
cyhal_gpio_t | data3 | ||
) |
Initialize the SDIO peripheral.
[out] | obj | Pointer to an SDIO object. The caller must allocate the memory for this object but the init function will initialize its contents. |
[in] | cmd | The pin for the command signal |
[in] | clk | The pin for the clk signal |
[in] | data0 | The pin for the data0 signal |
[in] | data1 | The pin for the data1 signal |
[in] | data2 | The pin for the data2 signal |
[in] | data3 | The pin for the data3 signal |
Returns CY_RSLT_SUCCESS on successful operation. Refer to Snippet1: Simple SDIO Host Initialization example and Snippet1: Simple SDIO Device Initialization example for more information.
void cyhal_sdio_free | ( | cyhal_sdio_t * | obj | ) |
Release the SDIO block.
Return the peripheral, pins and clock owned by the SDIO object to its reset state
[in,out] | obj | The SDIO object to deinitialize |
cy_rslt_t cyhal_sdio_configure | ( | cyhal_sdio_t * | obj, |
const cyhal_sdio_cfg_t * | config | ||
) |
Configure the SDIO block.
SDIO is either a host or a device type. This function allows specifying the features for either type. Refer to cyhal_sdio_cfg_t for more information.
[in,out] | obj | The SDIO object |
[in] | config | The SDIO configuration to apply |
Returns CY_RSLT_SUCCESS on successful operation.
bool cyhal_sdio_is_busy | ( | const cyhal_sdio_t * | obj | ) |
Check if the specified SDIO is in use.
[in] | obj | The SDIO peripheral to check |
cy_rslt_t cyhal_sdio_abort_async | ( | cyhal_sdio_t * | obj | ) |
Abort an SDIO transfer.
[in] | obj | The SDIO peripheral to stop |
Returns CY_RSLT_SUCCESS on successful operation.
void cyhal_sdio_register_callback | ( | cyhal_sdio_t * | obj, |
cyhal_sdio_event_callback_t | callback, | ||
void * | callback_arg | ||
) |
Register an SDIO event callback handler.
This function will be called when one of the events enabled by cyhal_sdio_enable_event occurs.
[in] | obj | The SDIO object |
[in] | callback | The callback function which will be invoked when the event triggers |
[in] | callback_arg | Generic argument that will be provided to the callback when executed |
Refer to Snippet2: Configure Host Interrupt and Snippet2: Configure Device Interrupt for usage information.
void cyhal_sdio_enable_event | ( | cyhal_sdio_t * | obj, |
cyhal_sdio_event_t | event, | ||
uint8_t | intr_priority, | ||
bool | enable | ||
) |
Configure the callback event.
Callbacks will be triggered for the specified SDIO events. Refer to cyhal_sdio_event_t for the list of supported events.
[in] | obj | The SDIO object |
[in] | event | The SDIO event type |
[in] | intr_priority | The priority for NVIC interrupt events |
[in] | enable | Set to true to enable events, or false to disable them |
Refer to Snippet2: Configure Host Interrupt and Snippet2: Configure Device Interrupt for usage information.
cy_rslt_t cyhal_sdio_init_cfg | ( | cyhal_sdio_t * | obj, |
const cyhal_sdio_configurator_t * | cfg | ||
) |
Initialize the SDIO peripheral using a configurator generated configuration struct.
[in] | obj | The SDIO peripheral to configure |
[in] | cfg | Configuration structure generated by a configurator. |
cy_rslt_t cyhal_sdio_host_send_cmd | ( | cyhal_sdio_t * | obj, |
cyhal_sdio_host_transfer_type_t | direction, | ||
cyhal_sdio_host_command_t | command, | ||
uint32_t | argument, | ||
uint32_t * | response | ||
) |
Send command to the SDIO device.
See cyhal_sdio_host_command_t for list of available commands. This will block until the command is completed.
[in,out] | obj | The SDIO host object |
[in] | direction | The direction of transfer (read/write) |
[in] | command | The command to send to the SDIO device |
[in] | argument | The argument to the command |
[out] | response | The response from the SDIO device |
Returns CY_RSLT_SUCCESS on successful operation. Refer Snippet3: Sending Host Commands for more information.
cy_rslt_t cyhal_sdio_host_bulk_transfer | ( | cyhal_sdio_t * | obj, |
cyhal_sdio_host_transfer_type_t | direction, | ||
uint32_t | argument, | ||
const uint32_t * | data, | ||
uint16_t | length, | ||
uint32_t * | response | ||
) |
Perform a bulk data transfer.
Sends CYHAL_SDIO_CMD_IO_RW_EXTENDED command (CMD=53) which allows writing and reading of a large number of I/O registers with a single command. This will block until the transfer is completed.
If D-cache is enabled and data Cache line is 32 bytes, the user needs to make sure that the data pointer passed to the cyhal_sdio_host_bulk_transfer function points to a 32 byte aligned array of words that contains the buffer data. The size of buffer data must be a multiple of 32 bytes to ensure cache coherency. CY_ALIGN(__SCB_DCACHE_LINE_SIZE) macro can be used for 32 byte alignment.
Refer to DCACHE_Management for more information.
[in,out] | obj | The SDIO host object |
[in] | direction | The direction of transfer (read/write) |
[in] | argument | The argument to the command |
[in] | data | The data to send to the SDIO device. A bulk transfer is done in block size (default: 64 bytes) chunks for better performance. Therefore, the size of the data buffer passed into this function must be at least length bytes and a multiple of the block size. For example, when requesting to read 100 bytes of data with a block size 64 bytes, the data buffer needs to be at least 128 bytes. The first 100 bytes of data in the buffer will be the requested data. |
[in] | length | The number of bytes to send |
[out] | response | The response from the SDIO device |
Returns CY_RSLT_SUCCESS on successful operation. Refer Snippet4: Host Bulk Data Transfer for more information.
cy_rslt_t cyhal_sdio_host_transfer_async | ( | cyhal_sdio_t * | obj, |
cyhal_sdio_host_transfer_type_t | direction, | ||
uint32_t | argument, | ||
const uint32_t * | data, | ||
uint16_t | length | ||
) |
Perform a bulk asynchronous data transfer.
Transfer by issuing CYHAL_SDIO_CMD_IO_RW_EXTENDED command(CMD=53) to the SDIO block. After exiting this function, CYHAL_SDIO_CMD_COMPLETE and CYHAL_SDIO_XFER_COMPLETE events are not asserted.
The CYHAL_SDIO_CMD_COMPLETE and CYHAL_SDIO_XFER_COMPLETE events are enabled after the asynchronous transfer completes and in the condition they were enabled in before the transfer operation started. Handle these events in the interrupt callback.
When the transfer is complete, the CYHAL_SDIO_XFER_COMPLETE event will be raised. See cyhal_sdio_register_callback and cyhal_sdio_enable_event.
If D-cache is enabled and data Cache line is 32 bytes, the user needs to make sure that the data pointer passed to the cyhal_sdio_host_transfer_async function points to a 32 byte aligned array of words that contains the buffer data. The size of buffer data must be a multiple of 32 bytes to ensure cache coherency. CY_ALIGN(__SCB_DCACHE_LINE_SIZE) macro can be used for 32 byte alignment.
Refer to DCACHE_Management for more information.
[in,out] | obj | The SDIO host object |
[in] | direction | The direction of transfer (read/write) |
[in] | argument | The argument to the command |
[in] | data | The data to send to the SDIO device |
[in] | length | The number of bytes to send |
Returns CY_RSLT_SUCCESS on successful operation. Refer Snippet5: Host Async Data Transfer for more information.
cy_rslt_t cyhal_sdio_host_set_io_voltage | ( | cyhal_sdio_t * | obj, |
cyhal_gpio_t | io_volt_sel, | ||
cyhal_sdio_host_io_voltage_t | io_voltage, | ||
cyhal_sdio_host_io_volt_action_type_t | io_switch_type | ||
) |
Set the voltage level of the I/O line.
This function changes the logic level on the io_volt_sel pin. It assumes that this line is used to control a regulator connected to the VDDIO of the MCU. This regulator allows for switching between the 3.3V and 1.8V signaling. High level on the pin stands for 1.8V signaling, while low - for 3.3V.
[in] | obj | The SDIO host object |
[in] | io_volt_sel | The pin connected to the io_volt_sel signal (This pin can be NC). |
[in] | io_voltage | I/O voltage to be set on lines |
[in] | io_switch_type | Defines how I/O voltage will be switched |