MT2523 API Reference  LinkIt SDK v4
SDIO

This section introduces the SDIO driver APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, SDIO function groups,enums, structures and functions. More...

Overview

This section introduces the SDIO driver APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, SDIO function groups,enums, structures and functions.

Terms and acronyms

Terms Details
MSDC MS/SD memory card controller, that supports the MultiMediaCard System Specification Version 4.41,SD Memory Card Specification Version 2.0 and SDIO Card Specification Version 2.0.
SDIO Secure Digital Input and Output.For an introduction to the SDIO, please refer to SDIO in Wikipedia .

Supported features

Software architecture of the SDIO

Call hal_sdio_init() to initialize the MSDC and the SDIO slave. Then the SDIO slave gets into a transfer state. Call hal_sdio_execute_command53(), hal_sdio_execute_command53_dma() or hal_sdio_execute_command52() to write data to the SDIO slave or read data from the SDIO slave. Other supported APIs can also be called, such as hal_sdio_set_clock(). Use COMMAND52 to access a single SDIO slave register and COMMAND53 to read and write multiple SDIO slave registers. For more details about COMMAND52 and COMMAND53, please refer to SDIO Simplified Specification V2.0 Chapter 5.1 and Chapter 5.3 .


How to use this driver

Functions

hal_sdio_status_t hal_sdio_init (hal_sdio_port_t sdio_port, hal_sdio_config_t *sdio_config)
 This function initializes the MSDC hardware and SDIO slave. More...
 
hal_sdio_status_t hal_sdio_deinit (hal_sdio_port_t sdio_port)
 This function deinitializes the MSDC and the SDIO slave settings. More...
 
hal_sdio_status_t hal_sdio_set_clock (hal_sdio_port_t sdio_port, uint32_t clock)
 Set the output clock of the MSDC. More...
 
hal_sdio_status_t hal_sdio_get_clock (hal_sdio_port_t sdio_port, uint32_t *clock)
 Get the output clock of the MSDC. More...
 
hal_sdio_status_t hal_sdio_set_bus_width (hal_sdio_port_t sdio_port, hal_sdio_bus_width_t bus_width)
 This function sets the bus widths for the MSDC and SDIO slave. More...
 
hal_sdio_status_t hal_sdio_set_block_size (hal_sdio_port_t sdio_port, hal_sdio_function_id_t function, uint32_t block_size)
 This function sets the transaction block size of the MSDC. More...
 
hal_sdio_status_t hal_sdio_get_block_size (hal_sdio_port_t sdio_port, hal_sdio_function_id_t function, uint32_t *block_size)
 This function gets the transaction block size of the MSDC. More...
 
hal_sdio_status_t hal_sdio_execute_command52 (hal_sdio_port_t sdio_port, hal_sdio_command52_config_t *command52_config)
 This function reads from or writes to the SDIO slave with COMMAND52. More...
 
hal_sdio_status_t hal_sdio_execute_command53 (hal_sdio_port_t sdio_port, hal_sdio_command53_config_t *command53_config)
 This function reads from or writes to the SDIO slave with COMMAND53 MCU mode. More...
 
hal_sdio_status_t hal_sdio_execute_command53_dma (hal_sdio_port_t sdio_port, hal_sdio_command53_config_t *command53_config)
 This function reads from or writes to the SDIO slave with COMMAND53 DMA mode. More...
 

Modules

 Enum
 
 Struct
 

Function Documentation

hal_sdio_status_t hal_sdio_deinit ( hal_sdio_port_t  sdio_port)

This function deinitializes the MSDC and the SDIO slave settings.

Parameters
[in]sdio_portis the MSDC deinitialization port.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully.
See also
hal_sdio_init()
hal_sdio_status_t hal_sdio_execute_command52 ( hal_sdio_port_t  sdio_port,
hal_sdio_command52_config_t command52_config 
)

This function reads from or writes to the SDIO slave with COMMAND52.

Parameters
[in]sdio_portis the MSDC port to read or write.
[in]command52_configis the configuration parameter pointer of the COMMAND52.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given. If the return value is HAL_SDIO_STATUS_BUSY, the MSDC is busy.
hal_sdio_status_t hal_sdio_execute_command53 ( hal_sdio_port_t  sdio_port,
hal_sdio_command53_config_t command53_config 
)

This function reads from or writes to the SDIO slave with COMMAND53 MCU mode.

Parameters
[in]sdio_portis the MSDC port to read.
[in]command53_configis the configuration parameter pointer of the COMMAND53.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given. If the return value is HAL_SDIO_STATUS_BUSY, the MSDC is busy.
hal_sdio_status_t hal_sdio_execute_command53_dma ( hal_sdio_port_t  sdio_port,
hal_sdio_command53_config_t command53_config 
)

This function reads from or writes to the SDIO slave with COMMAND53 DMA mode.

This API may block the application task.

Parameters
[in]sdio_portis the MSDC port to read.
[in]command53_configis the configuration parameter pointer of the COMMAND53.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given. If the return value is HAL_SDIO_STATUS_BUSY, the MSDC is busy.
hal_sdio_status_t hal_sdio_get_block_size ( hal_sdio_port_t  sdio_port,
hal_sdio_function_id_t  function,
uint32_t *  block_size 
)

This function gets the transaction block size of the MSDC.

Parameters
[in]sdio_portis the MSDC port to get blcok size.
[in]functionis the SDIO function to get block size.
[out]block_sizeis the SDIO transaction block size.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given.
hal_sdio_status_t hal_sdio_get_clock ( hal_sdio_port_t  sdio_port,
uint32_t *  clock 
)

Get the output clock of the MSDC.

Parameters
[in]sdio_portis the MSDC port to get clock.
[out]clockis the current output clock of the MSDC.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given.
hal_sdio_status_t hal_sdio_init ( hal_sdio_port_t  sdio_port,
hal_sdio_config_t sdio_config 
)

This function initializes the MSDC hardware and SDIO slave.

It can also be used to set the MSDC pin output clock and bus width.

Parameters
[in]sdio_portis the initialization configuration port. For more details about this parameter, please refer to hal_sdio_port_t.
[in]sdio_configis the initialization configuration parameter. For more details about this parameter, please refer to hal_sdio_config_t.
Returns
Indicates whether this function call is successful or not. If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an initialization error occurred. If the return value is HAL_SDIO_STATUS_BUSY, the MSDC is busy.
See also
hal_sdio_deinit()
hal_sdio_status_t hal_sdio_set_block_size ( hal_sdio_port_t  sdio_port,
hal_sdio_function_id_t  function,
uint32_t  block_size 
)

This function sets the transaction block size of the MSDC.

Parameters
[in]sdio_portis the MSDC port to set.
[in]functionis the SDIO function to set block size.
[in]block_sizeis the SDIO transaction block size.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given. If the return value is HAL_SDIO_STATUS_BUSY, the MSDC is busy.
hal_sdio_status_t hal_sdio_set_bus_width ( hal_sdio_port_t  sdio_port,
hal_sdio_bus_width_t  bus_width 
)

This function sets the bus widths for the MSDC and SDIO slave.

Parameters
[in]sdio_portis the MSDC port to set.
[in]bus_widthis the SDIO bus width.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given. If the return value is HAL_SDIO_STATUS_BUSY, the MSDC is busy.
hal_sdio_status_t hal_sdio_set_clock ( hal_sdio_port_t  sdio_port,
uint32_t  clock 
)

Set the output clock of the MSDC.

Parameters
[in]sdio_portis the MSDC port to set clock.
[in]clockis the expected output clock of the MSDC.
Returns
If the return value is HAL_SDIO_STATUS_OK, the operation completed successfully. If the return value is HAL_SDIO_STATUS_ERROR, an error occurred, such as a wrong parameter is given. If the return value is HAL_SDIO_STATUS_BUSY, the MSDC is busy.