STM32L486xx HAL User Manual
Functions
SD_Exported_Functions_Group2
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

__weak void HAL_SD_AbortCallback ( SD_HandleTypeDef *  hsd)

SD Abort callbacks.

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

Definition at line 2047 of file stm32l4xx_hal_sd.c.

Referenced by HAL_SD_Abort_IT(), HAL_SD_Init(), HAL_SD_IRQHandler(), HAL_SD_UnRegisterCallback(), SD_DMARxAbort(), and SD_DMATxAbort().

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 1573 of file stm32l4xx_hal_sd.c.

__weak void HAL_SD_ErrorCallback ( SD_HandleTypeDef *  hsd)

SD error callbacks.

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

Definition at line 2032 of file stm32l4xx_hal_sd.c.

Referenced by HAL_SD_Init(), HAL_SD_IRQHandler(), HAL_SD_UnRegisterCallback(), SD_DMAError(), SD_DMAReceiveCplt(), SD_DMARxAbort(), and SD_DMATxAbort().

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 1992 of file stm32l4xx_hal_sd.c.

HAL_SD_StateTypeDef HAL_SD_GetState ( SD_HandleTypeDef *  hsd)

return the SD state

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

Definition at line 1981 of file stm32l4xx_hal_sd.c.

void HAL_SD_IRQHandler ( SD_HandleTypeDef *  hsd)

This function handles SD card interrupt request.

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

Definition at line 1675 of file stm32l4xx_hal_sd.c.

References HAL_DMA_Abort_IT(), HAL_SD_AbortCallback(), HAL_SD_ErrorCallback(), HAL_SD_RxCpltCallback(), HAL_SD_TxCpltCallback(), SD_DMARxAbort(), SD_DMATxAbort(), SD_Read_IT(), and SD_Write_IT().

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 638 of file stm32l4xx_hal_sd.c.

References HAL_GetTick().

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 1277 of file stm32l4xx_hal_sd.c.

References HAL_DMA_Start_IT(), SD_DMAError(), and SD_DMAReceiveCplt().

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 1050 of file stm32l4xx_hal_sd.c.

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:
  • HAL_SD_TX_CPLT_CB_ID SD Tx Complete Callback ID
  • HAL_SD_RX_CPLT_CB_ID SD Rx Complete Callback ID
  • HAL_SD_ERROR_CB_ID SD Error Callback ID
  • HAL_SD_ABORT_CB_ID SD Abort Callback ID
  • HAL_SD_MSP_INIT_CB_ID SD MspInit Callback ID
  • HAL_SD_MSP_DEINIT_CB_ID SD MspDeInit Callback ID
pCallback: pointer to the Callback function
Return values:
status

Definition at line 2073 of file stm32l4xx_hal_sd.c.

__weak void HAL_SD_RxCpltCallback ( SD_HandleTypeDef *  hsd)

Rx Transfer completed callbacks.

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

Definition at line 2017 of file stm32l4xx_hal_sd.c.

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

__weak void HAL_SD_TxCpltCallback ( SD_HandleTypeDef *  hsd)

Tx Transfer completed callbacks.

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

Definition at line 2002 of file stm32l4xx_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:
  • HAL_SD_TX_CPLT_CB_ID SD Tx Complete Callback ID
  • HAL_SD_RX_CPLT_CB_ID SD Rx Complete Callback ID
  • HAL_SD_ERROR_CB_ID SD Error Callback ID
  • HAL_SD_ABORT_CB_ID SD Abort Callback ID
  • HAL_SD_MSP_INIT_CB_ID SD MspInit Callback ID
  • HAL_SD_MSP_DEINIT_CB_ID SD MspDeInit Callback ID
Return values:
status

Definition at line 2176 of file stm32l4xx_hal_sd.c.

References HAL_SD_AbortCallback(), HAL_SD_ErrorCallback(), HAL_SD_MspDeInit(), HAL_SD_MspInit(), HAL_SD_RxCpltCallback(), and HAL_SD_TxCpltCallback().

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 856 of file stm32l4xx_hal_sd.c.

References HAL_GetTick().

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 1423 of file stm32l4xx_hal_sd.c.

References HAL_DMA_Start_IT(), SD_DMAError(), and SD_DMATransmitCplt().

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 1159 of file stm32l4xx_hal_sd.c.