diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 455a90e8de..61952a014c 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -535,6 +535,8 @@ void setTest33816EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // yellow CONFIG(mc33816_driven) = GPIOD_6; + CONFIG(mc33816_flag0) = GPIOD_3; + // enable_spi 3 CONFIG(is_enabled_spi_3) = true; // Wire up spi3 diff --git a/firmware/hw_layer/mc33816.cpp b/firmware/hw_layer/mc33816.cpp index 18b6c1a9f1..9c3b48e264 100644 --- a/firmware/hw_layer/mc33816.cpp +++ b/firmware/hw_layer/mc33816.cpp @@ -28,6 +28,9 @@ static OutputPin chipSelect; static OutputPin resetB; static OutputPin driven; +static bool flag0before = false; +static bool flag0after = false; + static unsigned short mcChipId; static Logging* logger; @@ -48,6 +51,12 @@ static SPIDriver *driver; static void showStats() { // x9D is product code or something, and 43 is the revision? scheduleMsg(logger, "MC %x %s", mcChipId, (mcChipId >> 8) == 0x9D ? "hooray!" : "not hooray :("); + + if (CONFIG(mc33816_flag0) != GPIO_UNASSIGNED) { + scheduleMsg(logger, "flag0 before %d after %d", flag0before, flag0after); + } else { + scheduleMsg(logger, "No flag0"); + } } // Mostly unused @@ -310,6 +319,12 @@ void initMc33816(Logging *sharedLogger) { chThdSleepMilliseconds(10); resetB.setValue(1); chThdSleepMilliseconds(10); + if (CONFIG(mc33816_flag0) != GPIO_UNASSIGNED) { + efiSetPadMode("mc33816 flag0", CONFIG(mc33816_flag0), getInputMode(PI_DEFAULT)); + + flag0before = efiReadPin(CONFIG(startStopButtonPin)); + } + setup_spi(); mcChipId = readId(); @@ -317,7 +332,14 @@ void initMc33816(Logging *sharedLogger) { download_RAM(CODE_RAM1); // transfers code RAM1 download_RAM(CODE_RAM2); // transfers code RAM2 download_RAM(DATA_RAM); // transfers data RAM + /** + * current configuration of REG_MAIN would toggle flag0 from LOW to HIGH + */ download_register(REG_MAIN); // download main register configurations + if (CONFIG(mc33816_flag0) != GPIO_UNASSIGNED) { + flag0after = efiReadPin(CONFIG(startStopButtonPin)); + } + download_register(REG_CH1); // download channel 1 register configurations download_register(REG_CH2); // download channel 2 register configurations download_register(REG_IO); // download IO register configurations diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index a7f7f04bab..97e19ed6b6 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -979,7 +979,7 @@ int16_t tps2Min;Closed throttle#2. todo: extract these two fields into a structu int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\nSee also tps1_1AdcChannel\nset tps2_max X;"ADC", 1, 0, 0, 1023, 0 output_pin_e starterControlPin;See also startStopButtonPin pin_input_mode_e startStopButtonMode; - uint8_t[1] unusedFormerWarmupAfrPid; + brain_pin_e mc33816_flag0; uint8_t tachPulsePerRev;;"Pulse", 1, 0, 1.0, 255.0, 0 ! todo: mapErrorDetectionIdleTooLow? 30kPa is usually lowest on idle diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index f512f95ad1..f63e070f47 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1753,6 +1753,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" dialog = allPins1_1 field = mc33816_cs, mc33816_cs field = mc33816_rstb, mc33816_rstb + field = mc33816_flag0, mc33816_flag0 field = high_fuel_pressure_sensor_1, high_fuel_pressure_sensor_1 field = high_fuel_pressure_sensor_2, high_fuel_pressure_sensor_2 field = mc33816_driven, mc33816_driven diff --git a/java_console/models/src/com/rusefi/config/generated/Fields.java b/java_console/models/src/com/rusefi/config/generated/Fields.java index c0a9f96ba2..487f95a4f0 100644 --- a/java_console/models/src/com/rusefi/config/generated/Fields.java +++ b/java_console/models/src/com/rusefi/config/generated/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Mon Apr 13 09:22:02 EDT 2020 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Mon Apr 13 18:54:18 EDT 2020 // by class com.rusefi.output.FileJavaFieldsConsumer import com.rusefi.config.*; @@ -1048,6 +1048,7 @@ public class Fields { public static final int maxKnockSubDeg_offset_hex = 228; public static final int mc33816_cs_offset = 3107; public static final int mc33816_driven_offset = 2607; + public static final int mc33816_flag0_offset = 1774; public static final int mc33816_rstb_offset = 2606; public static final int mc33816spiDevice_offset = 4001; public static final int mc33972_cs_offset = 678; @@ -1466,7 +1467,6 @@ public class Fields { public static final int unusedBit_34_31_offset = 76; public static final int unusedErrorPin_offset = 2040; public static final int unusedFlexFuelSensor_offset = 3100; - public static final int unusedFormerWarmupAfrPid_offset = 1774; public static final int unusedOldBiquad_offset = 2332; public static final int unusedOneMoreHere_offset = 760; public static final int unusedSomethingWasHere_offset = 2416; @@ -2197,7 +2197,7 @@ public class Fields { public static final Field TPS2MAX = Field.create("TPS2MAX", 1770, FieldType.INT16); public static final Field STARTERCONTROLPIN = Field.create("STARTERCONTROLPIN", 1772, FieldType.INT8, output_pin_e); public static final Field STARTSTOPBUTTONMODE = Field.create("STARTSTOPBUTTONMODE", 1773, FieldType.INT8); - public static final Field UNUSEDFORMERWARMUPAFRPID = Field.create("UNUSEDFORMERWARMUPAFRPID", 1774, FieldType.INT8); + public static final Field MC33816_FLAG0 = Field.create("MC33816_FLAG0", 1774, FieldType.INT8, brain_pin_e); public static final Field TACHPULSEPERREV = Field.create("TACHPULSEPERREV", 1775, FieldType.INT8); public static final Field MAPERRORDETECTIONTOOLOW = Field.create("MAPERRORDETECTIONTOOLOW", 1776, FieldType.FLOAT); public static final Field MAPERRORDETECTIONTOOHIGH = Field.create("MAPERRORDETECTIONTOOHIGH", 1780, FieldType.FLOAT); @@ -3119,7 +3119,7 @@ public class Fields { TPS2MAX, STARTERCONTROLPIN, STARTSTOPBUTTONMODE, - UNUSEDFORMERWARMUPAFRPID, + MC33816_FLAG0, TACHPULSEPERREV, MAPERRORDETECTIONTOOLOW, MAPERRORDETECTIONTOOHIGH,