rusEFI
The most advanced open source ECU
|
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 char * | sdStatusName (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 char * | sdStatusNames [] | |
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 char * | fatErrors [] | |
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 | |
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.
PUBLIC_API_WEAK bool boardSdCardDisable | ( | ) |
Definition at line 886 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
PUBLIC_API_WEAK bool boardSdCardEnable | ( | ) |
Definition at line 881 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
|
static |
Definition at line 479 of file mmc_card.cpp.
Referenced by deinitMmc().
|
static |
Definition at line 558 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
|
extern |
Definition at line 343 of file error_handling.cpp.
Referenced by errorHandlerDeleteReports(), and sdReportStorageInit().
|
extern |
Definition at line 378 of file error_handling.cpp.
Referenced by sdModeExecuter().
|
extern |
Definition at line 275 of file error_handling.cpp.
Referenced by sdReportStorageInit().
void initEarlyMmcCard | ( | ) |
Definition at line 1015 of file mmc_card.cpp.
Referenced by initHardwareNoConfig().
|
static |
Definition at line 444 of file mmc_card.cpp.
Referenced by initMmc().
|
static |
Definition at line 542 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
void initMmcCard | ( | ) |
Definition at line 1028 of file mmc_card.cpp.
Referenced by commonEarlyInit().
|
static |
Definition at line 434 of file mmc_card.cpp.
Referenced by initMmcCard().
|
static |
Definition at line 948 of file mmc_card.cpp.
Referenced by sdLogger().
|
static |
Definition at line 568 of file mmc_card.cpp.
Referenced by sdModeSwitcher(), and THD_FUNCTION().
void onUsbConnectedNotifyMmcI | ( | void | ) |
Definition at line 426 of file mmc_card.cpp.
Referenced by usb_event().
|
static |
Definition at line 333 of file mmc_card.cpp.
Referenced by sdLoggerCreateFile().
void printFatFsError | ( | const char * | str, |
FRESULT | f_error | ||
) |
Definition at line 273 of file mmc_card.cpp.
Referenced by incLogFileName(), sdFormat(), sdLoggerCreateFile(), and unmountMmc().
|
static |
Definition at line 298 of file mmc_card.cpp.
Referenced by sdStatistics().
|
static |
Definition at line 413 of file mmc_card.cpp.
Referenced by initEarlyMmcCard().
SD_MODE sdCardGetCurrentMode | ( | void | ) |
Definition at line 1049 of file mmc_card.cpp.
Referenced by hellenDisableEn().
void sdCardRemoveReportFiles | ( | ) |
Definition at line 1054 of file mmc_card.cpp.
Referenced by handleCommandX14(), and initEarlyMmcCard().
void sdCardRequestMode | ( | SD_MODE | mode | ) |
Definition at line 1040 of file mmc_card.cpp.
Referenced by handleCommandX14(), hellenDisableEn(), and sdSetMode().
|
static |
Definition at line 732 of file mmc_card.cpp.
Referenced by sdModeSwitcher().
|
static |
Definition at line 652 of file mmc_card.cpp.
Referenced by sdModeExecuter().
|
static |
Definition at line 399 of file mmc_card.cpp.
Referenced by sdLogger(), and sdLoggerStop().
|
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.
Referenced by sdLogger().
|
static |
Definition at line 244 of file mmc_card.cpp.
Referenced by sdStatistics().
|
static |
Definition at line 240 of file mmc_card.cpp.
Referenced by sdLoggerCloseFile(), and sdLoggerCreateFile().
|
static |
Definition at line 708 of file mmc_card.cpp.
Referenced by sdModeSwitcher().
|
static |
Definition at line 721 of file mmc_card.cpp.
Referenced by sdModeSwitchToIdle().
|
static |
Definition at line 848 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
|
static |
Definition at line 785 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
|
static |
Definition at line 762 of file mmc_card.cpp.
Referenced by sdModeSwitcher().
|
static |
Definition at line 870 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
|
static |
Definition at line 323 of file mmc_card.cpp.
Referenced by initEarlyMmcCard().
|
static |
Definition at line 306 of file mmc_card.cpp.
Referenced by initEarlyMmcCard().
Definition at line 186 of file mmc_card.cpp.
Referenced by sdStatistics().
|
static |
Definition at line 980 of file mmc_card.cpp.
Referenced by sdLogger().
|
static |
Definition at line 891 of file mmc_card.cpp.
|
static |
|
static |
Definition at line 606 of file mmc_card.cpp.
Referenced by sdModeSwitchToIdle().
void updateSdCardLiveFlags | ( | void | ) |
Definition at line 1001 of file mmc_card.cpp.
Referenced by updateFlags().
|
static |
Referenced by onUsbConnectedNotifyMmcI(), and useMsdMode().
|
static |
Definition at line 523 of file mmc_card.cpp.
Referenced by THD_FUNCTION().
uint8_t blkbuf[4 *MMCSD_BLOCK_SIZE] |
Definition at line 292 of file mmc_card.cpp.
Referenced by MassStorageController::attachLun(), and attachMsdSdCard().
|
static |
Definition at line 539 of file mmc_card.cpp.
Referenced by deinitMmc(), initMmc(), mountMmc(), sdModeSwitcher(), and updateSdCardLiveFlags().
|
static |
Definition at line 249 of file mmc_card.cpp.
Referenced by printFatFsError().
FIL fd |
Definition at line 287 of file mmc_card.cpp.
Referenced by sdLogger(), sdLoggerCloseFile(), and sdLoggerCreateFile().
BYTE formatBuff[FATFS_CLUSTER_SIZE] |
Definition at line 290 of file mmc_card.cpp.
|
static |
Definition at line 149 of file mmc_card.cpp.
Referenced by mlgLogger(), sdLogger(), sdStatistics(), and sdTriggerLogger().
|
extern |
Definition at line 16 of file mmc_card_util.cpp.
Referenced by incLogFileName(), and prepareLogFileName().
|
static |
Definition at line 296 of file mmc_card.cpp.
Referenced by initEarlyMmcCard(), prepareLogFileName(), sdLoggerCreateFile(), and sdStatistics().
|
static |
|
static |
MMC driver instance.
Definition at line 215 of file mmc_card.cpp.
Referenced by initializeMmcBlockDevice().
|
static |
Definition at line 219 of file mmc_card.cpp.
Referenced by initializeMmcBlockDevice(), and sdStatistics().
MMCDriver MMCD1 |
Definition at line 216 of file mmc_card.cpp.
Referenced by deinitializeMmcBlockDevide(), and initializeMmcBlockDevice().
|
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 { ... } NO_CACHE |
|
static |
Definition at line 493 of file mmc_card.cpp.
|
static |
Definition at line 650 of file mmc_card.cpp.
Referenced by sdLogger(), and sdLoggerStart().
|
static |
Definition at line 649 of file mmc_card.cpp.
Referenced by sdLogger(), and sdLoggerStart().
|
static |
Definition at line 32 of file mmc_card.cpp.
Referenced by sdLoggerIsReady(), and sdLoggerSetReady().
|
static |
Definition at line 193 of file mmc_card.cpp.
Referenced by removeFile(), sdCardGetCurrentMode(), sdCardRemoveReportFiles(), sdModeExecuter(), sdModeSwitcher(), and THD_FUNCTION().
|
static |
Definition at line 197 of file mmc_card.cpp.
Referenced by sdCardRemoveReportFiles(), and sdModeExecuter().
|
static |
Definition at line 191 of file mmc_card.cpp.
Referenced by initializeMmcBlockDevice(), mountMmc(), sdLoggerCreateFile(), sdModeSwitcher(), sdStatistics(), and THD_FUNCTION().
|
static |
Definition at line 173 of file mmc_card.cpp.
Referenced by sdStatusName().
|
static |
Definition at line 195 of file mmc_card.cpp.
Referenced by sdCardRequestMode(), sdModeSwitcher(), and THD_FUNCTION().