From 0f98b4625c01d2184b13dd521ce4231cd0db39db Mon Sep 17 00:00:00 2001 From: rusEfi Date: Tue, 5 Jul 2016 09:01:23 -0400 Subject: [PATCH] auto-sync --- firmware/console/eficonsole.cpp | 12 ------ .../controllers/algo/engine_configuration.cpp | 2 + firmware/hw_layer/mmc_card.cpp | 37 +++++++++++++++++-- firmware/rusefi.cpp | 2 +- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/firmware/console/eficonsole.cpp b/firmware/console/eficonsole.cpp index 8b4a4e7325..5e1df9f731 100644 --- a/firmware/console/eficonsole.cpp +++ b/firmware/console/eficonsole.cpp @@ -31,18 +31,6 @@ static LoggingWithStorage logger("console"); -//static char fatalErrorMessage[200]; - -//void fatal3(char *msg, char *file, int line) { -// strncpy(fatalErrorMessage, msg, sizeof(fatalErrorMessage) - 1); -// fatalErrorMessage[sizeof(fatalErrorMessage) - 1] = 0; // just to be sure -//#if EFI_CUSTOM_PANIC_METHOD -// chDbgPanic3(fatalErrorMessage, file, line); -//#else -// chDbgPanic(fatalErrorMessage); -//#endif -//} - static void myfatal(void) { chDbgCheck(0, "my fatal"); } diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 59cf058a46..4bc76920e4 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -508,6 +508,8 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { // performance optimization boardConfiguration->sensorChartMode = SC_OFF; + engineConfiguration->storageMode = MS_AUTO; + engineConfiguration->map.sensor.hwChannel = EFI_ADC_4; engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index 2b4f1f3d71..1a2fccfa01 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -24,6 +24,11 @@ #include "hardware.h" #include "engine_configuration.h" #include "status_loop.h" +#include "usb_msd.h" +#include "usb_msd_cfg.h" + + +EXTERN_ENGINE; #define LOG_INDEX_FILENAME "index.txt" #define RUSEFI_LOG_PREFIX "rus" @@ -32,6 +37,12 @@ extern board_configuration_s *boardConfiguration; +static USBDriver *ms_usb_driver = &USBD1; +static USBMassStorageDriver UMSD1; +extern const USBConfig msd_usb_config; + + + #define PUSHPULLDELAY 500 static THD_WORKING_AREA(mmcThreadStack,UTILITY_THREAD_STACK_SIZE); // MMC monitor thread @@ -278,6 +289,26 @@ static void MMCmount(void) { return; } + + if (engineConfiguration->storageMode == MS_ALWAYS) { + BaseBlockDevice *bbdp = (BaseBlockDevice*)&MMCD1; +// const usb_msd_driver_state_t msd_driver_state = msdInit(ms_usb_driver, bbdp, &UMSD1, USB_MS_DATA_EP, USB_MSD_INTERFACE_NUMBER); +// UMSD1.chp = NULL; +// +// /*Disconnect the USB Bus*/ +// usbDisconnectBus(ms_usb_driver); +// chThdSleepMilliseconds(200); +// +// /*Start the useful functions*/ +// msdStart(&UMSD1); +// usbStart(ms_usb_driver, &msd_usb_config); +// +// /*Connect the USB Bus*/ +// usbConnectBus(ms_usb_driver); + + } + + unlockSpi(); // if Ok - mount FS now memset(&MMC_FS, 0, sizeof(FATFS)); @@ -325,9 +356,9 @@ void initMmcCard(void) { * FYI: SPI does not work with CCM memory, be sure to have main() stack in RAM, not in CCMRAM */ - // start to initialize MMC/SD - mmcObjectInit(&MMCD1); - mmcStart(&MMCD1, &mmccfg); +// // start to initialize MMC/SD +// mmcObjectInit(&MMCD1); +// mmcStart(&MMCD1, &mmccfg); chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t) MMCmonThread, NULL); diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 8e9b520116..2258e1639a 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -173,7 +173,7 @@ void runRusEfi(void) { #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) /** * This is so early because we want to init logger - * which would be used while finding trigger synch index + * which would be used while finding trigger sync index * while reading configuration */ initTriggerDecoderLogger(&sharedLogger);