cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_MMC_ReadBlocks compilation error

Kumar B
Associate II

Hi,

I am using HAL driver for STM32F4 microcontroller. Every thing is fine. But, I have the following compilation error for this macro (SDMMC_STATIC_FLAGS) from stm32f4xx_hal_mmc.c.

This macro was not found in the header file also. How to resolve this.

Kindly help.

 HAL_StatusTypeDef HAL_MMC_ReadBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout)
 
{
 
 SDIO_DataInitTypeDef config;
 
 uint32_t errorstate = HAL_MMC_ERROR_NONE;
 
 uint32_t tickstart = HAL_GetTick();
 
 uint32_t count = 0U, *tempbuff = (uint32_t *)pData;
 
 
 if(NULL == pData)
 
 {
 
   hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM;
 
   return HAL_ERROR;
 
 }
 
 
 if(hmmc->State == HAL_MMC_STATE_READY)
 
 {
 
   hmmc->ErrorCode = HAL_DMA_ERROR_NONE;
 
 
   if((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr))
 
   {
 
     hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE;
 
     return HAL_ERROR;
 
   }
 
 
   hmmc->State = HAL_MMC_STATE_BUSY;
 
 
   /* Initialize data control register */
 
   hmmc->Instance->DCTRL = 0U;
 
 
   /* Check the Card capacity in term of Logical number of blocks */
 
   if ((hmmc->MmcCard.LogBlockNbr) < CAPACITY)
 
   {
 
     BlockAdd *= 512U;
 
   }
 
 
   /* Set Block Size for Card */
 
   errorstate = SDMMC_CmdBlockLength(hmmc->Instance, BLOCKSIZE);
 
   if(errorstate != HAL_MMC_ERROR_NONE)
 
   {
 
     /* Clear all the static flags */
 
     __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);     
 
     hmmc->ErrorCode |= errorstate;
 
     hmmc->State = HAL_MMC_STATE_READY;
 
     return HAL_ERROR;
 
   }
 
 
   /* Configure the MMC DPSM (Data Path State Machine) */
 
   config.DataTimeOut  = SDMMC_DATATIMEOUT;
 
   config.DataLength   = NumberOfBlocks * BLOCKSIZE;
 
   config.DataBlockSize = SDIO_DATABLOCK_SIZE_512B;
 
   config.TransferDir  = SDIO_TRANSFER_DIR_TO_SDIO;
 
   config.TransferMode = SDIO_TRANSFER_MODE_BLOCK;
 
   config.DPSM         = SDIO_DPSM_ENABLE;
 
   SDIO_ConfigData(hmmc->Instance, &config);
 
 
   /* Read block(s) in polling mode */
 
   if(NumberOfBlocks > 1U)
 
   {
 
     hmmc->Context = MMC_CONTEXT_READ_MULTIPLE_BLOCK;
 
 
     /* Read Multi Block command */ 
 
     errorstate = SDMMC_CmdReadMultiBlock(hmmc->Instance, BlockAdd);
 
   }
 
   else
 
   {
 
     hmmc->Context = MMC_CONTEXT_READ_SINGLE_BLOCK;
 
 
     /* Read Single Block command */
 
     errorstate = SDMMC_CmdReadSingleBlock(hmmc->Instance, BlockAdd);
 
   }
 
   if(errorstate != HAL_MMC_ERROR_NONE)
 
   {
 
     /* Clear all the static flags */
 
     __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
 
     hmmc->ErrorCode |= errorstate;
 
     hmmc->State = HAL_MMC_STATE_READY;
 
     return HAL_ERROR;
 
   }
 
 
   /* Poll on SDMMC flags */
 
#ifdef SDIO_STA_STBITERR
 
   while(!__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DATAEND | SDIO_STA_STBITERR))
 
#else /* SDIO_STA_STBITERR not defined */
 
   while(!__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DATAEND))
 
#endif /* SDIO_STA_STBITERR */
 
   {
 
     if(__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_RXFIFOHF))
 
     {
 
       /* Read data from SDMMC Rx FIFO */
 
       for(count = 0U; count < 8U; count++)
 
       {
 
         *(tempbuff + count) = SDIO_ReadFIFO(hmmc->Instance);
 
       }
 
       tempbuff += 8U;
 
     }
 
 
     if((Timeout == 0U)||((HAL_GetTick()-tickstart) >= Timeout))
 
     {
 
       /* Clear all the static flags */
 
       __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
 
       hmmc->ErrorCode |= HAL_MMC_ERROR_TIMEOUT;
 
       hmmc->State= HAL_MMC_STATE_READY;
 
       return HAL_TIMEOUT;
 
     }
 
   }
 
 
   /* Send stop transmission command in case of multiblock read */
 
   if(__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_DATAEND) && (NumberOfBlocks > 1U))
 
   {   
 
     /* Send stop transmission command */
 
     errorstate = SDMMC_CmdStopTransfer(hmmc->Instance);
 
     if(errorstate != HAL_MMC_ERROR_NONE)
 
     {
 
       /* Clear all the static flags */
 
       __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
 
       hmmc->ErrorCode |= errorstate;
 
       hmmc->State = HAL_MMC_STATE_READY;
 
       return HAL_ERROR;
 
     }
 
   }
 
 
   /* Get error state */
 
   if(__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_DTIMEOUT))
 
   {
 
     /* Clear all the static flags */
 
     __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
 
     hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_TIMEOUT;
 
     hmmc->State = HAL_MMC_STATE_READY;
 
     return HAL_ERROR;
 
   }
 
   else if(__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_DCRCFAIL))
 
   {
 
     /* Clear all the static flags */
 
     __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
 
     hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_CRC_FAIL;
 
     hmmc->State = HAL_MMC_STATE_READY;
 
     return HAL_ERROR;
 
   }
 
   else if(__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_RXOVERR))
 
   {
 
     /* Clear all the static flags */
 
     __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
 
     hmmc->ErrorCode |= HAL_MMC_ERROR_RX_OVERRUN;
 
     hmmc->State = HAL_MMC_STATE_READY;
 
     return HAL_ERROR;
 
   }
 
 
   /* Empty FIFO if there is still any data */
 
   while ((__HAL_MMC_GET_FLAG(hmmc, SDIO_FLAG_RXDAVL)))
 
   {
 
     *tempbuff = SDIO_ReadFIFO(hmmc->Instance);
 
     tempbuff++;
 
 
     if((Timeout == 0U)||((HAL_GetTick()-tickstart) >= Timeout))
 
     {
 
       /* Clear all the static flags */
 
       __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);       
 
       hmmc->ErrorCode |= HAL_MMC_ERROR_TIMEOUT;
 
       hmmc->State= HAL_MMC_STATE_READY;
 
       return HAL_ERROR;
 
     }
 
   }
 
 
   /* Clear all the static flags */
 
   __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS);
 
 
   hmmc->State = HAL_MMC_STATE_READY;
 
 
   return HAL_OK;
 
 }
 
 else
 
 {
 
   hmmc->ErrorCode |= HAL_MMC_ERROR_BUSY;
 
   return HAL_ERROR;
 
 }
 
}

0690X00000BvWGdQAN.png

1 REPLY 1

Try SDIO_STATIC_FLAGS​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..