|
最近调试emmc,发现stm32自带的文件stm32h7xx_hal_mmc.c,stm32f7xx_hal_mmc.c,stm32h4xx_hal_mmc.c就可以驱动。
在HAL_StatusTypeDef HAL_MMC_Init(MMC_HandleTypeDef *hmmc)函数中加入适当延时:
HAL_StatusTypeDef HAL_MMC_Init(MMC_HandleTypeDef *hmmc)
{
/* Check the MMC handle allocation */
if(hmmc == NULL)
{
return HAL_ERROR;
}
/* Check the parameters */
assert_param(IS_SDMMC_ALL_INSTANCE(hmmc->Instance));
assert_param(IS_SDMMC_CLOCK_EDGE(hmmc->Init.ClockEdge));
assert_param(IS_SDMMC_CLOCK_POWER_SAVE(hmmc->Init.ClockPowerSave));
assert_param(IS_SDMMC_BUS_WIDE(hmmc->Init.BusWide));
assert_param(IS_SDMMC_HARDWARE_FLOW_CONTROL(hmmc->Init.HardwareFlowControl));
assert_param(IS_SDMMC_CLKDIV(hmmc->Init.ClockDiv));
if(hmmc->State == HAL_MMC_STATE_RESET)
{
/* Allocate lock resource and initialize it */
hmmc->Lock = HAL_UNLOCKED;
/* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */
HAL_MMC_MspInit(hmmc);
}
hmmc->State = HAL_MMC_STATE_BUSY;
/* Initialize the Card parameters */
if(HAL_MMC_InitCard(hmmc) == HAL_ERROR)
{
return HAL_ERROR;
}
HAL_Delay(20);///////加入适当延时
/* Configure the bus wide */
if(HAL_MMC_ConfigWideBusOperation(hmmc, hmmc->Init.BusWide) == HAL_ERROR)
{
return HAL_ERROR;
}
/* Initialize the error code */
hmmc->ErrorCode = HAL_DMA_ERROR_NONE;
/* Initialize the MMC operation */
hmmc->Context = MMC_CONTEXT_NONE;
/* Initialize the MMC state */
hmmc->State = HAL_MMC_STATE_READY;
return HAL_OK;
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|