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

896 {
897 return true;
898}

Referenced by THD_FUNCTION().

Here is the caller graph for this function:

◆ boardSdCardEnable()

PUBLIC_API_WEAK bool boardSdCardEnable ( )

Definition at line 891 of file mmc_card.cpp.

891 {
892 // assume powered and ready
893 return true;
894}

Referenced by THD_FUNCTION().

Here is the caller graph for this function:

◆ deinitializeMmcBlockDevide()

static void deinitializeMmcBlockDevide ( )
static

Definition at line 489 of file mmc_card.cpp.

489 {
490 blkDisconnect(&MMCD1); // Brings the driver in a state safe for card removal.
491 mmcStop(&MMCD1); // Disables the MMC peripheral.
492 UNLOCK_SD_SPI();
493}
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 568 of file mmc_card.cpp.

568 {
569 if (cardBlockDevice) {
571 }
572 cardBlockDevice = nullptr;
574}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
static EngineAccessor engine
Definition engine.h:413
static void deinitializeMmcBlockDevide()
Definition mmc_card.cpp:489
static BaseBlockDevice * cardBlockDevice
Definition mmc_card.cpp:549

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

1025 {
1026#if EFI_PROD_CODE
1027 logName[0] = 0;
1028
1029 addConsoleAction("sdinfo", sdStatistics);
1031 addConsoleActionS("sdmode", sdSetMode);
1033 //incLogFileName() use same shared FDLogFile, calling it while FDLogFile is used by log writer will cause damage
1034 //addConsoleAction("incfilename", incLogFileName);
1035#endif // EFI_PROD_CODE
1036}
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:310
void sdCardRemoveReportFiles()
static void sdSetMode(const char *mode)
Definition mmc_card.cpp:333
static char logName[_MAX_FILLER+20]
Definition mmc_card.cpp:296
static void removeFile(const char *pathx)
Definition mmc_card.cpp:423

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

454 {
455 // Configures and activates the MMC peripheral.
457
458 // todo: reuse initSpiCs method?
462
463 // Invalid SPI device, abort.
464 if (!mmccfg.spip) {
465 return nullptr;
466 }
467
468 // max SPI rate is 25 MHz after init
469 spiCalcClockDiv(mmccfg.spip, &mmc_hs_spicfg, 25 * 1000 * 1000);
470 // and 250 KHz during initialization
471 spiCalcClockDiv(mmccfg.spip, &mmc_ls_spicfg, 250 * 1000);
472
473 // We think we have everything for the card, let's try to mount it!
474 mmcObjectInit(&MMCD1, mmcbuf);
475 mmcStart(&MMCD1, &mmccfg);
476
477 // Performs the initialization procedure on the inserted card.
478 LOCK_SD_SPI();
479 if (blkConnect(&MMCD1) != HAL_SUCCESS) {
481 UNLOCK_SD_SPI();
482 return nullptr;
483 }
484 // We intentionally never unlock in case of success, we take exclusive access of that spi device for SD use
485
486 return reinterpret_cast<BaseBlockDevice*>(&MMCD1);
487}
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:210
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 552 of file mmc_card.cpp.

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

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

1038 {
1039#if EFI_PROD_CODE
1040 if (!isSdCardEnabled()) {
1041 // do not even bother starting the thread if SD card is not enabled & configured on start-up
1042 return;
1043 }
1044 chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), PRIO_MMC, (tfunc_t)(void*) MMCmonThread, NULL);
1045#endif // EFI_PROD_CODE
1046}
static bool isSdCardEnabled()
Definition mmc_card.cpp:444

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

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

578 {
579 bool ret = false;
580
581 // if no card, don't try to mount FS
582 if (cardBlockDevice != nullptr) {
583 // clean shared buffer
584 memset(&resources, 0x00, sizeof(resources));
585 // We were able to connect the SD card, mount the filesystem
586 memset(&MMC_FS, 0, sizeof(FATFS));
587 ret = (f_mount(&MMC_FS, "", /* Mount immediately */ 1) == FR_OK);
588
589 if (ret == false) {
591 efiPrintf("SD card mount failed!");
592 }
593 }
594
595 if (ret) {
597 efiPrintf("SD card mounted!");
598 }
599
600#if EFI_STORAGE_SD == TRUE
601 // notificate storage subsystem
603#endif // EFI_STORAGE_SD
604
605#if EFI_TUNER_STUDIO
607#endif
608
609 return ret;
610}
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 436 of file mmc_card.cpp.

436 {
437 usbConnectedSemaphore.signalI();
438}
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 343 of file mmc_card.cpp.

343 {
344 strcpy(logName, RUSEFI_LOG_PREFIX);
345 char *ptr;
346
347 // TS SD protocol supports only short 8 symbol file names, good thing that we do not use TS SD protocol!
348 bool result = dateToStringShort(&logName[PREFIX_LEN]);
349
350 if (result) {
351 ptr = &logName[PREFIX_LEN + SHORT_TIME_LEN];
352 } else {
353 ptr = itoa10(&logName[PREFIX_LEN], logFileIndex);
354 }
355
357 strcat(ptr, ".teeth");
358 } else {
359 strcat(ptr, DOT_MLG);
360 }
361}
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#if HAL_USE_MMC_SPI
300 efiPrintf("MMC CS %s", hwPortname(engineConfiguration->sdCardCsPin));
301 // todo: we need to figure out the right SPI pinout, not just SPI2
302// efiPrintf("MMC SCK %s:%d", portname(EFI_SPI2_SCK_PORT), EFI_SPI2_SCK_PIN);
303// efiPrintf("MMC MISO %s:%d", portname(EFI_SPI2_MISO_PORT), EFI_SPI2_MISO_PIN);
304// efiPrintf("MMC MOSI %s:%d", portname(EFI_SPI2_MOSI_PORT), EFI_SPI2_MOSI_PIN);
305#else
306 // not sure if we need to print SDIO pinout
307#endif
308}
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 423 of file mmc_card.cpp.

423 {
424 if (sdMode != SD_MODE_ECU) {
425 efiPrintf("SD card should be mounted to ECU");
426 return;
427 }
428
429 f_unlink(pathx);
430}
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 1059 of file mmc_card.cpp.

1060{
1061 return sdMode;
1062}

Referenced by hellenDisableEn().

Here is the caller graph for this function:

◆ sdCardRemoveReportFiles()

void sdCardRemoveReportFiles ( )

Definition at line 1064 of file mmc_card.cpp.

1064 {
1065 if (sdMode != SD_MODE_ECU) {
1066 efiPrintf("SD card should be mounted to ECU");
1067 return;
1068 }
1069
1070 sdNeedRemoveReports = true;
1071}
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 1050 of file mmc_card.cpp.

1051{
1052 // Check if SD is not in transition state...
1053 if (sdTargetMode == SD_MODE_IDLE) {
1054 efiPrintf("sdCardRequestMode %d", (int)mode);
1055 sdTargetMode = mode;
1056 }
1057}
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 742 of file mmc_card.cpp.

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

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

410{
411#ifdef LOGGER_MAX_FILE_SIZE
412 // truncate file to actual size
413 f_truncate(fd);
414#endif
415
416 // close file
417 f_close(fd);
418
419 // SD logger is inactive
420 sdLoggerSetReady(false);
421}
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 369 of file mmc_card.cpp.

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

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

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

732{
733 sdLoggerCloseFile(&resources.fd);
734#if EFI_TOOTH_LOGGER
735 // TODO: cache this config option untill sdLoggerStop()
738 }
739#endif
740}
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 858 of file mmc_card.cpp.

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

796{
797 if (sdTargetMode == SD_MODE_IDLE) {
798 return 0;
799 }
800
801 if (sdMode == sdTargetMode) {
802 // already here
804 return 0;
805 }
806
807 if (sdMode != SD_MODE_IDLE) {
808 int ret = sdModeSwitchToIdle(sdMode);
809 if (ret) {
810 return ret;
811 }
813 }
814
815 if (sdMode != SD_MODE_IDLE) {
816 return -1;
817 }
818
819 // Now SD card is in idle state, we can switch into target state
820 switch (sdTargetMode) {
821 case SD_MODE_IDLE:
822 return 0;
823 case SD_MODE_UNMOUNT:
824 // everithing is done in sdModeSwitchToIdle();
827 return 0;
828 case SD_MODE_ECU:
829 if (mountMmc()) {
832 } else {
833 // failed to mount SD card to ECU, go to idle
835 }
837 return 0;
838 case SD_MODE_PC:
839 attachMsdSdCard(cardBlockDevice, resources.blkbuf, sizeof(resources.blkbuf));
843 return 0;
844 case SD_MODE_FORMAT:
845 if (sdFormat()) {
846 // formated ok
847 }
849 // TODO: return to mode that was used before format was requested!
851 return 0;
852 }
853
854 // should not happen
855 return -1;
856}
void attachMsdSdCard(BaseBlockDevice *blkdev, uint8_t *blkbuf, size_t blkbufsize)
static bool sdFormat()
Definition mmc_card.cpp:742
static bool mountMmc()
Definition mmc_card.cpp:578
static int sdModeSwitchToIdle(SD_MODE from)
Definition mmc_card.cpp:772
static void sdLoggerStart(void)
Definition mmc_card.cpp:718

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

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

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

881{
882 // write error report file if needed
883 errorHandlerWriteReportFile(&resources.fd);
884
885 // check for any exist reports
887
888 return 0;
889}
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 333 of file mmc_card.cpp.

333 {
334 if (strcmp(mode, "pc") == 0) {
336 } else if (strcmp(mode, "ecu") == 0) {
338 } else {
339 efiPrintf("Invalid mode %s allowed modes pc and ecu", mode);
340 }
341}
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 310 of file mmc_card.cpp.

310 {
312 efiPrintf("SD enabled=%s status=%s", boolToString(engineConfiguration->isSdCardEnabled),
314#if HAL_USE_MMC_SPI
316 #if defined(STM32F4XX) || defined(STM32F7XX)
317 efiPrintf("HS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_hs_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
318 efiPrintf("LS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_ls_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
319 #else
320 efiPrintf("not implemented");
321 #endif
322#else
323 efiPrintf("SDIO mode");
324#endif
325 if (sdLoggerIsReady()) {
326 efiPrintf("filename=%s size=%d", logName, logBuffer.writen());
327 }
328#if EFI_FILE_LOGGING
329 efiPrintf("%d SD card fields", MLG::getSdCardFieldsCount());
330#endif
331}
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 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 990 of file mmc_card.cpp.

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

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

616 {
617 FRESULT ret;
618
619#if EFI_STORAGE_SD == TRUE
620 // notificate storage subsystem
622#endif // EFI_STORAGE_SD
623
624 // FATFS: Unregister work area prior to discard it
625 ret = f_unmount("");
626 if (ret != FR_OK) {
627 printFatFsError("Umount failed", ret);
628 }
629
630#if EFI_TUNER_STUDIO
632#endif
633
634 efiPrintf("SD card unmounted");
635}
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 1011 of file mmc_card.cpp.

1011 {
1012#if EFI_PROD_CODE
1013 if (cardBlockDevice) {
1014 engine->outputChannels.sd_active_wr = (blkGetDriverState(cardBlockDevice) == BLK_WRITING);
1015 engine->outputChannels.sd_active_rd = (blkGetDriverState(cardBlockDevice) == BLK_READING);
1016 } else
1017#endif // EFI_PROD_CODE
1018 {
1021 }
1022}

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

533 {
535 return false;
536 }
537 if (isIgnVoltage()) {
538 // if we have battery voltage let's give priority to logging not reading
539 // this gives us a chance to SD card log cranking
540 return false;
541 }
542 // Wait for the USB stack to wake up, or a 15 second timeout, whichever occurs first
543 msg_t usbResult = usbConnectedSemaphore.wait(TIME_MS2I(15000));
544
545 return usbResult == MSG_OK;
546}
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 549 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 210 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 503 of file mmc_card.cpp.

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

◆ sdLoggerFailed

bool sdLoggerFailed = false
static

Definition at line 660 of file mmc_card.cpp.

Referenced by sdLogger(), and sdLoggerStart().

◆ sdLoggerInitDone

bool sdLoggerInitDone = false
static

Definition at line 659 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.