fixing SD card under ChibiOS3
This commit is contained in:
parent
1f111240e4
commit
f46a354660
|
@ -344,12 +344,12 @@ static void MMCmount(void) {
|
||||||
scheduleMsg(&logger, "Error: Already mounted. \"umountsd\" first");
|
scheduleMsg(&logger, "Error: Already mounted. \"umountsd\" first");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((MMCD1.state != BLK_STOP) && (MMCD1.state != BLK_ACTIVE)) {
|
if ((MMCD1.state == BLK_STOP) || (MMCD1.state == BLK_ACTIVE)) {
|
||||||
firmwareError(CUSTOM_OBD_MMC_START1, "mmc_state1 %d", MMCD1.state);
|
// looks like we would only get here after manual unmount with mmcStop? Do we really need to ever mmcStop?
|
||||||
return;
|
// not sure if this code is needed
|
||||||
}
|
|
||||||
// start to initialize MMC/SD
|
// start to initialize MMC/SD
|
||||||
mmcStart(&MMCD1, &mmccfg); // Configures and activates the MMC peripheral.
|
mmcStart(&MMCD1, &mmccfg); // Configures and activates the MMC peripheral.
|
||||||
|
}
|
||||||
|
|
||||||
// Performs the initialization procedure on the inserted card.
|
// Performs the initialization procedure on the inserted card.
|
||||||
lockSpi(SPI_NONE);
|
lockSpi(SPI_NONE);
|
||||||
|
@ -383,7 +383,7 @@ static void MMCmount(void) {
|
||||||
unlockSpi();
|
unlockSpi();
|
||||||
// if Ok - mount FS now
|
// if Ok - mount FS now
|
||||||
memset(&MMC_FS, 0, sizeof(FATFS));
|
memset(&MMC_FS, 0, sizeof(FATFS));
|
||||||
if (f_mount(&MMC_FS, 0, 0) == FR_OK) {
|
if (f_mount(&MMC_FS, "/", 1) == FR_OK) {
|
||||||
sdStatus = SD_STATE_MOUNTED;
|
sdStatus = SD_STATE_MOUNTED;
|
||||||
incLogFileName();
|
incLogFileName();
|
||||||
createLogFile();
|
createLogFile();
|
||||||
|
@ -434,11 +434,6 @@ void initMmcCard(void) {
|
||||||
|
|
||||||
// start to initialize MMC/SD
|
// start to initialize MMC/SD
|
||||||
mmcObjectInit(&MMCD1); // Initializes an instance.
|
mmcObjectInit(&MMCD1); // Initializes an instance.
|
||||||
if ((MMCD1.state != BLK_STOP) && (MMCD1.state != BLK_ACTIVE)) {
|
|
||||||
firmwareError(CUSTOM_OBD_MMC_START2, "mmc_state2 %d", MMCD1.state);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mmcStart(&MMCD1, &mmccfg);
|
mmcStart(&MMCD1, &mmccfg);
|
||||||
|
|
||||||
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t) MMCmonThread, NULL);
|
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t) MMCmonThread, NULL);
|
||||||
|
|
Loading…
Reference in New Issue