fixing SD card under ChibiOS3
This commit is contained in:
parent
b5b7657493
commit
3d206d704c
|
@ -328,7 +328,7 @@ static void MMCumount(void) {
|
||||||
f_sync(&FDLogFile); // sync ALL
|
f_sync(&FDLogFile); // sync ALL
|
||||||
mmcDisconnect(&MMCD1); // Brings the driver in a state safe for card removal.
|
mmcDisconnect(&MMCD1); // Brings the driver in a state safe for card removal.
|
||||||
mmcStop(&MMCD1); // Disables the MMC peripheral.
|
mmcStop(&MMCD1); // Disables the MMC peripheral.
|
||||||
f_mount(NULL, 0, 0); // FATFS: Unregister work area prior to discard it
|
f_mount(NULL, 0, 0); // FATFS: Unregister work area prior to discard it
|
||||||
memset(&FDLogFile, 0, sizeof(FIL)); // clear FDLogFile
|
memset(&FDLogFile, 0, sizeof(FIL)); // clear FDLogFile
|
||||||
fs_ready = false; // status = false
|
fs_ready = false; // status = false
|
||||||
scheduleMsg(&logger, "MMC/SD card removed");
|
scheduleMsg(&logger, "MMC/SD card removed");
|
||||||
|
@ -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
|
||||||
|
mmcStart(&MMCD1, &mmccfg); // Configures and activates the MMC peripheral.
|
||||||
}
|
}
|
||||||
// start to initialize MMC/SD
|
|
||||||
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