STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers

Typedefs

typedef HAL_SD_CardInfoTypeDef SdCardInfo
 
typedef void(* Callback) (void)
 

Functions

bool SdmmcInit (void)
 Initialize the SDMMC peripheral and the SD card. More...
 
void SdmmcDeInit (void)
 De-initialize the SDMMC peripheral.
 
bool SdmmcGetCardInfo (SdCardInfo *const cardInfo)
 Get the SD card information (capacity, block size, etc.). More...
 
bool SdmmcIsCardInTransferState (void)
 Check if the SD card is in the transfer state. More...
 
bool SdmmcReadBlocks (uint8_t *const data, const uint32_t blockAddress, const uint32_t numOfBlocks, const uint32_t timeout)
 Read blocks from the SD card in blocking mode. More...
 
bool SdmmcWriteBlocks (const uint8_t *const data, const uint32_t blockAddress, const uint32_t numOfBlocks, const uint32_t timeout)
 Write blocks to the SD card in blocking mode. More...
 
bool SdmmcReadBlocksDma (uint8_t *const data, const uint32_t blockAddress, const uint32_t numOfBlocks)
 Read blocks from the SD card using DMA. More...
 
bool SdmmcWriteBlocksDma (const uint8_t *const data, const uint32_t blockAddress, const uint32_t numOfBlocks)
 Write blocks to the SD card using DMA. More...
 
void SdmmcRegisterRxCompleteCallback (Callback callback)
 Register a callback for the DMA receive complete event. More...
 
void SdmmcRegisterTxCompleteCallback (Callback callback)
 Register a callback for the DMA transmit complete event. More...
 
static void SdmmcResetPeripheralHandleState (void)
 Reset the SD peripheral handle state and card information.
 
static bool SdmmcConfigureDmaRx (void)
 Configure the DMA channel for SD card receive transfers. More...
 
static bool SdmmcConfigureDmaTx (void)
 Configure the DMA channel for SD card transmit transfers. More...
 
void SDMMC1_IRQHandler (void)
 SDMMC1 interrupt handler.
 
void DMA2_Channel5_IRQHandler (void)
 DMA2 Channel 5 interrupt handler for SDMMC DMA transfers.
 
void HAL_SD_RxCpltCallback (SD_HandleTypeDef *hsd)
 SD card receive complete callback. More...
 
void HAL_SD_TxCpltCallback (SD_HandleTypeDef *hsd)
 SD card transmit complete callback. More...
 
void HAL_SD_AbortCallback (SD_HandleTypeDef *hsd)
 SD card abort callback. More...
 
void HAL_SD_ErrorCallback (SD_HandleTypeDef *hsd)
 SD card error callback. More...
 

Variables

static SD_HandleTypeDef sdHandle = {0}
 
static Callback rxCompleteCallback = NULL
 
static Callback txCompleteCallback = NULL
 

Detailed Description

Typedef Documentation

◆ Callback

typedef void(* Callback) (void)

Callback function pointer type definition.

Definition at line 44 of file sdmmc.h.

◆ SdCardInfo

typedef HAL_SD_CardInfoTypeDef SdCardInfo

Type definition for the HAL SD card information structure.

Definition at line 41 of file sdmmc.h.

Function Documentation

◆ HAL_SD_AbortCallback()

void HAL_SD_AbortCallback ( SD_HandleTypeDef *  hsd)

SD card abort callback.

Note
This function is declared in the MCU HAL library.
Parameters
hsdPointer to the SD handle.

Definition at line 416 of file sdmmc.c.

◆ HAL_SD_ErrorCallback()

void HAL_SD_ErrorCallback ( SD_HandleTypeDef *  hsd)

SD card error callback.

Note
This function is declared in the MCU HAL library.
Parameters
hsdPointer to the SD handle.

Definition at line 428 of file sdmmc.c.

◆ HAL_SD_RxCpltCallback()

void HAL_SD_RxCpltCallback ( SD_HandleTypeDef *  hsd)

SD card receive complete callback.

Note
This function is declared in the MCU HAL library.
Parameters
hsdPointer to the SD handle.

Definition at line 386 of file sdmmc.c.

◆ HAL_SD_TxCpltCallback()

void HAL_SD_TxCpltCallback ( SD_HandleTypeDef *  hsd)

SD card transmit complete callback.

Note
This function is declared in the MCU HAL library.
Parameters
hsdPointer to the SD handle.

Definition at line 401 of file sdmmc.c.

◆ SdmmcConfigureDmaRx()

static bool SdmmcConfigureDmaRx ( void  )
static

Configure the DMA channel for SD card receive transfers.

Returns
True if the DMA channel was configured successfully; otherwise false.

Definition at line 228 of file sdmmc.c.

◆ SdmmcConfigureDmaTx()

static bool SdmmcConfigureDmaTx ( void  )
static

Configure the DMA channel for SD card transmit transfers.

Returns
True if the DMA channel was configured successfully; otherwise false.

Definition at line 271 of file sdmmc.c.

◆ SdmmcGetCardInfo()

bool SdmmcGetCardInfo ( SdCardInfo *const  cardInfo)

Get the SD card information (capacity, block size, etc.).

Parameters
cardInfoPointer to the structure to store the card information.
Returns
True if the card information was retrieved successfully; otherwise false.

Definition at line 127 of file sdmmc.c.

◆ SdmmcInit()

bool SdmmcInit ( void  )

Initialize the SDMMC peripheral and the SD card.

Returns
True if the initialization was successful; otherwise false.

Definition at line 62 of file sdmmc.c.

◆ SdmmcIsCardInTransferState()

bool SdmmcIsCardInTransferState ( void  )

Check if the SD card is in the transfer state.

Returns
True if the card is in transfer state; otherwise false.

Definition at line 132 of file sdmmc.c.

◆ SdmmcReadBlocks()

bool SdmmcReadBlocks ( uint8_t *const  data,
const uint32_t  blockAddress,
const uint32_t  numOfBlocks,
const uint32_t  timeout 
)

Read blocks from the SD card in blocking mode.

Parameters
dataPointer to the buffer to store the read data.
blockAddressBlock address to start reading from.
numOfBlocksNumber of blocks to read.
timeoutTimeout in milliseconds.
Returns
True if the read operation was successful; otherwise false.

Definition at line 137 of file sdmmc.c.

◆ SdmmcReadBlocksDma()

bool SdmmcReadBlocksDma ( uint8_t *const  data,
const uint32_t  blockAddress,
const uint32_t  numOfBlocks 
)

Read blocks from the SD card using DMA.

Parameters
dataPointer to the buffer to store the read data.
blockAddressBlock address to start reading from.
numOfBlocksNumber of blocks to read.
Returns
True if the DMA read transfer was started successfully; otherwise false.

Definition at line 172 of file sdmmc.c.

◆ SdmmcRegisterRxCompleteCallback()

void SdmmcRegisterRxCompleteCallback ( Callback  callback)

Register a callback for the DMA receive complete event.

Parameters
callbackFunction pointer to the callback.

Definition at line 314 of file sdmmc.c.

◆ SdmmcRegisterTxCompleteCallback()

void SdmmcRegisterTxCompleteCallback ( Callback  callback)

Register a callback for the DMA transmit complete event.

Parameters
callbackFunction pointer to the callback.

Definition at line 319 of file sdmmc.c.

◆ SdmmcWriteBlocks()

bool SdmmcWriteBlocks ( const uint8_t *const  data,
const uint32_t  blockAddress,
const uint32_t  numOfBlocks,
const uint32_t  timeout 
)

Write blocks to the SD card in blocking mode.

Parameters
dataPointer to the data to be written.
blockAddressBlock address to start writing to.
numOfBlocksNumber of blocks to write.
timeoutTimeout in milliseconds.
Returns
True if the write operation was successful; otherwise false.

Definition at line 146 of file sdmmc.c.

◆ SdmmcWriteBlocksDma()

bool SdmmcWriteBlocksDma ( const uint8_t *const  data,
const uint32_t  blockAddress,
const uint32_t  numOfBlocks 
)

Write blocks to the SD card using DMA.

Parameters
dataPointer to the data to be written.
blockAddressBlock address to start writing to.
numOfBlocksNumber of blocks to write.
Returns
True if the DMA write transfer was started successfully; otherwise false.

Definition at line 191 of file sdmmc.c.

Variable Documentation

◆ rxCompleteCallback

Callback rxCompleteCallback = NULL
static

Callback for the SD DMA read transfer complete.

Definition at line 37 of file sdmmc.c.

◆ sdHandle

SD_HandleTypeDef sdHandle = {0}
static

SD card peripheral handle.

Definition at line 35 of file sdmmc.c.

◆ txCompleteCallback

Callback txCompleteCallback = NULL
static

Callback for the SD DMA write transfer complete.

Definition at line 39 of file sdmmc.c.