STM32L4xx_HAL_Driver  1.14.0
Peripheral Control functions

management functions More...

Functions

HAL_StatusTypeDef HAL_MMC_ConfigWideBusOperation (MMC_HandleTypeDef *hmmc, uint32_t WideMode)
 Enables wide bus operation for the requested card if supported by card. More...
 
HAL_StatusTypeDef HAL_MMC_GetCardCID (MMC_HandleTypeDef *hmmc, HAL_MMC_CardCIDTypeDef *pCID)
 Returns information the information of the card which are stored on the CID register. More...
 
HAL_StatusTypeDef HAL_MMC_GetCardCSD (MMC_HandleTypeDef *hmmc, HAL_MMC_CardCSDTypeDef *pCSD)
 Returns information the information of the card which are stored on the CSD register. More...
 
HAL_StatusTypeDef HAL_MMC_GetCardInfo (MMC_HandleTypeDef *hmmc, HAL_MMC_CardInfoTypeDef *pCardInfo)
 Gets the MMC card info. More...
 
HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState (MMC_HandleTypeDef *hmmc)
 Gets the current mmc card data state. More...
 
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

management functions

  ==============================================================================
                      ##### Peripheral Control functions #####
  ==============================================================================
  [..]
    This subsection provides a set of functions allowing to control the MMC card
    operations and get the related information

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.

◆ HAL_MMC_ConfigWideBusOperation()

HAL_StatusTypeDef HAL_MMC_ConfigWideBusOperation ( MMC_HandleTypeDef hmmc,
uint32_t  WideMode 
)

Enables wide bus operation for the requested card if supported by card.

Parameters
hmmcPointer to MMC handle
WideModeSpecifies the MMC card wide bus mode This parameter can be one of the following values:
  • SDMMC_BUS_WIDE_8B: 8-bit data transfer
  • SDMMC_BUS_WIDE_4B: 4-bit data transfer
  • SDMMC_BUS_WIDE_1B: 1-bit data transfer
Return values
HALstatus

Definition at line 2429 of file stm32l4xx_hal_mmc.c.

2430 {
2431  __IO uint32_t count = 0U;
2432  SDMMC_InitTypeDef Init;
2433  uint32_t errorstate;
2434  uint32_t response = 0U, busy = 0U;
2435 
2436  /* Check the parameters */
2437  assert_param(IS_SDMMC_BUS_WIDE(WideMode));
2438 
2439  /* Chnage Satte */
2440  hmmc->State = HAL_MMC_STATE_BUSY;
2441 
2442 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
2443  /* Update Clock for Bus mode update */
2444  Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
2445  Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
2446  Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
2447  Init.BusWide = WideMode;
2448  Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
2449  Init.ClockDiv = SDMMC_INIT_CLK_DIV;
2450  /* Initialize SDMMC*/
2451  (void)SDMMC_Init(hmmc->Instance, Init);
2452 #endif
2453 
2454  if(WideMode == SDMMC_BUS_WIDE_8B)
2455  {
2456  errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70200U);
2457  if(errorstate != HAL_MMC_ERROR_NONE)
2458  {
2459  hmmc->ErrorCode |= errorstate;
2460  }
2461  }
2462  else if(WideMode == SDMMC_BUS_WIDE_4B)
2463  {
2464  errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70100U);
2465  if(errorstate != HAL_MMC_ERROR_NONE)
2466  {
2467  hmmc->ErrorCode |= errorstate;
2468  }
2469  }
2470  else if(WideMode == SDMMC_BUS_WIDE_1B)
2471  {
2472  errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70000U);
2473  if(errorstate != HAL_MMC_ERROR_NONE)
2474  {
2475  hmmc->ErrorCode |= errorstate;
2476  }
2477  }
2478  else
2479  {
2480  /* WideMode is not a valid argument*/
2481  hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM;
2482  }
2483 
2484  /* Check for switch error and violation of the trial number of sending CMD 13 */
2485  while(busy == 0U)
2486  {
2487  if(count == SDMMC_MAX_TRIAL)
2488  {
2489  hmmc->State = HAL_MMC_STATE_READY;
2490  hmmc->ErrorCode |= HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE;
2491  return HAL_ERROR;
2492  }
2493  count++;
2494 
2495  /* While card is not ready for data and trial number for sending CMD13 is not exceeded */
2496  errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U));
2497  if(errorstate != HAL_MMC_ERROR_NONE)
2498  {
2499  hmmc->ErrorCode |= errorstate;
2500  }
2501 
2502  /* Get command response */
2503  response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1);
2504 
2505  /* Get operating voltage*/
2506  busy = (((response >> 7U) == 1U) ? 0U : 1U);
2507  }
2508 
2509  /* While card is not ready for data and trial number for sending CMD13 is not exceeded */
2510  count = SDMMC_DATATIMEOUT;
2511  while((response & 0x00000100U) == 0U)
2512  {
2513  if(count == 0U)
2514  {
2515  hmmc->State = HAL_MMC_STATE_READY;
2516  hmmc->ErrorCode |= HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE;
2517  return HAL_ERROR;
2518  }
2519  count--;
2520 
2521  /* While card is not ready for data and trial number for sending CMD13 is not exceeded */
2522  errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U));
2523  if(errorstate != HAL_MMC_ERROR_NONE)
2524  {
2525  hmmc->ErrorCode |= errorstate;
2526  }
2527 
2528  /* Get command response */
2529  response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1);
2530  }
2531 
2532  if(hmmc->ErrorCode != HAL_MMC_ERROR_NONE)
2533  {
2534  /* Clear all the static flags */
2535  __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
2536  hmmc->State = HAL_MMC_STATE_READY;
2537  return HAL_ERROR;
2538  }
2539  else
2540  {
2541  /* Configure the SDMMC peripheral */
2542  Init.ClockEdge = hmmc->Init.ClockEdge;
2543 #if !defined(STM32L4R5xx) && !defined(STM32L4R7xx) && !defined(STM32L4R9xx) && !defined(STM32L4S5xx) && !defined(STM32L4S7xx) && !defined(STM32L4S9xx)
2544  Init.ClockBypass = hmmc->Init.ClockBypass;
2545 #endif
2546  Init.ClockPowerSave = hmmc->Init.ClockPowerSave;
2547  Init.BusWide = WideMode;
2548  Init.HardwareFlowControl = hmmc->Init.HardwareFlowControl;
2549  Init.ClockDiv = hmmc->Init.ClockDiv;
2550  (void)SDMMC_Init(hmmc->Instance, Init);
2551  }
2552 
2553  /* Change State */
2554  hmmc->State = HAL_MMC_STATE_READY;
2555 
2556  return HAL_OK;
2557 }
uint32_t SDMMC_CmdSendStatus(SDMMC_TypeDef *SDMMCx, uint32_t Argument)
Send the Status command and check the response.
uint32_t SDMMC_CmdSwitch(SDMMC_TypeDef *SDMMCx, uint32_t Argument)
Checks switchable function and switch card function. SDMMC_CMD_HS_SWITCH comand.
WWDG_InitTypeDef Init
return HAL_OK
uint32_t SDMMC_GetResponse(SDMMC_TypeDef *SDMMCx, uint32_t Response)
Return the response received from the card for the last command.
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...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_MMC_GetCardCID()

HAL_StatusTypeDef HAL_MMC_GetCardCID ( MMC_HandleTypeDef hmmc,
HAL_MMC_CardCIDTypeDef pCID 
)

Returns information the information of the card which are stored on the CID register.

Parameters
hmmcPointer to MMC handle
pCIDPointer to a HAL_MMC_CIDTypedef structure that contains all CID register parameters
Return values
HALstatus

Definition at line 2248 of file stm32l4xx_hal_mmc.c.

2249 {
2250  pCID->ManufacturerID = (uint8_t)((hmmc->CID[0] & 0xFF000000U) >> 24U);
2251 
2252  pCID->OEM_AppliID = (uint16_t)((hmmc->CID[0] & 0x00FFFF00U) >> 8U);
2253 
2254  pCID->ProdName1 = (((hmmc->CID[0] & 0x000000FFU) << 24U) | ((hmmc->CID[1] & 0xFFFFFF00U) >> 8U));
2255 
2256  pCID->ProdName2 = (uint8_t)(hmmc->CID[1] & 0x000000FFU);
2257 
2258  pCID->ProdRev = (uint8_t)((hmmc->CID[2] & 0xFF000000U) >> 24U);
2259 
2260  pCID->ProdSN = (((hmmc->CID[2] & 0x00FFFFFFU) << 8U) | ((hmmc->CID[3] & 0xFF000000U) >> 24U));
2261 
2262  pCID->Reserved1 = (uint8_t)((hmmc->CID[3] & 0x00F00000U) >> 20U);
2263 
2264  pCID->ManufactDate = (uint16_t)((hmmc->CID[3] & 0x000FFF00U) >> 8U);
2265 
2266  pCID->CID_CRC = (uint8_t)((hmmc->CID[3] & 0x000000FEU) >> 1U);
2267 
2268  pCID->Reserved2 = 1U;
2269 
2270  return HAL_OK;
2271 }
return HAL_OK

◆ HAL_MMC_GetCardCSD()

HAL_StatusTypeDef HAL_MMC_GetCardCSD ( MMC_HandleTypeDef hmmc,
HAL_MMC_CardCSDTypeDef pCSD 
)

Returns information the information of the card which are stored on the CSD register.

Parameters
hmmcPointer to MMC handle
pCSDPointer to a HAL_MMC_CardCSDTypeDef structure that contains all CSD register parameters
Return values
HALstatus

< Reserved

Definition at line 2281 of file stm32l4xx_hal_mmc.c.

2282 {
2283 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
2284  uint32_t block_nbr = 0;
2285 #endif
2286 
2287  pCSD->CSDStruct = (uint8_t)((hmmc->CSD[0] & 0xC0000000U) >> 30U);
2288 
2289  pCSD->SysSpecVersion = (uint8_t)((hmmc->CSD[0] & 0x3C000000U) >> 26U);
2290 
2291  pCSD->Reserved1 = (uint8_t)((hmmc->CSD[0] & 0x03000000U) >> 24U);
2292 
2293  pCSD->TAAC = (uint8_t)((hmmc->CSD[0] & 0x00FF0000U) >> 16U);
2294 
2295  pCSD->NSAC = (uint8_t)((hmmc->CSD[0] & 0x0000FF00U) >> 8U);
2296 
2297  pCSD->MaxBusClkFrec = (uint8_t)(hmmc->CSD[0] & 0x000000FFU);
2298 
2299  pCSD->CardComdClasses = (uint16_t)((hmmc->CSD[1] & 0xFFF00000U) >> 20U);
2300 
2301  pCSD->RdBlockLen = (uint8_t)((hmmc->CSD[1] & 0x000F0000U) >> 16U);
2302 
2303  pCSD->PartBlockRead = (uint8_t)((hmmc->CSD[1] & 0x00008000U) >> 15U);
2304 
2305  pCSD->WrBlockMisalign = (uint8_t)((hmmc->CSD[1] & 0x00004000U) >> 14U);
2306 
2307  pCSD->RdBlockMisalign = (uint8_t)((hmmc->CSD[1] & 0x00002000U) >> 13U);
2308 
2309  pCSD->DSRImpl = (uint8_t)((hmmc->CSD[1] & 0x00001000U) >> 12U);
2310 
2311  pCSD->Reserved2 = 0U;
2313 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
2314  if(MMC_ReadExtCSD(hmmc, &block_nbr, 0x0FFFFFFFU) != HAL_OK)
2315  {
2316  return HAL_ERROR;
2317  }
2318 
2319  if(hmmc->MmcCard.CardType == MMC_LOW_CAPACITY_CARD)
2320  {
2321 #endif
2322  pCSD->DeviceSize = (((hmmc->CSD[1] & 0x000003FFU) << 2U) | ((hmmc->CSD[2] & 0xC0000000U) >> 30U));
2323 
2324  pCSD->MaxRdCurrentVDDMin = (uint8_t)((hmmc->CSD[2] & 0x38000000U) >> 27U);
2325 
2326  pCSD->MaxRdCurrentVDDMax = (uint8_t)((hmmc->CSD[2] & 0x07000000U) >> 24U);
2327 
2328  pCSD->MaxWrCurrentVDDMin = (uint8_t)((hmmc->CSD[2] & 0x00E00000U) >> 21U);
2329 
2330  pCSD->MaxWrCurrentVDDMax = (uint8_t)((hmmc->CSD[2] & 0x001C0000U) >> 18U);
2331 
2332  pCSD->DeviceSizeMul = (uint8_t)((hmmc->CSD[2] & 0x00038000U) >> 15U);
2333 
2334  hmmc->MmcCard.BlockNbr = (pCSD->DeviceSize + 1U) ;
2335  hmmc->MmcCard.BlockNbr *= (1UL << ((pCSD->DeviceSizeMul & 0x07U) + 2U));
2336  hmmc->MmcCard.BlockSize = (1UL << (pCSD->RdBlockLen & 0x0FU));
2337 
2338  hmmc->MmcCard.LogBlockNbr = (hmmc->MmcCard.BlockNbr) * ((hmmc->MmcCard.BlockSize) / 512U);
2339  hmmc->MmcCard.LogBlockSize = 512U;
2340 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
2341  }
2342  else if(hmmc->MmcCard.CardType == MMC_HIGH_CAPACITY_CARD)
2343  {
2344  hmmc->MmcCard.BlockNbr = block_nbr;
2345  hmmc->MmcCard.LogBlockNbr = hmmc->MmcCard.BlockNbr;
2346  hmmc->MmcCard.BlockSize = 512U;
2347  hmmc->MmcCard.LogBlockSize = hmmc->MmcCard.BlockSize;
2348  }
2349  else
2350  {
2351  /* Clear all the static flags */
2352  __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
2353  hmmc->ErrorCode |= HAL_MMC_ERROR_UNSUPPORTED_FEATURE;
2354  hmmc->State = HAL_MMC_STATE_READY;
2355  return HAL_ERROR;
2356  }
2357 #endif
2358 
2359  pCSD->EraseGrSize = (uint8_t)((hmmc->CSD[2] & 0x00004000U) >> 14U);
2360 
2361  pCSD->EraseGrMul = (uint8_t)((hmmc->CSD[2] & 0x00003F80U) >> 7U);
2362 
2363  pCSD->WrProtectGrSize = (uint8_t)(hmmc->CSD[2] & 0x0000007FU);
2364 
2365  pCSD->WrProtectGrEnable = (uint8_t)((hmmc->CSD[3] & 0x80000000U) >> 31U);
2366 
2367  pCSD->ManDeflECC = (uint8_t)((hmmc->CSD[3] & 0x60000000U) >> 29U);
2368 
2369  pCSD->WrSpeedFact = (uint8_t)((hmmc->CSD[3] & 0x1C000000U) >> 26U);
2370 
2371  pCSD->MaxWrBlockLen= (uint8_t)((hmmc->CSD[3] & 0x03C00000U) >> 22U);
2372 
2373  pCSD->WriteBlockPaPartial = (uint8_t)((hmmc->CSD[3] & 0x00200000U) >> 21U);
2374 
2375  pCSD->Reserved3 = 0;
2376 
2377  pCSD->ContentProtectAppli = (uint8_t)((hmmc->CSD[3] & 0x00010000U) >> 16U);
2378 
2379  pCSD->FileFormatGroup = (uint8_t)((hmmc->CSD[3] & 0x00008000U) >> 15U);
2380 
2381  pCSD->CopyFlag = (uint8_t)((hmmc->CSD[3] & 0x00004000U) >> 14U);
2382 
2383  pCSD->PermWrProtect = (uint8_t)((hmmc->CSD[3] & 0x00002000U) >> 13U);
2384 
2385  pCSD->TempWrProtect = (uint8_t)((hmmc->CSD[3] & 0x00001000U) >> 12U);
2386 
2387  pCSD->FileFormat = (uint8_t)((hmmc->CSD[3] & 0x00000C00U) >> 10U);
2388 
2389  pCSD->ECC= (uint8_t)((hmmc->CSD[3] & 0x00000300U) >> 8U);
2390 
2391  pCSD->CSD_CRC = (uint8_t)((hmmc->CSD[3] & 0x000000FEU) >> 1U);
2392 
2393  pCSD->Reserved4 = 1;
2394 
2395  return HAL_OK;
2396 }
__IO uint8_t ContentProtectAppli
static HAL_StatusTypeDef MMC_ReadExtCSD(MMC_HandleTypeDef *hmmc, uint32_t *pBlockNbr, uint32_t Timeout)
Reads extended CSD register to get the sectors number of the device.
return HAL_OK
__IO uint8_t WriteBlockPaPartial

◆ HAL_MMC_GetCardInfo()

HAL_StatusTypeDef HAL_MMC_GetCardInfo ( MMC_HandleTypeDef hmmc,
HAL_MMC_CardInfoTypeDef pCardInfo 
)

Gets the MMC card info.

Parameters
hmmcPointer to MMC handle
pCardInfoPointer to the HAL_MMC_CardInfoTypeDef structure that will contain the MMC card status information
Return values
HALstatus

Definition at line 2405 of file stm32l4xx_hal_mmc.c.

2406 {
2407  pCardInfo->CardType = (uint32_t)(hmmc->MmcCard.CardType);
2408  pCardInfo->Class = (uint32_t)(hmmc->MmcCard.Class);
2409  pCardInfo->RelCardAdd = (uint32_t)(hmmc->MmcCard.RelCardAdd);
2410  pCardInfo->BlockNbr = (uint32_t)(hmmc->MmcCard.BlockNbr);
2411  pCardInfo->BlockSize = (uint32_t)(hmmc->MmcCard.BlockSize);
2412  pCardInfo->LogBlockNbr = (uint32_t)(hmmc->MmcCard.LogBlockNbr);
2413  pCardInfo->LogBlockSize = (uint32_t)(hmmc->MmcCard.LogBlockSize);
2414 
2415  return HAL_OK;
2416 }
return HAL_OK

◆ HAL_MMC_GetCardState()

HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState ( MMC_HandleTypeDef hmmc)

Gets the current mmc card data state.

Parameters
hmmcpointer to MMC handle
Return values
Cardstate

Definition at line 2564 of file stm32l4xx_hal_mmc.c.

2565 {
2566  uint32_t cardstate;
2567  uint32_t errorstate;
2568  uint32_t resp1 = 0U;
2569 
2570  errorstate = MMC_SendStatus(hmmc, &resp1);
2571  if(errorstate != HAL_MMC_ERROR_NONE)
2572  {
2573  hmmc->ErrorCode |= errorstate;
2574  }
2575 
2576  cardstate = ((resp1 >> 9U) & 0x0FU);
2577 
2578  return (HAL_MMC_CardStateTypeDef)cardstate;
2579 }
static uint32_t MMC_SendStatus(MMC_HandleTypeDef *hmmc, uint32_t *pCardStatus)
Returns the current card&#39;s status.
uint32_t HAL_MMC_CardStateTypeDef