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 mtb_hal_sdio_host_command_t. Bulk data transfer is supported via mtb_hal_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.
Initialize SDIO by using the Device Configurator and selecting pins according to the target device used. Specify the SDIO configuration using the configuration structure (const mtb_hal_sdio_configurator_t * config).
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 mtb_hal_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 mtb_hal_sdio_host_command_t for different commands.
The following snippet shows how to start a bulk 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 mtb_hal_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 | mtb_hal_sdio_cfg_t |
| SDIO initial configuration struct. More... | |
Typedefs | |
| typedef void(* | mtb_hal_sdio_event_callback_t) (void *callback_arg, mtb_hal_sdio_event_t event) |
| Callback for SDIO events. | |
Functions | |
| cy_rslt_t | mtb_hal_sdio_setup (mtb_hal_sdio_t *obj, const mtb_hal_sdio_configurator_t *config, const mtb_hal_clock_t *clock, cy_stc_sd_host_context_t *sdio_context) |
| Sets up a HAL instance to use the specified hardware resource. More... | |
| cy_rslt_t | mtb_hal_sdio_configure (mtb_hal_sdio_t *obj, const mtb_hal_sdio_cfg_t *config) |
| Configure the SDIO block. More... | |
| void | mtb_hal_sdio_register_callback (mtb_hal_sdio_t *obj, mtb_hal_sdio_event_callback_t callback, void *callback_arg) |
| Register an SDIO event callback handler. More... | |
| void | mtb_hal_sdio_enable_event (mtb_hal_sdio_t *obj, mtb_hal_sdio_event_t event, bool enable) |
| Configure the callback event. More... | |
| cy_rslt_t | mtb_hal_sdio_process_interrupt (mtb_hal_sdio_t *obj) |
| Process interrupts related related to an SDIO instance. More... | |
| cy_rslt_t | mtb_hal_sdio_host_send_cmd (mtb_hal_sdio_t *obj, mtb_hal_sdio_host_transfer_type_t direction, mtb_hal_sdio_host_command_t command, uint32_t argument, uint32_t *response) |
| Send command to the SDIO device. More... | |
| cy_rslt_t | mtb_hal_sdio_host_bulk_transfer (mtb_hal_sdio_t *obj, mtb_hal_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 | mtb_hal_sdio_host_set_io_voltage (mtb_hal_sdio_t *obj, mtb_hal_sdio_host_io_voltage_t io_voltage, mtb_hal_sdio_host_io_volt_action_type_t io_switch_type) |
| Set the voltage level of the I/O line. More... | |
| struct mtb_hal_sdio_cfg_t |
| enum mtb_hal_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 mtb_hal_sdio_setup | ( | mtb_hal_sdio_t * | obj, |
| const mtb_hal_sdio_configurator_t * | config, | ||
| const mtb_hal_clock_t * | clock, | ||
| cy_stc_sd_host_context_t * | sdio_context | ||
| ) |
Sets up a HAL instance to use the specified hardware resource.
This hardware resource must have already been configured via the PDL.
| [out] | obj | The HAL driver instance object. The caller must allocate the memory for this object, but the HAL will initialize its contents |
| [in] | config | The configurator-generated HAL config structure for this peripheral instance |
| [in] | clock | The HAL clock object that is connected to this peripheral instance |
| [in] | sdio_context | The context for the sdio instance allocated by the user |
| cy_rslt_t mtb_hal_sdio_configure | ( | mtb_hal_sdio_t * | obj, |
| const mtb_hal_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 mtb_hal_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.
| void mtb_hal_sdio_register_callback | ( | mtb_hal_sdio_t * | obj, |
| mtb_hal_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 mtb_hal_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 mtb_hal_sdio_enable_event | ( | mtb_hal_sdio_t * | obj, |
| mtb_hal_sdio_event_t | event, | ||
| bool | enable | ||
| ) |
Configure the callback event.
Callbacks will be triggered for the specified SDIO events. Refer to mtb_hal_sdio_event_t for the list of supported events.
| [in] | obj | The SDIO object |
| [in] | event | The SDIO event type |
| [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 mtb_hal_sdio_process_interrupt | ( | mtb_hal_sdio_t * | obj | ) |
Process interrupts related related to an SDIO instance.
| obj | HAL object for which the interrupt should be processed |
| cy_rslt_t mtb_hal_sdio_host_send_cmd | ( | mtb_hal_sdio_t * | obj, |
| mtb_hal_sdio_host_transfer_type_t | direction, | ||
| mtb_hal_sdio_host_command_t | command, | ||
| uint32_t | argument, | ||
| uint32_t * | response | ||
| ) |
Send command to the SDIO device.
See mtb_hal_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 mtb_hal_sdio_host_bulk_transfer | ( | mtb_hal_sdio_t * | obj, |
| mtb_hal_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 MTB_HAL_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, the user needs to make sure that the data pointer passed to the mtb_hal_sdio_host_bulk_transfer function points to a buffer which is aligned to the cache line size (__SCB_DCACHE_LINE_SIZE). The length of buffer data must be a multiple of the cache line size to ensure cache coherency. CY_ALIGN(__SCB_DCACHE_LINE_SIZE) macro can be used for 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 if 'length' is greater than the configured block size, it must also be a multiple of the block size. |
| [in] | length | The number of bytes to send. Must be less than the block size set up by the user (default: 64 bytes) OR be aligned with the block size. For example. the following lengths are legal for a block size of 64 bytes: 10, 29, 33, 64, 128, 192... |
| [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 mtb_hal_sdio_host_set_io_voltage | ( | mtb_hal_sdio_t * | obj, |
| mtb_hal_sdio_host_io_voltage_t | io_voltage, | ||
| mtb_hal_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_voltage | I/O voltage to be set on lines |
| [in] | io_switch_type | Defines how I/O voltage will be switched |