read SD card config exactly once (#1955)
* only read mmc device once * format Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
71638c07ae
commit
f9ae075ac6
|
@ -51,6 +51,8 @@ static int writeCounter = 0;
|
||||||
static int totalWritesCounter = 0;
|
static int totalWritesCounter = 0;
|
||||||
static int totalSyncCounter = 0;
|
static int totalSyncCounter = 0;
|
||||||
|
|
||||||
|
spi_device_e mmcSpiDevice = SPI_NONE;
|
||||||
|
|
||||||
#define LOG_INDEX_FILENAME "index.txt"
|
#define LOG_INDEX_FILENAME "index.txt"
|
||||||
|
|
||||||
#define RUSEFI_LOG_PREFIX "re_"
|
#define RUSEFI_LOG_PREFIX "re_"
|
||||||
|
@ -93,7 +95,6 @@ static SPIConfig ls_spicfg = {
|
||||||
.cr2 = 0};
|
.cr2 = 0};
|
||||||
|
|
||||||
/* MMC/SD over SPI driver configuration.*/
|
/* MMC/SD over SPI driver configuration.*/
|
||||||
// don't forget check if STM32_SPI_USE_SPI2 defined and spi has init with correct GPIO in hardware.cpp
|
|
||||||
static MMCConfig mmccfg = { NULL, &ls_spicfg, &hs_spicfg };
|
static MMCConfig mmccfg = { NULL, &ls_spicfg, &hs_spicfg };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +142,7 @@ static void sdStatistics(void) {
|
||||||
printMmcPinout();
|
printMmcPinout();
|
||||||
scheduleMsg(&logger, "SD enabled=%s status=%s", boolToString(CONFIG(isSdCardEnabled)),
|
scheduleMsg(&logger, "SD enabled=%s status=%s", boolToString(CONFIG(isSdCardEnabled)),
|
||||||
sdStatus);
|
sdStatus);
|
||||||
printSpiConfig(&logger, "SD", CONFIG(sdCardSpiDevice));
|
printSpiConfig(&logger, "SD", mmcSpiDevice);
|
||||||
if (isSdCardAlive()) {
|
if (isSdCardAlive()) {
|
||||||
scheduleMsg(&logger, "filename=%s size=%d", logName, totalLoggedBytes);
|
scheduleMsg(&logger, "filename=%s size=%d", logName, totalLoggedBytes);
|
||||||
}
|
}
|
||||||
|
@ -481,12 +482,14 @@ void initMmcCard(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, CONFIG(sdCardSpiDevice) != SPI_NONE, "SD card enabled, but no SPI device configured!");
|
mmcSpiDevice = CONFIG(sdCardSpiDevice);
|
||||||
|
|
||||||
|
efiAssertVoid(OBD_PCM_Processor_Fault, mmcSpiDevice != SPI_NONE, "SD card enabled, but no SPI device configured!");
|
||||||
|
|
||||||
// todo: reuse initSpiCs method?
|
// todo: reuse initSpiCs method?
|
||||||
hs_spicfg.ssport = ls_spicfg.ssport = getHwPort("mmc", CONFIG(sdCardCsPin));
|
hs_spicfg.ssport = ls_spicfg.ssport = getHwPort("mmc", CONFIG(sdCardCsPin));
|
||||||
hs_spicfg.sspad = ls_spicfg.sspad = getHwPin("mmc", CONFIG(sdCardCsPin));
|
hs_spicfg.sspad = ls_spicfg.sspad = getHwPin("mmc", CONFIG(sdCardCsPin));
|
||||||
mmccfg.spip = getSpiDevice(CONFIG(sdCardSpiDevice));
|
mmccfg.spip = getSpiDevice(mmcSpiDevice);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FYI: SPI does not work with CCM memory, be sure to have main() stack in RAM, not in CCMRAM
|
* FYI: SPI does not work with CCM memory, be sure to have main() stack in RAM, not in CCMRAM
|
||||||
|
@ -496,7 +499,7 @@ void initMmcCard(void) {
|
||||||
mmcObjectInit(&MMCD1); // Initializes an instance.
|
mmcObjectInit(&MMCD1); // Initializes an instance.
|
||||||
mmcStart(&MMCD1, &mmccfg);
|
mmcStart(&MMCD1, &mmccfg);
|
||||||
|
|
||||||
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), NORMALPRIO, (tfunc_t)(void*) MMCmonThread, NULL);
|
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t)(void*) MMCmonThread, NULL);
|
||||||
|
|
||||||
addConsoleAction("mountsd", MMCmount);
|
addConsoleAction("mountsd", MMCmount);
|
||||||
addConsoleAction("umountsd", mmcUnMount);
|
addConsoleAction("umountsd", mmcUnMount);
|
||||||
|
|
|
@ -22,5 +22,6 @@ void readLogFileContent(char *buffer, short fileId, short offset, short length);
|
||||||
void handleTsR(ts_channel_s *tsChannel, char *input);
|
void handleTsR(ts_channel_s *tsChannel, char *input);
|
||||||
void handleTsW(ts_channel_s *tsChannel, char *input);
|
void handleTsW(ts_channel_s *tsChannel, char *input);
|
||||||
|
|
||||||
#define LOCK_SD_SPI lockSpi(engineConfiguration->sdCardSpiDevice)
|
extern spi_device_e mmcSpiDevice;
|
||||||
#define UNLOCK_SD_SPI unlockSpi(engineConfiguration->sdCardSpiDevice)
|
#define LOCK_SD_SPI lockSpi(mmcSpiDevice)
|
||||||
|
#define UNLOCK_SD_SPI unlockSpi(mmcSpiDevice)
|
||||||
|
|
Loading…
Reference in New Issue