rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Enumerations | Functions | Variables
mmc_card.cpp File Reference

Detailed Description

Date
Dec 28, 2013
Author
Kot_dnz
Andrey Belomutskiy, (c) 2012-2020

default pinouts in case of SPI2 connected to MMC: PB13 - SCK, PB14 - MISO, PB15 - MOSI, PD4 - CS, 3.3v default pinouts in case of SPI3 connected to MMC: PB3 - SCK, PB4 - MISO, PB5 - MOSI, PD4 - CS, 3.3v

todo: extract some logic into a controller file

Definition in file mmc_card.cpp.

Enumerations

enum  SD_STATUS {
  SD_STATUS_INIT = 0 , SD_STATUS_MOUNTED , SD_STATUS_MOUNT_FAILED , SD_STATUS_OPEN_FAILED ,
  SD_STATUS_SEEK_FAILED , SD_STATUS_NOT_INSERTED , SD_STATUS_CONNECTING , SD_STATUS_MSD ,
  SD_STATUS_MMC_FAILED
}
 

Functions

void errorHandlerWriteReportFile (FIL *fd)
 
int errorHandlerCheckReportFiles ()
 
void errorHandlerDeleteReports ()
 
static const charsdStatusName (SD_STATUS status)
 
static void sdLoggerSetReady (bool value)
 
static bool sdLoggerIsReady ()
 
void printFatFsError (const char *str, FRESULT f_error)
 
static void printMmcPinout ()
 
static void sdStatistics ()
 
static void sdSetMode (const char *mode)
 
static void prepareLogFileName ()
 
static int sdLoggerCreateFile (FIL *fd)
 Create a new file with the specified name.
 
static void sdLoggerCloseFile (FIL *fd)
 
static void removeFile (const char *pathx)
 
static chibios_rt::BinarySemaphore usbConnectedSemaphore (true)
 
void onUsbConnectedNotifyMmcI ()
 
static bool isSdCardEnabled ()
 
static BaseBlockDevice * initializeMmcBlockDevice ()
 
static void deinitializeMmcBlockDevide ()
 
static bool useMsdMode ()
 
static bool initMmc ()
 
static void deinitMmc ()
 
static bool mountMmc ()
 
static void unmountMmc ()
 
static int mlgLogger ()
 
static int sdTriggerLogger ()
 
static int sdLogger (FIL *fd)
 
static void sdLoggerStart ()
 
static void sdLoggerStop ()
 
static bool sdFormat ()
 
static int sdModeSwitchToIdle (SD_MODE from)
 
static int sdModeSwitcher ()
 
static int sdModeExecuter ()
 
static int sdReportStorageInit ()
 
PUBLIC_API_WEAK bool boardSdCardEnable ()
 
PUBLIC_API_WEAK bool boardSdCardDisable ()
 
static THD_WORKING_AREA (mmcThreadStack, 3 *UTILITY_THREAD_STACK_SIZE)
 
static THD_FUNCTION (MMCmonThread, arg)
 
void updateSdCardLiveFlags ()
 
void initEarlyMmcCard ()
 
void initMmcCard ()
 
void sdCardRequestMode (SD_MODE mode)
 
SD_MODE sdCardGetCurrentMode ()
 
void sdCardRemoveReportFiles ()
 

Variables

static bool sdLoggerReady = false
 
static NO_CACHE SdLogBufferWriter logBuffer
 
static const charsdStatusNames []
 
static SD_STATUS sdStatus = SD_STATUS_INIT
 
static SD_MODE sdMode = SD_MODE_IDLE
 
static SD_MODE sdTargetMode = SD_MODE_ECU
 
static bool sdNeedRemoveReports = false
 
static spi_device_e mmcSpiDevice = SPI_NONE
 
static NO_CACHE uint8_t mmcbuf [MMC_BUFFER_SIZE]
 
MMCDriver MMCD1
 
static MMCConfig mmccfg
 
static NO_CACHE FATFS MMC_FS
 
static const charfatErrors []
 
union { 
 
   FIL   fd 
 
   BYTE   formatBuff [FATFS_CLUSTER_SIZE] 
 
   uint8_t   blkbuf [4 *MMCSD_BLOCK_SIZE] 
 
NO_CACHE 
 
int logFileIndex
 
static char logName [_MAX_FILLER+20]
 
static const SDCConfig sdcConfig
 
static BaseBlockDevice * cardBlockDevice = nullptr
 
static bool sdLoggerInitDone = false
 
static bool sdLoggerFailed = false
 
static bool sdLoggedSuppressed = false
 

Enumeration Type Documentation

◆ SD_STATUS

enum SD_STATUS
Enumerator
SD_STATUS_INIT 
SD_STATUS_MOUNTED 
SD_STATUS_MOUNT_FAILED 
SD_STATUS_OPEN_FAILED 
SD_STATUS_SEEK_FAILED 
SD_STATUS_NOT_INSERTED 
SD_STATUS_CONNECTING 
SD_STATUS_MSD 
SD_STATUS_MMC_FAILED 

Definition at line 161 of file mmc_card.cpp.

161 {
162 SD_STATUS_INIT = 0,
171} SD_STATUS;
SD_STATUS
Definition mmc_card.cpp:161
@ SD_STATUS_INIT
Definition mmc_card.cpp:162
@ SD_STATUS_MSD
Definition mmc_card.cpp:169
@ SD_STATUS_MOUNT_FAILED
Definition mmc_card.cpp:164
@ SD_STATUS_CONNECTING
Definition mmc_card.cpp:168
@ SD_STATUS_OPEN_FAILED
Definition mmc_card.cpp:165
@ SD_STATUS_MMC_FAILED
Definition mmc_card.cpp:170
@ SD_STATUS_NOT_INSERTED
Definition mmc_card.cpp:167
@ SD_STATUS_SEEK_FAILED
Definition mmc_card.cpp:166
@ SD_STATUS_MOUNTED
Definition mmc_card.cpp:163

Function Documentation

◆ boardSdCardDisable()

PUBLIC_API_WEAK bool boardSdCardDisable ( )

Definition at line 904 of file mmc_card.cpp.

904 {
905 return true;
906}

Referenced by THD_FUNCTION().

Here is the caller graph for this function:

◆ boardSdCardEnable()

PUBLIC_API_WEAK bool boardSdCardEnable ( )

Definition at line 899 of file mmc_card.cpp.

899 {
900 // assume powered and ready
901 return true;
902}

Referenced by THD_FUNCTION().

Here is the caller graph for this function:

◆ deinitializeMmcBlockDevide()

static void deinitializeMmcBlockDevide ( )
static

Definition at line 490 of file mmc_card.cpp.

490 {
491 blkDisconnect(&MMCD1); // Brings the driver in a state safe for card removal.
492 mmcStop(&MMCD1); // Disables the MMC peripheral.
493 UNLOCK_SD_SPI();
494}
MMCDriver MMCD1
Definition mmc_card.cpp:217

Referenced by deinitMmc().

Here is the caller graph for this function:

◆ deinitMmc()

static void deinitMmc ( )
static

Definition at line 569 of file mmc_card.cpp.

569 {
570 if (cardBlockDevice) {
572 }
573 cardBlockDevice = nullptr;
575}
TunerStudioOutputChannels outputChannels
Definition engine.h:113
static EngineAccessor engine
Definition engine.h:421
static void deinitializeMmcBlockDevide()
Definition mmc_card.cpp:490
static BaseBlockDevice * cardBlockDevice
Definition mmc_card.cpp:550

Referenced by THD_FUNCTION().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ errorHandlerCheckReportFiles()

int errorHandlerCheckReportFiles ( )
extern

Definition at line 343 of file error_handling.cpp.

343 {
348
349 return hasReportFile;
350}
static int errorHandlerIsReportExist(ErrorCookie cookie)
static bool hasReportFile

Referenced by errorHandlerDeleteReports(), and sdReportStorageInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ errorHandlerDeleteReports()

void errorHandlerDeleteReports ( )
extern

Definition at line 378 of file error_handling.cpp.

Referenced by sdModeExecuter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ errorHandlerWriteReportFile()

void errorHandlerWriteReportFile ( FIL *  fd)
extern

Definition at line 275 of file error_handling.cpp.

275 {
276#if EFI_BACKUP_SRAM
278 ErrorCookie cookie = err->Cookie;
279#else
281#endif
282
283 if (cookie != ErrorCookie::None) {
284 needErrorReportFile = true;
285 }
286
287 auto cause = getMCUResetCause();
288 // TODO: should we also report Unknown?
289 if ((cause != Reset_Cause_NRST_Pin) && (cause != Reset_Cause_BOR) &&
290 (cause != Reset_Cause_POR) && (cause != Reset_Cause_Unknown)) {
291 // not an expected cause
292 needErrorReportFile = true;
293 }
294
296 char fileName[_MAX_FILLER + 20];
297 memset(fd, 0, sizeof(FIL)); // clear the memory
298 //TODO: use date + time for file name?
299#if EFI_BACKUP_SRAM
300 sprintf(fileName, "%05ld_%s_%s.txt",
301 bootCount, FAIL_REPORT_PREFIX, errorHandlerGetErrorName(cookie));
302#else
303 sprintf(fileName, "last_%s_%s.txt",
304 FAIL_REPORT_PREFIX, errorHandlerGetErrorName(cookie));
305#endif
306
307 FRESULT ret = f_open(fd, fileName, FA_CREATE_ALWAYS | FA_WRITE);
308 if (ret == FR_OK) {
309 //this is file print
310 #define PRINT(format, ...) f_printf(fd, format "\r\n", __VA_ARGS__)
311 printResetReason();
312 printWdResetCounter();
313#if EFI_BACKUP_SRAM
314 printErrorState();
315 printErrorStack();
316#endif // EFI_BACKUP_SRAM
317 f_printf(fd, "rusEFI v%d@%u", getRusEfiVersion(), /*do we have a working way to print 64 bit values?!*/(int)SIGNATURE_HASH);
318 // additional board-specific data
320 // todo: figure out what else would be useful
321 f_close(fd);
323 }
324 }
325}
Reset_Cause_t getMCUResetCause()
OutputPin warningLedPin
Definition efi_gpio.h:107
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
EnginePins enginePins
Definition efi_gpio.cpp:24
bool needErrorReportFile
static uint32_t bootCount
static const char * errorHandlerGetErrorName(ErrorCookie cookie)
static backupErrorState lastBootError
PUBLIC_API_WEAK void onBoardWriteErrorFile(FIL *)
ErrorCookie
int getRusEfiVersion()
@ Reset_Cause_NRST_Pin
Definition mpu_util.h:111
@ Reset_Cause_Unknown
Definition mpu_util.h:107
@ Reset_Cause_POR
Definition mpu_util.h:112
@ Reset_Cause_BOR
Definition mpu_util.h:114
static NO_CACHE FIL fd

Referenced by sdReportStorageInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initEarlyMmcCard()

void initEarlyMmcCard ( )

Definition at line 1033 of file mmc_card.cpp.

1033 {
1034#if EFI_PROD_CODE
1035 logName[0] = 0;
1036
1037 addConsoleAction("sdinfo", sdStatistics);
1038 addConsoleAction("sdsuppresslogging", [](){
1039 sdLoggedSuppressed = true;
1040 efiPrintf("Suppressed!");
1041 });
1043 // sdmode pc
1044 // sdmode ecu
1045 addConsoleActionS("sdmode", sdSetMode);
1047 //incLogFileName() use same shared FDLogFile, calling it while FDLogFile is used by log writer will cause damage
1048 //addConsoleAction("incfilename", incLogFileName);
1049#endif // EFI_PROD_CODE
1050}
void addConsoleActionS(const char *token, VoidCharPtr callback)
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
static void sdStatistics()
Definition mmc_card.cpp:311
static bool sdLoggedSuppressed
Definition mmc_card.cpp:665
void sdCardRemoveReportFiles()
static void sdSetMode(const char *mode)
Definition mmc_card.cpp:334
static char logName[_MAX_FILLER+20]
Definition mmc_card.cpp:297
static void removeFile(const char *pathx)
Definition mmc_card.cpp:424

Referenced by initHardwareNoConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initializeMmcBlockDevice()

static BaseBlockDevice * initializeMmcBlockDevice ( )
static

Definition at line 455 of file mmc_card.cpp.

455 {
456 // Configures and activates the MMC peripheral.
458
459 // todo: reuse initSpiCs method?
463
464 // Invalid SPI device, abort.
465 if (!mmccfg.spip) {
466 return nullptr;
467 }
468
469 // max SPI rate is 25 MHz after init
470 spiCalcClockDiv(mmccfg.spip, &mmc_hs_spicfg, 25 * 1000 * 1000);
471 // and 250 KHz during initialization
472 spiCalcClockDiv(mmccfg.spip, &mmc_ls_spicfg, 250 * 1000);
473
474 // We think we have everything for the card, let's try to mount it!
475 mmcObjectInit(&MMCD1, mmcbuf);
476 mmcStart(&MMCD1, &mmccfg);
477
478 // Performs the initialization procedure on the inserted card.
479 LOCK_SD_SPI();
480 if (blkConnect(&MMCD1) != HAL_SUCCESS) {
482 UNLOCK_SD_SPI();
483 return nullptr;
484 }
485 // We intentionally never unlock in case of success, we take exclusive access of that spi device for SD use
486
487 return reinterpret_cast<BaseBlockDevice*>(&MMCD1);
488}
int spiCalcClockDiv(SPIDriver *, SPIConfig *, unsigned int)
Definition at32_spi.cpp:260
SPIConfig mmc_hs_spicfg
Definition at32_spi.cpp:273
SPIConfig mmc_ls_spicfg
Definition at32_spi.cpp:288
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
static constexpr engine_configuration_s * engineConfiguration
SPIDriver * getSpiDevice(spi_device_e spiDevice)
Definition hardware.cpp:152
static spi_device_e mmcSpiDevice
Definition mmc_card.cpp:211
static NO_CACHE uint8_t mmcbuf[MMC_BUFFER_SIZE]
Definition mmc_card.cpp:216
static SD_STATUS sdStatus
Definition mmc_card.cpp:192
static MMCConfig mmccfg
Definition mmc_card.cpp:220

Referenced by initMmc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initMmc()

bool initMmc ( )
static

Definition at line 553 of file mmc_card.cpp.

553 {
554 // Don't try to mount SD card in case of fatal error - hardware may be in an unexpected state
555 if (hasFirmwareError()) {
556 return false;
557 }
558
560
561#if EFI_TUNER_STUDIO
562 // If not null, card is present
564#endif
565
566 return (cardBlockDevice != nullptr);
567}
static BaseBlockDevice * initializeMmcBlockDevice()
Definition mmc_card.cpp:455

Referenced by THD_FUNCTION().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initMmcCard()

void initMmcCard ( )

Definition at line 1052 of file mmc_card.cpp.

1052 {
1053#if EFI_PROD_CODE
1054 if (!isSdCardEnabled()) {
1055 // do not even bother starting the thread if SD card is not enabled & configured on start-up
1056 return;
1057 }
1058 chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), PRIO_MMC, (tfunc_t)(void*) MMCmonThread, NULL);
1059#endif // EFI_PROD_CODE
1060}
static bool isSdCardEnabled()
Definition mmc_card.cpp:445

Referenced by commonEarlyInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSdCardEnabled()

static bool isSdCardEnabled ( )
static

Definition at line 445 of file mmc_card.cpp.

Referenced by initMmcCard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mlgLogger()

static int mlgLogger ( )
static

Definition at line 966 of file mmc_card.cpp.

966 {
967 // TODO: move this check somewhere out of here!
968 // if the SPI device got un-picked somehow, cancel SD card
969 // Don't do this check at all if using SDMMC interface instead of SPI
970#if EFI_PROD_CODE && !defined(EFI_SDC_DEVICE)
971 if (engineConfiguration->sdCardSpiDevice == SPI_NONE) {
972 return 0;
973 }
974#endif
975
976 systime_t before = chVTGetSystemTime();
977
978 size_t writen = MLG::writeSdLogLine(logBuffer);
979
980 // Something went wrong (already handled), so cancel further writes
981 if (logBuffer.failed) {
982 return -1;
983 }
984
986 if (freq > 250) {
987 freq = 250;
988 } else if (freq < 1) {
989 freq = 1;
990 }
991
992 systime_t period = CH_CFG_ST_FREQUENCY / freq;
993 chThdSleepUntilWindowed(before, before + period);
994
995 return writen;
996}
beuint32_t period
static NO_CACHE SdLogBufferWriter logBuffer
Definition mmc_card.cpp:149
size_t writeSdLogLine(Writer &bufferedWriter)

Referenced by sdLogger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mountMmc()

bool mountMmc ( )
static

Definition at line 579 of file mmc_card.cpp.

579 {
580 FRESULT ret = FR_NOT_READY;
581
582 // if no card, don't try to mount FS
583 if (cardBlockDevice != nullptr) {
584 // clean shared buffer
585 memset(&resources, 0x00, sizeof(resources));
586 // We were able to connect the SD card, mount the filesystem
587 memset(&MMC_FS, 0, sizeof(FATFS));
588 ret = f_mount(&MMC_FS, "", /* Mount immediately */ 1);
589
590 if (ret != FR_OK) {
592 printFatFsError("Mount failed", ret);
593 } else {
595 efiPrintf("SD card mounted!");
596 }
597 }
598
599#if EFI_STORAGE_SD == TRUE
600 if (ret == FR_OK) {
601 // notificate storage subsystem
603 }
604#endif // EFI_STORAGE_SD
605
606#if EFI_TUNER_STUDIO
607 engine->outputChannels.sd_error = (uint8_t) ret;
608 engine->outputChannels.sd_logging_internal = (ret == FR_OK);
609#endif
610
611 return (ret == FR_OK);
612}
void printFatFsError(const char *str, FRESULT f_error)
Definition mmc_card.cpp:274
static NO_CACHE FATFS MMC_FS
Definition mmc_card.cpp:239
bool initStorageSD()

Referenced by sdModeSwitcher(), and THD_FUNCTION().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onUsbConnectedNotifyMmcI()

void onUsbConnectedNotifyMmcI ( )

Definition at line 437 of file mmc_card.cpp.

437 {
438 usbConnectedSemaphore.signalI();
439}
static chibios_rt::BinarySemaphore usbConnectedSemaphore(true)

Referenced by usb_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareLogFileName()

static void prepareLogFileName ( )
static

Definition at line 344 of file mmc_card.cpp.

344 {
345 strcpy(logName, RUSEFI_LOG_PREFIX);
346 char *ptr;
347
348 // TS SD protocol supports only short 8 symbol file names, good thing that we do not use TS SD protocol!
349 bool result = dateToStringShort(&logName[PREFIX_LEN]);
350
351 if (result) {
352 ptr = &logName[PREFIX_LEN + SHORT_TIME_LEN];
353 } else {
354 ptr = itoa10(&logName[PREFIX_LEN], logFileIndex);
355 }
356
358 strcat(ptr, ".teeth");
359 } else {
360 strcat(ptr, DOT_MLG);
361 }
362}
char * itoa10(char *p, int num)
Definition efilib.cpp:107
int logFileIndex
bool dateToStringShort(char *destination)

Referenced by sdLoggerCreateFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printFatFsError()

void printFatFsError ( const char str,
FRESULT  f_error 
)

Definition at line 274 of file mmc_card.cpp.

274 {
275 static int fatFsErrors = 0;
276
277 if (fatFsErrors++ > 16) {
278 // no reason to spam the console
279 return;
280 }
281
282 efiPrintf("%s FATfs Error %d %s", str, f_error, f_error <= FR_INVALID_PARAMETER ? fatErrors[f_error] : "unknown");
283}
static const char * fatErrors[]
Definition mmc_card.cpp:250

Referenced by incLogFileName(), mountMmc(), sdFormat(), sdLoggerCreateFile(), and unmountMmc().

Here is the caller graph for this function:

◆ printMmcPinout()

static void printMmcPinout ( )
static

Definition at line 299 of file mmc_card.cpp.

299 {
300#if HAL_USE_MMC_SPI
301 efiPrintf("MMC CS %s", hwPortname(engineConfiguration->sdCardCsPin));
302 // todo: we need to figure out the right SPI pinout, not just SPI2
303// efiPrintf("MMC SCK %s:%d", portname(EFI_SPI2_SCK_PORT), EFI_SPI2_SCK_PIN);
304// efiPrintf("MMC MISO %s:%d", portname(EFI_SPI2_MISO_PORT), EFI_SPI2_MISO_PIN);
305// efiPrintf("MMC MOSI %s:%d", portname(EFI_SPI2_MOSI_PORT), EFI_SPI2_MOSI_PIN);
306#else
307 // not sure if we need to print SDIO pinout
308#endif
309}
const char * hwPortname(brain_pin_e brainPin)

Referenced by sdStatistics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeFile()

static void removeFile ( const char pathx)
static

Definition at line 424 of file mmc_card.cpp.

424 {
425 if (sdMode != SD_MODE_ECU) {
426 efiPrintf("SD card should be mounted to ECU");
427 return;
428 }
429
430 f_unlink(pathx);
431}
static SD_MODE sdMode
Definition mmc_card.cpp:194
@ SD_MODE_ECU
Definition mmc_card.h:19

Referenced by initEarlyMmcCard().

Here is the caller graph for this function:

◆ sdCardGetCurrentMode()

SD_MODE sdCardGetCurrentMode ( )

Definition at line 1073 of file mmc_card.cpp.

1074{
1075 return sdMode;
1076}

Referenced by hellenDisableEn().

Here is the caller graph for this function:

◆ sdCardRemoveReportFiles()

void sdCardRemoveReportFiles ( )

Definition at line 1078 of file mmc_card.cpp.

1078 {
1079 if (sdMode != SD_MODE_ECU) {
1080 efiPrintf("SD card should be mounted to ECU");
1081 return;
1082 }
1083
1084 sdNeedRemoveReports = true;
1085}
static bool sdNeedRemoveReports
Definition mmc_card.cpp:198

Referenced by handleCommandX14(), and initEarlyMmcCard().

Here is the caller graph for this function:

◆ sdCardRequestMode()

void sdCardRequestMode ( SD_MODE  mode)

Definition at line 1064 of file mmc_card.cpp.

1065{
1066 // Check if SD is not in transition state...
1067 if (sdTargetMode == SD_MODE_IDLE) {
1068 efiPrintf("sdCardRequestMode %d", (int)mode);
1069 sdTargetMode = mode;
1070 }
1071}
static SD_MODE sdTargetMode
Definition mmc_card.cpp:196
@ SD_MODE_IDLE
Definition mmc_card.h:18

Referenced by handleCommandX14(), hellenDisableEn(), and sdSetMode().

Here is the caller graph for this function:

◆ sdFormat()

static bool sdFormat ( )
static

Definition at line 750 of file mmc_card.cpp.

751{
752#if EFI_TUNER_STUDIO
755#endif
756 //FRESULT ret = f_mkfs("", nullptr, resources.formatBuff, sizeof(resources.formatBuff));
757 FRESULT ret = f_mkfs("", nullptr, resources.formatBuff, sizeof(resources.formatBuff));
758
759 if (ret) {
760 printFatFsError("format failed", ret);
761 warning(ObdCode::CUSTOM_ERR_SD_MOUNT_FAILED, "SD: format failed");
762 goto exit;
763 }
764 ret = f_setlabel(SD_CARD_LABEL);
765 if (ret) {
766 printFatFsError("setlabel failed", ret);
767 // this is not critical
768 ret = FR_OK;
769 }
770
771exit:
772#if EFI_TUNER_STUDIO
774 engine->outputChannels.sd_error = (uint8_t) ret;
775#endif
776
777 return (ret ? false : true);
778}
bool warning(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_SD_MOUNT_FAILED

Referenced by sdModeSwitcher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdLogger()

static int sdLogger ( FIL *  fd)
static

Definition at line 668 of file mmc_card.cpp.

668 {
669 if (sdLoggedSuppressed) {
670 return 0;
671 }
672 int ret = 0;
673
674 if (!sdLoggerInitDone) {
677
678 ret = sdLoggerCreateFile(fd);
679 if (ret == 0) {
680 ret = logBuffer.start(fd);
681 }
682
683 sdLoggerInitDone = true;
684
685 if (ret < 0) {
686 sdLoggerFailed = true;
687 return ret;
688 }
689 }
690
691 if (!sdLoggerFailed) {
693 ret = sdTriggerLogger();
694 } else {
695 ret = mlgLogger();
696 }
697 }
698
699 if (ret < 0) {
700 sdLoggerFailed = true;
701 return ret;
702 }
703
704 if (sdLoggerFailed) {
705 // logger is dead until restart, do not waste CPU
706 chThdSleepMilliseconds(100);
707 return -1;
708 }
709
710#ifdef LOGGER_MAX_FILE_SIZE
711 // check if we need to start next log file
712 // in next write (assume same size as current) will cross LOGGER_MAX_FILE_SIZE boundary
713 // TODO: use f_tell() instead ?
714 if (logBuffer.writen() + ret > LOGGER_MAX_FILE_SIZE) {
715 logBuffer.stop();
717
718 //need to start new file
719 sdLoggerInitDone = false;
720 }
721#endif
722
723 return ret;
724}
static bool sdLoggerFailed
Definition mmc_card.cpp:663
static int sdTriggerLogger()
Definition mmc_card.cpp:998
static void sdLoggerCloseFile(FIL *fd)
Definition mmc_card.cpp:410
static bool sdLoggerInitDone
Definition mmc_card.cpp:662
FIL fd
Definition mmc_card.cpp:288
static int sdLoggerCreateFile(FIL *fd)
Create a new file with the specified name.
Definition mmc_card.cpp:370
static int mlgLogger()
Definition mmc_card.cpp:966
void incLogFileName(FIL *fd)
void resetFileLogging()

Referenced by sdModeExecuter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdLoggerCloseFile()

static void sdLoggerCloseFile ( FIL *  fd)
static

Definition at line 410 of file mmc_card.cpp.

411{
412#ifdef LOGGER_MAX_FILE_SIZE
413 // truncate file to actual size
414 f_truncate(fd);
415#endif
416
417 // close file
418 f_close(fd);
419
420 // SD logger is inactive
421 sdLoggerSetReady(false);
422}
static void sdLoggerSetReady(bool value)
Definition mmc_card.cpp:241

Referenced by sdLogger(), and sdLoggerStop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdLoggerCreateFile()

static int sdLoggerCreateFile ( FIL *  fd)
static

Create a new file with the specified name.

This function saves the name of the file in a global variable so that we can later append to that file

Definition at line 370 of file mmc_card.cpp.

370 {
371 // turn off indicator
372 sdLoggerSetReady(false);
373
374 // clear the memory
375 memset(fd, 0, sizeof(FIL));
377
378 efiPrintf("starting log file %s", logName);
379 // Create new file. If file is exist - truncate and overwrite, we need header to be at zero offset.
380 FRESULT err = f_open(fd, logName, FA_CREATE_ALWAYS | FA_WRITE);
381 if (err == FR_EXIST) {
382 err = FR_OK;
383 }
384#if EFI_TUNER_STUDIO
385 // Show error to TS
386 engine->outputChannels.sd_error = (uint8_t)err;
387#endif
388 if (err != FR_OK) {
390 warning(ObdCode::CUSTOM_ERR_SD_MOUNT_FAILED, "SD: file open failed");
391 printFatFsError("log file create", err);
392 return -1;
393 }
394
395#ifdef LOGGER_MAX_FILE_SIZE
396 //pre-allocate data ahead
397 err = f_expand(fd, LOGGER_MAX_FILE_SIZE, /* Find and allocate */ 1);
398 if (err != FR_OK) {
399 printFatFsError("pre-allocate", err);
400 // this is not critical
401 }
402#endif
403
404 // SD logger is ok
405 sdLoggerSetReady(true);
406
407 return 0;
408}
static void prepareLogFileName()
Definition mmc_card.cpp:344

Referenced by sdLogger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdLoggerIsReady()

static bool sdLoggerIsReady ( )
static

Definition at line 245 of file mmc_card.cpp.

245 {
246 return sdLoggerReady;
247}
static bool sdLoggerReady
Definition mmc_card.cpp:32

Referenced by sdStatistics().

Here is the caller graph for this function:

◆ sdLoggerSetReady()

static void sdLoggerSetReady ( bool  value)
static

Definition at line 241 of file mmc_card.cpp.

241 {
242 sdLoggerReady = value;
243}

Referenced by sdLoggerCloseFile(), and sdLoggerCreateFile().

Here is the caller graph for this function:

◆ sdLoggerStart()

static void sdLoggerStart ( )
static

Definition at line 726 of file mmc_card.cpp.

727{
728 sdLoggerInitDone = false;
729 sdLoggerFailed = false;
730
731#if EFI_TOOTH_LOGGER
732 // TODO: cache this config option untill sdLoggerStop()
735 }
736#endif
737}
void EnableToothLogger()

Referenced by sdModeSwitcher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdLoggerStop()

static void sdLoggerStop ( )
static

Definition at line 739 of file mmc_card.cpp.

740{
741 sdLoggerCloseFile(&resources.fd);
742#if EFI_TOOTH_LOGGER
743 // TODO: cache this config option untill sdLoggerStop()
746 }
747#endif
748}
void DisableToothLogger()

Referenced by sdModeSwitchToIdle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdModeExecuter()

static int sdModeExecuter ( )
static

Definition at line 866 of file mmc_card.cpp.

867{
868 switch (sdMode) {
869 case SD_MODE_IDLE:
870 case SD_MODE_PC:
871 case SD_MODE_UNMOUNT:
872 case SD_MODE_FORMAT:
873 // nothing to do in these state, just sleep
874 chThdSleepMilliseconds(100);
875 return 0;
876 case SD_MODE_ECU:
879 sdNeedRemoveReports = false;
880 }
881 // execute logger
882 return sdLogger(&resources.fd);
883 }
884
885 return 0;
886}
static int sdLogger(FIL *fd)
Definition mmc_card.cpp:668
void errorHandlerDeleteReports()
@ SD_MODE_UNMOUNT
Definition mmc_card.h:21
@ SD_MODE_PC
Definition mmc_card.h:20
@ SD_MODE_FORMAT
Definition mmc_card.h:22

Referenced by THD_FUNCTION().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdModeSwitcher()

static int sdModeSwitcher ( )
static

Definition at line 803 of file mmc_card.cpp.

804{
805 if (sdTargetMode == SD_MODE_IDLE) {
806 return 0;
807 }
808
809 if (sdMode == sdTargetMode) {
810 // already here
812 return 0;
813 }
814
815 if (sdMode != SD_MODE_IDLE) {
816 int ret = sdModeSwitchToIdle(sdMode);
817 if (ret) {
818 return ret;
819 }
821 }
822
823 if (sdMode != SD_MODE_IDLE) {
824 return -1;
825 }
826
827 // Now SD card is in idle state, we can switch into target state
828 switch (sdTargetMode) {
829 case SD_MODE_IDLE:
830 return 0;
831 case SD_MODE_UNMOUNT:
832 // everything is done in sdModeSwitchToIdle();
835 return 0;
836 case SD_MODE_ECU:
837 if (mountMmc()) {
840 } else {
841 // failed to mount SD card to ECU, go to idle
843 }
845 return 0;
846 case SD_MODE_PC:
847 attachMsdSdCard(cardBlockDevice, resources.blkbuf, sizeof(resources.blkbuf));
851 return 0;
852 case SD_MODE_FORMAT:
853 if (sdFormat()) {
854 // formated ok
855 }
857 // TODO: return to mode that was used before format was requested!
859 return 0;
860 }
861
862 // should not happen
863 return -1;
864}
void attachMsdSdCard(BaseBlockDevice *blkdev, uint8_t *blkbuf, size_t blkbufsize)
static bool sdFormat()
Definition mmc_card.cpp:750
static void sdLoggerStart()
Definition mmc_card.cpp:726
static bool mountMmc()
Definition mmc_card.cpp:579
static int sdModeSwitchToIdle(SD_MODE from)
Definition mmc_card.cpp:780

Referenced by THD_FUNCTION().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdModeSwitchToIdle()

static int sdModeSwitchToIdle ( SD_MODE  from)
static

Definition at line 780 of file mmc_card.cpp.

781{
782 switch (from) {
783 case SD_MODE_IDLE:
784 return 0;
785 case SD_MODE_ECU:
786 sdLoggerStop();
787 unmountMmc();
788 return 0;
789 case SD_MODE_PC:
791 return 0;
792 case SD_MODE_UNMOUNT:
793 return 0;
794 case SD_MODE_FORMAT:
795 //not allowed to interrupt formating process
796 return -1;
797 }
798
799 efiPrintf("Invalid SD card thread state: %d", static_cast<int>(from));
800 return -1;
801}
void deattachMsdSdCard(void)
static void unmountMmc()
Definition mmc_card.cpp:618
static void sdLoggerStop()
Definition mmc_card.cpp:739

Referenced by sdModeSwitcher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdReportStorageInit()

static int sdReportStorageInit ( )
static

Definition at line 888 of file mmc_card.cpp.

889{
890 // write error report file if needed
891 errorHandlerWriteReportFile(&resources.fd);
892
893 // check for any exist reports
895
896 return 0;
897}
int errorHandlerCheckReportFiles()
void errorHandlerWriteReportFile(FIL *fd)

Referenced by THD_FUNCTION().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdSetMode()

static void sdSetMode ( const char mode)
static

Definition at line 334 of file mmc_card.cpp.

334 {
335 if (strcmp(mode, "pc") == 0) {
337 } else if (strcmp(mode, "ecu") == 0) {
339 } else {
340 efiPrintf("Invalid mode %s allowed modes pc and ecu", mode);
341 }
342}
void sdCardRequestMode(SD_MODE mode)

Referenced by initEarlyMmcCard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdStatistics()

static void sdStatistics ( )
static

Definition at line 311 of file mmc_card.cpp.

311 {
313 efiPrintf("SD enabled=%s status=%s", boolToString(engineConfiguration->isSdCardEnabled),
315#if HAL_USE_MMC_SPI
317 #if defined(STM32F4XX) || defined(STM32F7XX)
318 efiPrintf("HS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_hs_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
319 efiPrintf("LS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_ls_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
320 #else
321 efiPrintf("not implemented");
322 #endif
323#else
324 efiPrintf("SDIO mode");
325#endif
326 if (sdLoggerIsReady()) {
327 efiPrintf("filename=%s size=%d", logName, logBuffer.writen());
328 }
329#if EFI_FILE_LOGGING
330 efiPrintf("%d SD card fields", MLG::getSdCardFieldsCount());
331#endif
332}
int spiGetBaseClock(SPIDriver *)
Definition at32_spi.cpp:254
const char * boolToString(bool value)
Definition efilib.cpp:19
void printSpiConfig(const char *msg, spi_device_e device)
Definition hardware.cpp:259
static bool sdLoggerIsReady()
Definition mmc_card.cpp:245
static const char * sdStatusName(SD_STATUS status)
Definition mmc_card.cpp:187
static void printMmcPinout()
Definition mmc_card.cpp:299
int getSdCardFieldsCount()

Referenced by initEarlyMmcCard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdStatusName()

static const char * sdStatusName ( SD_STATUS  status)
static

Definition at line 187 of file mmc_card.cpp.

188{
189 return sdStatusNames[status];
190}
static const char * sdStatusNames[]
Definition mmc_card.cpp:174

Referenced by sdStatistics().

Here is the caller graph for this function:

◆ sdTriggerLogger()

static int sdTriggerLogger ( )
static

Definition at line 998 of file mmc_card.cpp.

998 {
999 size_t toWrite = 0;
1000#if EFI_TOOTH_LOGGER
1002
1003 // can return nullptr
1004 if (buffer) {
1005 toWrite = buffer->nextIdx * sizeof(composite_logger_s);
1006 logBuffer.write(reinterpret_cast<const char*>(buffer->buffer), toWrite);
1007 if (logBuffer.failed) {
1008 return -1;
1009 }
1010
1012 }
1013#endif /* EFI_TOOTH_LOGGER */
1014 return toWrite;
1015}
void ReturnToothLoggerBuffer(CompositeBuffer *buffer)
CompositeBuffer * GetToothLoggerBufferBlocking()
composite_logger_s
static BigBufferHandle buffer

Referenced by sdLogger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ THD_FUNCTION()

static THD_FUNCTION ( MMCmonThread  ,
arg   
)
static

Definition at line 909 of file mmc_card.cpp.

909 {
910 (void)arg;
911
912 chRegSetThreadName("SD Card Logger");
913
914 while (!boardSdCardEnable()) {
915 // wait until board enables peripheral
916 chThdSleepMilliseconds(100);
917 }
918
920 if (!initMmc()) {
921 efiPrintf("Card is not preset/failed to init");
923 // give up until next boot
924 goto die;
925 }
926
927 // Try to mount SD card, drop critical report if needed and check for previously stored reports
928 if (mountMmc()) {
930
932
933#if EFI_STORAGE_SD == TRUE
934 // Give some time for storage manager to load settings from SD
935 chThdSleepMilliseconds(1000);
936#endif
937 }
938
939#if HAL_USE_USB_MSD
940 // Wait for the USB stack to wake up, or a 15 second timeout, whichever occurs first
941 // If we have a device AND USB is connected, mount the card to USB, otherwise
942 // mount the null device and try to mount the filesystem ourselves
943 if (useMsdMode()) {
945 }
946#endif
947
948 while (1) {
951 }
952
953die:
954 // bring SD interface to safe state
955 deinitMmc();
957
958 efiPrintf("SD logger has died!");
959
960 // exiting thread will create zombie!
961 while(1) {
962 chThdSleepMilliseconds(100);
963 }
964}
static bool useMsdMode()
Definition mmc_card.cpp:534
PUBLIC_API_WEAK bool boardSdCardEnable()
Definition mmc_card.cpp:899
static int sdReportStorageInit()
Definition mmc_card.cpp:888
static int sdModeExecuter()
Definition mmc_card.cpp:866
static int sdModeSwitcher()
Definition mmc_card.cpp:803
static void deinitMmc()
Definition mmc_card.cpp:569
static bool initMmc()
Definition mmc_card.cpp:553
PUBLIC_API_WEAK bool boardSdCardDisable()
Definition mmc_card.cpp:904
Here is the call graph for this function:

◆ THD_WORKING_AREA()

static THD_WORKING_AREA ( mmcThreadStack  ,
3 *  UTILITY_THREAD_STACK_SIZE 
)
static

◆ unmountMmc()

static void unmountMmc ( )
static

Definition at line 618 of file mmc_card.cpp.

618 {
619 FRESULT ret;
620
621#if EFI_STORAGE_SD == TRUE
622 // notificate storage subsystem
624#endif // EFI_STORAGE_SD
625
626 // FATFS: Unregister work area prior to discard it
627 ret = f_unmount("");
628 if (ret != FR_OK) {
629 printFatFsError("Umount failed", ret);
630 }
631
632#if EFI_TUNER_STUDIO
633 engine->outputChannels.sd_error = (uint8_t) ret;
635#endif
636
637 efiPrintf("SD card unmounted");
638}
bool deinitStorageSD()

Referenced by sdModeSwitchToIdle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateSdCardLiveFlags()

void updateSdCardLiveFlags ( )

Definition at line 1019 of file mmc_card.cpp.

1019 {
1020#if EFI_PROD_CODE
1021 if (cardBlockDevice) {
1022 engine->outputChannels.sd_active_wr = (blkGetDriverState(cardBlockDevice) == BLK_WRITING);
1023 engine->outputChannels.sd_active_rd = (blkGetDriverState(cardBlockDevice) == BLK_READING);
1024 } else
1025#endif // EFI_PROD_CODE
1026 {
1029 }
1030}

Referenced by updateFlags().

Here is the caller graph for this function:

◆ usbConnectedSemaphore()

static chibios_rt::BinarySemaphore usbConnectedSemaphore ( true  )
static

Referenced by onUsbConnectedNotifyMmcI(), and useMsdMode().

Here is the caller graph for this function:

◆ useMsdMode()

static bool useMsdMode ( )
static

Definition at line 534 of file mmc_card.cpp.

534 {
536 return false;
537 }
538 if (isIgnVoltage()) {
539 // if we have battery voltage let's give priority to logging not reading
540 // this gives us a chance to SD card log cranking
541 return false;
542 }
543 // Wait for the USB stack to wake up, or a 15 second timeout, whichever occurs first
544 msg_t usbResult = usbConnectedSemaphore.wait(TIME_MS2I(15000));
545
546 return usbResult == MSG_OK;
547}
bool isIgnVoltage()

Referenced by THD_FUNCTION().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ blkbuf

uint8_t blkbuf[4 *MMCSD_BLOCK_SIZE]

Definition at line 293 of file mmc_card.cpp.

Referenced by MassStorageController::attachLun(), and attachMsdSdCard().

◆ cardBlockDevice

BaseBlockDevice* cardBlockDevice = nullptr
static

Definition at line 550 of file mmc_card.cpp.

Referenced by deinitMmc(), initMmc(), mountMmc(), sdModeSwitcher(), and updateSdCardLiveFlags().

◆ fatErrors

const char* fatErrors[]
static
Initial value:
= {
"FR_OK: Succeeded",
"FR_DISK_ERR: A hard error occurred in the low level disk I/O layer",
"FR_INT_ERR: Assertion failed",
"FR_NOT_READY: The physical drive cannot work",
"FR_NO_FILE: Could not find the file",
"FR_NO_PATH: Could not find the path",
"FR_INVALID_NAME: The path name format is invalid",
"FR_DENIED: Access denied due to prohibited access or directory full",
"FR_EXIST: Access denied due to prohibited access",
"FR_INVALID_OBJECT: The file/directory object is invalid",
"FR_WRITE_PROTECTED: The physical drive is write protected",
"FR_INVALID_DRIVE: The logical drive number is invalid",
"FR_NOT_ENABLED: The volume has no work area",
"FR_NO_FILESYSTEM: There is no valid FAT volume",
"FR_MKFS_ABORTED: The f_mkfs() aborted due to any problem",
"FR_TIMEOUT: Could not get a grant to access the volume within defined period",
"FR_LOCKED: The operation is rejected according to the file sharing policy",
"FR_NOT_ENOUGH_CORE: LFN working buffer could not be allocated",
"FR_TOO_MANY_OPEN_FILES: Number of open files > FF_FS_LOCK",
"FR_INVALID_PARAMETER: Given parameter is invalid"
}

Definition at line 250 of file mmc_card.cpp.

250 {
251 "FR_OK: Succeeded",
252 "FR_DISK_ERR: A hard error occurred in the low level disk I/O layer",
253 "FR_INT_ERR: Assertion failed",
254 "FR_NOT_READY: The physical drive cannot work",
255 "FR_NO_FILE: Could not find the file",
256 "FR_NO_PATH: Could not find the path",
257 "FR_INVALID_NAME: The path name format is invalid",
258 "FR_DENIED: Access denied due to prohibited access or directory full",
259 "FR_EXIST: Access denied due to prohibited access",
260 "FR_INVALID_OBJECT: The file/directory object is invalid",
261 "FR_WRITE_PROTECTED: The physical drive is write protected",
262 "FR_INVALID_DRIVE: The logical drive number is invalid",
263 "FR_NOT_ENABLED: The volume has no work area",
264 "FR_NO_FILESYSTEM: There is no valid FAT volume",
265 "FR_MKFS_ABORTED: The f_mkfs() aborted due to any problem",
266 "FR_TIMEOUT: Could not get a grant to access the volume within defined period",
267 "FR_LOCKED: The operation is rejected according to the file sharing policy",
268 "FR_NOT_ENOUGH_CORE: LFN working buffer could not be allocated",
269 "FR_TOO_MANY_OPEN_FILES: Number of open files > FF_FS_LOCK",
270 "FR_INVALID_PARAMETER: Given parameter is invalid"
271};

Referenced by printFatFsError().

◆ fd

FIL fd

Definition at line 288 of file mmc_card.cpp.

Referenced by sdLogger(), sdLoggerCloseFile(), and sdLoggerCreateFile().

◆ formatBuff

BYTE formatBuff[FATFS_CLUSTER_SIZE]

Definition at line 291 of file mmc_card.cpp.

◆ logBuffer

NO_CACHE SdLogBufferWriter logBuffer
static

Definition at line 149 of file mmc_card.cpp.

Referenced by mlgLogger(), sdLogger(), sdStatistics(), and sdTriggerLogger().

◆ logFileIndex

int logFileIndex
extern

Definition at line 16 of file mmc_card_util.cpp.

Referenced by incLogFileName(), and prepareLogFileName().

◆ logName

char logName[_MAX_FILLER+20]
static

◆ MMC_FS

NO_CACHE FATFS MMC_FS
static

fatfs MMC/SPI

Definition at line 239 of file mmc_card.cpp.

Referenced by mountMmc().

◆ mmcbuf

NO_CACHE uint8_t mmcbuf[MMC_BUFFER_SIZE]
static

MMC driver instance.

Definition at line 216 of file mmc_card.cpp.

Referenced by initializeMmcBlockDevice().

◆ mmccfg

MMCConfig mmccfg
static
Initial value:
= {
.spip = NULL,
.lscfg = &mmc_ls_spicfg,
.hscfg = &mmc_hs_spicfg
}

Definition at line 220 of file mmc_card.cpp.

220 {
221 .spip = NULL,
222 .lscfg = &mmc_ls_spicfg,
223 .hscfg = &mmc_hs_spicfg
224};

Referenced by initializeMmcBlockDevice(), and sdStatistics().

◆ MMCD1

MMCDriver MMCD1

Definition at line 217 of file mmc_card.cpp.

Referenced by deinitializeMmcBlockDevide(), and initializeMmcBlockDevice().

◆ mmcSpiDevice

spi_device_e mmcSpiDevice = SPI_NONE
static

on't re-read SD card spi device after boot - it could change mid transaction (TS thread could preempt), which will cause disaster (usually multiple-unlock of the same mutex in UNLOCK_SD_SPI)

Definition at line 211 of file mmc_card.cpp.

Referenced by initializeMmcBlockDevice(), and sdStatistics().

◆ [union]

union { ... } NO_CACHE

◆ sdcConfig

const SDCConfig sdcConfig
static
Initial value:
= {
.bus_width = RE_SDC_MODE,
.slowdown = 0U
}

Definition at line 504 of file mmc_card.cpp.

504 {
505 .bus_width = RE_SDC_MODE,
506 .slowdown = 0U
507};

◆ sdLoggedSuppressed

bool sdLoggedSuppressed = false
static

Definition at line 665 of file mmc_card.cpp.

Referenced by initEarlyMmcCard(), and sdLogger().

◆ sdLoggerFailed

bool sdLoggerFailed = false
static

Definition at line 663 of file mmc_card.cpp.

Referenced by sdLogger(), and sdLoggerStart().

◆ sdLoggerInitDone

bool sdLoggerInitDone = false
static

Definition at line 662 of file mmc_card.cpp.

Referenced by sdLogger(), and sdLoggerStart().

◆ sdLoggerReady

bool sdLoggerReady = false
static

Definition at line 32 of file mmc_card.cpp.

Referenced by sdLoggerIsReady(), and sdLoggerSetReady().

◆ sdMode

SD_MODE sdMode = SD_MODE_IDLE
static

◆ sdNeedRemoveReports

bool sdNeedRemoveReports = false
static

Definition at line 198 of file mmc_card.cpp.

Referenced by sdCardRemoveReportFiles(), and sdModeExecuter().

◆ sdStatus

SD_STATUS sdStatus = SD_STATUS_INIT
static

◆ sdStatusNames

const char* sdStatusNames[]
static
Initial value:
=
{
"INIT",
"MOUNTED",
"MOUNT_FAILED",
"OPEN_FAILED",
"SEEK_FAILED",
"NOT_INSERTED",
"CONNECTING",
"MSD",
"MMC_CONNECT_FAILED"
}

Definition at line 174 of file mmc_card.cpp.

175{
176 "INIT",
177 "MOUNTED",
178 "MOUNT_FAILED",
179 "OPEN_FAILED",
180 "SEEK_FAILED",
181 "NOT_INSERTED",
182 "CONNECTING",
183 "MSD",
184 "MMC_CONNECT_FAILED"
185};

Referenced by sdStatusName().

◆ sdTargetMode

SD_MODE sdTargetMode = SD_MODE_ECU
static

Definition at line 196 of file mmc_card.cpp.

Referenced by sdCardRequestMode(), sdModeSwitcher(), and THD_FUNCTION().

Go to the source code of this file.