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. | |
Enumerations | |
| enum | mtb_hal_sdio_event_t { MTB_HAL_SDIO_ALL_INTERRUPTS = 0x0E1FF } |
| Types of events that could be asserted by SDIO. More... | |
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. | |
| cy_rslt_t | mtb_hal_sdio_configure (mtb_hal_sdio_t *obj, const mtb_hal_sdio_cfg_t *config) |
| Configure the SDIO block. | |
| 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. | |
| void | mtb_hal_sdio_enable_event (mtb_hal_sdio_t *obj, mtb_hal_sdio_event_t event, bool enable) |
| Configure the callback event. | |
| cy_rslt_t | mtb_hal_sdio_process_interrupt (mtb_hal_sdio_t *obj) |
| Process interrupts related related to an SDIO instance. | |
| struct mtb_hal_sdio_cfg_t |
| enum mtb_hal_sdio_event_t |
| 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 |