mmc_card: isSdCardAlive() is actualy shows state of SD logger
...and not used externally
This commit is contained in:
parent
ab382a0fdf
commit
e0f7b5e46b
|
@ -20,7 +20,7 @@
|
||||||
#include "status_loop.h"
|
#include "status_loop.h"
|
||||||
#include "binary_logging.h"
|
#include "binary_logging.h"
|
||||||
|
|
||||||
static bool fs_ready = false;
|
static bool sdLoggerReady = false;
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
|
||||||
|
@ -124,10 +124,12 @@ static MMCConfig mmccfg = {
|
||||||
*/
|
*/
|
||||||
static NO_CACHE FATFS MMC_FS;
|
static NO_CACHE FATFS MMC_FS;
|
||||||
|
|
||||||
static int fatFsErrors = 0;
|
static void sdLoggerSetReady(bool value) {
|
||||||
|
sdLoggerReady = value;
|
||||||
|
}
|
||||||
|
|
||||||
static void setSdCardReady(bool value) {
|
static bool sdLoggerIsReady(void) {
|
||||||
fs_ready = value;
|
return sdLoggerReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See ff.h FRESULT enum */
|
/* See ff.h FRESULT enum */
|
||||||
|
@ -156,6 +158,8 @@ static const char *fatErrors[] = {
|
||||||
|
|
||||||
// print FAT error function
|
// print FAT error function
|
||||||
void printError(const char *str, FRESULT f_error) {
|
void printError(const char *str, FRESULT f_error) {
|
||||||
|
static int fatFsErrors = 0;
|
||||||
|
|
||||||
if (fatFsErrors++ > 16) {
|
if (fatFsErrors++ > 16) {
|
||||||
// no reason to spam the console
|
// no reason to spam the console
|
||||||
return;
|
return;
|
||||||
|
@ -187,7 +191,7 @@ static void sdStatistics() {
|
||||||
efiPrintf("HS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_hs_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
|
efiPrintf("HS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_hs_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
|
||||||
efiPrintf("LS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_ls_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
|
efiPrintf("LS clock %d Hz", spiGetBaseClock(mmccfg.spip) / (2 << ((mmc_ls_spicfg.cr1 & SPI_CR1_BR_Msk) >> SPI_CR1_BR_Pos)));
|
||||||
#endif
|
#endif
|
||||||
if (isSdCardAlive()) {
|
if (sdLoggerIsReady()) {
|
||||||
efiPrintf("filename=%s size=%d", logName, totalLoggedBytes);
|
efiPrintf("filename=%s size=%d", logName, totalLoggedBytes);
|
||||||
}
|
}
|
||||||
#if EFI_FILE_LOGGING
|
#if EFI_FILE_LOGGING
|
||||||
|
@ -241,15 +245,12 @@ static void createLogFile() {
|
||||||
printError("pre-allocate", err);
|
printError("pre-allocate", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSdCardReady(true); // everything Ok
|
// SD logger is ok
|
||||||
|
sdLoggerSetReady(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeFile(const char *pathx) {
|
|
||||||
if (!isSdCardAlive()) {
|
|
||||||
efiPrintf("Error: No File system is mounted");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static void removeFile(const char *pathx) {
|
||||||
f_unlink(pathx);
|
f_unlink(pathx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,13 +417,8 @@ static bool mountMmc() {
|
||||||
* @return true if we had SD card alive
|
* @return true if we had SD card alive
|
||||||
*/
|
*/
|
||||||
static void unmountMmc() {
|
static void unmountMmc() {
|
||||||
if (!isSdCardAlive()) {
|
// FATFS: Unregister work area prior to discard it
|
||||||
efiPrintf("Error: No File system is mounted. \"mountsd\" first");
|
f_mount(NULL, 0, 0);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
f_mount(NULL, 0, 0); // FATFS: Unregister work area prior to discard it
|
|
||||||
setSdCardReady(false); // status = false
|
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
engine->outputChannels.sd_logging_internal = false;
|
engine->outputChannels.sd_logging_internal = false;
|
||||||
|
@ -487,7 +483,7 @@ public:
|
||||||
SdLogBufferWriter()
|
SdLogBufferWriter()
|
||||||
: m_stream("rusefi_simulator_log.mlg", std::ios::binary | std::ios::trunc)
|
: m_stream("rusefi_simulator_log.mlg", std::ios::binary | std::ios::trunc)
|
||||||
{
|
{
|
||||||
fs_ready = true;
|
sdLoggerReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t writeInternal(const char* buffer, size_t count) override {
|
size_t writeInternal(const char* buffer, size_t count) override {
|
||||||
|
@ -808,10 +804,6 @@ static int sdTriggerLogger() {
|
||||||
|
|
||||||
#endif // EFI_PROD_CODE
|
#endif // EFI_PROD_CODE
|
||||||
|
|
||||||
bool isSdCardAlive(void) {
|
|
||||||
return fs_ready;
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateSdCardLiveFlags() {
|
void updateSdCardLiveFlags() {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
if (cardBlockDevice) {
|
if (cardBlockDevice) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ typedef enum {
|
||||||
|
|
||||||
void initEarlyMmcCard();
|
void initEarlyMmcCard();
|
||||||
void initMmcCard();
|
void initMmcCard();
|
||||||
bool isSdCardAlive();
|
|
||||||
|
|
||||||
void onUsbConnectedNotifyMmcI(void);
|
void onUsbConnectedNotifyMmcI(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue