我们这个就是他这种方式初始化的。
[C] 纯文本查看 复制代码 /** @defgroup STM324x9I_EVAL_SD_Private_Functions SD Private Functions
* @{
*/
/**
* @brief Initializes the SD card device.
* @retval SD status
*/
uint8_t BSP_SD_Init(void)
{
uint8_t SD_state = MSD_OK;
/* uSD device interface configuration */
uSdHandle.Instance = SDIO;
uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B;
uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV;
#if 0
/* Configure IO functionalities for SD detect pin */
BSP_IO_Init();
/* Check if the SD card is plugged in the slot */
if(BSP_SD_IsDetected() != SD_PRESENT)
{
return MSD_ERROR;
}
#endif
/* Msp SD initialization */
BSP_SD_MspInit(&uSdHandle, NULL);
if(HAL_SD_Init(&uSdHandle) != HAL_OK)
{
SD_state = MSD_ERROR;
}
/* Configure SD Bus width */
if(SD_state == MSD_OK)
{
/* Enable wide operation */
if(HAL_SD_ConfigWideBusOperation(&uSdHandle, SDIO_BUS_WIDE_4B) != HAL_OK)
{
SD_state = MSD_ERROR;
}
else
{
SD_state = MSD_OK;
}
}
return SD_state;
} |