@@ -56,6 +56,12 @@ uint8_t BSP_SD_Init(void)
{
return MSD_ERROR;
}
+
+ // Reset defaults. High-speed mode can be incorrectly set if user removed then
+ // inserted a new SD card and we re-run initialisation.
+ hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
+ hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
SD_state = HAL_SD_Init(&hsd);
#ifdef BUS_4BITS
if (SD_state == HAL_OK)
@@ -233,7 +233,7 @@ int sdInit()
// power on
if (!firstInit)
- for (int i = 0; cs && i < 50; ++i)
+ for (int i = 0; cs && (i < 50); ++i)
cs = HAL_GPIO_ReadPin(nSD_CD_GPIO_Port, nSD_CD_Pin) ? 0 : 1;
s2s_delay_ms(5);