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
 

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 899 of file mmc_card.cpp.

899 {
900 return true;
901}

Referenced by THD_FUNCTION().

Here is the caller graph for this function:

◆ boardSdCardEnable()

PUBLIC_API_WEAK bool boardSdCardEnable ( )

Definition at line 894 of file mmc_card.cpp.

894 {
895 // assume powered and ready
896 return true;
897}

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:109
static EngineAccessor engine
Definition engine.h:413
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:109
@ Reset_Cause_Unknown
Definition mpu_util.h:105
@ Reset_Cause_POR
Definition mpu_util.h:110
@ Reset_Cause_BOR
Definition mpu_util.h:112
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 1028 of file mmc_card.cpp.

1028 {
1029#if EFI_PROD_CODE
1030 logName[0] = 0;
1031
1032 addConsoleAction("sdinfo", sdStatistics);
1034 // sdmode pc
1035 // sdmode ecu
1036 addConsoleActionS("sdmode", sdSetMode);
1038 //incLogFileName() use same shared FDLogFile, calling it while FDLogFile is used by log writer will cause damage
1039 //addConsoleAction("incfilename", incLogFileName);
1040#endif // EFI_PROD_CODE
1041}
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
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 1043 of file mmc_card.cpp.

1043 {
1044#if EFI_PROD_CODE
1045 if (!isSdCardEnabled()) {
1046 // do not even bother starting the thread if SD card is not enabled & configured on start-up
1047 return;
1048 }
1049 chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), PRIO_MMC, (tfunc_t)(void*) MMCmonThread, NULL);
1050#endif // EFI_PROD_CODE
1051}
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 961 of file mmc_card.cpp.

961 {
962 // TODO: move this check somewhere out of here!
963 // if the SPI device got un-picked somehow, cancel SD card
964 // Don't do this check at all if using SDMMC interface instead of SPI
965#if EFI_PROD_CODE && !defined(EFI_SDC_DEVICE)
966 if (engineConfiguration->sdCardSpiDevice == SPI_NONE) {
967 return 0;
968 }
969#endif
970
971 systime_t before = chVTGetSystemTime();
972
973 size_t writen = MLG::writeSdLogLine(logBuffer);
974
975 // Something went wrong (already handled), so cancel further writes
976 if (logBuffer.failed) {
977 return -1;
978 }
979
981 if (freq > 250) {
982 freq = 250;
983 } else if (freq < 1) {
984 freq = 1;
985 }
986
987 systime_t period = CH_CFG_ST_FREQUENCY / freq;
988 chThdSleepUntilWindowed(before, before + period);
989
990 return writen;
991}
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 1064 of file mmc_card.cpp.

1065{
1066 return sdMode;
1067}

Referenced by hellenDisableEn().

Here is the caller graph for this function:

◆ sdCardRemoveReportFiles()

void sdCardRemoveReportFiles ( )

Definition at line 1069 of file mmc_card.cpp.

1069 {
1070 if (sdMode != SD_MODE_ECU) {
1071 efiPrintf("SD card should be mounted to ECU");
1072 return;
1073 }
1074
1075 sdNeedRemoveReports = true;
1076}
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 1055 of file mmc_card.cpp.

1056{
1057 // Check if SD is not in transition state...
1058 if (sdTargetMode == SD_MODE_IDLE) {
1059 efiPrintf("sdCardRequestMode %d", (int)mode);
1060 sdTargetMode = mode;
1061 }
1062}
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 745 of file mmc_card.cpp.

746{
747#if EFI_TUNER_STUDIO
750#endif
751 //FRESULT ret = f_mkfs("", nullptr, resources.formatBuff, sizeof(resources.formatBuff));
752 FRESULT ret = f_mkfs("", nullptr, resources.formatBuff, sizeof(resources.formatBuff));
753
754 if (ret) {
755 printFatFsError("format failed", ret);
756 warning(ObdCode::CUSTOM_ERR_SD_MOUNT_FAILED, "SD: format failed");
757 goto exit;
758 }
759 ret = f_setlabel(SD_CARD_LABEL);
760 if (ret) {
761 printFatFsError("setlabel failed", ret);
762 // this is not critical
763 ret = FR_OK;
764 }
765
766exit:
767#if EFI_TUNER_STUDIO
769 engine->outputChannels.sd_error = (uint8_t) ret;
770#endif
771
772 return (ret ? false : true);
773}
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 665 of file mmc_card.cpp.

666{
667 int ret = 0;
668
669 if (!sdLoggerInitDone) {
672
673 ret = sdLoggerCreateFile(fd);
674 if (ret == 0) {
675 ret = logBuffer.start(fd);
676 }
677
678 sdLoggerInitDone = true;
679
680 if (ret < 0) {
681 sdLoggerFailed = true;
682 return ret;
683 }
684 }
685
686 if (!sdLoggerFailed) {
688 ret = sdTriggerLogger();
689 } else {
690 ret = mlgLogger();
691 }
692 }
693
694 if (ret < 0) {
695 sdLoggerFailed = true;
696 return ret;
697 }
698
699 if (sdLoggerFailed) {
700 // logger is dead until restart, do not waste CPU
701 chThdSleepMilliseconds(100);
702 return -1;
703 }
704
705#ifdef LOGGER_MAX_FILE_SIZE
706 // check if we need to start next log file
707 // in next write (assume same size as current) will cross LOGGER_MAX_FILE_SIZE boundary
708 // TODO: use f_tell() instead ?
709 if (logBuffer.writen() + ret > LOGGER_MAX_FILE_SIZE) {
710 logBuffer.stop();
712
713 //need to start new file
714 sdLoggerInitDone = false;
715 }
716#endif
717
718 return ret;
719}
static bool sdLoggerFailed
Definition mmc_card.cpp:663
static int sdTriggerLogger()
Definition mmc_card.cpp:993
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:961
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 721 of file mmc_card.cpp.

722{
723 sdLoggerInitDone = false;
724 sdLoggerFailed = false;
725
726#if EFI_TOOTH_LOGGER
727 // TODO: cache this config option untill sdLoggerStop()
730 }
731#endif
732}
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 734 of file mmc_card.cpp.

735{
736 sdLoggerCloseFile(&resources.fd);
737#if EFI_TOOTH_LOGGER
738 // TODO: cache this config option untill sdLoggerStop()
741 }
742#endif
743}
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 861 of file mmc_card.cpp.

862{
863 switch (sdMode) {
864 case SD_MODE_IDLE:
865 case SD_MODE_PC:
866 case SD_MODE_UNMOUNT:
867 case SD_MODE_FORMAT:
868 // nothing to do in these state, just sleep
869 chThdSleepMilliseconds(100);
870 return 0;
871 case SD_MODE_ECU:
874 sdNeedRemoveReports = false;
875 }
876 // execute logger
877 return sdLogger(&resources.fd);
878 }
879
880 return 0;
881}
static int sdLogger(FIL *fd)
Definition mmc_card.cpp:665
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 798 of file mmc_card.cpp.

799{
800 if (sdTargetMode == SD_MODE_IDLE) {
801 return 0;
802 }
803
804 if (sdMode == sdTargetMode) {
805 // already here
807 return 0;
808 }
809
810 if (sdMode != SD_MODE_IDLE) {
811 int ret = sdModeSwitchToIdle(sdMode);
812 if (ret) {
813 return ret;
814 }
816 }
817
818 if (sdMode != SD_MODE_IDLE) {
819 return -1;
820 }
821
822 // Now SD card is in idle state, we can switch into target state
823 switch (sdTargetMode) {
824 case SD_MODE_IDLE:
825 return 0;
826 case SD_MODE_UNMOUNT:
827 // everything is done in sdModeSwitchToIdle();
830 return 0;
831 case SD_MODE_ECU:
832 if (mountMmc()) {
835 } else {
836 // failed to mount SD card to ECU, go to idle
838 }
840 return 0;
841 case SD_MODE_PC:
842 attachMsdSdCard(cardBlockDevice, resources.blkbuf, sizeof(resources.blkbuf));
846 return 0;
847 case SD_MODE_FORMAT:
848 if (sdFormat()) {
849 // formated ok
850 }
852 // TODO: return to mode that was used before format was requested!
854 return 0;
855 }
856
857 // should not happen
858 return -1;
859}
void attachMsdSdCard(BaseBlockDevice *blkdev, uint8_t *blkbuf, size_t blkbufsize)
static bool sdFormat()
Definition mmc_card.cpp:745
static void sdLoggerStart()
Definition mmc_card.cpp:721
static bool mountMmc()
Definition mmc_card.cpp:579
static int sdModeSwitchToIdle(SD_MODE from)
Definition mmc_card.cpp:775

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 775 of file mmc_card.cpp.

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

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 883 of file mmc_card.cpp.

884{
885 // write error report file if needed
886 errorHandlerWriteReportFile(&resources.fd);
887
888 // check for any exist reports
890
891 return 0;
892}
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 993 of file mmc_card.cpp.

993 {
994 size_t toWrite = 0;
995#if EFI_TOOTH_LOGGER
997
998 // can return nullptr
999 if (buffer) {
1000 toWrite = buffer->nextIdx * sizeof(composite_logger_s);
1001 logBuffer.write(reinterpret_cast<const char*>(buffer->buffer), toWrite);
1002 if (logBuffer.failed) {
1003 return -1;
1004 }
1005
1007 }
1008#endif /* EFI_TOOTH_LOGGER */
1009 return toWrite;
1010}
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 904 of file mmc_card.cpp.

904 {
905 (void)arg;
906
907 chRegSetThreadName("SD Card Logger");
908
909 while (!boardSdCardEnable()) {
910 // wait until board enables peripheral
911 chThdSleepMilliseconds(100);
912 }
913
915 if (!initMmc()) {
916 efiPrintf("Card is not preset/failed to init");
918 // give up until next boot
919 goto die;
920 }
921
922 // Try to mount SD card, drop critical report if needed and check for previously stored reports
923 if (mountMmc()) {
925
927
928#if EFI_STORAGE_SD == TRUE
929 // Give some time for storage manager to load settings from SD
930 chThdSleepMilliseconds(1000);
931#endif
932 }
933
934#if HAL_USE_USB_MSD
935 // Wait for the USB stack to wake up, or a 15 second timeout, whichever occurs first
936 // If we have a device AND USB is connected, mount the card to USB, otherwise
937 // mount the null device and try to mount the filesystem ourselves
938 if (useMsdMode()) {
940 }
941#endif
942
943 while (1) {
946 }
947
948die:
949 // bring SD interface to safe state
950 deinitMmc();
952
953 efiPrintf("SD logger has died!");
954
955 // exiting thread will create zombie!
956 while(1) {
957 chThdSleepMilliseconds(100);
958 }
959}
static bool useMsdMode()
Definition mmc_card.cpp:534
PUBLIC_API_WEAK bool boardSdCardEnable()
Definition mmc_card.cpp:894
static int sdReportStorageInit()
Definition mmc_card.cpp:883
static int sdModeExecuter()
Definition mmc_card.cpp:861
static int sdModeSwitcher()
Definition mmc_card.cpp:798
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:899
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 1014 of file mmc_card.cpp.

1014 {
1015#if EFI_PROD_CODE
1016 if (cardBlockDevice) {
1017 engine->outputChannels.sd_active_wr = (blkGetDriverState(cardBlockDevice) == BLK_WRITING);
1018 engine->outputChannels.sd_active_rd = (blkGetDriverState(cardBlockDevice) == BLK_READING);
1019 } else
1020#endif // EFI_PROD_CODE
1021 {
1024 }
1025}

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};

◆ 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.