初始化
D_Err SD_Init(void)
{
SD_Err Status = SD_OK;
/* Configure GPIO about SDIO interface */
GPIO_Configuration();
/* Enable the SDIO and DMA2 Clock */
RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_SDIO | RCC_AHBPERIPH_DMA2, ENABLE);
/* Deinitialize the SDIO */
SDIO_DeInit();
/* Configure the communication clock and the work voltage */
Status = SD_PWR_ON();
if (Status != SD_OK)
{
return(Status);
}
/* Init the card */
Status = SD_Init_Card();
if (Status != SD_OK)
{
return(Status);
}
/* Configure the SDIO peripheral */
/* HCLK = SDIOCLK = 72 MHz, SDIO_CLK = HCLK/(2 + 1) = 24 MHz */
SDIO_InitStructure.SDIO_ClockDiv = 0x04;
SDIO_InitStructure.SDIO_ClockEdge = SDIO_CLOCKEDGE_RISING;
SDIO_InitStructure.SDIO_ClockBypassState = SDIO_CLOCKBYPASSSTATE_DISABLE;
SDIO_InitStructure.SDIO_ClockPWRSave = SDIO_CLOCKPWRSAVE_DISABLE;
SDIO_InitStructure.SDIO_BusMode = SDIO_BUSMODE_1B;
SDIO_InitStructure.SDIO_HWFlowCtrlState = SDIO_HWFLOWCTRLSTATE_ENABLE;
SDIO_Init(&SDIO_InitStructure);
return(Status);
}
|