[mw_shl_code=c,true]MSD_Status BSP_SD_Init(void)
{
cardHandle.Instance = SDIO;
cardHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
cardHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
cardHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
cardHandle.Init.BusWide = SDIO_BUS_WIDE_1B;
cardHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
cardHandle.Init.ClockDiv = 0;
HAL_StatusTypeDef sd_err = HAL_SD_Init(&cardHandle);
if (sd_err != HAL_OK)
return MSD_ERR;
sd_err = HAL_SD_ConfigWideBusOperation(&cardHandle, SDIO_BUS_WIDE_4B);
if (sd_err != HAL_OK)
return MSD_ERR;
return MSD_OK;
}
void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
{
GPIO_InitTypeDef GPIO_InitStruct;
if (hsd->Instance == SDIO)
{
__HAL_RCC_SDIO_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11
| GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
__HAL_RCC_GPIOC_CLK_ENABLE();
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_2;
__HAL_RCC_GPIOD_CLK_ENABLE();
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
}
}[/mw_shl_code]
初始化部分代码源自CubeMX,使用HAL_SD_ReadBlocks函数的时候功能正常,但是HAL_SD_WriteBlocks的时候提示出错.请问哪位也遇到过了
用的是1.17.0的HAL库(2017年10月6日发布的)
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>