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)
 
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 (void)
 
static void sdLoggerStop (void)
 
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)
 
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 160 of file mmc_card.cpp.

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

Function Documentation

◆ boardSdCardDisable()

PUBLIC_API_WEAK bool boardSdCardDisable ( )

Definition at line 886 of file mmc_card.cpp.

886 {
887 return true;
888}

Referenced by THD_FUNCTION().

Here is the caller graph for this function:

◆ boardSdCardEnable()

PUBLIC_API_WEAK bool boardSdCardEnable ( )

Definition at line 881 of file mmc_card.cpp.

881 {
882 // assume powered and ready
883 return true;
884}

Referenced by THD_FUNCTION().

Here is the caller graph for this function:

◆ deinitializeMmcBlockDevide()

static void deinitializeMmcBlockDevide ( )
static

Definition at line 479 of file mmc_card.cpp.

479 {
480 blkDisconnect(&MMCD1); // Brings the driver in a state safe for card removal.
481 mmcStop(&MMCD1); // Disables the MMC peripheral.
482 UNLOCK_SD_SPI();
483}
MMCDriver MMCD1
Definition mmc_card.cpp:216

Referenced by deinitMmc().

Here is the caller graph for this function:

◆ deinitMmc()

static void deinitMmc ( )
static

Definition at line 558 of file mmc_card.cpp.

558 {
559 if (cardBlockDevice) {
561 }
562 cardBlockDevice = nullptr;
564}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
static EngineAccessor engine
Definition engine.h:413
static void deinitializeMmcBlockDevide()
Definition mmc_card.cpp:479
static BaseBlockDevice * cardBlockDevice
Definition mmc_card.cpp:539

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

1015 {
1016#if EFI_PROD_CODE
1017 logName[0] = 0;
1018
1019 addConsoleAction("sdinfo", sdStatistics);
1021 addConsoleActionS("sdmode", sdSetMode);
1023 //incLogFileName() use same shared FDLogFile, calling it while FDLogFile is used by log writer will cause damage
1024 //addConsoleAction("incfilename", incLogFileName);
1025#endif // EFI_PROD_CODE
1026}
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:306
void sdCardRemoveReportFiles()
static void sdSetMode(const char *mode)
Definition mmc_card.cpp:323
static char logName[_MAX_FILLER+20]
Definition mmc_card.cpp:296
static void removeFile(const char *pathx)
Definition mmc_card.cpp:413

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

444 {
445 // Configures and activates the MMC peripheral.
447
448 // todo: reuse initSpiCs method?
452
453 // Invalid SPI device, abort.
454 if (!mmccfg.spip) {
455 return nullptr;
456 }
457
458 // max SPI rate is 25 MHz after init
459 spiCalcClockDiv(mmccfg.spip, &mmc_hs_spicfg, 25 * 1000 * 1000);
460 // and 250 KHz during initialization
461 spiCalcClockDiv(mmccfg.spip, &mmc_ls_spicfg, 250 * 1000);
462
463 // We think we have everything for the card, let's try to mount it!
464 mmcObjectInit(&MMCD1, mmcbuf);
465 mmcStart(&MMCD1, &mmccfg);
466
467 // Performs the initialization procedure on the inserted card.
468 LOCK_SD_SPI();
469 if (blkConnect(&MMCD1) != HAL_SUCCESS) {
471 UNLOCK_SD_SPI();
472 return nullptr;
473 }
474 // We intentionally never unlock in case of success, we take exclusive access of that spi device for SD use
475
476 return reinterpret_cast<BaseBlockDevice*>(&MMCD1);
477}
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:149
static spi_device_e mmcSpiDevice
Definition mmc_card.cpp:203
static NO_CACHE uint8_t mmcbuf[MMC_BUFFER_SIZE]
Definition mmc_card.cpp:215
static SD_STATUS sdStatus
Definition mmc_card.cpp:191
static MMCConfig mmccfg
Definition mmc_card.cpp:219

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

542 {
543 // Don't try to mount SD card in case of fatal error - hardware may be in an unexpected state
544 if (hasFirmwareError()) {
545 return false;
546 }
547
549
550#if EFI_TUNER_STUDIO
551 // If not null, card is present
553#endif
554
555 return (cardBlockDevice != nullptr);
556}
static BaseBlockDevice * initializeMmcBlockDevice()
Definition mmc_card.cpp:444

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

1028 {
1029#if EFI_PROD_CODE
1030 if (!isSdCardEnabled()) {
1031 // do not even bother starting the thread if SD card is not enabled & configured on start-up
1032 return;
1033 }
1034 chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), PRIO_MMC, (tfunc_t)(void*) MMCmonThread, NULL);
1035#endif // EFI_PROD_CODE
1036}
static bool isSdCardEnabled()
Definition mmc_card.cpp:434

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

948 {
949 // TODO: move this check somewhere out of here!
950 // if the SPI device got un-picked somehow, cancel SD card
951 // Don't do this check at all if using SDMMC interface instead of SPI
952#if EFI_PROD_CODE && !defined(EFI_SDC_DEVICE)
953 if (engineConfiguration->sdCardSpiDevice == SPI_NONE) {
954 return 0;
955 }
956#endif
957
958 systime_t before = chVTGetSystemTime();
959
960 size_t writen = MLG::writeSdLogLine(logBuffer);
961
962 // Something went wrong (already handled), so cancel further writes
963 if (logBuffer.failed) {
964 return -1;
965 }
966
968 if (freq > 250) {
969 freq = 250;
970 } else if (freq < 1) {
971 freq = 1;
972 }
973
974 systime_t period = CH_CFG_ST_FREQUENCY / freq;
975 chThdSleepUntilWindowed(before, before + period);
976
977 return writen;
978}
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 568 of file mmc_card.cpp.

568 {
569 bool ret = false;
570
571 // if no card, don't try to mount FS
572 if (cardBlockDevice != nullptr) {
573 // clean shared buffer
574 memset(&resources, 0x00, sizeof(resources));
575 // We were able to connect the SD card, mount the filesystem
576 memset(&MMC_FS, 0, sizeof(FATFS));
577 ret = (f_mount(&MMC_FS, "", /* Mount immediately */ 1) == FR_OK);
578
579 if (ret == false) {
581 efiPrintf("SD card mount failed!");
582 }
583 }
584
585 if (ret) {
587 efiPrintf("SD card mounted!");
588 }
589
590#if EFI_STORAGE_SD == TRUE
591 // notificate storage subsystem
593#endif // EFI_STORAGE_SD
594
595#if EFI_TUNER_STUDIO
597#endif
598
599 return ret;
600}
static NO_CACHE FATFS MMC_FS
Definition mmc_card.cpp:238
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 ( void  )

Definition at line 426 of file mmc_card.cpp.

426 {
427 usbConnectedSemaphore.signalI();
428}
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 333 of file mmc_card.cpp.

333 {
334 strcpy(logName, RUSEFI_LOG_PREFIX);
335 char *ptr;
336
337 // TS SD protocol supports only short 8 symbol file names, good thing that we do not use TS SD protocol!
338 bool result = dateToStringShort(&logName[PREFIX_LEN]);
339
340 if (result) {
341 ptr = &logName[PREFIX_LEN + SHORT_TIME_LEN];
342 } else {
343 ptr = itoa10(&logName[PREFIX_LEN], logFileIndex);
344 }
345
347 strcat(ptr, ".teeth");
348 } else {
349 strcat(ptr, DOT_MLG);
350 }
351}
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 273 of file mmc_card.cpp.

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

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

Here is the caller graph for this function:

◆ printMmcPinout()

static void printMmcPinout ( )
static

Definition at line 298 of file mmc_card.cpp.

298 {
299 efiPrintf("MMC CS %s", hwPortname(engineConfiguration->sdCardCsPin));
300 // todo: we need to figure out the right SPI pinout, not just SPI2
301// efiPrintf("MMC SCK %s:%d", portname(EFI_SPI2_SCK_PORT), EFI_SPI2_SCK_PIN);
302// efiPrintf("MMC MISO %s:%d", portname(EFI_SPI2_MISO_PORT), EFI_SPI2_MISO_PIN);
303// efiPrintf("MMC MOSI %s:%d", portname(EFI_SPI2_MOSI_PORT), EFI_SPI2_MOSI_PIN);
304}
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 413 of file mmc_card.cpp.

413 {
414 if (sdMode != SD_MODE_ECU) {
415 efiPrintf("SD card should be mounted to ECU");
416 return;
417 }
418
419 f_unlink(pathx);
420}
static SD_MODE sdMode
Definition mmc_card.cpp:193
@ SD_MODE_ECU
Definition mmc_card.h:18

Referenced by initEarlyMmcCard().

Here is the caller graph for this function:

◆ sdCardGetCurrentMode()

SD_MODE sdCardGetCurrentMode ( void  )

Definition at line 1049 of file mmc_card.cpp.

1050{
1051 return sdMode;
1052}

Referenced by hellenDisableEn().

Here is the caller graph for this function:

◆ sdCardRemoveReportFiles()

void sdCardRemoveReportFiles ( )

Definition at line 1054 of file mmc_card.cpp.

1054 {
1055 if (sdMode != SD_MODE_ECU) {
1056 efiPrintf("SD card should be mounted to ECU");
1057 return;
1058 }
1059
1060 sdNeedRemoveReports = true;
1061}
static bool sdNeedRemoveReports
Definition mmc_card.cpp:197

Referenced by handleCommandX14(), and initEarlyMmcCard().

Here is the caller graph for this function:

◆ sdCardRequestMode()

void sdCardRequestMode ( SD_MODE  mode)

Definition at line 1040 of file mmc_card.cpp.

1041{
1042 // Check if SD is not in transition state...
1043 if (sdTargetMode == SD_MODE_IDLE) {
1044 efiPrintf("sdCardRequestMode %d", (int)mode);
1045 sdTargetMode = mode;
1046 }
1047}
static SD_MODE sdTargetMode
Definition mmc_card.cpp:195
@ SD_MODE_IDLE
Definition mmc_card.h:17

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

Here is the caller graph for this function:

◆ sdFormat()

static bool sdFormat ( )
static

Definition at line 732 of file mmc_card.cpp.

733{
734#if EFI_TUNER_STUDIO
737#endif
738 //FRESULT ret = f_mkfs("", nullptr, resources.formatBuff, sizeof(resources.formatBuff));
739 FRESULT ret = f_mkfs("", nullptr, resources.formatBuff, sizeof(resources.formatBuff));
740
741 if (ret) {
742 printFatFsError("format failed", ret);
743 warning(ObdCode::CUSTOM_ERR_SD_MOUNT_FAILED, "SD: format failed");
744 goto exit;
745 }
746 ret = f_setlabel(SD_CARD_LABEL);
747 if (ret) {
748 printFatFsError("setlabel failed", ret);
749 // this is not critical
750 ret = FR_OK;
751 }
752
753exit:
754#if EFI_TUNER_STUDIO
756 engine->outputChannels.sd_error = (uint8_t) ret;
757#endif
758
759 return (ret ? false : true);
760}
bool warning(ObdCode code, const char *fmt,...)
void printFatFsError(const char *str, FRESULT f_error)
Definition mmc_card.cpp:273
@ 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 652 of file mmc_card.cpp.

653{
654 int ret = 0;
655
656 if (!sdLoggerInitDone) {
659
660 ret = sdLoggerCreateFile(fd);
661 if (ret == 0) {
662 ret = logBuffer.start(fd);
663 }
664
665 sdLoggerInitDone = true;
666
667 if (ret < 0) {
668 sdLoggerFailed = true;
669 return ret;
670 }
671 }
672
673 if (!sdLoggerFailed) {
675 ret = sdTriggerLogger();
676 } else {
677 ret = mlgLogger();
678 }
679 }
680
681 if (ret < 0) {
682 sdLoggerFailed = true;
683 return ret;
684 }
685
686 if (sdLoggerFailed) {
687 // logger is dead until restart, do not waste CPU
688 chThdSleepMilliseconds(100);
689 return -1;
690 }
691
692#ifdef LOGGER_MAX_FILE_SIZE
693 // check if we need to start next log file
694 // in next write (assume same size as current) will cross LOGGER_MAX_FILE_SIZE boundary
695 // TODO: use f_tell() instead ?
696 if (logBuffer.writen() + ret > LOGGER_MAX_FILE_SIZE) {
697 logBuffer.stop();
699
700 //need to start new file
701 sdLoggerInitDone = false;
702 }
703#endif
704
705 return ret;
706}
static bool sdLoggerFailed
Definition mmc_card.cpp:650
static int sdTriggerLogger()
Definition mmc_card.cpp:980
static void sdLoggerCloseFile(FIL *fd)
Definition mmc_card.cpp:399
static bool sdLoggerInitDone
Definition mmc_card.cpp:649
FIL fd
Definition mmc_card.cpp:287
static int sdLoggerCreateFile(FIL *fd)
Create a new file with the specified name.
Definition mmc_card.cpp:359
static int mlgLogger()
Definition mmc_card.cpp:948
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 399 of file mmc_card.cpp.

400{
401#ifdef LOGGER_MAX_FILE_SIZE
402 // truncate file to actual size
403 f_truncate(fd);
404#endif
405
406 // close file
407 f_close(fd);
408
409 // SD logger is inactive
410 sdLoggerSetReady(false);
411}
static void sdLoggerSetReady(bool value)
Definition mmc_card.cpp:240

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

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

Referenced by sdLogger().

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

◆ sdLoggerIsReady()

static bool sdLoggerIsReady ( void  )
static

Definition at line 244 of file mmc_card.cpp.

244 {
245 return sdLoggerReady;
246}
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 240 of file mmc_card.cpp.

240 {
241 sdLoggerReady = value;
242}

Referenced by sdLoggerCloseFile(), and sdLoggerCreateFile().

Here is the caller graph for this function:

◆ sdLoggerStart()

static void sdLoggerStart ( void  )
static

Definition at line 708 of file mmc_card.cpp.

709{
710 sdLoggerInitDone = false;
711 sdLoggerFailed = false;
712
713#if EFI_TOOTH_LOGGER
714 // TODO: cache this config option untill sdLoggerStop()
717 }
718#endif
719}
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 ( void  )
static

Definition at line 721 of file mmc_card.cpp.

722{
723 sdLoggerCloseFile(&resources.fd);
724#if EFI_TOOTH_LOGGER
725 // TODO: cache this config option untill sdLoggerStop()
728 }
729#endif
730}
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 848 of file mmc_card.cpp.

849{
850 switch (sdMode) {
851 case SD_MODE_IDLE:
852 case SD_MODE_PC:
853 case SD_MODE_UNMOUNT:
854 case SD_MODE_FORMAT:
855 // nothing to do in these state, just sleep
856 chThdSleepMilliseconds(100);
857 return 0;
858 case SD_MODE_ECU:
861 sdNeedRemoveReports = false;
862 }
863 // execute logger
864 return sdLogger(&resources.fd);
865 }
866
867 return 0;
868}
static int sdLogger(FIL *fd)
Definition mmc_card.cpp:652
void errorHandlerDeleteReports()
@ SD_MODE_UNMOUNT
Definition mmc_card.h:20
@ SD_MODE_PC
Definition mmc_card.h:19
@ SD_MODE_FORMAT
Definition mmc_card.h:21

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

786{
787 if (sdTargetMode == SD_MODE_IDLE) {
788 return 0;
789 }
790
791 if (sdMode == sdTargetMode) {
792 // already here
794 return 0;
795 }
796
797 if (sdMode != SD_MODE_IDLE) {
798 int ret = sdModeSwitchToIdle(sdMode);
799 if (ret) {
800 return ret;
801 }
803 }
804
805 if (sdMode != SD_MODE_IDLE) {
806 return -1;
807 }
808
809 // Now SD card is in idle state, we can switch into target state
810 switch (sdTargetMode) {
811 case SD_MODE_IDLE:
812 return 0;
813 case SD_MODE_UNMOUNT:
814 // everithing is done in sdModeSwitchToIdle();
817 return 0;
818 case SD_MODE_ECU:
819 if (mountMmc()) {
822 } else {
823 // failed to mount SD card to ECU, go to idle
825 }
827 return 0;
828 case SD_MODE_PC:
829 attachMsdSdCard(cardBlockDevice, resources.blkbuf, sizeof(resources.blkbuf));
833 return 0;
834 case SD_MODE_FORMAT:
835 if (sdFormat()) {
836 // formated ok
837 }
839 // TODO: return to mode that was used before format was requested!
841 return 0;
842 }
843
844 // should not happen
845 return -1;
846}
void attachMsdSdCard(BaseBlockDevice *blkdev, uint8_t *blkbuf, size_t blkbufsize)
static bool sdFormat()
Definition mmc_card.cpp:732
static bool mountMmc()
Definition mmc_card.cpp:568
static int sdModeSwitchToIdle(SD_MODE from)
Definition mmc_card.cpp:762
static void sdLoggerStart(void)
Definition mmc_card.cpp:708

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

763{
764 switch (from) {
765 case SD_MODE_IDLE:
766 return 0;
767 case SD_MODE_ECU:
768 sdLoggerStop();
769 unmountMmc();
770 return 0;
771 case SD_MODE_PC:
773 return 0;
774 case SD_MODE_UNMOUNT:
775 return 0;
776 case SD_MODE_FORMAT:
777 //not allowed to interrupt formating process
778 return -1;
779 }
780
781 efiPrintf("Invalid SD card thread state: %d", static_cast<int>(from));
782 return -1;
783}
void deattachMsdSdCard(void)
static void unmountMmc()
Definition mmc_card.cpp:606
static void sdLoggerStop(void)
Definition mmc_card.cpp:721

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

871{
872 // write error report file if needed
873 errorHandlerWriteReportFile(&resources.fd);
874
875 // check for any exist reports
877
878 return 0;
879}
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 323 of file mmc_card.cpp.

323 {
324 if (strcmp(mode, "pc") == 0) {
326 } else if (strcmp(mode, "ecu") == 0) {
328 } else {
329 efiPrintf("Invalid mode %s allowed modes pc and ecu", mode);
330 }
331}
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 306 of file mmc_card.cpp.

306 {
308 efiPrintf("SD enabled=%s status=%s", boolToString(engineConfiguration->isSdCardEnabled),
311#if HAL_USE_MMC_SPI && (defined(STM32F4XX) || defined(STM32F7XX))
312 efiPrintf("HS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_hs_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
313 efiPrintf("LS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_ls_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
314#endif
315 if (sdLoggerIsReady()) {
316 efiPrintf("filename=%s size=%d", logName, logBuffer.writen());
317 }
318#if EFI_FILE_LOGGING
319 efiPrintf("%d SD card fields", MLG::getSdCardFieldsCount());
320#endif
321}
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:256
static const char * sdStatusName(SD_STATUS status)
Definition mmc_card.cpp:186
static bool sdLoggerIsReady(void)
Definition mmc_card.cpp:244
static void printMmcPinout()
Definition mmc_card.cpp:298
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 186 of file mmc_card.cpp.

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

Referenced by sdStatistics().

Here is the caller graph for this function:

◆ sdTriggerLogger()

static int sdTriggerLogger ( )
static

Definition at line 980 of file mmc_card.cpp.

980 {
981 size_t toWrite = 0;
982#if EFI_TOOTH_LOGGER
984
985 // can return nullptr
986 if (buffer) {
987 toWrite = buffer->nextIdx * sizeof(composite_logger_s);
988 logBuffer.write(reinterpret_cast<const char*>(buffer->buffer), toWrite);
989 if (logBuffer.failed) {
990 return -1;
991 }
992
994 }
995#endif /* EFI_TOOTH_LOGGER */
996 return toWrite;
997}
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 891 of file mmc_card.cpp.

891 {
892 (void)arg;
893
894 chRegSetThreadName("SD Card Logger");
895
896 while (!boardSdCardEnable()) {
897 // wait until board enables peripheral
898 chThdSleepMilliseconds(100);
899 }
900
902 if (!initMmc()) {
903 efiPrintf("Card is not preset/failed to init");
905 // give up until next boot
906 goto die;
907 }
908
909 // Try to mount SD card, drop critical report if needed and check for previously stored reports
910 if (mountMmc()) {
912
914
915#if EFI_STORAGE_SD == TRUE
916 // Give some time for storage manager to load settings from SD
917 chThdSleepMilliseconds(1000);
918#endif
919 }
920
921#if HAL_USE_USB_MSD
922 // Wait for the USB stack to wake up, or a 15 second timeout, whichever occurs first
923 // If we have a device AND USB is connected, mount the card to USB, otherwise
924 // mount the null device and try to mount the filesystem ourselves
925 if (useMsdMode()) {
927 }
928#endif
929
930 while (1) {
933 }
934
935die:
936 // bring SD interface to safe state
937 deinitMmc();
939
940 efiPrintf("SD logger has died!");
941
942 // exiting thread will create zombie!
943 while(1) {
944 chThdSleepMilliseconds(100);
945 }
946}
static bool useMsdMode()
Definition mmc_card.cpp:523
PUBLIC_API_WEAK bool boardSdCardEnable()
Definition mmc_card.cpp:881
static int sdReportStorageInit()
Definition mmc_card.cpp:870
static int sdModeExecuter()
Definition mmc_card.cpp:848
static int sdModeSwitcher()
Definition mmc_card.cpp:785
static void deinitMmc()
Definition mmc_card.cpp:558
static bool initMmc()
Definition mmc_card.cpp:542
PUBLIC_API_WEAK bool boardSdCardDisable()
Definition mmc_card.cpp:886
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 606 of file mmc_card.cpp.

606 {
607 FRESULT ret;
608
609#if EFI_STORAGE_SD == TRUE
610 // notificate storage subsystem
612#endif // EFI_STORAGE_SD
613
614 // FATFS: Unregister work area prior to discard it
615 ret = f_unmount("");
616 if (ret != FR_OK) {
617 printFatFsError("Umount failed", ret);
618 }
619
620#if EFI_TUNER_STUDIO
622#endif
623
624 efiPrintf("SD card unmounted");
625}
bool deinitStorageSD()

Referenced by sdModeSwitchToIdle().

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

◆ updateSdCardLiveFlags()

void updateSdCardLiveFlags ( void  )

Definition at line 1001 of file mmc_card.cpp.

1001 {
1002#if EFI_PROD_CODE
1003 if (cardBlockDevice) {
1004 engine->outputChannels.sd_active_wr = (blkGetDriverState(cardBlockDevice) == BLK_WRITING);
1005 engine->outputChannels.sd_active_rd = (blkGetDriverState(cardBlockDevice) == BLK_READING);
1006 } else
1007#endif // EFI_PROD_CODE
1008 {
1011 }
1012}

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

523 {
525 return false;
526 }
527 if (isIgnVoltage()) {
528 // if we have battery voltage let's give priority to logging not reading
529 // this gives us a chance to SD card log cranking
530 return false;
531 }
532 // Wait for the USB stack to wake up, or a 15 second timeout, whichever occurs first
533 msg_t usbResult = usbConnectedSemaphore.wait(TIME_MS2I(15000));
534
535 return usbResult == MSG_OK;
536}
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 292 of file mmc_card.cpp.

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

◆ cardBlockDevice

BaseBlockDevice* cardBlockDevice = nullptr
static

Definition at line 539 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 249 of file mmc_card.cpp.

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

Referenced by printFatFsError().

◆ fd

FIL fd

Definition at line 287 of file mmc_card.cpp.

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

◆ formatBuff

BYTE formatBuff[FATFS_CLUSTER_SIZE]

Definition at line 290 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 238 of file mmc_card.cpp.

Referenced by mountMmc().

◆ mmcbuf

NO_CACHE uint8_t mmcbuf[MMC_BUFFER_SIZE]
static

MMC driver instance.

Definition at line 215 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 219 of file mmc_card.cpp.

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

Referenced by initializeMmcBlockDevice(), and sdStatistics().

◆ MMCD1

MMCDriver MMCD1

Definition at line 216 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 203 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 493 of file mmc_card.cpp.

493 {
494 .bus_width = RE_SDC_MODE,
495 .slowdown = 0U
496};

◆ sdLoggerFailed

bool sdLoggerFailed = false
static

Definition at line 650 of file mmc_card.cpp.

Referenced by sdLogger(), and sdLoggerStart().

◆ sdLoggerInitDone

bool sdLoggerInitDone = false
static

Definition at line 649 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 197 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 173 of file mmc_card.cpp.

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

Referenced by sdStatusName().

◆ sdTargetMode

SD_MODE sdTargetMode = SD_MODE_ECU
static

Definition at line 195 of file mmc_card.cpp.

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

Go to the source code of this file.