STM32L4xx_HAL_Driver  1.14.0
Perioheral Abort management

Functions

HAL_StatusTypeDef HAL_MMC_Abort (MMC_HandleTypeDef *hmmc)
 Abort the current transfer and disable the MMC. More...
 
HAL_StatusTypeDef HAL_MMC_Abort_IT (MMC_HandleTypeDef *hmmc)
 Abort the current transfer and disable the MMC (IT mode). More...
 

Detailed Description

Function Documentation

◆ HAL_MMC_Abort()

HAL_StatusTypeDef HAL_MMC_Abort ( MMC_HandleTypeDef hmmc)

Abort the current transfer and disable the MMC.

Parameters
hmmcpointer to a MMC_HandleTypeDef structure that contains the configuration information for MMC module.
Return values
HALstatus

Definition at line 2587 of file stm32l4xx_hal_mmc.c.

2588 {
2589  HAL_MMC_CardStateTypeDef CardState;
2590 
2591  /* DIsable All interrupts */
2592  __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_DATAEND | SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT|\
2593  SDMMC_IT_TXUNDERR| SDMMC_IT_RXOVERR);
2594 
2595  /* Clear All flags */
2596  __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS);
2597 
2598 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
2599  if((hmmc->hdmatx != NULL) || (hmmc->hdmarx != NULL))
2600  {
2601  /* Disable the MMC DMA request */
2602  hmmc->Instance->DCTRL &= (uint32_t)~((uint32_t)SDMMC_DCTRL_DMAEN);
2603 
2604  /* Abort the MMC DMA Tx Stream */
2605  if(hmmc->hdmatx != NULL)
2606  {
2607  if(HAL_DMA_Abort(hmmc->hdmatx) != HAL_OK)
2608  {
2609  hmmc->ErrorCode |= HAL_MMC_ERROR_DMA;
2610  }
2611  }
2612  /* Abort the MMC DMA Rx Stream */
2613  if(hmmc->hdmarx != NULL)
2614  {
2615  if(HAL_DMA_Abort(hmmc->hdmarx) != HAL_OK)
2616  {
2617  hmmc->ErrorCode |= HAL_MMC_ERROR_DMA;
2618  }
2619  }
2620  }
2621 #else
2622  /* If IDMA Context, disable Internal DMA */
2623  hmmc->Instance->IDMACTRL = SDMMC_DISABLE_IDMA;
2624 #endif
2625 
2626  hmmc->State = HAL_MMC_STATE_READY;
2627 
2628  /* Initialize the MMC operation */
2629  hmmc->Context = MMC_CONTEXT_NONE;
2630 
2631  CardState = HAL_MMC_GetCardState(hmmc);
2632  if((CardState == HAL_MMC_CARD_RECEIVING) || (CardState == HAL_MMC_CARD_SENDING))
2633  {
2634  hmmc->ErrorCode = SDMMC_CmdStopTransfer(hmmc->Instance);
2635  }
2636  if(hmmc->ErrorCode != HAL_MMC_ERROR_NONE)
2637  {
2638  return HAL_ERROR;
2639  }
2640  return HAL_OK;
2641 }
HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState(MMC_HandleTypeDef *hmmc)
Gets the current mmc card data state.
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
uint32_t SDMMC_CmdStopTransfer(SDMMC_TypeDef *SDMMCx)
Send the Stop Transfer command and check the response.
uint32_t HAL_MMC_CardStateTypeDef

◆ HAL_MMC_Abort_IT()

HAL_StatusTypeDef HAL_MMC_Abort_IT ( MMC_HandleTypeDef hmmc)

Abort the current transfer and disable the MMC (IT mode).

Parameters
hmmcpointer to a MMC_HandleTypeDef structure that contains the configuration information for MMC module.
Return values
HALstatus

Definition at line 2649 of file stm32l4xx_hal_mmc.c.

2650 {
2651  HAL_MMC_CardStateTypeDef CardState;
2652 
2653  /* DIsable All interrupts */
2654  __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_DATAEND | SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT|\
2655  SDMMC_IT_TXUNDERR| SDMMC_IT_RXOVERR);
2656 
2657 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
2658  /* If IDMA Context, disable Internal DMA */
2659  hmmc->Instance->IDMACTRL = SDMMC_DISABLE_IDMA;
2660 #endif
2661 
2662  /* Clear All flags */
2663  __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS);
2664 
2665 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
2666  if((hmmc->hdmatx != NULL) || (hmmc->hdmarx != NULL))
2667  {
2668  /* Disable the MMC DMA request */
2669  hmmc->Instance->DCTRL &= (uint32_t)~((uint32_t)SDMMC_DCTRL_DMAEN);
2670 
2671  /* Abort the MMC DMA Tx Stream */
2672  if(hmmc->hdmatx != NULL)
2673  {
2674  hmmc->hdmatx->XferAbortCallback = MMC_DMATxAbort;
2675  if(HAL_DMA_Abort_IT(hmmc->hdmatx) != HAL_OK)
2676  {
2677  hmmc->hdmatx = NULL;
2678  }
2679  }
2680  /* Abort the MMC DMA Rx Stream */
2681  if(hmmc->hdmarx != NULL)
2682  {
2683  hmmc->hdmarx->XferAbortCallback = MMC_DMARxAbort;
2684  if(HAL_DMA_Abort_IT(hmmc->hdmarx) != HAL_OK)
2685  {
2686  hmmc->hdmarx = NULL;
2687  }
2688  }
2689  }
2690 
2691  /* No transfer ongoing on both DMA channels*/
2692  if((hmmc->hdmatx == NULL) && (hmmc->hdmarx == NULL))
2693  {
2694 #endif
2695  CardState = HAL_MMC_GetCardState(hmmc);
2696  hmmc->State = HAL_MMC_STATE_READY;
2697 
2698  if((CardState == HAL_MMC_CARD_RECEIVING) || (CardState == HAL_MMC_CARD_SENDING))
2699  {
2700  hmmc->ErrorCode = SDMMC_CmdStopTransfer(hmmc->Instance);
2701  }
2702  if(hmmc->ErrorCode != HAL_MMC_ERROR_NONE)
2703  {
2704  return HAL_ERROR;
2705  }
2706  else
2707  {
2708 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U)
2709  hmmc->AbortCpltCallback(hmmc);
2710 #else
2711  HAL_MMC_AbortCallback(hmmc);
2712 #endif
2713 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
2714  }
2715 #endif
2716  }
2717 
2718  return HAL_OK;
2719 }
void HAL_MMC_AbortCallback(MMC_HandleTypeDef *hmmc)
MMC Abort callbacks.
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState(MMC_HandleTypeDef *hmmc)
Gets the current mmc card data state.
return HAL_OK
uint32_t SDMMC_CmdStopTransfer(SDMMC_TypeDef *SDMMCx)
Send the Stop Transfer command and check the response.
static void MMC_DMARxAbort(DMA_HandleTypeDef *hdma)
DMA MMC Rx Abort callback.
uint32_t HAL_MMC_CardStateTypeDef
static void MMC_DMATxAbort(DMA_HandleTypeDef *hdma)
DMA MMC Tx Abort callback.