mirror of https://github.com/ArduPilot/ardupilot
HAL_ChibiOS: added 3 tries to microSD MMC init
this makes init for MMC/SPI interfaces more reliable
This commit is contained in:
parent
6a27e8585a
commit
8f51bef0f0
|
@ -78,9 +78,23 @@ void sdcard_init()
|
|||
mmcconfig.hscfg = &highspeed;
|
||||
mmcconfig.lscfg = &lowspeed;
|
||||
|
||||
mmcStart(&MMCD1, &mmcconfig);
|
||||
/*
|
||||
try up to 3 times to init microSD interface
|
||||
*/
|
||||
const uint8_t tries = 3;
|
||||
bool start_ok = false;
|
||||
for (uint8_t i=0; i<tries; i++) {
|
||||
mmcStart(&MMCD1, &mmcconfig);
|
||||
|
||||
if (mmcConnect(&MMCD1) == HAL_FAILED) {
|
||||
if (mmcConnect(&MMCD1) != HAL_FAILED) {
|
||||
start_ok = true;
|
||||
break;
|
||||
}
|
||||
mmcStop(&MMCD1);
|
||||
hal.scheduler->delay(100);
|
||||
}
|
||||
|
||||
if (!start_ok) {
|
||||
printf("Err: Failed to initialize SDCARD_SPI!\n");
|
||||
sdcard_running = false;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue