return -1;
}
ret = sdmmc_write_block(µ_sd, block_num, mmc_data);
- /* FIXME : check return value */
+ /* Check return value */
+ if (ret == -EBUSY) {
+ uint8_t cnt = 10;
+ do {
+ ret = sdmmc_wait_for_ready(mmc, 0xFF);
+ while ((ret != 0xFF) && (cnt-- > 0));
+ } else if (ret == -ENODEV) {
+ /* uSD stalled ??? */
+ /* FIXME : Try reset ? */
+ got_uSD = 0;
+ }
return ret;
}
/* Let some time for uSD card to power up */
do {
i = 0;
- msleep(250);
ret = sdmmc_init(µ_sd);
if (ret == 0) {
#ifdef DEBUG
i++;
msleep(10);
ret = sdmmc_init_wait_card_ready(µ_sd);
- } while ((ret == 0 ) && (i < 10));
+ } while ((ret != 0 ) && (i < 10));
if (ret <= 1) {
#ifdef DEBUG
step = 2;
if (loop++ > 10) {
break;
}
- } while ((loop < 2) || (((ret < 0) || (ret > 1)) && (micro_sd.card_type == MMC_CARDTYPE_UNKNOWN)));
+ msleep(50);
+ } while (ret != 0);
/* Got uSD ? */
if (loop >= 10) {