auto-sync

This commit is contained in:
rusEfi 2015-07-13 20:02:18 -04:00
parent f7e8f1f567
commit b3bb926ee8
5 changed files with 23 additions and 10 deletions

View File

@ -14,6 +14,9 @@
#include "flash.h"
#include "rusefi.h"
// this message is part of console API, see FLASH_SUCCESS_MSG in java code
#define FLASH_SUCCESS_MSG "FLASH_SUCESS"
#if EFI_TUNER_STUDIO || defined(__DOXYGEN__)
#include "tunerstudio.h"
#endif
@ -67,15 +70,20 @@ void writeToFlashNow(void) {
persistentState.size = PERSISTENT_SIZE;
persistentState.version = FLASH_DATA_VERSION;
scheduleMsg(logger, "flash compatible with %d", persistentState.version);
crc_t result = flashStateCrc(&persistentState);
persistentState.value = result;
crc_t crcResult = flashStateCrc(&persistentState);
persistentState.value = crcResult;
scheduleMsg(logger, "Reseting flash: size=%d", PERSISTENT_SIZE);
flashErase(FLASH_ADDR, PERSISTENT_SIZE);
scheduleMsg(logger, "Flashing with CRC=%d", result);
scheduleMsg(logger, "Flashing with CRC=%d", crcResult);
efitimems_t nowMs = currentTimeMillis();
result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE);
scheduleMsg(logger, "Flash programmed in (ms): %d", currentTimeMillis() - nowMs);
scheduleMsg(logger, "Flashing result: %d", result);
int result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE);
scheduleMsg(logger, "Flash programmed in %dms", currentTimeMillis() - nowMs);
bool_t isSuccess = result == FLASH_RETURN_SUCCESS;
if (isSuccess) {
scheduleMsg(logger, FLASH_SUCCESS_MSG);
} else {
scheduleMsg(logger, "Flashing failed");
}
maxLockTime = 0;
}

View File

@ -915,7 +915,6 @@ static void printAllInfo(void) {
#endif
#if EFI_PROD_CODE
scheduleMsg(&logger, "console mode jumper: %s", boolToString(!GET_CONSOLE_MODE_VALUE()));
scheduleMsg(&logger, "board test mode jumper: %s", boolToString(GET_BOARD_TEST_MODE_VALUE()));
#endif
}

View File

@ -282,7 +282,12 @@ void initHardware(Logging *l) {
mySetPadMode2("board test", boardConfiguration->boardTestModeJumperPin,
PAL_MODE_INPUT_PULLUP);
bool isBoardTestMode_b = GET_BOARD_TEST_MODE_VALUE();
bool isBoardTestMode_b = (!palReadPad(getHwPort(boardConfiguration->boardTestModeJumperPin), getHwPin(boardConfiguration->boardTestModeJumperPin)));
// we can now relese this pin, it is actually used as output sometimes
unmarkPin(boardConfiguration->boardTestModeJumperPin);
#if HAL_USE_ADC || defined(__DOXYGEN__)
initAdcInputs(isBoardTestMode_b);

View File

@ -41,8 +41,6 @@ brain_pin_e getSckPin(spi_device_e device);
#endif /* HAL_USE_SPI */
#define GET_BOARD_TEST_MODE_VALUE() (!palReadPad(getHwPort(boardConfiguration->boardTestModeJumperPin), getHwPin(boardConfiguration->boardTestModeJumperPin)))
#ifdef __cplusplus
#if EFI_PROD_CODE

View File

@ -149,6 +149,9 @@ void initPinRepository(void) {
addConsoleAction("pins", reportPins);
}
/**
* See also unmarkPin()
*/
static inline void markUsed(int index, const char *msg) {
PIN_USED[index] = msg;
totalPinsUsed++;