auto-sync
This commit is contained in:
parent
2067b4c3c0
commit
220a66d40d
|
@ -236,6 +236,7 @@ void prepareVoidConfiguration(engine_configuration_s *activeConfiguration) {
|
|||
void setDefaultBasePins(DECLARE_ENGINE_PARAMETER_F) {
|
||||
engineConfiguration->fatalErrorPin = GPIOD_14;
|
||||
engineConfiguration->warninigPin = GPIOD_13;
|
||||
engineConfiguration->configResetPin = GPIOB_1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -681,7 +682,6 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
|
|||
engineConfiguration->directSelfStimulation = true;
|
||||
#endif /* */
|
||||
engineConfiguration->engineType = engineType;
|
||||
engineConfiguration->headerMagicValue = HEADER_MAGIC_NUMBER;
|
||||
|
||||
/**
|
||||
* And override them with engine-specific defaults
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
// WARNING: by default, our small enums are ONE BYTE. this one is made 4-byte with the 'ENUM_32_BITS' hack
|
||||
|
||||
// 19010105 decimal
|
||||
#define HEADER_MAGIC_NUMBER 0x1221239
|
||||
|
||||
/**
|
||||
* @brief Engine configuration.
|
||||
* Values in this data structure are adjustable and persisted in on-board flash RAM.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Dec 21 19:26:52 EST 2015
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Dec 21 21:22:24 EST 2015
|
||||
// begin
|
||||
#include "rusefi_types.h"
|
||||
typedef struct {
|
||||
|
@ -751,10 +751,9 @@ typedef struct {
|
|||
*/
|
||||
engine_type_e engineType;
|
||||
/**
|
||||
* this magic number is used to make sure that what we read from Flash is in fact some configuration
|
||||
* offset 4
|
||||
*/
|
||||
int headerMagicValue;
|
||||
int unusedOffset4;
|
||||
/**
|
||||
* offset 8
|
||||
*/
|
||||
|
@ -1596,4 +1595,4 @@ typedef struct {
|
|||
} persistent_config_s;
|
||||
|
||||
// end
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Dec 21 19:26:52 EST 2015
|
||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Dec 21 21:22:24 EST 2015
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
#define engineConfiguration_offset_hex 0
|
||||
#define engineType_offset 0
|
||||
#define engineType_offset_hex 0
|
||||
#define headerMagicValue_offset 4
|
||||
#define headerMagicValue_offset_hex 4
|
||||
#define unusedOffset4_offset 4
|
||||
#define unusedOffset4_offset_hex 4
|
||||
#define injector_offset 8
|
||||
#define injector_offset_hex 8
|
||||
#define injector_flow_offset 8
|
||||
|
|
|
@ -100,31 +100,45 @@ static void doResetConfiguration(void) {
|
|||
resetConfigurationExt(logger, engineConfiguration->engineType PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
static bool hasValidEngineType(engine_configuration_s *engineConfiguration) {
|
||||
uint32_t ordinal = (uint32_t)engineConfiguration->engineType;
|
||||
return ordinal < ET_UNUSED && engineConfiguration->headerMagicValue == HEADER_MAGIC_NUMBER;
|
||||
}
|
||||
typedef enum {
|
||||
OK = 0,
|
||||
CRC_FAILED = 1,
|
||||
INCOMPATIBLE_VERSION = 2,
|
||||
RESET_REQUESTED = 3
|
||||
} persisted_configuration_state_e;
|
||||
|
||||
persisted_configuration_state_e flashState;
|
||||
|
||||
void readFromFlash(void) {
|
||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "read f");
|
||||
printMsg(logger, "readFromFlash()");
|
||||
flashRead(FLASH_ADDR, (char *) &persistentState, PERSISTENT_SIZE);
|
||||
|
||||
persisted_configuration_state_e result;
|
||||
|
||||
if (!isValidCrc(&persistentState)) {
|
||||
printMsg(logger, "Need to reset flash to default due to CRC");
|
||||
result = CRC_FAILED;
|
||||
resetConfigurationExt(logger, DEFAULT_ENGINE_TYPE PASS_ENGINE_PARAMETER);
|
||||
} else if (persistentState.version == FLASH_DATA_VERSION && persistentState.size == PERSISTENT_SIZE) {
|
||||
printMsg(logger, "Got valid configuration from flash!");
|
||||
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
|
||||
} else if (hasValidEngineType(engineConfiguration)) {
|
||||
printMsg(logger, "Resetting but saving engine type [%d]", engineConfiguration->engineType);
|
||||
} else if (persistentState.version != FLASH_DATA_VERSION || persistentState.size != PERSISTENT_SIZE) {
|
||||
result = INCOMPATIBLE_VERSION;
|
||||
resetConfigurationExt(logger, engineConfiguration->engineType PASS_ENGINE_PARAMETER);
|
||||
} else {
|
||||
printMsg(logger, "Need to reset flash to default due to version change");
|
||||
resetConfigurationExt(logger, DEFAULT_ENGINE_TYPE PASS_ENGINE_PARAMETER);
|
||||
/**
|
||||
* At this point we know that CRC and version number is what we expect. Safe to assume it's a valid configuration.
|
||||
*/
|
||||
result = OK;
|
||||
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
// we can only change the state after the CRC check
|
||||
engineConfiguration->firmwareVersion = getRusEfiVersion();
|
||||
|
||||
if (result == CRC_FAILED) {
|
||||
printMsg(logger, "Need to reset flash to default due to CRC");
|
||||
} else if (result == INCOMPATIBLE_VERSION) {
|
||||
printMsg(logger, "Resetting but saving engine type [%d]", engineConfiguration->engineType);
|
||||
} else {
|
||||
printMsg(logger, "Got valid configuration from flash!");
|
||||
}
|
||||
}
|
||||
|
||||
static void rewriteConfig(void) {
|
||||
|
|
|
@ -132,7 +132,7 @@ end_struct
|
|||
custom engine_type_e 4 bits, S32, @OFFSET@, [0:2], "AUDI_AAN", "DODGE_NEON_1995", "FORD_ASPIRE_1996", "FORD_FIESTA", "NISSAN_PRIMERA", "HONDA_ACCORD", "FORD_INLINE_6_1995", "GY6_139QMB"
|
||||
engine_type_e engineType;http://rusefi.com/wiki/index.php?title=Manual:Engine_Type
|
||||
|
||||
int headerMagicValue;this magic number is used to make sure that what we read from Flash is in fact some configuration
|
||||
int unusedOffset4;
|
||||
|
||||
struct injector_s
|
||||
float flow;cc/min, cubic centimeter per minute\nBy the way, g/s = 0.125997881 * (lb/hr)\ng/s = 0.125997881 * (cc/min)/10.5\ng/s = 0.0119997981 * cc/min;"cm3/min", 1, 0, 0, 1000, 2
|
||||
|
|
|
@ -47,12 +47,12 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Dec 21 19:26:52 EST 2015
|
||||
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Dec 21 21:22:24 EST 2015
|
||||
|
||||
pageSize = 16088
|
||||
page = 1
|
||||
engineType = bits, S32, 0, [0:2], "AUDI_AAN", "DODGE_NEON_1995", "FORD_ASPIRE_1996", "FORD_FIESTA", "NISSAN_PRIMERA", "HONDA_ACCORD", "FORD_INLINE_6_1995", "GY6_139QMB"
|
||||
;skipping headerMagicValue offset 4
|
||||
;skipping unusedOffset4 offset 4
|
||||
injector_flow = scalar, F32, 8, "cm3/min", 1, 0, 0, 1000, 2
|
||||
injector_lag = scalar, F32, 12, "msec", 1, 0, -10, 25.50, 2
|
||||
injector_battLagCorrBins = array, F32, 16, [8], "V", 1, 0, 0.0, 20.0, 2
|
||||
|
|
Loading…
Reference in New Issue