STM32L4xx_HAL_Driver  1.14.0
MMC_Exported_Functions_Group1

Initialization and de-initialization functions. More...

Functions

HAL_StatusTypeDef HAL_MMC_Init (MMC_HandleTypeDef *hmmc)
 Initializes the MMC according to the specified parameters in the MMC_HandleTypeDef and create the associated handle. More...
 
HAL_StatusTypeDef HAL_MMC_InitCard (MMC_HandleTypeDef *hmmc)
 Initializes the MMC Card. More...
 
HAL_StatusTypeDef HAL_MMC_DeInit (MMC_HandleTypeDef *hmmc)
 De-Initializes the MMC card. More...
 
void HAL_MMC_MspInit (MMC_HandleTypeDef *hmmc)
 Initializes the MMC MSP. More...
 
void HAL_MMC_MspDeInit (MMC_HandleTypeDef *hmmc)
 De-Initialize MMC MSP. More...
 

Detailed Description

Initialization and de-initialization functions.

  ==============================================================================
          ##### Initialization and de-initialization functions #####
  ==============================================================================
  [..]
    This section provides functions allowing to initialize/de-initialize the MMC
    card device to be ready for use.

Function Documentation

◆ HAL_MMC_DeInit()

HAL_StatusTypeDef HAL_MMC_DeInit ( MMC_HandleTypeDef hmmc)

De-Initializes the MMC card.

Parameters
hmmcPointer to MMC handle
Return values
HALstatus

Definition at line 479 of file stm32l4xx_hal_mmc.c.

480 {
481  /* Check the MMC handle allocation */
482  if(hmmc == NULL)
483  {
484  return HAL_ERROR;
485  }
486 
487  /* Check the parameters */
488  assert_param(IS_SDMMC_ALL_INSTANCE(hmmc->Instance));
489 
490  hmmc->State = HAL_MMC_STATE_BUSY;
491 
492  /* Set MMC power state to off */
493  MMC_PowerOFF(hmmc);
494 
495 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
496  if(hmmc->MspDeInitCallback == NULL)
497  {
498  hmmc->MspDeInitCallback = HAL_MMC_MspDeInit;
499  }
500 
501  /* DeInit the low level hardware */
502  hmmc->MspDeInitCallback(hmmc);
503 #else
504  /* De-Initialize the MSP layer */
505  HAL_MMC_MspDeInit(hmmc);
506 #endif
507 
508  hmmc->ErrorCode = HAL_MMC_ERROR_NONE;
509  hmmc->State = HAL_MMC_STATE_RESET;
510 
511  return HAL_OK;
512 }
return HAL_OK
void HAL_MMC_MspDeInit(MMC_HandleTypeDef *hmmc)
De-Initialize MMC MSP.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
static void MMC_PowerOFF(MMC_HandleTypeDef *hmmc)
Turns the SDMMC output signals off.

◆ HAL_MMC_Init()

HAL_StatusTypeDef HAL_MMC_Init ( MMC_HandleTypeDef hmmc)

Initializes the MMC according to the specified parameters in the MMC_HandleTypeDef and create the associated handle.

Parameters
hmmcPointer to the MMC handle
Return values
HALstatus

Definition at line 337 of file stm32l4xx_hal_mmc.c.

338 {
339  /* Check the MMC handle allocation */
340  if(hmmc == NULL)
341  {
342  return HAL_ERROR;
343  }
344 
345  /* Check the parameters */
346  assert_param(IS_SDMMC_ALL_INSTANCE(hmmc->Instance));
347  assert_param(IS_SDMMC_CLOCK_EDGE(hmmc->Init.ClockEdge));
348 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
349  assert_param(IS_SDMMC_CLOCK_BYPASS(hmmc->Init.ClockBypass));
350 #endif
351  assert_param(IS_SDMMC_CLOCK_POWER_SAVE(hmmc->Init.ClockPowerSave));
352  assert_param(IS_SDMMC_BUS_WIDE(hmmc->Init.BusWide));
353  assert_param(IS_SDMMC_HARDWARE_FLOW_CONTROL(hmmc->Init.HardwareFlowControl));
354  assert_param(IS_SDMMC_CLKDIV(hmmc->Init.ClockDiv));
355 
356  if(hmmc->State == HAL_MMC_STATE_RESET)
357  {
358  /* Allocate lock resource and initialize it */
359  hmmc->Lock = HAL_UNLOCKED;
360 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
361  /* Reset Callback pointers in HAL_MMC_STATE_RESET only */
362  hmmc->TxCpltCallback = HAL_MMC_TxCpltCallback;
363  hmmc->RxCpltCallback = HAL_MMC_RxCpltCallback;
364  hmmc->ErrorCallback = HAL_MMC_ErrorCallback;
365  hmmc->AbortCpltCallback = HAL_MMC_AbortCallback;
366 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
367  hmmc->Read_DMADblBuf0CpltCallback = HAL_MMCEx_Read_DMADoubleBuffer0CpltCallback;
368  hmmc->Read_DMADblBuf1CpltCallback = HAL_MMCEx_Read_DMADoubleBuffer1CpltCallback;
369  hmmc->Write_DMADblBuf0CpltCallback = HAL_MMCEx_Write_DMADoubleBuffer0CpltCallback;
370  hmmc->Write_DMADblBuf1CpltCallback = HAL_MMCEx_Write_DMADoubleBuffer1CpltCallback;
371 #endif
372 
373  if(hmmc->MspInitCallback == NULL)
374  {
375  hmmc->MspInitCallback = HAL_MMC_MspInit;
376  }
377 
378  /* Init the low level hardware */
379  hmmc->MspInitCallback(hmmc);
380 #else
381  /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */
382  HAL_MMC_MspInit(hmmc);
383 #endif
384  }
385 
386  hmmc->State = HAL_MMC_STATE_BUSY;
387 
388  /* Initialize the Card parameters */
389  if(HAL_MMC_InitCard(hmmc) == HAL_ERROR)
390  {
391  return HAL_ERROR;
392  }
393 
394  /* Initialize the error code */
395  hmmc->ErrorCode = HAL_DMA_ERROR_NONE;
396 
397  /* Initialize the MMC operation */
398  hmmc->Context = MMC_CONTEXT_NONE;
399 
400  /* Initialize the MMC state */
401  hmmc->State = HAL_MMC_STATE_READY;
402 
403  return HAL_OK;
404 }
void HAL_MMC_AbortCallback(MMC_HandleTypeDef *hmmc)
MMC Abort callbacks.
void HAL_MMCEx_Read_DMADoubleBuffer0CpltCallback(MMC_HandleTypeDef *hmmc)
Read DMA Buffer 0 Transfer completed callbacks.
void HAL_MMC_MspInit(MMC_HandleTypeDef *hmmc)
Initializes the MMC MSP.
HAL_StatusTypeDef HAL_MMC_InitCard(MMC_HandleTypeDef *hmmc)
Initializes the MMC Card.
void HAL_MMC_ErrorCallback(MMC_HandleTypeDef *hmmc)
MMC error callbacks.
void HAL_MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc)
Tx Transfer completed callbacks.
void HAL_MMCEx_Write_DMADoubleBuffer0CpltCallback(MMC_HandleTypeDef *hmmc)
Write DMA Buffer 0 Transfer completed callbacks.
return HAL_OK
void HAL_MMCEx_Read_DMADoubleBuffer1CpltCallback(MMC_HandleTypeDef *hmmc)
Read DMA Buffer 1 Transfer completed callbacks.
void HAL_MMCEx_Write_DMADoubleBuffer1CpltCallback(MMC_HandleTypeDef *hmmc)
Write DMA Buffer 1 Transfer completed callbacks.
void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc)
Rx Transfer completed callbacks.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_MMC_InitCard()

HAL_StatusTypeDef HAL_MMC_InitCard ( MMC_HandleTypeDef hmmc)

Initializes the MMC Card.

Parameters
hmmcPointer to MMC handle
Note
This function initializes the MMC card. It could be used when a card re-initialization is needed.
Return values
HALstatus

Definition at line 413 of file stm32l4xx_hal_mmc.c.

414 {
415  uint32_t errorstate;
416  MMC_InitTypeDef Init;
417  HAL_StatusTypeDef status;
418 
419  /* Default SDMMC peripheral configuration for MMC card initialization */
420  Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
421 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
422  Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
423 #endif
424  Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
425  Init.BusWide = SDMMC_BUS_WIDE_1B;
426  Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
427  Init.ClockDiv = SDMMC_INIT_CLK_DIV;
428 
429  /* Initialize SDMMC peripheral interface with default configuration */
430  status = SDMMC_Init(hmmc->Instance, Init);
431  if(status == HAL_ERROR)
432  {
433  return HAL_ERROR;
434  }
435 
436 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
437  /* Disable SDMMC Clock */
438  __HAL_MMC_DISABLE(hmmc);
439 #endif
440 
441  /* Set Power State to ON */
442  status = SDMMC_PowerState_ON(hmmc->Instance);
443  if(status == HAL_ERROR)
444  {
445  return HAL_ERROR;
446  }
447 
448 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
449  /* Enable MMC Clock */
450  __HAL_MMC_ENABLE(hmmc);
451 #endif
452 
453  /* Identify card operating voltage */
454  errorstate = MMC_PowerON(hmmc);
455  if(errorstate != HAL_MMC_ERROR_NONE)
456  {
457  hmmc->State = HAL_MMC_STATE_READY;
458  hmmc->ErrorCode |= errorstate;
459  return HAL_ERROR;
460  }
461 
462  /* Card initialization */
463  errorstate = MMC_InitCard(hmmc);
464  if(errorstate != HAL_MMC_ERROR_NONE)
465  {
466  hmmc->State = HAL_MMC_STATE_READY;
467  hmmc->ErrorCode |= errorstate;
468  return HAL_ERROR;
469  }
470 
471  return HAL_OK;
472 }
static uint32_t MMC_PowerON(MMC_HandleTypeDef *hmmc)
Enquires cards about their operating voltage and configures clock controls and stores MMC information...
WWDG_InitTypeDef Init
return HAL_OK
static uint32_t MMC_InitCard(MMC_HandleTypeDef *hmmc)
Initializes the mmc card.
HAL_StatusTypeDef SDMMC_Init(SDMMC_TypeDef *SDMMCx, SDMMC_InitTypeDef Init)
Initializes the SDMMC according to the specified parameters in the SDMMC_InitTypeDef and create the a...
HAL_StatusTypeDef SDMMC_PowerState_ON(SDMMC_TypeDef *SDMMCx)
Set SDMMC Power state to ON.

◆ HAL_MMC_MspDeInit()

__weak void HAL_MMC_MspDeInit ( MMC_HandleTypeDef hmmc)

De-Initialize MMC MSP.

Parameters
hmmcPointer to MMC handle
Return values
None

Definition at line 535 of file stm32l4xx_hal_mmc.c.

536 {
537  /* Prevent unused argument(s) compilation warning */
538  UNUSED(hmmc);
539 
540  /* NOTE : This function Should not be modified, when the callback is needed,
541  the HAL_MMC_MspDeInit could be implemented in the user file
542  */
543 }

◆ HAL_MMC_MspInit()

__weak void HAL_MMC_MspInit ( MMC_HandleTypeDef hmmc)

Initializes the MMC MSP.

Parameters
hmmcPointer to MMC handle
Return values
None

Definition at line 520 of file stm32l4xx_hal_mmc.c.

521 {
522  /* Prevent unused argument(s) compilation warning */
523  UNUSED(hmmc);
524 
525  /* NOTE : This function Should not be modified, when the callback is needed,
526  the HAL_MMC_MspInit could be implemented in the user file
527  */
528 }