SD Card Write operation
You can write to SD card in polling mode by using function HAL_SD_WriteBlocks().
This function allows the read of 512 bytes blocks. You can choose either one block
read operation or multiple block read operation by adjusting the "NumberOfBlocks"
parameter. After this, you have to ensure that the transfer is done correctly. The check
is done through HAL_SD_GetCardState() function for SD card state.
You can write to SD card in DMA mode by using function
HAL_SD_WriteBlocks_DMA(). This function allows the read of 512 bytes blocks. You
can choose either one block read operation or multiple block read operation by
adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the
transfer is done correctly. The check is done through HAL_SD_GetCardState()
function for SD card state. You could also check the DMA transfer process through the
SD Tx interrupt event.
You can write to SD card in Interrupt mode by using function
HAL_SD_WriteBlocks_IT(). This function allows the read of 512 bytes blocks. You can
choose either one block read operation or multiple block read operation by adjusting
the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is
done correctly. The check is done through HAL_SD_GetCardState() function for SD
card state. You could also check the IT transfer process through the SD Tx interrupt
event.
SD card status
The SD Status contains status bits that are related to the SD Memory Card proprietary
features. To get SD card status use the HAL_SD_GetCardStatus().
SD card information
To get SD card information, you can use the function HAL_SD_GetCardInfo(). It
returns useful information about the SD card such as block size, card type, block
number ...
SD card CSD register
The HAL_SD_GetCardCSD() API allows to get the parameters of the CSD register.
Some of the CSD parameters are useful for card initialization and identification.
SD card CID register
The HAL_SD_GetCardCID() API allows to get the parameters of the CID register.
Some of the CSD parameters are useful for card initialization and identification.
SD HAL driver macros list
Below the list of most used macros in SD HAL driver.
__HAL_SD_ENABLE : Enable the SD device
__HAL_SD_DISABLE : Disable the SD device
__HAL_SD_DMA_ENABLE: Enable the SDIO DMA transfer
__HAL_SD_DMA_DISABLE: Disable the SDIO DMA transfer
__HAL_SD_ENABLE_IT: Enable the SD device interrupt
__HAL_SD_DISABLE_IT: Disable the SD device interrupt
__HAL_SD_GET_FLAG:Check whether the specified SD flag is set or not
__HAL_SD_CLEAR_FLAG: Clear the SD's pending flags