文件系统与SDIO对接有些地方需要修改。
打开bsp_driver_sd.c文件,找到BSP_SD_IsDetected函数,由于SD卡插入检测是通过用户定义的管脚来实现检测的(本例是通过PH13来检测的),因此,这里需要匹配下,在此函数内的/* USER CODE BEGIN 1 /与/ USER CODE END 1 */之间添加用户自己的代码:
uint8_t BSP_SD_IsDetected(void)
{
__IO uint8_t status = SD_PRESENT;
/* USER CODE BEGIN 1 */
/* user code can be inserted here */
if(HAL_GPIO_ReadPin(SD_DETECT_GPIO_Port, SD_DETECT_Pin) != GPIO_PIN_RESET) //SD卡插入时为低电平
{
status =SD_NOT_PRESENT;
}
/* USER CODE END 1 */
/*##-10- Compare read data with the expected data ############*/
if((bytesread != byteswritten)) //比较
{
/* Read data is different from the expected data */
Error_Handler();
}
else
{
/* Success of the demo: no error occurrence */
HAL_GPIO_WritePin(LED1_GPIO_Port,LED1_Pin,GPIO_PIN_SET);
}
}
}
}
}