diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index c6fb1a07bd..2d7626425c 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1452,11 +1452,6 @@ void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { for (int i = 0;i < CLT_CURVE_SIZE;i++) { engineConfiguration->cltIdleRpmBins[i] = fixNegativeZero(engineConfiguration->cltIdleRpmBins[i]); } - // having zeros in unsued fields is important for REO CRC match - engineConfiguration->unusedAt712 = 0; - engineConfiguration->unusedAt716 = 0; - engineConfiguration->unusedAt720 = 0; - engineConfiguration->unusedAt724 = 0; } void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX) { diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 4a6416dcf2..abc272f3f8 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -695,10 +695,10 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) * linking process which is the way to raise the alarm * * You get "cannot move location counter backwards" linker error when you run out of RAM. When you run out of RAM you shall reduce these - * UNUSED_SIZE contants. + * UNUSED_SIZE constants. */ #ifndef RAM_UNUSED_SIZE -#define RAM_UNUSED_SIZE 8600 +#define RAM_UNUSED_SIZE 9600 #endif #ifndef CCM_UNUSED_SIZE #define CCM_UNUSED_SIZE 2900 diff --git a/firmware/development/hw_layer/poten.cpp b/firmware/development/hw_layer/poten.cpp index 177a71ab65..be6283262b 100644 --- a/firmware/development/hw_layer/poten.cpp +++ b/firmware/development/hw_layer/poten.cpp @@ -74,7 +74,7 @@ static void sendToPot(Mcp42010Driver *driver, int channel, int value) { spiSend(driver->spi, 1, &word); spiUnselect(driver->spi); spiStop(driver->spi); - unlockSpi(); + unlockSpi(SPI_NONE); } void setPotResistance(Mcp42010Driver *driver, int channel, int resistance) { diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index 2ebcd3c299..b6e88a183f 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -88,7 +88,7 @@ void lockSpi(spi_device_e device) { chMtxLock(&spiMtx); } -void unlockSpi(void) { +void unlockSpi(spi_device_e device) { chMtxUnlock(&spiMtx); } diff --git a/firmware/hw_layer/hardware.h b/firmware/hw_layer/hardware.h index a7acd7028f..5ee79a8083 100644 --- a/firmware/hw_layer/hardware.h +++ b/firmware/hw_layer/hardware.h @@ -35,7 +35,7 @@ int getSpiPrescaler(spi_speed_e speed, spi_device_e device); EXTERNC SPIDriver * getSpiDevice(spi_device_e spiDevice); void turnOnSpi(spi_device_e device); void lockSpi(spi_device_e device); -void unlockSpi(void); +void unlockSpi(spi_device_e device); brain_pin_e getMisoPin(spi_device_e device); brain_pin_e getMosiPin(spi_device_e device); brain_pin_e getSckPin(spi_device_e device); diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index 02bf4c3c32..6989bc3e6a 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -52,8 +52,10 @@ static int totalSyncCounter = 0; #define LOG_INDEX_FILENAME "index.txt" -#define RUSEFI_LOG_PREFIX "rusefi_" -#define PREFIX_LEN 7 +#define DOT_MLG ".mlg" + +#define RUSEFI_LOG_PREFIX "re_" +#define PREFIX_LEN 3 #define SHORT_TIME_LEN 13 #define LS_RESPONSE "ls_result" @@ -69,6 +71,8 @@ static int totalSyncCounter = 0; extern const USBConfig msdusbcfg; #endif /* HAL_USE_USB_MSD */ +#define LOCK_SD_SPI lockSpi(engineConfiguration->sdCardSpiDevice) +#define UNLOCK_SD_SPI unlockSpi(engineConfiguration->sdCardSpiDevice) static THD_WORKING_AREA(mmcThreadStack,3 * UTILITY_THREAD_STACK_SIZE); // MMC monitor thread @@ -145,7 +149,7 @@ static void sdStatistics(void) { } static void incLogFileName(void) { - lockSpi(SPI_NONE); + LOCK_SD_SPI; memset(&FDCurrFile, 0, sizeof(FIL)); // clear the memory FRESULT err = f_open(&FDCurrFile, LOG_INDEX_FILENAME, FA_READ); // This file has the index for next log file name @@ -177,20 +181,22 @@ static void incLogFileName(void) { f_write(&FDCurrFile, (void*)data, strlen(data), &result); f_close(&FDCurrFile); scheduleMsg(&logger, "Done %d", logFileIndex); - unlockSpi(); + UNLOCK_SD_SPI; } static void prepareLogFileName(void) { strcpy(logName, RUSEFI_LOG_PREFIX); - bool result = dateToStringShort(&logName[PREFIX_LEN]); char *ptr; +/* TS SD protocol supports only short 8 symbol file names :( + + bool result = dateToStringShort(&logName[PREFIX_LEN]); if (result) { ptr = &logName[PREFIX_LEN + SHORT_TIME_LEN]; } else { + */ ptr = itoa10(&logName[PREFIX_LEN], logFileIndex); - } - strcat(ptr, ".mlg"); - +// } + strcat(ptr, DOT_MLG); } /** @@ -200,13 +206,13 @@ static void prepareLogFileName(void) { * so that we can later append to that file */ static void createLogFile(void) { - lockSpi(SPI_NONE); + LOCK_SD_SPI; memset(&FDLogFile, 0, sizeof(FIL)); // clear the memory prepareLogFileName(); FRESULT err = f_open(&FDLogFile, logName, FA_OPEN_ALWAYS | FA_WRITE); // Create new file if (err != FR_OK && err != FR_EXIST) { - unlockSpi(); + UNLOCK_SD_SPI; sdStatus = SD_STATE_OPEN_FAILED; warning(CUSTOM_ERR_SD_MOUNT_FAILED, "SD: mount failed"); printError("FS mount failed", err); // else - show error @@ -215,7 +221,7 @@ static void createLogFile(void) { err = f_lseek(&FDLogFile, f_size(&FDLogFile)); // Move to end of the file to append data if (err) { - unlockSpi(); + UNLOCK_SD_SPI; sdStatus = SD_STATE_SEEK_FAILED; warning(CUSTOM_ERR_SD_SEEK_FAILED, "SD: seek failed"); printError("Seek error", err); @@ -223,7 +229,7 @@ static void createLogFile(void) { } f_sync(&FDLogFile); setSdCardReady(true); // everything Ok - unlockSpi(); + UNLOCK_SD_SPI; } static void removeFile(const char *pathx) { @@ -231,10 +237,10 @@ static void removeFile(const char *pathx) { scheduleMsg(&logger, "Error: No File system is mounted"); return; } - lockSpi(SPI_NONE); + LOCK_SD_SPI; f_unlink(pathx); - unlockSpi(); + UNLOCK_SD_SPI; } int @@ -262,14 +268,14 @@ static void listDirectory(const char *path) { scheduleMsg(&logger, "Error: No File system is mounted"); return; } - lockSpi(SPI_NONE); + LOCK_SD_SPI; DIR dir; FRESULT res = f_opendir(&dir, path); if (res != FR_OK) { scheduleMsg(&logger, "Error opening directory %s", path); - unlockSpi(); + UNLOCK_SD_SPI; return; } @@ -295,7 +301,7 @@ static void listDirectory(const char *path) { // (fno.fdate >> 5) & 15, fno.fdate & 31, (fno.ftime >> 11), (fno.ftime >> 5) & 63, fno.fsize, // fno.fname); } - unlockSpi(); + UNLOCK_SD_SPI; } static int errorReported = FALSE; // this is used to report the error only once @@ -319,7 +325,7 @@ void appendToLog(const char *line, size_t lineLength) { } totalLoggedBytes += lineLength; - lockSpi(SPI_NONE); + LOCK_SD_SPI; FRESULT err = f_write(&FDLogFile, line, lineLength, &bytesWritten); if (bytesWritten < lineLength) { printError("write error or disk full", err); // error or disk full @@ -338,7 +344,7 @@ void appendToLog(const char *line, size_t lineLength) { } } - unlockSpi(); + UNLOCK_SD_SPI; } /* @@ -382,12 +388,12 @@ static void MMCmount(void) { } // Performs the initialization procedure on the inserted card. - lockSpi(SPI_NONE); + LOCK_SD_SPI; sdStatus = SD_STATE_CONNECTING; if (mmcConnect(&MMCD1) != HAL_SUCCESS) { sdStatus = SD_STATE_NOT_CONNECTED; warning(CUSTOM_OBD_MMC_ERROR, "Can't connect or mount MMC/SD"); - unlockSpi(); + UNLOCK_SD_SPI; return; } @@ -415,7 +421,7 @@ static void MMCmount(void) { //} - unlockSpi(); + UNLOCK_SD_SPI; #if HAL_USE_USB_MSD sdStatus = SD_STATE_MOUNTED; return;