68 static DRESULT
SdDiskIoRead(BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
93 static DRESULT
SdDiskIoIoctl(BYTE pdrv, BYTE cmd,
void* buff);
105 static const Diskio_drvTypeDef SD_DISK_IO_DRIVER = {
110 return &SD_DISK_IO_DRIVER;
127 DSTATUS result = STA_NOINIT;
131 result &= ~STA_NOINIT;
137 static DRESULT
SdDiskIoRead(BYTE pdrv, BYTE* buff, DWORD sector, UINT count)
140 DRESULT result = RES_ERROR;
142 #if defined(USE_SDMMC_DMA)
148 uint32_t timeout = HAL_GetTick();
167 LogPrint(
"ERROR: SD card is not in transfer state.\n");
191 DRESULT result = RES_ERROR;
193 #if defined(USE_SDMMC_DMA)
199 uint32_t timeout = HAL_GetTick();
218 LogPrint(
"ERROR: SD card is not in transfer state.\n");
240 DRESULT result = RES_NOTRDY;
253 case GET_SECTOR_COUNT:
268 *(DWORD*)buff = sdCardInfo.LogBlockNbr;
274 case GET_SECTOR_SIZE:
289 *(WORD*)buff = (WORD)sdCardInfo.LogBlockSize;
310 *(DWORD*)buff = sdCardInfo.LogBlockSize;
This file contains the board-specific GPIO pin definitions, peripheral configurations,...
static volatile bool isWriteComplete
static DRESULT SdDiskIoRead(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
Read one or more sectors from the SD card.
static DRESULT SdDiskIoWrite(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
Write one or more sectors to the SD card.
static DSTATUS SdDiskIoStatus(BYTE pdrv)
Return the current status of the SD card.
static volatile bool isReadComplete
static DRESULT SdDiskIoIoctl(BYTE pdrv, BYTE cmd, void *buff)
Perform miscellaneous disk I/O control operations on the SD card.
static void SdReadCompleteCallback(void)
Callback for the SD DMA read transfer complete.
const Diskio_drvTypeDef * SdDiskIoGetDriver(void)
Get a pointer to the SD card disk I/O driver structure containing the initialize, status,...
static void SdWriteCompleteCallback(void)
Callback for the SD DMA write transfer complete.
static DSTATUS SdDiskIoInit(BYTE pdrv)
Initialize the SD card disk I/O driver and register DMA callbacks.
#define SDMMC_TRANSFER_TIMEOUT
void LogPrint(const char *format,...)
Print a formatted log message over the UART interface.
bool SdmmcGetCardInfo(SdCardInfo *const cardInfo)
Get the SD card information (capacity, block size, etc.).
void SdmmcRegisterRxCompleteCallback(Callback callback)
Register a callback for the DMA receive complete event.
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.
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.
bool SdmmcReadBlocksDma(uint8_t *const data, const uint32_t blockAddress, const uint32_t numOfBlocks)
Read blocks from the SD card using DMA.
void SdmmcRegisterTxCompleteCallback(Callback callback)
Register a callback for the DMA transmit complete event.
bool SdmmcWriteBlocksDma(const uint8_t *const data, const uint32_t blockAddress, const uint32_t numOfBlocks)
Write blocks to the SD card using DMA.
HAL_SD_CardInfoTypeDef SdCardInfo
bool SdmmcIsCardInTransferState(void)
Check if the SD card is in the transfer state.
This file contains the UART-based logging function prototypes for the debug output.
This file contains the SD card disk I/O driver interface for the FatFs middleware.
This file contains the SDMMC peripheral driver function prototypes for SD card initialization,...