STM32L4xx_HAL_Driver  1.14.0
MultiBuffer functions

Functions

HAL_StatusTypeDef HAL_MMCEx_ConfigDMAMultiBuffer (MMC_HandleTypeDef *hmmc, uint32_t *pDataBuffer0, uint32_t *pDataBuffer1, uint32_t BufferSize)
 Configure DMA Dual Buffer mode. The Data transfer is managed by an Internal DMA. More...
 
HAL_StatusTypeDef HAL_MMCEx_ReadBlocksDMAMultiBuffer (MMC_HandleTypeDef *hmmc, 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 Buffer1. Buffer0, Buffer1 and BufferSize need to be configured by function HAL_MMCEx_ConfigDMAMultiBuffer before call this function. More...
 
HAL_StatusTypeDef HAL_MMCEx_WriteBlocksDMAMultiBuffer (MMC_HandleTypeDef *hmmc, uint32_t BlockAdd, uint32_t NumberOfBlocks)
 Write block(s) to a specified address in a card. The transfered Data are stored in Buffer0 and Buffer1. Buffer0, Buffer1 and BufferSize need to be configured by function HAL_MMCEx_ConfigDMAMultiBuffer before call this function. More...
 
HAL_StatusTypeDef HAL_MMCEx_ChangeDMABuffer (MMC_HandleTypeDef *hmmc, HAL_MMCEx_DMABuffer_MemoryTypeDef Buffer, uint32_t *pDataBuffer)
 Change the DMA Buffer0 or Buffer1 address on the fly. More...
 
void HAL_MMCEx_Read_DMADoubleBuffer0CpltCallback (MMC_HandleTypeDef *hmmc)
 Read DMA Buffer 0 Transfer completed callbacks. More...
 
void HAL_MMCEx_Read_DMADoubleBuffer1CpltCallback (MMC_HandleTypeDef *hmmc)
 Read DMA Buffer 1 Transfer completed callbacks. More...
 
void HAL_MMCEx_Write_DMADoubleBuffer0CpltCallback (MMC_HandleTypeDef *hmmc)
 Write DMA Buffer 0 Transfer completed callbacks. More...
 
void HAL_MMCEx_Write_DMADoubleBuffer1CpltCallback (MMC_HandleTypeDef *hmmc)
 Write DMA Buffer 1 Transfer completed callbacks. More...
 

Detailed Description

Function Documentation

◆ HAL_MMCEx_ChangeDMABuffer()

HAL_StatusTypeDef HAL_MMCEx_ChangeDMABuffer ( MMC_HandleTypeDef hmmc,
HAL_MMCEx_DMABuffer_MemoryTypeDef  Buffer,
uint32_t *  pDataBuffer 
)

Change the DMA Buffer0 or Buffer1 address on the fly.

Parameters
hmmcpointer to a MMC_HandleTypeDef structure.
Bufferthe buffer to be changed, This parameter can be one of the following values: MMC_DMA_BUFFER0 or MMC_DMA_BUFFER1
pDataBufferThe new address
Note
The BUFFER0 address can be changed only when the current transfer use BUFFER1 and the BUFFER1 address can be changed only when the current transfer use BUFFER0.
Return values
HALstatus

Definition at line 271 of file stm32l4xx_hal_mmc_ex.c.

272 {
273  if(Buffer == MMC_DMA_BUFFER0)
274  {
275  /* change the buffer0 address */
276  hmmc->Instance->IDMABASE0 = (uint32_t)pDataBuffer;
277  }
278  else
279  {
280  /* change the memory1 address */
281  hmmc->Instance->IDMABASE1 = (uint32_t)pDataBuffer;
282  }
283 
284  return HAL_OK;
285 }
return HAL_OK

◆ HAL_MMCEx_ConfigDMAMultiBuffer()

HAL_StatusTypeDef HAL_MMCEx_ConfigDMAMultiBuffer ( MMC_HandleTypeDef hmmc,
uint32_t *  pDataBuffer0,
uint32_t *  pDataBuffer1,
uint32_t  BufferSize 
)

Configure DMA Dual Buffer mode. The Data transfer is managed by an Internal DMA.

Parameters
hmmcMMC handle
pDataBuffer0Pointer to the buffer0 that will contain/receive the transfered data
pDataBuffer1Pointer to the buffer1 that will contain/receive the transfered data
BufferSizeSize of Buffer0 in Blocks. Buffer0 and Buffer1 must have the same size.
Return values
HALstatus

Definition at line 85 of file stm32l4xx_hal_mmc_ex.c.

86 {
87  if(hmmc->State == HAL_MMC_STATE_READY)
88  {
89  hmmc->Instance->IDMABASE0= (uint32_t) pDataBuffer0 ;
90  hmmc->Instance->IDMABASE1= (uint32_t) pDataBuffer1 ;
91  hmmc->Instance->IDMABSIZE= (uint32_t) (BLOCKSIZE * BufferSize);
92 
93  return HAL_OK;
94  }
95  else
96  {
97  return HAL_BUSY;
98  }
99 }
return HAL_OK

◆ HAL_MMCEx_Read_DMADoubleBuffer0CpltCallback()

void HAL_MMCEx_Read_DMADoubleBuffer0CpltCallback ( MMC_HandleTypeDef hmmc)

Read DMA Buffer 0 Transfer completed callbacks.

Parameters
hmmcMMC handle
Return values
None

Definition at line 292 of file stm32l4xx_hal_mmc_ex.c.

293 {
294  /* Prevent unused argument(s) compilation warning */
295  UNUSED(hmmc);
296 
297  /* NOTE : This function should not be modified, when the callback is needed,
298  the HAL_MMCEx_Read_DMADoubleBuffer0CpltCallback can be implemented in the user file
299  */
300 }

◆ HAL_MMCEx_Read_DMADoubleBuffer1CpltCallback()

void HAL_MMCEx_Read_DMADoubleBuffer1CpltCallback ( MMC_HandleTypeDef hmmc)

Read DMA Buffer 1 Transfer completed callbacks.

Parameters
hmmcMMC handle
Return values
None

Definition at line 307 of file stm32l4xx_hal_mmc_ex.c.

308 {
309  /* Prevent unused argument(s) compilation warning */
310  UNUSED(hmmc);
311 
312  /* NOTE : This function should not be modified, when the callback is needed,
313  the HAL_MMCEx_Read_DMADoubleBuffer1CpltCallback can be implemented in the user file
314  */
315 }

◆ HAL_MMCEx_ReadBlocksDMAMultiBuffer()

HAL_StatusTypeDef HAL_MMCEx_ReadBlocksDMAMultiBuffer ( MMC_HandleTypeDef hmmc,
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 Buffer1. Buffer0, Buffer1 and BufferSize need to be configured by function HAL_MMCEx_ConfigDMAMultiBuffer before call this function.

Parameters
hmmcMMC handle
BlockAddBlock Address from where data is to be read
NumberOfBlocksTotal number of blocks to read
Return values
HALstatus

Definition at line 109 of file stm32l4xx_hal_mmc_ex.c.

110 {
111  SDMMC_DataInitTypeDef config;
112  uint32_t DmaBase0_reg, DmaBase1_reg;
113  uint32_t errorstate;
114  uint32_t add = BlockAdd;
115 
116  if(hmmc->State == HAL_MMC_STATE_READY)
117  {
118  if((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr))
119  {
120  hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE;
121  return HAL_ERROR;
122  }
123 
124  DmaBase0_reg = hmmc->Instance->IDMABASE0;
125  DmaBase1_reg = hmmc->Instance->IDMABASE1;
126  if ((hmmc->Instance->IDMABSIZE == 0U) || (DmaBase0_reg == 0U) || (DmaBase1_reg == 0U))
127  {
128  hmmc->ErrorCode = HAL_MMC_ERROR_ADDR_OUT_OF_RANGE;
129  return HAL_ERROR;
130  }
131 
132  /* Initialize data control register */
133  hmmc->Instance->DCTRL = 0;
134 
135  hmmc->ErrorCode = HAL_MMC_ERROR_NONE;
136  hmmc->State = HAL_MMC_STATE_BUSY;
137 
138  if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD)
139  {
140  add *= 512U;
141  }
142 
143  /* Configure the MMC DPSM (Data Path State Machine) */
144  config.DataTimeOut = SDMMC_DATATIMEOUT;
145  config.DataLength = MMC_BLOCKSIZE * NumberOfBlocks;
146  config.DataBlockSize = SDMMC_DATABLOCK_SIZE_512B;
147  config.TransferDir = SDMMC_TRANSFER_DIR_TO_SDMMC;
148  config.TransferMode = SDMMC_TRANSFER_MODE_BLOCK;
149  config.DPSM = SDMMC_DPSM_DISABLE;
150  (void)SDMMC_ConfigData(hmmc->Instance, &config);
151 
152  hmmc->Instance->DCTRL |= SDMMC_DCTRL_FIFORST;
153 
154  __SDMMC_CMDTRANS_ENABLE( hmmc->Instance);
155 
156  hmmc->Instance->IDMACTRL = SDMMC_ENABLE_IDMA_DOUBLE_BUFF0;
157 
158  __HAL_MMC_ENABLE_IT(hmmc, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_RXOVERR | SDMMC_IT_DATAEND | SDMMC_FLAG_IDMATE | SDMMC_FLAG_IDMABTC));
159 
160  /* Read Blocks in DMA mode */
161  hmmc->Context = (MMC_CONTEXT_READ_MULTIPLE_BLOCK | MMC_CONTEXT_DMA);
162 
163  /* Read Multi Block command */
164  errorstate = SDMMC_CmdReadMultiBlock(hmmc->Instance, add);
165  if(errorstate != HAL_MMC_ERROR_NONE)
166  {
167  hmmc->State = HAL_MMC_STATE_READY;
168  hmmc->ErrorCode |= errorstate;
169  return HAL_ERROR;
170  }
171 
172  return HAL_OK;
173  }
174  else
175  {
176  return HAL_BUSY;
177  }
178 
179 }
SDMMC Data Control structure.
return HAL_OK
uint32_t SDMMC_CmdReadMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t ReadAdd)
Send the Read Multi Block command and check the response.
HAL_StatusTypeDef SDMMC_ConfigData(SDMMC_TypeDef *SDMMCx, SDMMC_DataInitTypeDef *Data)
Configure the SDMMC data path according to the specified parameters in the SDMMC_DataInitTypeDef.

◆ HAL_MMCEx_Write_DMADoubleBuffer0CpltCallback()

void HAL_MMCEx_Write_DMADoubleBuffer0CpltCallback ( MMC_HandleTypeDef hmmc)

Write DMA Buffer 0 Transfer completed callbacks.

Parameters
hmmcMMC handle
Return values
None

Definition at line 322 of file stm32l4xx_hal_mmc_ex.c.

323 {
324  /* Prevent unused argument(s) compilation warning */
325  UNUSED(hmmc);
326 
327  /* NOTE : This function should not be modified, when the callback is needed,
328  the HAL_MMCEx_Write_DMADoubleBuffer0CpltCallback can be implemented in the user file
329  */
330 }

◆ HAL_MMCEx_Write_DMADoubleBuffer1CpltCallback()

void HAL_MMCEx_Write_DMADoubleBuffer1CpltCallback ( MMC_HandleTypeDef hmmc)

Write DMA Buffer 1 Transfer completed callbacks.

Parameters
hmmcMMC handle
Return values
None

Definition at line 337 of file stm32l4xx_hal_mmc_ex.c.

338 {
339  /* Prevent unused argument(s) compilation warning */
340  UNUSED(hmmc);
341 
342  /* NOTE : This function should not be modified, when the callback is needed,
343  the HAL_MMCEx_Write_DMADoubleBuffer0CpltCallback can be implemented in the user file
344  */
345 }

◆ HAL_MMCEx_WriteBlocksDMAMultiBuffer()

HAL_StatusTypeDef HAL_MMCEx_WriteBlocksDMAMultiBuffer ( MMC_HandleTypeDef hmmc,
uint32_t  BlockAdd,
uint32_t  NumberOfBlocks 
)

Write block(s) to a specified address in a card. The transfered Data are stored in Buffer0 and Buffer1. Buffer0, Buffer1 and BufferSize need to be configured by function HAL_MMCEx_ConfigDMAMultiBuffer before call this function.

Parameters
hmmcMMC handle
BlockAddBlock Address from where data is to be read
NumberOfBlocksTotal number of blocks to read
Return values
HALstatus

Definition at line 189 of file stm32l4xx_hal_mmc_ex.c.

190 {
191  SDMMC_DataInitTypeDef config;
192  uint32_t errorstate;
193  uint32_t DmaBase0_reg, DmaBase1_reg;
194  uint32_t add = BlockAdd;
195 
196  if(hmmc->State == HAL_MMC_STATE_READY)
197  {
198  if((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr))
199  {
200  hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE;
201  return HAL_ERROR;
202  }
203 
204  DmaBase0_reg = hmmc->Instance->IDMABASE0;
205  DmaBase1_reg = hmmc->Instance->IDMABASE1;
206  if ((hmmc->Instance->IDMABSIZE == 0U) || (DmaBase0_reg == 0U) || (DmaBase1_reg == 0U))
207  {
208  hmmc->ErrorCode = HAL_MMC_ERROR_ADDR_OUT_OF_RANGE;
209  return HAL_ERROR;
210  }
211 
212  /* Initialize data control register */
213  hmmc->Instance->DCTRL = 0;
214 
215  hmmc->ErrorCode = HAL_MMC_ERROR_NONE;
216 
217  hmmc->State = HAL_MMC_STATE_BUSY;
218 
219  if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD)
220  {
221  add *= 512U;
222  }
223 
224  /* Configure the MMC DPSM (Data Path State Machine) */
225  config.DataTimeOut = SDMMC_DATATIMEOUT;
226  config.DataLength = MMC_BLOCKSIZE * NumberOfBlocks;
227  config.DataBlockSize = SDMMC_DATABLOCK_SIZE_512B;
228  config.TransferDir = SDMMC_TRANSFER_DIR_TO_CARD;
229  config.TransferMode = SDMMC_TRANSFER_MODE_BLOCK;
230  config.DPSM = SDMMC_DPSM_DISABLE;
231  (void)SDMMC_ConfigData(hmmc->Instance, &config);
232 
233  __SDMMC_CMDTRANS_ENABLE( hmmc->Instance);
234 
235  hmmc->Instance->IDMACTRL = SDMMC_ENABLE_IDMA_DOUBLE_BUFF0;
236 
237  __HAL_MMC_ENABLE_IT(hmmc, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_TXUNDERR | SDMMC_IT_DATAEND | SDMMC_FLAG_IDMATE | SDMMC_FLAG_IDMABTC));
238 
239  /* Write Blocks in DMA mode */
240  hmmc->Context = (MMC_CONTEXT_WRITE_MULTIPLE_BLOCK | MMC_CONTEXT_DMA);
241 
242  /* Write Multi Block command */
243  errorstate = SDMMC_CmdWriteMultiBlock(hmmc->Instance, add);
244  if(errorstate != HAL_MMC_ERROR_NONE)
245  {
246  hmmc->State = HAL_MMC_STATE_READY;
247  hmmc->ErrorCode |= errorstate;
248  return HAL_ERROR;
249  }
250 
251  return HAL_OK;
252  }
253  else
254  {
255  return HAL_BUSY;
256  }
257 }
uint32_t SDMMC_CmdWriteMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t WriteAdd)
Send the Write Multi Block command and check the response.
SDMMC Data Control structure.
return HAL_OK
HAL_StatusTypeDef SDMMC_ConfigData(SDMMC_TypeDef *SDMMCx, SDMMC_DataInitTypeDef *Data)
Configure the SDMMC data path according to the specified parameters in the SDMMC_DataInitTypeDef.