38 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 49 #ifdef HAL_SD_MODULE_ENABLED 134 if(hsd->State == HAL_SD_STATE_READY)
136 hsd->Instance->IDMABASE0= (uint32_t) pDataBuffer0;
137 hsd->Instance->IDMABASE1= (uint32_t) pDataBuffer1;
138 hsd->Instance->IDMABSIZE= (uint32_t) (BLOCKSIZE * BufferSize);
160 uint32_t DmaBase0_reg, DmaBase1_reg;
161 uint32_t add = BlockAdd;
163 if(hsd->State == HAL_SD_STATE_READY)
165 if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr))
167 hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE;
171 DmaBase0_reg = hsd->Instance->IDMABASE0;
172 DmaBase1_reg = hsd->Instance->IDMABASE1;
173 if ((hsd->Instance->IDMABSIZE == 0U) || (DmaBase0_reg == 0U) || (DmaBase1_reg == 0U))
175 hsd->ErrorCode = HAL_SD_ERROR_ADDR_OUT_OF_RANGE;
180 hsd->Instance->DCTRL = 0;
182 __HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_DATA_FLAGS);
184 hsd->ErrorCode = HAL_SD_ERROR_NONE;
185 hsd->State = HAL_SD_STATE_BUSY;
187 if(hsd->SdCard.CardType != CARD_SDHC_SDXC)
194 if(errorstate != HAL_SD_ERROR_NONE)
197 __HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_FLAGS);
198 hsd->ErrorCode |= errorstate;
199 hsd->State = HAL_SD_STATE_READY;
205 config.
DataLength = BLOCKSIZE * NumberOfBlocks;
209 config.
DPSM = SDMMC_DPSM_DISABLE;
212 hsd->Instance->DCTRL |= SDMMC_DCTRL_FIFORST;
214 __SDMMC_CMDTRANS_ENABLE( hsd->Instance);
216 hsd->Instance->IDMACTRL = SDMMC_ENABLE_IDMA_DOUBLE_BUFF0;
218 __HAL_SD_ENABLE_IT(hsd, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_RXOVERR | SDMMC_IT_DATAEND | SDMMC_IT_IDMABTC));
221 hsd->Context = (SD_CONTEXT_READ_MULTIPLE_BLOCK | SD_CONTEXT_DMA);
225 if(errorstate != HAL_SD_ERROR_NONE)
227 hsd->State = HAL_SD_STATE_READY;
228 hsd->ErrorCode |= errorstate;
253 uint32_t DmaBase0_reg, DmaBase1_reg;
254 uint32_t add = BlockAdd;
256 if(hsd->State == HAL_SD_STATE_READY)
258 if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr))
260 hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE;
264 DmaBase0_reg = hsd->Instance->IDMABASE0;
265 DmaBase1_reg = hsd->Instance->IDMABASE1;
266 if ((hsd->Instance->IDMABSIZE == 0U) || (DmaBase0_reg == 0U) || (DmaBase1_reg == 0U))
268 hsd->ErrorCode = HAL_SD_ERROR_ADDR_OUT_OF_RANGE;
273 hsd->Instance->DCTRL = 0;
275 hsd->ErrorCode = HAL_SD_ERROR_NONE;
277 hsd->State = HAL_SD_STATE_BUSY;
279 if(hsd->SdCard.CardType != CARD_SDHC_SDXC)
286 if(errorstate != HAL_SD_ERROR_NONE)
289 __HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_FLAGS);
290 hsd->ErrorCode |= errorstate;
291 hsd->State = HAL_SD_STATE_READY;
297 config.
DataLength = BLOCKSIZE * NumberOfBlocks;
301 config.
DPSM = SDMMC_DPSM_DISABLE;
304 __SDMMC_CMDTRANS_ENABLE( hsd->Instance);
306 hsd->Instance->IDMACTRL = SDMMC_ENABLE_IDMA_DOUBLE_BUFF0;
308 __HAL_SD_ENABLE_IT(hsd, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_TXUNDERR | SDMMC_IT_DATAEND | SDMMC_IT_IDMABTC));
311 hsd->Context = (SD_CONTEXT_WRITE_MULTIPLE_BLOCK | SD_CONTEXT_DMA);
315 if(errorstate != HAL_SD_ERROR_NONE)
317 hsd->State = HAL_SD_STATE_READY;
318 hsd->ErrorCode |= errorstate;
344 if(Buffer == SD_DMA_BUFFER0)
347 hsd->Instance->IDMABASE0 = (uint32_t)pDataBuffer;
352 hsd->Instance->IDMABASE1 = (uint32_t)pDataBuffer;
uint32_t SDMMC_CmdBlockLength(SDMMC_TypeDef *SDMMCx, uint32_t BlockSize)
Send the Data Block Lenght command and check the response.
uint32_t HAL_SDEx_HighSpeed(SD_HandleTypeDef *hsd)
Switches the SD card to High Speed mode. This API must be used after "Transfer State".
uint32_t SDMMC_CmdWriteMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t WriteAdd)
Send the Write Multi Block command and check the response.
This file contains all the functions prototypes for the HAL module driver.
SDMMC Data Control structure.
HAL_StatusTypeDef HAL_SDEx_WriteBlocksDMAMultiBuffer(SD_HandleTypeDef *hsd, uint32_t BlockAdd, uint32_t NumberOfBlocks)
Write block(s) to a specified address in a card. The transfered Data are stored in Buffer0 and Buffer...
struct __SD_HandleTypeDef else typedef struct endif SD_HandleTypeDef
SD handle Structure definition.
void HAL_SDEx_Write_DMADoubleBuffer0CpltCallback(SD_HandleTypeDef *hsd)
Write DMA Buffer 0 Transfer completed callbacks.
void HAL_SDEx_Read_DMADoubleBuffer0CpltCallback(SD_HandleTypeDef *hsd)
Read DMA Buffer 0 Transfer completed callbacks.
void HAL_SDEx_Write_DMADoubleBuffer1CpltCallback(SD_HandleTypeDef *hsd)
Write DMA Buffer 1 Transfer completed callbacks.
uint32_t SD_HighSpeed(SD_HandleTypeDef *hsd)
Switches the SD card to High Speed mode. This API must be used after "Transfer State".
HAL_StatusTypeDef HAL_SDEx_ChangeDMABuffer(SD_HandleTypeDef *hsd, HAL_SDEx_DMABuffer_MemoryTypeDef Buffer, uint32_t *pDataBuffer)
Change the DMA Buffer0 or Buffer1 address on the fly.
HAL_StatusTypeDef HAL_SDEx_ReadBlocksDMAMultiBuffer(SD_HandleTypeDef *hsd, uint32_t BlockAdd, uint32_t NumberOfBlocks)
Reads block(s) from a specified address in a card. The received Data will be stored in Buffer0 and Bu...
uint32_t SDMMC_CmdReadMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t ReadAdd)
Send the Read Multi Block command and check the response.
HAL_StatusTypeDef HAL_SDEx_ConfigDMAMultiBuffer(SD_HandleTypeDef *hsd, uint32_t *pDataBuffer0, uint32_t *pDataBuffer1, uint32_t BufferSize)
Configure DMA Dual Buffer mode. The Data transfer is managed by an Internal DMA.
void HAL_SDEx_Read_DMADoubleBuffer1CpltCallback(SD_HandleTypeDef *hsd)
Read DMA Buffer 1 Transfer completed callbacks.
void HAL_SDEx_DriveTransceiver_1_8V_Callback(FlagStatus status)
Enable/Disable the SD Transceiver 1.8V Mode Callback.
HAL_StatusTypeDef SDMMC_ConfigData(SDMMC_TypeDef *SDMMCx, SDMMC_DataInitTypeDef *Data)
Configure the SDMMC data path according to the specified parameters in the SDMMC_DataInitTypeDef.