WebRadioApp  0.1
bsp_driver_sd.h File Reference

This file contains the common defines and functions prototypes for the bsp_driver_sd.c driver. More...

#include "stm32h7xx_hal.h"
#include "fatfs_platform.h"
Include dependency graph for bsp_driver_sd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BSP_SD_CardInfo   HAL_SD_CardInfoTypeDef
 SD Card information structure. More...
 
#define MSD_OK   ((uint8_t)0x00)
 SD status structure definition. More...
 
#define MSD_ERROR   ((uint8_t)0x01)
 
#define MSD_ERROR_SD_NOT_PRESENT   ((uint8_t)0x02)
 
#define SD_TRANSFER_OK   ((uint8_t)0x00)
 SD transfer state definition. More...
 
#define SD_TRANSFER_BUSY   ((uint8_t)0x01)
 
#define SD_PRESENT   ((uint8_t)0x01)
 
#define SD_NOT_PRESENT   ((uint8_t)0x00)
 
#define SD_DATATIMEOUT   ((uint32_t)100000000)
 
#define SD_DetectIRQHandler()   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8)
 

Functions

uint8_t BSP_SD_Init (void)
 Initializes the SD card device. More...
 
uint8_t BSP_SD_ITConfig (void)
 Configures Interrupt mode for SD detection pin. More...
 
uint8_t BSP_SD_ReadBlocks (uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
 Reads block(s) from a specified address in an SD card, in polling mode. More...
 
uint8_t BSP_SD_WriteBlocks (uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
 Writes block(s) to a specified address in an SD card, in polling mode. More...
 
uint8_t BSP_SD_ReadBlocks_DMA (uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks)
 Reads block(s) from a specified address in an SD card, in DMA mode. More...
 
uint8_t BSP_SD_WriteBlocks_DMA (uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
 Writes block(s) to a specified address in an SD card, in DMA mode. More...
 
uint8_t BSP_SD_Erase (uint32_t StartAddr, uint32_t EndAddr)
 Erases the specified memory area of the given SD card. More...
 
uint8_t BSP_SD_GetCardState (void)
 Gets the current SD card data status. More...
 
void BSP_SD_GetCardInfo (BSP_SD_CardInfo *CardInfo)
 
uint8_t BSP_SD_IsDetected (void)
 Detects if SD card is correctly plugged in the memory slot or not. More...
 
void BSP_SD_AbortCallback (void)
 BSP SD Abort callback. More...
 
void BSP_SD_WriteCpltCallback (void)
 BSP Tx Transfer completed callback. More...
 
void BSP_SD_ReadCpltCallback (void)
 BSP Rx Transfer completed callback. More...
 

Detailed Description

This file contains the common defines and functions prototypes for the bsp_driver_sd.c driver.

(based on stm32h743i_eval_sd.h)

Attention

© Copyright (c) 2021 STMicroelectronics. All rights reserved.

This software component is licensed by ST under Ultimate Liberty license SLA0044, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: www.st.com/SLA0044

Macro Definition Documentation

◆ BSP_SD_CardInfo

#define BSP_SD_CardInfo   HAL_SD_CardInfoTypeDef

SD Card information structure.

◆ MSD_ERROR

#define MSD_ERROR   ((uint8_t)0x01)

◆ MSD_ERROR_SD_NOT_PRESENT

#define MSD_ERROR_SD_NOT_PRESENT   ((uint8_t)0x02)

◆ MSD_OK

#define MSD_OK   ((uint8_t)0x00)

SD status structure definition.

◆ SD_DATATIMEOUT

#define SD_DATATIMEOUT   ((uint32_t)100000000)

◆ SD_DetectIRQHandler

#define SD_DetectIRQHandler ( )    HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8)

◆ SD_NOT_PRESENT

#define SD_NOT_PRESENT   ((uint8_t)0x00)

◆ SD_PRESENT

#define SD_PRESENT   ((uint8_t)0x01)

◆ SD_TRANSFER_BUSY

#define SD_TRANSFER_BUSY   ((uint8_t)0x01)

◆ SD_TRANSFER_OK

#define SD_TRANSFER_OK   ((uint8_t)0x00)

SD transfer state definition.

Function Documentation

◆ BSP_SD_AbortCallback()

void BSP_SD_AbortCallback ( void  )

BSP SD Abort callback.

Return values
None
Note
empty (up to the user to fill it in or to remove it if useless)
Here is the caller graph for this function:

◆ BSP_SD_Erase()

uint8_t BSP_SD_Erase ( uint32_t  StartAddr,
uint32_t  EndAddr 
)

Erases the specified memory area of the given SD card.

Parameters
StartAddrStart byte address
EndAddrEnd byte address
Return values
SDstatus

References hsd1, MSD_ERROR, and MSD_OK.

◆ BSP_SD_GetCardInfo()

void BSP_SD_GetCardInfo ( BSP_SD_CardInfo CardInfo)

◆ BSP_SD_GetCardState()

uint8_t BSP_SD_GetCardState ( void  )

Gets the current SD card data status.

Parameters
None
Return values
Datatransfer state. This value can be one of the following values:
  • SD_TRANSFER_OK: No data transfer is acting
  • SD_TRANSFER_BUSY: Data transfer is acting

References hsd1, SD_TRANSFER_BUSY, and SD_TRANSFER_OK.

Here is the caller graph for this function:

◆ BSP_SD_Init()

uint8_t BSP_SD_Init ( void  )

Initializes the SD card device.

Return values
SDstatus

References BSP_SD_IsDetected(), hsd1, MSD_ERROR, MSD_ERROR_SD_NOT_PRESENT, MSD_OK, and SD_PRESENT.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BSP_SD_IsDetected()

uint8_t BSP_SD_IsDetected ( void  )

Detects if SD card is correctly plugged in the memory slot or not.

Parameters
None
Return values
Returnsif SD is detected or not

References BSP_PlatformIsDetected(), SD_NOT_PRESENT, and SD_PRESENT.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BSP_SD_ITConfig()

uint8_t BSP_SD_ITConfig ( void  )

Configures Interrupt mode for SD detection pin.

Return values
Returns0

◆ BSP_SD_ReadBlocks()

uint8_t BSP_SD_ReadBlocks ( uint32_t *  pData,
uint32_t  ReadAddr,
uint32_t  NumOfBlocks,
uint32_t  Timeout 
)

Reads block(s) from a specified address in an SD card, in polling mode.

Parameters
pDataPointer to the buffer that will contain the data to transmit
ReadAddrAddress from where data is to be read
NumOfBlocksNumber of SD blocks to read
TimeoutTimeout for read operation
Return values
SDstatus

References hsd1, MSD_ERROR, and MSD_OK.

Here is the caller graph for this function:

◆ BSP_SD_ReadBlocks_DMA()

uint8_t BSP_SD_ReadBlocks_DMA ( uint32_t *  pData,
uint32_t  ReadAddr,
uint32_t  NumOfBlocks 
)

Reads block(s) from a specified address in an SD card, in DMA mode.

Parameters
pDataPointer to the buffer that will contain the data to transmit
ReadAddrAddress from where data is to be read
NumOfBlocksNumber of SD blocks to read
Return values
SDstatus

References hsd1, MSD_ERROR, and MSD_OK.

◆ BSP_SD_ReadCpltCallback()

void BSP_SD_ReadCpltCallback ( void  )

BSP Rx Transfer completed callback.

Return values
None
Note
empty (up to the user to fill it in or to remove it if useless)
Here is the caller graph for this function:

◆ BSP_SD_WriteBlocks()

uint8_t BSP_SD_WriteBlocks ( uint32_t *  pData,
uint32_t  WriteAddr,
uint32_t  NumOfBlocks,
uint32_t  Timeout 
)

Writes block(s) to a specified address in an SD card, in polling mode.

Parameters
pDataPointer to the buffer that will contain the data to transmit
WriteAddrAddress from where data is to be written
NumOfBlocksNumber of SD blocks to write
TimeoutTimeout for write operation
Return values
SDstatus

References hsd1, MSD_ERROR, and MSD_OK.

◆ BSP_SD_WriteBlocks_DMA()

uint8_t BSP_SD_WriteBlocks_DMA ( uint32_t *  pData,
uint32_t  WriteAddr,
uint32_t  NumOfBlocks 
)

Writes block(s) to a specified address in an SD card, in DMA mode.

Parameters
pDataPointer to the buffer that will contain the data to transmit
WriteAddrAddress from where data is to be written
NumOfBlocksNumber of SD blocks to write
Return values
SDstatus

References hsd1, MSD_ERROR, and MSD_OK.

◆ BSP_SD_WriteCpltCallback()

void BSP_SD_WriteCpltCallback ( void  )

BSP Tx Transfer completed callback.

Return values
None
Note
empty (up to the user to fill it in or to remove it if useless)
Here is the caller graph for this function: