STM32H735xx HAL User Manual
Functions
Input and Output operation functions
SD Exported Functions

Data transfer functions. More...

Functions

HAL_StatusTypeDef HAL_SD_ReadBlocks (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout)
 Reads block(s) from a specified address in a card.
HAL_StatusTypeDef HAL_SD_WriteBlocks (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout)
 Allows to write block(s) to a specified address in a card.
HAL_StatusTypeDef HAL_SD_ReadBlocks_IT (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
 Reads block(s) from a specified address in a card.
HAL_StatusTypeDef HAL_SD_WriteBlocks_IT (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
 Writes block(s) to a specified address in a card.
HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
 Reads block(s) from a specified address in a card.
HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA (SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks)
 Writes block(s) to a specified address in a card.
HAL_StatusTypeDef HAL_SD_Erase (SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd)
 Erases the specified memory area of the given SD card.
void HAL_SD_IRQHandler (SD_HandleTypeDef *hsd)
 This function handles SD card interrupt request.
HAL_SD_StateTypeDef HAL_SD_GetState (SD_HandleTypeDef *hsd)
 return the SD state
uint32_t HAL_SD_GetError (SD_HandleTypeDef *hsd)
 Return the SD error code.
__weak void HAL_SD_TxCpltCallback (SD_HandleTypeDef *hsd)
 Tx Transfer completed callbacks.
__weak void HAL_SD_RxCpltCallback (SD_HandleTypeDef *hsd)
 Rx Transfer completed callbacks.
__weak void HAL_SD_ErrorCallback (SD_HandleTypeDef *hsd)
 SD error callbacks.
__weak void HAL_SD_AbortCallback (SD_HandleTypeDef *hsd)
 SD Abort callbacks.
HAL_StatusTypeDef HAL_SD_RegisterCallback (SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID, pSD_CallbackTypeDef pCallback)
 Register a User SD Callback To be used instead of the weak (surcharged) predefined callback.
HAL_StatusTypeDef HAL_SD_UnRegisterCallback (SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID)
 Unregister a User SD Callback SD Callback is redirected to the weak (surcharged) predefined callback.

Detailed Description

Data transfer functions.

  ==============================================================================
                        ##### IO operation functions #####
  ==============================================================================
  [..]
    This subsection provides a set of functions allowing to manage the data
    transfer from/to SD card.


Function Documentation

SD Abort callbacks.

Parameters:
hsd,:Pointer SD handle
Return values:
None

Definition at line 1827 of file stm32h7xx_hal_sd.c.

Referenced by HAL_SD_Abort_IT(), HAL_SD_Init(), and HAL_SD_UnRegisterCallback().

HAL_StatusTypeDef HAL_SD_Erase ( SD_HandleTypeDef hsd,
uint32_t  BlockStartAdd,
uint32_t  BlockEndAdd 
)

Erases the specified memory area of the given SD card.

Note:
This API should be followed by a check on the card state through HAL_SD_GetCardState().
Parameters:
hsd,:Pointer to SD handle
BlockStartAdd,:Start Block address
BlockEndAdd,:End Block address
Return values:
HALstatus

Definition at line 1424 of file stm32h7xx_hal_sd.c.

References __HAL_SD_CLEAR_FLAG, CARD_SDHC_SDXC, CARD_SECURED, HAL_SD_CardInfoTypeDef::CardType, HAL_SD_CardInfoTypeDef::Class, __SD_HandleTypeDef::ErrorCode, HAL_SD_ERROR_ADDR_OUT_OF_RANGE, HAL_SD_ERROR_LOCK_UNLOCK_FAILED, HAL_SD_ERROR_NONE, HAL_SD_ERROR_PARAM, HAL_SD_ERROR_REQUEST_NOT_APPLICABLE, HAL_SD_STATE_BUSY, HAL_SD_STATE_READY, __SD_HandleTypeDef::Instance, HAL_SD_CardInfoTypeDef::LogBlockNbr, __SD_HandleTypeDef::SdCard, and __SD_HandleTypeDef::State.

SD error callbacks.

Parameters:
hsd,:Pointer SD handle
Return values:
None

Definition at line 1812 of file stm32h7xx_hal_sd.c.

Referenced by HAL_SD_Init(), HAL_SD_IRQHandler(), and HAL_SD_UnRegisterCallback().

uint32_t HAL_SD_GetError ( SD_HandleTypeDef hsd)

Return the SD error code.

Parameters:
hsd: Pointer to a SD_HandleTypeDef structure that contains the configuration information.
Return values:
SDError Code

Definition at line 1772 of file stm32h7xx_hal_sd.c.

References __SD_HandleTypeDef::ErrorCode.

return the SD state

Parameters:
hsd,:Pointer to sd handle
Return values:
HALstate

Definition at line 1761 of file stm32h7xx_hal_sd.c.

References __SD_HandleTypeDef::State.

HAL_StatusTypeDef HAL_SD_ReadBlocks ( SD_HandleTypeDef hsd,
uint8_t *  pData,
uint32_t  BlockAdd,
uint32_t  NumberOfBlocks,
uint32_t  Timeout 
)

Reads block(s) from a specified address in a card.

The Data transfer is managed by polling mode.

Note:
This API should be followed by a check on the card state through HAL_SD_GetCardState().
Parameters:
hsd,:Pointer to SD handle
pData,:pointer to the buffer that will contain the received data
BlockAdd,:Block Address from where data is to be read
NumberOfBlocks,:Number of SD blocks to read
Timeout,:Specify timeout value
Return values:
HALstatus

Definition at line 665 of file stm32h7xx_hal_sd.c.

References __HAL_SD_CLEAR_FLAG, __HAL_SD_GET_FLAG, BLOCKSIZE, CARD_SDHC_SDXC, CARD_SECURED, HAL_SD_CardInfoTypeDef::CardType, __SD_HandleTypeDef::Context, __SD_HandleTypeDef::ErrorCode, HAL_GetTick(), HAL_SD_ERROR_ADDR_OUT_OF_RANGE, HAL_SD_ERROR_BUSY, HAL_SD_ERROR_DATA_CRC_FAIL, HAL_SD_ERROR_DATA_TIMEOUT, HAL_SD_ERROR_NONE, HAL_SD_ERROR_PARAM, HAL_SD_ERROR_RX_OVERRUN, HAL_SD_ERROR_TIMEOUT, HAL_SD_STATE_BUSY, HAL_SD_STATE_READY, __SD_HandleTypeDef::Instance, HAL_SD_CardInfoTypeDef::LogBlockNbr, SD_CONTEXT_NONE, SD_CONTEXT_READ_MULTIPLE_BLOCK, SD_CONTEXT_READ_SINGLE_BLOCK, __SD_HandleTypeDef::SdCard, and __SD_HandleTypeDef::State.

HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA ( SD_HandleTypeDef hsd,
uint8_t *  pData,
uint32_t  BlockAdd,
uint32_t  NumberOfBlocks 
)

Reads block(s) from a specified address in a card.

The Data transfer is managed by DMA mode.

Note:
This API should be followed by a check on the card state through HAL_SD_GetCardState().
You could also check the DMA transfer process through the SD Rx interrupt event.
Parameters:
hsd,:Pointer SD handle
pData,:Pointer to the buffer that will contain the received data
BlockAdd,:Block Address from where data is to be read
NumberOfBlocks,:Number of blocks to read.
Return values:
HALstatus

Definition at line 1229 of file stm32h7xx_hal_sd.c.

References __HAL_SD_CLEAR_FLAG, __HAL_SD_ENABLE_IT, BLOCKSIZE, CARD_SDHC_SDXC, HAL_SD_CardInfoTypeDef::CardType, __SD_HandleTypeDef::Context, __SD_HandleTypeDef::ErrorCode, HAL_SD_ERROR_ADDR_OUT_OF_RANGE, HAL_SD_ERROR_NONE, HAL_SD_ERROR_PARAM, HAL_SD_STATE_BUSY, HAL_SD_STATE_READY, __SD_HandleTypeDef::Instance, HAL_SD_CardInfoTypeDef::LogBlockNbr, __SD_HandleTypeDef::pRxBuffPtr, __SD_HandleTypeDef::RxXferSize, SD_CONTEXT_DMA, SD_CONTEXT_NONE, SD_CONTEXT_READ_MULTIPLE_BLOCK, SD_CONTEXT_READ_SINGLE_BLOCK, __SD_HandleTypeDef::SdCard, and __SD_HandleTypeDef::State.

HAL_StatusTypeDef HAL_SD_ReadBlocks_IT ( SD_HandleTypeDef hsd,
uint8_t *  pData,
uint32_t  BlockAdd,
uint32_t  NumberOfBlocks 
)

Reads block(s) from a specified address in a card.

The Data transfer is managed in interrupt mode.

Note:
This API should be followed by a check on the card state through HAL_SD_GetCardState().
You could also check the IT transfer process through the SD Rx interrupt event.
Parameters:
hsd,:Pointer to SD handle
pData,:Pointer to the buffer that will contain the received data
BlockAdd,:Block Address from where data is to be read
NumberOfBlocks,:Number of blocks to read.
Return values:
HALstatus

Definition at line 1037 of file stm32h7xx_hal_sd.c.

References __HAL_SD_CLEAR_FLAG, __HAL_SD_ENABLE_IT, BLOCKSIZE, CARD_SDHC_SDXC, HAL_SD_CardInfoTypeDef::CardType, __SD_HandleTypeDef::Context, __SD_HandleTypeDef::ErrorCode, HAL_SD_ERROR_ADDR_OUT_OF_RANGE, HAL_SD_ERROR_NONE, HAL_SD_ERROR_PARAM, HAL_SD_STATE_BUSY, HAL_SD_STATE_READY, __SD_HandleTypeDef::Instance, HAL_SD_CardInfoTypeDef::LogBlockNbr, __SD_HandleTypeDef::pRxBuffPtr, __SD_HandleTypeDef::RxXferSize, SD_CONTEXT_IT, SD_CONTEXT_NONE, SD_CONTEXT_READ_MULTIPLE_BLOCK, SD_CONTEXT_READ_SINGLE_BLOCK, __SD_HandleTypeDef::SdCard, and __SD_HandleTypeDef::State.

HAL_StatusTypeDef HAL_SD_RegisterCallback ( SD_HandleTypeDef hsd,
HAL_SD_CallbackIDTypeDef  CallbackID,
pSD_CallbackTypeDef  pCallback 
)

Register a User SD Callback To be used instead of the weak (surcharged) predefined callback.

Parameters:
hsd: SD handle
CallbackID: ID of the callback to be registered This parameter can be one of the following values:
pCallback: pointer to the Callback function
Return values:
status

Definition at line 1873 of file stm32h7xx_hal_sd.c.

References __SD_HandleTypeDef::AbortCpltCallback, __SD_HandleTypeDef::ErrorCallback, __SD_HandleTypeDef::ErrorCode, HAL_SD_ABORT_CB_ID, HAL_SD_ERROR_CB_ID, HAL_SD_ERROR_INVALID_CALLBACK, HAL_SD_MSP_DEINIT_CB_ID, HAL_SD_MSP_INIT_CB_ID, HAL_SD_READ_DMA_DBL_BUF0_CPLT_CB_ID, HAL_SD_READ_DMA_DBL_BUF1_CPLT_CB_ID, HAL_SD_RX_CPLT_CB_ID, HAL_SD_STATE_READY, HAL_SD_STATE_RESET, HAL_SD_TX_CPLT_CB_ID, HAL_SD_WRITE_DMA_DBL_BUF0_CPLT_CB_ID, HAL_SD_WRITE_DMA_DBL_BUF1_CPLT_CB_ID, __SD_HandleTypeDef::MspDeInitCallback, __SD_HandleTypeDef::MspInitCallback, __SD_HandleTypeDef::Read_DMADblBuf0CpltCallback, __SD_HandleTypeDef::Read_DMADblBuf1CpltCallback, __SD_HandleTypeDef::RxCpltCallback, __SD_HandleTypeDef::State, __SD_HandleTypeDef::TxCpltCallback, __SD_HandleTypeDef::Write_DMADblBuf0CpltCallback, and __SD_HandleTypeDef::Write_DMADblBuf1CpltCallback.

Rx Transfer completed callbacks.

Parameters:
hsd,:Pointer SD handle
Return values:
None

Definition at line 1797 of file stm32h7xx_hal_sd.c.

Referenced by HAL_SD_Init(), HAL_SD_IRQHandler(), and HAL_SD_UnRegisterCallback().

Tx Transfer completed callbacks.

Parameters:
hsd,:Pointer to SD handle
Return values:
None

Definition at line 1782 of file stm32h7xx_hal_sd.c.

Referenced by HAL_SD_Init(), HAL_SD_IRQHandler(), and HAL_SD_UnRegisterCallback().

HAL_StatusTypeDef HAL_SD_UnRegisterCallback ( SD_HandleTypeDef hsd,
HAL_SD_CallbackIDTypeDef  CallbackID 
)

Unregister a User SD Callback SD Callback is redirected to the weak (surcharged) predefined callback.

Parameters:
hsd: SD handle
CallbackID: ID of the callback to be unregistered This parameter can be one of the following values:
Return values:
status

Definition at line 1979 of file stm32h7xx_hal_sd.c.

References __SD_HandleTypeDef::AbortCpltCallback, __SD_HandleTypeDef::ErrorCallback, __SD_HandleTypeDef::ErrorCode, HAL_SD_ABORT_CB_ID, HAL_SD_AbortCallback(), HAL_SD_ERROR_CB_ID, HAL_SD_ERROR_INVALID_CALLBACK, HAL_SD_ErrorCallback(), HAL_SD_MSP_DEINIT_CB_ID, HAL_SD_MSP_INIT_CB_ID, HAL_SD_MspDeInit(), HAL_SD_MspInit(), HAL_SD_READ_DMA_DBL_BUF0_CPLT_CB_ID, HAL_SD_READ_DMA_DBL_BUF1_CPLT_CB_ID, HAL_SD_RX_CPLT_CB_ID, HAL_SD_RxCpltCallback(), HAL_SD_STATE_READY, HAL_SD_STATE_RESET, HAL_SD_TX_CPLT_CB_ID, HAL_SD_TxCpltCallback(), HAL_SD_WRITE_DMA_DBL_BUF0_CPLT_CB_ID, HAL_SD_WRITE_DMA_DBL_BUF1_CPLT_CB_ID, HAL_SDEx_Read_DMADoubleBuf0CpltCallback(), HAL_SDEx_Read_DMADoubleBuf1CpltCallback(), HAL_SDEx_Write_DMADoubleBuf0CpltCallback(), HAL_SDEx_Write_DMADoubleBuf1CpltCallback(), __SD_HandleTypeDef::MspDeInitCallback, __SD_HandleTypeDef::MspInitCallback, __SD_HandleTypeDef::Read_DMADblBuf0CpltCallback, __SD_HandleTypeDef::Read_DMADblBuf1CpltCallback, __SD_HandleTypeDef::RxCpltCallback, __SD_HandleTypeDef::State, __SD_HandleTypeDef::TxCpltCallback, __SD_HandleTypeDef::Write_DMADblBuf0CpltCallback, and __SD_HandleTypeDef::Write_DMADblBuf1CpltCallback.

HAL_StatusTypeDef HAL_SD_WriteBlocks ( SD_HandleTypeDef hsd,
uint8_t *  pData,
uint32_t  BlockAdd,
uint32_t  NumberOfBlocks,
uint32_t  Timeout 
)

Allows to write block(s) to a specified address in a card.

The Data transfer is managed by polling mode.

Note:
This API should be followed by a check on the card state through HAL_SD_GetCardState().
Parameters:
hsd,:Pointer to SD handle
pData,:pointer to the buffer that will contain the data to transmit
BlockAdd,:Block Address where data will be written
NumberOfBlocks,:Number of SD blocks to write
Timeout,:Specify timeout value
Return values:
HALstatus

Definition at line 850 of file stm32h7xx_hal_sd.c.

References __HAL_SD_CLEAR_FLAG, __HAL_SD_GET_FLAG, BLOCKSIZE, CARD_SDHC_SDXC, CARD_SECURED, HAL_SD_CardInfoTypeDef::CardType, __SD_HandleTypeDef::Context, __SD_HandleTypeDef::ErrorCode, HAL_GetTick(), HAL_SD_ERROR_ADDR_OUT_OF_RANGE, HAL_SD_ERROR_BUSY, HAL_SD_ERROR_DATA_CRC_FAIL, HAL_SD_ERROR_DATA_TIMEOUT, HAL_SD_ERROR_NONE, HAL_SD_ERROR_PARAM, HAL_SD_ERROR_TX_UNDERRUN, HAL_SD_STATE_BUSY, HAL_SD_STATE_READY, __SD_HandleTypeDef::Instance, HAL_SD_CardInfoTypeDef::LogBlockNbr, SD_CONTEXT_NONE, SD_CONTEXT_WRITE_MULTIPLE_BLOCK, SD_CONTEXT_WRITE_SINGLE_BLOCK, __SD_HandleTypeDef::SdCard, and __SD_HandleTypeDef::State.

HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA ( SD_HandleTypeDef hsd,
uint8_t *  pData,
uint32_t  BlockAdd,
uint32_t  NumberOfBlocks 
)

Writes block(s) to a specified address in a card.

The Data transfer is managed by DMA mode.

Note:
This API should be followed by a check on the card state through HAL_SD_GetCardState().
You could also check the DMA transfer process through the SD Tx interrupt event.
Parameters:
hsd,:Pointer to SD handle
pData,:Pointer to the buffer that will contain the data to transmit
BlockAdd,:Block Address where data will be written
NumberOfBlocks,:Number of blocks to write
Return values:
HALstatus

Definition at line 1328 of file stm32h7xx_hal_sd.c.

References __HAL_SD_CLEAR_FLAG, __HAL_SD_ENABLE_IT, BLOCKSIZE, CARD_SDHC_SDXC, HAL_SD_CardInfoTypeDef::CardType, __SD_HandleTypeDef::Context, __SD_HandleTypeDef::ErrorCode, HAL_SD_ERROR_ADDR_OUT_OF_RANGE, HAL_SD_ERROR_NONE, HAL_SD_ERROR_PARAM, HAL_SD_STATE_BUSY, HAL_SD_STATE_READY, __SD_HandleTypeDef::Instance, HAL_SD_CardInfoTypeDef::LogBlockNbr, __SD_HandleTypeDef::pTxBuffPtr, SD_CONTEXT_DMA, SD_CONTEXT_NONE, SD_CONTEXT_WRITE_MULTIPLE_BLOCK, SD_CONTEXT_WRITE_SINGLE_BLOCK, __SD_HandleTypeDef::SdCard, __SD_HandleTypeDef::State, and __SD_HandleTypeDef::TxXferSize.

HAL_StatusTypeDef HAL_SD_WriteBlocks_IT ( SD_HandleTypeDef hsd,
uint8_t *  pData,
uint32_t  BlockAdd,
uint32_t  NumberOfBlocks 
)

Writes block(s) to a specified address in a card.

The Data transfer is managed in interrupt mode.

Note:
This API should be followed by a check on the card state through HAL_SD_GetCardState().
You could also check the IT transfer process through the SD Tx interrupt event.
Parameters:
hsd,:Pointer to SD handle
pData,:Pointer to the buffer that will contain the data to transmit
BlockAdd,:Block Address where data will be written
NumberOfBlocks,:Number of blocks to write
Return values:
HALstatus

Definition at line 1132 of file stm32h7xx_hal_sd.c.

References __HAL_SD_CLEAR_FLAG, __HAL_SD_ENABLE_IT, BLOCKSIZE, CARD_SDHC_SDXC, HAL_SD_CardInfoTypeDef::CardType, __SD_HandleTypeDef::Context, __SD_HandleTypeDef::ErrorCode, HAL_SD_ERROR_ADDR_OUT_OF_RANGE, HAL_SD_ERROR_NONE, HAL_SD_ERROR_PARAM, HAL_SD_STATE_BUSY, HAL_SD_STATE_READY, __SD_HandleTypeDef::Instance, HAL_SD_CardInfoTypeDef::LogBlockNbr, __SD_HandleTypeDef::pTxBuffPtr, SD_CONTEXT_IT, SD_CONTEXT_NONE, SD_CONTEXT_WRITE_MULTIPLE_BLOCK, SD_CONTEXT_WRITE_SINGLE_BLOCK, __SD_HandleTypeDef::SdCard, __SD_HandleTypeDef::State, and __SD_HandleTypeDef::TxXferSize.