|
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 | printFatFsError (const char *str, FRESULT f_error) |
| static void | printMmcPinout () |
| static void | sdStatistics () |
| static void | sdSetMode (const char *mode) |
| static void | prepareLogFileName () |
| static int | sdLoggerCreateFile (FIL *fd) |
| Create a new file with the specified name. | |
| static void | sdLoggerCloseFile (FIL *fd) |
| static void | removeFile (const char *pathx) |
| static chibios_rt::BinarySemaphore | usbConnectedSemaphore (true) |
| void | onUsbConnectedNotifyMmcI () |
| static bool | isSdCardEnabled () |
| static BaseBlockDevice * | initializeMmcBlockDevice () |
| static void | deinitializeMmcBlockDevide () |
| static bool | useMsdMode () |
| static bool | initMmc () |
| static void | deinitMmc () |
| static bool | mountMmc () |
| static void | unmountMmc () |
| static int | mlgLogger () |
| static int | sdTriggerLogger () |
| static int | sdLogger (FIL *fd) |
| static void | sdLoggerStart () |
| static void | sdLoggerStop () |
| static bool | sdFormat () |
| static int | sdModeSwitchToIdle (SD_MODE from) |
| static int | sdModeSwitcher () |
| static int | sdModeExecuter () |
| static int | sdReportStorageInit () |
| PUBLIC_API_WEAK bool | boardSdCardEnable () |
| PUBLIC_API_WEAK bool | boardSdCardDisable () |
| static | THD_WORKING_AREA (mmcThreadStack, 3 *UTILITY_THREAD_STACK_SIZE) |
| static | THD_FUNCTION (MMCmonThread, arg) |
| void | updateSdCardLiveFlags () |
| void | initEarlyMmcCard () |
| void | initMmcCard () |
| void | sdCardRequestMode (SD_MODE mode) |
| SD_MODE | sdCardGetCurrentMode () |
| void | sdCardRemoveReportFiles () |
Variables | ||
| static bool | sdLoggerReady = false | |
| static NO_CACHE SdLogBufferWriter | logBuffer | |
| static const 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 161 of file mmc_card.cpp.
| PUBLIC_API_WEAK bool boardSdCardDisable | ( | ) |
Definition at line 899 of file mmc_card.cpp.
Referenced by THD_FUNCTION().

| PUBLIC_API_WEAK bool boardSdCardEnable | ( | ) |
Definition at line 894 of file mmc_card.cpp.
Referenced by THD_FUNCTION().

|
static |
Definition at line 490 of file mmc_card.cpp.
Referenced by deinitMmc().

|
static |
Definition at line 569 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 1028 of file mmc_card.cpp.
Referenced by initHardwareNoConfig().


|
static |
Definition at line 455 of file mmc_card.cpp.
Referenced by initMmc().


|
static |
Definition at line 553 of file mmc_card.cpp.
Referenced by THD_FUNCTION().


| void initMmcCard | ( | ) |
Definition at line 1043 of file mmc_card.cpp.
Referenced by commonEarlyInit().


|
static |
Definition at line 445 of file mmc_card.cpp.
Referenced by initMmcCard().


|
static |
Definition at line 961 of file mmc_card.cpp.
Referenced by sdLogger().


|
static |
Definition at line 579 of file mmc_card.cpp.
Referenced by sdModeSwitcher(), and THD_FUNCTION().


| void onUsbConnectedNotifyMmcI | ( | ) |
Definition at line 437 of file mmc_card.cpp.
Referenced by usb_event().


|
static |
Definition at line 344 of file mmc_card.cpp.
Referenced by sdLoggerCreateFile().


| void printFatFsError | ( | const char * | str, |
| FRESULT | f_error | ||
| ) |
Definition at line 274 of file mmc_card.cpp.
Referenced by incLogFileName(), mountMmc(), sdFormat(), sdLoggerCreateFile(), and unmountMmc().

|
static |
Definition at line 299 of file mmc_card.cpp.
Referenced by sdStatistics().


|
static |
Definition at line 424 of file mmc_card.cpp.
Referenced by initEarlyMmcCard().

| SD_MODE sdCardGetCurrentMode | ( | ) |
Definition at line 1064 of file mmc_card.cpp.
Referenced by hellenDisableEn().

| void sdCardRemoveReportFiles | ( | ) |
Definition at line 1069 of file mmc_card.cpp.
Referenced by handleCommandX14(), and initEarlyMmcCard().

| void sdCardRequestMode | ( | SD_MODE | mode | ) |
Definition at line 1055 of file mmc_card.cpp.
Referenced by handleCommandX14(), hellenDisableEn(), and sdSetMode().

|
static |
Definition at line 745 of file mmc_card.cpp.
Referenced by sdModeSwitcher().


|
static |
Definition at line 665 of file mmc_card.cpp.
Referenced by sdModeExecuter().


|
static |
Definition at line 410 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 370 of file mmc_card.cpp.
Referenced by sdLogger().


|
static |
Definition at line 245 of file mmc_card.cpp.
Referenced by sdStatistics().

|
static |
Definition at line 241 of file mmc_card.cpp.
Referenced by sdLoggerCloseFile(), and sdLoggerCreateFile().

|
static |
Definition at line 721 of file mmc_card.cpp.
Referenced by sdModeSwitcher().


|
static |
Definition at line 734 of file mmc_card.cpp.
Referenced by sdModeSwitchToIdle().


|
static |
Definition at line 861 of file mmc_card.cpp.
Referenced by THD_FUNCTION().


|
static |
Definition at line 798 of file mmc_card.cpp.
Referenced by THD_FUNCTION().


|
static |
Definition at line 775 of file mmc_card.cpp.
Referenced by sdModeSwitcher().


|
static |
Definition at line 883 of file mmc_card.cpp.
Referenced by THD_FUNCTION().


|
static |
Definition at line 334 of file mmc_card.cpp.
Referenced by initEarlyMmcCard().


|
static |
Definition at line 311 of file mmc_card.cpp.
Referenced by initEarlyMmcCard().


Definition at line 187 of file mmc_card.cpp.
Referenced by sdStatistics().

|
static |
Definition at line 993 of file mmc_card.cpp.
Referenced by sdLogger().


|
static |
Definition at line 904 of file mmc_card.cpp.

|
static |
|
static |
Definition at line 618 of file mmc_card.cpp.
Referenced by sdModeSwitchToIdle().


| void updateSdCardLiveFlags | ( | ) |
Definition at line 1014 of file mmc_card.cpp.
Referenced by updateFlags().

|
static |
Referenced by onUsbConnectedNotifyMmcI(), and useMsdMode().

|
static |
Definition at line 534 of file mmc_card.cpp.
Referenced by THD_FUNCTION().


| uint8_t blkbuf[4 *MMCSD_BLOCK_SIZE] |
Definition at line 293 of file mmc_card.cpp.
Referenced by MassStorageController::attachLun(), and attachMsdSdCard().
|
static |
Definition at line 550 of file mmc_card.cpp.
Referenced by deinitMmc(), initMmc(), mountMmc(), sdModeSwitcher(), and updateSdCardLiveFlags().
|
static |
Definition at line 250 of file mmc_card.cpp.
Referenced by printFatFsError().
| FIL fd |
Definition at line 288 of file mmc_card.cpp.
Referenced by sdLogger(), sdLoggerCloseFile(), and sdLoggerCreateFile().
| BYTE formatBuff[FATFS_CLUSTER_SIZE] |
Definition at line 291 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 297 of file mmc_card.cpp.
Referenced by initEarlyMmcCard(), prepareLogFileName(), sdLoggerCreateFile(), and sdStatistics().
|
static |
|
static |
MMC driver instance.
Definition at line 216 of file mmc_card.cpp.
Referenced by initializeMmcBlockDevice().
|
static |
Definition at line 220 of file mmc_card.cpp.
Referenced by initializeMmcBlockDevice(), and sdStatistics().
| MMCDriver MMCD1 |
Definition at line 217 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 211 of file mmc_card.cpp.
Referenced by initializeMmcBlockDevice(), and sdStatistics().
| union { ... } NO_CACHE |
|
static |
Definition at line 504 of file mmc_card.cpp.
|
static |
Definition at line 663 of file mmc_card.cpp.
Referenced by sdLogger(), and sdLoggerStart().
|
static |
Definition at line 662 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 194 of file mmc_card.cpp.
Referenced by removeFile(), sdCardGetCurrentMode(), sdCardRemoveReportFiles(), sdModeExecuter(), sdModeSwitcher(), and THD_FUNCTION().
|
static |
Definition at line 198 of file mmc_card.cpp.
Referenced by sdCardRemoveReportFiles(), and sdModeExecuter().
|
static |
Definition at line 192 of file mmc_card.cpp.
Referenced by initializeMmcBlockDevice(), mountMmc(), sdLoggerCreateFile(), sdModeSwitcher(), sdStatistics(), and THD_FUNCTION().
|
static |
Definition at line 174 of file mmc_card.cpp.
Referenced by sdStatusName().
|
static |
Definition at line 196 of file mmc_card.cpp.
Referenced by sdCardRequestMode(), sdModeSwitcher(), and THD_FUNCTION().