HAL SDIO How to Use

group SDIO_How_To_Use

How to use this driver

The HAL SDIO driver can be used as follows:

SDIO card system specifications are available through the SD card association website at www.sdcard.org This driver is compliant with SDIO card specification version 4.0 and fully compliant with previous version.

This HAL SDIO driver is a layered driver on top of the SDMMC core driver (allowing to handle SD,MMC memories and SDIO cards). The HAL SDIO driver allows to interface with SDIO cards.

This driver implements a high level communication layer for read and write from/to this SDIO card.

This driver provides 8 different sets of APIs that allows to:

  1. Initialize and de-initialize the logical SDIO object :

    • To initialize the SDIO Card, use the HAL_SDIO_Init() function

      • to associate physical instance to logical object.

      • Enable the SDMMC peripheral clock either by :

        • Calling the appropriate HAL RCC function HAL_RCC_SDMMCx_EnableClock

        • Setting the USE_HAL_SDIO_CLK_ENABLE_MODEL to HAL_CLK_ENABLE_PERIPH_ONLY through stm32tnxx_hal_conf.h module, in this case the SDMMC peripheral clock must be automatically enabled by the HAL_SDIO_Init() .

    • To de-initialize the SDIO card, use the HAL_SDIO_DeInit() function that must turn off the SDIO Card and set the HAL SDIO handle state to RESET.

  2. Set and Get SDIO configuration:

    • Configures the SDIO card. The clock frequency must be less than 400 kHz. This phase allows the card identification to ensure that the card has been correctly identified. After identification, apply the user parameters. During this stage, the SDIO card moves from the IDENTIFICATION STATE to the TRANSFER STATE and sets the global state to the IDLE state.

    • To retrieve the current SDIO card configuration, use the HAL_SDIO_GetConfig() .

    • When the GPIO Pin detects a removal of the SDIO card from the bus, use the HAL_SDIO_NotifyCardRemoval() to apply the SDMMC default configuration and wait for an insertion of the SDIO card.

    • When the GPIO Pin detects an insertion of the SDIO card, use the HAL_SDIO_NotifyCardInsertion() to re-apply the user configuration.

    • To change the SDIO data bus width, use the HAL_SDIO_SetDataBusWidth() .

    • To get the SDIO data bus width, use the HAL_SDIO_GetDataBusWidth() .

    • To set a new transfer clock frequency, use the HAL_SDIO_SetTransferClockFreq() .

    • To get the current transfer clock frequency, use the HAL_SDIO_GetTransferClockFreq() .

    • To update the SDIO block size, use the HAL_SDIO_SetBlockSize() .

    • To configure the speed mode on the SDIO card, use HAL_SDIO_SetSpeedMode() .

    • To reset the SDIO card, use the HAL_SDIO_ResetCard() .

    • To retrieve the peripheral clock frequency for SDIO card, use the HAL_SDIO_GetClockFreq() .

    • According to the SDIO card specification, the timeout values available through define can be used also by user to fill the configuration structure at the SetConfig call:

      • HAL_SDIO_DATA_MAX_TIMEOUT (0xFFFFFFFFU) : Max data timeout

      • For the data_timeout_cycle : Use HAL_SDIO_SetDataTimeout() to update it with the user definition

  3. Input and Output operations:

  4. IRQHandler and Callbacks Functions:

  5. SDIO Card related information functions:

  6. SDIO card IO interrupt:

  7. SDIO Delay Block functions: The delay block (DLYB) is used to generate an output clock that is phased from the input clock.

  8. SDIO Card Interrupt and flags Inline functions: