diff --git a/.gitignore b/.gitignore index b25b5c32ae..2395e1fd71 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build/ build_kinetis/ out/ +logs/ blbuild/ Debug_EMS/ Release_EMS/ diff --git a/firmware/config/boards/kinetis/board_configuration.cpp b/firmware/config/boards/kinetis/board_configuration.cpp index 9b8d8defd7..44915dc5b4 100644 --- a/firmware/config/boards/kinetis/board_configuration.cpp +++ b/firmware/config/boards/kinetis/board_configuration.cpp @@ -26,8 +26,8 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; engineConfiguration->useOnlyRisingEdgeForTrigger = true; - boardConfiguration->isFasterEngineSpinUpEnabled = true; - boardConfiguration->useNoiselessTriggerDecoder = true; + engineConfiguration->isFasterEngineSpinUpEnabled = true; + engineConfiguration->useNoiselessTriggerDecoder = true; setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); @@ -72,7 +72,7 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->tpsErrorDetectionTooLow = -10; // -10% open engineConfiguration->tpsErrorDetectionTooHigh = 110; // 110% open - boardConfiguration->mapMinBufferLength = 4; + engineConfiguration->mapMinBufferLength = 4; // todo: engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE; @@ -90,9 +90,9 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->clt.adcChannel = EFI_ADC_14; - boardConfiguration->triggerInputPins[0] = GPIOE_7; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOE_7; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; engineConfiguration->tle6240spiDevice = SPI_DEVICE_1; engineConfiguration->tle6240_cs = GPIOB_0; @@ -100,14 +100,14 @@ void setBoardConfigurationOverrides(void) { // todo: int i; for (i = 0; i < INJECTION_PIN_COUNT; i++) - boardConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; for (i = 0; i < IGNITION_PIN_COUNT; i++) - boardConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; engineConfiguration->adcVcc = 5.0f; engineConfiguration->analogInputDividerCoefficient = 1; - //boardConfiguration->isFastAdcEnabled = false; + //engineConfiguration->isFastAdcEnabled = false; // we call it here because setDefaultBoardConfiguration() is not called for DEFAULT_ENGINE_TYPE=MINIMAL_PINS setSerialConfigurationOverrides(); @@ -117,12 +117,12 @@ void setPinConfigurationOverrides(void) { } void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = true; + engineConfiguration->useSerialPort = true; engineConfiguration->binarySerialTxPin = GPIOC_7; engineConfiguration->binarySerialRxPin = GPIOC_6; engineConfiguration->consoleSerialTxPin = GPIOA_10; engineConfiguration->consoleSerialRxPin = GPIOA_11; - boardConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; + engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } diff --git a/firmware/config/boards/kinetis/chconf.h b/firmware/config/boards/kinetis/chconf.h index 693e73d42b..aa88a5f858 100644 --- a/firmware/config/boards/kinetis/chconf.h +++ b/firmware/config/boards/kinetis/chconf.h @@ -44,12 +44,11 @@ * */ -#define PORT_IDLE_THREAD_STACK_SIZE 64/*768*//*1024*/ +#define PORT_IDLE_THREAD_STACK_SIZE 32 -// rusEfi main processing happens on IRQ so PORT_INT_REQUIRED_STACK has to be pretty large. -// see also a strange comment about PORT_INT_REQUIRED_STACK in global_shared.h +// See global_shared.h notes about stack requirements // see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks -#define PORT_INT_REQUIRED_STACK 512/*768*/ +#define PORT_INT_REQUIRED_STACK 128 #define CHPRINTF_USE_FLOAT TRUE diff --git a/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp b/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp index b462a65b13..14ee7f8858 100644 --- a/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp +++ b/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp @@ -587,8 +587,8 @@ case HONDA_ACCORD_CD_TWO_WIRES: return "HONDA_ACCORD_CD_TWO_WIRES"; case LADA_KALINA: return "LADA_KALINA"; -case MAZDA_323: - return "MAZDA_323"; +case MRE_MIATA_NB2_MTB: + return "MRE_MIATA_NB2_MTB"; case MAZDA_626: return "MAZDA_626"; case MAZDA_MIATA_2003: @@ -659,6 +659,8 @@ case TOYOTA_JZS147: return "TOYOTA_JZS147"; case VAG_18_TURBO: return "VAG_18_TURBO"; +case VW_B6: + return "VW_B6"; case VW_ABA: return "VW_ABA"; case ZIL_130: diff --git a/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h b/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h index 845efa0091..7a52be0512 100644 --- a/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Sun Dec 08 00:34:54 EST 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Sat Dec 21 19:54:17 EST 2019 // by class com.rusefi.output.CHeaderConsumer // begin #ifndef CONFIG_BOARDS_KINETIS_CONFIG_CONTROLLERS_ALGO_ENGINE_CONFIGURATION_GENERATED_STRUCTURES_H @@ -347,6 +347,93 @@ struct trigger_config_s { * This option could be used if your second trigger channel is broken offset 4 bit 2 */ bool useOnlyFirstChannel : 1; + /** + offset 4 bit 3 */ + bool unusedBit_4_3 : 1; + /** + offset 4 bit 4 */ + bool unusedBit_4_4 : 1; + /** + offset 4 bit 5 */ + bool unusedBit_4_5 : 1; + /** + offset 4 bit 6 */ + bool unusedBit_4_6 : 1; + /** + offset 4 bit 7 */ + bool unusedBit_4_7 : 1; + /** + offset 4 bit 8 */ + bool unusedBit_4_8 : 1; + /** + offset 4 bit 9 */ + bool unusedBit_4_9 : 1; + /** + offset 4 bit 10 */ + bool unusedBit_4_10 : 1; + /** + offset 4 bit 11 */ + bool unusedBit_4_11 : 1; + /** + offset 4 bit 12 */ + bool unusedBit_4_12 : 1; + /** + offset 4 bit 13 */ + bool unusedBit_4_13 : 1; + /** + offset 4 bit 14 */ + bool unusedBit_4_14 : 1; + /** + offset 4 bit 15 */ + bool unusedBit_4_15 : 1; + /** + offset 4 bit 16 */ + bool unusedBit_4_16 : 1; + /** + offset 4 bit 17 */ + bool unusedBit_4_17 : 1; + /** + offset 4 bit 18 */ + bool unusedBit_4_18 : 1; + /** + offset 4 bit 19 */ + bool unusedBit_4_19 : 1; + /** + offset 4 bit 20 */ + bool unusedBit_4_20 : 1; + /** + offset 4 bit 21 */ + bool unusedBit_4_21 : 1; + /** + offset 4 bit 22 */ + bool unusedBit_4_22 : 1; + /** + offset 4 bit 23 */ + bool unusedBit_4_23 : 1; + /** + offset 4 bit 24 */ + bool unusedBit_4_24 : 1; + /** + offset 4 bit 25 */ + bool unusedBit_4_25 : 1; + /** + offset 4 bit 26 */ + bool unusedBit_4_26 : 1; + /** + offset 4 bit 27 */ + bool unusedBit_4_27 : 1; + /** + offset 4 bit 28 */ + bool unusedBit_4_28 : 1; + /** + offset 4 bit 29 */ + bool unusedBit_4_29 : 1; + /** + offset 4 bit 30 */ + bool unusedBit_4_30 : 1; + /** + offset 4 bit 31 */ + bool unusedBit_4_31 : 1; /** * offset 8 */ @@ -441,564 +528,6 @@ struct etb_io { typedef struct etb_io etb_io; -// start of board_configuration_s -struct board_configuration_s { - /** - * offset 0 - */ - idle_hardware_s idle; - /** - * value between 0 and 100 used in Manual mode - * offset 8 - */ - float manIdlePosition; - /** - * offset 12 - */ - float mapFrequency0Kpa; - /** - * offset 16 - */ - float mapFrequency100Kpa; - /** - * Same RPM is used for two ways of producing simulated RPM. See also triggerSimulatorPins (with wires) - * See also directSelfStimulation (no wires, bypassing input hardware) - * rpm X - * offset 20 - */ - int triggerSimulatorFrequency; - /** - * offset 24 - */ - output_pin_e injectionPins[INJECTION_PIN_COUNT]; - /** - * offset 36 - */ - output_pin_e ignitionPins[IGNITION_PIN_COUNT]; - /** - * offset 48 - */ - pin_output_mode_e injectionPinMode; - /** - * offset 49 - */ - pin_output_mode_e ignitionPinMode; - /** - * offset 50 - */ - brain_pin_e HD44780_rs; - /** - * offset 51 - */ - brain_pin_e HD44780_e; - /** - * offset 52 - */ - brain_pin_e HD44780_db4; - /** - * offset 53 - */ - brain_pin_e HD44780_db5; - /** - * offset 54 - */ - brain_pin_e HD44780_db6; - /** - * offset 55 - */ - brain_pin_e HD44780_db7; - /** - * offset 56 - */ - brain_pin_e gps_rx_pin; - /** - * offset 57 - */ - brain_pin_e gps_tx_pin; - /** - * offset 58 - */ - output_pin_e fuelPumpPin; - /** - * offset 59 - */ - pin_output_mode_e fuelPumpPinMode; - /** - * Check engine light, also malfunction indicator light. Always blinks once on boot. - * offset 60 - */ - output_pin_e malfunctionIndicatorPin; - /** - * offset 61 - */ - pin_output_mode_e malfunctionIndicatorPinMode; - /** - * offset 62 - */ - pin_output_mode_e fanPinMode; - /** - * offset 63 - */ - output_pin_e fanPin; - /** - * some cars have a switch to indicate that clutch pedal is all the way down - * offset 64 - */ - switch_input_pin_e clutchDownPin; - /** - * offset 65 - */ - output_pin_e alternatorControlPin; - /** - * offset 66 - */ - pin_output_mode_e alternatorControlPinMode; - /** - * offset 67 - */ - pin_input_mode_e clutchDownPinMode; - /** - * offset 68 - */ - brain_pin_e digitalPotentiometerChipSelect[DIGIPOT_COUNT]; - /** - * offset 72 - */ - pin_output_mode_e electronicThrottlePin1Mode; - /** - * offset 73 - */ - brain_pin_e wboHeaterPin; - /** - * offset 74 - */ - brain_pin_e cj125CsPin; - /** - * offset 75 - */ - spi_device_e max31855spiDevice; - /** - * offset 76 - */ - brain_pin_e debugTriggerSync; - /** - * Digital Potentiometer is used by stock ECU stimulation code - * offset 77 - */ - spi_device_e digitalPotentiometerSpiDevice; - /** - * offset 78 - */ - brain_pin_e mc33972_cs; - /** - * offset 79 - */ - pin_output_mode_e mc33972_csPinMode; - /** - * Useful in Research&Development phase - * offset 80 - */ - adc_channel_e auxFastSensor1_adcChannel; - /** - * offset 81 - */ - uint8_t unused556[3]; - /** - * offset 84 - */ - float fuelLevelEmptyTankVoltage; - /** - * offset 88 - */ - float fuelLevelFullTankVoltage; - /** - * AFR, WBO, EGO - whatever you like to call it - * offset 92 - */ - ego_sensor_e afr_type; - /** - * offset 96 - */ - float fuelClosedLoopAfrLowThreshold; - /** - * offset 100 - */ - brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]; - /** - * offset 103 - */ - pin_output_mode_e hip9011CsPinMode; - /** - * This implementation produces one pulse per engine cycle. See also dizzySparkOutputPin. - * offset 104 - */ - output_pin_e tachOutputPin; - /** - * offset 105 - */ - pin_output_mode_e tachOutputPinMode; - /** - * offset 106 - */ - output_pin_e mainRelayPin; - /** - * offset 107 - */ - brain_pin_e sdCardCsPin; - /** - * offset 108 - */ - brain_pin_e canTxPin; - /** - * offset 109 - */ - brain_pin_e canRxPin; - /** - * offset 110 - */ - pin_input_mode_e throttlePedalUpPinMode; - /** - * offset 111 - */ - brain_pin_e debugTimerCallback; - /** - * offset 112 - */ - int idleThreadPeriodMs; - /** - * offset 116 - */ - int consoleLoopPeriodMs; - /** - * offset 120 - */ - int lcdThreadPeriodMs; - /** - * offset 124 - */ - int generalPeriodicThreadPeriodMs; - /** - * offset 128 - */ - uint32_t tunerStudioSerialSpeed; - /** - * offset 132 - */ - can_device_mode_e canDeviceMode; - /** - * Each rusEfi piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEfi board. - * See also directSelfStimulation which is different. - * offset 136 - */ - brain_pin_e triggerSimulatorPins[TRIGGER_SIMULATOR_PIN_COUNT]; - /** - * offset 139 - */ - pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT]; - /** - * Narrow band o2 heater, not used for CJ125. See wboHeaterPin - * offset 142 - */ - output_pin_e o2heaterPin; - /** - * offset 143 - */ - pin_output_mode_e o2heaterPinModeTodO; - /** - offset 144 bit 0 */ - bool is_enabled_spi_1 : 1; - /** - offset 144 bit 1 */ - bool is_enabled_spi_2 : 1; - /** - offset 144 bit 2 */ - bool is_enabled_spi_3 : 1; - /** - offset 144 bit 3 */ - bool isSdCardEnabled : 1; - /** - offset 144 bit 4 */ - bool isFastAdcEnabled : 1; - /** - offset 144 bit 5 */ - bool isEngineControlEnabled : 1; - /** - offset 144 bit 6 */ - bool isHip9011Enabled : 1; - /** - offset 144 bit 7 */ - bool isVerboseAlternator : 1; - /** - offset 144 bit 8 */ - bool useSerialPort : 1; - /** - * This setting should only be used if you have a stepper motor idle valve and a stepper motor driver installed. - offset 144 bit 9 */ - bool useStepperIdle : 1; - /** - offset 144 bit 10 */ - bool enabledStep1Limiter : 1; - /** - offset 144 bit 11 */ - bool useTpicAdvancedMode : 1; - /** - offset 144 bit 12 */ - bool useLcdScreen : 1; - /** - offset 144 bit 13 */ - bool unusedAnotherOne : 1; - /** - offset 144 bit 14 */ - bool unusedOldWarmupAfr : 1; - /** - * +This will cause the alternator to be operated in a basic on or off mode, this is the simplest alternator control. - offset 144 bit 15 */ - bool onOffAlternatorLogic : 1; - /** - offset 144 bit 16 */ - bool isCJ125Enabled : 1; - /** - * Use rise or fall signal front - offset 144 bit 17 */ - bool vvtCamSensorUseRise : 1; - /** - * Useful for individual intakes - offset 144 bit 18 */ - bool measureMapOnlyInOneCylinder : 1; - /** - offset 144 bit 19 */ - bool stepperForceParkingEveryRestart : 1; - /** - * Smarter cranking logic. - * See also startOfCrankingPrimingPulse - offset 144 bit 20 */ - bool isFasterEngineSpinUpEnabled : 1; - /** - * This setting disables fuel injection while the engine is in overrun, this is useful as a fuel saving measure and to prevent back firing. - offset 144 bit 21 */ - bool coastingFuelCutEnabled : 1; - /** - * This setting allows the ECU to open the IAC during overrun conditions to help reduce engine breaking, this can be helpful for large engines in light weight cars. - offset 144 bit 22 */ - bool useIacTableForCoasting : 1; - /** - offset 144 bit 23 */ - bool useNoiselessTriggerDecoder : 1; - /** - offset 144 bit 24 */ - bool useIdleTimingPidControl : 1; - /** - offset 144 bit 25 */ - bool useTPSBasedVeTable : 1; - /** - offset 144 bit 26 */ - bool is_enabled_spi_4 : 1; - /** - offset 144 bit 27 */ - bool pauseEtbControl : 1; - /** - offset 144 bit 28 */ - bool alignEngineSnifferAtTDC : 1; - /** - * This setting allows the ETB to act as the idle air control valve and move to regulate the airflow at idle. - offset 144 bit 29 */ - bool useETBforIdleControl : 1; - /** - offset 144 bit 30 */ - bool idleIncrementalPidCic : 1; - /** - offset 144 bit 31 */ - bool unused_board_984_31 : 1; - /** - * offset 148 - */ - brain_input_pin_e logicAnalyzerPins[LOGIC_ANALYZER_CHANNEL_COUNT]; - /** - * offset 152 - */ - pin_output_mode_e mainRelayPinMode; - /** - * offset 153 - */ - brain_pin_e hip9011CsPin; - /** - * offset 154 - */ - brain_pin_e hip9011IntHoldPin; - /** - * offset 155 - */ - pin_output_mode_e hip9011IntHoldPinMode; - /** - * default or inverted input - * offset 156 - */ - uint8_t logicAnalyzerMode[LOGIC_ANALYZER_CHANNEL_COUNT]; - /** - * offset 160 - */ - int unrealisticRpmThreashold; - /** - * offset 164 - */ - pin_output_mode_e gpioPinModes[FSIO_COMMAND_COUNT]; - /** - * todo: more comments - * offset 180 - */ - output_pin_e fsioOutputPins[FSIO_COMMAND_COUNT]; - /** - * offset 196 - */ - brain_pin_e max31855_cs[EGT_CHANNEL_COUNT]; - /** - * SD card logging period, in milliseconds - * offset 204 - */ - int16_t sdCardPeriodMs; - /** - * offset 206 - */ - brain_pin_e debugSetTimer; - /** - * offset 207 - */ - brain_pin_e debugMapAveraging; - /** - * offset 208 - */ - brain_pin_e starterRelayPin; - /** - * offset 209 - */ - pin_output_mode_e starterRelayPinMode; - /** - * offset 210 - */ - uint8_t unuseduartPadding1[2]; - /** - * offset 212 - */ - int mapMinBufferLength; - /** - * offset 216 - */ - int16_t idlePidDeactivationTpsThreshold; - /** - * offset 218 - */ - int16_t stepperParkingExtraSteps; - /** - * This magic property is specific to Mazda Miata NB2 - * offset 220 - */ - float miataNb2VVTRatioFrom; - /** - * This magic property is specific to Mazda Miata NB2 - * offset 224 - */ - float miataNb2VVTRatioTo; - /** - * This pin is used for debugging - snap a logic analyzer on it and see if it's ever high - * offset 228 - */ - brain_pin_e triggerErrorPin; - /** - * offset 229 - */ - pin_output_mode_e triggerErrorPinMode; - /** - * offset 230 - */ - output_pin_e acRelayPin; - /** - * offset 231 - */ - pin_output_mode_e acRelayPinMode; - /** - * offset 232 - */ - fsio_pwm_freq_t fsioFrequency[FSIO_COMMAND_COUNT]; - /** - * offset 264 - */ - fsio_setting_t fsio_setting[FSIO_COMMAND_COUNT]; - /** - * offset 328 - */ - brain_pin_e spi1mosiPin; - /** - * offset 329 - */ - brain_pin_e spi1misoPin; - /** - * offset 330 - */ - brain_pin_e spi1sckPin; - /** - * offset 331 - */ - brain_pin_e spi2mosiPin; - /** - * offset 332 - */ - brain_pin_e spi2misoPin; - /** - * offset 333 - */ - brain_pin_e spi2sckPin; - /** - * offset 334 - */ - brain_pin_e spi3mosiPin; - /** - * offset 335 - */ - brain_pin_e spi3misoPin; - /** - * offset 336 - */ - brain_pin_e spi3sckPin; - /** - * Saab Combustion Detection Module knock signal input pin - * also known as Saab Ion Sensing Module - * offset 337 - */ - brain_pin_e cdmInputPin; - /** - * offset 338 - */ - brain_pin_e joystickCenterPin; - /** - * offset 339 - */ - brain_pin_e joystickAPin; - /** - * offset 340 - */ - brain_pin_e joystickBPin; - /** - * offset 341 - */ - brain_pin_e joystickCPin; - /** - * offset 342 - */ - brain_pin_e joystickDPin; - /** - * offset 343 - */ - uart_device_e consoleUartDevice; - /** - * rusEfi console Sensor Sniffer mode - * offset 344 - */ - sensor_chart_e sensorChartMode; - /** total size 348*/ -}; - -typedef struct board_configuration_s board_configuration_s; - // start of engine_configuration_s struct engine_configuration_s { /** @@ -1115,6 +644,9 @@ struct engine_configuration_s { /** offset 76 bit 30 */ bool issue_294_31 : 1; + /** + offset 76 bit 31 */ + bool unusedBit_34_31 : 1; /** * Closed throttle. todo: extract these two fields into a structure * See also tps1_1AdcChannel @@ -1449,7 +981,554 @@ struct engine_configuration_s { /** * offset 600 */ - board_configuration_s bc; + idle_hardware_s idle; + /** + * value between 0 and 100 used in Manual mode + * offset 608 + */ + float manIdlePosition; + /** + * offset 612 + */ + float mapFrequency0Kpa; + /** + * offset 616 + */ + float mapFrequency100Kpa; + /** + * Same RPM is used for two ways of producing simulated RPM. See also triggerSimulatorPins (with wires) + * See also directSelfStimulation (no wires, bypassing input hardware) + * rpm X + * offset 620 + */ + int triggerSimulatorFrequency; + /** + * offset 624 + */ + output_pin_e injectionPins[INJECTION_PIN_COUNT]; + /** + * offset 636 + */ + output_pin_e ignitionPins[IGNITION_PIN_COUNT]; + /** + * offset 648 + */ + pin_output_mode_e injectionPinMode; + /** + * offset 649 + */ + pin_output_mode_e ignitionPinMode; + /** + * offset 650 + */ + brain_pin_e HD44780_rs; + /** + * offset 651 + */ + brain_pin_e HD44780_e; + /** + * offset 652 + */ + brain_pin_e HD44780_db4; + /** + * offset 653 + */ + brain_pin_e HD44780_db5; + /** + * offset 654 + */ + brain_pin_e HD44780_db6; + /** + * offset 655 + */ + brain_pin_e HD44780_db7; + /** + * offset 656 + */ + brain_pin_e gps_rx_pin; + /** + * offset 657 + */ + brain_pin_e gps_tx_pin; + /** + * offset 658 + */ + output_pin_e fuelPumpPin; + /** + * offset 659 + */ + pin_output_mode_e fuelPumpPinMode; + /** + * Check engine light, also malfunction indicator light. Always blinks once on boot. + * offset 660 + */ + output_pin_e malfunctionIndicatorPin; + /** + * offset 661 + */ + pin_output_mode_e malfunctionIndicatorPinMode; + /** + * offset 662 + */ + pin_output_mode_e fanPinMode; + /** + * offset 663 + */ + output_pin_e fanPin; + /** + * some cars have a switch to indicate that clutch pedal is all the way down + * offset 664 + */ + switch_input_pin_e clutchDownPin; + /** + * offset 665 + */ + output_pin_e alternatorControlPin; + /** + * offset 666 + */ + pin_output_mode_e alternatorControlPinMode; + /** + * offset 667 + */ + pin_input_mode_e clutchDownPinMode; + /** + * offset 668 + */ + brain_pin_e digitalPotentiometerChipSelect[DIGIPOT_COUNT]; + /** + * offset 672 + */ + pin_output_mode_e electronicThrottlePin1Mode; + /** + * offset 673 + */ + brain_pin_e wboHeaterPin; + /** + * offset 674 + */ + brain_pin_e cj125CsPin; + /** + * offset 675 + */ + spi_device_e max31855spiDevice; + /** + * offset 676 + */ + brain_pin_e debugTriggerSync; + /** + * Digital Potentiometer is used by stock ECU stimulation code + * offset 677 + */ + spi_device_e digitalPotentiometerSpiDevice; + /** + * offset 678 + */ + brain_pin_e mc33972_cs; + /** + * offset 679 + */ + pin_output_mode_e mc33972_csPinMode; + /** + * Useful in Research&Development phase + * offset 680 + */ + adc_channel_e auxFastSensor1_adcChannel; + /** + * offset 681 + */ + uint8_t unused556[3]; + /** + * offset 684 + */ + float fuelLevelEmptyTankVoltage; + /** + * offset 688 + */ + float fuelLevelFullTankVoltage; + /** + * AFR, WBO, EGO - whatever you like to call it + * offset 692 + */ + ego_sensor_e afr_type; + /** + * offset 696 + */ + float fuelClosedLoopAfrLowThreshold; + /** + * offset 700 + */ + brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]; + /** + * offset 703 + */ + pin_output_mode_e hip9011CsPinMode; + /** + * This implementation produces one pulse per engine cycle. See also dizzySparkOutputPin. + * offset 704 + */ + output_pin_e tachOutputPin; + /** + * offset 705 + */ + pin_output_mode_e tachOutputPinMode; + /** + * offset 706 + */ + output_pin_e mainRelayPin; + /** + * offset 707 + */ + brain_pin_e sdCardCsPin; + /** + * offset 708 + */ + brain_pin_e canTxPin; + /** + * offset 709 + */ + brain_pin_e canRxPin; + /** + * offset 710 + */ + pin_input_mode_e throttlePedalUpPinMode; + /** + * offset 711 + */ + brain_pin_e debugTimerCallback; + /** + * offset 712 + */ + int idleThreadPeriodMs; + /** + * offset 716 + */ + int consoleLoopPeriodMs; + /** + * offset 720 + */ + int lcdThreadPeriodMs; + /** + * offset 724 + */ + int generalPeriodicThreadPeriodMs; + /** + * offset 728 + */ + uint32_t tunerStudioSerialSpeed; + /** + * offset 732 + */ + can_device_mode_e canDeviceMode; + /** + * Each rusEfi piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEfi board. + * See also directSelfStimulation which is different. + * offset 736 + */ + brain_pin_e triggerSimulatorPins[TRIGGER_SIMULATOR_PIN_COUNT]; + /** + * offset 739 + */ + pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT]; + /** + * Narrow band o2 heater, not used for CJ125. See wboHeaterPin + * offset 742 + */ + output_pin_e o2heaterPin; + /** + * offset 743 + */ + pin_output_mode_e o2heaterPinModeTodO; + /** + offset 744 bit 0 */ + bool is_enabled_spi_1 : 1; + /** + offset 744 bit 1 */ + bool is_enabled_spi_2 : 1; + /** + offset 744 bit 2 */ + bool is_enabled_spi_3 : 1; + /** + offset 744 bit 3 */ + bool isSdCardEnabled : 1; + /** + offset 744 bit 4 */ + bool isFastAdcEnabled : 1; + /** + offset 744 bit 5 */ + bool isEngineControlEnabled : 1; + /** + offset 744 bit 6 */ + bool isHip9011Enabled : 1; + /** + offset 744 bit 7 */ + bool isVerboseAlternator : 1; + /** + offset 744 bit 8 */ + bool useSerialPort : 1; + /** + * This setting should only be used if you have a stepper motor idle valve and a stepper motor driver installed. + offset 744 bit 9 */ + bool useStepperIdle : 1; + /** + offset 744 bit 10 */ + bool enabledStep1Limiter : 1; + /** + offset 744 bit 11 */ + bool useTpicAdvancedMode : 1; + /** + offset 744 bit 12 */ + bool useLcdScreen : 1; + /** + offset 744 bit 13 */ + bool unusedAnotherOne : 1; + /** + offset 744 bit 14 */ + bool unusedOldWarmupAfr : 1; + /** + * +This will cause the alternator to be operated in a basic on or off mode, this is the simplest alternator control. + offset 744 bit 15 */ + bool onOffAlternatorLogic : 1; + /** + offset 744 bit 16 */ + bool isCJ125Enabled : 1; + /** + * Use rise or fall signal front + offset 744 bit 17 */ + bool vvtCamSensorUseRise : 1; + /** + * Useful for individual intakes + offset 744 bit 18 */ + bool measureMapOnlyInOneCylinder : 1; + /** + offset 744 bit 19 */ + bool stepperForceParkingEveryRestart : 1; + /** + * Smarter cranking logic. + * See also startOfCrankingPrimingPulse + offset 744 bit 20 */ + bool isFasterEngineSpinUpEnabled : 1; + /** + * This setting disables fuel injection while the engine is in overrun, this is useful as a fuel saving measure and to prevent back firing. + offset 744 bit 21 */ + bool coastingFuelCutEnabled : 1; + /** + * This setting allows the ECU to open the IAC during overrun conditions to help reduce engine breaking, this can be helpful for large engines in light weight cars. + offset 744 bit 22 */ + bool useIacTableForCoasting : 1; + /** + offset 744 bit 23 */ + bool useNoiselessTriggerDecoder : 1; + /** + offset 744 bit 24 */ + bool useIdleTimingPidControl : 1; + /** + offset 744 bit 25 */ + bool useTPSBasedVeTable : 1; + /** + offset 744 bit 26 */ + bool is_enabled_spi_4 : 1; + /** + offset 744 bit 27 */ + bool pauseEtbControl : 1; + /** + offset 744 bit 28 */ + bool alignEngineSnifferAtTDC : 1; + /** + * This setting allows the ETB to act as the idle air control valve and move to regulate the airflow at idle. + offset 744 bit 29 */ + bool useETBforIdleControl : 1; + /** + offset 744 bit 30 */ + bool idleIncrementalPidCic : 1; + /** + offset 744 bit 31 */ + bool unused_board_984_31 : 1; + /** + * offset 748 + */ + brain_input_pin_e logicAnalyzerPins[LOGIC_ANALYZER_CHANNEL_COUNT]; + /** + * offset 752 + */ + pin_output_mode_e mainRelayPinMode; + /** + * offset 753 + */ + brain_pin_e hip9011CsPin; + /** + * offset 754 + */ + brain_pin_e hip9011IntHoldPin; + /** + * offset 755 + */ + pin_output_mode_e hip9011IntHoldPinMode; + /** + * default or inverted input + * offset 756 + */ + uint8_t logicAnalyzerMode[LOGIC_ANALYZER_CHANNEL_COUNT]; + /** + * offset 760 + */ + int unrealisticRpmThreashold; + /** + * offset 764 + */ + pin_output_mode_e gpioPinModes[FSIO_COMMAND_COUNT]; + /** + * todo: more comments + * offset 780 + */ + output_pin_e fsioOutputPins[FSIO_COMMAND_COUNT]; + /** + * offset 796 + */ + brain_pin_e max31855_cs[EGT_CHANNEL_COUNT]; + /** + * SD card logging period, in milliseconds + * offset 804 + */ + int16_t sdCardPeriodMs; + /** + * offset 806 + */ + brain_pin_e debugSetTimer; + /** + * offset 807 + */ + brain_pin_e debugMapAveraging; + /** + * offset 808 + */ + brain_pin_e starterRelayPin; + /** + * offset 809 + */ + pin_output_mode_e starterRelayPinMode; + /** + * offset 810 + */ + uint8_t unuseduartPadding1[2]; + /** + * offset 812 + */ + int mapMinBufferLength; + /** + * offset 816 + */ + int16_t idlePidDeactivationTpsThreshold; + /** + * offset 818 + */ + int16_t stepperParkingExtraSteps; + /** + * This magic property is specific to Mazda Miata NB2 + * offset 820 + */ + float miataNb2VVTRatioFrom; + /** + * This magic property is specific to Mazda Miata NB2 + * offset 824 + */ + float miataNb2VVTRatioTo; + /** + * This pin is used for debugging - snap a logic analyzer on it and see if it's ever high + * offset 828 + */ + brain_pin_e triggerErrorPin; + /** + * offset 829 + */ + pin_output_mode_e triggerErrorPinMode; + /** + * offset 830 + */ + output_pin_e acRelayPin; + /** + * offset 831 + */ + pin_output_mode_e acRelayPinMode; + /** + * offset 832 + */ + fsio_pwm_freq_t fsioFrequency[FSIO_COMMAND_COUNT]; + /** + * offset 864 + */ + fsio_setting_t fsio_setting[FSIO_COMMAND_COUNT]; + /** + * offset 928 + */ + brain_pin_e spi1mosiPin; + /** + * offset 929 + */ + brain_pin_e spi1misoPin; + /** + * offset 930 + */ + brain_pin_e spi1sckPin; + /** + * offset 931 + */ + brain_pin_e spi2mosiPin; + /** + * offset 932 + */ + brain_pin_e spi2misoPin; + /** + * offset 933 + */ + brain_pin_e spi2sckPin; + /** + * offset 934 + */ + brain_pin_e spi3mosiPin; + /** + * offset 935 + */ + brain_pin_e spi3misoPin; + /** + * offset 936 + */ + brain_pin_e spi3sckPin; + /** + * Saab Combustion Detection Module knock signal input pin + * also known as Saab Ion Sensing Module + * offset 937 + */ + brain_pin_e cdmInputPin; + /** + * offset 938 + */ + brain_pin_e joystickCenterPin; + /** + * offset 939 + */ + brain_pin_e joystickAPin; + /** + * offset 940 + */ + brain_pin_e joystickBPin; + /** + * offset 941 + */ + brain_pin_e joystickCPin; + /** + * offset 942 + */ + brain_pin_e joystickDPin; + /** + * offset 943 + */ + uart_device_e consoleUartDevice; + /** + * rusEfi console Sensor Sniffer mode + * offset 944 + */ + sensor_chart_e sensorChartMode; /** * offset 948 */ @@ -1487,6 +1566,96 @@ struct engine_configuration_s { /** offset 976 bit 1 */ bool todoClutchDownPinInverted : 1; + /** + offset 976 bit 2 */ + bool unusedBit_247_2 : 1; + /** + offset 976 bit 3 */ + bool unusedBit_247_3 : 1; + /** + offset 976 bit 4 */ + bool unusedBit_247_4 : 1; + /** + offset 976 bit 5 */ + bool unusedBit_247_5 : 1; + /** + offset 976 bit 6 */ + bool unusedBit_247_6 : 1; + /** + offset 976 bit 7 */ + bool unusedBit_247_7 : 1; + /** + offset 976 bit 8 */ + bool unusedBit_247_8 : 1; + /** + offset 976 bit 9 */ + bool unusedBit_247_9 : 1; + /** + offset 976 bit 10 */ + bool unusedBit_247_10 : 1; + /** + offset 976 bit 11 */ + bool unusedBit_247_11 : 1; + /** + offset 976 bit 12 */ + bool unusedBit_247_12 : 1; + /** + offset 976 bit 13 */ + bool unusedBit_247_13 : 1; + /** + offset 976 bit 14 */ + bool unusedBit_247_14 : 1; + /** + offset 976 bit 15 */ + bool unusedBit_247_15 : 1; + /** + offset 976 bit 16 */ + bool unusedBit_247_16 : 1; + /** + offset 976 bit 17 */ + bool unusedBit_247_17 : 1; + /** + offset 976 bit 18 */ + bool unusedBit_247_18 : 1; + /** + offset 976 bit 19 */ + bool unusedBit_247_19 : 1; + /** + offset 976 bit 20 */ + bool unusedBit_247_20 : 1; + /** + offset 976 bit 21 */ + bool unusedBit_247_21 : 1; + /** + offset 976 bit 22 */ + bool unusedBit_247_22 : 1; + /** + offset 976 bit 23 */ + bool unusedBit_247_23 : 1; + /** + offset 976 bit 24 */ + bool unusedBit_247_24 : 1; + /** + offset 976 bit 25 */ + bool unusedBit_247_25 : 1; + /** + offset 976 bit 26 */ + bool unusedBit_247_26 : 1; + /** + offset 976 bit 27 */ + bool unusedBit_247_27 : 1; + /** + offset 976 bit 28 */ + bool unusedBit_247_28 : 1; + /** + offset 976 bit 29 */ + bool unusedBit_247_29 : 1; + /** + offset 976 bit 30 */ + bool unusedBit_247_30 : 1; + /** + offset 976 bit 31 */ + bool unusedBit_247_31 : 1; /** * offset 980 */ @@ -2939,4 +3108,4 @@ typedef struct persistent_config_s persistent_config_s; #endif // end -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Sun Dec 08 00:34:54 EST 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Sat Dec 21 19:54:17 EST 2019 diff --git a/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h b/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h index 76440ba83a..b7929dfbdc 100644 --- a/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h +++ b/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h @@ -246,8 +246,6 @@ #define baroSensor_offset_hex 248 #define baroSensor_type_offset 592 #define baroSensor_type_offset_hex 250 -#define bc_offset 600 -#define bc_offset_hex 258 #define binarySerialRxPin_offset 1815 #define binarySerialRxPin_offset_hex 717 #define binarySerialTxPin_offset 1814 @@ -377,9 +375,11 @@ #define CMD_ENABLE "enable" #define CMD_ENGINE_TYPE "engine_type" #define CMD_ETB_DUTY "set_etb_duty" +#define CMD_FUNCTIONAL_TEST_MODE "test_mode" #define CMD_PINS "pins" #define CMD_REBOOT "reboot" #define CMD_REBOOT_DFU "reboot_dfu" +#define CMD_RESET_ENGINE_SNIFFER "reset_engine_chart" #define CMD_TRIGGER_HW_INPUT "trigger_hw_input" #define CMD_TRIGGERINFO "triggerinfo" #define CMD_WRITECONFIG "writeconfig" @@ -1552,6 +1552,13 @@ #define overrideCrankingIacSetting_offset_hex 5c4 #define overrideCrankingIgnition_offset 516 #define overrideCrankingIgnition_offset_hex 204 +#define PACK_MULT_AFR 1000 +#define PACK_MULT_ANGLE 50 +#define PACK_MULT_MS 300 +#define PACK_MULT_PERCENT 100 +#define PACK_MULT_PRESSURE 30 +#define PACK_MULT_TEMPERATURE 100 +#define PACK_MULT_VOLTAGE 1000 #define pauseEtbControl_offset 744 #define pauseEtbControl_offset_hex 2e8 #define PEDAL_TO_TPS_SIZE 8 @@ -1851,6 +1858,64 @@ #define trigger_type_e_enum "custom toothed wheel", "Ford Aspire", "Dodge Neon 1995", "Miata NA", "Miata NB", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Honda 4+24+1", "Mitsubishi", "Honda 4+24", "Honda 1+4+24", "Dodge Neon 2003", "Mazda DOHC 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Honda 1+24", "Dodge Stratus", "36_2_2_2", "Nissan Primera", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped" , "Dodge Neon 2003 crank", "Miata VVT", "trg34", "trg35", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "trg43", "trg44", "trg45", "INVALID" #define trigger_type_offset 524 #define trigger_type_offset_hex 20c +#define trigger_unusedBit_4_10_offset 528 +#define trigger_unusedBit_4_10_offset_hex 210 +#define trigger_unusedBit_4_11_offset 528 +#define trigger_unusedBit_4_11_offset_hex 210 +#define trigger_unusedBit_4_12_offset 528 +#define trigger_unusedBit_4_12_offset_hex 210 +#define trigger_unusedBit_4_13_offset 528 +#define trigger_unusedBit_4_13_offset_hex 210 +#define trigger_unusedBit_4_14_offset 528 +#define trigger_unusedBit_4_14_offset_hex 210 +#define trigger_unusedBit_4_15_offset 528 +#define trigger_unusedBit_4_15_offset_hex 210 +#define trigger_unusedBit_4_16_offset 528 +#define trigger_unusedBit_4_16_offset_hex 210 +#define trigger_unusedBit_4_17_offset 528 +#define trigger_unusedBit_4_17_offset_hex 210 +#define trigger_unusedBit_4_18_offset 528 +#define trigger_unusedBit_4_18_offset_hex 210 +#define trigger_unusedBit_4_19_offset 528 +#define trigger_unusedBit_4_19_offset_hex 210 +#define trigger_unusedBit_4_20_offset 528 +#define trigger_unusedBit_4_20_offset_hex 210 +#define trigger_unusedBit_4_21_offset 528 +#define trigger_unusedBit_4_21_offset_hex 210 +#define trigger_unusedBit_4_22_offset 528 +#define trigger_unusedBit_4_22_offset_hex 210 +#define trigger_unusedBit_4_23_offset 528 +#define trigger_unusedBit_4_23_offset_hex 210 +#define trigger_unusedBit_4_24_offset 528 +#define trigger_unusedBit_4_24_offset_hex 210 +#define trigger_unusedBit_4_25_offset 528 +#define trigger_unusedBit_4_25_offset_hex 210 +#define trigger_unusedBit_4_26_offset 528 +#define trigger_unusedBit_4_26_offset_hex 210 +#define trigger_unusedBit_4_27_offset 528 +#define trigger_unusedBit_4_27_offset_hex 210 +#define trigger_unusedBit_4_28_offset 528 +#define trigger_unusedBit_4_28_offset_hex 210 +#define trigger_unusedBit_4_29_offset 528 +#define trigger_unusedBit_4_29_offset_hex 210 +#define trigger_unusedBit_4_30_offset 528 +#define trigger_unusedBit_4_30_offset_hex 210 +#define trigger_unusedBit_4_31_offset 528 +#define trigger_unusedBit_4_31_offset_hex 210 +#define trigger_unusedBit_4_3_offset 528 +#define trigger_unusedBit_4_3_offset_hex 210 +#define trigger_unusedBit_4_4_offset 528 +#define trigger_unusedBit_4_4_offset_hex 210 +#define trigger_unusedBit_4_5_offset 528 +#define trigger_unusedBit_4_5_offset_hex 210 +#define trigger_unusedBit_4_6_offset 528 +#define trigger_unusedBit_4_6_offset_hex 210 +#define trigger_unusedBit_4_7_offset 528 +#define trigger_unusedBit_4_7_offset_hex 210 +#define trigger_unusedBit_4_8_offset 528 +#define trigger_unusedBit_4_8_offset_hex 210 +#define trigger_unusedBit_4_9_offset 528 +#define trigger_unusedBit_4_9_offset_hex 210 #define trigger_unusedCustomIsSynchronizationNeeded_offset 528 #define trigger_unusedCustomIsSynchronizationNeeded_offset_hex 210 #define trigger_unusedCustomNeedSecondTriggerInput_offset 528 @@ -1889,8 +1954,8 @@ #define triggerSimulatorPins2_offset_hex 2e1 #define triggerSimulatorPins3_offset 738 #define triggerSimulatorPins3_offset_hex 2e2 -#define TS_FILE_VERSION 20190701 -#define TS_OUTPUT_SIZE 356 +#define TS_FILE_VERSION 20191221 +#define TS_OUTPUT_SIZE 220 #define ts_show_cj125 true #define ts_show_egt true #define ts_show_etb true @@ -1900,7 +1965,7 @@ #define ts_show_hip9011 true #define ts_show_joystick true #define ts_show_lcd true -#define TS_SIGNATURE "rusEFI v1.07" +#define TS_SIGNATURE "rusEFI v1.08" #define tunerStudioSerialSpeed_offset 728 #define tunerStudioSerialSpeed_offset_hex 2d8 #define twoWireBatchIgnition_offset 1476 @@ -1947,6 +2012,68 @@ #define unusedAnotherOne_offset_hex 2e8 #define unusedAtOldBoardConfigurationEnd_offset 988 #define unusedAtOldBoardConfigurationEnd_offset_hex 3dc +#define unusedBit_247_10_offset 976 +#define unusedBit_247_10_offset_hex 3d0 +#define unusedBit_247_11_offset 976 +#define unusedBit_247_11_offset_hex 3d0 +#define unusedBit_247_12_offset 976 +#define unusedBit_247_12_offset_hex 3d0 +#define unusedBit_247_13_offset 976 +#define unusedBit_247_13_offset_hex 3d0 +#define unusedBit_247_14_offset 976 +#define unusedBit_247_14_offset_hex 3d0 +#define unusedBit_247_15_offset 976 +#define unusedBit_247_15_offset_hex 3d0 +#define unusedBit_247_16_offset 976 +#define unusedBit_247_16_offset_hex 3d0 +#define unusedBit_247_17_offset 976 +#define unusedBit_247_17_offset_hex 3d0 +#define unusedBit_247_18_offset 976 +#define unusedBit_247_18_offset_hex 3d0 +#define unusedBit_247_19_offset 976 +#define unusedBit_247_19_offset_hex 3d0 +#define unusedBit_247_20_offset 976 +#define unusedBit_247_20_offset_hex 3d0 +#define unusedBit_247_21_offset 976 +#define unusedBit_247_21_offset_hex 3d0 +#define unusedBit_247_22_offset 976 +#define unusedBit_247_22_offset_hex 3d0 +#define unusedBit_247_23_offset 976 +#define unusedBit_247_23_offset_hex 3d0 +#define unusedBit_247_24_offset 976 +#define unusedBit_247_24_offset_hex 3d0 +#define unusedBit_247_25_offset 976 +#define unusedBit_247_25_offset_hex 3d0 +#define unusedBit_247_26_offset 976 +#define unusedBit_247_26_offset_hex 3d0 +#define unusedBit_247_27_offset 976 +#define unusedBit_247_27_offset_hex 3d0 +#define unusedBit_247_28_offset 976 +#define unusedBit_247_28_offset_hex 3d0 +#define unusedBit_247_29_offset 976 +#define unusedBit_247_29_offset_hex 3d0 +#define unusedBit_247_2_offset 976 +#define unusedBit_247_2_offset_hex 3d0 +#define unusedBit_247_30_offset 976 +#define unusedBit_247_30_offset_hex 3d0 +#define unusedBit_247_31_offset 976 +#define unusedBit_247_31_offset_hex 3d0 +#define unusedBit_247_3_offset 976 +#define unusedBit_247_3_offset_hex 3d0 +#define unusedBit_247_4_offset 976 +#define unusedBit_247_4_offset_hex 3d0 +#define unusedBit_247_5_offset 976 +#define unusedBit_247_5_offset_hex 3d0 +#define unusedBit_247_6_offset 976 +#define unusedBit_247_6_offset_hex 3d0 +#define unusedBit_247_7_offset 976 +#define unusedBit_247_7_offset_hex 3d0 +#define unusedBit_247_8_offset 976 +#define unusedBit_247_8_offset_hex 3d0 +#define unusedBit_247_9_offset 976 +#define unusedBit_247_9_offset_hex 3d0 +#define unusedBit_34_31_offset 76 +#define unusedBit_34_31_offset_hex 4c #define unusedErrorPin_offset 2040 #define unusedErrorPin_offset_hex 7f8 #define unusedFlexFuelSensor_offset 3100 diff --git a/firmware/config/boards/kinetis/efifeatures.h b/firmware/config/boards/kinetis/efifeatures.h index b42bcbfccc..03463ff1c1 100644 --- a/firmware/config/boards/kinetis/efifeatures.h +++ b/firmware/config/boards/kinetis/efifeatures.h @@ -264,7 +264,6 @@ // todo: switch to continues ADC conversion for slow ADC? // https://github.com/rusefi/rusefi/issues/630 -#define EFI_INTERNAL_SLOW_ADC_PWM &PWMD1 // todo: switch to continues ADC conversion for fast ADC? #define EFI_INTERNAL_FAST_ADC_PWM &PWMD2 diff --git a/firmware/config/boards/me7_pnp/board_configuration.cpp b/firmware/config/boards/me7_pnp/board_configuration.cpp index 1fb7bbed46..b4c5bce7cf 100644 --- a/firmware/config/boards/me7_pnp/board_configuration.cpp +++ b/firmware/config/boards/me7_pnp/board_configuration.cpp @@ -19,7 +19,7 @@ EXTERN_ENGINE static void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = true; + engineConfiguration->useSerialPort = true; //UART @@ -36,11 +36,11 @@ void setPinConfigurationOverrides(void) { engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; engineConfiguration->afr.hwChannel = EFI_ADC_NONE; - boardConfiguration->ignitionPins[8] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[9] = GPIO_UNASSIGNED; - boardConfiguration->mainRelayPin = GPIO_UNASSIGNED; - boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - boardConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[8] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[9] = GPIO_UNASSIGNED; + engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = GPIO_UNASSIGNED; } void setBoardConfigurationOverrides(void) { @@ -49,33 +49,33 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->dizzySparkOutputPin = GPIO_UNASSIGNED; engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; engineConfiguration->displayMode = DM_NONE; - boardConfiguration->HD44780_rs = GPIO_UNASSIGNED; - boardConfiguration->HD44780_e = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; + engineConfiguration->HD44780_e = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; for (int i = 0; i < DIGIPOT_COUNT; i++) { - boardConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; } - boardConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; - boardConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; - boardConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; - boardConfiguration->max31855spiDevice = SPI_NONE; + engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; + engineConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; + engineConfiguration->max31855spiDevice = SPI_NONE; engineConfiguration->warningLedPin = GPIO_UNASSIGNED; engineConfiguration->runningLedPin = GPIO_UNASSIGNED; - boardConfiguration->useStepperIdle = false; - boardConfiguration->idle.stepperDirectionPin = GPIO_UNASSIGNED; - boardConfiguration->idle.stepperStepPin = GPIO_UNASSIGNED; + engineConfiguration->useStepperIdle = false; + engineConfiguration->idle.stepperDirectionPin = GPIO_UNASSIGNED; + engineConfiguration->idle.stepperStepPin = GPIO_UNASSIGNED; engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED; engineConfiguration->stepperEnablePinMode = OM_DEFAULT; - boardConfiguration->injectionPins[8] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[9] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[10] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[11] = GPIO_UNASSIGNED; - boardConfiguration->isHip9011Enabled = false; + engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED; + engineConfiguration->isHip9011Enabled = false; } diff --git a/firmware/config/boards/microrusefi/board_configuration.cpp b/firmware/config/boards/microrusefi/board_configuration.cpp index c23f373100..d7d800c212 100644 --- a/firmware/config/boards/microrusefi/board_configuration.cpp +++ b/firmware/config/boards/microrusefi/board_configuration.cpp @@ -19,32 +19,32 @@ EXTERN_ENGINE; static void setInjectorPins() { - boardConfiguration->injectionPins[0] = GPIOE_14; - boardConfiguration->injectionPins[1] = GPIOE_13; - boardConfiguration->injectionPins[2] = GPIOE_12; - boardConfiguration->injectionPins[3] = GPIOE_11; + engineConfiguration->injectionPins[0] = GPIOE_14; + engineConfiguration->injectionPins[1] = GPIOE_13; + engineConfiguration->injectionPins[2] = GPIOE_12; + engineConfiguration->injectionPins[3] = GPIOE_11; // Disable remainder for (int i = 4; i < INJECTION_PIN_COUNT;i++) { - boardConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; } - boardConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { // todo: I wonder if these are not right in light of the network rename and the +12 VP issue? - boardConfiguration->ignitionPins[0] = GPIOD_4; - boardConfiguration->ignitionPins[1] = GPIOD_3; - boardConfiguration->ignitionPins[2] = GPIOD_2; - boardConfiguration->ignitionPins[3] = GPIOD_1; + engineConfiguration->ignitionPins[0] = GPIOD_4; + engineConfiguration->ignitionPins[1] = GPIOD_3; + engineConfiguration->ignitionPins[2] = GPIOD_2; + engineConfiguration->ignitionPins[3] = GPIOD_1; // disable remainder for (int i = 4; i < IGNITION_PIN_COUNT; i++) { - boardConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; } - boardConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPinMode = OM_DEFAULT; } static void setLedPins() { @@ -55,7 +55,7 @@ static void setLedPins() { engineConfiguration->communicationLedPin = GPIOE_2; // d23 = blue #endif /* EFI_COMMUNICATION_PIN */ engineConfiguration->runningLedPin = GPIOE_4; // d22 = green - boardConfiguration->triggerErrorPin = GPIOE_1; // d27 = orange + engineConfiguration->triggerErrorPin = GPIOE_1; // d27 = orange } static void setupVbatt() { @@ -71,12 +71,12 @@ static void setupVbatt() { static void setupTle8888() { // Enable spi3 - boardConfiguration->is_enabled_spi_3 = true; + engineConfiguration->is_enabled_spi_3 = true; // Wire up spi3 - boardConfiguration->spi3mosiPin = GPIOB_5; - boardConfiguration->spi3misoPin = GPIOB_4; - boardConfiguration->spi3sckPin = GPIOB_3; + engineConfiguration->spi3mosiPin = GPIOB_5; + engineConfiguration->spi3misoPin = GPIOB_4; + engineConfiguration->spi3sckPin = GPIOB_3; // Chip select engineConfiguration->tle8888_cs = GPIOD_5; @@ -124,9 +124,9 @@ static void setupEtb() { static void setupDefaultSensorInputs() { // trigger inputs // tle8888 VR conditioner - boardConfiguration->triggerInputPins[0] = GPIOC_6; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOC_6; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; // Direct hall-only cam input engineConfiguration->camInputs[0] = GPIOA_5; @@ -157,7 +157,7 @@ void setPinConfigurationOverrides(void) { } void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = false; + engineConfiguration->useSerialPort = false; engineConfiguration->binarySerialTxPin = GPIO_UNASSIGNED; engineConfiguration->binarySerialRxPin = GPIO_UNASSIGNED; engineConfiguration->consoleSerialTxPin = GPIO_UNASSIGNED; @@ -185,16 +185,16 @@ void setBoardConfigurationOverrides(void) { // todo: maybe even set EFI_MAIN_RELAY_CONTROL to FALSE for MRE configuration // TLE8888 half bridges (pushpull, lowside, or high-low) TLE8888_IN11 / TLE8888_OUT21 // GPIOE_8: "35 - GP Out 1" - boardConfiguration->fuelPumpPin = GPIOE_8; + engineConfiguration->fuelPumpPin = GPIOE_8; // TLE8888 high current low side: VVT2 IN9 / OUT5 // GPIOE_10: "3 - Lowside 2" - boardConfiguration->idle.solenoidPin = GPIOE_10; + engineConfiguration->idle.solenoidPin = GPIOE_10; // TLE8888_PIN_22: "34 - GP Out 2" - boardConfiguration->fanPin = TLE8888_PIN_22; + engineConfiguration->fanPin = TLE8888_PIN_22; // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); diff --git a/firmware/config/boards/nucleo_f767/board_configuration.cpp b/firmware/config/boards/nucleo_f767/board_configuration.cpp index c4bbf9ae07..fda5cb365d 100644 --- a/firmware/config/boards/nucleo_f767/board_configuration.cpp +++ b/firmware/config/boards/nucleo_f767/board_configuration.cpp @@ -24,12 +24,12 @@ void setPinConfigurationOverrides(void) { } void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = true; + engineConfiguration->useSerialPort = true; engineConfiguration->binarySerialTxPin = GPIOD_8; engineConfiguration->binarySerialRxPin = GPIOD_9; engineConfiguration->consoleSerialTxPin = GPIOD_8; engineConfiguration->consoleSerialRxPin = GPIOD_9; - boardConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; + engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } @@ -56,28 +56,28 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->dizzySparkOutputPin = GPIO_UNASSIGNED; engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; engineConfiguration->displayMode = DM_NONE; - boardConfiguration->HD44780_rs = GPIO_UNASSIGNED; - boardConfiguration->HD44780_e = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; + engineConfiguration->HD44780_e = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; for (int i = 0; i < DIGIPOT_COUNT ; i++) { - boardConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; } - boardConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; - boardConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; engineConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; - boardConfiguration->max31855spiDevice = SPI_NONE; + engineConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; + engineConfiguration->max31855spiDevice = SPI_NONE; ///////////////////////////////////////////////////////// - boardConfiguration->is_enabled_spi_1 = false; - boardConfiguration->is_enabled_spi_2 = false; - boardConfiguration->is_enabled_spi_3 = false; + engineConfiguration->is_enabled_spi_1 = false; + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->is_enabled_spi_3 = false; } void setAdcChannelOverrides(void) { diff --git a/firmware/config/boards/nucleo_h743/board.h b/firmware/config/boards/nucleo_h743/board.h index 06ac52fbf9..0dcc966702 100644 --- a/firmware/config/boards/nucleo_h743/board.h +++ b/firmware/config/boards/nucleo_h743/board.h @@ -36,6 +36,16 @@ #define BOARD_ST_NUCLEO144_H743ZI #define BOARD_NAME "STMicroelectronics STM32 Nucleo144-H743ZI" +/* + * input-floating is the default pin mode. input-output boards should provision appropriate pull-ups/pull-downs. + */ +#define EFI_PIN_MODE_DEFAULT PIN_MODE_INPUT +#define EFI_DR_DEFAULT PIN_PUPDR_FLOATING + +// See https://github.com/rusefi/rusefi/issues/397 +#define DEFAULT_GPIO_SPEED PIN_OSPEED_HIGH + + /* * Ethernet PHY type. */ @@ -572,13 +582,13 @@ * PA14 - SWCLK (alternate 0). * PA15 - ZIO_D20 I2S3_WS (input pullup). */ -#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_ZIO_D32) | \ +#define VAL_GPIOA_MODER (EFI_PIN_MODE_DEFAULT(GPIOA_ZIO_D32) | \ PIN_MODE_ALTERNATE(GPIOA_RMII_REF_CLK) |\ PIN_MODE_ALTERNATE(GPIOA_RMII_MDIO) | \ - PIN_MODE_INPUT(GPIOA_ARD_A0) | \ - PIN_MODE_INPUT(GPIOA_ZIO_D24) | \ - PIN_MODE_INPUT(GPIOA_ARD_D13) | \ - PIN_MODE_INPUT(GPIOA_ARD_D12) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_ARD_A0) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_ZIO_D24) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_ARD_D13) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_ARD_D12) | \ PIN_MODE_ALTERNATE(GPIOA_ARD_D11) | \ PIN_MODE_ALTERNATE(GPIOA_USB_SOF) | \ PIN_MODE_ANALOG(GPIOA_USB_VBUS) | \ @@ -587,7 +597,7 @@ PIN_MODE_ALTERNATE(GPIOA_USB_DP) | \ PIN_MODE_ALTERNATE(GPIOA_SWDIO) | \ PIN_MODE_ALTERNATE(GPIOA_SWCLK) | \ - PIN_MODE_INPUT(GPIOA_ZIO_D20)) + EFI_PIN_MODE_DEFAULT(GPIOA_ZIO_D20)) #define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_ZIO_D32) | \ PIN_OTYPE_PUSHPULL(GPIOA_RMII_REF_CLK) |\ PIN_OTYPE_PUSHPULL(GPIOA_RMII_MDIO) | \ @@ -604,37 +614,37 @@ PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | \ PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | \ PIN_OTYPE_PUSHPULL(GPIOA_ZIO_D20)) -#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_HIGH(GPIOA_ZIO_D32) | \ - PIN_OSPEED_HIGH(GPIOA_RMII_REF_CLK) | \ - PIN_OSPEED_HIGH(GPIOA_RMII_MDIO) | \ - PIN_OSPEED_HIGH(GPIOA_ARD_A0) | \ - PIN_OSPEED_HIGH(GPIOA_ZIO_D24) | \ - PIN_OSPEED_HIGH(GPIOA_ARD_D13) | \ - PIN_OSPEED_HIGH(GPIOA_ARD_D12) | \ - PIN_OSPEED_HIGH(GPIOA_ARD_D11) | \ - PIN_OSPEED_HIGH(GPIOA_USB_SOF) | \ - PIN_OSPEED_HIGH(GPIOA_USB_VBUS) | \ - PIN_OSPEED_HIGH(GPIOA_USB_ID) | \ - PIN_OSPEED_HIGH(GPIOA_USB_DM) | \ - PIN_OSPEED_HIGH(GPIOA_USB_DP) | \ - PIN_OSPEED_HIGH(GPIOA_SWDIO) | \ - PIN_OSPEED_HIGH(GPIOA_SWCLK) | \ - PIN_OSPEED_HIGH(GPIOA_ZIO_D20)) +#define VAL_GPIOA_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOA_ZIO_D32) | \ + DEFAULT_GPIO_SPEED(GPIOA_RMII_REF_CLK) | \ + DEFAULT_GPIO_SPEED(GPIOA_RMII_MDIO) | \ + DEFAULT_GPIO_SPEED(GPIOA_ARD_A0) | \ + DEFAULT_GPIO_SPEED(GPIOA_ZIO_D24) | \ + DEFAULT_GPIO_SPEED(GPIOA_ARD_D13) | \ + DEFAULT_GPIO_SPEED(GPIOA_ARD_D12) | \ + DEFAULT_GPIO_SPEED(GPIOA_ARD_D11) | \ + DEFAULT_GPIO_SPEED(GPIOA_USB_SOF) | \ + DEFAULT_GPIO_SPEED(GPIOA_USB_VBUS) | \ + DEFAULT_GPIO_SPEED(GPIOA_USB_ID) | \ + DEFAULT_GPIO_SPEED(GPIOA_USB_DM) | \ + DEFAULT_GPIO_SPEED(GPIOA_USB_DP) | \ + DEFAULT_GPIO_SPEED(GPIOA_SWDIO) | \ + DEFAULT_GPIO_SPEED(GPIOA_SWCLK) | \ + DEFAULT_GPIO_SPEED(GPIOA_ZIO_D20)) #define VAL_GPIOA_PUPDR (PIN_PUPDR_PULLUP(GPIOA_ZIO_D32) | \ - PIN_PUPDR_FLOATING(GPIOA_RMII_REF_CLK) |\ + EFI_DR_DEFAULT(GPIOA_RMII_REF_CLK) |\ PIN_PUPDR_PULLUP(GPIOA_RMII_MDIO) | \ PIN_PUPDR_PULLUP(GPIOA_ARD_A0) | \ PIN_PUPDR_PULLUP(GPIOA_ZIO_D24) | \ PIN_PUPDR_PULLUP(GPIOA_ARD_D13) | \ PIN_PUPDR_PULLUP(GPIOA_ARD_D12) | \ PIN_PUPDR_PULLUP(GPIOA_ARD_D11) | \ - PIN_PUPDR_FLOATING(GPIOA_USB_SOF) | \ - PIN_PUPDR_FLOATING(GPIOA_USB_VBUS) | \ - PIN_PUPDR_FLOATING(GPIOA_USB_ID) | \ - PIN_PUPDR_FLOATING(GPIOA_USB_DM) | \ - PIN_PUPDR_FLOATING(GPIOA_USB_DP) | \ - PIN_PUPDR_FLOATING(GPIOA_SWDIO) | \ - PIN_PUPDR_FLOATING(GPIOA_SWCLK) | \ + EFI_DR_DEFAULT(GPIOA_USB_SOF) | \ + EFI_DR_DEFAULT(GPIOA_USB_VBUS) | \ + EFI_DR_DEFAULT(GPIOA_USB_ID) | \ + EFI_DR_DEFAULT(GPIOA_USB_DM) | \ + EFI_DR_DEFAULT(GPIOA_USB_DP) | \ + EFI_DR_DEFAULT(GPIOA_SWDIO) | \ + EFI_DR_DEFAULT(GPIOA_SWCLK) | \ PIN_PUPDR_PULLUP(GPIOA_ZIO_D20)) #define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_ZIO_D32) | \ PIN_ODR_HIGH(GPIOA_RMII_REF_CLK) | \ @@ -690,21 +700,21 @@ * PB15 - ZIO_D17 I2S2_SD (input pullup). */ #define VAL_GPIOB_MODER (PIN_MODE_OUTPUT(GPIOB_ZIO_D33) | \ - PIN_MODE_INPUT(GPIOB_ZIO_A6) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D27) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D23) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D25) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D22) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D26) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_A6) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D27) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D23) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D25) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D22) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D26) | \ PIN_MODE_OUTPUT(GPIOB_LED2) | \ - PIN_MODE_INPUT(GPIOB_ARD_D15) | \ - PIN_MODE_INPUT(GPIOB_ARD_D14) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D36) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D35) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D19) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ARD_D15) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ARD_D14) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D36) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D35) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D19) | \ PIN_MODE_ALTERNATE(GPIOB_ZIO_D18) | \ PIN_MODE_OUTPUT(GPIOB_LED3) | \ - PIN_MODE_INPUT(GPIOB_ZIO_D17)) + EFI_PIN_MODE_DEFAULT(GPIOB_ZIO_D17)) #define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_ZIO_D33) | \ PIN_OTYPE_PUSHPULL(GPIOB_ZIO_A6) | \ PIN_OTYPE_PUSHPULL(GPIOB_ZIO_D27) | \ @@ -721,37 +731,37 @@ PIN_OTYPE_PUSHPULL(GPIOB_ZIO_D18) | \ PIN_OTYPE_PUSHPULL(GPIOB_LED3) | \ PIN_OTYPE_PUSHPULL(GPIOB_ZIO_D17)) -#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_HIGH(GPIOB_ZIO_D33) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_A6) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D27) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D23) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D25) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D22) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D26) | \ - PIN_OSPEED_HIGH(GPIOB_LED2) | \ - PIN_OSPEED_HIGH(GPIOB_ARD_D15) | \ - PIN_OSPEED_HIGH(GPIOB_ARD_D14) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D36) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D35) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D19) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D18) | \ - PIN_OSPEED_HIGH(GPIOB_LED3) | \ - PIN_OSPEED_HIGH(GPIOB_ZIO_D17)) -#define VAL_GPIOB_PUPDR (PIN_PUPDR_FLOATING(GPIOB_ZIO_D33) | \ +#define VAL_GPIOB_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOB_ZIO_D33) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_A6) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D27) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D23) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D25) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D22) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D26) | \ + DEFAULT_GPIO_SPEED(GPIOB_LED2) | \ + DEFAULT_GPIO_SPEED(GPIOB_ARD_D15) | \ + DEFAULT_GPIO_SPEED(GPIOB_ARD_D14) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D36) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D35) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D19) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D18) | \ + DEFAULT_GPIO_SPEED(GPIOB_LED3) | \ + DEFAULT_GPIO_SPEED(GPIOB_ZIO_D17)) +#define VAL_GPIOB_PUPDR (EFI_DR_DEFAULT(GPIOB_ZIO_D33) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_A6) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D27) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D23) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D25) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D22) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D26) | \ - PIN_PUPDR_FLOATING(GPIOB_LED2) | \ + EFI_DR_DEFAULT(GPIOB_LED2) | \ PIN_PUPDR_PULLUP(GPIOB_ARD_D15) | \ PIN_PUPDR_PULLUP(GPIOB_ARD_D14) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D36) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D35) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D19) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D18) | \ - PIN_PUPDR_FLOATING(GPIOB_LED3) | \ + EFI_DR_DEFAULT(GPIOB_LED3) | \ PIN_PUPDR_PULLUP(GPIOB_ZIO_D17)) #define VAL_GPIOB_ODR (PIN_ODR_LOW(GPIOB_ZIO_D33) | \ PIN_ODR_HIGH(GPIOB_ZIO_A6) | \ @@ -806,22 +816,22 @@ * PC14 - OSC32_IN (input floating). * PC15 - OSC32_OUT (input floating). */ -#define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_ARD_A1) | \ +#define VAL_GPIOC_MODER (EFI_PIN_MODE_DEFAULT(GPIOC_ARD_A1) | \ PIN_MODE_ALTERNATE(GPIOC_RMII_MDC) | \ - PIN_MODE_INPUT(GPIOC_ZIO_A7) | \ - PIN_MODE_INPUT(GPIOC_ARD_A2) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_A7) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ARD_A2) | \ PIN_MODE_ALTERNATE(GPIOC_RMII_RXD0) | \ PIN_MODE_ALTERNATE(GPIOC_RMII_RXD1) | \ - PIN_MODE_INPUT(GPIOC_ZIO_D16) | \ - PIN_MODE_INPUT(GPIOC_ZIO_D21) | \ - PIN_MODE_INPUT(GPIOC_ZIO_D43) | \ - PIN_MODE_INPUT(GPIOC_ZIO_D44) | \ - PIN_MODE_INPUT(GPIOC_ZIO_D45) | \ - PIN_MODE_INPUT(GPIOC_ZIO_D46) | \ - PIN_MODE_INPUT(GPIOC_ZIO_D47) | \ - PIN_MODE_INPUT(GPIOC_BUTTON) | \ - PIN_MODE_INPUT(GPIOC_OSC32_IN) | \ - PIN_MODE_INPUT(GPIOC_OSC32_OUT)) + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_D16) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_D21) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_D43) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_D44) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_D45) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_D46) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_ZIO_D47) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_BUTTON) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_OSC32_IN) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_OSC32_OUT)) #define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_ARD_A1) | \ PIN_OTYPE_PUSHPULL(GPIOC_RMII_MDC) | \ PIN_OTYPE_PUSHPULL(GPIOC_ZIO_A7) | \ @@ -838,28 +848,28 @@ PIN_OTYPE_PUSHPULL(GPIOC_BUTTON) | \ PIN_OTYPE_PUSHPULL(GPIOC_OSC32_IN) | \ PIN_OTYPE_PUSHPULL(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_HIGH(GPIOC_ARD_A1) | \ - PIN_OSPEED_HIGH(GPIOC_RMII_MDC) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_A7) | \ - PIN_OSPEED_HIGH(GPIOC_ARD_A2) | \ - PIN_OSPEED_HIGH(GPIOC_RMII_RXD0) | \ - PIN_OSPEED_HIGH(GPIOC_RMII_RXD1) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_D16) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_D21) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_D43) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_D44) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_D45) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_D46) | \ - PIN_OSPEED_HIGH(GPIOC_ZIO_D47) | \ - PIN_OSPEED_HIGH(GPIOC_BUTTON) | \ +#define VAL_GPIOC_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOC_ARD_A1) | \ + DEFAULT_GPIO_SPEED(GPIOC_RMII_MDC) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_A7) | \ + DEFAULT_GPIO_SPEED(GPIOC_ARD_A2) | \ + DEFAULT_GPIO_SPEED(GPIOC_RMII_RXD0) | \ + DEFAULT_GPIO_SPEED(GPIOC_RMII_RXD1) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_D16) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_D21) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_D43) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_D44) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_D45) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_D46) | \ + DEFAULT_GPIO_SPEED(GPIOC_ZIO_D47) | \ + DEFAULT_GPIO_SPEED(GPIOC_BUTTON) | \ PIN_OSPEED_VERYLOW(GPIOC_OSC32_IN) | \ PIN_OSPEED_VERYLOW(GPIOC_OSC32_OUT)) #define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_ARD_A1) | \ - PIN_PUPDR_FLOATING(GPIOC_RMII_MDC) | \ + EFI_DR_DEFAULT(GPIOC_RMII_MDC) | \ PIN_PUPDR_PULLUP(GPIOC_ZIO_A7) | \ PIN_PUPDR_PULLUP(GPIOC_ARD_A2) | \ - PIN_PUPDR_FLOATING(GPIOC_RMII_RXD0) | \ - PIN_PUPDR_FLOATING(GPIOC_RMII_RXD1) | \ + EFI_DR_DEFAULT(GPIOC_RMII_RXD0) | \ + EFI_DR_DEFAULT(GPIOC_RMII_RXD1) | \ PIN_PUPDR_PULLUP(GPIOC_ZIO_D16) | \ PIN_PUPDR_PULLUP(GPIOC_ZIO_D21) | \ PIN_PUPDR_PULLUP(GPIOC_ZIO_D43) | \ @@ -867,9 +877,9 @@ PIN_PUPDR_PULLUP(GPIOC_ZIO_D45) | \ PIN_PUPDR_PULLUP(GPIOC_ZIO_D46) | \ PIN_PUPDR_PULLUP(GPIOC_ZIO_D47) | \ - PIN_PUPDR_FLOATING(GPIOC_BUTTON) | \ - PIN_PUPDR_FLOATING(GPIOC_OSC32_IN) | \ - PIN_PUPDR_FLOATING(GPIOC_OSC32_OUT)) + EFI_DR_DEFAULT(GPIOC_BUTTON) | \ + EFI_DR_DEFAULT(GPIOC_OSC32_IN) | \ + EFI_DR_DEFAULT(GPIOC_OSC32_OUT)) #define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_ARD_A1) | \ PIN_ODR_HIGH(GPIOC_RMII_MDC) | \ PIN_ODR_HIGH(GPIOC_ZIO_A7) | \ @@ -923,22 +933,22 @@ * PD14 - ARD_D10 SPI1_NSS (input pullup). * PD15 - ARD_D9 TIM4_CH4 (input pullup). */ -#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_ZIO_D67) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D66) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D48) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D55) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D54) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D53) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D52) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D51) | \ +#define VAL_GPIOD_MODER (EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D67) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D66) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D48) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D55) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D54) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D53) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D52) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D51) | \ PIN_MODE_ALTERNATE(GPIOD_USART3_RX) | \ PIN_MODE_ALTERNATE(GPIOD_USART3_TX) | \ - PIN_MODE_INPUT(GPIOD_PIN10) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D30) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D29) | \ - PIN_MODE_INPUT(GPIOD_ZIO_D28) | \ - PIN_MODE_INPUT(GPIOD_ARD_D10) | \ - PIN_MODE_INPUT(GPIOD_ARD_D9)) + EFI_PIN_MODE_DEFAULT(GPIOD_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D30) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D29) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ZIO_D28) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ARD_D10) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_ARD_D9)) #define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_ZIO_D67) | \ PIN_OTYPE_PUSHPULL(GPIOD_ZIO_D66) | \ PIN_OTYPE_PUSHPULL(GPIOD_ZIO_D48) | \ @@ -955,22 +965,22 @@ PIN_OTYPE_PUSHPULL(GPIOD_ZIO_D28) | \ PIN_OTYPE_PUSHPULL(GPIOD_ARD_D10) | \ PIN_OTYPE_PUSHPULL(GPIOD_ARD_D9)) -#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_HIGH(GPIOD_ZIO_D67) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D66) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D48) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D55) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D54) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D53) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D52) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D51) | \ - PIN_OSPEED_HIGH(GPIOD_USART3_RX) | \ - PIN_OSPEED_HIGH(GPIOD_USART3_TX) | \ +#define VAL_GPIOD_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOD_ZIO_D67) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D66) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D48) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D55) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D54) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D53) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D52) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D51) | \ + DEFAULT_GPIO_SPEED(GPIOD_USART3_RX) | \ + DEFAULT_GPIO_SPEED(GPIOD_USART3_TX) | \ PIN_OSPEED_VERYLOW(GPIOD_PIN10) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D30) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D29) | \ - PIN_OSPEED_HIGH(GPIOD_ZIO_D28) | \ - PIN_OSPEED_HIGH(GPIOD_ARD_D10) | \ - PIN_OSPEED_HIGH(GPIOD_ARD_D9)) + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D30) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D29) | \ + DEFAULT_GPIO_SPEED(GPIOD_ZIO_D28) | \ + DEFAULT_GPIO_SPEED(GPIOD_ARD_D10) | \ + DEFAULT_GPIO_SPEED(GPIOD_ARD_D9)) #define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_ZIO_D67) | \ PIN_PUPDR_PULLUP(GPIOD_ZIO_D66) | \ PIN_PUPDR_PULLUP(GPIOD_ZIO_D48) | \ @@ -979,8 +989,8 @@ PIN_PUPDR_PULLUP(GPIOD_ZIO_D53) | \ PIN_PUPDR_PULLUP(GPIOD_ZIO_D52) | \ PIN_PUPDR_PULLUP(GPIOD_ZIO_D51) | \ - PIN_PUPDR_FLOATING(GPIOD_USART3_RX) | \ - PIN_PUPDR_FLOATING(GPIOD_USART3_TX) | \ + EFI_DR_DEFAULT(GPIOD_USART3_RX) | \ + EFI_DR_DEFAULT(GPIOD_USART3_TX) | \ PIN_PUPDR_PULLUP(GPIOD_PIN10) | \ PIN_PUPDR_PULLUP(GPIOD_ZIO_D30) | \ PIN_PUPDR_PULLUP(GPIOD_ZIO_D29) | \ @@ -1040,22 +1050,22 @@ * PE14 - ZIO_D38 (input pullup). * PE15 - ZIO_D37 TIM1_BKIN1 (input pullup). */ -#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_ZIO_D34) | \ - PIN_MODE_INPUT(GPIOE_PIN1) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D31) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D60) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D57) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D58) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D59) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D41) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D42) | \ - PIN_MODE_INPUT(GPIOE_ARD_D6) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D40) | \ - PIN_MODE_INPUT(GPIOE_ARD_D5) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D39) | \ - PIN_MODE_INPUT(GPIOE_ARD_D3) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D38) | \ - PIN_MODE_INPUT(GPIOE_ZIO_D37)) +#define VAL_GPIOE_MODER (EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D34) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D31) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D60) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D57) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D58) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D59) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D41) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D42) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ARD_D6) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D40) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ARD_D5) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D39) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ARD_D3) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D38) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_ZIO_D37)) #define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_ZIO_D34) | \ PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOE_ZIO_D31) | \ @@ -1072,22 +1082,22 @@ PIN_OTYPE_PUSHPULL(GPIOE_ARD_D3) | \ PIN_OTYPE_PUSHPULL(GPIOE_ZIO_D38) | \ PIN_OTYPE_PUSHPULL(GPIOE_ZIO_D37)) -#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_HIGH(GPIOE_ZIO_D34) | \ +#define VAL_GPIOE_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOE_ZIO_D34) | \ PIN_OSPEED_VERYLOW(GPIOE_PIN1) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D31) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D60) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D57) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D58) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D59) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D41) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D42) | \ - PIN_OSPEED_HIGH(GPIOE_ARD_D6) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D40) | \ - PIN_OSPEED_HIGH(GPIOE_ARD_D5) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D39) | \ - PIN_OSPEED_HIGH(GPIOE_ARD_D3) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D31) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D60) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D57) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D58) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D59) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D41) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D42) | \ + DEFAULT_GPIO_SPEED(GPIOE_ARD_D6) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D40) | \ + DEFAULT_GPIO_SPEED(GPIOE_ARD_D5) | \ + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D39) | \ + DEFAULT_GPIO_SPEED(GPIOE_ARD_D3) | \ PIN_OSPEED_VERYLOW(GPIOE_ZIO_D38) | \ - PIN_OSPEED_HIGH(GPIOE_ZIO_D37)) + DEFAULT_GPIO_SPEED(GPIOE_ZIO_D37)) #define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_ZIO_D34) | \ PIN_PUPDR_PULLUP(GPIOE_PIN1) | \ PIN_PUPDR_PULLUP(GPIOE_ZIO_D31) | \ @@ -1157,22 +1167,22 @@ * PF14 - ARD_D4 (input pullup). * PF15 - ARD_D2 (input pullup). */ -#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_ZIO_D68) | \ - PIN_MODE_INPUT(GPIOF_ZIO_D69) | \ - PIN_MODE_INPUT(GPIOF_ZIO_D70) | \ - PIN_MODE_INPUT(GPIOF_ARD_A3) | \ - PIN_MODE_INPUT(GPIOF_ZIO_A8) | \ - PIN_MODE_INPUT(GPIOF_ARD_A4) | \ - PIN_MODE_INPUT(GPIOF_PIN6) | \ - PIN_MODE_INPUT(GPIOF_ZIO_D62) | \ - PIN_MODE_INPUT(GPIOF_ZIO_D61) | \ - PIN_MODE_INPUT(GPIOF_ZIO_D63) | \ - PIN_MODE_INPUT(GPIOF_ARD_A5) | \ - PIN_MODE_INPUT(GPIOF_PIN11) | \ - PIN_MODE_INPUT(GPIOF_ARD_D8) | \ - PIN_MODE_INPUT(GPIOF_ARD_D7) | \ - PIN_MODE_INPUT(GPIOF_ARD_D4) | \ - PIN_MODE_INPUT(GPIOF_ARD_D2)) +#define VAL_GPIOF_MODER (EFI_PIN_MODE_DEFAULT(GPIOF_ZIO_D68) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ZIO_D69) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ZIO_D70) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ARD_A3) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ZIO_A8) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ARD_A4) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ZIO_D62) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ZIO_D61) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ZIO_D63) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ARD_A5) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ARD_D8) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ARD_D7) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ARD_D4) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_ARD_D2)) #define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_ZIO_D68) | \ PIN_OTYPE_PUSHPULL(GPIOF_ZIO_D69) | \ PIN_OTYPE_PUSHPULL(GPIOF_ZIO_D70) | \ @@ -1189,17 +1199,17 @@ PIN_OTYPE_PUSHPULL(GPIOF_ARD_D7) | \ PIN_OTYPE_PUSHPULL(GPIOF_ARD_D4) | \ PIN_OTYPE_PUSHPULL(GPIOF_ARD_D2)) -#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_ZIO_D68) | \ - PIN_OSPEED_HIGH(GPIOF_ZIO_D69) | \ - PIN_OSPEED_HIGH(GPIOF_ZIO_D70) | \ - PIN_OSPEED_HIGH(GPIOF_ARD_A3) | \ - PIN_OSPEED_HIGH(GPIOF_ZIO_A8) | \ - PIN_OSPEED_HIGH(GPIOF_ARD_A4) | \ +#define VAL_GPIOF_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOF_ZIO_D68) | \ + DEFAULT_GPIO_SPEED(GPIOF_ZIO_D69) | \ + DEFAULT_GPIO_SPEED(GPIOF_ZIO_D70) | \ + DEFAULT_GPIO_SPEED(GPIOF_ARD_A3) | \ + DEFAULT_GPIO_SPEED(GPIOF_ZIO_A8) | \ + DEFAULT_GPIO_SPEED(GPIOF_ARD_A4) | \ PIN_OSPEED_VERYLOW(GPIOF_PIN6) | \ - PIN_OSPEED_HIGH(GPIOF_ZIO_D62) | \ - PIN_OSPEED_HIGH(GPIOF_ZIO_D61) | \ - PIN_OSPEED_HIGH(GPIOF_ZIO_D63) | \ - PIN_OSPEED_HIGH(GPIOF_ARD_A5) | \ + DEFAULT_GPIO_SPEED(GPIOF_ZIO_D62) | \ + DEFAULT_GPIO_SPEED(GPIOF_ZIO_D61) | \ + DEFAULT_GPIO_SPEED(GPIOF_ZIO_D63) | \ + DEFAULT_GPIO_SPEED(GPIOF_ARD_A5) | \ PIN_OSPEED_VERYLOW(GPIOF_PIN11) | \ PIN_OSPEED_VERYLOW(GPIOF_ARD_D8) | \ PIN_OSPEED_VERYLOW(GPIOF_ARD_D7) | \ @@ -1274,22 +1284,22 @@ * PG14 - ARD_D1 USART6_TX (input pullup). * PG15 - PIN15 (input pullup). */ -#define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_ZIO_D65) | \ - PIN_MODE_INPUT(GPIOG_ZIO_D64) | \ - PIN_MODE_INPUT(GPIOG_ZIO_D49) | \ - PIN_MODE_INPUT(GPIOG_ZIO_D50) | \ - PIN_MODE_INPUT(GPIOG_PIN4) | \ - PIN_MODE_INPUT(GPIOG_PIN5) | \ - PIN_MODE_INPUT(GPIOG_USB_GPIO_OUT) | \ - PIN_MODE_INPUT(GPIOG_USB_GPIO_IN) | \ - PIN_MODE_INPUT(GPIOG_PIN8) | \ - PIN_MODE_INPUT(GPIOG_ARD_D0) | \ - PIN_MODE_INPUT(GPIOG_PIN10) | \ +#define VAL_GPIOG_MODER (EFI_PIN_MODE_DEFAULT(GPIOG_ZIO_D65) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_ZIO_D64) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_ZIO_D49) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_ZIO_D50) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_USB_GPIO_OUT) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_USB_GPIO_IN) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_ARD_D0) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN10) | \ PIN_MODE_ALTERNATE(GPIOG_RMII_TX_EN) | \ - PIN_MODE_INPUT(GPIOG_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN12) | \ PIN_MODE_ALTERNATE(GPIOG_RMII_TXD0) | \ - PIN_MODE_INPUT(GPIOG_ARD_D1) | \ - PIN_MODE_INPUT(GPIOG_PIN15)) + EFI_PIN_MODE_DEFAULT(GPIOG_ARD_D1) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN15)) #define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_ZIO_D65) | \ PIN_OTYPE_PUSHPULL(GPIOG_ZIO_D64) | \ PIN_OTYPE_PUSHPULL(GPIOG_ZIO_D49) | \ @@ -1312,15 +1322,15 @@ PIN_OSPEED_VERYLOW(GPIOG_ZIO_D50) | \ PIN_OSPEED_VERYLOW(GPIOG_PIN4) | \ PIN_OSPEED_VERYLOW(GPIOG_PIN5) | \ - PIN_OSPEED_HIGH(GPIOG_USB_GPIO_OUT) | \ - PIN_OSPEED_HIGH(GPIOG_USB_GPIO_IN) | \ + DEFAULT_GPIO_SPEED(GPIOG_USB_GPIO_OUT) | \ + DEFAULT_GPIO_SPEED(GPIOG_USB_GPIO_IN) | \ PIN_OSPEED_VERYLOW(GPIOG_PIN8) | \ - PIN_OSPEED_HIGH(GPIOG_ARD_D0) | \ + DEFAULT_GPIO_SPEED(GPIOG_ARD_D0) | \ PIN_OSPEED_VERYLOW(GPIOG_PIN10) | \ - PIN_OSPEED_HIGH(GPIOG_RMII_TX_EN) | \ + DEFAULT_GPIO_SPEED(GPIOG_RMII_TX_EN) | \ PIN_OSPEED_VERYLOW(GPIOG_PIN12) | \ - PIN_OSPEED_HIGH(GPIOG_RMII_TXD0) | \ - PIN_OSPEED_HIGH(GPIOG_ARD_D1) | \ + DEFAULT_GPIO_SPEED(GPIOG_RMII_TXD0) | \ + DEFAULT_GPIO_SPEED(GPIOG_ARD_D1) | \ PIN_OSPEED_VERYLOW(GPIOG_PIN15)) #define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_ZIO_D65) | \ PIN_PUPDR_PULLUP(GPIOG_ZIO_D64) | \ @@ -1333,9 +1343,9 @@ PIN_PUPDR_PULLUP(GPIOG_PIN8) | \ PIN_PUPDR_PULLUP(GPIOG_ARD_D0) | \ PIN_PUPDR_PULLUP(GPIOG_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOG_RMII_TX_EN) | \ + EFI_DR_DEFAULT(GPIOG_RMII_TX_EN) | \ PIN_PUPDR_PULLUP(GPIOG_PIN12) | \ - PIN_PUPDR_FLOATING(GPIOG_RMII_TXD0) | \ + EFI_DR_DEFAULT(GPIOG_RMII_TXD0) | \ PIN_PUPDR_PULLUP(GPIOG_ARD_D1) | \ PIN_PUPDR_PULLUP(GPIOG_PIN15)) #define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_ZIO_D65) | \ @@ -1391,22 +1401,22 @@ * PH14 - PIN14 (input pullup). * PH15 - PIN15 (input pullup). */ -#define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_OSC_IN) | \ - PIN_MODE_INPUT(GPIOH_OSC_OUT) | \ - PIN_MODE_INPUT(GPIOH_PIN2) | \ - PIN_MODE_INPUT(GPIOH_PIN3) | \ - PIN_MODE_INPUT(GPIOH_PIN4) | \ - PIN_MODE_INPUT(GPIOH_PIN5) | \ - PIN_MODE_INPUT(GPIOH_PIN6) | \ - PIN_MODE_INPUT(GPIOH_PIN7) | \ - PIN_MODE_INPUT(GPIOH_PIN8) | \ - PIN_MODE_INPUT(GPIOH_PIN9) | \ - PIN_MODE_INPUT(GPIOH_PIN10) | \ - PIN_MODE_INPUT(GPIOH_PIN11) | \ - PIN_MODE_INPUT(GPIOH_PIN12) | \ - PIN_MODE_INPUT(GPIOH_PIN13) | \ - PIN_MODE_INPUT(GPIOH_PIN14) | \ - PIN_MODE_INPUT(GPIOH_PIN15)) +#define VAL_GPIOH_MODER (EFI_PIN_MODE_DEFAULT(GPIOH_OSC_IN) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_OSC_OUT) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN15)) #define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_OSC_IN) | \ PIN_OTYPE_PUSHPULL(GPIOH_OSC_OUT) | \ PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | \ @@ -1423,8 +1433,8 @@ PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | \ PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | \ PIN_OTYPE_PUSHPULL(GPIOH_PIN15)) -#define VAL_GPIOH_OSPEEDR (PIN_OSPEED_HIGH(GPIOH_OSC_IN) | \ - PIN_OSPEED_HIGH(GPIOH_OSC_OUT) | \ +#define VAL_GPIOH_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOH_OSC_IN) | \ + DEFAULT_GPIO_SPEED(GPIOH_OSC_OUT) | \ PIN_OSPEED_VERYLOW(GPIOH_PIN2) | \ PIN_OSPEED_VERYLOW(GPIOH_PIN3) | \ PIN_OSPEED_VERYLOW(GPIOH_PIN4) | \ @@ -1439,8 +1449,8 @@ PIN_OSPEED_VERYLOW(GPIOH_PIN13) | \ PIN_OSPEED_VERYLOW(GPIOH_PIN14) | \ PIN_OSPEED_VERYLOW(GPIOH_PIN15)) -#define VAL_GPIOH_PUPDR (PIN_PUPDR_FLOATING(GPIOH_OSC_IN) | \ - PIN_PUPDR_FLOATING(GPIOH_OSC_OUT) | \ +#define VAL_GPIOH_PUPDR (EFI_DR_DEFAULT(GPIOH_OSC_IN) | \ + EFI_DR_DEFAULT(GPIOH_OSC_OUT) | \ PIN_PUPDR_PULLUP(GPIOH_PIN2) | \ PIN_PUPDR_PULLUP(GPIOH_PIN3) | \ PIN_PUPDR_PULLUP(GPIOH_PIN4) | \ @@ -1508,22 +1518,22 @@ * PI14 - PIN14 (input pullup). * PI15 - PIN15 (input pullup). */ -#define VAL_GPIOI_MODER (PIN_MODE_INPUT(GPIOI_PIN0) | \ - PIN_MODE_INPUT(GPIOI_PIN1) | \ - PIN_MODE_INPUT(GPIOI_PIN2) | \ - PIN_MODE_INPUT(GPIOI_PIN3) | \ - PIN_MODE_INPUT(GPIOI_PIN4) | \ - PIN_MODE_INPUT(GPIOI_PIN5) | \ - PIN_MODE_INPUT(GPIOI_PIN6) | \ - PIN_MODE_INPUT(GPIOI_PIN7) | \ - PIN_MODE_INPUT(GPIOI_PIN8) | \ - PIN_MODE_INPUT(GPIOI_PIN9) | \ - PIN_MODE_INPUT(GPIOI_PIN10) | \ - PIN_MODE_INPUT(GPIOI_PIN11) | \ - PIN_MODE_INPUT(GPIOI_PIN12) | \ - PIN_MODE_INPUT(GPIOI_PIN13) | \ - PIN_MODE_INPUT(GPIOI_PIN14) | \ - PIN_MODE_INPUT(GPIOI_PIN15)) +#define VAL_GPIOI_MODER (EFI_PIN_MODE_DEFAULT(GPIOI_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN15)) #define VAL_GPIOI_OTYPER (PIN_OTYPE_PUSHPULL(GPIOI_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOI_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOI_PIN2) | \ @@ -1625,22 +1635,22 @@ * PJ14 - PIN14 (input pullup). * PJ15 - PIN15 (input pullup). */ -#define VAL_GPIOJ_MODER (PIN_MODE_INPUT(GPIOJ_PIN0) | \ - PIN_MODE_INPUT(GPIOJ_PIN1) | \ - PIN_MODE_INPUT(GPIOJ_PIN2) | \ - PIN_MODE_INPUT(GPIOJ_PIN3) | \ - PIN_MODE_INPUT(GPIOJ_PIN4) | \ - PIN_MODE_INPUT(GPIOJ_PIN5) | \ - PIN_MODE_INPUT(GPIOJ_PIN6) | \ - PIN_MODE_INPUT(GPIOJ_PIN7) | \ - PIN_MODE_INPUT(GPIOJ_PIN8) | \ - PIN_MODE_INPUT(GPIOJ_PIN9) | \ - PIN_MODE_INPUT(GPIOJ_PIN10) | \ - PIN_MODE_INPUT(GPIOJ_PIN11) | \ - PIN_MODE_INPUT(GPIOJ_PIN12) | \ - PIN_MODE_INPUT(GPIOJ_PIN13) | \ - PIN_MODE_INPUT(GPIOJ_PIN14) | \ - PIN_MODE_INPUT(GPIOJ_PIN15)) +#define VAL_GPIOJ_MODER (EFI_PIN_MODE_DEFAULT(GPIOJ_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOJ_PIN15)) #define VAL_GPIOJ_OTYPER (PIN_OTYPE_PUSHPULL(GPIOJ_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOJ_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOJ_PIN2) | \ @@ -1742,22 +1752,22 @@ * PK14 - PIN14 (input pullup). * PK15 - PIN15 (input pullup). */ -#define VAL_GPIOK_MODER (PIN_MODE_INPUT(GPIOK_PIN0) | \ - PIN_MODE_INPUT(GPIOK_PIN1) | \ - PIN_MODE_INPUT(GPIOK_PIN2) | \ - PIN_MODE_INPUT(GPIOK_PIN3) | \ - PIN_MODE_INPUT(GPIOK_PIN4) | \ - PIN_MODE_INPUT(GPIOK_PIN5) | \ - PIN_MODE_INPUT(GPIOK_PIN6) | \ - PIN_MODE_INPUT(GPIOK_PIN7) | \ - PIN_MODE_INPUT(GPIOK_PIN8) | \ - PIN_MODE_INPUT(GPIOK_PIN9) | \ - PIN_MODE_INPUT(GPIOK_PIN10) | \ - PIN_MODE_INPUT(GPIOK_PIN11) | \ - PIN_MODE_INPUT(GPIOK_PIN12) | \ - PIN_MODE_INPUT(GPIOK_PIN13) | \ - PIN_MODE_INPUT(GPIOK_PIN14) | \ - PIN_MODE_INPUT(GPIOK_PIN15)) +#define VAL_GPIOK_MODER (EFI_PIN_MODE_DEFAULT(GPIOK_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOK_PIN15)) #define VAL_GPIOK_OTYPER (PIN_OTYPE_PUSHPULL(GPIOK_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOK_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOK_PIN2) | \ diff --git a/firmware/config/boards/prometheus/board_configuration.cpp b/firmware/config/boards/prometheus/board_configuration.cpp index 2faf3efe50..ebd518aa08 100644 --- a/firmware/config/boards/prometheus/board_configuration.cpp +++ b/firmware/config/boards/prometheus/board_configuration.cpp @@ -63,22 +63,22 @@ static void setPrometheusDefaults(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->tpsErrorDetectionTooLow = -10; // -10% open engineConfiguration->tpsErrorDetectionTooHigh = 110; // 110% open - boardConfiguration->mapMinBufferLength = 4; + engineConfiguration->mapMinBufferLength = 4; } void setPinConfigurationOverrides(void) { #if 0 - boardConfiguration->injectionPins[0] = is469 ? GPIOD_9 : GPIOB_14; // #1 - boardConfiguration->injectionPins[1] = is469 ? GPIOD_15 : GPIOC_7; // #2 - boardConfiguration->injectionPins[2] = is469 ? GPIOD_10 : GPIOB_15; // #3 - boardConfiguration->injectionPins[3] = is469 ? GPIOD_14 : GPIOC_6; // #4 + engineConfiguration->injectionPins[0] = is469 ? GPIOD_9 : GPIOB_14; // #1 + engineConfiguration->injectionPins[1] = is469 ? GPIOD_15 : GPIOC_7; // #2 + engineConfiguration->injectionPins[2] = is469 ? GPIOD_10 : GPIOB_15; // #3 + engineConfiguration->injectionPins[3] = is469 ? GPIOD_14 : GPIOC_6; // #4 - boardConfiguration->ignitionPins[0] = GPIOA_10; - boardConfiguration->ignitionPins[1] = GPIOA_9; - boardConfiguration->ignitionPins[2] = GPIOA_8; - boardConfiguration->ignitionPins[3] = GPIOA_11; - boardConfiguration->ignitionPinMode = OM_INVERTED; + engineConfiguration->ignitionPins[0] = GPIOA_10; + engineConfiguration->ignitionPins[1] = GPIOA_9; + engineConfiguration->ignitionPins[2] = GPIOA_8; + engineConfiguration->ignitionPins[3] = GPIOA_11; + engineConfiguration->ignitionPinMode = OM_INVERTED; enginePins.startInjectionPins(); enginePins.startIgnitionPins(); @@ -109,20 +109,20 @@ void setPinConfigurationOverrides(void) { } void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = true; + engineConfiguration->useSerialPort = true; engineConfiguration->binarySerialTxPin = GPIOA_0; engineConfiguration->binarySerialRxPin = GPIOA_1; engineConfiguration->consoleSerialTxPin = GPIOA_0; engineConfiguration->consoleSerialRxPin = GPIOA_1; - boardConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; + engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } void setSdCardConfigurationOverrides(void) { - boardConfiguration->is_enabled_spi_1 = true; + engineConfiguration->is_enabled_spi_1 = true; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_1; - boardConfiguration->sdCardCsPin = GPIOA_2; - boardConfiguration->isSdCardEnabled = true; + engineConfiguration->sdCardCsPin = GPIOA_2; + engineConfiguration->isSdCardEnabled = true; } /** @@ -148,24 +148,24 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; - boardConfiguration->injectionPins[0] = is469 ? GPIOD_9 : GPIOB_14; // #1 - boardConfiguration->injectionPins[1] = is469 ? GPIOD_15 : GPIOC_7; // #2 - boardConfiguration->injectionPins[2] = is469 ? GPIOD_10 : GPIOB_15; // #3 - boardConfiguration->injectionPins[3] = is469 ? GPIOD_14 : GPIOC_6; // #4 + engineConfiguration->injectionPins[0] = is469 ? GPIOD_9 : GPIOB_14; // #1 + engineConfiguration->injectionPins[1] = is469 ? GPIOD_15 : GPIOC_7; // #2 + engineConfiguration->injectionPins[2] = is469 ? GPIOD_10 : GPIOB_15; // #3 + engineConfiguration->injectionPins[3] = is469 ? GPIOD_14 : GPIOC_6; // #4 - boardConfiguration->ignitionPins[0] = GPIOA_10; - boardConfiguration->ignitionPins[1] = GPIOA_9; - boardConfiguration->ignitionPins[2] = GPIOA_8; - boardConfiguration->ignitionPins[3] = GPIOA_11; - boardConfiguration->ignitionPinMode = OM_INVERTED; + engineConfiguration->ignitionPins[0] = GPIOA_10; + engineConfiguration->ignitionPins[1] = GPIOA_9; + engineConfiguration->ignitionPins[2] = GPIOA_8; + engineConfiguration->ignitionPins[3] = GPIOA_11; + engineConfiguration->ignitionPinMode = OM_INVERTED; engineConfiguration->vbattDividerCoeff = ((float) (2 + 10)) / 2; engineConfiguration->clt.config.bias_resistor = 2700; engineConfiguration->iat.config.bias_resistor = 2700; - boardConfiguration->useStepperIdle = true; - boardConfiguration->idle.stepperDirectionPin = is469 ? GPIOB_14 : GPIOB_12; - boardConfiguration->idle.stepperStepPin = is469 ? GPIOB_15 : GPIOB_13; + engineConfiguration->useStepperIdle = true; + engineConfiguration->idle.stepperDirectionPin = is469 ? GPIOB_14 : GPIOB_12; + engineConfiguration->idle.stepperStepPin = is469 ? GPIOB_15 : GPIOB_13; engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED; engineConfiguration->stepperEnablePinMode = OM_DEFAULT; @@ -174,93 +174,93 @@ void setBoardConfigurationOverrides(void) { //engineConfiguration->fatalErrorPin = GPIOA_13; engineConfiguration->warningLedPin = GPIO_UNASSIGNED; - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = is469 ? GPIOE_9 : GPIOA_6; - boardConfiguration->tachOutputPin = GPIOC_8; - boardConfiguration->tachOutputPinMode = OM_DEFAULT; - boardConfiguration->fuelPumpPin = is469 ? GPIOD_6 : GPIOB_7; - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; - boardConfiguration->mainRelayPin = is469 ? GPIOB_11 : GPIOB_2; - boardConfiguration->mainRelayPinMode = OM_DEFAULT; - boardConfiguration->fanPin = GPIOC_9; - boardConfiguration->fanPinMode = OM_DEFAULT; - boardConfiguration->malfunctionIndicatorPin = GPIOC_1; - boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; + engineConfiguration->tachOutputPin = GPIOC_8; + engineConfiguration->tachOutputPinMode = OM_DEFAULT; + engineConfiguration->fuelPumpPin = is469 ? GPIOD_6 : GPIOB_7; + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->mainRelayPin = is469 ? GPIOB_11 : GPIOB_2; + engineConfiguration->mainRelayPinMode = OM_DEFAULT; + engineConfiguration->fanPin = GPIOC_9; + engineConfiguration->fanPinMode = OM_DEFAULT; + engineConfiguration->malfunctionIndicatorPin = GPIOC_1; + engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; // starter block setFsio(0, (is469 ? GPIOB_10 : GPIOB_1), STARTER_RELAY_LOGIC PASS_CONFIG_PARAMETER_SUFFIX); // debug pad - boardConfiguration->triggerSimulatorPins[0] = GPIOD_8; - boardConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPins[0] = GPIOD_8; + engineConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT; // not used engineConfiguration->dizzySparkOutputPin = GPIO_UNASSIGNED; engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; engineConfiguration->displayMode = DM_NONE; - boardConfiguration->HD44780_rs = GPIO_UNASSIGNED; - boardConfiguration->HD44780_e = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; + engineConfiguration->HD44780_e = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; for (int i = 0; i < DIGIPOT_COUNT ; i++) { - boardConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; } - boardConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; - boardConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; engineConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; - boardConfiguration->max31855spiDevice = SPI_NONE; + engineConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; + engineConfiguration->max31855spiDevice = SPI_NONE; ///////////////////////////////////////////////////////// - boardConfiguration->is_enabled_spi_1 = true; - boardConfiguration->is_enabled_spi_2 = false; - boardConfiguration->is_enabled_spi_3 = true; + engineConfiguration->is_enabled_spi_1 = true; + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->is_enabled_spi_3 = true; - boardConfiguration->spi1mosiPin = GPIOB_5; + engineConfiguration->spi1mosiPin = GPIOB_5; engineConfiguration->spi1MosiMode = PO_DEFAULT; // PAL_STM32_OTYPE_PUSHPULL - boardConfiguration->spi1misoPin = GPIOB_4; + engineConfiguration->spi1misoPin = GPIOB_4; engineConfiguration->spi1MisoMode = PO_DEFAULT; // PAL_STM32_OTYPE_PUSHPULL - boardConfiguration->spi1sckPin = GPIOB_3; + engineConfiguration->spi1sckPin = GPIOB_3; engineConfiguration->spi1SckMode = PO_DEFAULT; // PAL_STM32_OTYPE_PUSHPULL - boardConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3mosiPin = GPIOC_12; engineConfiguration->spi3MosiMode = PO_OPENDRAIN; // 4 - boardConfiguration->spi3misoPin = GPIOC_11; + engineConfiguration->spi3misoPin = GPIOC_11; engineConfiguration->spi3MisoMode = PO_PULLUP; // 32 - boardConfiguration->spi3sckPin = GPIOC_10; + engineConfiguration->spi3sckPin = GPIOC_10; engineConfiguration->spi3SckMode = PO_OPENDRAIN; // 4 engineConfiguration->hip9011SpiDevice = SPI_DEVICE_3; - boardConfiguration->hip9011CsPin = is469 ? GPIOD_1 : GPIOD_2; - boardConfiguration->hip9011CsPinMode = OM_OPENDRAIN; - boardConfiguration->hip9011IntHoldPin = GPIOC_14; - boardConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; + engineConfiguration->hip9011CsPin = is469 ? GPIOD_1 : GPIOD_2; + engineConfiguration->hip9011CsPinMode = OM_OPENDRAIN; + engineConfiguration->hip9011IntHoldPin = GPIOC_14; + engineConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; engineConfiguration->hipOutputChannel = EFI_ADC_10; // PC0 - boardConfiguration->isHip9011Enabled = true; + engineConfiguration->isHip9011Enabled = true; engineConfiguration->cj125SpiDevice = SPI_DEVICE_3; engineConfiguration->cj125ua = is469 ? EFI_ADC_9 : EFI_ADC_8; engineConfiguration->cj125ur = EFI_ADC_12; - boardConfiguration->cj125CsPin = GPIOA_15; + engineConfiguration->cj125CsPin = GPIOA_15; engineConfiguration->cj125CsPinMode = OM_OPENDRAIN; - boardConfiguration->wboHeaterPin = GPIOC_13; - boardConfiguration->o2heaterPin = GPIOC_13; - //boardConfiguration->isCJ125Enabled = true; - boardConfiguration->isCJ125Enabled = false; + engineConfiguration->wboHeaterPin = GPIOC_13; + engineConfiguration->o2heaterPin = GPIOC_13; + //engineConfiguration->isCJ125Enabled = true; + engineConfiguration->isCJ125Enabled = false; - boardConfiguration->canDeviceMode = CD_USE_CAN1; - boardConfiguration->canTxPin = GPIOB_9; - boardConfiguration->canRxPin = GPIOB_8; + engineConfiguration->canDeviceMode = CD_USE_CAN1; + engineConfiguration->canTxPin = GPIOB_9; + engineConfiguration->canRxPin = GPIOB_8; //!!!!!!!!!!!!!!! #if 1 diff --git a/firmware/config/boards/proteus/adc_hack.cpp b/firmware/config/boards/proteus/adc_hack.cpp new file mode 100644 index 0000000000..eeb13248fa --- /dev/null +++ b/firmware/config/boards/proteus/adc_hack.cpp @@ -0,0 +1,54 @@ +/** + * @file adc_hack.cpp + * @brief Hacky support for a single channel on adc3 + * + * @date December 17, 2019 + * @author Matthew Kennedy, (c) 2019 + */ + +#include "ch.h" +#include "hal.h" + +#include "mpu_util.h" +#include "io_pins.h" + +#include "efilib.h" + +static ADCConversionGroup adcConvGroup = { FALSE, 1, nullptr, nullptr, + 0, + ADC_CR2_SWSTART, + 0, // sample times for channels 10...18 + ADC_SMPR2_SMP_AN9(ADC_SAMPLE_56), + + 0, // htr + 0, // ltr + + 0, // sqr1 + 0, // sqr2 + ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9) // sqr3 - vbatt is on pf3 = adc9 +}; + +__ALIGNED(32) adcsample_t samples[8]; + +// we use this as a hook to run near the rest of ADC init... +void setAdcChannelOverrides(void) { + efiSetPadMode("adc input", GPIOF_3, PAL_MODE_INPUT_ANALOG); + + adcStart(&ADCD3, nullptr); +} + +adcsample_t vbattSampleProteus = 0; + +void proteusAdcHack() +{ + adcConvert(&ADCD3, &adcConvGroup, samples, 8); + SCB_InvalidateDCache_by_Addr(reinterpret_cast(samples), sizeof(samples)); + + uint32_t sum = 0; + + for (int i = 0; i < 8; i++) { + sum += samples[i]; + } + + vbattSampleProteus = sum / efi::size(samples); +} diff --git a/firmware/config/boards/proteus/board.mk b/firmware/config/boards/proteus/board.mk index eb50754451..83e6d059c4 100644 --- a/firmware/config/boards/proteus/board.mk +++ b/firmware/config/boards/proteus/board.mk @@ -1,6 +1,7 @@ # List of all the board related files. BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO144_F767ZI/board.c -BOARDSRC_CPP = $(PROJECT_DIR)/config/boards/proteus/board_configuration.cpp +BOARDSRC_CPP = $(PROJECT_DIR)/config/boards/proteus/board_configuration.cpp \ + $(PROJECT_DIR)/config/boards/proteus/adc_hack.cpp # Required include directories BOARDINC = $(PROJECT_DIR)/config/boards/nucleo_f767 $(PROJECT_DIR)/config/stm32f7ems @@ -8,4 +9,4 @@ BOARDINC = $(PROJECT_DIR)/config/boards/nucleo_f767 $(PROJECT_DIR)/config/stm32f LDSCRIPT= $(PROJECT_DIR)/config/boards/nucleo_f767/STM32F76xxI.ld # Override DEFAULT_ENGINE_TYPE -DDEFS += -DSTM32F767xx -DEFI_USE_OSC=TRUE -DEFI_FATAL_ERROR_PIN=GPIOE_3 -DFIRMWARE_ID=\"proteus\" -DDEFAULT_ENGINE_TYPE=PROTEUS +DDEFS += -DSTM32F767xx -DEFI_USE_OSC=TRUE -DEFI_FATAL_ERROR_PIN=GPIOE_3 -DFIRMWARE_ID=\"proteus\" -DDEFAULT_ENGINE_TYPE=PROTEUS -DUSE_ADC3_VBATT_HACK -DSTM32_ADC_USE_ADC3=TRUE diff --git a/firmware/config/boards/proteus/board_configuration.cpp b/firmware/config/boards/proteus/board_configuration.cpp index 0554f34496..ac31207589 100644 --- a/firmware/config/boards/proteus/board_configuration.cpp +++ b/firmware/config/boards/proteus/board_configuration.cpp @@ -15,49 +15,55 @@ EXTERN_ENGINE; -static void setInjectorPins() { - boardConfiguration->injectionPins[0] = GPIOD_7; - boardConfiguration->injectionPins[1] = GPIOG_9; - boardConfiguration->injectionPins[2] = GPIOG_10; - boardConfiguration->injectionPins[3] = GPIOG_11; - boardConfiguration->injectionPins[4] = GPIOG_12; - boardConfiguration->injectionPins[5] = GPIOG_13; - boardConfiguration->injectionPins[6] = GPIOG_14; - boardConfiguration->injectionPins[7] = GPIOB_4; - boardConfiguration->injectionPins[8] = GPIOB_5; - boardConfiguration->injectionPins[9] = GPIOB_6; - boardConfiguration->injectionPins[10] = GPIOB_7; - boardConfiguration->injectionPins[11] = GPIOB_8; +static const brain_pin_e injPins[] = { + GPIOD_7, + GPIOG_9, + GPIOG_10, + GPIOG_11, + GPIOG_12, + GPIOG_13, + GPIOG_14, + GPIOB_4, + GPIOB_5, + GPIOB_6, + GPIOB_7, + GPIOB_8 +}; - boardConfiguration->injectionPinMode = OM_DEFAULT; +static const brain_pin_e ignPins[] = { + GPIOD_4, + GPIOD_3, + GPIOC_9, + GPIOC_8, + GPIOC_7, + GPIOG_8, + GPIOG_7, + GPIOG_6, + GPIOG_5, + GPIOG_4, + GPIOG_3, + GPIOG_2, +}; + +static void setInjectorPins() { + copyArray(engineConfiguration->injectionPins, injPins); + engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { - boardConfiguration->ignitionPins[0] = GPIOD_4; - boardConfiguration->ignitionPins[1] = GPIOD_3; - boardConfiguration->ignitionPins[2] = GPIOC_9; - boardConfiguration->ignitionPins[3] = GPIOC_8; - boardConfiguration->ignitionPins[4] = GPIOC_7; - boardConfiguration->ignitionPins[5] = GPIOG_8; - boardConfiguration->ignitionPins[6] = GPIOG_7; - boardConfiguration->ignitionPins[7] = GPIOG_6; - boardConfiguration->ignitionPins[8] = GPIOG_5; - boardConfiguration->ignitionPins[9] = GPIOG_4; - boardConfiguration->ignitionPins[10] = GPIOG_3; - boardConfiguration->ignitionPins[11] = GPIOG_2; - - boardConfiguration->ignitionPinMode = OM_DEFAULT; + copyArray(engineConfiguration->ignitionPins, ignPins); + engineConfiguration->ignitionPinMode = OM_DEFAULT; } static void setLedPins() { engineConfiguration->communicationLedPin = GPIOE_4; engineConfiguration->runningLedPin = GPIOE_5; - boardConfiguration->triggerErrorPin = GPIOE_6; + engineConfiguration->triggerErrorPin = GPIOE_6; } static void setupVbatt() { - // 6.8k high side/10k low side = 1.6667 ratio divider - engineConfiguration->analogInputDividerCoefficient = 2.5f / 1.5f; + // 5.6k high side/10k low side = 1.56 ratio divider + engineConfiguration->analogInputDividerCoefficient = 1.56f; // 47k high side/10k low side = 4.7 engineConfiguration->vbattDividerCoeff = (57.0f / 10.0f); @@ -103,9 +109,9 @@ static void setupEtb() { static void setupDefaultSensorInputs() { // trigger inputs // VR channel 1 as default - others not set - boardConfiguration->triggerInputPins[0] = GPIOC_6; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOC_6; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; // clt = Analog Temp 1 = PC4 @@ -123,7 +129,7 @@ void setPinConfigurationOverrides(void) { } void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = false; + engineConfiguration->useSerialPort = false; engineConfiguration->binarySerialTxPin = GPIO_UNASSIGNED; engineConfiguration->binarySerialRxPin = GPIO_UNASSIGNED; engineConfiguration->consoleSerialTxPin = GPIO_UNASSIGNED; @@ -161,6 +167,3 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SIMULTANEOUS; } - -void setAdcChannelOverrides(void) { -} diff --git a/firmware/config/boards/skeleton/board_configuration.cpp b/firmware/config/boards/skeleton/board_configuration.cpp index 0ca92b6f12..641145b987 100644 --- a/firmware/config/boards/skeleton/board_configuration.cpp +++ b/firmware/config/boards/skeleton/board_configuration.cpp @@ -42,10 +42,10 @@ EXTERN_ENGINE; // This shows a SPI connected TLE8888. static void setupTle8888() { // Enable the SPI channel and set up the SPI pins - boardConfiguration->is_enabled_spi_3 = true; - boardConfiguration->spi3mosiPin = GPIOB_5; - boardConfiguration->spi3misoPin = GPIOB_4; - boardConfiguration->spi3sckPin = GPIOB_3; + engineConfiguration->is_enabled_spi_3 = true; + engineConfiguration->spi3mosiPin = GPIOB_5; + engineConfiguration->spi3misoPin = GPIOB_4; + engineConfiguration->spi3sckPin = GPIOB_3; // SPI chip select is often independent of the SPI pin limitations engineConfiguration->tle8888_cs = GPIOD_5; @@ -81,8 +81,8 @@ static void setupDefaultSensorInputs() { // Engine rotation position sensors // Trigger is our primary timing signal, and usually comes from the crank. // trigger inputs up TRIGGER_SUPPORTED_CHANNELS (2) - boardConfiguration->triggerInputPins[0] = GPIOC_6; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOC_6; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; // A secondary Cam signal up to CAM_INPUTS_COUNT (4) engineConfiguration->camInputs[0] = GPIOA_5; @@ -121,7 +121,7 @@ void setPinConfigurationOverrides(void) { // Future: configure USART3 for LIN bus and UART4 for console void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = false; + engineConfiguration->useSerialPort = false; engineConfiguration->binarySerialTxPin = GPIO_UNASSIGNED; engineConfiguration->binarySerialRxPin = GPIO_UNASSIGNED; engineConfiguration->consoleSerialTxPin = GPIO_UNASSIGNED; @@ -140,7 +140,7 @@ void setBoardConfigurationOverrides(void) { // Set indicator LED pins. // This is often redundant with efifeatures.h or the run-time config - boardConfiguration->triggerErrorPin = GPIOE_1; + engineConfiguration->triggerErrorPin = GPIOE_1; engineConfiguration->communicationLedPin = GPIOE_2; engineConfiguration->FatalErrorPin = GPIOE_3; engineConfiguration->runningLedPin = GPIOE_4; @@ -149,25 +149,25 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->errorLedPin = GPIOE_7; // Set injector pins and the pin output mode - boardConfiguration->injectionPinMode = OM_DEFAULT; - boardConfiguration->injectionPins[0] = GPIOE_14; - boardConfiguration->injectionPins[1] = GPIOE_13; - boardConfiguration->injectionPins[2] = GPIOE_12; - boardConfiguration->injectionPins[3] = GPIOE_11; + engineConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPins[0] = GPIOE_14; + engineConfiguration->injectionPins[1] = GPIOE_13; + engineConfiguration->injectionPins[2] = GPIOE_12; + engineConfiguration->injectionPins[3] = GPIOE_11; // Disable the remainder only when they may never be assigned for (int i = 4; i < INJECTION_PIN_COUNT;i++) { - boardConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; } // Do the same for ignition outputs - boardConfiguration->ignitionPinMode = OM_DEFAULT; - boardConfiguration->ignitionPins[0] = GPIOD_4; - boardConfiguration->ignitionPins[1] = GPIOD_3; - boardConfiguration->ignitionPins[2] = GPIOD_2; - boardConfiguration->ignitionPins[3] = GPIOD_1; + engineConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPins[0] = GPIOD_4; + engineConfiguration->ignitionPins[1] = GPIOD_3; + engineConfiguration->ignitionPins[2] = GPIOD_2; + engineConfiguration->ignitionPins[3] = GPIOD_1; // Disable remainder for (int i = 4; i < IGNITION_PIN_COUNT; i++) { - boardConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; } // Board-specific scaling values to convert ADC fraction to Volts. @@ -199,16 +199,16 @@ void setBoardConfigurationOverrides(void) { // Configure the TLE8888 half bridges (pushpull, lowside, or high-low) // TLE8888_IN11 -> TLE8888_OUT21 // GPIOE_8: "35 - GP Out 1" - boardConfiguration->fuelPumpPin = GPIOE_8; + engineConfiguration->fuelPumpPin = GPIOE_8; // TLE8888 high current low side: VVT2 IN9 / OUT5 // GPIOE_10: "3 - Lowside 2" - boardConfiguration->idle.solenoidPin = GPIOE_10; + engineConfiguration->idle.solenoidPin = GPIOE_10; // TLE8888_PIN_22: "34 - GP Out 2" - boardConfiguration->fanPin = TLE8888_PIN_22; + engineConfiguration->fanPin = TLE8888_PIN_22; // The "required" hardware is done - set some reasonable input defaults setupDefaultSensorInputs(); diff --git a/firmware/config/boards/skeleton/efifeatures.h b/firmware/config/boards/skeleton/efifeatures.h index d48d411b16..38d6d4886a 100644 --- a/firmware/config/boards/skeleton/efifeatures.h +++ b/firmware/config/boards/skeleton/efifeatures.h @@ -267,7 +267,6 @@ // todo: switch to continuous ADC conversion for slow ADC? // https://github.com/rusefi/rusefi/issues/630 -#define EFI_INTERNAL_SLOW_ADC_PWM &PWMD8 // todo: switch to continues ADC conversion for fast ADC? #define EFI_INTERNAL_FAST_ADC_PWM &PWMD4 diff --git a/firmware/config/boards/st_stm32f4/board.h b/firmware/config/boards/st_stm32f4/board.h index 11aa5e44e2..4a100ba869 100644 --- a/firmware/config/boards/st_stm32f4/board.h +++ b/firmware/config/boards/st_stm32f4/board.h @@ -39,6 +39,13 @@ #define EFI_USB_SERIAL_DP GPIOA_12 +/* + * input-floating is the default pin mode. input-output boards should provision appropriate pull-ups/pull-downs. + */ +#define EFI_PIN_MODE_DEFAULT PIN_MODE_INPUT +#define EFI_DR_DEFAULT PIN_PUPDR_FLOATING + + /* * Board oscillators-related settings. * NOTE: LSE not fitted. @@ -70,7 +77,7 @@ /* * IO pins assignments. */ -#define GPIOA_BUTTON 0 +#define GPIOA_PIN0 0 #define GPIOA_PIN1 1 #define GPIOA_PIN2 2 #define GPIOA_PIN3 3 @@ -79,7 +86,7 @@ #define GPIOA_PIN6 6 #define GPIOA_PIN7 7 #define GPIOA_PIN8 8 -#define GPIOA_VBUS_FS 9 +#define GPIOA_PIN9 9 #define GPIOA_PIN10 10 #define GPIOA_PIN11 11 #define GPIOA_PIN12 12 @@ -93,7 +100,7 @@ #define GPIOB_SWO 3 #define GPIOB_PIN4 4 #define GPIOB_PIN5 5 -#define GPIOB_SCL 6 +#define GPIOB_PIN6 6 #define GPIOB_PIN7 7 #define GPIOB_PIN8 8 #define GPIOB_PIN9 9 @@ -226,12 +233,7 @@ /* * IO lines assignments. */ -#define LINE_BUTTON PAL_LINE(GPIOA, 0U) #define LINE_LRCK PAL_LINE(GPIOA, 4U) -#define LINE_SPC PAL_LINE(GPIOA, 5U) -#define LINE_SDO PAL_LINE(GPIOA, 6U) -#define LINE_SDI PAL_LINE(GPIOA, 7U) -#define LINE_VBUS_FS PAL_LINE(GPIOA, 9U) #define LINE_OTG_FS_ID PAL_LINE(GPIOA, 10U) #define LINE_OTG_FS_DM PAL_LINE(GPIOA, 11U) #define LINE_OTG_FS_DP PAL_LINE(GPIOA, 12U) @@ -294,40 +296,30 @@ /* * GPIOA setup: * - * PA0 - BUTTON (input floating). - * PA1 - PIN1 (input pullup). - * PA2 - PIN2 (input pullup). - * PA3 - PIN3 (input pullup). - * PA4 - LRCK (alternate 6). - * PA5 - SPC (alternate 5). - * PA6 - SDO (alternate 5). - * PA7 - SDI (alternate 5). - * PA8 - PIN8 (input pullup). * PA9 - VBUS_FS (input floating). * PA10 - OTG_FS_ID (alternate 10). * PA11 - OTG_FS_DM (alternate 10). * PA12 - OTG_FS_DP (alternate 10). * PA13 - SWDIO (alternate 0). * PA14 - SWCLK (alternate 0). - * PA15 - PIN15 (input pullup). */ -#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_BUTTON) | \ - PIN_MODE_INPUT(GPIOA_PIN1) | \ - PIN_MODE_INPUT(GPIOA_PIN2) | \ - PIN_MODE_INPUT(GPIOA_PIN3) | \ - PIN_MODE_INPUT(GPIOA_LRCK) | \ - PIN_MODE_INPUT(GPIOA_PIN5) | \ - PIN_MODE_INPUT(GPIOA_PIN6) | \ - PIN_MODE_INPUT(GPIOA_PIN7) | \ - PIN_MODE_INPUT(GPIOA_PIN8) | \ - PIN_MODE_INPUT(GPIOA_VBUS_FS) | \ +#define VAL_GPIOA_MODER (EFI_PIN_MODE_DEFAULT(GPIOA_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_LRCK) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN9) | \ PIN_MODE_ALTERNATE(GPIOA_PIN10) | \ PIN_MODE_ALTERNATE(GPIOA_PIN11) | \ PIN_MODE_ALTERNATE(GPIOA_PIN12) | \ PIN_MODE_ALTERNATE(GPIOA_SWDIO) | \ PIN_MODE_ALTERNATE(GPIOA_SWCLK) | \ - PIN_MODE_INPUT(GPIOA_PIN15)) -#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_BUTTON) | \ + EFI_PIN_MODE_DEFAULT(GPIOA_PIN15)) +#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | \ @@ -336,46 +328,46 @@ PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | \ - PIN_OTYPE_PUSHPULL(GPIOA_VBUS_FS) | \ + PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN11) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN12) | \ PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | \ PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | \ PIN_OTYPE_PUSHPULL(GPIOA_PIN15)) -#define VAL_GPIOA_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOA_BUTTON) | \ - DEFAULT_GPIO_SPEED(GPIOA_PIN1) | \ - DEFAULT_GPIO_SPEED(GPIOA_PIN2) | \ - DEFAULT_GPIO_SPEED(GPIOA_PIN3) | \ - DEFAULT_GPIO_SPEED(GPIOA_LRCK) | \ - PIN_OSPEED_MEDIUM(GPIOA_PIN5) | \ - PIN_OSPEED_MEDIUM(GPIOA_PIN6) | \ - PIN_OSPEED_MEDIUM(GPIOA_PIN7) | \ - DEFAULT_GPIO_SPEED(GPIOA_PIN8) | \ - DEFAULT_GPIO_SPEED(GPIOA_VBUS_FS) | \ +#define VAL_GPIOA_OSPEEDR (DEFAULT_GPIO_SPEED(GPIOA_PIN0) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN1) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN2) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN3) | \ + DEFAULT_GPIO_SPEED(GPIOA_LRCK) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN5) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN6) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN7) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN8) | \ + DEFAULT_GPIO_SPEED(GPIOA_PIN9) | \ DEFAULT_GPIO_SPEED(GPIOA_PIN10) | \ DEFAULT_GPIO_SPEED(GPIOA_PIN11) | \ DEFAULT_GPIO_SPEED(GPIOA_PIN12) | \ DEFAULT_GPIO_SPEED(GPIOA_SWDIO) | \ DEFAULT_GPIO_SPEED(GPIOA_SWCLK) | \ DEFAULT_GPIO_SPEED(GPIOA_PIN15)) -#define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(GPIOA_BUTTON) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN1) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN2) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN3) | \ - PIN_PUPDR_FLOATING(GPIOA_LRCK) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN5) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN6) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN7) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN8) | \ - PIN_PUPDR_FLOATING(GPIOA_VBUS_FS) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN12) | \ - PIN_PUPDR_FLOATING(GPIOA_SWDIO) | \ - PIN_PUPDR_FLOATING(GPIOA_SWCLK) | \ +#define VAL_GPIOA_PUPDR (EFI_DR_DEFAULT(GPIOA_PIN0) | \ + EFI_DR_DEFAULT(GPIOA_PIN1) | \ + EFI_DR_DEFAULT(GPIOA_PIN2) | \ + EFI_DR_DEFAULT(GPIOA_PIN3) | \ + EFI_DR_DEFAULT(GPIOA_LRCK) | \ + EFI_DR_DEFAULT(GPIOA_PIN5) | \ + EFI_DR_DEFAULT(GPIOA_PIN6) | \ + EFI_DR_DEFAULT(GPIOA_PIN7) | \ + EFI_DR_DEFAULT(GPIOA_PIN8) | \ + EFI_DR_DEFAULT(GPIOA_PIN9) | \ + EFI_DR_DEFAULT(GPIOA_PIN10) | \ + EFI_DR_DEFAULT(GPIOA_PIN11) | \ + EFI_DR_DEFAULT(GPIOA_PIN12) | \ + EFI_DR_DEFAULT(GPIOA_SWDIO) | \ + EFI_DR_DEFAULT(GPIOA_SWCLK) | \ PIN_PUPDR_PULLUP(GPIOA_PIN15)) -#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_BUTTON) | \ +#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | \ PIN_ODR_HIGH(GPIOA_PIN1) | \ PIN_ODR_HIGH(GPIOA_PIN2) | \ PIN_ODR_HIGH(GPIOA_PIN3) | \ @@ -384,14 +376,14 @@ PIN_ODR_HIGH(GPIOA_PIN6) | \ PIN_ODR_HIGH(GPIOA_PIN7) | \ PIN_ODR_HIGH(GPIOA_PIN8) | \ - PIN_ODR_HIGH(GPIOA_VBUS_FS) | \ + PIN_ODR_HIGH(GPIOA_PIN9) | \ PIN_ODR_HIGH(GPIOA_PIN10) | \ PIN_ODR_HIGH(GPIOA_PIN11) | \ PIN_ODR_HIGH(GPIOA_PIN12) | \ PIN_ODR_HIGH(GPIOA_SWDIO) | \ PIN_ODR_HIGH(GPIOA_SWCLK) | \ PIN_ODR_HIGH(GPIOA_PIN15)) -#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_BUTTON, 0U) | \ +#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0U) | \ PIN_AFIO_AF(GPIOA_PIN1, 0U) | \ PIN_AFIO_AF(GPIOA_PIN2, 0U) | \ PIN_AFIO_AF(GPIOA_PIN3, 0U) | \ @@ -400,7 +392,7 @@ PIN_AFIO_AF(GPIOA_PIN6, 5U) | \ PIN_AFIO_AF(GPIOA_PIN7, 5U)) #define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0U) | \ - PIN_AFIO_AF(GPIOA_VBUS_FS, 0U) | \ + PIN_AFIO_AF(GPIOA_PIN9, 0U) | \ PIN_AFIO_AF(GPIOA_PIN10, 0U) | \ PIN_AFIO_AF(GPIOA_PIN11, 0U) | \ PIN_AFIO_AF(GPIOA_PIN12, 0U) | \ @@ -421,36 +413,36 @@ * PB7 - PIN7 (input pullup). * PB8 - PIN8 (input pullup). * PB9 - SDA (alternate 4). - * PB10 - CLK_IN (input pullup). + * PB10 - PIN10 (input pullup). * PB11 - PIN11 (input pullup). * PB12 - PIN12 (input pullup). * PB13 - PIN13 (input pullup). * PB14 - PIN14 (input pullup). * PB15 - PIN15 (input pullup). */ -#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | \ - PIN_MODE_INPUT(GPIOB_PIN1) | \ - PIN_MODE_INPUT(GPIOB_PIN2) | \ +#define VAL_GPIOB_MODER (EFI_PIN_MODE_DEFAULT(GPIOB_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN2) | \ PIN_MODE_ALTERNATE(GPIOB_SWO) | \ - PIN_MODE_INPUT(GPIOB_PIN4) | \ - PIN_MODE_INPUT(GPIOB_PIN5) | \ - PIN_MODE_ALTERNATE(GPIOB_SCL) | \ - PIN_MODE_INPUT(GPIOB_PIN7) | \ - PIN_MODE_INPUT(GPIOB_PIN8) | \ - PIN_MODE_INPUT(GPIOB_PIN9) | \ - PIN_MODE_INPUT(GPIOB_PIN10) | \ - PIN_MODE_INPUT(GPIOB_PIN11) | \ - PIN_MODE_INPUT(GPIOB_PIN12) | \ - PIN_MODE_INPUT(GPIOB_PIN13) | \ - PIN_MODE_INPUT(GPIOB_PIN14) | \ - PIN_MODE_INPUT(GPIOB_PIN15)) + EFI_PIN_MODE_DEFAULT(GPIOB_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN5) | \ + PIN_MODE_ALTERNATE(GPIOB_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOB_PIN15)) #define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | \ PIN_OTYPE_PUSHPULL(GPIOB_SWO) | \ PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | \ PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | \ - PIN_OTYPE_OPENDRAIN(GPIOB_SCL) | \ + PIN_OTYPE_OPENDRAIN(GPIOB_PIN6) | \ PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | \ PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | \ PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | \ @@ -466,7 +458,7 @@ DEFAULT_GPIO_SPEED(GPIOB_SWO) | \ DEFAULT_GPIO_SPEED(GPIOB_PIN4) | \ DEFAULT_GPIO_SPEED(GPIOB_PIN5) | \ - DEFAULT_GPIO_SPEED(GPIOB_SCL) | \ + DEFAULT_GPIO_SPEED(GPIOB_PIN6) | \ DEFAULT_GPIO_SPEED(GPIOB_PIN7) | \ DEFAULT_GPIO_SPEED(GPIOB_PIN8) | \ DEFAULT_GPIO_SPEED(GPIOB_PIN9) | \ @@ -479,10 +471,10 @@ #define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | \ PIN_PUPDR_PULLUP(GPIOB_PIN1) | \ PIN_PUPDR_PULLUP(GPIOB_PIN2) | \ - PIN_PUPDR_FLOATING(GPIOB_SWO) | \ + EFI_DR_DEFAULT(GPIOB_SWO) | \ PIN_PUPDR_PULLUP(GPIOB_PIN4) | \ PIN_PUPDR_PULLUP(GPIOB_PIN5) | \ - PIN_PUPDR_FLOATING(GPIOB_SCL) | \ + EFI_DR_DEFAULT(GPIOB_PIN6) | \ PIN_PUPDR_PULLDOWN(GPIOB_PIN7) | \ PIN_PUPDR_PULLDOWN(GPIOB_PIN8) | \ PIN_PUPDR_PULLDOWN(GPIOB_PIN9) | \ @@ -498,7 +490,7 @@ PIN_ODR_HIGH(GPIOB_SWO) | \ PIN_ODR_HIGH(GPIOB_PIN4) | \ PIN_ODR_HIGH(GPIOB_PIN5) | \ - PIN_ODR_HIGH(GPIOB_SCL) | \ + PIN_ODR_HIGH(GPIOB_PIN6) | \ PIN_ODR_HIGH(GPIOB_PIN7) | \ PIN_ODR_HIGH(GPIOB_PIN8) | \ PIN_ODR_HIGH(GPIOB_PIN9) | \ @@ -514,7 +506,7 @@ PIN_AFIO_AF(GPIOB_SWO, 0U) | \ PIN_AFIO_AF(GPIOB_PIN4, 0U) | \ PIN_AFIO_AF(GPIOB_PIN5, 0U) | \ - PIN_AFIO_AF(GPIOB_SCL, 4U) | \ + PIN_AFIO_AF(GPIOB_PIN6, 4U) | \ PIN_AFIO_AF(GPIOB_PIN7, 0U)) #define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0U) | \ PIN_AFIO_AF(GPIOB_PIN9, 0U) | \ @@ -546,21 +538,21 @@ * PC15 - PIN15 (input pullup). */ #define VAL_GPIOC_MODER (PIN_MODE_OUTPUT(GPIOC_OTG_FS_POWER_ON) |\ - PIN_MODE_INPUT(GPIOC_PIN1) | \ - PIN_MODE_INPUT(GPIOC_PIN2) | \ - PIN_MODE_INPUT(GPIOC_PIN3) | \ - PIN_MODE_INPUT(GPIOC_PIN4) | \ - PIN_MODE_INPUT(GPIOC_PIN5) | \ - PIN_MODE_INPUT(GPIOC_PIN6) | \ - PIN_MODE_INPUT(GPIOC_PIN7) | \ - PIN_MODE_INPUT(GPIOC_PIN8) | \ - PIN_MODE_INPUT(GPIOC_PIN9) | \ - PIN_MODE_INPUT(GPIOC_PIN10) | \ - PIN_MODE_INPUT(GPIOC_PIN11) | \ - PIN_MODE_INPUT(GPIOC_PIN12) | \ - PIN_MODE_INPUT(GPIOC_PIN13) | \ - PIN_MODE_INPUT(GPIOC_PIN14) | \ - PIN_MODE_INPUT(GPIOC_PIN15)) + EFI_PIN_MODE_DEFAULT(GPIOC_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOC_PIN15)) #define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_OTG_FS_POWER_ON) |\ PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | \ @@ -593,7 +585,7 @@ DEFAULT_GPIO_SPEED(GPIOC_PIN13) | \ DEFAULT_GPIO_SPEED(GPIOC_PIN14) | \ DEFAULT_GPIO_SPEED(GPIOC_PIN15)) -#define VAL_GPIOC_PUPDR (PIN_PUPDR_FLOATING(GPIOC_OTG_FS_POWER_ON) |\ +#define VAL_GPIOC_PUPDR (EFI_DR_DEFAULT(GPIOC_OTG_FS_POWER_ON) |\ PIN_PUPDR_PULLDOWN(GPIOC_PIN1) | \ PIN_PUPDR_PULLDOWN(GPIOC_PIN2) | \ PIN_PUPDR_PULLDOWN(GPIOC_PIN3) | \ @@ -662,18 +654,18 @@ * PD14 - LED5 (output pushpull maximum). * PD15 - LED6 (output pushpull maximum). */ -#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | \ - PIN_MODE_INPUT(GPIOD_PIN1) | \ - PIN_MODE_INPUT(GPIOD_PIN2) | \ - PIN_MODE_INPUT(GPIOD_PIN3) | \ +#define VAL_GPIOD_MODER (EFI_PIN_MODE_DEFAULT(GPIOD_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN3) | \ PIN_MODE_OUTPUT(GPIOD_RESET) | \ - PIN_MODE_INPUT(GPIOD_OVER_CURRENT) | \ - PIN_MODE_INPUT(GPIOD_PIN6) | \ - PIN_MODE_INPUT(GPIOD_PIN7) | \ - PIN_MODE_INPUT(GPIOD_PIN8) | \ - PIN_MODE_INPUT(GPIOD_PIN9) | \ - PIN_MODE_INPUT(GPIOD_PIN10) | \ - PIN_MODE_INPUT(GPIOD_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_OVER_CURRENT) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOD_PIN11) | \ PIN_MODE_OUTPUT(GPIOD_LED4) | \ PIN_MODE_OUTPUT(GPIOD_LED3) | \ PIN_MODE_OUTPUT(GPIOD_LED5) | \ @@ -714,18 +706,18 @@ PIN_PUPDR_PULLUP(GPIOD_PIN1) | \ PIN_PUPDR_PULLUP(GPIOD_PIN2) | \ PIN_PUPDR_PULLUP(GPIOD_PIN3) | \ - PIN_PUPDR_FLOATING(GPIOD_RESET) | \ - PIN_PUPDR_FLOATING(GPIOD_OVER_CURRENT) |\ + EFI_DR_DEFAULT(GPIOD_RESET) | \ + EFI_DR_DEFAULT(GPIOD_OVER_CURRENT) |\ PIN_PUPDR_PULLUP(GPIOD_PIN6) | \ PIN_PUPDR_PULLUP(GPIOD_PIN7) | \ PIN_PUPDR_PULLUP(GPIOD_PIN8) | \ PIN_PUPDR_PULLUP(GPIOD_PIN9) | \ PIN_PUPDR_PULLUP(GPIOD_PIN10) | \ PIN_PUPDR_PULLUP(GPIOD_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOD_LED4) | \ - PIN_PUPDR_FLOATING(GPIOD_LED3) | \ - PIN_PUPDR_FLOATING(GPIOD_LED5) | \ - PIN_PUPDR_FLOATING(GPIOD_LED6)) + EFI_DR_DEFAULT(GPIOD_LED4) | \ + EFI_DR_DEFAULT(GPIOD_LED3) | \ + EFI_DR_DEFAULT(GPIOD_LED5) | \ + EFI_DR_DEFAULT(GPIOD_LED6)) #define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | \ PIN_ODR_HIGH(GPIOD_PIN1) | \ PIN_ODR_HIGH(GPIOD_PIN2) | \ @@ -779,22 +771,22 @@ * PE14 - PIN14 (input floating). * PE15 - PIN15 (input floating). */ -#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | \ - PIN_MODE_INPUT(GPIOE_PIN1) | \ - PIN_MODE_INPUT(GPIOE_PIN2) | \ - PIN_MODE_INPUT(GPIOE_PIN3) | \ - PIN_MODE_INPUT(GPIOE_PIN4) | \ - PIN_MODE_INPUT(GPIOE_PIN5) | \ - PIN_MODE_INPUT(GPIOE_PIN6) | \ - PIN_MODE_INPUT(GPIOE_PIN7) | \ - PIN_MODE_INPUT(GPIOE_PIN8) | \ - PIN_MODE_INPUT(GPIOE_PIN9) | \ - PIN_MODE_INPUT(GPIOE_PIN10) | \ - PIN_MODE_INPUT(GPIOE_PIN11) | \ - PIN_MODE_INPUT(GPIOE_PIN12) | \ - PIN_MODE_INPUT(GPIOE_PIN13) | \ - PIN_MODE_INPUT(GPIOE_PIN14) | \ - PIN_MODE_INPUT(GPIOE_PIN15)) +#define VAL_GPIOE_MODER (EFI_PIN_MODE_DEFAULT(GPIOE_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOE_PIN15)) #define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOE_PIN2) | \ @@ -827,22 +819,22 @@ DEFAULT_GPIO_SPEED(GPIOE_PIN13) | \ DEFAULT_GPIO_SPEED(GPIOE_PIN14) | \ DEFAULT_GPIO_SPEED(GPIOE_PIN15)) -#define VAL_GPIOE_PUPDR (PIN_PUPDR_FLOATING(GPIOE_PIN0) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN1) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN2) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN3) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN4) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN5) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN6) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN7) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN8) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN9) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN12) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN13) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN14) | \ - PIN_PUPDR_FLOATING(GPIOE_PIN15)) +#define VAL_GPIOE_PUPDR (EFI_DR_DEFAULT(GPIOE_PIN0) | \ + EFI_DR_DEFAULT(GPIOE_PIN1) | \ + EFI_DR_DEFAULT(GPIOE_PIN2) | \ + EFI_DR_DEFAULT(GPIOE_PIN3) | \ + EFI_DR_DEFAULT(GPIOE_PIN4) | \ + EFI_DR_DEFAULT(GPIOE_PIN5) | \ + EFI_DR_DEFAULT(GPIOE_PIN6) | \ + EFI_DR_DEFAULT(GPIOE_PIN7) | \ + EFI_DR_DEFAULT(GPIOE_PIN8) | \ + EFI_DR_DEFAULT(GPIOE_PIN9) | \ + EFI_DR_DEFAULT(GPIOE_PIN10) | \ + EFI_DR_DEFAULT(GPIOE_PIN11) | \ + EFI_DR_DEFAULT(GPIOE_PIN12) | \ + EFI_DR_DEFAULT(GPIOE_PIN13) | \ + EFI_DR_DEFAULT(GPIOE_PIN14) | \ + EFI_DR_DEFAULT(GPIOE_PIN15)) #define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | \ PIN_ODR_HIGH(GPIOE_PIN1) | \ PIN_ODR_HIGH(GPIOE_PIN2) | \ @@ -896,22 +888,22 @@ * PF14 - PIN14 (input floating). * PF15 - PIN15 (input floating). */ -#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_PIN0) | \ - PIN_MODE_INPUT(GPIOF_PIN1) | \ - PIN_MODE_INPUT(GPIOF_PIN2) | \ - PIN_MODE_INPUT(GPIOF_PIN3) | \ - PIN_MODE_INPUT(GPIOF_PIN4) | \ - PIN_MODE_INPUT(GPIOF_PIN5) | \ - PIN_MODE_INPUT(GPIOF_PIN6) | \ - PIN_MODE_INPUT(GPIOF_PIN7) | \ - PIN_MODE_INPUT(GPIOF_PIN8) | \ - PIN_MODE_INPUT(GPIOF_PIN9) | \ - PIN_MODE_INPUT(GPIOF_PIN10) | \ - PIN_MODE_INPUT(GPIOF_PIN11) | \ - PIN_MODE_INPUT(GPIOF_PIN12) | \ - PIN_MODE_INPUT(GPIOF_PIN13) | \ - PIN_MODE_INPUT(GPIOF_PIN14) | \ - PIN_MODE_INPUT(GPIOF_PIN15)) +#define VAL_GPIOF_MODER (EFI_PIN_MODE_DEFAULT(GPIOF_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOF_PIN15)) #define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOF_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | \ @@ -944,22 +936,22 @@ DEFAULT_GPIO_SPEED(GPIOF_PIN13) | \ DEFAULT_GPIO_SPEED(GPIOF_PIN14) | \ DEFAULT_GPIO_SPEED(GPIOF_PIN15)) -#define VAL_GPIOF_PUPDR (PIN_PUPDR_FLOATING(GPIOF_PIN0) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN1) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN2) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN3) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN4) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN5) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN6) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN7) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN8) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN9) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN12) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN13) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN14) | \ - PIN_PUPDR_FLOATING(GPIOF_PIN15)) +#define VAL_GPIOF_PUPDR (EFI_DR_DEFAULT(GPIOF_PIN0) | \ + EFI_DR_DEFAULT(GPIOF_PIN1) | \ + EFI_DR_DEFAULT(GPIOF_PIN2) | \ + EFI_DR_DEFAULT(GPIOF_PIN3) | \ + EFI_DR_DEFAULT(GPIOF_PIN4) | \ + EFI_DR_DEFAULT(GPIOF_PIN5) | \ + EFI_DR_DEFAULT(GPIOF_PIN6) | \ + EFI_DR_DEFAULT(GPIOF_PIN7) | \ + EFI_DR_DEFAULT(GPIOF_PIN8) | \ + EFI_DR_DEFAULT(GPIOF_PIN9) | \ + EFI_DR_DEFAULT(GPIOF_PIN10) | \ + EFI_DR_DEFAULT(GPIOF_PIN11) | \ + EFI_DR_DEFAULT(GPIOF_PIN12) | \ + EFI_DR_DEFAULT(GPIOF_PIN13) | \ + EFI_DR_DEFAULT(GPIOF_PIN14) | \ + EFI_DR_DEFAULT(GPIOF_PIN15)) #define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_PIN0) | \ PIN_ODR_HIGH(GPIOF_PIN1) | \ PIN_ODR_HIGH(GPIOF_PIN2) | \ @@ -1013,22 +1005,22 @@ * PG14 - PIN14 (input floating). * PG15 - PIN15 (input floating). */ -#define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | \ - PIN_MODE_INPUT(GPIOG_PIN1) | \ - PIN_MODE_INPUT(GPIOG_PIN2) | \ - PIN_MODE_INPUT(GPIOG_PIN3) | \ - PIN_MODE_INPUT(GPIOG_PIN4) | \ - PIN_MODE_INPUT(GPIOG_PIN5) | \ - PIN_MODE_INPUT(GPIOG_PIN6) | \ - PIN_MODE_INPUT(GPIOG_PIN7) | \ - PIN_MODE_INPUT(GPIOG_PIN8) | \ - PIN_MODE_INPUT(GPIOG_PIN9) | \ - PIN_MODE_INPUT(GPIOG_PIN10) | \ - PIN_MODE_INPUT(GPIOG_PIN11) | \ - PIN_MODE_INPUT(GPIOG_PIN12) | \ - PIN_MODE_INPUT(GPIOG_PIN13) | \ - PIN_MODE_INPUT(GPIOG_PIN14) | \ - PIN_MODE_INPUT(GPIOG_PIN15)) +#define VAL_GPIOG_MODER (EFI_PIN_MODE_DEFAULT(GPIOG_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOG_PIN15)) #define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | \ @@ -1061,22 +1053,22 @@ DEFAULT_GPIO_SPEED(GPIOG_PIN13) | \ DEFAULT_GPIO_SPEED(GPIOG_PIN14) | \ DEFAULT_GPIO_SPEED(GPIOG_PIN15)) -#define VAL_GPIOG_PUPDR (PIN_PUPDR_FLOATING(GPIOG_PIN0) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN1) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN2) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN3) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN4) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN5) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN6) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN7) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN8) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN9) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN12) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN13) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN14) | \ - PIN_PUPDR_FLOATING(GPIOG_PIN15)) +#define VAL_GPIOG_PUPDR (EFI_DR_DEFAULT(GPIOG_PIN0) | \ + EFI_DR_DEFAULT(GPIOG_PIN1) | \ + EFI_DR_DEFAULT(GPIOG_PIN2) | \ + EFI_DR_DEFAULT(GPIOG_PIN3) | \ + EFI_DR_DEFAULT(GPIOG_PIN4) | \ + EFI_DR_DEFAULT(GPIOG_PIN5) | \ + EFI_DR_DEFAULT(GPIOG_PIN6) | \ + EFI_DR_DEFAULT(GPIOG_PIN7) | \ + EFI_DR_DEFAULT(GPIOG_PIN8) | \ + EFI_DR_DEFAULT(GPIOG_PIN9) | \ + EFI_DR_DEFAULT(GPIOG_PIN10) | \ + EFI_DR_DEFAULT(GPIOG_PIN11) | \ + EFI_DR_DEFAULT(GPIOG_PIN12) | \ + EFI_DR_DEFAULT(GPIOG_PIN13) | \ + EFI_DR_DEFAULT(GPIOG_PIN14) | \ + EFI_DR_DEFAULT(GPIOG_PIN15)) #define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | \ PIN_ODR_HIGH(GPIOG_PIN1) | \ PIN_ODR_HIGH(GPIOG_PIN2) | \ @@ -1130,22 +1122,22 @@ * PH14 - PIN14 (input floating). * PH15 - PIN15 (input floating). */ -#define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_OSC_IN) | \ - PIN_MODE_INPUT(GPIOH_OSC_OUT) | \ - PIN_MODE_INPUT(GPIOH_PIN2) | \ - PIN_MODE_INPUT(GPIOH_PIN3) | \ - PIN_MODE_INPUT(GPIOH_PIN4) | \ - PIN_MODE_INPUT(GPIOH_PIN5) | \ - PIN_MODE_INPUT(GPIOH_PIN6) | \ - PIN_MODE_INPUT(GPIOH_PIN7) | \ - PIN_MODE_INPUT(GPIOH_PIN8) | \ - PIN_MODE_INPUT(GPIOH_PIN9) | \ - PIN_MODE_INPUT(GPIOH_PIN10) | \ - PIN_MODE_INPUT(GPIOH_PIN11) | \ - PIN_MODE_INPUT(GPIOH_PIN12) | \ - PIN_MODE_INPUT(GPIOH_PIN13) | \ - PIN_MODE_INPUT(GPIOH_PIN14) | \ - PIN_MODE_INPUT(GPIOH_PIN15)) +#define VAL_GPIOH_MODER (EFI_PIN_MODE_DEFAULT(GPIOH_OSC_IN) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_OSC_OUT) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOH_PIN15)) #define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_OSC_IN) | \ PIN_OTYPE_PUSHPULL(GPIOH_OSC_OUT) | \ PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | \ @@ -1178,22 +1170,22 @@ DEFAULT_GPIO_SPEED(GPIOH_PIN13) | \ DEFAULT_GPIO_SPEED(GPIOH_PIN14) | \ DEFAULT_GPIO_SPEED(GPIOH_PIN15)) -#define VAL_GPIOH_PUPDR (PIN_PUPDR_FLOATING(GPIOH_OSC_IN) | \ - PIN_PUPDR_FLOATING(GPIOH_OSC_OUT) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN2) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN3) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN4) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN5) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN6) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN7) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN8) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN9) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN12) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN13) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN14) | \ - PIN_PUPDR_FLOATING(GPIOH_PIN15)) +#define VAL_GPIOH_PUPDR (EFI_DR_DEFAULT(GPIOH_OSC_IN) | \ + EFI_DR_DEFAULT(GPIOH_OSC_OUT) | \ + EFI_DR_DEFAULT(GPIOH_PIN2) | \ + EFI_DR_DEFAULT(GPIOH_PIN3) | \ + EFI_DR_DEFAULT(GPIOH_PIN4) | \ + EFI_DR_DEFAULT(GPIOH_PIN5) | \ + EFI_DR_DEFAULT(GPIOH_PIN6) | \ + EFI_DR_DEFAULT(GPIOH_PIN7) | \ + EFI_DR_DEFAULT(GPIOH_PIN8) | \ + EFI_DR_DEFAULT(GPIOH_PIN9) | \ + EFI_DR_DEFAULT(GPIOH_PIN10) | \ + EFI_DR_DEFAULT(GPIOH_PIN11) | \ + EFI_DR_DEFAULT(GPIOH_PIN12) | \ + EFI_DR_DEFAULT(GPIOH_PIN13) | \ + EFI_DR_DEFAULT(GPIOH_PIN14) | \ + EFI_DR_DEFAULT(GPIOH_PIN15)) #define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_OSC_IN) | \ PIN_ODR_HIGH(GPIOH_OSC_OUT) | \ PIN_ODR_HIGH(GPIOH_PIN2) | \ @@ -1247,22 +1239,22 @@ * PI14 - PIN14 (input floating). * PI15 - PIN15 (input floating). */ -#define VAL_GPIOI_MODER (PIN_MODE_INPUT(GPIOI_PIN0) | \ - PIN_MODE_INPUT(GPIOI_PIN1) | \ - PIN_MODE_INPUT(GPIOI_PIN2) | \ - PIN_MODE_INPUT(GPIOI_PIN3) | \ - PIN_MODE_INPUT(GPIOI_PIN4) | \ - PIN_MODE_INPUT(GPIOI_PIN5) | \ - PIN_MODE_INPUT(GPIOI_PIN6) | \ - PIN_MODE_INPUT(GPIOI_PIN7) | \ - PIN_MODE_INPUT(GPIOI_PIN8) | \ - PIN_MODE_INPUT(GPIOI_PIN9) | \ - PIN_MODE_INPUT(GPIOI_PIN10) | \ - PIN_MODE_INPUT(GPIOI_PIN11) | \ - PIN_MODE_INPUT(GPIOI_PIN12) | \ - PIN_MODE_INPUT(GPIOI_PIN13) | \ - PIN_MODE_INPUT(GPIOI_PIN14) | \ - PIN_MODE_INPUT(GPIOI_PIN15)) +#define VAL_GPIOI_MODER (EFI_PIN_MODE_DEFAULT(GPIOI_PIN0) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN1) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN2) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN3) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN4) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN5) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN6) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN7) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN8) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN9) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN10) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN11) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN12) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN13) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN14) | \ + EFI_PIN_MODE_DEFAULT(GPIOI_PIN15)) #define VAL_GPIOI_OTYPER (PIN_OTYPE_PUSHPULL(GPIOI_PIN0) | \ PIN_OTYPE_PUSHPULL(GPIOI_PIN1) | \ PIN_OTYPE_PUSHPULL(GPIOI_PIN2) | \ @@ -1295,22 +1287,22 @@ DEFAULT_GPIO_SPEED(GPIOI_PIN13) | \ DEFAULT_GPIO_SPEED(GPIOI_PIN14) | \ DEFAULT_GPIO_SPEED(GPIOI_PIN15)) -#define VAL_GPIOI_PUPDR (PIN_PUPDR_FLOATING(GPIOI_PIN0) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN1) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN2) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN3) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN4) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN5) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN6) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN7) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN8) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN9) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN12) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN13) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN14) | \ - PIN_PUPDR_FLOATING(GPIOI_PIN15)) +#define VAL_GPIOI_PUPDR (EFI_DR_DEFAULT(GPIOI_PIN0) | \ + EFI_DR_DEFAULT(GPIOI_PIN1) | \ + EFI_DR_DEFAULT(GPIOI_PIN2) | \ + EFI_DR_DEFAULT(GPIOI_PIN3) | \ + EFI_DR_DEFAULT(GPIOI_PIN4) | \ + EFI_DR_DEFAULT(GPIOI_PIN5) | \ + EFI_DR_DEFAULT(GPIOI_PIN6) | \ + EFI_DR_DEFAULT(GPIOI_PIN7) | \ + EFI_DR_DEFAULT(GPIOI_PIN8) | \ + EFI_DR_DEFAULT(GPIOI_PIN9) | \ + EFI_DR_DEFAULT(GPIOI_PIN10) | \ + EFI_DR_DEFAULT(GPIOI_PIN11) | \ + EFI_DR_DEFAULT(GPIOI_PIN12) | \ + EFI_DR_DEFAULT(GPIOI_PIN13) | \ + EFI_DR_DEFAULT(GPIOI_PIN14) | \ + EFI_DR_DEFAULT(GPIOI_PIN15)) #define VAL_GPIOI_ODR (PIN_ODR_HIGH(GPIOI_PIN0) | \ PIN_ODR_HIGH(GPIOI_PIN1) | \ PIN_ODR_HIGH(GPIOI_PIN2) | \ diff --git a/firmware/config/boards/subaru-ej20gn/board_configuration.cpp b/firmware/config/boards/subaru-ej20gn/board_configuration.cpp index 03a9dcf8f0..e6dc998cbc 100644 --- a/firmware/config/boards/subaru-ej20gn/board_configuration.cpp +++ b/firmware/config/boards/subaru-ej20gn/board_configuration.cpp @@ -57,7 +57,7 @@ static void setSubaruEJ20GDefaults(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->tpsErrorDetectionTooLow = -10; // -10% open engineConfiguration->tpsErrorDetectionTooHigh = 110; // 110% open - boardConfiguration->mapMinBufferLength = 4; + engineConfiguration->mapMinBufferLength = 4; } void setPinConfigurationOverrides(void) { @@ -65,20 +65,20 @@ void setPinConfigurationOverrides(void) { } void setSerialConfigurationOverrides(void) { - boardConfiguration->useSerialPort = false; + engineConfiguration->useSerialPort = false; engineConfiguration->binarySerialTxPin = GPIOE_1; engineConfiguration->binarySerialRxPin = GPIOE_0; engineConfiguration->consoleSerialTxPin = GPIOA_9; engineConfiguration->consoleSerialRxPin = GPIOA_10; - boardConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; + engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } void setSdCardConfigurationOverrides(void) { - boardConfiguration->is_enabled_spi_1 = false; + engineConfiguration->is_enabled_spi_1 = false; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_1; - boardConfiguration->sdCardCsPin = GPIOA_2; - boardConfiguration->isSdCardEnabled = false; + engineConfiguration->sdCardCsPin = GPIOA_2; + engineConfiguration->isSdCardEnabled = false; } /** @@ -103,19 +103,19 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; /* Injectors */ - boardConfiguration->injectionPins[0] = GPIOB_11; - boardConfiguration->injectionPins[1] = GPIOA_0; - boardConfiguration->injectionPins[2] = GPIOA_1; - boardConfiguration->injectionPins[3] = GPIOB_10; + engineConfiguration->injectionPins[0] = GPIOB_11; + engineConfiguration->injectionPins[1] = GPIOA_0; + engineConfiguration->injectionPins[2] = GPIOA_1; + engineConfiguration->injectionPins[3] = GPIOB_10; /* 5th injector */ - //boardConfiguration->injectionPins[4] = GPIOD_15; + //engineConfiguration->injectionPins[4] = GPIOD_15; /* Ignition */ - boardConfiguration->ignitionPins[0] = GPIOB_8; - boardConfiguration->ignitionPins[1] = GPIOB_9; - boardConfiguration->ignitionPins[2] = GPIOF_8; - boardConfiguration->ignitionPins[3] = GPIOF_9; - //boardConfiguration->ignitionPinMode = OM_INVERTED; + engineConfiguration->ignitionPins[0] = GPIOB_8; + engineConfiguration->ignitionPins[1] = GPIOB_9; + engineConfiguration->ignitionPins[2] = GPIOF_8; + engineConfiguration->ignitionPins[3] = GPIOF_9; + //engineConfiguration->ignitionPinMode = OM_INVERTED; //? //engineConfiguration->vbattDividerCoeff = ((float) (2 + 10)) / 2; @@ -123,9 +123,9 @@ void setBoardConfigurationOverrides(void) { //sengineConfiguration->iat.config.bias_resistor = 2700; //? - //boardConfiguration->useStepperIdle = true; - //boardConfiguration->idle.stepperDirectionPin = GPIOB_12; - //boardConfiguration->idle.stepperStepPin = GPIOB_13; + //engineConfiguration->useStepperIdle = true; + //engineConfiguration->idle.stepperDirectionPin = GPIOB_12; + //engineConfiguration->idle.stepperStepPin = GPIOB_13; //engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED; //engineConfiguration->stepperEnablePinMode = OM_DEFAULT; @@ -136,27 +136,27 @@ void setBoardConfigurationOverrides(void) { /* IF you have BOTH camshaft position sensor and crankshaft position sensor * camshaft is always trigger#1 input and then crankshaft is trigger#2. */ - boardConfiguration->triggerInputPins[0] = GPIOC_8; - boardConfiguration->triggerInputPins[1] = GPIOC_9; - boardConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOC_8; + engineConfiguration->triggerInputPins[1] = GPIOC_9; + engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; /* spi driven - TLE6240 - OUT8, also direct driven by GPIOG_2 */ - boardConfiguration->tachOutputPin = TLE6240_PIN(0); - boardConfiguration->tachOutputPinMode = OM_DEFAULT; + engineConfiguration->tachOutputPin = TLE6240_PIN(0); + engineConfiguration->tachOutputPinMode = OM_DEFAULT; /* spi driven - TLE6240 - OUT5 */ - boardConfiguration->fuelPumpPin = TLE6240_PIN(5); - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->fuelPumpPin = TLE6240_PIN(5); + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; /* self shutdownd? */ - boardConfiguration->mainRelayPin = GPIOG_4; - boardConfiguration->mainRelayPinMode = OM_DEFAULT; + engineConfiguration->mainRelayPin = GPIOG_4; + engineConfiguration->mainRelayPinMode = OM_DEFAULT; /* spi driven - TLE6240 - OUT3, OUT4 * TODO: second fan */ - boardConfiguration->fanPin = TLE6240_PIN(2); - boardConfiguration->fanPinMode = OM_DEFAULT; + engineConfiguration->fanPin = TLE6240_PIN(2); + engineConfiguration->fanPinMode = OM_DEFAULT; /* spi driven - TLE6240 - OUT8 */ - boardConfiguration->malfunctionIndicatorPin = TLE6240_PIN(7); - boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; + engineConfiguration->malfunctionIndicatorPin = TLE6240_PIN(7); + engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; // starter block /* Starter signal connected through MC33972 - SG11 */ @@ -167,84 +167,84 @@ void setBoardConfigurationOverrides(void) { engineConfiguration->dizzySparkOutputPin = GPIO_UNASSIGNED; engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; engineConfiguration->displayMode = DM_NONE; - boardConfiguration->HD44780_rs = GPIO_UNASSIGNED; - boardConfiguration->HD44780_e = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db7 = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerChipSelect[0] = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerChipSelect[2] = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; + engineConfiguration->HD44780_e = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[0] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[2] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED; engineConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; - boardConfiguration->max31855spiDevice = SPI_NONE; + engineConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; + engineConfiguration->max31855spiDevice = SPI_NONE; ///////////////////////////////////////////////////////// - boardConfiguration->is_enabled_spi_1 = true; - boardConfiguration->is_enabled_spi_2 = false; - boardConfiguration->is_enabled_spi_3 = true; + engineConfiguration->is_enabled_spi_1 = true; + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->is_enabled_spi_3 = true; - boardConfiguration->spi1mosiPin = GPIO_UNASSIGNED; + engineConfiguration->spi1mosiPin = GPIO_UNASSIGNED; engineConfiguration->spi1MosiMode = PO_DEFAULT; - boardConfiguration->spi1misoPin = GPIO_UNASSIGNED; + engineConfiguration->spi1misoPin = GPIO_UNASSIGNED; engineConfiguration->spi1MisoMode = PO_DEFAULT; - boardConfiguration->spi1sckPin = GPIO_UNASSIGNED; + engineConfiguration->spi1sckPin = GPIO_UNASSIGNED; engineConfiguration->spi1SckMode = PO_DEFAULT; - boardConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3mosiPin = GPIOC_12; engineConfiguration->spi3MosiMode = PO_DEFAULT; - boardConfiguration->spi3misoPin = GPIOC_11; + engineConfiguration->spi3misoPin = GPIOC_11; engineConfiguration->spi3MisoMode = PO_DEFAULT; - boardConfiguration->spi3sckPin = GPIOC_10; + engineConfiguration->spi3sckPin = GPIOC_10; engineConfiguration->spi3SckMode = PO_DEFAULT; engineConfiguration->hip9011SpiDevice = SPI_DEVICE_4; - boardConfiguration->hip9011CsPin = GPIOF_1; - boardConfiguration->hip9011CsPinMode = OM_OPENDRAIN; - boardConfiguration->hip9011IntHoldPin = GPIOC_15; - boardConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; + engineConfiguration->hip9011CsPin = GPIOF_1; + engineConfiguration->hip9011CsPinMode = OM_OPENDRAIN; + engineConfiguration->hip9011IntHoldPin = GPIOC_15; + engineConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; engineConfiguration->hipOutputChannel = EFI_ADC_7; // PA7 - boardConfiguration->isHip9011Enabled = true; + engineConfiguration->isHip9011Enabled = true; #if 0 engineConfiguration->cj125SpiDevice = SPI_DEVICE_3; engineConfiguration->cj125ua = EFI_ADC_9; engineConfiguration->cj125ur = EFI_ADC_12; - boardConfiguration->cj125CsPin = GPIOA_15; + engineConfiguration->cj125CsPin = GPIOA_15; engineConfiguration->cj125CsPinMode = OM_OPENDRAIN; - boardConfiguration->wboHeaterPin = GPIOC_13; - boardConfiguration->o2heaterPin = GPIOC_13; + engineConfiguration->wboHeaterPin = GPIOC_13; + engineConfiguration->o2heaterPin = GPIOC_13; #endif - boardConfiguration->isCJ125Enabled = false; + engineConfiguration->isCJ125Enabled = false; - boardConfiguration->canDeviceMode = CD_USE_CAN1; - boardConfiguration->canTxPin = GPIOD_0; - boardConfiguration->canRxPin = GPIOD_1; + engineConfiguration->canDeviceMode = CD_USE_CAN1; + engineConfiguration->canTxPin = GPIOD_0; + engineConfiguration->canRxPin = GPIOD_1; //!!!!!!!!!!!!!!! #if 1 setSubaruEJ20GDefaults(PASS_ENGINE_PARAMETER_SIGNATURE); #endif /* actually i2c extension connector */ - boardConfiguration->triggerSimulatorPins[0] = GPIOF_14; - boardConfiguration->triggerSimulatorPins[1] = GPIOF_15; - boardConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT; - boardConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; - boardConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPins[0] = GPIOF_14; + engineConfiguration->triggerSimulatorPins[1] = GPIOF_15; + engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; - boardConfiguration->logicAnalyzerPins[0] = GPIO_UNASSIGNED; - boardConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; - boardConfiguration->logicAnalyzerPins[2] = GPIO_UNASSIGNED; - boardConfiguration->logicAnalyzerPins[3] = GPIO_UNASSIGNED; - boardConfiguration->logicAnalyzerMode[0] = OM_DEFAULT; - boardConfiguration->logicAnalyzerMode[1] = OM_DEFAULT; - boardConfiguration->logicAnalyzerMode[2] = OM_DEFAULT; - boardConfiguration->logicAnalyzerMode[3] = OM_DEFAULT; + engineConfiguration->logicAnalyzerPins[0] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[2] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[3] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerMode[0] = OM_DEFAULT; + engineConfiguration->logicAnalyzerMode[1] = OM_DEFAULT; + engineConfiguration->logicAnalyzerMode[2] = OM_DEFAULT; + engineConfiguration->logicAnalyzerMode[3] = OM_DEFAULT; //!!!!!!!!!!!!!!!!!!! //engineConfiguration->silentTriggerError = true; diff --git a/firmware/config/engines/GY6_139QMB.cpp b/firmware/config/engines/GY6_139QMB.cpp index 319a352508..9b59b7da51 100644 --- a/firmware/config/engines/GY6_139QMB.cpp +++ b/firmware/config/engines/GY6_139QMB.cpp @@ -89,7 +89,7 @@ void setGy6139qmbDefaultEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) engineConfiguration->analogInputDividerCoefficient = 1; engineConfiguration->fuelAlgorithm = LM_MAP; engineConfiguration->globalTriggerAngleOffset = 45; - boardConfiguration->sensorChartMode = SC_MAP; + engineConfiguration->sensorChartMode = SC_MAP; engineConfiguration->specs.displacement = 0.072; // 72cc engineConfiguration->specs.cylindersCount = 1; setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); @@ -103,8 +103,8 @@ void setGy6139qmbDefaultEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) engineConfiguration->trigger.customTotalToothCount = 8; engineConfiguration->trigger.customSkippedToothCount = 1; - boardConfiguration->injectionPins[0] = GPIOC_9; - boardConfiguration->ignitionPins[0] = GPIOC_8; + engineConfiguration->injectionPins[0] = GPIOC_9; + engineConfiguration->ignitionPins[0] = GPIOC_8; // set injection_mode 1 engineConfiguration->injectionMode = IM_SEQUENTIAL; diff --git a/firmware/config/engines/bmw_e34.cpp b/firmware/config/engines/bmw_e34.cpp index 72bcb1d5e3..4baf1b83b1 100644 --- a/firmware/config/engines/bmw_e34.cpp +++ b/firmware/config/engines/bmw_e34.cpp @@ -27,8 +27,8 @@ void setBmwE34(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR); // engineConfiguration->trigger.type = TT_ONE_PLUS_TOOTHED_WHEEL_60_2; // engineConfiguration->injectionMode = IM_SEQUENTIAL; -// boardConfiguration->triggerInputPins[0] = GPIOC_6; -// boardConfiguration->triggerInputPins[1] = GPIOA_5; +// engineConfiguration->triggerInputPins[0] = GPIOC_6; +// engineConfiguration->triggerInputPins[1] = GPIOA_5; //Base engine setting engineConfiguration->specs.cylindersCount = 6; @@ -39,7 +39,7 @@ void setBmwE34(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->useOnlyRisingEdgeForTrigger = true; - boardConfiguration->tachOutputPin = GPIOC_8; + engineConfiguration->tachOutputPin = GPIOC_8; // Trigger configuration // engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; @@ -58,12 +58,12 @@ void setBmwE34(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->injector.flow = 750; // General settings - boardConfiguration->tunerStudioSerialSpeed = 57600; + engineConfiguration->tunerStudioSerialSpeed = 57600; engineConfiguration->rpmHardLimit = 7000; setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); // for best performance at high RPM, we need to turn off 'Engine Sniffer' and 'Sensor Sniffer' - boardConfiguration->sensorChartMode = SC_OFF; + engineConfiguration->sensorChartMode = SC_OFF; engineConfiguration->isEngineChartEnabled = false; engineConfiguration->isCylinderCleanupEnabled = false; @@ -90,52 +90,52 @@ void setBmwE34(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->tps1_1AdcChannel = EFI_ADC_3; - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; setWholeTimingTable(25); - boardConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; // bc->isFastAdcEnabled = true; - boardConfiguration->injectionPinMode = OM_INVERTED; - boardConfiguration->injectionPins[0] = GPIOB_8; // #1 - boardConfiguration->injectionPins[1] = GPIOE_2; // #2 - boardConfiguration->injectionPins[2] = GPIOE_3; // #3 - boardConfiguration->injectionPins[3] = GPIOE_4; // #4 - boardConfiguration->injectionPins[4] = GPIOE_5; // #5 - boardConfiguration->injectionPins[5] = GPIOE_6; // #6 + engineConfiguration->injectionPinMode = OM_INVERTED; + engineConfiguration->injectionPins[0] = GPIOB_8; // #1 + engineConfiguration->injectionPins[1] = GPIOE_2; // #2 + engineConfiguration->injectionPins[2] = GPIOE_3; // #3 + engineConfiguration->injectionPins[3] = GPIOE_4; // #4 + engineConfiguration->injectionPins[4] = GPIOE_5; // #5 + engineConfiguration->injectionPins[5] = GPIOE_6; // #6 - boardConfiguration->ignitionPinMode = OM_INVERTED; + engineConfiguration->ignitionPinMode = OM_INVERTED; - boardConfiguration->ignitionPins[0] = GPIOB_5; // #1 - boardConfiguration->ignitionPins[2] = GPIOB_6; // #3 - boardConfiguration->ignitionPins[4] = GPIOB_7; // #5 + engineConfiguration->ignitionPins[0] = GPIOB_5; // #1 + engineConfiguration->ignitionPins[2] = GPIOB_6; // #3 + engineConfiguration->ignitionPins[4] = GPIOB_7; // #5 - boardConfiguration->canRxPin = GPIO_UNASSIGNED; - boardConfiguration->canTxPin = GPIO_UNASSIGNED; + engineConfiguration->canRxPin = GPIO_UNASSIGNED; + engineConfiguration->canTxPin = GPIO_UNASSIGNED; - boardConfiguration->triggerErrorPin = GPIO_UNASSIGNED; + engineConfiguration->triggerErrorPin = GPIO_UNASSIGNED; // clutch up engineConfiguration->clutchUpPin = GPIOD_3; engineConfiguration->clutchUpPinMode = PI_PULLUP; // fuel pump - boardConfiguration->fuelPumpPin = GPIOD_4; + engineConfiguration->fuelPumpPin = GPIOD_4; // idle - boardConfiguration->idle.solenoidPin = GPIOC_14; - boardConfiguration->idle.solenoidPinMode = OM_INVERTED; - boardConfiguration->idle.solenoidFrequency = 300; - boardConfiguration->manIdlePosition = 50; // set_idle_pwm 50 + engineConfiguration->idle.solenoidPin = GPIOC_14; + engineConfiguration->idle.solenoidPinMode = OM_INVERTED; + engineConfiguration->idle.solenoidFrequency = 300; + engineConfiguration->manIdlePosition = 50; // set_idle_pwm 50 // disable sd_card - boardConfiguration->sdCardCsPin = GPIO_UNASSIGNED; - boardConfiguration->is_enabled_spi_2 = false; - boardConfiguration->is_enabled_spi_3 = false; - boardConfiguration->max31855spiDevice = SPI_NONE; + engineConfiguration->sdCardCsPin = GPIO_UNASSIGNED; + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->is_enabled_spi_3 = false; + engineConfiguration->max31855spiDevice = SPI_NONE; // turbocharger boost control solenoid: TODO output: GPIOE_6 // water injection #1 TODO GPIOD_7 @@ -145,7 +145,7 @@ void setBmwE34(DECLARE_CONFIG_PARAMETER_SIGNATURE) { * emulating the 60-0 trigger takes some resources, let's keep it slow by default * rpm 200 */ - boardConfiguration->triggerSimulatorFrequency = 200; + engineConfiguration->triggerSimulatorFrequency = 200; // Configurating sensors: @@ -163,7 +163,7 @@ void setBmwE34(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // */ // bc->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPins[0] = GPIOD_1; - boardConfiguration->triggerSimulatorPins[1] = GPIOD_2; - boardConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[0] = GPIOD_1; + engineConfiguration->triggerSimulatorPins[1] = GPIOD_2; + engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; } diff --git a/firmware/config/engines/bmw_m73.cpp b/firmware/config/engines/bmw_m73.cpp index 96058e04da..0f52463f3b 100644 --- a/firmware/config/engines/bmw_m73.cpp +++ b/firmware/config/engines/bmw_m73.cpp @@ -98,36 +98,36 @@ void setEngineBMW_M73_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFrankensoConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); m73engine(PASS_CONFIG_PARAMETER_SIGNATURE); - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = GPIOC_6; - CONFIGB(idle).solenoidPin = GPIO_UNASSIGNED; - CONFIGB(mainRelayPin) = GPIO_UNASSIGNED; - CONFIGB(fanPin) = GPIO_UNASSIGNED; - CONFIGB(fuelPumpPin) = GPIO_UNASSIGNED; + CONFIG(idle).solenoidPin = GPIO_UNASSIGNED; + CONFIG(mainRelayPin) = GPIO_UNASSIGNED; + CONFIG(fanPin) = GPIO_UNASSIGNED; + CONFIG(fuelPumpPin) = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[ID2INDEX(1)] = GPIOE_14; // Frankenso high side - pin 1G - GREEN wire - boardConfiguration->ignitionPins[ID2INDEX(2)] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[ID2INDEX(3)] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[ID2INDEX(4)] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[ID2INDEX(7)] = GPIOC_7; // Frankenso high side - pin 1H - ORANGE wire + engineConfiguration->ignitionPins[ID2INDEX(1)] = GPIOE_14; // Frankenso high side - pin 1G - GREEN wire + engineConfiguration->ignitionPins[ID2INDEX(2)] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[ID2INDEX(3)] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[ID2INDEX(4)] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[ID2INDEX(7)] = GPIOC_7; // Frankenso high side - pin 1H - ORANGE wire - boardConfiguration->injectionPins[0] = GPIOB_8; // BLU - boardConfiguration->injectionPins[1] = GPIOB_7; // BLK - boardConfiguration->injectionPins[2] = GPIOB_9; // GRN - boardConfiguration->injectionPins[3] = GPIOD_5; // WHT - boardConfiguration->injectionPins[4] = GPIOD_3; // RED - boardConfiguration->injectionPins[5] = GPIOE_2; // ORG + engineConfiguration->injectionPins[0] = GPIOB_8; // BLU + engineConfiguration->injectionPins[1] = GPIOB_7; // BLK + engineConfiguration->injectionPins[2] = GPIOB_9; // GRN + engineConfiguration->injectionPins[3] = GPIOD_5; // WHT + engineConfiguration->injectionPins[4] = GPIOD_3; // RED + engineConfiguration->injectionPins[5] = GPIOE_2; // ORG - boardConfiguration->injectionPins[6] = GPIOE_3; // BLU - boardConfiguration->injectionPins[7] = GPIOE_4; // BLK - boardConfiguration->injectionPins[8] = GPIOE_5; // GRN - boardConfiguration->injectionPins[9] = GPIOE_6; // WHT - boardConfiguration->injectionPins[10] = GPIOC_13;//RED - boardConfiguration->injectionPins[11] = GPIOD_7;// ORG + engineConfiguration->injectionPins[6] = GPIOE_3; // BLU + engineConfiguration->injectionPins[7] = GPIOE_4; // BLK + engineConfiguration->injectionPins[8] = GPIOE_5; // GRN + engineConfiguration->injectionPins[9] = GPIOE_6; // WHT + engineConfiguration->injectionPins[10] = GPIOC_13;//RED + engineConfiguration->injectionPins[11] = GPIOD_7;// ORG } // BMW_M73_M @@ -155,10 +155,10 @@ GPIOA_6 */ - CONFIGB(fsioOutputPins)[7] = GPIO_UNASSIGNED; - boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED; - boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - boardConfiguration->fanPin = GPIO_UNASSIGNED; + CONFIG(fsioOutputPins)[7] = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = GPIO_UNASSIGNED; /** * Yellow op-amp board @@ -194,19 +194,19 @@ GPIOA_6 engineConfiguration->etbIo[1].directionPin2 = GPIOB_9; - boardConfiguration->injectionPins[0] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[0] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[7] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[8] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[9] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[10] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[11] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED; } diff --git a/firmware/config/engines/chevrolet_camaro_4.cpp b/firmware/config/engines/chevrolet_camaro_4.cpp index 26eddc0b7f..cbe24d74c3 100644 --- a/firmware/config/engines/chevrolet_camaro_4.cpp +++ b/firmware/config/engines/chevrolet_camaro_4.cpp @@ -24,8 +24,8 @@ void setCamaro4(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->specs.cylindersCount = 8; engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3; - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIOC_6; engineConfiguration->injectionMode = IM_BATCH; engineConfiguration->twoWireBatchInjection = true; @@ -56,31 +56,31 @@ void setCamaro4(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->afr.hwChannel = EFI_ADC_13; - boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[0] = GPIOE_6; - boardConfiguration->injectionPins[1] = GPIOE_5; - boardConfiguration->injectionPins[2] = GPIOD_7; - boardConfiguration->injectionPins[3] = GPIOC_13; - boardConfiguration->injectionPins[4] = GPIOE_3; - boardConfiguration->injectionPins[5] = GPIOE_4; - boardConfiguration->injectionPins[6] = GPIOD_3; - boardConfiguration->injectionPins[7] = GPIOE_2; + engineConfiguration->injectionPins[0] = GPIOE_6; + engineConfiguration->injectionPins[1] = GPIOE_5; + engineConfiguration->injectionPins[2] = GPIOD_7; + engineConfiguration->injectionPins[3] = GPIOC_13; + engineConfiguration->injectionPins[4] = GPIOE_3; + engineConfiguration->injectionPins[5] = GPIOE_4; + engineConfiguration->injectionPins[6] = GPIOD_3; + engineConfiguration->injectionPins[7] = GPIOE_2; - boardConfiguration->ignitionPins[0] = GPIOC_9; - boardConfiguration->ignitionPins[1] = GPIOC_7; - boardConfiguration->ignitionPins[2] = GPIOE_14; - boardConfiguration->ignitionPins[3] = GPIOE_12; - boardConfiguration->ignitionPins[4] = GPIOE_10; - boardConfiguration->ignitionPins[5] = GPIOE_8; - boardConfiguration->ignitionPins[6] = GPIOD_9; - boardConfiguration->ignitionPins[7] = GPIOD_8; + engineConfiguration->ignitionPins[0] = GPIOC_9; + engineConfiguration->ignitionPins[1] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOE_14; + engineConfiguration->ignitionPins[3] = GPIOE_12; + engineConfiguration->ignitionPins[4] = GPIOE_10; + engineConfiguration->ignitionPins[5] = GPIOE_8; + engineConfiguration->ignitionPins[6] = GPIOD_9; + engineConfiguration->ignitionPins[7] = GPIOD_8; - boardConfiguration->fuelPumpPin = GPIOB_8; - boardConfiguration->fanPin = GPIO_UNASSIGNED; - boardConfiguration->mainRelayPin = GPIOD_5; + engineConfiguration->fuelPumpPin = GPIOB_8; + engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->mainRelayPin = GPIOD_5; } diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index 301d99210c..e970ea469d 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -14,13 +14,13 @@ #include "citroenBerlingoTU3JP.h" #include "settings.h" -void setLCD(board_configuration_s *boardConfiguration) { - boardConfiguration->HD44780_rs = GPIOE_7; - boardConfiguration->HD44780_e = GPIOE_9; - boardConfiguration->HD44780_db4 = GPIOE_11; - boardConfiguration->HD44780_db5 = GPIOE_13; - boardConfiguration->HD44780_db6 = GPIOE_15; - boardConfiguration->HD44780_db7 = GPIOB_10; +void setLCD(engine_configuration_s *engineConfiguration) { + engineConfiguration->HD44780_rs = GPIOE_7; + engineConfiguration->HD44780_e = GPIOE_9; + engineConfiguration->HD44780_db4 = GPIOE_11; + engineConfiguration->HD44780_db5 = GPIOE_13; + engineConfiguration->HD44780_db6 = GPIOE_15; + engineConfiguration->HD44780_db7 = GPIOB_10; } #if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT @@ -117,35 +117,35 @@ void setCitroenBerlingoTU3JPConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenstein lo-side output #11: PB8 Main relay // Frankenstein lo-side output #12: PB9 Fuel pump - boardConfiguration->ignitionPins[0] = GPIOC_14; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOC_15; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOC_14; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOC_15; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; engineConfiguration->injector.flow = 137; //SIEMENS DEKA VAZ20734 - boardConfiguration->injectionPins[0] = GPIOE_6; - boardConfiguration->injectionPins[1] = GPIOC_13; - boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[0] = GPIOE_6; + engineConfiguration->injectionPins[1] = GPIOC_13; + engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->fanPin = GPIOE_0; - boardConfiguration->fanPinMode = OM_DEFAULT; + engineConfiguration->fanPin = GPIOE_0; + engineConfiguration->fanPinMode = OM_DEFAULT; engineConfiguration->fanOffTemperature = 95; engineConfiguration->fanOnTemperature = 99; - boardConfiguration->malfunctionIndicatorPin = GPIOE_1; - boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; + engineConfiguration->malfunctionIndicatorPin = GPIOE_1; + engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; - boardConfiguration->mainRelayPin = GPIOB_8; + engineConfiguration->mainRelayPin = GPIOB_8; - boardConfiguration->fuelPumpPin = GPIOB_9; - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->fuelPumpPin = GPIOB_9; + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; - setLCD(boardConfiguration); + setLCD(engineConfiguration); -// boardConfiguration->o2heaterPin = GPIOC_13; -// boardConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; +// engineConfiguration->o2heaterPin = GPIOC_13; +// engineConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; /** * Inputs diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 8686d24dc9..69f88312b3 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -65,22 +65,22 @@ void runSchedulingPrecisionTestIfNeeded(void) { } #endif /* EFI_PROD_CODE */ -void setFrankenso_01_LCD(board_configuration_s *boardConfiguration) { - boardConfiguration->HD44780_rs = GPIOE_7; - boardConfiguration->HD44780_e = GPIOE_9; - boardConfiguration->HD44780_db4 = GPIOE_11; - boardConfiguration->HD44780_db5 = GPIOE_13; - boardConfiguration->HD44780_db6 = GPIOE_15; - boardConfiguration->HD44780_db7 = GPIOB_10; +void setFrankenso_01_LCD(engine_configuration_s *engineConfiguration) { + engineConfiguration->HD44780_rs = GPIOE_7; + engineConfiguration->HD44780_e = GPIOE_9; + engineConfiguration->HD44780_db4 = GPIOE_11; + engineConfiguration->HD44780_db5 = GPIOE_13; + engineConfiguration->HD44780_db6 = GPIOE_15; + engineConfiguration->HD44780_db7 = GPIOB_10; } -void disableLCD(board_configuration_s *boardConfiguration) { - boardConfiguration->HD44780_rs = GPIO_UNASSIGNED; - boardConfiguration->HD44780_e = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db7 = GPIO_UNASSIGNED; +void disableLCD(engine_configuration_s *engineConfiguration) { + engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; + engineConfiguration->HD44780_e = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; } // todo: should this be part of more default configurations? @@ -88,7 +88,7 @@ void setFrankensoConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setDefaultFrankensoConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->trigger.type = TT_ONE_PLUS_ONE; - setFrankenso_01_LCD(boardConfiguration); + setFrankenso_01_LCD(engineConfiguration); engineConfiguration->displayMode = DM_HD44780; commonFrankensoAnalogInputs(engineConfiguration); setFrankenso0_1_joystick(engineConfiguration); @@ -135,32 +135,32 @@ void setFrankensoConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenso low out #11: PB8 injector #3 // Frankenso low out #12: PB7 injector #4 - boardConfiguration->fuelPumpPin = GPIOE_4; - boardConfiguration->mainRelayPin = GPIOD_7; - boardConfiguration->idle.solenoidPin = GPIOC_13; + engineConfiguration->fuelPumpPin = GPIOE_4; + engineConfiguration->mainRelayPin = GPIOD_7; + engineConfiguration->idle.solenoidPin = GPIOC_13; - boardConfiguration->fanPin = GPIOE_5; + engineConfiguration->fanPin = GPIOE_5; - boardConfiguration->injectionPins[0] = GPIOB_9; // #1 - boardConfiguration->injectionPins[1] = GPIOE_2; // #2 - boardConfiguration->injectionPins[2] = GPIOB_8; // #3 + engineConfiguration->injectionPins[0] = GPIOB_9; // #1 + engineConfiguration->injectionPins[1] = GPIOE_2; // #2 + engineConfiguration->injectionPins[2] = GPIOB_8; // #3 #ifndef EFI_INJECTOR_PIN3 - boardConfiguration->injectionPins[3] = GPIOB_7; // #4 + engineConfiguration->injectionPins[3] = GPIOB_7; // #4 #else /* EFI_INJECTOR_PIN3 */ - boardConfiguration->injectionPins[3] = EFI_INJECTOR_PIN3; // #4 + engineConfiguration->injectionPins[3] = EFI_INJECTOR_PIN3; // #4 #endif /* EFI_INJECTOR_PIN3 */ setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); #if EFI_PWM_TESTER - boardConfiguration->injectionPins[4] = GPIOC_8; // #5 - boardConfiguration->injectionPins[5] = GPIOD_10; // #6 - boardConfiguration->injectionPins[6] = GPIOD_9; - boardConfiguration->injectionPins[7] = GPIOD_11; - boardConfiguration->injectionPins[8] = GPIOD_0; - boardConfiguration->injectionPins[9] = GPIOB_11; - boardConfiguration->injectionPins[10] = GPIOC_7; - boardConfiguration->injectionPins[11] = GPIOE_4; + engineConfiguration->injectionPins[4] = GPIOC_8; // #5 + engineConfiguration->injectionPins[5] = GPIOD_10; // #6 + engineConfiguration->injectionPins[6] = GPIOD_9; + engineConfiguration->injectionPins[7] = GPIOD_11; + engineConfiguration->injectionPins[8] = GPIOD_0; + engineConfiguration->injectionPins[9] = GPIOB_11; + engineConfiguration->injectionPins[10] = GPIOC_7; + engineConfiguration->injectionPins[11] = GPIOE_4; /** * We want to initialize all outputs for test @@ -169,20 +169,20 @@ void setFrankensoConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->displayMode = DM_NONE; #else /* EFI_PWM_TESTER */ - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[7] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[8] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[9] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[10] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[11] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[0] = GPIOE_14; - boardConfiguration->ignitionPins[1] = GPIOC_7; - boardConfiguration->ignitionPins[2] = GPIOC_9; + engineConfiguration->ignitionPins[0] = GPIOE_14; + engineConfiguration->ignitionPins[1] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOC_9; // set_ignition_pin 4 PE10 - boardConfiguration->ignitionPins[3] = GPIOE_10; + engineConfiguration->ignitionPins[3] = GPIOE_10; #endif /* EFI_PWM_TESTER */ // todo: 8.2 or 10k? @@ -198,7 +198,7 @@ void setFrankensoBoardTestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->directSelfStimulation = true; // this engine type is used for board validation - boardConfiguration->triggerSimulatorFrequency = 300; + engineConfiguration->triggerSimulatorFrequency = 300; engineConfiguration->cranking.rpm = 100; engineConfiguration->specs.cylindersCount = 12; @@ -207,38 +207,38 @@ void setFrankensoBoardTestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // set ignition_mode 1 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; - boardConfiguration->injectionPins[0] = GPIOB_7; // injector in default pinout - boardConfiguration->injectionPins[1] = GPIOB_8; // injector in default pinout - boardConfiguration->injectionPins[2] = GPIOB_9; // injector in default pinout - boardConfiguration->injectionPins[3] = GPIOC_13; + engineConfiguration->injectionPins[0] = GPIOB_7; // injector in default pinout + engineConfiguration->injectionPins[1] = GPIOB_8; // injector in default pinout + engineConfiguration->injectionPins[2] = GPIOB_9; // injector in default pinout + engineConfiguration->injectionPins[3] = GPIOC_13; - boardConfiguration->injectionPins[4] = GPIOD_3; - boardConfiguration->injectionPins[5] = GPIOD_5; - boardConfiguration->injectionPins[6] = GPIOD_7; - boardConfiguration->injectionPins[7] = GPIOE_2; // injector in default pinout - boardConfiguration->injectionPins[8] = GPIOE_3; - boardConfiguration->injectionPins[9] = GPIOE_4; - boardConfiguration->injectionPins[10] = GPIOE_5; - boardConfiguration->injectionPins[11] = GPIOE_6; + engineConfiguration->injectionPins[4] = GPIOD_3; + engineConfiguration->injectionPins[5] = GPIOD_5; + engineConfiguration->injectionPins[6] = GPIOD_7; + engineConfiguration->injectionPins[7] = GPIOE_2; // injector in default pinout + engineConfiguration->injectionPins[8] = GPIOE_3; + engineConfiguration->injectionPins[9] = GPIOE_4; + engineConfiguration->injectionPins[10] = GPIOE_5; + engineConfiguration->injectionPins[11] = GPIOE_6; - boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED; - boardConfiguration->mainRelayPin = GPIO_UNASSIGNED; - boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - boardConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[0] = GPIOC_9; // coil in default pinout - boardConfiguration->ignitionPins[1] = GPIOC_7; // coil in default pinout - boardConfiguration->ignitionPins[2] = GPIOE_10; // coil in default pinout - boardConfiguration->ignitionPins[3] = GPIOE_8; // Miata VVT tach + engineConfiguration->ignitionPins[0] = GPIOC_9; // coil in default pinout + engineConfiguration->ignitionPins[1] = GPIOC_7; // coil in default pinout + engineConfiguration->ignitionPins[2] = GPIOE_10; // coil in default pinout + engineConfiguration->ignitionPins[3] = GPIOE_8; // Miata VVT tach - boardConfiguration->ignitionPins[4] = GPIOE_14; // coil in default pinout - boardConfiguration->ignitionPins[5] = GPIOE_12; - boardConfiguration->ignitionPins[6] = GPIOD_8; - boardConfiguration->ignitionPins[7] = GPIOD_9; + engineConfiguration->ignitionPins[4] = GPIOE_14; // coil in default pinout + engineConfiguration->ignitionPins[5] = GPIOE_12; + engineConfiguration->ignitionPins[6] = GPIOD_8; + engineConfiguration->ignitionPins[7] = GPIOD_9; - boardConfiguration->ignitionPins[8] = GPIOE_0; // brain board, not discovery - boardConfiguration->ignitionPins[9] = GPIOE_1; // brain board, not discovery + engineConfiguration->ignitionPins[8] = GPIOE_0; // brain board, not discovery + engineConfiguration->ignitionPins[9] = GPIOE_1; // brain board, not discovery } @@ -260,10 +260,10 @@ void setEtbTestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; - boardConfiguration->ignitionPins[0] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; /** * remember that some H-bridges require 5v control lines, not just 3v logic outputs we have on stm32 */ @@ -282,11 +282,11 @@ void setEtbTestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->debugMode = DBG_ELECTRONIC_THROTTLE_PID; // turning off other PWMs to simplify debugging - engineConfiguration->bc.triggerSimulatorFrequency = 0; + engineConfiguration->triggerSimulatorFrequency = 0; engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED; - CONFIGB(idle).stepperStepPin = GPIO_UNASSIGNED; - CONFIGB(idle).stepperDirectionPin = GPIO_UNASSIGNED; - boardConfiguration->useStepperIdle = true; + CONFIG(idle).stepperStepPin = GPIO_UNASSIGNED; + CONFIG(idle).stepperDirectionPin = GPIO_UNASSIGNED; + engineConfiguration->useStepperIdle = true; // no analog dividers - all sensors with 3v supply, naked discovery bench setup engineConfiguration->analogInputDividerCoefficient = 1; @@ -313,28 +313,28 @@ void setTle8888TestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->directSelfStimulation = true; #if defined(STM32_HAS_GPIOG) && STM32_HAS_GPIOG - boardConfiguration->ignitionPins[0] = GPIOG_3; - boardConfiguration->ignitionPins[1] = GPIOG_4; - boardConfiguration->ignitionPins[2] = GPIOG_5; - boardConfiguration->ignitionPins[3] = GPIOG_6; - boardConfiguration->ignitionPins[4] = GPIOG_7; - boardConfiguration->ignitionPins[5] = GPIOG_8; + engineConfiguration->ignitionPins[0] = GPIOG_3; + engineConfiguration->ignitionPins[1] = GPIOG_4; + engineConfiguration->ignitionPins[2] = GPIOG_5; + engineConfiguration->ignitionPins[3] = GPIOG_6; + engineConfiguration->ignitionPins[4] = GPIOG_7; + engineConfiguration->ignitionPins[5] = GPIOG_8; #endif /* STM32_HAS_GPIOG */ - boardConfiguration->ignitionPins[6] = GPIOC_6; - boardConfiguration->ignitionPins[7] = GPIOC_7; + engineConfiguration->ignitionPins[6] = GPIOC_6; + engineConfiguration->ignitionPins[7] = GPIOC_7; #if (BOARD_TLE8888_COUNT > 0) engineConfiguration->tle8888spiDevice = SPI_DEVICE_1; engineConfiguration->tle8888_cs = GPIOD_5; // PB3 is nicely both SWO and SPI1 SCK so logic analyzer could be used on SWO header - boardConfiguration->spi1mosiPin = GPIOB_5; - boardConfiguration->spi1misoPin = GPIOB_4; - boardConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output - boardConfiguration->is_enabled_spi_1 = true; + engineConfiguration->spi1mosiPin = GPIOB_5; + engineConfiguration->spi1misoPin = GPIOB_4; + engineConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output + engineConfiguration->is_enabled_spi_1 = true; engineConfiguration->debugMode = DBG_TLE8888; - boardConfiguration->fuelPumpPin = TLE8888_PIN_20; + engineConfiguration->fuelPumpPin = TLE8888_PIN_20; #endif /* BOARD_TLE8888_COUNT */ engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_9; // PB1 // just any non-empty value for now @@ -353,7 +353,7 @@ void setTle8888TestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { CONFIG(etbIo[0].directionPin2) = GPIOF_14; #endif /* STM32_HAS_GPIOF */ CONFIG(etb_use_two_wires) = true; - boardConfiguration->isHip9011Enabled = false; + engineConfiguration->isHip9011Enabled = false; // ETB #2 // DIS PE5 @@ -400,7 +400,7 @@ void mreBoardTest(DECLARE_CONFIG_PARAMETER_SIGNATURE) { #if (BOARD_TLE8888_COUNT > 0) engineConfiguration->directSelfStimulation = true; // this engine type is used for board validation - boardConfiguration->triggerSimulatorFrequency = 60; + engineConfiguration->triggerSimulatorFrequency = 60; // set cranking_rpm 500 engineConfiguration->cranking.rpm = 100; // set cranking_dwell 200 @@ -447,64 +447,64 @@ void mreBoardTest(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->specs.firingOrder = FO_1_10_9_4_3_6_5_8_7_2; // red LED #1 - boardConfiguration->ignitionPins[1 - 1] = GPIOD_4; - boardConfiguration->ignitionPins[10 - 1] = GPIOD_3; - boardConfiguration->ignitionPins[9 - 1] = GPIOD_6; - boardConfiguration->ignitionPins[4 - 1] = GPIOD_7; - boardConfiguration->ignitionPins[3 - 1] = GPIOD_1; - boardConfiguration->ignitionPins[6 - 1] = GPIOD_2; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[6] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[7] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1 - 1] = GPIOD_4; + engineConfiguration->ignitionPins[10 - 1] = GPIOD_3; + engineConfiguration->ignitionPins[9 - 1] = GPIOD_6; + engineConfiguration->ignitionPins[4 - 1] = GPIOD_7; + engineConfiguration->ignitionPins[3 - 1] = GPIOD_1; + engineConfiguration->ignitionPins[6 - 1] = GPIOD_2; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[6] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[7] = GPIO_UNASSIGNED; - boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED; - boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - boardConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = GPIO_UNASSIGNED; // fuel pump is useful to test power on/off scenario -// boardConfiguration->fuelPumpPin = TLE8888_PIN_22; +// engineConfiguration->fuelPumpPin = TLE8888_PIN_22; // LED #1 // GPIOE_7: "34 - GP Out 2" - boardConfiguration->injectionPins[1 - 1] = TLE8888_PIN_22;//GPIOE_7; + engineConfiguration->injectionPins[1 - 1] = TLE8888_PIN_22;//GPIOE_7; // LED #2 // TLE8888_PIN_23: "33 - GP Out 3" - boardConfiguration->injectionPins[10 - 1] = TLE8888_PIN_23; + engineConfiguration->injectionPins[10 - 1] = TLE8888_PIN_23; // LED #3 - INJ#1 - boardConfiguration->injectionPins[9 - 1] = GPIOE_13; + engineConfiguration->injectionPins[9 - 1] = GPIOE_13; // LED #4 - INJ#2 - boardConfiguration->injectionPins[4 - 1] = GPIOE_14; + engineConfiguration->injectionPins[4 - 1] = GPIOE_14; // LED #5 - INJ#3 - boardConfiguration->injectionPins[3 - 1] = GPIOE_12; + engineConfiguration->injectionPins[3 - 1] = GPIOE_12; // LED #6 - INJ#4 - boardConfiguration->injectionPins[6 - 1] = GPIOE_11; + engineConfiguration->injectionPins[6 - 1] = GPIOE_11; // LED #7 // TLE8888_PIN_24: "43 - GP Out 4" - boardConfiguration->injectionPins[5 - 1] = TLE8888_PIN_24; + engineConfiguration->injectionPins[5 - 1] = TLE8888_PIN_24; // LED #8 // TLE8888 half bridges (pushpull, lowside, or high-low) IN12 // GPIOE_8: "35 - GP Out 1" - boardConfiguration->injectionPins[8 - 1] = GPIOE_8; + engineConfiguration->injectionPins[8 - 1] = GPIOE_8; // LED #9 // TLE8888 high current low side: IN10 // GPIOE_9: "7 - Lowside 1" - boardConfiguration->injectionPins[7 - 1] = GPIOE_9; + engineConfiguration->injectionPins[7 - 1] = GPIOE_9; // LED #10 // TLE8888 high current low side: VVT2 IN9 / OUT5 // GPIOE_10: "3 - Lowside 2" - boardConfiguration->injectionPins[2 - 1] = GPIOE_10; + engineConfiguration->injectionPins[2 - 1] = GPIOE_10; #endif /* BOARD_TLE8888_COUNT */ } diff --git a/firmware/config/engines/custom_engine.h b/firmware/config/engines/custom_engine.h index 210b04562b..da55c1f5e6 100644 --- a/firmware/config/engines/custom_engine.h +++ b/firmware/config/engines/custom_engine.h @@ -10,8 +10,8 @@ #include "engine_configuration.h" void setFrankensoConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE); -void setFrankenso_01_LCD(board_configuration_s *boardConfiguration); -void disableLCD(board_configuration_s *boardConfiguration); +void setFrankenso_01_LCD(engine_configuration_s *engineConfiguration); +void disableLCD(engine_configuration_s *engineConfiguration); void runSchedulingPrecisionTestIfNeeded(void); void setFrankensoBoardTestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setEtbTestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index c07d5b80f7..89687a1dba 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -155,12 +155,12 @@ void setDodgeNeon1995EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // engineConfiguration->spi2MosiMode = PAL_STM32_OTYPE_OPENDRAIN; // 4 // engineConfiguration->spi2MisoMode = PAL_STM32_PUDR_PULLUP; // 32 - // boardConfiguration->spi2mosiPin = GPIOB_15; - // boardConfiguration->spi2misoPin = GPIOB_14; - // boardConfiguration->spi2sckPin = GPIOB_13; - boardConfiguration->cj125CsPin = GPIOB_0; // rev 0.4 - boardConfiguration->isCJ125Enabled = true; - boardConfiguration->is_enabled_spi_2 = true; + // engineConfiguration->spi2mosiPin = GPIOB_15; + // engineConfiguration->spi2misoPin = GPIOB_14; + // engineConfiguration->spi2sckPin = GPIOB_13; + engineConfiguration->cj125CsPin = GPIOB_0; // rev 0.4 + engineConfiguration->isCJ125Enabled = true; + engineConfiguration->is_enabled_spi_2 = true; // set_rpm_hard_limit 4000 @@ -222,28 +222,28 @@ void setDodgeNeon1995EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - boardConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - boardConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - boardConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 - boardConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 + engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 + engineConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 - boardConfiguration->fuelPumpPin = GPIOC_13; // Frankenstein: low side - out #4 - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->fuelPumpPin = GPIOC_13; // Frankenstein: low side - out #4 + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; engineConfiguration->mapErrorDetectionTooHigh = 120; // set injection_pin_mode 0 - boardConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPinMode = OM_DEFAULT; // Frankenstein: high side #1: PE8 // Frankenstein: high side #2: PE10 - boardConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: high side #1 - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOE_10; // // Frankenstein: high side #2 + engineConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: high side #1 + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOE_10; // // Frankenstein: high side #2 // set ignition_pin_mode 0 - boardConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPinMode = OM_DEFAULT; engineConfiguration->clt.config = {0, 30, 100, 32500, 7550, 700, 2700}; @@ -253,7 +253,7 @@ void setDodgeNeon1995EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setDefaultFrankensoConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->trigger.type = TT_DODGE_NEON_2003_CAM; - setFrankenso_01_LCD(boardConfiguration); + setFrankenso_01_LCD(engineConfiguration); setFrankenso0_1_joystick(engineConfiguration); // set global_trigger_offset_angle 38 @@ -316,7 +316,7 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFuelTablesLoadBin(20, 120 PASS_CONFIG_PARAMETER_SUFFIX); - boardConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; /** * PA4 Wideband O2 Sensor @@ -342,29 +342,29 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenso low out #11: PB8 injector #1 // Frankenso low out #12: PB7 injector #4 - boardConfiguration->fanPin = GPIOD_7; + engineConfiguration->fanPin = GPIOD_7; - boardConfiguration->injectionPins[0] = GPIOB_8; - boardConfiguration->injectionPins[1] = GPIOB_9; - boardConfiguration->injectionPins[2] = GPIOE_2; - boardConfiguration->injectionPins[3] = GPIOB_7; + engineConfiguration->injectionPins[0] = GPIOB_8; + engineConfiguration->injectionPins[1] = GPIOB_9; + engineConfiguration->injectionPins[2] = GPIOE_2; + engineConfiguration->injectionPins[3] = GPIOB_7; - boardConfiguration->ignitionPins[0] = GPIOC_9; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOE_8; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOC_9; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOE_8; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->mainRelayPin = GPIOE_6; + engineConfiguration->mainRelayPin = GPIOE_6; - boardConfiguration->idle.solenoidPin = GPIOC_13; - boardConfiguration->idle.solenoidFrequency = 300; - boardConfiguration->manIdlePosition = 36; + engineConfiguration->idle.solenoidPin = GPIOC_13; + engineConfiguration->idle.solenoidFrequency = 300; + engineConfiguration->manIdlePosition = 36; - boardConfiguration->fuelPumpPin = GPIOE_3; - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->fuelPumpPin = GPIOE_3; + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIOC_6; /** * Frankenso analog #1 PC2 ADC12 CLT @@ -412,8 +412,8 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { */ engineConfiguration->clt.adcChannel = EFI_ADC_12; - boardConfiguration->sensorChartMode = SC_MAP; - boardConfiguration->isFastAdcEnabled = true; + engineConfiguration->sensorChartMode = SC_MAP; + engineConfiguration->isFastAdcEnabled = true; engineConfiguration->map.sensor.type = MT_DODGE_NEON_2003; engineConfiguration->hip9011Gain = 0.3; @@ -432,8 +432,8 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->cylinderBore = 87.5; - boardConfiguration->clutchDownPin = GPIOC_12; - boardConfiguration->clutchDownPinMode = PI_PULLUP; + engineConfiguration->clutchDownPin = GPIOC_12; + engineConfiguration->clutchDownPinMode = PI_PULLUP; // engineConfiguration->clutchUpPin = GPIOA_14; // note SWCLK - conflict with SWD engineConfiguration->clutchUpPinMode = PI_PULLUP; @@ -452,7 +452,7 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // /** // * set_fsio_setting 1 0.55 // */ -// boardConfiguration->fsio_setting[0] = 0.55; +// engineConfiguration->fsio_setting[0] = 0.55; // setFsioExt(0, GPIOE_5, "0 fsio_setting", 400 PASS_CONFIG_PARAMETER_SUFFIX); #endif @@ -463,11 +463,11 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // engineConfiguration->fanOnTemperature = 115; // knock testing - value is a bit high // engineConfiguration->fanOffTemperature = 100; -// boardConfiguration->tunerStudioSerialSpeed = 9600; - boardConfiguration->tunerStudioSerialSpeed = 19200; +// engineConfiguration->tunerStudioSerialSpeed = 9600; + engineConfiguration->tunerStudioSerialSpeed = 19200; setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); -//temp boardConfiguration->alternatorControlPin = GPIOD_5; +//temp engineConfiguration->alternatorControlPin = GPIOD_5; engineConfiguration->targetVBatt = 14.0; engineConfiguration->alternatorControl.offset = 20; engineConfiguration->alternatorControl.pFactor = 20; @@ -493,8 +493,8 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->wwaeTau = 0; engineConfiguration->wwaeBeta = 0; - boardConfiguration->isSdCardEnabled = false; - boardConfiguration->manIdlePosition = 36; // set_idle_pwm 40 + engineConfiguration->isSdCardEnabled = false; + engineConfiguration->manIdlePosition = 36; // set_idle_pwm 40 engineConfiguration->slowAdcAlpha = 0.33333; diff --git a/firmware/config/engines/dodge_ram.cpp b/firmware/config/engines/dodge_ram.cpp index 6a12cf9259..1ee445e19f 100644 --- a/firmware/config/engines/dodge_ram.cpp +++ b/firmware/config/engines/dodge_ram.cpp @@ -35,27 +35,27 @@ void setDodgeRam1996(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->specs.firingOrder = FO_1_8_4_3_6_5_7_2; engineConfiguration->specs.displacement = 5.2; - boardConfiguration->triggerInputPins[0] = GPIOC_6; - boardConfiguration->triggerInputPins[1] = GPIOA_5; + engineConfiguration->triggerInputPins[0] = GPIOC_6; + engineConfiguration->triggerInputPins[1] = GPIOA_5; - boardConfiguration->injectionPins[0] = GPIOE_2; - boardConfiguration->injectionPins[1] = GPIOB_9; - boardConfiguration->injectionPins[2] = GPIOD_5; - boardConfiguration->injectionPins[3] = GPIOB_8; + engineConfiguration->injectionPins[0] = GPIOE_2; + engineConfiguration->injectionPins[1] = GPIOB_9; + engineConfiguration->injectionPins[2] = GPIOD_5; + engineConfiguration->injectionPins[3] = GPIOB_8; - boardConfiguration->injectionPins[4] = GPIOB_7; - boardConfiguration->injectionPins[5] = GPIOE_3; - boardConfiguration->injectionPins[6] = GPIOE_4; - boardConfiguration->injectionPins[7] = GPIOD_3; + engineConfiguration->injectionPins[4] = GPIOB_7; + engineConfiguration->injectionPins[5] = GPIOE_3; + engineConfiguration->injectionPins[6] = GPIOE_4; + engineConfiguration->injectionPins[7] = GPIOD_3; - boardConfiguration->ignitionPins[0] = GPIOC_9; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOC_9; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->mainRelayPin = GPIOE_5; - boardConfiguration->fuelPumpPin = GPIOE_6; - boardConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->mainRelayPin = GPIOE_5; + engineConfiguration->fuelPumpPin = GPIOE_6; + engineConfiguration->fanPin = GPIO_UNASSIGNED; engineConfiguration->engineChartSize = 450; @@ -69,11 +69,11 @@ void setDodgeRam1996(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setWholeTimingTable_d(10 PASS_CONFIG_PARAMETER_SUFFIX); - boardConfiguration->alternatorControlPin = GPIOD_7; + engineConfiguration->alternatorControlPin = GPIOD_7; engineConfiguration->alternatorControl.pFactor = 22; - boardConfiguration->idle.solenoidPin = GPIOC_13; - boardConfiguration->idle.solenoidFrequency = 300; + engineConfiguration->idle.solenoidPin = GPIOC_13; + engineConfiguration->idle.solenoidFrequency = 300; engineConfiguration->vbattAdcChannel = EFI_ADC_14; // engineConfiguration->vbattDividerCoeff = ((float) (8.93 + 41.27)) / 8.93 * 2; @@ -82,5 +82,5 @@ void setDodgeRam1996(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setDodgeSensor(&engineConfiguration->clt, 2700); setDodgeSensor(&engineConfiguration->iat, 2700); - boardConfiguration->useStepperIdle = true; + engineConfiguration->useStepperIdle = true; } diff --git a/firmware/config/engines/engines.mk b/firmware/config/engines/engines.mk index f83ff040c4..6352602767 100644 --- a/firmware/config/engines/engines.mk +++ b/firmware/config/engines/engines.mk @@ -21,13 +21,13 @@ ENGINES_SRC_CPP = $(PROJECT_DIR)/config/engines/ford_aspire.cpp \ $(PROJECT_DIR)/config/engines/subaru.cpp \ $(PROJECT_DIR)/config/engines/GY6_139QMB.cpp \ $(PROJECT_DIR)/config/engines/rover_v8.cpp \ - $(PROJECT_DIR)/config/engines/mazda_323.cpp \ $(PROJECT_DIR)/config/engines/mazda_626.cpp \ $(PROJECT_DIR)/config/engines/sachs.cpp \ $(PROJECT_DIR)/config/engines/test_engine.cpp \ $(PROJECT_DIR)/config/engines/mitsubishi.cpp \ $(PROJECT_DIR)/config/engines/dodge_ram.cpp \ $(PROJECT_DIR)/config/engines/vw.cpp \ + $(PROJECT_DIR)/config/engines/vw_b6.cpp \ $(PROJECT_DIR)/config/engines/dodge_stratus.cpp \ $(PROJECT_DIR)/config/engines/chevrolet_camaro_4.cpp \ $(PROJECT_DIR)/config/engines/suzuki_vitara.cpp \ diff --git a/firmware/config/engines/ford_1995_inline_6.cpp b/firmware/config/engines/ford_1995_inline_6.cpp index b041473081..639516b587 100644 --- a/firmware/config/engines/ford_1995_inline_6.cpp +++ b/firmware/config/engines/ford_1995_inline_6.cpp @@ -82,13 +82,13 @@ void setFordInline6(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // output 5 is PC13 // output 6 is PC15 - boardConfiguration->fuelPumpPin = GPIOC_13; - boardConfiguration->injectionPins[0] = GPIOB_9; - boardConfiguration->injectionPins[1] = GPIOE_3; - boardConfiguration->ignitionPins[0] = GPIOC_15; + engineConfiguration->fuelPumpPin = GPIOC_13; + engineConfiguration->injectionPins[0] = GPIOB_9; + engineConfiguration->injectionPins[1] = GPIOE_3; + engineConfiguration->ignitionPins[0] = GPIOC_15; - boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->fanPin = GPIO_UNASSIGNED; engineConfiguration->tpsMin = convertVoltageTo10bitADC(1.250); engineConfiguration->tpsMax = convertVoltageTo10bitADC(4.538); @@ -96,10 +96,10 @@ void setFordInline6(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // engineConfiguration->vbattAdcChannel = 0; // engineConfiguration->mafAdcChannel = EFI_ADC_1; - boardConfiguration->triggerInputPins[0] = GPIOA_8; - boardConfiguration->triggerInputPins[1] = GPIOA_5; - boardConfiguration->logicAnalyzerPins[0] = GPIOC_6; - boardConfiguration->logicAnalyzerPins[1] = GPIOE_5; + engineConfiguration->triggerInputPins[0] = GPIOA_8; + engineConfiguration->triggerInputPins[1] = GPIOA_5; + engineConfiguration->logicAnalyzerPins[0] = GPIOC_6; + engineConfiguration->logicAnalyzerPins[1] = GPIOE_5; } #endif /* EFI_SUPPORT_1995_FORD_INLINE_6 */ diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index f3bbe29921..1568759197 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -129,8 +129,8 @@ void setFordAspireEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->useOnlyRisingEdgeForTrigger = true; engineConfiguration->trigger.type = TT_FORD_ASPIRE; - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; engineConfiguration->HD44780width = 20; engineConfiguration->HD44780height = 4; diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index 1ebc26f6b8..69e257aefb 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -73,7 +73,7 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->trigger.type = TT_MAZDA_DOHC_1_4; - setFrankenso_01_LCD(boardConfiguration); + setFrankenso_01_LCD(engineConfiguration); setFrankenso0_1_joystick(engineConfiguration); setDensoTODO(config); @@ -87,40 +87,46 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFuelLoadBin(1.2, 4.4 PASS_CONFIG_PARAMETER_SUFFIX); setFuelRpmBin(800, 7000 PASS_CONFIG_PARAMETER_SUFFIX); - config->veRpmBins[0] = 800; - config->veRpmBins[1] = 1200; - config->veRpmBins[2] = 1600; - config->veRpmBins[3] = 2000; - config->veRpmBins[4] = 2400; - config->veRpmBins[5] = 2800; - config->veRpmBins[6] = 3200; - config->veRpmBins[7] = 3600; - config->veRpmBins[8] = 4100; - config->veRpmBins[9] = 4500; - config->veRpmBins[10] = 4900; - config->veRpmBins[11] = 5300; - config->veRpmBins[12] = 5700; - config->veRpmBins[13] = 6100; - config->veRpmBins[14] = 6500; - config->veRpmBins[15] = 7000; + static const float veRpmBins[] = + { + 800, + 1200, + 1600, + 2000, + 2400, + 2800, + 3200, + 3600, + 4100, + 4500, + 4900, + 5300, + 5700, + 6100, + 6500, + 7000 + }; + + copyArray(config->veRpmBins, veRpmBins); + copyFuelTable(racingFestivaVeTable, config->veTable); -// boardConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU -// boardConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP +// engineConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU +// engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP // in case of SOHC distributor we only have one signal -// boardConfiguration->triggerInputPins[0] = GPIOA_5; // 2E White CKP -// boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; +// engineConfiguration->triggerInputPins[0] = GPIOA_5; // 2E White CKP +// engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; // in case of DOHC distributor we have two signals - boardConfiguration->triggerInputPins[0] = GPIOC_6; - boardConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP + engineConfiguration->triggerInputPins[0] = GPIOC_6; + engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP // Denso 195500-2180 engineConfiguration->injector.flow = 265; - boardConfiguration->isFastAdcEnabled = true; + engineConfiguration->isFastAdcEnabled = true; engineConfiguration->map.sensor.type = MT_DENSO183; /** * pin PA4: jumper W47<>W47 - ecu plug 3I @@ -131,7 +137,7 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->afr.hwChannel = EFI_ADC_2; // Frankenso analog #5 // PA2 // set_idle_position 10 - boardConfiguration->manIdlePosition = 10; + engineConfiguration->manIdlePosition = 10; engineConfiguration->crankingIACposition = 65; setWholeIatCorrTimingTable(0 PASS_CONFIG_PARAMETER_SUFFIX); @@ -158,8 +164,8 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setSingleCoilDwell(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->ignitionMode = IM_ONE_COIL; - boardConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN; - boardConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; + engineConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN; + engineConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; // individual coils // W6 PC9 @@ -167,11 +173,11 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // W12 PE8 // W13 PE12 - boardConfiguration->ignitionPins[0] = GPIOC_9; - boardConfiguration->ignitionPins[1] = GPIOC_7; - boardConfiguration->ignitionPins[2] = GPIOE_8; - boardConfiguration->ignitionPins[3] = GPIOE_12; - boardConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPins[0] = GPIOC_9; + engineConfiguration->ignitionPins[1] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOE_8; + engineConfiguration->ignitionPins[3] = GPIOE_12; + engineConfiguration->ignitionPinMode = OM_DEFAULT; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; @@ -193,18 +199,18 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenso low out #11: PB8 // Frankenso low out #12: PB7 - boardConfiguration->injectionPins[0] = GPIOD_3; - boardConfiguration->injectionPins[1] = GPIOE_2; + engineConfiguration->injectionPins[0] = GPIOD_3; + engineConfiguration->injectionPins[1] = GPIOE_2; // 40% idle is good default - boardConfiguration->idle.solenoidFrequency = 300; - boardConfiguration->idle.solenoidPin = GPIOB_9; + engineConfiguration->idle.solenoidFrequency = 300; + engineConfiguration->idle.solenoidPin = GPIOB_9; - boardConfiguration->malfunctionIndicatorPin = GPIOE_5; - boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; + engineConfiguration->malfunctionIndicatorPin = GPIOE_5; + engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; - boardConfiguration->tunerStudioSerialSpeed = 19200; + engineConfiguration->tunerStudioSerialSpeed = 19200; commonFrankensoAnalogInputs(engineConfiguration); setCommonNTCSensor(&engineConfiguration->clt, 2700); @@ -229,7 +235,7 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { * to test * set_fsio_setting 1 5000 */ - boardConfiguration->fsio_setting[0] = 5000; + engineConfiguration->fsio_setting[0] = 5000; // set_fsio_expression 1 "rpm > fsio_setting(1)" setFsioExt(0, GPIOE_3, RPM_ABOVE_USER_SETTING_1, 150 PASS_CONFIG_PARAMETER_SUFFIX); @@ -244,30 +250,36 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { * set_rpn_expression 1 "rpm 0 fsio_setting > coolant 1 fsio_setting > | vbatt 2 fsio_setting < |" * eval "rpm 0 fsio_setting > coolant 1 fsio_setting > | vbatt 2 fsio_setting < |" */ - boardConfiguration->fsio_setting[1] = 6200; // RPM threshold - boardConfiguration->fsio_setting[2] = 90; // CLT threshold - boardConfiguration->fsio_setting[3] = 13.5; // voltage threshold + engineConfiguration->fsio_setting[1] = 6200; // RPM threshold + engineConfiguration->fsio_setting[2] = 90; // CLT threshold + engineConfiguration->fsio_setting[3] = 13.5; // voltage threshold // setFsio(1, GPIOC_13, "rpm 2 fsio_setting > coolant 3 fsio_setting > | vbatt 4 fsio_setting < |" PASS_CONFIG_PARAMETER_SUFFIX); setFsio(1, GPIOD_7, RPM_ABOVE_USER_SETTING_2 PASS_CONFIG_PARAMETER_SUFFIX); #endif /* EFI_FSIO */ - config->ignitionRpmBins[0] = 800; - config->ignitionRpmBins[1] = 1200; - config->ignitionRpmBins[2] = 1600; - config->ignitionRpmBins[3] = 2000; - config->ignitionRpmBins[4] = 2400; - config->ignitionRpmBins[5] = 2800; - config->ignitionRpmBins[6] = 3200; - config->ignitionRpmBins[7] = 3600; - config->ignitionRpmBins[8] = 4100; - config->ignitionRpmBins[9] = 4500; - config->ignitionRpmBins[10] = 4900; - config->ignitionRpmBins[11] = 5300; - config->ignitionRpmBins[12] = 5700; - config->ignitionRpmBins[13] = 6100; - config->ignitionRpmBins[14] = 6500; - config->ignitionRpmBins[15] = 7000; + static const float ignitionRpmBins[] = + { + 800, + 1200, + 1600, + 2000, + 2400, + 2800, + 3200, + 3600, + 4100, + 4500, + 4900, + 5300, + 5700, + 6100, + 6500, + 7000 + }; + + copyArray(config->ignitionRpmBins, ignitionRpmBins); + #if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(racingFestivaIgnitionTable, config->ignitionTable); #endif @@ -277,7 +289,7 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->engineLoadAccelEnrichmentThreshold = 5.0; engineConfiguration->engineLoadAccelEnrichmentMultiplier = 1; - boardConfiguration->isSdCardEnabled = true; + engineConfiguration->isSdCardEnabled = true; // engineConfiguration->useFSIO16ForTimingAdjustment = true; // we wanted to have a timinig table adjustment switch here diff --git a/firmware/config/engines/honda_600.cpp b/firmware/config/engines/honda_600.cpp index 5a00607f04..66c1ba5b22 100644 --- a/firmware/config/engines/honda_600.cpp +++ b/firmware/config/engines/honda_600.cpp @@ -69,8 +69,8 @@ void setHonda600(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->fuelAlgorithm = LM_ALPHA_N; // upside down wiring - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIOC_6; // set global_trigger_offset_angle 180 @@ -90,7 +90,7 @@ void setHonda600(DECLARE_CONFIG_PARAMETER_SIGNATURE) { //setIndividualCoilsIgnition(); - setFrankenso_01_LCD(boardConfiguration); + setFrankenso_01_LCD(engineConfiguration); commonFrankensoAnalogInputs(engineConfiguration); setFrankenso0_1_joystick(engineConfiguration); #if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT @@ -138,33 +138,33 @@ void setHonda600(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenso low out #11: PB8 injector #3 // Frankenso low out #12: PB7 injector #4 - boardConfiguration->fuelPumpPin = GPIOE_4; - boardConfiguration->mainRelayPin = GPIOD_7; - boardConfiguration->idle.solenoidPin = GPIOC_13; + engineConfiguration->fuelPumpPin = GPIOE_4; + engineConfiguration->mainRelayPin = GPIOD_7; + engineConfiguration->idle.solenoidPin = GPIOC_13; - boardConfiguration->fanPin = GPIOE_5; + engineConfiguration->fanPin = GPIOE_5; - boardConfiguration->injectionPins[0] = GPIOB_9; // #1 - boardConfiguration->injectionPins[1] = GPIOD_5; // #2 - boardConfiguration->injectionPins[2] = GPIOB_7; // #3 - boardConfiguration->injectionPins[3] = GPIOB_8; // #4 + engineConfiguration->injectionPins[0] = GPIOB_9; // #1 + engineConfiguration->injectionPins[1] = GPIOD_5; // #2 + engineConfiguration->injectionPins[2] = GPIOB_7; // #3 + engineConfiguration->injectionPins[3] = GPIOB_8; // #4 setDefaultCustomMaps(PASS_CONFIG_PARAMETER_SIGNATURE); setAlgorithm(LM_ALPHA_N PASS_CONFIG_PARAMETER_SUFFIX); - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[7] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[8] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[9] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[10] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[11] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[0] = GPIOE_14; - boardConfiguration->ignitionPins[1] = GPIOC_7; - boardConfiguration->ignitionPins[2] = GPIOE_10; - boardConfiguration->ignitionPins[3] = GPIOC_9; // #4 + engineConfiguration->ignitionPins[0] = GPIOE_14; + engineConfiguration->ignitionPins[1] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOE_10; + engineConfiguration->ignitionPins[3] = GPIOC_9; // #4 // todo: 8.2 or 10k? engineConfiguration->vbattDividerCoeff = ((float) (10 + 33)) / 10 * 2; diff --git a/firmware/config/engines/honda_accord.cpp b/firmware/config/engines/honda_accord.cpp index 6b9e6db0c6..89364d2c1e 100644 --- a/firmware/config/engines/honda_accord.cpp +++ b/firmware/config/engines/honda_accord.cpp @@ -39,7 +39,7 @@ EXTERN_CONFIG; static void setHondaAccordConfigurationCommon(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->map.sensor.type = MT_DENSO183; - boardConfiguration->isFastAdcEnabled = true; + engineConfiguration->isFastAdcEnabled = true; // set ignition_mode 0 engineConfiguration->ignitionMode = IM_ONE_COIL; @@ -148,29 +148,29 @@ static void setHondaAccordConfigurationCommon(DECLARE_CONFIG_PARAMETER_SIGNATURE // Frankenso low out #10: PD5 Injector #3 // Frankenso low out #11: PB8 injector #1 // Frankenso low out #12: PB7 injector #4 - boardConfiguration->fuelPumpPin = GPIOE_3; - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; - boardConfiguration->malfunctionIndicatorPin = GPIOE_2; - boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; - boardConfiguration->fanPin = GPIOE_4; // blue wire + engineConfiguration->fuelPumpPin = GPIOE_3; + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->malfunctionIndicatorPin = GPIOE_2; + engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; + engineConfiguration->fanPin = GPIOE_4; // blue wire - boardConfiguration->idle.solenoidPin = GPIOD_3; // green wire + engineConfiguration->idle.solenoidPin = GPIOD_3; // green wire - boardConfiguration->injectionPins[0] = GPIOB_8; - boardConfiguration->injectionPins[1] = GPIOB_9; - boardConfiguration->injectionPins[2] = GPIOD_5; - boardConfiguration->injectionPins[3] = GPIOB_7; + engineConfiguration->injectionPins[0] = GPIOB_8; + engineConfiguration->injectionPins[1] = GPIOB_9; + engineConfiguration->injectionPins[2] = GPIOD_5; + engineConfiguration->injectionPins[3] = GPIOB_7; - boardConfiguration->ignitionPins[0] = GPIOE_12; // white wire - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOE_12; // white wire + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - setFrankenso_01_LCD(boardConfiguration); + setFrankenso_01_LCD(engineConfiguration); setFrankenso0_1_joystick(engineConfiguration); - boardConfiguration->idle.solenoidFrequency = 500; + engineConfiguration->idle.solenoidFrequency = 500; } /* diff --git a/firmware/config/engines/lada_kalina.cpp b/firmware/config/engines/lada_kalina.cpp index ed03a3b18d..56f77539bc 100644 --- a/firmware/config/engines/lada_kalina.cpp +++ b/firmware/config/engines/lada_kalina.cpp @@ -15,35 +15,35 @@ EXTERN_CONFIG; void setLadaKalina(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFrankensoConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); - disableLCD(boardConfiguration); + disableLCD(engineConfiguration); - boardConfiguration->HD44780_rs = GPIO_UNASSIGNED; - boardConfiguration->HD44780_e = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - boardConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; + engineConfiguration->HD44780_e = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; engineConfiguration->globalTriggerAngleOffset = 114; - boardConfiguration->ignitionPins[0] = GPIOE_14; - boardConfiguration->ignitionPins[1] = GPIOC_7; - boardConfiguration->ignitionPins[2] = GPIOC_9; - boardConfiguration->ignitionPins[3] = GPIOE_12; + engineConfiguration->ignitionPins[0] = GPIOE_14; + engineConfiguration->ignitionPins[1] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOC_9; + engineConfiguration->ignitionPins[3] = GPIOE_12; - boardConfiguration->useStepperIdle = true; - boardConfiguration->fuelPumpPin = GPIOC_13; - boardConfiguration->mainRelayPin = GPIOD_7; + engineConfiguration->useStepperIdle = true; + engineConfiguration->fuelPumpPin = GPIOC_13; + engineConfiguration->mainRelayPin = GPIOD_7; - boardConfiguration->idle.stepperDirectionPin = GPIOE_15; - boardConfiguration->idle.stepperStepPin = GPIOE_13; + engineConfiguration->idle.stepperDirectionPin = GPIOE_15; + engineConfiguration->idle.stepperStepPin = GPIOE_13; engineConfiguration->stepperEnablePin = GPIOE_11; @@ -54,7 +54,7 @@ void setLadaKalina(DECLARE_CONFIG_PARAMETER_SIGNATURE) { * to test * set_fsio_setting 1 5000 */ - engineConfiguration->bc.fsio_setting[0] = 500; + engineConfiguration->fsio_setting[0] = 500; // set_rpn_expression 1 "rpm 0 fsio_setting <" setFsioExt(0, GPIOE_3, RPM_BELOW_USER_SETTING_1, 0 PASS_CONFIG_PARAMETER_SUFFIX); #endif /* EFI_FSIO */ diff --git a/firmware/config/engines/mazda_323.cpp b/firmware/config/engines/mazda_323.cpp deleted file mode 100644 index 08056574d5..0000000000 --- a/firmware/config/engines/mazda_323.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @file mazda_323.cpp - * - * @date Mar 8, 2014 - * @author Andrey Belomutskiy, (c) 2012-2018 - */ - -#include "mazda_323.h" - -EXTERN_CONFIG; - -void setMazda323EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.displacement = 1.6; - - engineConfiguration->ignitionMode = IM_ONE_COIL; - - /** - * We treat the trigger as 4/0 toothed wheel - */ -// setToothedWheelConfiguration(engineConfiguration, 4, 0); -} diff --git a/firmware/config/engines/mazda_323.h b/firmware/config/engines/mazda_323.h deleted file mode 100644 index ff614afc87..0000000000 --- a/firmware/config/engines/mazda_323.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file mazda_323.h - * - * 90-94 Mazda 323 (1.6l SOHC) - * 90-93 Ford Festiva (1.3l SOHC) - * - * http://rusefi.com/forum/viewtopic.php?f=3&t=498 - * - * @date Mar 8, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 - */ - -#pragma once - -#include "engine_configuration.h" - -void setMazda323EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/config/engines/mazda_626.cpp b/firmware/config/engines/mazda_626.cpp index a75e558467..880c7a8a9f 100644 --- a/firmware/config/engines/mazda_626.cpp +++ b/firmware/config/engines/mazda_626.cpp @@ -26,7 +26,7 @@ void setMazda626EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // engineConfiguration->trigger.type = TT_MAZDA_DOHC_1_4; // with this complex trigger we do not need this by default - boardConfiguration->sensorChartMode = SC_OFF; + engineConfiguration->sensorChartMode = SC_OFF; engineConfiguration->useOnlyRisingEdgeForTrigger = true; @@ -103,6 +103,6 @@ void setMazda626EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->externalKnockSenseAdc = EFI_ADC_4; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = GPIOA_5; } diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index 6ab448d89d..2ea2a44160 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -135,14 +135,14 @@ static void commonMiataNa(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->trigger.type = TT_MAZDA_MIATA_NA; engineConfiguration->engineChartSize = 100; - boardConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU - boardConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP + engineConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU + engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP engineConfiguration->ignitionMode = IM_WASTED_SPARK; setFuelLoadBin(1.2, 4.4 PASS_CONFIG_PARAMETER_SUFFIX); setFuelRpmBin(800, 7000 PASS_CONFIG_PARAMETER_SUFFIX); - boardConfiguration->idle.solenoidFrequency = 160; + engineConfiguration->idle.solenoidFrequency = 160; // Frankenstein: high side #1 is PE8 // Frankenstein: high side #2 is PE10 @@ -151,16 +151,16 @@ static void commonMiataNa(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenstein: high side #5 is PC9 // Frankenstein: high side #6 is PC7 - boardConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 - boardConfiguration->ignitionPins[1] = GPIOE_14; // Frankenstein: high side #4 - boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 + engineConfiguration->ignitionPins[1] = GPIOE_14; // Frankenstein: high side #4 + engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPinMode = OM_DEFAULT; setDefaultCrankingFuel(engineConfiguration); - boardConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN; - boardConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; + engineConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN; + engineConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; setCommonNTCSensor(&engineConfiguration->clt, 2700); setCommonNTCSensor(&engineConfiguration->iat, 2700); @@ -174,7 +174,7 @@ void common079721_2351(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->specs.cylindersCount = 4; engineConfiguration->specs.firingOrder = FO_1_3_4_2; - boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED; // fuel pump is not controlled by ECU on this engine + engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; // fuel pump is not controlled by ECU on this engine // set cranking_injection_mode 0 engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; @@ -221,13 +221,13 @@ void setMiata1990(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - boardConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - boardConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPinMode = OM_DEFAULT; // todo: idleValvePin } @@ -250,17 +250,17 @@ static void setMiata1994_common(DECLARE_CONFIG_PARAMETER_SIGNATURE) { copyTimingTable(miataNA8_maf_advance_table, config->ignitionTable); #endif -// boardConfiguration->triggerSimulatorPins[0] = GPIOD_2; // 2G - YEL/BLU -// boardConfiguration->triggerSimulatorPins[1] = GPIOB_3; // 2E - WHT - four times -// boardConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN; -// boardConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; +// engineConfiguration->triggerSimulatorPins[0] = GPIOD_2; // 2G - YEL/BLU +// engineConfiguration->triggerSimulatorPins[1] = GPIOB_3; // 2E - WHT - four times +// engineConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN; +// engineConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; // -// boardConfiguration->triggerInputPins[0] = GPIO_UNASSIGNED; -// boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; +// engineConfiguration->triggerInputPins[0] = GPIO_UNASSIGNED; +// engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; // -// boardConfiguration->is_enabled_spi_1 = false; -// boardConfiguration->is_enabled_spi_2 = false; -// boardConfiguration->is_enabled_spi_3 = false; +// engineConfiguration->is_enabled_spi_1 = false; +// engineConfiguration->is_enabled_spi_2 = false; +// engineConfiguration->is_enabled_spi_3 = false; /** * Outputs @@ -277,25 +277,25 @@ static void setMiata1994_common(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenso low out #10: PE0 (do not use with discovery!) // Frankenso low out #11: PB8 // Frankenso low out #12: PB7 - boardConfiguration->fanPin = GPIOE_6; + engineConfiguration->fanPin = GPIOE_6; - boardConfiguration->o2heaterPin = GPIO_UNASSIGNED; + engineConfiguration->o2heaterPin = GPIO_UNASSIGNED; - boardConfiguration->fuelPumpPin = GPIOE_4; + engineConfiguration->fuelPumpPin = GPIOE_4; - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPinMode = OM_DEFAULT; - boardConfiguration->idle.solenoidPin = GPIOB_9; + engineConfiguration->idle.solenoidPin = GPIOB_9; - boardConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOC_7; // Frankenso high side - pin 1H - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOC_7; // Frankenso high side - pin 1H + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPinMode = OM_DEFAULT; - setFrankenso_01_LCD(boardConfiguration); + setFrankenso_01_LCD(engineConfiguration); commonFrankensoAnalogInputs(engineConfiguration); @@ -318,13 +318,13 @@ void setMiata1994_d(DECLARE_CONFIG_PARAMETER_SIGNATURE) { /** * This board was avoiding PE0 & PE1 mosfets altogether */ - boardConfiguration->injectionPins[0] = GPIOD_7; // avoiding PE1 - boardConfiguration->injectionPins[1] = GPIOE_2; - boardConfiguration->injectionPins[2] = GPIOB_8; - boardConfiguration->injectionPins[3] = GPIOB_7; + engineConfiguration->injectionPins[0] = GPIOD_7; // avoiding PE1 + engineConfiguration->injectionPins[1] = GPIOE_2; + engineConfiguration->injectionPins[2] = GPIOB_8; + engineConfiguration->injectionPins[3] = GPIOB_7; // todo: add the diode? change idle valve logic? - boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; } /** @@ -342,31 +342,31 @@ void setMiata1996(DECLARE_CONFIG_PARAMETER_SIGNATURE) { #endif // upside down - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIOC_6; - boardConfiguration->fuelPumpPin = GPIOE_4; - boardConfiguration->idle.solenoidPin = GPIOE_5; + engineConfiguration->fuelPumpPin = GPIOE_4; + engineConfiguration->idle.solenoidPin = GPIOE_5; engineConfiguration->mafAdcChannel = EFI_ADC_1; engineConfiguration->clt.adcChannel = EFI_ADC_11; engineConfiguration->tps1_1AdcChannel = EFI_ADC_13; - boardConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOE_14; // Frankenstein: high side #4 - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOE_14; // Frankenstein: high side #4 + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPinMode = OM_DEFAULT; // harness is sequential but we have a limited board engineConfiguration->crankingInjectionMode = IM_BATCH; engineConfiguration->injectionMode = IM_BATCH; - boardConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - boardConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPinMode = OM_DEFAULT; } diff --git a/firmware/config/engines/mazda_miata_1_6.cpp b/firmware/config/engines/mazda_miata_1_6.cpp index c84624c382..33a746ebda 100644 --- a/firmware/config/engines/mazda_miata_1_6.cpp +++ b/firmware/config/engines/mazda_miata_1_6.cpp @@ -114,7 +114,7 @@ static void miataNAcommonEngineSettings(DECLARE_CONFIG_PARAMETER_SIGNATURE) { copyTimingTable(mapBased16IgnitionTable, config->ignitionTable); #endif - boardConfiguration->idle.solenoidFrequency = 160; + engineConfiguration->idle.solenoidFrequency = 160; engineConfiguration->ignitionMode = IM_WASTED_SPARK; } @@ -122,16 +122,16 @@ void miataNAcommon(DECLARE_CONFIG_PARAMETER_SIGNATURE) { miataNAcommonEngineSettings(PASS_CONFIG_PARAMETER_SIGNATURE); - boardConfiguration->idle.solenoidPin = GPIOB_9; // this W61 <> W61 jumper, pin 3W + engineConfiguration->idle.solenoidPin = GPIOB_9; // this W61 <> W61 jumper, pin 3W - boardConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOC_7; // Frankenso high side - pin 1H - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOC_7; // Frankenso high side - pin 1H + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; } static void setMiataNA6_settings(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - engineConfiguration->bc.isFasterEngineSpinUpEnabled = true; + engineConfiguration->isFasterEngineSpinUpEnabled = true; memcpy(config->veRpmBins, ve16RpmBins, sizeof(ve16RpmBins)); memcpy(config->veLoadBins, ve16LoadBins, sizeof(ve16LoadBins)); @@ -202,8 +202,8 @@ void setMiataNA6_MAP_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFrankensoConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); - boardConfiguration->isHip9011Enabled = false; - boardConfiguration->isSdCardEnabled = false; + engineConfiguration->isHip9011Enabled = false; + engineConfiguration->isSdCardEnabled = false; setMiataNA6_settings(PASS_CONFIG_PARAMETER_SIGNATURE); @@ -217,7 +217,7 @@ void setMiataNA6_MAP_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->vbattDividerCoeff = 9.75;// ((float) (8.2 + 33)) / 8.2 * 2; - boardConfiguration->isSdCardEnabled = true; + engineConfiguration->isSdCardEnabled = true; // /** // * oil pressure line @@ -238,14 +238,14 @@ void setMiataNA6_MAP_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) { */ /* //WARNING: these indeces are off - boardConfiguration->fsio_setting[0] = 6400; // RPM threshold - boardConfiguration->fsio_setting[1] = 100; // CLT threshold, fsio_setting #2 - boardConfiguration->fsio_setting[2] = 13.0; // voltage threshold, fsio_setting #3 + engineConfiguration->fsio_setting[0] = 6400; // RPM threshold + engineConfiguration->fsio_setting[1] = 100; // CLT threshold, fsio_setting #2 + engineConfiguration->fsio_setting[2] = 13.0; // voltage threshold, fsio_setting #3 // set_fsio_setting 4 3000 - boardConfiguration->fsio_setting[3] = 3000; // oil pressure RPM, fsio_setting #4 + engineConfiguration->fsio_setting[3] = 3000; // oil pressure RPM, fsio_setting #4 // set_fsio_setting 5 0.52 - boardConfiguration->fsio_setting[4] = 0.52; // oil pressure threshold, fsio_setting #5 + engineConfiguration->fsio_setting[4] = 0.52; // oil pressure threshold, fsio_setting #5 */ // * set_rpn_expression 1 "rpm 3 fsio_setting >" @@ -259,17 +259,17 @@ void setMiataNA6_MAP_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFsio(0, GPIOC_13, COMBINED_WARNING_LIGHT PASS_CONFIG_PARAMETER_SUFFIX); #endif /* EFI_FSIO */ - boardConfiguration->injectionPins[0] = GPIOD_3; // #1&3 pin 3U - boardConfiguration->injectionPins[1] = GPIOE_2; // #2&4 pin 3V - boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[0] = GPIOD_3; // #1&3 pin 3U + engineConfiguration->injectionPins[1] = GPIOE_2; // #2&4 pin 3V + engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; // white wire from 1E - TOP of W4 to BOTTOM W62 - boardConfiguration->malfunctionIndicatorPin = GPIOD_5; + engineConfiguration->malfunctionIndicatorPin = GPIOD_5; // yellow wire from 1V/W22 to bottom of W48 - boardConfiguration->clutchDownPin = GPIOA_3; - boardConfiguration->clutchDownPinMode = PI_PULLUP; + engineConfiguration->clutchDownPin = GPIOA_3; + engineConfiguration->clutchDownPinMode = PI_PULLUP; // 110mm red wire from 1N/W14 to bottom of W45 @@ -280,7 +280,7 @@ void setMiataNA6_MAP_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) { #if ! EFI_UNIT_TEST // W57 PE3 A/C compressor relay out - boardConfiguration->acRelayPin = GPIOE_3; + engineConfiguration->acRelayPin = GPIOE_3; // W58 PE4 A/C fan relay out #endif /* EFI_UNIT_TEST */ @@ -311,17 +311,17 @@ void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // MAF/VAF: "19 - AN volt 4" engineConfiguration->mafAdcChannel = EFI_ADC_12; - //boardConfiguration->triggerInputPins[0] = GPIOC_6; - boardConfiguration->triggerInputPins[1] = GPIOA_5; + //engineConfiguration->triggerInputPins[0] = GPIOC_6; + engineConfiguration->triggerInputPins[1] = GPIOA_5; engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[0] = GPIOD_7; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOD_6; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOD_7; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOD_6; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; // tps = "20 - AN volt 5" //engineConfiguration->tps1_1AdcChannel = EFI_ADC_13; @@ -332,7 +332,7 @@ void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // TLE8888_PIN_24: "43 - GP Out 4" // MIL check engine // NA6 check engine light is just a normal low side driver - boardConfiguration->malfunctionIndicatorPin = TLE8888_PIN_24; + engineConfiguration->malfunctionIndicatorPin = TLE8888_PIN_24; // IAC: GPIOE_9: "7 - Lowside 1" @@ -342,8 +342,8 @@ void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // engineConfiguration->vbattDividerCoeff = (66.0f / 10.0f) * engineConfiguration->analogInputDividerCoefficient; - boardConfiguration->isHip9011Enabled = false; - boardConfiguration->isSdCardEnabled = false; + engineConfiguration->isHip9011Enabled = false; + engineConfiguration->isSdCardEnabled = false; setMiataNA6_settings(PASS_CONFIG_PARAMETER_SIGNATURE); miataNAcommonEngineSettings(PASS_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/config/engines/mazda_miata_custom_hunchback.cpp b/firmware/config/engines/mazda_miata_custom_hunchback.cpp index 32c0895a58..6efaf285dd 100644 --- a/firmware/config/engines/mazda_miata_custom_hunchback.cpp +++ b/firmware/config/engines/mazda_miata_custom_hunchback.cpp @@ -122,7 +122,7 @@ void setMazdaMiata2003EngineConfigurationNaFuelRail(DECLARE_CONFIG_PARAMETER_SIG memcpy(config->afrLoadBins, mazda_miata_nb2_targetAfrLoadBins, sizeof(mazda_miata_nb2_targetAfrLoadBins)); copyTargetAfrTable(target_AFR_hunchback, config->afrTable); - boardConfiguration->ignitionPins[2] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOC_7; // Frankenso analog #7 pin 3J, W48 top <>W48 bottom jumper, not OEM engineConfiguration->afr.hwChannel = EFI_ADC_3; // PA3 @@ -145,7 +145,7 @@ void setMazdaMiata2003EngineConfigurationNaFuelRail(DECLARE_CONFIG_PARAMETER_SIG engineConfiguration->rpmHardLimit = 7200; // we want to survive the race, but we also want some fun! // set idle_position 30 - boardConfiguration->manIdlePosition = 30; + engineConfiguration->manIdlePosition = 30; engineConfiguration->crankingIACposition = 65; } diff --git a/firmware/config/engines/mazda_miata_na8.cpp b/firmware/config/engines/mazda_miata_na8.cpp index 32415cc461..8c22452187 100644 --- a/firmware/config/engines/mazda_miata_na8.cpp +++ b/firmware/config/engines/mazda_miata_na8.cpp @@ -41,10 +41,10 @@ void setMazdaMiataNA8Configuration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->vbattDividerCoeff = 9.75;// ((float) (8.2 + 33)) / 8.2 * 2; - boardConfiguration->injectionPins[0] = GPIOD_3; // #1 pin 3U - boardConfiguration->injectionPins[1] = GPIOE_2; // #2 pin 3V - boardConfiguration->injectionPins[2] = GPIOB_8; // #3 pin 3Y - boardConfiguration->injectionPins[3] = GPIOB_7; // #4 pin 3Z + engineConfiguration->injectionPins[0] = GPIOD_3; // #1 pin 3U + engineConfiguration->injectionPins[1] = GPIOE_2; // #2 pin 3V + engineConfiguration->injectionPins[2] = GPIOB_8; // #3 pin 3Y + engineConfiguration->injectionPins[3] = GPIOB_7; // #4 pin 3Z engineConfiguration->injectionMode = IM_SEQUENTIAL; } diff --git a/firmware/config/engines/mazda_miata_nb.cpp b/firmware/config/engines/mazda_miata_nb.cpp index a1eda0b209..7449a4e953 100644 --- a/firmware/config/engines/mazda_miata_nb.cpp +++ b/firmware/config/engines/mazda_miata_nb.cpp @@ -45,33 +45,33 @@ void setMazdaMiataNb1EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->iat.adcChannel = EFI_ADC_13; engineConfiguration->afr.hwChannel = EFI_ADC_2; // PA2 - boardConfiguration->idle.solenoidPin = GPIOE_0; - boardConfiguration->idle.solenoidPinMode = OM_DEFAULT; + engineConfiguration->idle.solenoidPin = GPIOE_0; + engineConfiguration->idle.solenoidPinMode = OM_DEFAULT; - boardConfiguration->fuelPumpPin = GPIOC_14; // Frankenstein: low side - out #4 - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->fuelPumpPin = GPIOC_14; // Frankenstein: low side - out #4 + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; - boardConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - boardConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - boardConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 - boardConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 + engineConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPinMode = OM_DEFAULT; - boardConfiguration->ignitionPins[0] = GPIOE_10; // Frankenstein: high side #1 - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOC_9; // // Frankenstein: high side #2 - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPinMode = OM_INVERTED; + engineConfiguration->ignitionPins[0] = GPIOE_10; // Frankenstein: high side #1 + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOC_9; // // Frankenstein: high side #2 + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPinMode = OM_INVERTED; - boardConfiguration->malfunctionIndicatorPin = GPIOE_1; - boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; + engineConfiguration->malfunctionIndicatorPin = GPIOE_1; + engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; - boardConfiguration->fanPin = GPIOE_6; - boardConfiguration->fanPinMode = OM_DEFAULT; + engineConfiguration->fanPin = GPIOE_6; + engineConfiguration->fanPinMode = OM_DEFAULT; - boardConfiguration->clutchDownPin = GPIO_UNASSIGNED; + engineConfiguration->clutchDownPin = GPIO_UNASSIGNED; // set_whole_fuel_map 3 setWholeFuelMap(3 PASS_CONFIG_PARAMETER_SUFFIX); @@ -84,7 +84,7 @@ void setMazdaMiataNb1EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { * to test * set_fsio_setting 1 5000 */ - boardConfiguration->fsio_setting[0] = 5000; + engineConfiguration->fsio_setting[0] = 5000; // (self and (rpm > 4800)) OR (rpm > 5000) // set_rpn_expression 1 "self rpm 4800 > & rpm 5000 > OR" // setFsioExt(0, GPIOE_3, "self rpm 4800 > & rpm 5000 > OR", 150 PASS_CONFIG_PARAMETER_SUFFIX); diff --git a/firmware/config/engines/mazda_miata_vvt.cpp b/firmware/config/engines/mazda_miata_vvt.cpp index cb87c96203..896a73a057 100644 --- a/firmware/config/engines/mazda_miata_vvt.cpp +++ b/firmware/config/engines/mazda_miata_vvt.cpp @@ -197,14 +197,14 @@ static void setMazdaMiataEngineNB2Defaults(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // 0.1375 // 6.375 // 10.625 - boardConfiguration->miataNb2VVTRatioFrom = 8.50 * 0.75; - boardConfiguration->miataNb2VVTRatioTo = 14; + engineConfiguration->miataNb2VVTRatioFrom = 8.50 * 0.75; + engineConfiguration->miataNb2VVTRatioTo = 14; engineConfiguration->nbVvtIndex = 0; engineConfiguration->auxPidFrequency[0] = 300; // VVT solenoid control // set idle_position 35 - boardConfiguration->manIdlePosition = 35; + engineConfiguration->manIdlePosition = 35; engineConfiguration->specs.cylindersCount = 4; engineConfiguration->specs.firingOrder = FO_1_3_4_2; @@ -292,29 +292,29 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setMazdaMiataEngineNB2Defaults(PASS_CONFIG_PARAMETER_SIGNATURE); -// boardConfiguration->triggerInputPins[0] = GPIOA_8; // custom Frankenso wiring in order to use SPI1 for accelerometer - boardConfiguration->triggerInputPins[0] = GPIOA_5; // board still not modified - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; +// engineConfiguration->triggerInputPins[0] = GPIOA_8; // custom Frankenso wiring in order to use SPI1 for accelerometer + engineConfiguration->triggerInputPins[0] = GPIOA_5; // board still not modified + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = GPIOC_6; -// boardConfiguration->is_enabled_spi_1 = true; +// engineConfiguration->is_enabled_spi_1 = true; engineConfiguration->twoWireBatchInjection = true; // this is needed for #492 testing - boardConfiguration->alternatorControlPin = GPIOE_10; - boardConfiguration->alternatorControlPinMode = OM_OPENDRAIN; + engineConfiguration->alternatorControlPin = GPIOE_10; + engineConfiguration->alternatorControlPinMode = OM_OPENDRAIN; // engineConfiguration->vehicleSpeedSensorInputPin = GPIOA_8; - boardConfiguration->vvtCamSensorUseRise = true; + engineConfiguration->vvtCamSensorUseRise = true; engineConfiguration->vvtDisplayInverted = true; engineConfiguration->auxPidPins[0] = GPIOE_3; // VVT solenoid control // /** // * set_fsio_setting 1 0.55 // */ - boardConfiguration->fsio_setting[0] = 0.0; + engineConfiguration->fsio_setting[0] = 0.0; // setFsioExt(0, GPIOE_3, "0 fsio_setting", 400 PASS_CONFIG_PARAMETER_SUFFIX); @@ -341,10 +341,10 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { * Miata coil on #4 PE14 - white ECU wire "1&4" */ - boardConfiguration->ignitionPins[0] = GPIOE_14; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOC_9; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOE_14; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOC_9; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; // set tps_min 90 engineConfiguration->tpsMin = 100; // convert 12to10 bit (ADC/4) @@ -354,11 +354,11 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - boardConfiguration->malfunctionIndicatorPin = GPIOD_5; + engineConfiguration->malfunctionIndicatorPin = GPIOD_5; -// boardConfiguration->malfunctionIndicatorPin = GPIOD_9; -// boardConfiguration->malfunctionIndicatorPinMode = OM_INVERTED; +// engineConfiguration->malfunctionIndicatorPin = GPIOD_9; +// engineConfiguration->malfunctionIndicatorPinMode = OM_INVERTED; // todo: blue jumper wire - what is it?! // Frankenso analog #6 pin 3R, W56 (5th lower row pin from the end) top <> W45 bottom jumper, not OEM @@ -383,9 +383,9 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { * set_fsio_setting 3 65 * set_fsio_setting 4 15 */ - boardConfiguration->fsio_setting[1] = 6500; // #2 RPM threshold - boardConfiguration->fsio_setting[2] = 105; // #3 CLT threshold - boardConfiguration->fsio_setting[3] = 12.0; // #4 voltage threshold + engineConfiguration->fsio_setting[1] = 6500; // #2 RPM threshold + engineConfiguration->fsio_setting[2] = 105; // #3 CLT threshold + engineConfiguration->fsio_setting[3] = 12.0; // #4 voltage threshold // setFsio(1, GPIOE_6, COMBINED_WARNING_LIGHT PASS_CONFIG_PARAMETER_SUFFIX); @@ -409,22 +409,26 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->throttlePedalUpVoltage = 0.65f; - // VNH2SP30 three-wire ETB control + // TLE7209 two-wire ETB control // PWM - engineConfiguration->etbIo[0].controlPin1 = GPIOE_6; - engineConfiguration->etbIo[0].controlPinMode = OM_INVERTED; + CONFIG(etb_use_two_wires) = true; + + engineConfiguration->etbIo[0].controlPin1 = GPIO_UNASSIGNED; + // - engineConfiguration->etbIo[0].directionPin1 = GPIOE_12; + engineConfiguration->etbIo[0].directionPin1 = GPIOE_12; // orange // - engineConfiguration->etbIo[0].directionPin2 = GPIOC_7; + engineConfiguration->etbIo[0].directionPin2 = GPIOC_7; // white/blue // set_analog_input_pin tps PC3 - engineConfiguration->tps1_1AdcChannel = EFI_ADC_13; // PC3 + engineConfiguration->tps1_1AdcChannel = EFI_ADC_13; // PC3 blue engineConfiguration->idleMode = IM_AUTO; - CONFIGB(useETBforIdleControl) = true; + CONFIG(useETBforIdleControl) = true; // set_analog_input_pin pps PA2 +/* a step back - Frankenso does not use ETB engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_2; +*/ engineConfiguration->idleRpmPid.offset = 0; engineConfiguration->idleRpmPid.pFactor = 0.2; @@ -432,7 +436,7 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->idleRpmPid.dFactor = 5; engineConfiguration->idleRpmPid.periodMs = 10; - engineConfiguration->bc.isFasterEngineSpinUpEnabled = true; + engineConfiguration->isFasterEngineSpinUpEnabled = true; //set etb_p 12 engineConfiguration->etb.pFactor = 12; // a bit lower p-factor seems to work better on TLE9201? MRE? @@ -473,7 +477,7 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setMazdaMiata2003EngineConfigurationBoardTest(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setMazdaMiata2003EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); - boardConfiguration->ignitionPins[2] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOC_7; // Frankenso analog #7 pin 3J, W48 top <>W48 bottom jumper, not OEM. Make sure 500K pull-down on Frankenso engineConfiguration->afr.hwChannel = EFI_ADC_3; // PA3 @@ -481,11 +485,7 @@ void setMazdaMiata2003EngineConfigurationBoardTest(DECLARE_CONFIG_PARAMETER_SIGN engineConfiguration->mafAdcChannel = EFI_ADC_4; // PA4 - W47 top <>W47 } -/** - * Pretty much OEM 2003 Miata with ETB - * set engine_type 13 - */ -void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { +static void setMiataNB2_MRE_common(DECLARE_CONFIG_PARAMETER_SIGNATURE) { #if (BOARD_TLE8888_COUNT > 0) setMazdaMiataEngineNB2Defaults(PASS_CONFIG_PARAMETER_SIGNATURE); @@ -499,15 +499,15 @@ void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // tps1_1AdcChannel input is inherited from boards/microrusefi/board_configuration.cpp // afr.hwChannel input is inherited from boards/microrusefi/board_configuration.cpp - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = GPIOA_5; engineConfiguration->useOnlyRisingEdgeForTrigger = false; engineConfiguration->useTLE8888_hall_mode = true; // GPIOD_6: "13 - GP Out 6" - selected to +12v - boardConfiguration->alternatorControlPin = GPIOD_6; + engineConfiguration->alternatorControlPin = GPIOD_6; // GPIOD_7: "14 - GP Out 5" - selected to +12v engineConfiguration->dizzySparkOutputPin = GPIOD_7; // tachometer @@ -525,25 +525,9 @@ void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->auxPidPins[0] = GPIOE_9; // VVT solenoid control // TLE8888_PIN_23: "33 - GP Out 3" - boardConfiguration->malfunctionIndicatorPin = TLE8888_PIN_23; + engineConfiguration->malfunctionIndicatorPin = TLE8888_PIN_23; - //set idle_offset 0 - engineConfiguration->idleRpmPid.offset = 0; - engineConfiguration->idleRpmPid.pFactor = 0.2; - engineConfiguration->idleRpmPid.iFactor = 0.0001; - engineConfiguration->idleRpmPid.dFactor = 5; - engineConfiguration->idleRpmPid.periodMs = 10; - - engineConfiguration->bc.isFasterEngineSpinUpEnabled = true; - - engineConfiguration->etb.pFactor = 12; // a bit lower p-factor seems to work better on TLE9201? MRE? - engineConfiguration->etb.iFactor = 0; - engineConfiguration->etb.dFactor = 0; - engineConfiguration->etb.offset = 0; - - // enable ETB - // set_rpn_expression 8 "0" - setFsio(7, GPIOC_8, "0" PASS_CONFIG_PARAMETER_SUFFIX); + engineConfiguration->isFasterEngineSpinUpEnabled = true; // set_analog_input_pin pps PA7 // EFI_ADC_7: "31 - AN volt 3" - PA7 @@ -556,10 +540,6 @@ void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->tpsMax = 870; engineConfiguration->idleMode = IM_AUTO; - CONFIGB(useETBforIdleControl) = true; - engineConfiguration->throttlePedalUpVoltage = 1; - // WAT? that's an interesting value, how come it's above 5v? - engineConfiguration->throttlePedalWOTVoltage = 5.47; // set vbatt_divider 11 // 0.3#4 has wrong R139 as well? @@ -567,3 +547,43 @@ void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->vbattDividerCoeff = (66.0f / 10.0f) * engineConfiguration->analogInputDividerCoefficient; #endif /* BOARD_TLE8888_COUNT */ } + + +/** + * Pretty much OEM 2003 Miata with ETB + * set engine_type 13 + */ +void setMiataNB2_MRE_ETB(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + setMiataNB2_MRE_common(PASS_CONFIG_PARAMETER_SIGNATURE); + +#if EFI_FSIO + // enable ETB + // set_rpn_expression 8 "0" + setFsio(7, GPIOC_8, "0" PASS_CONFIG_PARAMETER_SUFFIX); +#endif /* EFI_FSIO */ + + //set idle_offset 0 + engineConfiguration->idleRpmPid.offset = 0; + engineConfiguration->idleRpmPid.pFactor = 0.2; + engineConfiguration->idleRpmPid.iFactor = 0.0001; + engineConfiguration->idleRpmPid.dFactor = 5; + engineConfiguration->idleRpmPid.periodMs = 10; + + CONFIG(useETBforIdleControl) = true; + engineConfiguration->throttlePedalUpVoltage = 1; + // WAT? that's an interesting value, how come it's above 5v? + engineConfiguration->throttlePedalWOTVoltage = 5.47; + + engineConfiguration->etb.pFactor = 12; // a bit lower p-factor seems to work better on TLE9201? MRE? + engineConfiguration->etb.iFactor = 0; + engineConfiguration->etb.dFactor = 0; + engineConfiguration->etb.offset = 0; +} + +/** + * set engine_type 11 + */ +void setMiataNB2_MRE_MTB(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + setMiataNB2_MRE_common(PASS_CONFIG_PARAMETER_SIGNATURE); + +} diff --git a/firmware/config/engines/mazda_miata_vvt.h b/firmware/config/engines/mazda_miata_vvt.h index a5acf6b878..aa8af923c3 100644 --- a/firmware/config/engines/mazda_miata_vvt.h +++ b/firmware/config/engines/mazda_miata_vvt.h @@ -18,4 +18,5 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setMazdaMiata2003EngineConfigurationNaFuelRail(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setMazdaMiata2003EngineConfigurationBoardTest(DECLARE_CONFIG_PARAMETER_SIGNATURE); -void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE); +void setMiataNB2_MRE_ETB(DECLARE_CONFIG_PARAMETER_SIGNATURE); +void setMiataNB2_MRE_MTB(DECLARE_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/config/engines/me7pnp.cpp b/firmware/config/engines/me7pnp.cpp index 4f9f1721f2..07bd1d93ee 100644 --- a/firmware/config/engines/me7pnp.cpp +++ b/firmware/config/engines/me7pnp.cpp @@ -35,8 +35,8 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL; engineConfiguration->injectionMode = IM_SEQUENTIAL; - boardConfiguration->ignitionPinMode = OM_INVERTED; - boardConfiguration->injectionPinMode = OM_OPENDRAIN_INVERTED; + engineConfiguration->ignitionPinMode = OM_INVERTED; + engineConfiguration->injectionPinMode = OM_OPENDRAIN_INVERTED; engineConfiguration->isCylinderCleanupEnabled = true; engineConfiguration->rpmHardLimit = 8000; engineConfiguration->cranking.baseFuel = 4; @@ -44,7 +44,7 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { //Analog Inputs - boardConfiguration->isFastAdcEnabled = true; + engineConfiguration->isFastAdcEnabled = true; engineConfiguration->map.sensor.type = MT_GM_3_BAR; setCommonNTCSensor(&engineConfiguration->clt, 2700); setCommonNTCSensor(&engineConfiguration->iat, 2700); @@ -65,56 +65,56 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->canNbcType = CAN_BUS_NBC_VAG; engineConfiguration->canReadEnabled = true; engineConfiguration->canWriteEnabled = true; - boardConfiguration->canDeviceMode = CD_USE_CAN1; - boardConfiguration->canTxPin = GPIOB_6; - boardConfiguration->canRxPin = GPIOB_12; + engineConfiguration->canDeviceMode = CD_USE_CAN1; + engineConfiguration->canTxPin = GPIOB_6; + engineConfiguration->canRxPin = GPIOB_12; // Injectors - boardConfiguration->injectionPins[0] = GPIOE_4; // #1 - boardConfiguration->injectionPins[1] = GPIOE_2; // #2 - boardConfiguration->injectionPins[2] = GPIOE_3; // #3 - boardConfiguration->injectionPins[3] = GPIOE_1; // #4 - boardConfiguration->injectionPins[4] = GPIOE_6; // #5 - boardConfiguration->injectionPins[5] = GPIOE_5; // #6 - boardConfiguration->injectionPins[6] = GPIOB_9; // #7 - boardConfiguration->injectionPins[7] = GPIOE_0; // #8 + engineConfiguration->injectionPins[0] = GPIOE_4; // #1 + engineConfiguration->injectionPins[1] = GPIOE_2; // #2 + engineConfiguration->injectionPins[2] = GPIOE_3; // #3 + engineConfiguration->injectionPins[3] = GPIOE_1; // #4 + engineConfiguration->injectionPins[4] = GPIOE_6; // #5 + engineConfiguration->injectionPins[5] = GPIOE_5; // #6 + engineConfiguration->injectionPins[6] = GPIOB_9; // #7 + engineConfiguration->injectionPins[7] = GPIOE_0; // #8 //Ignition Outputs - boardConfiguration->ignitionPins[0] = GPIOD_1; // #1 - boardConfiguration->ignitionPins[1] = GPIOD_6; // #2 - boardConfiguration->ignitionPins[2] = GPIOD_3; // #3 - boardConfiguration->ignitionPins[3] = GPIOD_4; // #4 - boardConfiguration->ignitionPins[4] = GPIOD_0; // #5 - boardConfiguration->ignitionPins[5] = GPIOD_2; // #6 - boardConfiguration->ignitionPins[6] = GPIOA_15; // #7 - boardConfiguration->ignitionPins[7] = GPIOC_12; // #8 + engineConfiguration->ignitionPins[0] = GPIOD_1; // #1 + engineConfiguration->ignitionPins[1] = GPIOD_6; // #2 + engineConfiguration->ignitionPins[2] = GPIOD_3; // #3 + engineConfiguration->ignitionPins[3] = GPIOD_4; // #4 + engineConfiguration->ignitionPins[4] = GPIOD_0; // #5 + engineConfiguration->ignitionPins[5] = GPIOD_2; // #6 + engineConfiguration->ignitionPins[6] = GPIOA_15; // #7 + engineConfiguration->ignitionPins[7] = GPIOC_12; // #8 //SPI Settings - boardConfiguration->is_enabled_spi_1 = true; - boardConfiguration->is_enabled_spi_2 = true; - boardConfiguration->is_enabled_spi_3 = false; + engineConfiguration->is_enabled_spi_1 = true; + engineConfiguration->is_enabled_spi_2 = true; + engineConfiguration->is_enabled_spi_3 = false; engineConfiguration->cj125SpiDevice = SPI_DEVICE_2; - boardConfiguration->cj125CsPin = GPIOB_11; + engineConfiguration->cj125CsPin = GPIOB_11; //Digital Inputs/Outputs #if (BOARD_TLE8888_COUNT > 0) engineConfiguration->tle8888spiDevice = SPI_DEVICE_1; - boardConfiguration->fuelPumpPin = TLE8888_PIN_22; - boardConfiguration->tachOutputPin = TLE8888_PIN_16; - boardConfiguration->alternatorControlPin = TLE8888_PIN_17; + engineConfiguration->fuelPumpPin = TLE8888_PIN_22; + engineConfiguration->tachOutputPin = TLE8888_PIN_16; + engineConfiguration->alternatorControlPin = TLE8888_PIN_17; engineConfiguration->auxPidPins[0] = TLE8888_PIN_6; // VVT solenoid control #endif /* BOARD_TLE8888_COUNT */ - boardConfiguration->mainRelayPin = GPIO_UNASSIGNED; - boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - boardConfiguration->fanPin = GPIO_UNASSIGNED; - boardConfiguration->clutchDownPin = GPIOD_11; + engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->clutchDownPin = GPIOD_11; engineConfiguration->brakePedalPin = GPIOE_10; engineConfiguration->camInputs[0] = GPIOA_2; #if defined(STM32_HAS_GPIOG) && STM32_HAS_GPIOG - boardConfiguration->triggerInputPins[0] = GPIOG_7; + engineConfiguration->triggerInputPins[0] = GPIOG_7; #endif /* STM32_HAS_GPIOF */ #if defined(STM32_HAS_GPIOF) && STM32_HAS_GPIOF engineConfiguration->vehicleSpeedSensorInputPin = GPIOF_14; @@ -122,7 +122,7 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { //Alternator Settings - boardConfiguration->alternatorControlPinMode = OM_OPENDRAIN; + engineConfiguration->alternatorControlPinMode = OM_OPENDRAIN; engineConfiguration->targetVBatt = 13.8; engineConfiguration->alternatorControl.offset = 40; engineConfiguration->alternatorControl.pFactor = 14; @@ -145,7 +145,7 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { CONFIG(etbIo[0].directionPin1) = GPIOF_15; CONFIG(etbIo[0].directionPin2) = GPIOF_14; #endif /* STM32_HAS_GPIOF */ - boardConfiguration->isHip9011Enabled = false; + engineConfiguration->isHip9011Enabled = false; #if EFI_FSIO setFsio (13, GPIOE_5, "0" PASS_CONFIG_PARAMETER_SUFFIX); @@ -165,7 +165,7 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->activateAuxPid1 = true; engineConfiguration->auxPidFrequency[0] = 300; - boardConfiguration->fsio_setting[0] = 0.0; + engineConfiguration->fsio_setting[0] = 0.0; engineConfiguration->auxPid[0].pFactor = 2; engineConfiguration->auxPid[0].iFactor = 0.005; engineConfiguration->auxPid[0].dFactor = 0; @@ -173,7 +173,7 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->auxPid[0].minValue = 24; engineConfiguration->auxPid[0].maxValue = 44; engineConfiguration->auxPidFrequency[0] = 300; - boardConfiguration->fsio_setting[0] = 0.0; + engineConfiguration->fsio_setting[0] = 0.0; //AC Settings @@ -181,7 +181,7 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { //Configuration 2 : Over CAN with variable Kompressor(CAN: Input=B_sacc,B_skoc Output: B_kov) //Configuration 3 : 2 Wires - boardConfiguration->acRelayPin = GPIO_UNASSIGNED; + engineConfiguration->acRelayPin = GPIO_UNASSIGNED; engineConfiguration->acCutoffLowRpm = 400; engineConfiguration->acCutoffHighRpm = 4500; engineConfiguration->acIdleRpmBump = 200; diff --git a/firmware/config/engines/mitsubishi.cpp b/firmware/config/engines/mitsubishi.cpp index 207c25d7cc..7590562102 100644 --- a/firmware/config/engines/mitsubishi.cpp +++ b/firmware/config/engines/mitsubishi.cpp @@ -65,19 +65,19 @@ void setMitsubishiConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - boardConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - boardConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - boardConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 - boardConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 + engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 + engineConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 // Frankenstein: high side #1: PE8 // Frankenstein: high side #2: PE10 - boardConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: high side #1 - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOE_10; // // Frankenstein: high side #2 - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: high side #1 + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOE_10; // // Frankenstein: high side #2 + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; engineConfiguration->HD44780width = 20; engineConfiguration->HD44780height = 4; diff --git a/firmware/config/engines/nissan_primera.cpp b/firmware/config/engines/nissan_primera.cpp index 5e319d17e9..b9bc7639fb 100644 --- a/firmware/config/engines/nissan_primera.cpp +++ b/firmware/config/engines/nissan_primera.cpp @@ -20,9 +20,9 @@ void setNissanPrimeraEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->trigger.type = TT_NISSAN_SR20VE; - boardConfiguration->ignitionPins[0] = GPIOD_7; - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIOD_6; + engineConfiguration->ignitionPins[0] = GPIOD_7; + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIOD_6; engineConfiguration->auxValves[0] = GPIOE_14; diff --git a/firmware/config/engines/rover_v8.cpp b/firmware/config/engines/rover_v8.cpp index 417fa006a2..eaee8377f5 100644 --- a/firmware/config/engines/rover_v8.cpp +++ b/firmware/config/engines/rover_v8.cpp @@ -16,13 +16,13 @@ #include "engine_math.h" #include "allsensors.h" -void setFrankenstein_01_LCD(board_configuration_s *boardConfiguration) { - boardConfiguration->HD44780_rs = GPIOE_9; - boardConfiguration->HD44780_e = GPIOE_11; - boardConfiguration->HD44780_db4 = GPIOE_13; - boardConfiguration->HD44780_db5 = GPIOE_15; - boardConfiguration->HD44780_db6 = GPIOB_11; - boardConfiguration->HD44780_db7 = GPIOB_13; +void setFrankenstein_01_LCD(engine_configuration_s *engineConfiguration) { + engineConfiguration->HD44780_rs = GPIOE_9; + engineConfiguration->HD44780_e = GPIOE_11; + engineConfiguration->HD44780_db4 = GPIOE_13; + engineConfiguration->HD44780_db5 = GPIOE_15; + engineConfiguration->HD44780_db6 = GPIOB_11; + engineConfiguration->HD44780_db7 = GPIOB_13; } EXTERN_CONFIG; @@ -34,10 +34,10 @@ void setRoverv8(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // set trigger_type 9 engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_36_1; - boardConfiguration->is_enabled_spi_2 = false; - boardConfiguration->isHip9011Enabled = false; - CONFIGB(hip9011IntHoldPin) = GPIO_UNASSIGNED; - setFrankenstein_01_LCD(boardConfiguration); + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->isHip9011Enabled = false; + CONFIG(hip9011IntHoldPin) = GPIO_UNASSIGNED; + setFrankenstein_01_LCD(engineConfiguration); engineConfiguration->specs.displacement = 3.528; engineConfiguration->specs.cylindersCount = 8; @@ -58,13 +58,13 @@ void setRoverv8(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // set ignition_mode 2 engineConfiguration->ignitionMode = IM_WASTED_SPARK; - boardConfiguration->ignitionPinMode = OM_INVERTED; + engineConfiguration->ignitionPinMode = OM_INVERTED; // set_ignition_channels - boardConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: low side - out #x (?) - boardConfiguration->ignitionPins[7] = GPIOE_10; // Frankenstein: low side - out #x (?) - boardConfiguration->ignitionPins[3] = GPIOE_12; // Frankenstein: low side - out #x (?) - boardConfiguration->ignitionPins[2] = GPIOE_14; // Frankenstein: low side - out #x (?) + engineConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: low side - out #x (?) + engineConfiguration->ignitionPins[7] = GPIOE_10; // Frankenstein: low side - out #x (?) + engineConfiguration->ignitionPins[3] = GPIOE_12; // Frankenstein: low side - out #x (?) + engineConfiguration->ignitionPins[2] = GPIOE_14; // Frankenstein: low side - out #x (?) // Frankenstein: low side - out #1: PC14 // Frankenstein: low side - out #2: PC15 @@ -79,27 +79,27 @@ void setRoverv8(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - boardConfiguration->injectionPins[0] = GPIOC_14; // Frankenstein: low side - out #1 - boardConfiguration->injectionPins[1] = GPIOC_15; // Frankenstein: low side - out #2 - boardConfiguration->injectionPins[2] = GPIOE_6; // Frankenstein: low side - out #3 - boardConfiguration->injectionPins[3] = GPIOC_13; // Frankenstein: low side - out #4 - boardConfiguration->injectionPins[4] = GPIOE_4; // Frankenstein: low side - out #5 - boardConfiguration->injectionPins[5] = GPIOE_5; // Frankenstein: low side - out #6 - boardConfiguration->injectionPins[6] = GPIOE_2; // Frankenstein: low side - out #7 - boardConfiguration->injectionPins[7] = GPIOE_3; // Frankenstein: low side - out #8 + engineConfiguration->injectionPins[0] = GPIOC_14; // Frankenstein: low side - out #1 + engineConfiguration->injectionPins[1] = GPIOC_15; // Frankenstein: low side - out #2 + engineConfiguration->injectionPins[2] = GPIOE_6; // Frankenstein: low side - out #3 + engineConfiguration->injectionPins[3] = GPIOC_13; // Frankenstein: low side - out #4 + engineConfiguration->injectionPins[4] = GPIOE_4; // Frankenstein: low side - out #5 + engineConfiguration->injectionPins[5] = GPIOE_5; // Frankenstein: low side - out #6 + engineConfiguration->injectionPins[6] = GPIOE_2; // Frankenstein: low side - out #7 + engineConfiguration->injectionPins[7] = GPIOE_3; // Frankenstein: low side - out #8 // not valid ICU pin engineConfiguration->vehicleSpeedSensorInputPin = GPIOC_2; //GPIOE_0 AND GPIOE_1 are bad pins since they conflict with accelerometer //no malfunction indicator pin needed, since we use CAN_BUS_MAZDA_RX8 - //boardConfiguration->fuelPumpPin = GPIOE_0; // Frankenstein: low side - out #9 - //boardConfiguration->malfunctionIndicatorPin = GPIOE_1; // Frankenstein: low side - out #10 - boardConfiguration->fuelPumpPin = GPIOB_8; // Frankenstein: low side - out #11 - boardConfiguration->fuelPumpPinMode = OM_DEFAULT; - boardConfiguration->mainRelayPin = GPIOB_9; // Frankenstein: low side - out #12 + //engineConfiguration->fuelPumpPin = GPIOE_0; // Frankenstein: low side - out #9 + //engineConfiguration->malfunctionIndicatorPin = GPIOE_1; // Frankenstein: low side - out #10 + engineConfiguration->fuelPumpPin = GPIOB_8; // Frankenstein: low side - out #11 + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; + engineConfiguration->mainRelayPin = GPIOB_9; // Frankenstein: low side - out #12 - boardConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU - boardConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP + engineConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU + engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP setCommonNTCSensor(&engineConfiguration->clt, 2700); setCommonNTCSensor(&engineConfiguration->iat, 2700); @@ -117,19 +117,19 @@ void setRoverv8(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->tpsMax = convertVoltageTo10bitADC(4.538); // Stepper logic: - boardConfiguration->idle.stepperDirectionPin = GPIOB_10; - boardConfiguration->idle.stepperStepPin = GPIOB_15; + engineConfiguration->idle.stepperDirectionPin = GPIOB_10; + engineConfiguration->idle.stepperStepPin = GPIOB_15; engineConfiguration->stepperEnablePin = GPIOB_14; engineConfiguration->idleStepperReactionTime = 10; engineConfiguration->idleStepperTotalSteps = 150; - boardConfiguration->useStepperIdle = false; + engineConfiguration->useStepperIdle = false; // set injection_pin_mode 0 - boardConfiguration->injectionPinMode = OM_DEFAULT; + engineConfiguration->injectionPinMode = OM_DEFAULT; - boardConfiguration->canTxPin = GPIOB_6; - boardConfiguration->canRxPin = GPIOB_12; + engineConfiguration->canTxPin = GPIOB_6; + engineConfiguration->canRxPin = GPIOB_12; engineConfiguration->canWriteEnabled = true; engineConfiguration->canReadEnabled = false; engineConfiguration->canNbcType = CAN_BUS_MAZDA_RX8; @@ -138,10 +138,10 @@ void setRoverv8(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); // todo: make this official Frankenstein joystick? - boardConfiguration->joystickCenterPin = GPIOD_8; - boardConfiguration->joystickAPin = GPIOD_10; - boardConfiguration->joystickBPin = GPIO_UNASSIGNED; - boardConfiguration->joystickCPin = GPIO_UNASSIGNED; - boardConfiguration->joystickDPin = GPIOD_11; + engineConfiguration->joystickCenterPin = GPIOD_8; + engineConfiguration->joystickAPin = GPIOD_10; + engineConfiguration->joystickBPin = GPIO_UNASSIGNED; + engineConfiguration->joystickCPin = GPIO_UNASSIGNED; + engineConfiguration->joystickDPin = GPIOD_11; } diff --git a/firmware/config/engines/rover_v8.h b/firmware/config/engines/rover_v8.h index 3d9b773987..838438a7b0 100644 --- a/firmware/config/engines/rover_v8.h +++ b/firmware/config/engines/rover_v8.h @@ -9,7 +9,7 @@ #include "engine_configuration.h" -void setFrankenstein_01_LCD(board_configuration_s *boardConfiguration); +void setFrankenstein_01_LCD(engine_configuration_s *engineConfiguration); void setRoverv8(DECLARE_CONFIG_PARAMETER_SIGNATURE); #endif /* ROVER_V8_H_ */ diff --git a/firmware/config/engines/sachs.cpp b/firmware/config/engines/sachs.cpp index f811931d64..1c9420fd46 100644 --- a/firmware/config/engines/sachs.cpp +++ b/firmware/config/engines/sachs.cpp @@ -36,7 +36,7 @@ void setSachs(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->trigger.customTotalToothCount = 50; engineConfiguration->trigger.customSkippedToothCount = 2; - boardConfiguration->useSerialPort = false; + engineConfiguration->useSerialPort = false; // Frankenstein analog input #1: PA1 adc1 MAP // Frankenstein analog input #2: PA3 adc3 TPS @@ -75,12 +75,12 @@ void setSachs(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - boardConfiguration->triggerInputPins[0] = GPIOA_5; - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[0] = GPIOC_15; + engineConfiguration->injectionPins[0] = GPIOC_15; - boardConfiguration->fuelPumpPin = GPIOE_6; + engineConfiguration->fuelPumpPin = GPIOE_6; // todo: extract a method? figure out something smarter setFuelRpmBin(800, 15000 PASS_CONFIG_PARAMETER_SUFFIX); @@ -90,6 +90,6 @@ void setSachs(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->hasFrequencyReportingMapSensor = true; engineConfiguration->frequencyReportingMapInputPin = GPIOC_6; - boardConfiguration->mapFrequency100Kpa = 159; - boardConfiguration->mapFrequency0Kpa = 80; + engineConfiguration->mapFrequency100Kpa = 159; + engineConfiguration->mapFrequency0Kpa = 80; } diff --git a/firmware/config/engines/subaru.cpp b/firmware/config/engines/subaru.cpp index bfe2086d81..f74a1bebf4 100644 --- a/firmware/config/engines/subaru.cpp +++ b/firmware/config/engines/subaru.cpp @@ -14,7 +14,7 @@ EXTERN_CONFIG; void setSubaru2003Wrx(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - setFrankenso_01_LCD(boardConfiguration); + setFrankenso_01_LCD(engineConfiguration); setFrankenso0_1_joystick(engineConfiguration); engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; @@ -23,16 +23,16 @@ void setSubaru2003Wrx(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->sensorChartFrequency = 2; - boardConfiguration->useStepperIdle = true; + engineConfiguration->useStepperIdle = true; // See http://rusefi.com/forum/viewtopic.php?f=4&t=1161 - boardConfiguration->idle.stepperDirectionPin = GPIOD_1; // top stepper drive pin, white wire recommended - boardConfiguration->idle.stepperStepPin = GPIOD_6; // yellow wire recommended + engineConfiguration->idle.stepperDirectionPin = GPIOD_1; // top stepper drive pin, white wire recommended + engineConfiguration->idle.stepperStepPin = GPIOD_6; // yellow wire recommended engineConfiguration->stepperEnablePin = GPIOB_1; // bottom stepper driver board pin, blue wire recommended - boardConfiguration->triggerSimulatorPins[0] = GPIO_UNASSIGNED; // we want to avoid PD1 conflict - boardConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - boardConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[0] = GPIO_UNASSIGNED; // we want to avoid PD1 conflict + engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; } /* diff --git a/firmware/config/engines/suzuki_vitara.cpp b/firmware/config/engines/suzuki_vitara.cpp index 2909e2031f..0f43f6447d 100644 --- a/firmware/config/engines/suzuki_vitara.cpp +++ b/firmware/config/engines/suzuki_vitara.cpp @@ -19,7 +19,7 @@ void setSuzukiVitara(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->ignitionMode = IM_ONE_COIL; engineConfiguration->injectionMode = IM_SIMULTANEOUS; - boardConfiguration->mainRelayPin = GPIOE_6; + engineConfiguration->mainRelayPin = GPIOE_6; } diff --git a/firmware/config/engines/test_engine.cpp b/firmware/config/engines/test_engine.cpp index 0062d9e438..8e7e1f0858 100644 --- a/firmware/config/engines/test_engine.cpp +++ b/firmware/config/engines/test_engine.cpp @@ -38,20 +38,19 @@ void setTestEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->ignitionMode = IM_ONE_COIL; setConstantDwell(3 PASS_CONFIG_PARAMETER_SUFFIX); // 50% duty cycle @ 5000 rpm - board_configuration_s *bc = &engineConfiguration->bc; - bc->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[0] = GPIOC_7; // #1 - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; // #2 - boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; // #3 - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; // #4 - boardConfiguration->ignitionPins[4] = GPIO_UNASSIGNED; // #5 - boardConfiguration->ignitionPins[5] = GPIO_UNASSIGNED; // #6 + engineConfiguration->ignitionPins[0] = GPIOC_7; // #1 + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; // #2 + engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; // #3 + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; // #4 + engineConfiguration->ignitionPins[4] = GPIO_UNASSIGNED; // #5 + engineConfiguration->ignitionPins[5] = GPIO_UNASSIGNED; // #6 - boardConfiguration->logicAnalyzerPins[0] = GPIO_UNASSIGNED; - boardConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; - boardConfiguration->logicAnalyzerPins[2] = GPIO_UNASSIGNED; - boardConfiguration->logicAnalyzerPins[3] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[0] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[2] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[3] = GPIO_UNASSIGNED; } void setTestVVTEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { @@ -65,7 +64,7 @@ void setTestVVTEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // set algorithm 3 setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; engineConfiguration->camInputs[0] = GPIOA_5; // set global_trigger_offset_angle 0 diff --git a/firmware/config/engines/toyota_jzs147.cpp b/firmware/config/engines/toyota_jzs147.cpp index 93c4edcf9d..d2f0e21430 100644 --- a/firmware/config/engines/toyota_jzs147.cpp +++ b/firmware/config/engines/toyota_jzs147.cpp @@ -32,22 +32,22 @@ static void common2jz(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // set ignition_mode 1 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; - boardConfiguration->ignitionPins[0] = GPIOE_14; - boardConfiguration->ignitionPins[1] = GPIOC_7; - boardConfiguration->ignitionPins[2] = GPIOC_9; - boardConfiguration->ignitionPins[3] = GPIOE_10; - boardConfiguration->ignitionPins[4] = GPIOE_8; - boardConfiguration->ignitionPins[5] = GPIOE_12; + engineConfiguration->ignitionPins[0] = GPIOE_14; + engineConfiguration->ignitionPins[1] = GPIOC_7; + engineConfiguration->ignitionPins[2] = GPIOC_9; + engineConfiguration->ignitionPins[3] = GPIOE_10; + engineConfiguration->ignitionPins[4] = GPIOE_8; + engineConfiguration->ignitionPins[5] = GPIOE_12; - boardConfiguration->injectionPins[0] = GPIOB_9; // #1 - boardConfiguration->injectionPins[1] = GPIOE_2; // #2 - boardConfiguration->injectionPins[2] = GPIOB_8; // #3 - boardConfiguration->injectionPins[3] = GPIOB_7; // #4 - boardConfiguration->injectionPins[4] = GPIOE_3; // #5 - boardConfiguration->injectionPins[5] = GPIOE_4; // #6 + engineConfiguration->injectionPins[0] = GPIOB_9; // #1 + engineConfiguration->injectionPins[1] = GPIOE_2; // #2 + engineConfiguration->injectionPins[2] = GPIOB_8; // #3 + engineConfiguration->injectionPins[3] = GPIOB_7; // #4 + engineConfiguration->injectionPins[4] = GPIOE_3; // #5 + engineConfiguration->injectionPins[5] = GPIOE_4; // #6 - boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; // chartsize 450 engineConfiguration->engineChartSize = 450; @@ -87,10 +87,10 @@ void setToyota_jzs147EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // engineConfiguration->injectionMode = IM_BATCH; // engineConfiguration->twoWireBatchInjection = true; -// boardConfiguration->triggerInputPins[0] = GPIOA_5; -// boardConfiguration->triggerInputPins[1] = GPIOC_6; +// engineConfiguration->triggerInputPins[0] = GPIOA_5; +// engineConfiguration->triggerInputPins[1] = GPIOC_6; - boardConfiguration->isSdCardEnabled = false; + engineConfiguration->isSdCardEnabled = false; } @@ -98,13 +98,13 @@ void setToyota_jzs147EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setToyota_2jz_vics(DECLARE_CONFIG_PARAMETER_SIGNATURE) { common2jz(PASS_CONFIG_PARAMETER_SIGNATURE); - boardConfiguration->isSdCardEnabled = true; + engineConfiguration->isSdCardEnabled = true; setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); engineConfiguration->trigger.type = TT_2JZ_3_34; - boardConfiguration->triggerInputPins[0] = GPIOA_5; // crank sensor - boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; // cam sensor will he handled by custom vtti code + engineConfiguration->triggerInputPins[0] = GPIOA_5; // crank sensor + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; // cam sensor will he handled by custom vtti code engineConfiguration->camInputs[0] = GPIOC_6; engineConfiguration->vvtMode = VVT_2GZ; diff --git a/firmware/config/engines/vw.cpp b/firmware/config/engines/vw.cpp index d15b73bc13..968487ef8f 100644 --- a/firmware/config/engines/vw.cpp +++ b/firmware/config/engines/vw.cpp @@ -4,7 +4,7 @@ * set engine_type 32 * * @date May 24, 2015 - * @author Andrey Belomutskiy, (c) 2012-2018 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #include "global.h" @@ -48,11 +48,11 @@ void setVwAba(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->ignitionMode = IM_ONE_COIL; - boardConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G - boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPinMode = OM_DEFAULT; + engineConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G + engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPinMode = OM_DEFAULT; float mapRange = 110; @@ -60,7 +60,7 @@ void setVwAba(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFuelTablesLoadBin(20, mapRange PASS_CONFIG_PARAMETER_SUFFIX); setTimingLoadBin(20, mapRange PASS_CONFIG_PARAMETER_SUFFIX); - boardConfiguration->isSdCardEnabled = false; + engineConfiguration->isSdCardEnabled = false; engineConfiguration->tpsMin = 740; engineConfiguration->tpsMax = 135; } diff --git a/firmware/config/engines/vw.h b/firmware/config/engines/vw.h index c419b0ea95..d8528faf64 100644 --- a/firmware/config/engines/vw.h +++ b/firmware/config/engines/vw.h @@ -2,14 +2,11 @@ * @file vw.h * * @date May 24, 2015 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef CONFIG_ENGINES_VW_H_ -#define CONFIG_ENGINES_VW_H_ +#pragma once #include "engine_configuration.h" void setVwAba(DECLARE_CONFIG_PARAMETER_SIGNATURE); - -#endif /* CONFIG_ENGINES_VW_H_ */ diff --git a/firmware/config/engines/vw_b6.cpp b/firmware/config/engines/vw_b6.cpp new file mode 100644 index 0000000000..813a550586 --- /dev/null +++ b/firmware/config/engines/vw_b6.cpp @@ -0,0 +1,19 @@ +/* + * @file vw_b6.cpp + * + * @date Dec 26, 2019 + * @author Andrey Belomutskiy, (c) 2012-2019 + */ + +#include "engine.h" +#include "vw_b6.h" + +EXTERN_CONFIG; + +/** + * set engine_type 62 + */ + + + + diff --git a/firmware/config/engines/vw_b6.h b/firmware/config/engines/vw_b6.h new file mode 100644 index 0000000000..b679aa10a1 --- /dev/null +++ b/firmware/config/engines/vw_b6.h @@ -0,0 +1,10 @@ +/* + * @file vw_b6.h + * + * @date Dec 26, 2019 + * @author Andrey Belomutskiy, (c) 2012-2019 + */ + +#pragma once + +void setVwPassatB6(DECLARE_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/config/engines/zil130.cpp b/firmware/config/engines/zil130.cpp index 2cf22aafd9..dcd19bbad3 100644 --- a/firmware/config/engines/zil130.cpp +++ b/firmware/config/engines/zil130.cpp @@ -31,39 +31,39 @@ void setZil130(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - boardConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; // engineConfiguration->twoWireBatchInjection = true; - boardConfiguration->injectionPinMode = OM_INVERTED; - boardConfiguration->injectionPins[0] = GPIOB_8; // #1 - boardConfiguration->injectionPins[1] = GPIOE_2; // #2 - boardConfiguration->injectionPins[2] = GPIOE_3; // #3 - boardConfiguration->injectionPins[3] = GPIOE_4; // #4 - boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; // #5 - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; // #6 - boardConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPinMode = OM_INVERTED; + engineConfiguration->injectionPins[0] = GPIOB_8; // #1 + engineConfiguration->injectionPins[1] = GPIOE_2; // #2 + engineConfiguration->injectionPins[2] = GPIOE_3; // #3 + engineConfiguration->injectionPins[3] = GPIOE_4; // #4 + engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; // #5 + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; // #6 + engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - boardConfiguration->ignitionPins[0] = GPIOB_5; // #1 - boardConfiguration->ignitionPins[1] = GPIOB_6; // #2 - boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; // #3 - boardConfiguration->ignitionPins[3] = GPIOB_7; // #4 - boardConfiguration->ignitionPins[4] = GPIOC_7; // #5 + engineConfiguration->ignitionPins[0] = GPIOB_5; // #1 + engineConfiguration->ignitionPins[1] = GPIOB_6; // #2 + engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; // #3 + engineConfiguration->ignitionPins[3] = GPIOB_7; // #4 + engineConfiguration->ignitionPins[4] = GPIOC_7; // #5 // fuel pump - boardConfiguration->fuelPumpPin = GPIOD_4; + engineConfiguration->fuelPumpPin = GPIOD_4; // idle - boardConfiguration->idle.solenoidPin = GPIOC_14; - boardConfiguration->idle.solenoidPinMode = OM_INVERTED; - boardConfiguration->idle.solenoidFrequency = 300; - boardConfiguration->manIdlePosition = 50; // set_idle_pwm 50 + engineConfiguration->idle.solenoidPin = GPIOC_14; + engineConfiguration->idle.solenoidPinMode = OM_INVERTED; + engineConfiguration->idle.solenoidFrequency = 300; + engineConfiguration->manIdlePosition = 50; // set_idle_pwm 50 // disable sd_card - boardConfiguration->sdCardCsPin = GPIO_UNASSIGNED; - boardConfiguration->is_enabled_spi_2 = false; - boardConfiguration->is_enabled_spi_3 = false; - boardConfiguration->max31855spiDevice = SPI_NONE; + engineConfiguration->sdCardCsPin = GPIO_UNASSIGNED; + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->is_enabled_spi_3 = false; + engineConfiguration->max31855spiDevice = SPI_NONE; - boardConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = GPIO_UNASSIGNED; } diff --git a/firmware/config/stm32f4ems/chconf.h b/firmware/config/stm32f4ems/chconf.h index ac805a917b..c9a783c24a 100644 --- a/firmware/config/stm32f4ems/chconf.h +++ b/firmware/config/stm32f4ems/chconf.h @@ -41,12 +41,11 @@ * */ -#define PORT_IDLE_THREAD_STACK_SIZE 1024 +#define PORT_IDLE_THREAD_STACK_SIZE 32 -// rusEfi main processing happens on IRQ so PORT_INT_REQUIRED_STACK has to be pretty large. -// see also a strange comment about PORT_INT_REQUIRED_STACK in global_shared.h +// See global_shared.h notes about stack requirements // see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks -#define PORT_INT_REQUIRED_STACK 768 +#define PORT_INT_REQUIRED_STACK 128 #define CHPRINTF_USE_FLOAT TRUE @@ -605,7 +604,7 @@ * tickless mode. */ #if !defined(CH_DBG_THREADS_PROFILING) -#define CH_DBG_THREADS_PROFILING FALSE +#define CH_DBG_THREADS_PROFILING TRUE #endif /** @} */ diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index f232636b48..cf208105a9 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -293,7 +293,6 @@ // todo: switch to continues ADC conversion for slow ADC? // https://github.com/rusefi/rusefi/issues/630 -#define EFI_INTERNAL_SLOW_ADC_PWM &PWMD8 // todo: switch to continues ADC conversion for fast ADC? #define EFI_INTERNAL_FAST_ADC_PWM &PWMD4 diff --git a/firmware/config/stm32f4ems/halconf.h b/firmware/config/stm32f4ems/halconf.h index 3c1c20f274..3063fecfae 100644 --- a/firmware/config/stm32f4ems/halconf.h +++ b/firmware/config/stm32f4ems/halconf.h @@ -201,7 +201,7 @@ * @note Disabling this option saves both code and data space. */ #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define ADC_USE_MUTUAL_EXCLUSION TRUE +#define ADC_USE_MUTUAL_EXCLUSION FALSE #endif /*===========================================================================*/ diff --git a/firmware/config/stm32f4ems/mcuconf.h b/firmware/config/stm32f4ems/mcuconf.h index 9485c69336..bc971dc229 100644 --- a/firmware/config/stm32f4ems/mcuconf.h +++ b/firmware/config/stm32f4ems/mcuconf.h @@ -244,7 +244,7 @@ #define STM32_ICU_USE_TIM3 TRUE #define STM32_ICU_USE_TIM4 FALSE #define STM32_ICU_USE_TIM5 FALSE -#define STM32_ICU_USE_TIM8 FALSE +#define STM32_ICU_USE_TIM8 TRUE #define STM32_ICU_USE_TIM9 TRUE #define STM32_ICU_TIM1_IRQ_PRIORITY ICU_PRIORITY #define STM32_ICU_TIM2_IRQ_PRIORITY ICU_PRIORITY @@ -277,7 +277,7 @@ #define STM32_PWM_USE_TIM4 TRUE #define STM32_PWM_USE_TIM5 FALSE // todo: https://github.com/rusefi/rusefi/issues/630 ? -#define STM32_PWM_USE_TIM8 TRUE +#define STM32_PWM_USE_TIM8 FALSE #define STM32_PWM_USE_TIM9 FALSE #define STM32_PWM_TIM1_IRQ_PRIORITY 7 #define STM32_PWM_TIM2_IRQ_PRIORITY 7 diff --git a/firmware/config/stm32f7ems/chconf.h b/firmware/config/stm32f7ems/chconf.h index 6adecfefcb..35a4721ef1 100644 --- a/firmware/config/stm32f7ems/chconf.h +++ b/firmware/config/stm32f7ems/chconf.h @@ -41,12 +41,11 @@ * */ -#define PORT_IDLE_THREAD_STACK_SIZE 1024 +#define PORT_IDLE_THREAD_STACK_SIZE 32 -// rusEfi main processing happens on IRQ so PORT_INT_REQUIRED_STACK has to be pretty large. -// see also a strange comment about PORT_INT_REQUIRED_STACK in global_shared.h +// See global_shared.h notes about stack requirements // see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks -#define PORT_INT_REQUIRED_STACK 768 +#define PORT_INT_REQUIRED_STACK 128 #define CHPRINTF_USE_FLOAT TRUE diff --git a/firmware/config/stm32f7ems/mcuconf.h b/firmware/config/stm32f7ems/mcuconf.h index 4059ae77d7..6fcb25519f 100644 --- a/firmware/config/stm32f7ems/mcuconf.h +++ b/firmware/config/stm32f7ems/mcuconf.h @@ -255,7 +255,7 @@ #define STM32_ICU_USE_TIM3 TRUE #define STM32_ICU_USE_TIM4 FALSE #define STM32_ICU_USE_TIM5 FALSE -#define STM32_ICU_USE_TIM8 FALSE +#define STM32_ICU_USE_TIM8 TRUE #define STM32_ICU_USE_TIM9 TRUE #define STM32_ICU_TIM1_IRQ_PRIORITY ICU_PRIORITY #define STM32_ICU_TIM2_IRQ_PRIORITY ICU_PRIORITY @@ -285,7 +285,7 @@ #define STM32_PWM_USE_TIM3 FALSE #define STM32_PWM_USE_TIM4 TRUE #define STM32_PWM_USE_TIM5 FALSE -#define STM32_PWM_USE_TIM8 TRUE +#define STM32_PWM_USE_TIM8 FALSE #define STM32_PWM_USE_TIM9 FALSE #define STM32_PWM_TIM1_IRQ_PRIORITY 7 #define STM32_PWM_TIM2_IRQ_PRIORITY 7 diff --git a/firmware/console/binary/bluetooth.cpp b/firmware/console/binary/bluetooth.cpp index 1260ef921c..5667721f7e 100644 --- a/firmware/console/binary/bluetooth.cpp +++ b/firmware/console/binary/bluetooth.cpp @@ -49,7 +49,7 @@ static void runCommands() { chThdSleepMilliseconds(1000); // safety // Store current serial port speed - we're going to change it - int savedSerialSpeed = CONFIGB(tunerStudioSerialSpeed); + int savedSerialSpeed = CONFIG(tunerStudioSerialSpeed); int prevBaudIdx = -1, baudIdx = -1, baudListIdx = 0; int cmdIdx = 0; @@ -75,7 +75,7 @@ static void runCommands() { } chThdSleepMilliseconds(10); // safety // change the port speed - CONFIGB(tunerStudioSerialSpeed) = restoreAndExit ? savedSerialSpeed : baudRates[baudIdx]; + CONFIG(tunerStudioSerialSpeed) = restoreAndExit ? savedSerialSpeed : baudRates[baudIdx]; // init UART startTsPort(tsChannel); chThdSleepMilliseconds(10); // safety @@ -160,7 +160,7 @@ void bluetoothStart(ts_channel_s *tsChan, bluetooth_module_e moduleType, const c tsChannel = tsChan; // if a binary protocol uses USB, we cannot init the bluetooth module! - if (!CONFIGB(useSerialPort)) { + if (!CONFIG(useSerialPort)) { scheduleMsg(&btLogger, "Failed! Serial Port connection is disabled!"); return; } diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 8dc37b6138..d070e9d54f 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -152,7 +152,7 @@ void printTsStats(void) { scheduleMsg(&tsLogger, "TS RX on %s", hwPortname(engineConfiguration->binarySerialRxPin)); scheduleMsg(&tsLogger, "TS TX on %s @%d", hwPortname(engineConfiguration->binarySerialTxPin), - CONFIGB(tunerStudioSerialSpeed)); + CONFIG(tunerStudioSerialSpeed)); } #endif /* EFI_PROD_CODE */ @@ -164,7 +164,7 @@ void printTsStats(void) { // int fuelMapOffset = (int) (&engineConfiguration->fuelTable) - (int) engineConfiguration; // scheduleMsg(logger, "fuelTable %d", fuelMapOffset); // -// int offset = (int) (&CONFIGB(hip9011Gain)) - (int) engineConfiguration; +// int offset = (int) (&CONFIG(hip9011Gain)) - (int) engineConfiguration; // scheduleMsg(&tsLogger, "hip9011Gain %d", offset); // // offset = (int) (&engineConfiguration->crankingCycleBins) - (int) engineConfiguration; @@ -175,7 +175,7 @@ void printTsStats(void) { } static void setTsSpeed(int value) { - CONFIGB(tunerStudioSerialSpeed) = value; + CONFIG(tunerStudioSerialSpeed) = value; printTsStats(); } @@ -257,8 +257,6 @@ static void onlineApplyWorkingCopyBytes(int currentPageId, uint32_t offset, int } } -extern EtbController etbController[ETB_COUNT]; - static const void * getStructAddr(int structId) { switch (structId) { case LDS_CLT_STATE_INDEX: @@ -275,7 +273,7 @@ static const void * getStructAddr(int structId) { return static_cast(&engine->triggerCentral.triggerState); #if EFI_ELECTRONIC_THROTTLE_BODY case LDS_ETB_PID_STATE_INDEX: - return static_cast(&etbController[0].etbPid); + return static_cast(engine->etbControllers[0])->getPidState(); #endif /* EFI_ELECTRONIC_THROTTLE_BODY */ #ifndef EFI_IDLE_CONTROL diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index e97dce30ab..5507e0d45f 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -12,6 +12,49 @@ #define TUNERSTUDIO_CONFIGURATION_H_ #include "rusefi_types.h" +#include "rusefi_generated.h" + +#include "tunerstudio_debug_struct.h" + +// This class lets us transparently store something at a ratio inside an integer type +// Just use it like a float - you can read and write to it, like this: +// scaled_channel myVar; +// myVar = 2.4f; // converts to an int, stores 24 +// float x = myVar; // converts back to float, returns 2.4f +template +class scaled_channel { +public: + scaled_channel() : m_value(static_cast(0)) { } + scaled_channel(float val) + : m_value(val * mult) + { + } + + // Allow reading back out as a float (note: this may be lossy!) + operator float() const { + return m_value / (float)mult; + } + +private: + T m_value; +}; + +// We need to guarantee that scaled values containing some type are the same size +// as that underlying type. We rely on the class only having a single member for +// this trick to work. +static_assert(sizeof(scaled_channel) == 1); +static_assert(sizeof(scaled_channel) == 2); +static_assert(sizeof(scaled_channel) == 4); +static_assert(sizeof(scaled_channel) == 4); + +// Common scaling options - use these if you can! +using scaled_temperature = scaled_channel; // +-327 deg C at 0.01 deg resolution +using scaled_ms = scaled_channel; // +- 100ms at 0.003ms precision +using scaled_percent = scaled_channel; // +-327% at 0.01% resolution +using scaled_pressure = scaled_channel; // 0-2000kPa (~300psi) at 0.03kPa resolution +using scaled_angle = scaled_channel; // +-655 degrees at 0.02 degree resolution +using scaled_voltage = scaled_channel; // 0-65v at 1mV resolution +using scaled_afr = scaled_channel; // 0-65afr at 0.001 resolution #define PAGE_COUNT 1 @@ -20,40 +63,16 @@ typedef struct { } egt_values_s; /** + * At the moment rusEfi does NOT have any code generation around TS output channels, three locations have to be changed manually + * 1) this TunerStudioOutputChannels firmware version of the structure + * 2) '[OutputChannels]' block in rusefi.input + * 3) com.rusefi.core.Sensor enum in rusEfi console source code + * * please be aware that 'float' (F32) type requires TunerStudio version 2.6 and later */ typedef struct { /* see also [OutputChannels] in rusefi.input */ - // primary instrument cluster gauges - int rpm; // size 4, offset 0 - /** - * This value is in Celcius - UI would convert into F if needed - */ - float coolantTemperature; // size 4, offset 4 - float intakeAirTemperature; // size 4, offset 8 - float throttlePositon; // size 4, offset 12 - float massAirFlowVoltage; // size 4, offset 16 - float airFuelRatio; // size 4, offset 20 - float engineLoad; // size 4, offset 24 - float vBatt; // size 4, offset 28 - short int tpsADC; // size 2, offset 32 - short int alignment; // size 2, offset 34 - float baroPressure; // size 4, offset 36 - float manifoldAirPressure; // size 4, offset 40 - float crankingFuelMs; // offset 44 - /** - * This is the raw value we take from the fuel map or base fuel algorithm, before the corrections - */ - float fuelBase; // 48 - float tCharge; // 52 - float ignitionAdvance; // 56 - float sparkDwell; // 60 - /** - * this one contains total resulting fuel squirt time, per event - * With all corrections and injector lag. See also baseFuel - */ - float actualLastInjection; // 64 - float debugFloatField1; // 68 + /** * Yes, I do not really enjoy packing bits into integers but we simply have too many boolean flags and I cannot * water 4 bytes per traffic - I want gauges to work as fast as possible @@ -76,107 +95,139 @@ typedef struct { unsigned int brakePedalState : 1; // bit 15. 0 - not pressed, 1 = pressed unsigned int toothLogReady : 1; // bit 16 unsigned int acSwitchState : 1; // bit 17. 0 - not pressed, 1 = pressed - float vehicleSpeedKph; // 76 - unsigned int isTpsError : 1; // bit 0, 80 - unsigned int isCltError : 1; // bit 1 - unsigned int isMapError : 1; // bit 2 - unsigned int isIatError : 1; // bit 3 - unsigned int isAcSwitchEngaged : 1; // bit 4 - unsigned int isTriggerError : 1; // bit 5 - unsigned int hasFatalError : 1; // bit 6 - unsigned int isWarnNow : 1; // bit 7 - unsigned int unused80b8 : 1; // bit 8 - unsigned int isKnockChipOk : 1; // bit 9 - int tsConfigVersion; // 84 - egt_values_s egtValues; // 88 - float rpmAcceleration; // 104 - float massAirFlow; // 108 - /** - * Current volumetric efficiency - */ - float veValue; // offset 112 - /** - * TPS value delta within specified number of cycles - * See tpsAccelFuel - */ - float deltaTps; // offset 116 - int triggerErrorsCounter; // offset 120 - /** - * Engine load delta - */ - float engineLoadAccelExtra; // offset 124 - float tpsAccelFuel; // offset 128 - float baroCorrection; // 132 - float pedalPosition; // 136 - /** - * @see coilDutyCycle - */ - float injectorDutyCycle; // 140 - int knockCount; // 144 - float fuelTankLevel; // 148 - float knockLevel; // 152 - int totalTriggerErrorCounter; // 156 - float wallFuelAmount; // 160 - /** - * multiplier, 1 means no correction, 1.20 means 20% extra - */ - float iatCorrection; // 164 - floatms_t wallFuelCorrection; // 168 - float idlePosition; // 172 - float currentTargetAfr; // 176 - float chargeAirMass; // 180 - /** - * multiplier, 1 means no correction, 1.20 means 20% extra - */ - float cltCorrection; // 184 - /** - * Total fuel with CLT, IAT and TPS acceleration without injector lag corrections per cycle, - * as squirt duration. - * - * @see actualLastInjection - */ - float fuelRunning; // 188 - int debugIntField1; // 192 - float injectorLagMs; // 196 - float debugFloatField2; // 200 - float debugFloatField3; // 204 - float debugFloatField4; // 208 - float debugFloatField5; // 212 - int debugIntField2; // 216 - int debugIntField3; // 220 - int timeSeconds; // 224 - float engineLoadDelta; // 228 - float speedToRpmRatio; // 232 - int16_t warningCounter; // 236 - int16_t unused_238; - int16_t lastErrorCode; // 240 - int16_t unused_242; - /** - * Microcontroller own internal temperature, C - */ - float internalMcuTemperature; // 244 - float vvtPosition; // 248 - int engineMode; // 252 - float debugFloatField6; // 256 - float debugFloatField7; // 260 - int firmwareVersion; // 264 - float fuelPidCorrection; // 268 - /** - * @see injectorDutyCycle - */ - float coilDutyCycle; // 272 - int16_t accelerationX; // 276 - int16_t accelerationY; // 278 - float oilPressure; // 280 - float fuelConsumptionPerHour; // 284 - float injectionOffset; // 288 - int16_t debugIntField4; // 292 - int16_t debugIntField5; // 294 - int16_t recentErrorCodes[8]; // 298 - float etbTarget; // 312 - float etb1DutyCycle; // 316 - float etb1Error; // 320 - int unused3[8]; + unsigned int isTpsError : 1; // bit 18 + unsigned int isCltError : 1; // bit 19 + unsigned int isMapError : 1; // bit 20 + unsigned int isIatError : 1; // bit 21 + unsigned int isAcSwitchEngaged : 1; // bit 22 + unsigned int isTriggerError : 1; // bit 23 + unsigned int hasFatalError : 1; // bit 24 + unsigned int isWarnNow : 1; // bit 25 + unsigned int unused80b8 : 1; // bit 26 + unsigned int isKnockChipOk : 1; // bit 27 + + // RPM, vss + scaled_channel rpm; // 4 + scaled_percent rpmAcceleration; // 6 + scaled_percent speedToRpmRatio; // 8 + scaled_channel vehicleSpeedKph; // 10 + + // temperatures + scaled_channel internalMcuTemperature; // offset 11 + scaled_temperature coolantTemperature; // offset 12 + scaled_temperature intakeAirTemperature; // offset 14 + scaled_temperature auxTemp1; // offset 16 + scaled_temperature auxTemp2; // offset 18 + + // throttle, pedal + scaled_percent throttlePosition; // 20 + scaled_percent pedalPosition; // 22 + uint16_t tpsADC; // 24 + + // air flow/mass measurment + scaled_voltage massAirFlowVoltage; // 26 + scaled_channel massAirFlow; // 28 + scaled_pressure manifoldAirPressure; // 30 + scaled_pressure baroPressure; // 32 + + scaled_afr airFuelRatio; // 34 + scaled_channel engineLoad; // 36 + + // misc sensors + scaled_voltage vBatt; // 38 + scaled_pressure oilPressure; // 40 + scaled_angle vvtPosition; // 42 + + // Fuel math + scaled_channel chargeAirMass; // 44 + scaled_ms crankingFuelMs; // 46 + scaled_afr currentTargetAfr; // 48 + // This is the raw value we take from the fuel map or base fuel algorithm, before the corrections + scaled_ms fuelBase; // 50 + // Total fuel with CLT, IAT and TPS acceleration without injector lag corrections per cycle, as pulse per cycle + scaled_ms fuelRunning; // 52 + // Actual last injection time - including all compensation and injection mode + scaled_ms actualLastInjection; // 54 + scaled_channel injectorDutyCycle; // 56 + scaled_channel veValue; // 57 + scaled_angle injectionOffset; // 58 + scaled_temperature tCharge; // 60 + + // Corrections + scaled_ms injectorLagMs; // 62 + scaled_percent iatCorrection; // 64 + scaled_percent cltCorrection; // 66 + scaled_percent baroCorrection; // 68 + scaled_ms fuelPidCorrection; // 70 + + // Wall model AE + scaled_ms wallFuelAmount; // 72 + scaled_channel wallFuelCorrection; // 74 + + // TPS/load AE + scaled_percent engineLoadDelta; // 76 + scaled_percent deltaTps; // 78 + scaled_percent engineLoadAccelExtra; // 80 + scaled_ms tpsAccelFuel; // 82 + + // Ignition + scaled_angle ignitionAdvance; // 84 + scaled_ms sparkDwell; // 86 + scaled_percent coilDutyCycle; // 88 + + // Idle & ETB + scaled_percent idlePosition; // 90 + scaled_percent etbTarget; // 92 + scaled_percent etb1DutyCycle; // 94 + scaled_percent etb1Error; // 96 + + // Fuel system + scaled_percent fuelTankLevel; // 98 + float fuelConsumptionPerHour; // 100 + + // Knock + uint32_t knockCount; // 104 + float knockLevel; // 108 + + // Mode, firmware, protocol, run time + uint32_t timeSeconds; // 112 + uint32_t engineMode; // 116 + uint32_t firmwareVersion; // 120 + uint32_t tsConfigVersion; // 124 + + // Errors + int totalTriggerErrorCounter; // 128 + int orderingErrorCounter; // 132 + int16_t warningCounter; // 136 + int16_t lastErrorCode; // 138 + int16_t recentErrorCodes[8]; // 140 + + // Debug + float debugFloatField1; // 156 + float debugFloatField2; + float debugFloatField3; + float debugFloatField4; + float debugFloatField5; + float debugFloatField6; + float debugFloatField7; + int debugIntField1; + int debugIntField2; + int debugIntField3; + int16_t debugIntField4; + int16_t debugIntField5; // 198 + + // accelerometer + int16_t accelerationX; // 200 + int16_t accelerationY; // 202 + + // EGT + egt_values_s egtValues; // 204 + + // Temporary - will remove soon + TsDebugChannels* getDebugChannels() { + return reinterpret_cast(&debugFloatField1); + } + /* see also [OutputChannels] in rusefi.input */ } TunerStudioOutputChannels; diff --git a/firmware/console/binary/tunerstudio_debug_struct.h b/firmware/console/binary/tunerstudio_debug_struct.h new file mode 100644 index 0000000000..993ad2acb0 --- /dev/null +++ b/firmware/console/binary/tunerstudio_debug_struct.h @@ -0,0 +1,16 @@ +#pragma once + +typedef struct { + float debugFloatField1; // 180 + float debugFloatField2; + float debugFloatField3; + float debugFloatField4; + float debugFloatField5; + float debugFloatField6; + float debugFloatField7; + int debugIntField1; + int debugIntField2; + int debugIntField3; + int16_t debugIntField4; + int16_t debugIntField5; +} TsDebugChannels; diff --git a/firmware/console/binary/tunerstudio_io.cpp b/firmware/console/binary/tunerstudio_io.cpp index 9a6111ea5a..170c692529 100644 --- a/firmware/console/binary/tunerstudio_io.cpp +++ b/firmware/console/binary/tunerstudio_io.cpp @@ -99,7 +99,7 @@ void startTsPort(ts_channel_s *tsChannel) { return; #endif /* CONSOLE_USB_DEVICE */ #if defined(TS_UART_DEVICE) || defined(TS_SERIAL_DEVICE) - if (CONFIGB(useSerialPort)) { + if (CONFIG(useSerialPort)) { print("TunerStudio over USART"); /** @@ -115,7 +115,7 @@ void startTsPort(ts_channel_s *tsChannel) { iqObjectInit(&tsUartDma.fifoRxQueue, tsUartDma.buffer, sizeof(tsUartDma.buffer), NULL, NULL); // start DMA driver - tsDmaUartConfig.speed = CONFIGB(tunerStudioSerialSpeed); + tsDmaUartConfig.speed = CONFIG(tunerStudioSerialSpeed); uartStart(TS_UART_DEVICE, &tsDmaUartConfig); // start continuous DMA transfer using our circular buffer @@ -124,11 +124,11 @@ void startTsPort(ts_channel_s *tsChannel) { #elif TS_UART_MODE print("Using UART mode"); // start DMA driver - tsUartConfig.speed = CONFIGB(tunerStudioSerialSpeed); + tsUartConfig.speed = CONFIG(tunerStudioSerialSpeed); uartStart(TS_UART_DEVICE, &tsUartConfig); #elif defined(TS_SERIAL_DEVICE) print("Using Serial mode"); - tsSerialConfig.speed = CONFIGB(tunerStudioSerialSpeed); + tsSerialConfig.speed = CONFIG(tunerStudioSerialSpeed); sdStart(TS_SERIAL_DEVICE, &tsSerialConfig); @@ -148,7 +148,7 @@ bool stopTsPort(ts_channel_s *tsChannel) { //usb_serial_stop(); return false; #endif - if (CONFIGB(useSerialPort)) { + if (CONFIG(useSerialPort)) { // todo: disable Rx/Tx pads? #if (TS_UART_DMA_MODE || TS_UART_MODE) uartStop(TS_UART_DEVICE); diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 9f0b9ee948..b6ca2016bd 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -100,15 +100,12 @@ extern int icuWidthPeriodCounter; extern WaveChart waveChart; #endif /* EFI_ENGINE_SNIFFER */ -// this 'true' value is needed for simulator -static volatile bool fullLog = true; int warningEnabled = true; -//int warningEnabled = FALSE; extern bool hasFirmwareErrorFlag; extern int maxTriggerReentraint; extern uint32_t maxLockedDuration; -#define FULL_LOGGING_KEY "fl" + #if !defined(STATUS_LOGGING_BUFFER_SIZE) #define STATUS_LOGGING_BUFFER_SIZE 1800 @@ -406,9 +403,6 @@ void writeLogLine(void) { #endif /* EFI_FILE_LOGGING */ } -#define INITIAL_FULL_LOG TRUE -//#define INITIAL_FULL_LOG FALSE - volatile int needToReportStatus = FALSE; static int prevCkpEventCounter = -1; @@ -452,21 +446,21 @@ void printOverallStatus(systime_t nowSeconds) { int seconds = getTimeNowSeconds(); printCurrentState(&logger, seconds, getConfigurationName(engineConfiguration->engineType), FIRMWARE_ID); #if EFI_PROD_CODE - printOutPin(PROTOCOL_CRANK1, CONFIGB(triggerInputPins)[0]); - printOutPin(PROTOCOL_CRANK2, CONFIGB(triggerInputPins)[1]); + printOutPin(PROTOCOL_CRANK1, CONFIG(triggerInputPins)[0]); + printOutPin(PROTOCOL_CRANK2, CONFIG(triggerInputPins)[1]); printOutPin(PROTOCOL_VVT_NAME, engineConfiguration->camInputs[0]); - printOutPin(PROTOCOL_HIP_NAME, CONFIGB(hip9011IntHoldPin)); - printOutPin(PROTOCOL_TACH_NAME, CONFIGB(tachOutputPin)); + printOutPin(PROTOCOL_HIP_NAME, CONFIG(hip9011IntHoldPin)); + printOutPin(PROTOCOL_TACH_NAME, CONFIG(tachOutputPin)); printOutPin(PROTOCOL_DIZZY_NAME, engineConfiguration->dizzySparkOutputPin); #if EFI_LOGIC_ANALYZER - printOutPin(PROTOCOL_WA_CHANNEL_1, CONFIGB(logicAnalyzerPins)[0]); - printOutPin(PROTOCOL_WA_CHANNEL_2, CONFIGB(logicAnalyzerPins)[1]); + printOutPin(PROTOCOL_WA_CHANNEL_1, CONFIG(logicAnalyzerPins)[0]); + printOutPin(PROTOCOL_WA_CHANNEL_2, CONFIG(logicAnalyzerPins)[1]); #endif /* EFI_LOGIC_ANALYZER */ for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { - printOutPin(enginePins.coils[i].getShortName(), CONFIGB(ignitionPins)[i]); + printOutPin(enginePins.coils[i].getShortName(), CONFIG(ignitionPins)[i]); - printOutPin(enginePins.injectors[i].getShortName(), CONFIGB(injectionPins)[i]); + printOutPin(enginePins.injectors[i].getShortName(), CONFIG(injectionPins)[i]); } for (int i = 0; i < AUX_DIGITAL_VALVE_COUNT;i++) { printOutPin(enginePins.auxValve[i].getShortName(), engineConfiguration->auxValves[i]); @@ -586,14 +580,14 @@ static OutputPin *leds[] = { &enginePins.warningLedPin, &enginePins.runningLedPi static void initStatusLeds(void) { enginePins.communicationLedPin.initPin("led: comm status", engineConfiguration->communicationLedPin); // we initialize this here so that we can blink it on start-up - enginePins.checkEnginePin.initPin("MalfunctionIndicator", CONFIGB(malfunctionIndicatorPin), &CONFIGB(malfunctionIndicatorPinMode)); + enginePins.checkEnginePin.initPin("MalfunctionIndicator", CONFIG(malfunctionIndicatorPin), &CONFIG(malfunctionIndicatorPinMode)); enginePins.warningLedPin.initPin("led: warning status", engineConfiguration->warningLedPin); enginePins.runningLedPin.initPin("led: running status", engineConfiguration->runningLedPin); - enginePins.debugTriggerSync.initPin("debug: sync", CONFIGB(debugTriggerSync)); - enginePins.debugTimerCallback.initPin("debug: timer callback", CONFIGB(debugTimerCallback)); - enginePins.debugSetTimer.initPin("debug: set timer", CONFIGB(debugSetTimer)); + enginePins.debugTriggerSync.initPin("debug: sync", CONFIG(debugTriggerSync)); + enginePins.debugTimerCallback.initPin("debug: timer callback", CONFIG(debugTimerCallback)); + enginePins.debugSetTimer.initPin("debug: set timer", CONFIG(debugSetTimer)); } #define BLINKING_PERIOD_MS 33 @@ -602,7 +596,7 @@ static void initStatusLeds(void) { static bool isTriggerErrorNow() { #if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT - bool justHadError = (getTimeNowNt() - engine->triggerCentral.triggerState.lastDecodingErrorTime) < US2NT(MS2US(200)); + bool justHadError = (getTimeNowNt() - engine->triggerCentral.triggerState.lastDecodingErrorTime) < MS2NT(200); return justHadError || isTriggerDecoderError(); #else return false; @@ -676,12 +670,12 @@ static CommunicationBlinkingTask communicationsBlinkingTask; #if EFI_LCD class LcdController : public PeriodicController { public: - LcdController() : PeriodicController("BenchThread") { } + LcdController() : PeriodicController("LCD") { } private: - void PeriodicTask(efitime_t nowNt) override { + void PeriodicTask(efitick_t nowNt) override { UNUSED(nowNt); - setPeriod(NOT_TOO_OFTEN(10 /* ms */, engineConfiguration->bc.lcdThreadPeriodMs)); - if (engineConfiguration->bc.useLcdScreen) { + setPeriod(NOT_TOO_OFTEN(10 /* ms */, engineConfiguration->lcdThreadPeriodMs)); + if (engineConfiguration->useLcdScreen) { #if EFI_HD44780_LCD updateHD44780lcd(); #endif @@ -726,7 +720,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ // offset 8 tsOutputChannels->intakeAirTemperature = intake; // offset 12 - tsOutputChannels->throttlePositon = tps; + tsOutputChannels->throttlePosition = tps; // offset 16 tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE) : 0; @@ -756,13 +750,15 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->rpmAcceleration = engine->rpmCalculator.getRpmAcceleration(); // offset 108 // For air-interpolated tCharge mode, we calculate a decent massAirFlow approximation, so we can show it to users even without MAF sensor! - tsOutputChannels->massAirFlow = getAirFlowGauge(PASS_ENGINE_PARAMETER_SIGNATURE); + tsOutputChannels->massAirFlow = getAirFlowGauge(PASS_ENGINE_PARAMETER_SIGNATURE); // offset 116 // TPS acceleration tsOutputChannels->deltaTps = engine->tpsAccelEnrichment.getMaxDelta(); - // 120 - tsOutputChannels->triggerErrorsCounter = engine->triggerCentral.triggerState.totalTriggerErrorCounter; + // 128 + tsOutputChannels->totalTriggerErrorCounter = engine->triggerCentral.triggerState.totalTriggerErrorCounter; // 132 + tsOutputChannels->orderingErrorCounter = engine->triggerCentral.triggerState.orderingErrorCounter; + // 68 tsOutputChannels->baroCorrection = engine->engineState.baroCorrection; // 136 tsOutputChannels->pedalPosition = hasPedalPositionSensor(PASS_ENGINE_PARAMETER_SIGNATURE) ? getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE) : 0; @@ -789,16 +785,18 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->vvtPosition = engine->triggerCentral.vvtPosition; // 252 tsOutputChannels->engineMode = packEngineMode(PASS_ENGINE_PARAMETER_SIGNATURE); - // 264 + // 120 tsOutputChannels->firmwareVersion = getRusEfiVersion(); // 268 tsOutputChannels->fuelPidCorrection = ENGINE(engineState.running.pidCorrection); - // 276 - tsOutputChannels->accelerationX = engine->sensors.accelerometer.x; - // 278 - tsOutputChannels->accelerationY = engine->sensors.accelerometer.y; - // 288 - tsOutputChannels->injectionOffset = engine->engineState.injectionOffset; + // 276 + tsOutputChannels->accelerationX = engine->sensors.accelerometer.x; + // 278 + tsOutputChannels->accelerationY = engine->sensors.accelerometer.y; + // 280 + tsOutputChannels->oilPressure = Sensor::get(SensorType::OilPressure).Value; + // 288 + tsOutputChannels->injectionOffset = engine->engineState.injectionOffset; if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { float mapValue = getMap(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -814,7 +812,6 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->knockLevel = engine->knockVolts; tsOutputChannels->hasFatalError = hasFirmwareError(); - tsOutputChannels->totalTriggerErrorCounter = engine->triggerCentral.triggerState.totalTriggerErrorCounter; tsOutputChannels->coilDutyCycle = getCoilDutyCycle(rpm PASS_ENGINE_PARAMETER_SUFFIX); @@ -1019,7 +1016,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ break; case DBG_TLE8888: #if (BOARD_TLE8888_COUNT > 0) - tle8888PostState(tsOutputChannels); + tle8888PostState(tsOutputChannels->getDebugChannels()); #endif /* BOARD_TLE8888_COUNT */ break; default: @@ -1035,8 +1032,6 @@ void prepareTunerStudioOutputs(void) { #endif /* EFI_TUNER_STUDIO */ void initStatusLoop(void) { - setFullLog(INITIAL_FULL_LOG); - addConsoleActionI(FULL_LOGGING_KEY, setFullLog); addConsoleActionI("warn", setWarningEnabled); #if EFI_ENGINE_CONTROL @@ -1061,13 +1056,3 @@ void startStatusThreads(void) { lcdInstance.Start(); #endif /* EFI_LCD */ } - -void setFullLog(int value) { - print("Setting full logging: %s\r\n", boolToString(value)); - printMsg(&logger, "%s%d", FULL_LOGGING_KEY, value); - fullLog = value; -} - -bool getFullLog(void) { - return fullLog; -} diff --git a/firmware/console/status_loop.h b/firmware/console/status_loop.h index a4e85cf8e9..54dac6d5b7 100644 --- a/firmware/console/status_loop.h +++ b/firmware/console/status_loop.h @@ -2,11 +2,10 @@ * @file status_loop.h * * @date Mar 15, 2013 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef CONSOLE_LOOP_H_ -#define CONSOLE_LOOP_H_ +#pragma once #include "engine.h" @@ -15,7 +14,4 @@ void prepareTunerStudioOutputs(void); void startStatusThreads(void); void initStatusLoop(void); void writeLogLine(void); -void setFullLog(int value); void printOverallStatus(systime_t nowSeconds); - -#endif /* CONSOLE_LOOP_H_ */ diff --git a/firmware/controllers/actuators/alternator_controller.cpp b/firmware/controllers/actuators/alternator_controller.cpp index 44ac40ff64..0b4fa3ab48 100644 --- a/firmware/controllers/actuators/alternator_controller.cpp +++ b/firmware/controllers/actuators/alternator_controller.cpp @@ -86,7 +86,7 @@ class AlternatorController : public PeriodicTimerController { float vBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE); float targetVoltage = engineConfiguration->targetVBatt; - if (CONFIGB(onOffAlternatorLogic)) { + if (CONFIG(onOffAlternatorLogic)) { float h = 0.1; bool newState = (vBatt < targetVoltage - h) || (currentPlainOnOffState && vBatt < targetVoltage); enginePins.alternatorPin.setValue(newState); @@ -102,7 +102,7 @@ class AlternatorController : public PeriodicTimerController { currentAltDuty = alternatorPid.getOutput(targetVoltage, vBatt); - if (CONFIGB(isVerboseAlternator)) { + if (CONFIG(isVerboseAlternator)) { scheduleMsg(logger, "alt duty: %.2f/vbatt=%.2f/p=%.2f/i=%.2f/d=%.2f int=%.2f", currentAltDuty, vBatt, alternatorPid.getP(), alternatorPid.getI(), alternatorPid.getD(), alternatorPid.getIntegration()); } @@ -116,7 +116,7 @@ static AlternatorController instance; void showAltInfo(void) { scheduleMsg(logger, "alt=%s @%s t=%dms", boolToString(engineConfiguration->isAlternatorControlEnabled), - hwPortname(CONFIGB(alternatorControlPin)), + hwPortname(CONFIG(alternatorControlPin)), engineConfiguration->alternatorControl.periodMs); scheduleMsg(logger, "p=%.2f/i=%.2f/d=%.2f offset=%.2f", engineConfiguration->alternatorControl.pFactor, 0, 0, engineConfiguration->alternatorControl.offset); // todo: i & d @@ -160,17 +160,17 @@ void onConfigurationChangeAlternatorCallback(engine_configuration_s *previousCon void initAlternatorCtrl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { logger = sharedLogger; addConsoleAction("altinfo", showAltInfo); - if (CONFIGB(alternatorControlPin) == GPIO_UNASSIGNED) + if (CONFIG(alternatorControlPin) == GPIO_UNASSIGNED) return; - if (CONFIGB(onOffAlternatorLogic)) { - enginePins.alternatorPin.initPin("on/off alternator", CONFIGB(alternatorControlPin)); + if (CONFIG(onOffAlternatorLogic)) { + enginePins.alternatorPin.initPin("on/off alternator", CONFIG(alternatorControlPin)); } else { startSimplePwmExt(&alternatorControl, "Alternator control", &engine->executor, - CONFIGB(alternatorControlPin), + CONFIG(alternatorControlPin), &enginePins.alternatorPin, engineConfiguration->alternatorPwmFrequency, 0.1, (pwm_gen_callback*)applyAlternatorPinState); } diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 51dacd6f75..9458d266df 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -180,9 +180,24 @@ static percent_t currentEtbDuty; // this macro clamps both positive and negative percentages from about -100% to 100% #define ETB_PERCENT_TO_DUTY(X) (maxF(minF((X * 0.01), ETB_DUTY_LIMIT - 0.01), 0.01 - ETB_DUTY_LIMIT)) -void EtbController::init(DcMotor *motor, int ownIndex) { - this->m_motor = motor; - this->ownIndex = ownIndex; +void EtbController::init(DcMotor *motor, int ownIndex, pid_s *pidParameters) { + m_motor = motor; + m_myIndex = ownIndex; + m_pid.initPidClass(pidParameters); +} + +void EtbController::reset() { + m_shouldResetPid = true; +} + +void EtbController::onConfigurationChange(pid_s* previousConfiguration) { + if (m_pid.isSame(previousConfiguration)) { + m_shouldResetPid = true; + } +} + +void EtbController::showStatus(Logging* logger) { + m_pid.showPidStatus(logger, "ETB"); } int EtbController::getPeriodMs() { @@ -190,18 +205,19 @@ int EtbController::getPeriodMs() { } void EtbController::PeriodicTask() { - // set debug_mode 17 - if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) { #if EFI_TUNER_STUDIO - etbPid.postState(&tsOutputChannels); - tsOutputChannels.debugIntField5 = engine->engineState.etbFeedForward; -#endif /* EFI_TUNER_STUDIO */ - } else if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_EXTRA) { -#if EFI_TUNER_STUDIO - // set debug_mode 29 - tsOutputChannels.debugFloatField1 = directPwmValue; -#endif /* EFI_TUNER_STUDIO */ + // Only debug throttle #0 + if (m_myIndex == 0) { + // set debug_mode 17 + if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) { + m_pid.postState(&tsOutputChannels); + tsOutputChannels.debugIntField5 = engine->engineState.etbFeedForward; + } else if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_EXTRA) { + // set debug_mode 29 + tsOutputChannels.debugFloatField1 = directPwmValue; + } } +#endif /* EFI_TUNER_STUDIO */ if (!m_motor) { return; @@ -212,9 +228,9 @@ void EtbController::PeriodicTask() { return; } - if (shouldResetPid) { - etbPid.reset(); - shouldResetPid = false; + if (m_shouldResetPid) { + m_pid.reset(); + m_shouldResetPid = false; } if (!cisnan(directPwmValue)) { @@ -222,12 +238,12 @@ void EtbController::PeriodicTask() { return; } - if (boardConfiguration->pauseEtbControl) { + if (engineConfiguration->pauseEtbControl) { m_motor->set(0); return; } - percent_t actualThrottlePosition = getTPSWithIndex(ownIndex PASS_ENGINE_PARAMETER_SUFFIX); + percent_t actualThrottlePosition = getTPSWithIndex(m_myIndex PASS_ENGINE_PARAMETER_SUFFIX); if (engine->etbAutoTune) { autoTune.input = actualThrottlePosition; @@ -254,7 +270,7 @@ void EtbController::PeriodicTask() { int rpm = GET_RPM(); engine->engineState.targetFromTable = pedal2tpsMap.getValue(rpm / RPM_1_BYTE_PACKING_MULT, pedalPosition); - percent_t etbIdleAddition = CONFIGB(useETBforIdleControl) ? engine->engineState.idle.etbIdleAddition : 0; + percent_t etbIdleAddition = CONFIG(useETBforIdleControl) ? engine->engineState.idle.etbIdleAddition : 0; percent_t targetPosition = engine->engineState.targetFromTable + etbIdleAddition; if (engineConfiguration->debugMode == DBG_ETB_LOGIC) { @@ -271,16 +287,16 @@ void EtbController::PeriodicTask() { } engine->engineState.etbFeedForward = interpolate2d("etbb", targetPosition, engineConfiguration->etbBiasBins, engineConfiguration->etbBiasValues); - etbPid.iTermMin = engineConfiguration->etb_iTermMin; - etbPid.iTermMax = engineConfiguration->etb_iTermMax; + m_pid.iTermMin = engineConfiguration->etb_iTermMin; + m_pid.iTermMax = engineConfiguration->etb_iTermMax; currentEtbDuty = engine->engineState.etbFeedForward + - etbPid.getOutput(targetPosition, actualThrottlePosition); + m_pid.getOutput(targetPosition, actualThrottlePosition); m_motor->set(ETB_PERCENT_TO_DUTY(currentEtbDuty)); if (engineConfiguration->isVerboseETB) { - etbPid.showPidStatus(&logger, "ETB"); + m_pid.showPidStatus(&logger, "ETB"); } DISPLAY_STATE(Engine) @@ -323,48 +339,30 @@ DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor)) /* DISPLAY_ELSE */ DISPLAY_TEXT(No_Pedal_Sensor); /* DISPLAY_ENDIF */ + + // Only report the 0th throttle + if (m_myIndex == 0) { #if EFI_TUNER_STUDIO - // 312 - tsOutputChannels.etbTarget = targetPosition; - // 316 - tsOutputChannels.etb1DutyCycle = currentEtbDuty; - // 320 - // Error is positive if the throttle needs to open further - tsOutputChannels.etb1Error = targetPosition - actualThrottlePosition; + // 312 + tsOutputChannels.etbTarget = targetPosition; + // 316 + tsOutputChannels.etb1DutyCycle = currentEtbDuty; + // 320 + // Error is positive if the throttle needs to open further + tsOutputChannels.etb1Error = targetPosition - actualThrottlePosition; #endif /* EFI_TUNER_STUDIO */ + } } static EtbHardware etbHardware[ETB_COUNT]; -EtbController etbController[ETB_COUNT]; - -/** - * At the moment there are TWO ways to use this - * set_etb_duty X - * set etb X - * manual duty cycle control without PID. Percent value from 0 to 100 - */ -void setThrottleDutyCycle(percent_t level) { - scheduleMsg(&logger, "setting ETB duty=%f%%", level); - if (cisnan(level)) { - directPwmValue = NAN; - return; - } - - float dc = ETB_PERCENT_TO_DUTY(level); - directPwmValue = dc; - for (int i = 0 ; i < ETB_COUNT; i++) { - etbHardware[i].dcMotor.set(dc); - } - scheduleMsg(&logger, "duty ETB duty=%f", dc); -} - -static bool etbOperational = false; +// real implementation (we mock for some unit tests) +EtbController etbControllers[ETB_COUNT]; static void showEthInfo(void) { #if EFI_PROD_CODE static char pinNameBuffer[16]; - if (!etbOperational) { + if (engine->etbActualCount == 0) { scheduleMsg(&logger, "ETB DISABLED since no PPS"); } @@ -387,28 +385,50 @@ static void showEthInfo(void) { scheduleMsg(&logger, "dir1=%s", hwPortname(CONFIG(etbIo[0].directionPin1))); scheduleMsg(&logger, "dir2=%s", hwPortname(CONFIG(etbIo[0].directionPin2))); - for (int i = 0 ; i < ETB_COUNT; i++) { + for (int i = 0 ; i < engine->etbActualCount; i++) { EtbHardware *etb = &etbHardware[i]; - scheduleMsg(&logger, "%d: dir=%d DC=%f", i, etb->dcMotor.isOpenDirection(), etb->dcMotor.get()); + scheduleMsg(&logger, "ETB %d", i); + scheduleMsg(&logger, "Motor: dir=%d DC=%f", etb->dcMotor.isOpenDirection(), etb->dcMotor.get()); + etbControllers[i].showStatus(&logger); } - etbController[0].etbPid.showPidStatus(&logger, "ETB"); #endif /* EFI_PROD_CODE */ } -static void etbPidReset() { - for (int i = 0 ; i < ETB_COUNT; i++) { - etbController[i].etbPid.reset(); +static void etbPidReset(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + for (int i = 0 ; i < engine->etbActualCount; i++) { + engine->etbControllers[i]->reset(); } } -#if EFI_PROD_CODE +#if !EFI_UNIT_TEST + +/** + * At the moment there are TWO ways to use this + * set_etb_duty X + * set etb X + * manual duty cycle control without PID. Percent value from 0 to 100 + */ +void setThrottleDutyCycle(percent_t level) { + scheduleMsg(&logger, "setting ETB duty=%f%%", level); + if (cisnan(level)) { + directPwmValue = NAN; + return; + } + + float dc = ETB_PERCENT_TO_DUTY(level); + directPwmValue = dc; + for (int i = 0 ; i < engine->etbActualCount; i++) { + etbHardware[i].dcMotor.set(dc); + } + scheduleMsg(&logger, "duty ETB duty=%f", dc); +} static void setEtbFrequency(int frequency) { engineConfiguration->etbFreq = frequency; - for (int i = 0 ; i < ETB_COUNT; i++) { + for (int i = 0 ; i < engine->etbActualCount; i++) { etbHardware[i].setFrequency(frequency); } } @@ -416,9 +436,10 @@ static void setEtbFrequency(int frequency) { static void etbReset() { scheduleMsg(&logger, "etbReset"); - for (int i = 0 ; i < ETB_COUNT; i++) { + for (int i = 0 ; i < engine->etbActualCount; i++) { etbHardware[i].dcMotor.set(0); } + etbPidReset(); mockPedalPosition = MOCK_UNDEFINED; @@ -555,14 +576,16 @@ void stopETBPins(void) { #endif /* EFI_PROD_CODE */ void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration) { - bool shouldResetPid = !etbController[0].etbPid.isSame(&previousConfiguration->etb); - for (int i = 0 ; i < ETB_COUNT; i++) { - etbController[i].shouldResetPid = shouldResetPid; + for (int i = 0; i < ETB_COUNT; i++) { + etbControllers[i].onConfigurationChange(&previousConfiguration->etb); } } void startETBPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + /** + * safer to start 2nd ETB even if 2nd TPS is not configured by mistake + */ for (int i = 0 ; i < ETB_COUNT; i++) { etb_io *io = &engineConfiguration->etbIo[i]; // controlPinMode is a strange feature - it's simply because I am short on 5v I/O on Frankenso with Miata NB2 test mule @@ -633,10 +656,18 @@ void setDefaultEtbBiasCurve(DECLARE_CONFIG_PARAMETER_SIGNATURE) { } void unregisterEtbPins() { - + // todo: we probably need an implementation here?! } void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + for (int i = 0; i < ETB_COUNT; i++) { + engine->etbControllers[i] = &etbControllers[i]; + } + doInitElectronicThrottle(PASS_ENGINE_PARAMETER_SIGNATURE); +} + +void doInitElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + efiAssertVoid(OBD_PCM_Processor_Fault, engine->etbControllers != NULL, "etbControllers NULL"); #if EFI_PROD_CODE addConsoleAction("ethinfo", showEthInfo); addConsoleAction("etbreset", etbReset); @@ -644,9 +675,8 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #endif /* EFI_PROD_CODE */ for (int i = 0 ; i < ETB_COUNT; i++) { - etbController[i].init(&etbHardware[i].dcMotor, i); - etbController[i].etbPid.initPidClass(&engineConfiguration->etb); - INJECT_ENGINE_REFERENCE(&etbController[i]); + engine->etbControllers[i]->init(&etbHardware[i].dcMotor, i, &engineConfiguration->etb); + INJECT_ENGINE_REFERENCE(engine->etbControllers[i]); } @@ -656,7 +686,8 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (!engine->engineState.hasEtbPedalPositionSensor) { return; } - etbOperational = true; + engine->etbActualCount = hasTps2(PASS_ENGINE_PARAMETER_SIGNATURE) ? 2 : 1; + #if 0 // not alive code autoTune.SetOutputStep(0.1); @@ -680,7 +711,7 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_PROD_CODE if (engineConfiguration->etbCalibrationOnStart) { - for (int i = 0 ; i < ETB_COUNT; i++) { + for (int i = 0 ; i < engine->etbActualCount; i++) { EtbHardware *etb = &etbHardware[i]; etb->dcMotor.set(70); @@ -717,12 +748,13 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #endif /* EFI_PROD_CODE */ - etbPidReset(); + etbPidReset(PASS_ENGINE_PARAMETER_SIGNATURE); - for (int i = 0 ; i < ETB_COUNT; i++) { - etbController[i].Start(); + for (int i = 0 ; i < engine->etbActualCount; i++) { + engine->etbControllers[i]->Start(); } } + #endif /* EFI_ELECTRONIC_THROTTLE_BODY */ diff --git a/firmware/controllers/actuators/electronic_throttle.h b/firmware/controllers/actuators/electronic_throttle.h index c2dc136aa5..c09e697bcf 100644 --- a/firmware/controllers/actuators/electronic_throttle.h +++ b/firmware/controllers/actuators/electronic_throttle.h @@ -15,23 +15,44 @@ #include "periodic_task.h" class DcMotor; +class Logging; -class EtbController final : public PeriodicTimerController { +class IEtbController : public PeriodicTimerController{ public: DECLARE_ENGINE_PTR; - void init(DcMotor *motor, int ownIndex); + virtual void init(DcMotor *motor, int ownIndex, pid_s *pidParameters) = 0; + virtual void reset() = 0; +}; +class EtbController final : public IEtbController { +public: + void init(DcMotor *motor, int ownIndex, pid_s *pidParameters) override; + + // PeriodicTimerController implementation int getPeriodMs() override; void PeriodicTask() override; - Pid etbPid; - bool shouldResetPid = false; + void reset() override; + + // Called when the configuration may have changed. Controller will + // reset if necessary. + void onConfigurationChange(pid_s* previousConfiguration); + + // Print this throttle's status. + void showStatus(Logging* logger); + + // Used to inspect the internal PID controller's state + const pid_state_s* getPidState() const { return &m_pid; }; private: - int ownIndex; - DcMotor *m_motor; + int m_myIndex; + DcMotor *m_motor; + Pid m_pid; + bool m_shouldResetPid = false; }; void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE); +void doInitElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE); + void setDefaultEtbBiasCurve(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setDefaultEtbParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setBoschVNH2SP30Curve(DECLARE_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 8ee03533a8..3e4fe53e18 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -112,18 +112,18 @@ void idleDebug(const char *msg, percent_t value) { static void showIdleInfo(void) { const char * idleModeStr = getIdle_mode_e(engineConfiguration->idleMode); scheduleMsg(logger, "idleMode=%s position=%.2f isStepper=%s", idleModeStr, - getIdlePosition(), boolToString(CONFIGB(useStepperIdle))); + getIdlePosition(), boolToString(CONFIG(useStepperIdle))); - if (CONFIGB(useStepperIdle)) { - scheduleMsg(logger, "directionPin=%s reactionTime=%.2f", hwPortname(CONFIGB(idle).stepperDirectionPin), + if (CONFIG(useStepperIdle)) { + scheduleMsg(logger, "directionPin=%s reactionTime=%.2f", hwPortname(CONFIG(idle).stepperDirectionPin), engineConfiguration->idleStepperReactionTime); - scheduleMsg(logger, "stepPin=%s steps=%d", hwPortname(CONFIGB(idle).stepperStepPin), + scheduleMsg(logger, "stepPin=%s steps=%d", hwPortname(CONFIG(idle).stepperStepPin), engineConfiguration->idleStepperTotalSteps); scheduleMsg(logger, "enablePin=%s/%d", hwPortname(engineConfiguration->stepperEnablePin), engineConfiguration->stepperEnablePinMode); } else { - scheduleMsg(logger, "idle valve freq=%d on %s", CONFIGB(idle).solenoidFrequency, - hwPortname(CONFIGB(idle).solenoidPin)); + scheduleMsg(logger, "idle valve freq=%d on %s", CONFIG(idle).solenoidFrequency, + hwPortname(CONFIG(idle).solenoidPin)); } @@ -138,10 +138,10 @@ void setIdleMode(idle_mode_e value) { } static void applyIACposition(percent_t position) { - if (CONFIGB(useETBforIdleControl)) { + if (CONFIG(useETBforIdleControl)) { engine->engineState.idle.etbIdleAddition = position / 100 * CONFIG(etbIdleThrottleRange); #if ! EFI_UNIT_TEST - } if (CONFIGB(useStepperIdle)) { + } if (CONFIG(useStepperIdle)) { iacMotor.setTargetPosition(position / 100 * engineConfiguration->idleStepperTotalSteps); #endif /* EFI_UNIT_TEST */ } else { @@ -165,14 +165,14 @@ void setIdleValvePosition(int positionPercent) { showIdleInfo(); #endif /* EFI_UNIT_TEST */ // todo: this is not great that we have to write into configuration here - CONFIGB(manIdlePosition) = positionPercent; + CONFIG(manIdlePosition) = positionPercent; } #endif /* EFI_UNIT_TEST */ static percent_t manualIdleController(float cltCorrection DECLARE_ENGINE_PARAMETER_SUFFIX) { - percent_t correctedPosition = cltCorrection * CONFIGB(manIdlePosition); + percent_t correctedPosition = cltCorrection * CONFIG(manIdlePosition); // let's put the value into the right range correctedPosition = maxF(correctedPosition, 0.01); @@ -223,7 +223,7 @@ static bool isOutOfAutomaticIdleCondition(DECLARE_ENGINE_PARAMETER_SIGNATURE) { inputPosition = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); } - return inputPosition > CONFIGB(idlePidDeactivationTpsThreshold); + return inputPosition > CONFIG(idlePidDeactivationTpsThreshold); } /** @@ -287,7 +287,7 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // Apply PID Deactivation Threshold as a smooth taper for TPS transients. percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); // if tps==0 then PID just works as usual, or we completely disable it if tps>=threshold - newValue = interpolateClamped(0.0f, newValue, CONFIGB(idlePidDeactivationTpsThreshold), engine->engineState.idle.baseIdlePosition, tpsPos); + newValue = interpolateClamped(0.0f, newValue, CONFIG(idlePidDeactivationTpsThreshold), engine->engineState.idle.baseIdlePosition, tpsPos); // Interpolate to the manual position when RPM is close to the upper RPM limit (if idlePidRpmUpperLimit is set). // If RPM increases and the throttle is closed, then we're in coasting mode, and we should smoothly disable auto-pid. @@ -297,7 +297,7 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) { int idlePidLowerRpm = targetRpm + CONFIG(idlePidRpmDeadZone); if (CONFIG(idlePidRpmUpperLimit) > 0) { engine->engineState.idle.idleState = PID_UPPER; - if (CONFIGB(useIacTableForCoasting) && hasCltSensor()) { + if (CONFIG(useIacTableForCoasting) && hasCltSensor()) { percent_t iacPosForCoasting = interpolate2d("iacCoasting", getCoolantTemperature(), CONFIG(iacCoastingBins), CONFIG(iacCoasting)); newValue = interpolateClamped(idlePidLowerRpm, newValue, idlePidLowerRpm + CONFIG(idlePidRpmUpperLimit), iacPosForCoasting, rpm); } else { @@ -341,8 +341,8 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_GPIO_HARDWARE // this value is not used yet - if (CONFIGB(clutchDownPin) != GPIO_UNASSIGNED) { - engine->clutchDownState = efiReadPin(CONFIGB(clutchDownPin)); + if (CONFIG(clutchDownPin) != GPIO_UNASSIGNED) { + engine->clutchDownState = efiReadPin(CONFIG(clutchDownPin)); } if (hasAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE)) { bool result = getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -412,7 +412,7 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) { percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); float additionalAir = (float)engineConfiguration->iacByTpsTaper; - iacPosition += interpolateClamped(0.0f, 0.0f, CONFIGB(idlePidDeactivationTpsThreshold), additionalAir, tpsPos); + iacPosition += interpolateClamped(0.0f, 0.0f, CONFIG(idlePidDeactivationTpsThreshold), additionalAir, tpsPos); // taper transition from cranking to running (uint32_t to float conversion is safe here) if (engineConfiguration->afterCrankingIACtaperDuration > 0) @@ -472,7 +472,7 @@ void setDefaultIdleParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration) { shouldResetPid = !idlePid.isSame(&previousConfiguration->idleRpmPid); - idleSolenoid.setFrequency(CONFIGB(idle).solenoidFrequency); + idleSolenoid.setFrequency(CONFIG(idle).solenoidFrequency); } void setTargetIdleRpm(int value) { @@ -534,31 +534,31 @@ static void applyIdleSolenoidPinState(int stateIndex, PwmConfig *state) /* pwm_g bool isIdleHardwareRestartNeeded() { return isConfigurationChanged(stepperEnablePin) || isConfigurationChanged(stepperEnablePinMode) || - isConfigurationChanged(bc.idle.stepperStepPin) || - isConfigurationChanged(bc.idle.solenoidFrequency) || - isConfigurationChanged(bc.useStepperIdle) || + isConfigurationChanged(idle.stepperStepPin) || + isConfigurationChanged(idle.solenoidFrequency) || + isConfigurationChanged(useStepperIdle) || // isConfigurationChanged() || - isConfigurationChanged(bc.useETBforIdleControl) || - isConfigurationChanged(bc.idle.solenoidPin); + isConfigurationChanged(useETBforIdleControl) || + isConfigurationChanged(idle.solenoidPin); } void stopIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_PROD_CODE brain_pin_markUnused(activeConfiguration.stepperEnablePin); - brain_pin_markUnused(activeConfiguration.bc.idle.stepperStepPin); - brain_pin_markUnused(activeConfiguration.bc.idle.solenoidPin); -// brain_pin_markUnused(activeConfiguration.bc.idle.); -// brain_pin_markUnused(activeConfiguration.bc.idle.); -// brain_pin_markUnused(activeConfiguration.bc.idle.); -// brain_pin_markUnused(activeConfiguration.bc.idle.); + brain_pin_markUnused(activeConfiguration.idle.stepperStepPin); + brain_pin_markUnused(activeConfiguration.idle.solenoidPin); +// brain_pin_markUnused(activeConfiguration.idle.); +// brain_pin_markUnused(activeConfiguration.idle.); +// brain_pin_markUnused(activeConfiguration.idle.); +// brain_pin_markUnused(activeConfiguration.idle.); #endif /* EFI_PROD_CODE */ } void initIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (CONFIGB(useStepperIdle)) { - iacMotor.initialize(CONFIGB(idle).stepperStepPin, - CONFIGB(idle).stepperDirectionPin, + if (CONFIG(useStepperIdle)) { + iacMotor.initialize(CONFIG(idle).stepperStepPin, + CONFIG(idle).stepperDirectionPin, engineConfiguration->stepperDirectionPinMode, engineConfiguration->idleStepperReactionTime, engineConfiguration->idleStepperTotalSteps, @@ -566,14 +566,14 @@ void initIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) { logger); // This greatly improves PID accuracy for steppers with a small number of steps idlePositionSensitivityThreshold = 1.0f / engineConfiguration->idleStepperTotalSteps; - } else if (!engineConfiguration->bc.useETBforIdleControl) { + } else if (!engineConfiguration->useETBforIdleControl) { /** * Start PWM for idleValvePin */ startSimplePwmExt(&idleSolenoid, "Idle Valve", &engine->executor, - CONFIGB(idle).solenoidPin, &enginePins.idleSolenoidPin, - CONFIGB(idle).solenoidFrequency, CONFIGB(manIdlePosition) / 100, + CONFIG(idle).solenoidPin, &enginePins.idleSolenoidPin, + CONFIG(idle).solenoidFrequency, CONFIG(manIdlePosition) / 100, (pwm_gen_callback*)applyIdleSolenoidPinState); idlePositionSensitivityThreshold = 0.0f; } @@ -642,9 +642,9 @@ void startIdleThread(Logging*sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { #if ! EFI_UNIT_TEST // this is neutral/no gear switch input. on Miata it's wired both to clutch pedal and neutral in gearbox // this switch is not used yet - if (CONFIGB(clutchDownPin) != GPIO_UNASSIGNED) { - efiSetPadMode("clutch down switch", CONFIGB(clutchDownPin), - getInputMode(CONFIGB(clutchDownPinMode))); + if (CONFIG(clutchDownPin) != GPIO_UNASSIGNED) { + efiSetPadMode("clutch down switch", CONFIG(clutchDownPin), + getInputMode(CONFIG(clutchDownPinMode))); } if (CONFIG(clutchUpPin) != GPIO_UNASSIGNED) { @@ -654,7 +654,7 @@ void startIdleThread(Logging*sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { if (CONFIG(throttlePedalUpPin) != GPIO_UNASSIGNED) { efiSetPadMode("throttle pedal up switch", CONFIG(throttlePedalUpPin), - getInputMode(CONFIGB(throttlePedalUpPinMode))); + getInputMode(CONFIG(throttlePedalUpPinMode))); } if (engineConfiguration->brakePedalPin != GPIO_UNASSIGNED) { diff --git a/firmware/controllers/actuators/pwm_tester.cpp b/firmware/controllers/actuators/pwm_tester.cpp index c257bf7f74..f6d1277c62 100644 --- a/firmware/controllers/actuators/pwm_tester.cpp +++ b/firmware/controllers/actuators/pwm_tester.cpp @@ -35,7 +35,7 @@ static void startPwmTest(int freq) { /** * See custom_engine.cpp for pinout */ - // currently this is PB9 by default - see CONFIGB(injectionPins) + // currently this is PB9 by default - see CONFIG(injectionPins) startSimplePwm(&pwmTest[1], "tester", &enginePins.injectors[0], freq / 1.3333333333, 0.5f, applyPinState); // currently this is PE2 by default startSimplePwm(&pwmTest[2], "tester", &enginePins.injectors[1], freq / 1000, 0.5f, applyPinState); diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index 8da18d85c9..46bfb5674e 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -68,7 +68,7 @@ static const ignition_table_t defaultIatTiming = { #endif /* IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT */ bool isStep1Condition(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { - return CONFIGB(enabledStep1Limiter) && rpm >= engineConfiguration->step1rpm; + return CONFIG(enabledStep1Limiter) && rpm >= engineConfiguration->step1rpm; } /** @@ -104,7 +104,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME float idleAdvance = interpolate2d("idleAdvance", rpm, config->idleAdvanceBins, config->idleAdvance); // interpolate between idle table and normal (running) table using TPS threshold float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); - advanceAngle = interpolateClamped(0.0f, idleAdvance, CONFIGB(idlePidDeactivationTpsThreshold), advanceAngle, tps); + advanceAngle = interpolateClamped(0.0f, idleAdvance, CONFIG(idlePidDeactivationTpsThreshold), advanceAngle, tps); } engine->m.advanceLookupTime = getTimeNowLowerNt() - engine->m.beforeAdvance; @@ -120,11 +120,11 @@ angle_t getAdvanceCorrections(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { } // PID Ignition Advance angle correction float pidTimingCorrection = 0.0f; - if (CONFIGB(useIdleTimingPidControl)) { + if (CONFIG(useIdleTimingPidControl)) { int targetRpm = getTargetRpmForIdleCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); int rpmDelta = absI(rpm - targetRpm); float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); - if (tps >= CONFIGB(idlePidDeactivationTpsThreshold)) { + if (tps >= CONFIG(idlePidDeactivationTpsThreshold)) { // we are not in the idle mode anymore, so the 'reset' flag will help us when we return to the idle. shouldResetTimingPid = true; } @@ -139,7 +139,7 @@ angle_t getAdvanceCorrections(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { percent_t timingRawCorr = idleTimingPid.getOutput(targetRpm, rpm, /* is this the right dTime? this period is not exactly the period at which this code is invoked*/engineConfiguration->idleTimingPid.periodMs); // tps idle-running falloff - pidTimingCorrection = interpolateClamped(0.0f, timingRawCorr, CONFIGB(idlePidDeactivationTpsThreshold), 0.0f, tps); + pidTimingCorrection = interpolateClamped(0.0f, timingRawCorr, CONFIG(idlePidDeactivationTpsThreshold), 0.0f, tps); // rpm falloff pidTimingCorrection = interpolateClamped(0.0f, pidTimingCorrection, CONFIG(idlePidFalloffDeltaRpm), 0.0f, rpmDelta - CONFIG(idleTimingPidWorkZone)); } else { diff --git a/firmware/controllers/algo/algo.cpp b/firmware/controllers/algo/algo.cpp deleted file mode 100644 index c9043fa298..0000000000 --- a/firmware/controllers/algo/algo.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * @file algo.cpp - * - * @date Mar 2, 2014 - * @author Andrey Belomutskiy, (c) 2012-2018 - * - * - * This file is part of rusEfi - see http://rusefi.com - * - * rusEfi is free software; you can redistribute it and/or modify it under the terms of - * the GNU General Public License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program. - * If not, see . - */ - -#include "globalaccess.h" -#include "algo.h" -#include "advance_map.h" -#include "fuel_math.h" -#include "settings.h" -#include "speed_density.h" -#include "fsio_impl.h" - -EXTERN_ENGINE; - -void initDataStructures(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - initFuelMap(PASS_ENGINE_PARAMETER_SIGNATURE); - initTimingMap(PASS_ENGINE_PARAMETER_SIGNATURE); - initSpeedDensity(PASS_ENGINE_PARAMETER_SIGNATURE); -} - -void initAlgo(Logging *sharedLogger) { - initInterpolation(sharedLogger); -} diff --git a/firmware/controllers/algo/algo.h b/firmware/controllers/algo/algo.h deleted file mode 100644 index f08b8d1497..0000000000 --- a/firmware/controllers/algo/algo.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @file algo.h - * - * @date Mar 2, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 - */ - -#pragma once - -#include "global.h" -#include "engine_configuration.h" -void initDataStructures(DECLARE_ENGINE_PARAMETER_SIGNATURE); -void initAlgo(Logging *sharedLogger); diff --git a/firmware/controllers/algo/algo.mk b/firmware/controllers/algo/algo.mk index e150fdcf32..d55e64de0a 100644 --- a/firmware/controllers/algo/algo.mk +++ b/firmware/controllers/algo/algo.mk @@ -10,4 +10,3 @@ CONTROLLERS_ALGO_SRC_CPP = $(PROJECT_DIR)/controllers/algo/advance_map.cpp \ $(PROJECT_DIR)/controllers/algo/engine2.cpp \ $(PROJECT_DIR)/controllers/gauges/lcd_menu_tree.cpp \ $(PROJECT_DIR)/controllers/algo/event_registry.cpp \ - $(PROJECT_DIR)/controllers/algo/algo.cpp \ diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 9612068455..faf4d88f64 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -733,8 +733,8 @@ case HONDA_ACCORD_CD_TWO_WIRES: return "HONDA_ACCORD_CD_TWO_WIRES"; case LADA_KALINA: return "LADA_KALINA"; -case MAZDA_323: - return "MAZDA_323"; +case MRE_MIATA_NB2_MTB: + return "MRE_MIATA_NB2_MTB"; case MAZDA_626: return "MAZDA_626"; case MAZDA_MIATA_2003: @@ -803,6 +803,8 @@ case TOYOTA_JZS147: return "TOYOTA_JZS147"; case VAG_18_TURBO: return "VAG_18_TURBO"; +case VW_B6: + return "VW_B6"; case VW_ABA: return "VW_ABA"; case ZIL_130: diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 98c1ab7b2c..195c130209 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -43,6 +43,12 @@ LoggingWithStorage engineLogger("engine"); EXTERN_ENGINE ; +#if EFI_ENGINE_SNIFFER +#include "engine_sniffer.h" +extern int waveChartUsedSize; +extern WaveChart waveChart; +#endif /* EFI_ENGINE_SNIFFER */ + FsioState::FsioState() { #if EFI_ENABLE_ENGINE_WARNING isEngineWarning = FALSE; @@ -52,6 +58,16 @@ FsioState::FsioState() { #endif } +void Engine::resetEngineSnifferIfInTestMode() { +#if EFI_ENGINE_SNIFFER + if (isTestMode) { + // TODO: what is the exact reasoning for the exact engine sniffer pause time I wonder + waveChart.pauseEngineSnifferUntilNt = getTimeNowNt() + MS2NT(300); + waveChart.reset(); + } +#endif /* EFI_ENGINE_SNIFFER */ +} + void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT // we have a confusing threading model so some synchronization would not hurt @@ -130,7 +146,7 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if (BOARD_TLE8888_COUNT > 0) if (CONFIG(useTLE8888_cranking_hack) && ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) { efitick_t nowNt = getTimeNowNt(); - if (nowNt - tle8888CrankingResetTime > US2NT(MS2US(300))) { + if (nowNt - tle8888CrankingResetTime > MS2NT(300)) { requestTLE8888initialization(); // let's reset TLE8888 every 300ms while cranking since that's the best we can do to deal with undervoltage reset // PS: oh yes, it's a horrible design! Please suggest something better! @@ -155,15 +171,15 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_ENGINE_CONTROL int rpm = GET_RPM(); isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold); - sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? CONFIGB(sensorChartMode) : SC_OFF; + sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? CONFIG(sensorChartMode) : SC_OFF; engineState.updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE); // todo: move this logic somewhere to sensors folder? if (CONFIG(fuelLevelSensor) != EFI_ADC_NONE) { float fuelLevelVoltage = getVoltageDivided("fuel", engineConfiguration->fuelLevelSensor PASS_ENGINE_PARAMETER_SUFFIX); - sensors.fuelTankLevel = interpolateMsg("fgauge", CONFIGB(fuelLevelEmptyTankVoltage), 0, - CONFIGB(fuelLevelFullTankVoltage), 100, + sensors.fuelTankLevel = interpolateMsg("fgauge", CONFIG(fuelLevelEmptyTankVoltage), 0, + CONFIG(fuelLevelFullTankVoltage), 100, fuelLevelVoltage); } sensors.vBatt = hasVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) ? getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) : 12; @@ -341,7 +357,7 @@ bool Engine::isInShutdownMode() const { if (stopEngineRequestTimeNt == 0) // the shutdown procedure is not started return false; - const efitime_t engineStopWaitTimeoutNt = 5LL * 1000000LL; + const efitick_t engineStopWaitTimeoutNt = 5LL * 1000000LL; // The engine is still spinning! Give it some time to stop (but wait no more than 5 secs) if (isSpinning && (getTimeNowNt() - stopEngineRequestTimeNt) < US2NT(engineStopWaitTimeoutNt)) return true; diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 0c4c26ff3e..3488ecd487 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -47,11 +47,15 @@ class RpmCalculator; #define CYCLE_ALTERNATION 2 +class IEtbController; + class Engine : public TriggerStateListener { public: explicit Engine(persistent_config_s *config); Engine(); + IEtbController *etbControllers[ETB_COUNT]; + void OnTriggerStateDecodingError() override; void OnTriggerStateProperState(efitick_t nowNt) override; @@ -64,7 +68,14 @@ public: AuxActor auxValves[AUX_DIGITAL_VALVE_COUNT][2]; +#if EFI_UNIT_TEST bool needTdcCallback = true; +#endif /* EFI_UNIT_TEST */ + + /** + * if 2nd TPS is not configured we do not run 2nd ETB + */ + int etbActualCount = 0; /** * By the way 32-bit value should hold at least 400 hours of events at 6K RPM x 12 events per revolution @@ -133,16 +144,11 @@ public: bool isCltBroken = false; bool slowCallBackWasInvoked = false; - -// floatms_t callToPitEndTime; - /** * remote telemetry: if not zero, time to stop flashing 'CALL FROM PIT STOP' light + * todo: looks like there is a bug here? 64 bit storage an 32 bit time logic? anyway this feature is mostly a dream at this point */ - efitime_t callFromPitStopEndTime = 0; - - // timestamp of most recent time RPM hard limit was triggered - efitime_t rpmHardLimitTimestamp = 0; + efitimems64_t callFromPitStopEndTime = 0; /** * This flag indicated a big enough problem that engine control would be @@ -235,6 +241,7 @@ public: */ bool isTestMode = false; + void resetEngineSnifferIfInTestMode(); /** * pre-calculated offset for given sequence index within engine cycle diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index 8ef3bcd6bf..e586c91cb8 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -205,7 +205,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { /** * *0.01 because of https://sourceforge.net/p/rusefi/tickets/153/ */ - if (CONFIGB(useTPSBasedVeTable)) { + if (CONFIG(useTPSBasedVeTable)) { // todo: should we have 'veTpsMap' fuel_Map3D_t variable here? currentRawVE = interpolate3d(tps, CONFIG(ignitionTpsBins), IGN_TPS_COUNT, rpm, config->veRpmBins, FUEL_RPM_COUNT, veMap.pointers); } else { @@ -215,7 +215,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (CONFIG(useSeparateVeForIdle)) { float idleVe = interpolate2d("idleVe", rpm, config->idleVeBins, config->idleVe); // interpolate between idle table and normal (running) table using TPS threshold - currentRawVE = interpolateClamped(0.0f, idleVe, CONFIGB(idlePidDeactivationTpsThreshold), currentRawVE, tps); + currentRawVE = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), currentRawVE, tps); } currentBaroCorrectedVE = baroCorrection * currentRawVE * PERCENT_DIV; targetAFR = afrMap.getValue(rpm, map); diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 6269268700..f176831f3f 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -57,7 +57,6 @@ #include "mazda_miata_na8.h" #include "mazda_miata_nb.h" #include "mazda_miata_vvt.h" -#include "mazda_323.h" #include "mazda_626.h" #include "citroenBerlingoTU3JP.h" @@ -67,6 +66,7 @@ #include "test_engine.h" #include "sachs.h" #include "vw.h" +#include "vw_b6.h" #include "daihatsu.h" #include "chevrolet_camaro_4.h" #include "suzuki_vitara.h" @@ -286,7 +286,7 @@ static void initTemperatureCurve(float *bins, float *values, int size, float def void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) { efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL"); memset(engineConfiguration, 0, sizeof(engine_configuration_s)); - board_configuration_s *boardConfiguration = &engineConfiguration->bc; + // Now that GPIO_UNASSIGNED == 0 we do not really need explicit zero assignments since memset above does that // todo: migrate 'EFI_ADC_NONE' to '0' and eliminate the need in this method altogether @@ -312,7 +312,7 @@ void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) { engineConfiguration->tps1_1AdcChannel = EFI_ADC_NONE; */ engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; - engineConfiguration->bc.auxFastSensor1_adcChannel = EFI_ADC_NONE; + engineConfiguration->auxFastSensor1_adcChannel = EFI_ADC_NONE; engineConfiguration->acSwitchAdc = EFI_ADC_NONE; engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; engineConfiguration->fuelLevelSensor = EFI_ADC_NONE; @@ -321,7 +321,7 @@ void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) { engineConfiguration->high_fuel_pressure_sensor_1 = EFI_ADC_NONE; engineConfiguration->high_fuel_pressure_sensor_2 = EFI_ADC_NONE; - boardConfiguration->clutchDownPinMode = PI_PULLUP; + engineConfiguration->clutchDownPinMode = PI_PULLUP; engineConfiguration->clutchUpPinMode = PI_PULLUP; engineConfiguration->brakePedalPinMode = PI_PULLUP; } @@ -353,12 +353,12 @@ void setDefaultBasePins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // set UART pads configuration based on the board // needed also by bootloader code - boardConfiguration->useSerialPort = true; + engineConfiguration->useSerialPort = true; engineConfiguration->binarySerialTxPin = GPIOC_10; engineConfiguration->binarySerialRxPin = GPIOC_11; engineConfiguration->consoleSerialTxPin = GPIOC_10; engineConfiguration->consoleSerialRxPin = GPIOC_11; - boardConfiguration->tunerStudioSerialSpeed = TS_DEFAULT_SPEED; + engineConfiguration->tunerStudioSerialSpeed = TS_DEFAULT_SPEED; engineConfiguration->uartConsoleSerialSpeed = 115200; #if EFI_PROD_CODE @@ -370,10 +370,10 @@ void setDefaultBasePins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // needed also by bootloader code // at the moment bootloader does NOT really need SD card, this is a step towards future bootloader SD card usage void setDefaultSdCardParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - boardConfiguration->is_enabled_spi_3 = true; + engineConfiguration->is_enabled_spi_3 = true; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - boardConfiguration->sdCardCsPin = GPIOD_4; - boardConfiguration->isSdCardEnabled = true; + engineConfiguration->sdCardCsPin = GPIOD_4; + engineConfiguration->isSdCardEnabled = true; #if EFI_PROD_CODE // call overrided board-specific SD card configuration setup, if needed (for custom boards only) @@ -431,24 +431,53 @@ static void setDefaultWarmupIdleCorrection(DECLARE_CONFIG_PARAMETER_SIGNATURE) { } static void setDefaultWarmupFuelEnrichment(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - initTemperatureCurve(WARMUP_CLT_EXTRA_FUEL_CURVE, 1.0); + static const float bins[] = + { + -40, + -30, + -20, + -10, + 0, + 10, + 20, + 30, + 40, + 50, + 60, + 70, + 80, + 90, + 100, + 110 + }; - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -40, 1.50); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -30, 1.50); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -20, 1.42); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -10, 1.36); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 0, 1.28); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 10, 1.19); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 20, 1.12); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 30, 1.10); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 40, 1.06); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 50, 1.06); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 60, 1.03); - setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 70, 1.01); + copyArray(config->cltFuelCorrBins, bins); + + static const float values[] = + { + 1.50, + 1.50, + 1.42, + 1.36, + 1.28, + 1.19, + 1.12, + 1.10, + 1.06, + 1.06, + 1.03, + 1.01, + 1, + 1, + 1, + 1 + }; + + copyArray(config->cltFuelCorr, values); } static void setDefaultFuelCutParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - boardConfiguration->coastingFuelCutEnabled = false; + engineConfiguration->coastingFuelCutEnabled = false; engineConfiguration->coastingFuelCutRpmLow = 1300; engineConfiguration->coastingFuelCutRpmHigh = 1500; engineConfiguration->coastingFuelCutTps = 2; @@ -465,54 +494,64 @@ static void setDefaultCrankingSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) { setLinearCurve(config->cltCrankingCorrBins, CLT_CURVE_RANGE_FROM, 100, 1); setLinearCurve(config->cltCrankingCorr, 1.0, 1.0, 1); - config->crankingFuelCoef[0] = 2.8; // base cranking fuel adjustment coefficient - config->crankingFuelBins[0] = -20; // temperature in C - config->crankingFuelCoef[1] = 2.2; - config->crankingFuelBins[1] = -10; - config->crankingFuelCoef[2] = 1.8; - config->crankingFuelBins[2] = 5; - config->crankingFuelCoef[3] = 1.5; - config->crankingFuelBins[3] = 30; + // Cranking temperature compensation + static const float crankingCoef[] = { + 2.8, + 2.2, + 1.8, + 1.5, + 1.0, + 1.0, + 1.0, + 1.0 + }; + copyArray(config->crankingFuelCoef, crankingCoef); - config->crankingFuelCoef[4] = 1.0; - config->crankingFuelBins[4] = 35; - config->crankingFuelCoef[5] = 1.0; - config->crankingFuelBins[5] = 50; - config->crankingFuelCoef[6] = 1.0; - config->crankingFuelBins[6] = 65; - config->crankingFuelCoef[7] = 1.0; - config->crankingFuelBins[7] = 90; + // Deg C + static const float crankingBins[] = { + -20, + -10, + 5, + 30, + 35, + 50, + 65, + 90 + }; + copyArray(config->crankingFuelBins, crankingBins); - config->crankingCycleCoef[0] = 1.5; - config->crankingCycleBins[0] = 4; + // Cranking cycle compensation - config->crankingCycleCoef[1] = 1.35; - config->crankingCycleBins[1] = 8; + static const float crankingCycleCoef[] = { + 1.5, + 1.35, + 1.05, + 0.75, + 0.5, + 0.5, + 0.5, + 0.5 + }; + copyArray(config->crankingCycleCoef, crankingCycleCoef); - config->crankingCycleCoef[2] = 1.05; - config->crankingCycleBins[2] = 12; + static const float crankingCycleBins[] = { + 4, + 8, + 12, + 16, + 74, + 75, + 76, + 77 + }; + copyArray(config->crankingCycleBins, crankingCycleBins); - config->crankingCycleCoef[3] = 0.75; - config->crankingCycleBins[3] = 16; - - config->crankingCycleCoef[4] = 0.5; - config->crankingCycleBins[4] = 74; - config->crankingCycleCoef[5] = 0.5; - config->crankingCycleBins[5] = 75; - config->crankingCycleCoef[6] = 0.5; - config->crankingCycleBins[6] = 76; - config->crankingCycleCoef[7] = 0.5; - config->crankingCycleBins[7] = 77; - - engineConfiguration->crankingAdvance[0] = 0; - engineConfiguration->crankingAdvanceBins[0] = 0; - engineConfiguration->crankingAdvance[1] = 0; - engineConfiguration->crankingAdvanceBins[1] = 200; - engineConfiguration->crankingAdvance[2] = 0; - engineConfiguration->crankingAdvanceBins[2] = 400; - engineConfiguration->crankingAdvance[3] = 0; - engineConfiguration->crankingAdvanceBins[3] = 1000; + // Cranking ignition timing + static const float advanceValues[] = { 0, 0, 0, 0 }; + copyArray(engineConfiguration->crankingAdvance, advanceValues); + static const float advanceBins[] = { 0, 200, 400, 1000 }; + copyArray(engineConfiguration->crankingAdvanceBins, advanceBins); } /** @@ -536,21 +575,20 @@ static void setDefaultIdleSpeedTarget(DECLARE_ENGINE_PARAMETER_SIGNATURE) { setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 90, 900); setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 100, 1000); setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 110, 1100); - } static void setDefaultStepperIdleParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - boardConfiguration->idle.stepperDirectionPin = GPIOE_10; - boardConfiguration->idle.stepperStepPin = GPIOE_12; + engineConfiguration->idle.stepperDirectionPin = GPIOE_10; + engineConfiguration->idle.stepperStepPin = GPIOE_12; engineConfiguration->stepperEnablePin = GPIOE_14; engineConfiguration->idleStepperReactionTime = 10; engineConfiguration->idleStepperTotalSteps = 150; } static void setCanFrankensoDefaults(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - boardConfiguration->canDeviceMode = CD_USE_CAN2; - boardConfiguration->canTxPin = GPIOB_6; - boardConfiguration->canRxPin = GPIOB_12; + engineConfiguration->canDeviceMode = CD_USE_CAN2; + engineConfiguration->canTxPin = GPIOB_6; + engineConfiguration->canRxPin = GPIOB_12; } /** @@ -619,14 +657,14 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->canWriteEnabled = true; engineConfiguration->canNbcType = CAN_BUS_MAZDA_RX8; - boardConfiguration->sdCardPeriodMs = 50; + engineConfiguration->sdCardPeriodMs = 50; for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { config->fsioFormulas[i][0] = 0; } - CONFIGB(mapMinBufferLength) = 1; + CONFIG(mapMinBufferLength) = 1; engineConfiguration->idlePidRpmDeadZone = 50; engineConfiguration->startOfCrankingPrimingPulse = 0; @@ -768,7 +806,7 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->fuelClosedLoopCltThreshold = 70; engineConfiguration->fuelClosedLoopRpmThreshold = 900; engineConfiguration->fuelClosedLoopTpsThreshold = 80; - boardConfiguration->fuelClosedLoopAfrLowThreshold = 10.3; + engineConfiguration->fuelClosedLoopAfrLowThreshold = 10.3; engineConfiguration->fuelClosedLoopAfrHighThreshold = 19.8; engineConfiguration->fuelClosedLoopPid.pFactor = -0.1; @@ -783,16 +821,16 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->idleRpmPid.minValue = 0.1; engineConfiguration->idleRpmPid.maxValue = 99; - boardConfiguration->idlePidDeactivationTpsThreshold = 2; + engineConfiguration->idlePidDeactivationTpsThreshold = 2; - boardConfiguration->idle.solenoidFrequency = 200; + engineConfiguration->idle.solenoidFrequency = 200; // set idle_position 50 - boardConfiguration->manIdlePosition = 50; + engineConfiguration->manIdlePosition = 50; engineConfiguration->crankingIACposition = 50; // engineConfiguration->idleMode = IM_AUTO; engineConfiguration->idleMode = IM_MANUAL; - boardConfiguration->useStepperIdle = false; + engineConfiguration->useStepperIdle = false; setDefaultStepperIdleParameters(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -812,7 +850,7 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #endif // performance optimization - boardConfiguration->sensorChartMode = SC_OFF; + engineConfiguration->sensorChartMode = SC_OFF; engineConfiguration->storageMode = MS_AUTO; @@ -907,13 +945,13 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->knockDetectionWindowStart = 35; engineConfiguration->knockDetectionWindowEnd = 135; - boardConfiguration->fuelLevelEmptyTankVoltage = 0; - boardConfiguration->fuelLevelFullTankVoltage = 5; + engineConfiguration->fuelLevelEmptyTankVoltage = 0; + engineConfiguration->fuelLevelFullTankVoltage = 5; /** * this is RPM. 10000 rpm is only 166Hz, 800 rpm is 13Hz */ - boardConfiguration->triggerSimulatorFrequency = 1200; + engineConfiguration->triggerSimulatorFrequency = 1200; engineConfiguration->alternatorPwmFrequency = 300; @@ -926,24 +964,24 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->vehicleSpeedCoef = 1.0f; - boardConfiguration->logicAnalyzerMode[0] = false; - boardConfiguration->logicAnalyzerMode[1] = false; + engineConfiguration->logicAnalyzerMode[0] = false; + engineConfiguration->logicAnalyzerMode[1] = false; engineConfiguration->mapErrorDetectionTooLow = 5; engineConfiguration->mapErrorDetectionTooHigh = 250; - boardConfiguration->idleThreadPeriodMs = 100; - boardConfiguration->consoleLoopPeriodMs = 200; - boardConfiguration->lcdThreadPeriodMs = 300; - boardConfiguration->generalPeriodicThreadPeriodMs = 50; - boardConfiguration->useLcdScreen = true; + engineConfiguration->idleThreadPeriodMs = 100; + engineConfiguration->consoleLoopPeriodMs = 200; + engineConfiguration->lcdThreadPeriodMs = 300; + engineConfiguration->generalPeriodicThreadPeriodMs = 50; + engineConfiguration->useLcdScreen = true; engineConfiguration->hip9011Gain = 1; - boardConfiguration->isFastAdcEnabled = true; - boardConfiguration->isEngineControlEnabled = true; + engineConfiguration->isFastAdcEnabled = true; + engineConfiguration->isEngineControlEnabled = true; - boardConfiguration->isVerboseAlternator = false; + engineConfiguration->isVerboseAlternator = false; engineConfiguration->engineLoadAccelLength = 6; engineConfiguration->engineLoadAccelEnrichmentThreshold = 5; // kPa @@ -962,7 +1000,7 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { * * fsioinfo */ - boardConfiguration->fsio_setting[0] = 5000; + engineConfiguration->fsio_setting[0] = 5000; // simple warning light as default configuration // set_fsio_expression 1 "rpm > fsio_setting(1)" setFsio(0, GPIO_UNASSIGNED, RPM_ABOVE_USER_SETTING_1 PASS_CONFIG_PARAMETER_SUFFIX); @@ -985,36 +1023,36 @@ void setDefaultFrankensoConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->hip9011SpiDevice = SPI_DEVICE_2; engineConfiguration->cj125SpiDevice = SPI_DEVICE_2; -// boardConfiguration->gps_rx_pin = GPIOB_7; -// boardConfiguration->gps_tx_pin = GPIOB_6; +// engineConfiguration->gps_rx_pin = GPIOB_7; +// engineConfiguration->gps_tx_pin = GPIOB_6; - boardConfiguration->triggerSimulatorPins[0] = GPIOD_1; - boardConfiguration->triggerSimulatorPins[1] = GPIOD_2; + engineConfiguration->triggerSimulatorPins[0] = GPIOD_1; + engineConfiguration->triggerSimulatorPins[1] = GPIOD_2; - boardConfiguration->triggerInputPins[0] = GPIOC_6; - boardConfiguration->triggerInputPins[1] = GPIOA_5; + engineConfiguration->triggerInputPins[0] = GPIOC_6; + engineConfiguration->triggerInputPins[1] = GPIOA_5; - //boardConfiguration->logicAnalyzerPins[1] = GPIOE_5; // GPIOE_5 is a popular option (if available) + //engineConfiguration->logicAnalyzerPins[1] = GPIOE_5; // GPIOE_5 is a popular option (if available) // set this to SPI_DEVICE_3 to enable stimulation - //boardConfiguration->digitalPotentiometerSpiDevice = SPI_DEVICE_3; - boardConfiguration->digitalPotentiometerChipSelect[0] = GPIOD_7; - boardConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED; - boardConfiguration->digitalPotentiometerChipSelect[2] = GPIOD_5; - boardConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED; + //engineConfiguration->digitalPotentiometerSpiDevice = SPI_DEVICE_3; + engineConfiguration->digitalPotentiometerChipSelect[0] = GPIOD_7; + engineConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[2] = GPIOD_5; + engineConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED; - boardConfiguration->spi1mosiPin = GPIOB_5; - boardConfiguration->spi1misoPin = GPIOB_4; - boardConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output + engineConfiguration->spi1mosiPin = GPIOB_5; + engineConfiguration->spi1misoPin = GPIOB_4; + engineConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output - boardConfiguration->spi2mosiPin = GPIOB_15; - boardConfiguration->spi2misoPin = GPIOB_14; - boardConfiguration->spi2sckPin = GPIOB_13; + engineConfiguration->spi2mosiPin = GPIOB_15; + engineConfiguration->spi2misoPin = GPIOB_14; + engineConfiguration->spi2sckPin = GPIOB_13; - boardConfiguration->spi3mosiPin = GPIOB_5; - boardConfiguration->spi3misoPin = GPIOB_4; - boardConfiguration->spi3sckPin = GPIOB_3; + engineConfiguration->spi3mosiPin = GPIOB_5; + engineConfiguration->spi3misoPin = GPIOB_4; + engineConfiguration->spi3sckPin = GPIOB_3; // set optional subsystem configs #if EFI_MEMS @@ -1030,9 +1068,9 @@ void setDefaultFrankensoConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setDefaultSdCardParameters(PASS_CONFIG_PARAMETER_SIGNATURE); #endif /* EFI_FILE_LOGGING */ - boardConfiguration->is_enabled_spi_1 = false; - boardConfiguration->is_enabled_spi_2 = false; - boardConfiguration->is_enabled_spi_3 = true; + engineConfiguration->is_enabled_spi_1 = false; + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->is_enabled_spi_3 = true; } void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallback, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) { @@ -1077,8 +1115,11 @@ void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallb case ISSUE_898: setIssue898(PASS_CONFIG_PARAMETER_SIGNATURE); break; + case MRE_MIATA_NB2_MTB: + setMiataNB2_MRE_MTB(PASS_CONFIG_PARAMETER_SIGNATURE); + break; case MRE_MIATA_NB2: - setMiataNB2_MRE(PASS_CONFIG_PARAMETER_SIGNATURE); + setMiataNB2_MRE_ETB(PASS_CONFIG_PARAMETER_SIGNATURE); break; case PROMETHEUS_DEFAULTS: case MINIMAL_PINS: @@ -1172,9 +1213,6 @@ void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallb case MAZDA_MIATA_NB1: setMazdaMiataNb1EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); break; - case MAZDA_323: - setMazda323EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); - break; case MAZDA_626: setMazda626EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); break; @@ -1289,7 +1327,7 @@ void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_PROD_CODE - efiAssertVoid(CUSTOM_APPLY_STACK, getCurrentRemainingStack() > 256, "apply c"); + efiAssertVoid(CUSTOM_APPLY_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "apply c"); scheduleMsg(logger, "applyNonPersistentConfiguration()"); #endif @@ -1335,12 +1373,12 @@ void commonFrankensoAnalogInputs(engine_configuration_s *engineConfiguration) { } void setFrankenso0_1_joystick(engine_configuration_s *engineConfiguration) { - board_configuration_s *boardConfiguration = &engineConfiguration->bc; - boardConfiguration->joystickCenterPin = GPIOC_8; - boardConfiguration->joystickAPin = GPIOD_10; - boardConfiguration->joystickBPin = GPIO_UNASSIGNED; - boardConfiguration->joystickCPin = GPIO_UNASSIGNED; - boardConfiguration->joystickDPin = GPIOD_11; + + engineConfiguration->joystickCenterPin = GPIOC_8; + engineConfiguration->joystickAPin = GPIOD_10; + engineConfiguration->joystickBPin = GPIO_UNASSIGNED; + engineConfiguration->joystickCPin = GPIO_UNASSIGNED; + engineConfiguration->joystickDPin = GPIOD_11; } void copyTargetAfrTable(fuel_table_t const source, afr_table_t destination) { diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index 8d181683c1..bb69496650 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -3,11 +3,10 @@ * @brief Main engine configuration data structure. * * @date Oct 30, 2013 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef ENGINE_CONFIGURATION_H_ -#define ENGINE_CONFIGURATION_H_ +#pragma once #include "globalaccess.h" #include "crc.h" @@ -24,19 +23,6 @@ #define MOCK_UNDEFINED -1 -// WARNING: by default, our small enums are ONE BYTE. this one is made 4-byte with the 'ENUM_32_BITS' hack - -/** - * @brief Engine configuration. - * Values in this data structure are adjustable and persisted in on-board flash RAM. - * - * The offsets are tracked using - * https://docs.google.com/spreadsheet/ccc?key=0AiAmAn6tn3L_dGJXZDZOcVVhaG9SaHZKU1dyMjhEV0E - * - * todo: currently the fields here are simply in the order in which they were implemented - * todo: re-arrange this structure one we have a stable code version - */ - float getRpmMultiplier(operation_mode_e mode); void setOperationMode(engine_configuration_s *engineConfiguration, operation_mode_e mode); @@ -89,5 +75,3 @@ typedef void (*configuration_callback_t)(engine_configuration_s*); void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallback, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX); void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX); #endif /* __cplusplus */ - -#endif /* ENGINE_CONFIGURATION_H_ */ diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index e059f99f90..7fd257cced 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -344,7 +344,7 @@ float getFuelCutOffCorrection(efitick_t nowNt, int rpm DECLARE_ENGINE_PARAMETER_ float fuelCorr = 1.0f; // coasting fuel cut-off correction - if (CONFIGB(coastingFuelCutEnabled)) { + if (CONFIG(coastingFuelCutEnabled)) { percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); float map = getMap(PASS_ENGINE_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h index a74417f997..861fef4723 100644 --- a/firmware/controllers/algo/obd_error_codes.h +++ b/firmware/controllers/algo/obd_error_codes.h @@ -1927,7 +1927,7 @@ typedef enum { CUSTOM_ERR_6575 = 6575, CUSTOM_ERR_6576 = 6576, CUSTOM_ERR_6577 = 6577, - CUSTOM_ERR_6578 = 6578, + CUSTOM_NULL_ENGINE_PTR = 6578, CUSTOM_DUTY_TOO_LOW = 6579, CUSTOM_ERR_6580 = 6580, @@ -2081,7 +2081,7 @@ typedef enum { CUSTOM_INVALID_ADC = 6720, - CUSTOM_ERR_6721 = 6721, + CUSTOM_INVALID_MODE_SETTING = 6721, CUSTOM_ERR_6722 = 6722, CUSTOM_ERR_6723 = 6723, CUSTOM_ERR_6724 = 6724, diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 8d913fa55e..07f1fde8cf 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -16,14 +16,6 @@ // https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename #include -#define ENUM_16_BITS 20000 - -#define DIGIPOT_COUNT 4 - -#define TRIGGER_SIMULATOR_PIN_COUNT 3 - -#define LOGIC_ANALYZER_CHANNEL_COUNT 4 - // I believe that TunerStudio curve editor has a bug with F32 support // because of that bug we cannot have '1.05' for 5% extra multiplier /** @@ -68,7 +60,7 @@ typedef enum { ROVER_V8 = 10, - MAZDA_323 = 11, + MRE_MIATA_NB2_MTB = 11, MRE_MIATA_NA6 = 12, @@ -189,6 +181,8 @@ typedef enum { PROTEUS = 61, + VW_B6 = 62, + /** * this configuration has as few pins configured as possible */ diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index 41c23f8693..fa02d9f7b1 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -30,7 +30,7 @@ typedef unsigned int time_t; typedef time_t efitimesec_t; /** - * integer time in milliseconds + * integer time in milliseconds (1/1_000 of a second) * 32 bit 4B / 1000 = 4M seconds = 1111.11 hours = 46 days. * Please restart your ECU every 46 days? :) * See getTimeNowUs() @@ -51,10 +51,16 @@ typedef int pid_dt; typedef int64_t efitime_t; /** - * 64 bit time in microseconds, since boot + * 64 bit time in microseconds (1/1_000_000 of a second), since boot */ typedef efitime_t efitimeus_t; +/** + * 64 bit time in milliseconds (1/1_000 of a second), since boot + */ +typedef efitime_t efitimems64_t; + + /** * platform-dependent tick since boot * in case of stm32f4 that's a CPU tick diff --git a/firmware/controllers/core/common_headers.h b/firmware/controllers/core/common_headers.h index aa0056ac64..e78518d2ba 100644 --- a/firmware/controllers/core/common_headers.h +++ b/firmware/controllers/core/common_headers.h @@ -34,12 +34,21 @@ #endif /* __cplusplus */ /** - * reference to configuration parameter + * reference to configuration parameter. */ #define DISPLAY_CONFIG(x) x /** * The main annotation of live data - reference to dynamic state variable * See also 'TS_GET_STRUCT' + * The advantage of Live Data is that there is no need to copy data into tsOutputChannels structure - Live Data is reading exactly + * the same data as actual runtime logic. It's also important to have annotations of the View as close to actual implementation as possible + * to increase the changes of those being in sync. + * + * One day Live Data could be replace with a Domain Specific Language + * One day all Live Data could be provided to TS without data copy to tsOutputChannels - the idea is to have a virtual tsOutputChannels + * where rusEfi would pull data from different memory ranges depending on the requested offset, more or less virtual pages. This could depend + * on the TS bugfix described in https://github.com/rusefi/rusefi/issues/794? + * */ #define DISPLAY_FIELD(x) x /** @@ -68,20 +77,18 @@ #define DECLARE_ENGINE_PTR \ Engine *engine = nullptr; \ engine_configuration_s *engineConfiguration = nullptr; \ - persistent_config_s *config = nullptr; \ - board_configuration_s *boardConfiguration = nullptr; + persistent_config_s *config = nullptr; #define INJECT_ENGINE_REFERENCE(x) \ (x)->engine = engine; \ (x)->engineConfiguration = engineConfiguration; \ - (x)->config = config; \ - (x)->boardConfiguration = boardConfiguration; + (x)->config = config; #define EXPAND_Engine \ engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr; \ persistent_config_s *config = engine->config; \ - board_configuration_s *boardConfiguration = &engineConfiguration->bc; + #ifndef EFI_ACTIVE_CONFIGURATION_IN_FLASH // We store a special changeable copy of configuration is RAM, so we can just compare them diff --git a/firmware/controllers/core/fsio_core.cpp b/firmware/controllers/core/fsio_core.cpp index 221c77874e..f4a08c0038 100644 --- a/firmware/controllers/core/fsio_core.cpp +++ b/firmware/controllers/core/fsio_core.cpp @@ -254,7 +254,7 @@ bool LECalculator::processElement(LEElement *element DECLARE_ENGINE_PARAMETER_SU float humanIndex = pop(LE_METHOD_FSIO_SETTING); int index = (int) humanIndex - 1; if (index >= 0 && index < FSIO_COMMAND_COUNT) { - push(element->action, CONFIGB(fsio_setting)[index]); + push(element->action, CONFIG(fsio_setting)[index]); } else { push(element->action, NAN); } diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index 8b358f3a9c..bcbc454787 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -229,7 +229,7 @@ static void setFsioOutputPin(const char *indexStr, const char *pinName) { scheduleMsg(logger, "invalid pin name [%s]", pinName); return; } - CONFIGB(fsioOutputPins)[index] = pin; + CONFIG(fsioOutputPins)[index] = pin; scheduleMsg(logger, "FSIO output pin #%d [%s]", (index + 1), hwPortname(pin)); scheduleMsg(logger, "please writeconfig and reboot for pin to take effect"); showFsioInfo(); @@ -242,13 +242,13 @@ static void setFsioOutputPin(const char *indexStr, const char *pinName) { * index is between zero and LE_COMMAND_LENGTH-1 */ void setFsioExt(int index, brain_pin_e pin, const char * formula, int pwmFrequency DECLARE_CONFIG_PARAMETER_SUFFIX) { - CONFIGB(fsioOutputPins)[index] = pin; + CONFIG(fsioOutputPins)[index] = pin; int len = strlen(formula); if (len >= LE_COMMAND_LENGTH) { return; } strcpy(config->fsioFormulas[index], formula); - CONFIGB(fsioFrequency)[index] = pwmFrequency; + CONFIG(fsioFrequency)[index] = pwmFrequency; } void setFsio(int index, brain_pin_e pin, const char * exp DECLARE_CONFIG_PARAMETER_SUFFIX) { @@ -260,7 +260,7 @@ void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { const char *formula = config->fsioFormulas[i]; LEElement *logic = userPool.parseExpression(formula); - brain_pin_e brainPin = CONFIGB(fsioOutputPins)[i]; + brain_pin_e brainPin = CONFIG(fsioOutputPins)[i]; if (brainPin != GPIO_UNASSIGNED && logic == NULL) { warning(CUSTOM_FSIO_PARSING, "parsing [%s]", formula); } @@ -321,7 +321,7 @@ static const char *getGpioPinName(int index) { float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { if (state.fsioLogics[index] == NULL) { - warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(CONFIGB(fsioOutputPins)[index])); + warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(CONFIG(fsioOutputPins)[index])); return NAN; } else { return calc.getValue2(engine->fsioState.fsioLastValue[index], state.fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX); @@ -332,12 +332,12 @@ float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { * @param index from zero for (FSIO_COMMAND_COUNT - 1) */ static void handleFsio(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { - if (CONFIGB(fsioOutputPins)[index] == GPIO_UNASSIGNED) { + if (CONFIG(fsioOutputPins)[index] == GPIO_UNASSIGNED) { engine->fsioState.fsioLastValue[index] = NAN; return; } - bool isPwmMode = CONFIGB(fsioFrequency)[index] != NO_PWM; + bool isPwmMode = CONFIG(fsioFrequency)[index] != NO_PWM; float fvalue = getFsioOutputValue(index PASS_ENGINE_PARAMETER_SUFFIX); engine->fsioState.fsioLastValue[index] = fvalue; @@ -410,11 +410,11 @@ static void setFsioFrequency(int index, int frequency) { scheduleMsg(logger, "invalid FSIO index: %d", index); return; } - CONFIGB(fsioFrequency)[index] = frequency; + CONFIG(fsioFrequency)[index] = frequency; if (frequency == 0) { - scheduleMsg(logger, "FSIO output #%d@%s set to on/off mode", index + 1, hwPortname(CONFIGB(fsioOutputPins)[index])); + scheduleMsg(logger, "FSIO output #%d@%s set to on/off mode", index + 1, hwPortname(CONFIG(fsioOutputPins)[index])); } else { - scheduleMsg(logger, "Setting FSIO frequency %dHz on #%d@%s", frequency, index + 1, hwPortname(CONFIGB(fsioOutputPins)[index])); + scheduleMsg(logger, "Setting FSIO frequency %dHz on #%d@%s", frequency, index + 1, hwPortname(CONFIG(fsioOutputPins)[index])); } } #endif /* EFI_PROD_CODE */ @@ -449,23 +449,23 @@ void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } #if EFI_FUEL_PUMP - if (CONFIGB(fuelPumpPin) != GPIO_UNASSIGNED) { + if (CONFIG(fuelPumpPin) != GPIO_UNASSIGNED) { setPinState("pump", &enginePins.fuelPumpRelay, fuelPumpLogic PASS_ENGINE_PARAMETER_SUFFIX); } #endif /* EFI_FUEL_PUMP */ #if EFI_MAIN_RELAY_CONTROL - if (CONFIGB(mainRelayPin) != GPIO_UNASSIGNED) + if (CONFIG(mainRelayPin) != GPIO_UNASSIGNED) setPinState("main_relay", &enginePins.mainRelay, mainRelayLogic PASS_ENGINE_PARAMETER_SUFFIX); #else /* EFI_MAIN_RELAY_CONTROL */ /** * main relay is always on if ECU is on, that's a good enough initial implementation */ - if (CONFIGB(mainRelayPin) != GPIO_UNASSIGNED) + if (CONFIG(mainRelayPin) != GPIO_UNASSIGNED) enginePins.mainRelay.setValue(true); #endif /* EFI_MAIN_RELAY_CONTROL */ - if (CONFIGB(starterRelayPin) != GPIO_UNASSIGNED) + if (CONFIG(starterRelayPin) != GPIO_UNASSIGNED) setPinState("starter_relay", &enginePins.starterRelay, starterRelayLogic PASS_ENGINE_PARAMETER_SUFFIX); /** @@ -475,15 +475,15 @@ void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) { */ enginePins.o2heater.setValue(engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE)); - if (CONFIGB(acRelayPin) != GPIO_UNASSIGNED) { + if (CONFIG(acRelayPin) != GPIO_UNASSIGNED) { setPinState("A/C", &enginePins.acRelay, acRelayLogic PASS_ENGINE_PARAMETER_SUFFIX); } -// if (CONFIGB(alternatorControlPin) != GPIO_UNASSIGNED) { +// if (CONFIG(alternatorControlPin) != GPIO_UNASSIGNED) { // setPinState("alternator", &enginePins.alternatorField, alternatorLogic, engine PASS_ENGINE_PARAMETER_SUFFIX); // } - if (CONFIGB(fanPin) != GPIO_UNASSIGNED) { + if (CONFIG(fanPin) != GPIO_UNASSIGNED) { setPinState("fan", &enginePins.fanRelay, radiatorFanLogic PASS_ENGINE_PARAMETER_SUFFIX); } @@ -573,14 +573,14 @@ static void showFsioInfo(void) { * is the fact that the target audience is more software developers */ scheduleMsg(logger, "FSIO #%d [%s] at %s@%dHz value=%.2f", (i + 1), exp, - hwPortname(CONFIGB(fsioOutputPins)[i]), CONFIGB(fsioFrequency)[i], + hwPortname(CONFIG(fsioOutputPins)[i]), CONFIG(fsioFrequency)[i], engine->fsioState.fsioLastValue[i]); // scheduleMsg(logger, "user-defined #%d value=%.2f", i, engine->engineConfigurationPtr2->fsioLastValue[i]); showFsio(NULL, state.fsioLogics[i]); } } for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { - float v = CONFIGB(fsio_setting)[i]; + float v = CONFIG(fsio_setting)[i]; if (!cisnan(v)) { scheduleMsg(logger, "user property #%d: %.2f", i + 1, v); } @@ -604,7 +604,7 @@ static void setFsioSetting(float humanIndexF, float value) { scheduleMsg(logger, "invalid FSIO index: %d", (int)humanIndexF); return; } - engineConfiguration->bc.fsio_setting[index] = value; + engineConfiguration->fsio_setting[index] = value; showFsioInfo(); #endif } @@ -674,20 +674,20 @@ void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { alternatorLogic = sysPool.parseExpression(ALTERNATOR_LOGIC); #if EFI_MAIN_RELAY_CONTROL - if (CONFIGB(mainRelayPin) != GPIO_UNASSIGNED) + if (CONFIG(mainRelayPin) != GPIO_UNASSIGNED) mainRelayLogic = sysPool.parseExpression(MAIN_RELAY_LOGIC); #endif /* EFI_MAIN_RELAY_CONTROL */ - if (CONFIGB(starterRelayPin) != GPIO_UNASSIGNED) + if (CONFIG(starterRelayPin) != GPIO_UNASSIGNED) starterRelayLogic = sysPool.parseExpression(STARTER_RELAY_LOGIC); #if EFI_PROD_CODE for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { - brain_pin_e brainPin = CONFIGB(fsioOutputPins)[i]; + brain_pin_e brainPin = CONFIG(fsioOutputPins)[i]; if (brainPin != GPIO_UNASSIGNED) { - int frequency = CONFIGB(fsioFrequency)[i]; + int frequency = CONFIG(fsioFrequency)[i]; if (frequency == 0) { - enginePins.fsioOutputs[i].initPin(getGpioPinName(i), CONFIGB(fsioOutputPins)[i], &DEFAULT_OUTPUT); + enginePins.fsioOutputs[i].initPin(getGpioPinName(i), CONFIG(fsioOutputPins)[i], &DEFAULT_OUTPUT); } else { startSimplePwmExt(&fsioPwm[i], "FSIOpwm", &engine->executor, @@ -739,24 +739,24 @@ extern EnginePins enginePins; // "Limp-mode" implementation for some RAM-limited configs without FSIO void runHardcodedFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // see MAIN_RELAY_LOGIC - if (CONFIGB(mainRelayPin) != GPIO_UNASSIGNED) { + if (CONFIG(mainRelayPin) != GPIO_UNASSIGNED) { enginePins.mainRelay.setValue((getTimeNowSeconds() < 2) || (getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) > 5) || engine->isInShutdownMode()); } // see STARTER_RELAY_LOGIC - if (CONFIGB(starterRelayPin) != GPIO_UNASSIGNED) { + if (CONFIG(starterRelayPin) != GPIO_UNASSIGNED) { enginePins.starterRelay.setValue(engine->rpmCalculator.getRpm() < engineConfiguration->cranking.rpm); } // see FAN_CONTROL_LOGIC - if (CONFIGB(fanPin) != GPIO_UNASSIGNED) { + if (CONFIG(fanPin) != GPIO_UNASSIGNED) { enginePins.fanRelay.setValue((enginePins.fanRelay.getLogicValue() && (getCoolantTemperature() > engineConfiguration->fanOffTemperature)) || (getCoolantTemperature() > engineConfiguration->fanOnTemperature) || engine->isCltBroken); } // see AC_RELAY_LOGIC - if (CONFIGB(acRelayPin) != GPIO_UNASSIGNED) { + if (CONFIG(acRelayPin) != GPIO_UNASSIGNED) { enginePins.acRelay.setValue(getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE) && engine->rpmCalculator.getRpm() > 850); } // see FUEL_PUMP_LOGIC - if (CONFIGB(fuelPumpPin) != GPIO_UNASSIGNED) { + if (CONFIG(fuelPumpPin) != GPIO_UNASSIGNED) { enginePins.fuelPumpRelay.setValue((getTimeNowSeconds() < engineConfiguration->startUpFuelPumpDuration) || (engine->rpmCalculator.getRpm() > 0)); } diff --git a/firmware/controllers/core/fsio_impl.h b/firmware/controllers/core/fsio_impl.h index 37fd5d3153..4ef5cd8f82 100644 --- a/firmware/controllers/core/fsio_impl.h +++ b/firmware/controllers/core/fsio_impl.h @@ -3,11 +3,10 @@ * @brief FSIO as it's used for GPIO * * @date Oct 5, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef LE_FUNCTIONS_H_ -#define LE_FUNCTIONS_H_ +#pragma once #include "fsio_core.h" #include "engine.h" @@ -43,4 +42,3 @@ void runHardcodedFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE); ValueProvider3D *getFSIOTable(int index); -#endif /* LE_FUNCTIONS_H_ */ diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 202abfe541..92e020649a 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -23,44 +23,49 @@ #include "global.h" #include "os_access.h" -#if EFI_SENSOR_CHART -#include "sensor_chart.h" -#endif -#include "engine_configuration.h" #include "trigger_central.h" #include "engine_controller.h" #include "fsio_core.h" #include "fsio_impl.h" #include "idle_thread.h" +#include "advance_map.h" #include "rpm_calculator.h" #include "main_trigger_callback.h" #include "io_pins.h" #include "flash_main.h" -#if EFI_TUNER_STUDIO -#include "tunerstudio.h" -#endif #include "injector_central.h" #include "os_util.h" #include "engine_math.h" -#if EFI_LOGIC_ANALYZER -#include "logic_analyzer.h" -#endif #include "allsensors.h" #include "electronic_throttle.h" #include "map_averaging.h" #include "malfunction_central.h" #include "malfunction_indicator.h" #include "engine.h" -#include "algo.h" +#include "speed_density.h" #include "local_version_holder.h" #include "alternator_controller.h" #include "fuel_math.h" #include "settings.h" #include "aux_pid.h" +#include "spark_logic.h" +#include "aux_valves.h" #include "accelerometer.h" #include "counter64.h" #include "perf_trace.h" +#if EFI_SENSOR_CHART +#include "sensor_chart.h" +#endif + +#if EFI_TUNER_STUDIO +#include "tunerstudio.h" +#endif + +#if EFI_LOGIC_ANALYZER +#include "logic_analyzer.h" +#endif + #if HAL_USE_ADC #include "AdcConfiguration.h" #endif /* HAL_USE_ADC */ @@ -94,8 +99,13 @@ EXTERN_ENGINE; -// this method is used by real firmware and simulator and unit test -void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { +void initDataStructures(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + initFuelMap(PASS_ENGINE_PARAMETER_SIGNATURE); + initTimingMap(PASS_ENGINE_PARAMETER_SIGNATURE); + initSpeedDensity(PASS_ENGINE_PARAMETER_SIGNATURE); +} + +static void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { #if !EFI_UNIT_TEST initSensors(); #endif /* EFI_UNIT_TEST */ @@ -157,7 +167,7 @@ class PeriodicSlowController : public PeriodicTimerController { int getPeriodMs() override { // we need at least protection from zero value while resetting configuration - int periodMs = maxI(50, CONFIGB(generalPeriodicThreadPeriodMs)); + int periodMs = maxI(50, CONFIG(generalPeriodicThreadPeriodMs)); return periodMs; } }; @@ -207,7 +217,7 @@ static Overflow64Counter halTime; */ //todo: macro to save method invocation efitimeus_t getTimeNowUs(void) { - ScopePerf perf(PE::ScheduleByAngle); + ScopePerf perf(PE::GetTimeNowUs); return getTimeNowNt() / (CORE_CLOCK / 1000000); } @@ -298,8 +308,6 @@ static void resetAccel(void) { } } -static int previousSecond; - #if ENABLE_PERF_TRACE void irqEnterHook(void) { @@ -389,7 +397,7 @@ static void printAnalogChannelInfoExt(const char *name, adc_channel_e hwChannel, } if (fastAdc.isHwUsed(hwChannel)) { - scheduleMsg(&logger, "fast enabled=%s", boolToString(CONFIGB(isFastAdcEnabled))); + scheduleMsg(&logger, "fast enabled=%s", boolToString(CONFIG(isFastAdcEnabled))); } float voltage = adcVoltage * dividerCoeff; @@ -659,13 +667,29 @@ static void getKnockInfo(void) { engine->printKnockState(); } +#endif /* EFI_UNIT_TEST */ -// this method is used by real firmware and simulator but not unit tests +// this method is used by real firmware and simulator and unit test void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { + initInterpolation(sharedLogger); + #if EFI_SIMULATOR printf("commonInitEngineController\n"); #endif + +#if !EFI_UNIT_TEST initConfigActions(); +#endif /* EFI_UNIT_TEST */ + +#if EFI_ENGINE_CONTROL + /** + * This has to go after 'initInjectorCentral' in order to + * properly detect un-assigned output pins + */ + prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE); +#endif /* EFI_PROD_CODE && EFI_ENGINE_CONTROL */ + + #if EFI_ENABLE_MOCK_ADC initMockVoltage(); #endif /* EFI_ENABLE_MOCK_ADC */ @@ -674,10 +698,6 @@ void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S initSensorChart(); #endif /* EFI_SENSOR_CHART */ -#if EFI_PROD_CODE || EFI_SIMULATOR - // todo: this is a mess, remove code duplication with simulator - initSettings(); -#endif #if EFI_TUNER_STUDIO if (engineConfiguration->isTunerStudioEnabled) { @@ -685,25 +705,55 @@ void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S } #endif /* EFI_TUNER_STUDIO */ +#if EFI_PROD_CODE || EFI_SIMULATOR + initSettings(); + if (hasFirmwareError()) { return; } +#endif + mostCommonInitEngineController(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); + +#if EFI_SHAFT_POSITION_INPUT + /** + * there is an implicit dependency on the fact that 'tachometer' listener is the 1st listener - this case + * other listeners can access current RPM value + */ + initRpmCalculator(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); +#endif /* EFI_SHAFT_POSITION_INPUT */ + +#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || EFI_SIMULATOR || EFI_UNIT_TEST + if (CONFIG(isEngineControlEnabled)) { + initAuxValves(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); + /** + * This method adds trigger listener which actually schedules ignition + */ + initSparkLogic(sharedLogger); + initMainEventListener(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); + } +#endif /* EFI_ENGINE_CONTROL */ + } +#if !EFI_UNIT_TEST + void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_SIMULATOR printf("initEngineContoller\n"); #endif addConsoleAction("analoginfo", printAnalogInfo); + +#if EFI_PROD_CODE && EFI_ENGINE_CONTROL + initInjectorCentral(sharedLogger); +#endif /* EFI_PROD_CODE && EFI_ENGINE_CONTROL */ + commonInitEngineController(sharedLogger); #if EFI_PROD_CODE initPwmGenerator(); #endif - initAlgo(sharedLogger); - #if EFI_LOGIC_ANALYZER if (engineConfiguration->isWaveAnalyzerEnabled) { initWaveAnalyzer(sharedLogger); @@ -718,19 +768,6 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) #endif /* EFI_CJ125 */ -#if EFI_SHAFT_POSITION_INPUT - /** - * there is an implicit dependency on the fact that 'tachometer' listener is the 1st listener - this case - * other listeners can access current RPM value - */ - initRpmCalculator(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); -#endif /* EFI_SHAFT_POSITION_INPUT */ - -#if EFI_PROD_CODE && EFI_ENGINE_CONTROL - initInjectorCentral(sharedLogger); -#endif /* EFI_PROD_CODE && EFI_ENGINE_CONTROL */ - -// multiple issues with this initMapAdjusterThread(); // periodic events need to be initialized after fuel&spark pins to avoid a warning initPeriodicEvents(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -740,14 +777,6 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) engineStateBlinkingTask.Start(); -#if EFI_PROD_CODE && EFI_ENGINE_CONTROL - /** - * This has to go after 'initInjectorCentral' and 'initInjectorCentral' in order to - * properly detect un-assigned output pins - */ - prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE); -#endif /* EFI_PROD_CODE && EFI_ENGINE_CONTROL */ - #if EFI_PWM_TESTER initPwmTester(); #endif /* EFI_PWM_TESTER */ @@ -768,15 +797,6 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) initEgoAveraging(PASS_ENGINE_PARAMETER_SIGNATURE); -#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT - if (CONFIGB(isEngineControlEnabled)) { - /** - * This method initialized the main listener which actually runs injectors & ignition - */ - initMainEventListener(sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); - } -#endif /* EFI_ENGINE_CONTROL */ - if (engineConfiguration->externalKnockSenseAdc != EFI_ADC_NONE) { addConsoleAction("knockinfo", getKnockInfo); } @@ -798,7 +818,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) // help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail // linking process which is the way to raise the alarm #ifndef RAM_UNUSED_SIZE -#define RAM_UNUSED_SIZE 2500 +#define RAM_UNUSED_SIZE 14000 #endif #ifndef CCM_UNUSED_SIZE #define CCM_UNUSED_SIZE 4600 @@ -819,6 +839,6 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20191206; + return 20191222; } #endif /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/engine_controller.h b/firmware/controllers/engine_controller.h index 2b0e402e25..307f06cab2 100644 --- a/firmware/controllers/engine_controller.h +++ b/firmware/controllers/engine_controller.h @@ -3,20 +3,19 @@ * @brief Controllers package entry point header * * @date Feb 7, 2013 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #pragma once #include "global.h" -#include "engine_configuration.h" -#include "engine.h" char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer); void initPeriodicEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE); void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); -void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); + +void initDataStructures(DECLARE_ENGINE_PARAMETER_SIGNATURE); #if EFI_ENABLE_MOCK_ADC void setMockVoltage(int hwChannel, float voltage DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 647a3ee6c1..35ee53e240 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -5,7 +5,7 @@ * See http://rusefi.com/docs/html/ * * @date Feb 7, 2013 - * @author Andrey Belomutskiy, (c) 2012-2018 + * @author Andrey Belomutskiy, (c) 2012-2019 * * This file is part of rusEfi - see http://rusefi.com * @@ -40,21 +40,18 @@ #include "advance_map.h" #include "allsensors.h" #include "cyclic_buffer.h" -#include "histogram.h" #include "fuel_math.h" -#include "histogram.h" #include "cdm_ion_sense.h" #include "engine_controller.h" #include "efi_gpio.h" #if EFI_PROD_CODE #include "os_util.h" -#endif /* EFI_HISTOGRAMS */ +#endif /* EFI_PROD_CODE */ #include "local_version_holder.h" #include "event_queue.h" #include "engine.h" #include "perf_trace.h" -#include "aux_valves.h" #include "backup_ram.h" EXTERN_ENGINE @@ -342,7 +339,7 @@ static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (GET_RPM_VALUE < CONFIG(fuelClosedLoopRpmThreshold) || getCoolantTemperature() < CONFIG(fuelClosedLoopCltThreshold) || getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(fuelClosedLoopTpsThreshold) || - ENGINE(sensors.currentAfr) < CONFIGB(fuelClosedLoopAfrLowThreshold) || + ENGINE(sensors.currentAfr) < CONFIG(fuelClosedLoopAfrLowThreshold) || ENGINE(sensors.currentAfr) > engineConfiguration->fuelClosedLoopAfrHighThreshold) { engine->engineState.running.pidCorrection = 0; fuelPid.reset(); @@ -406,16 +403,6 @@ static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIn } } -#if EFI_HISTOGRAMS -static histogram_s mainLoopHistogram; -#endif /* EFI_HISTOGRAMS */ - -void showMainHistogram(void) { -#if EFI_HISTOGRAMS - printHistogram(logger, &mainLoopHistogram); -#endif /* EFI_HISTOGRAMS */ -} - #if EFI_PROD_CODE /** * this field is used as an Expression in IAR debugger @@ -427,7 +414,7 @@ uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT; * This is the main trigger event handler. * Both injection and ignition are controlled from this method. */ -void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex DECLARE_ENGINE_PARAMETER_SUFFIX) { +static void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex DECLARE_ENGINE_PARAMETER_SUFFIX) { ScopePerf perf(PE::MainTriggerCallback); (void) ckpSignalType; @@ -440,10 +427,10 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D */ return; } - efiAssertVoid(CUSTOM_STACK_6629, getCurrentRemainingStack() > 128, "lowstck#2"); + efiAssertVoid(CUSTOM_STACK_6629, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2a"); #if EFI_CDM_INTEGRATION - if (trgEventIndex == 0 && CONFIGB(cdmInputPin) != GPIO_UNASSIGNED) { + if (trgEventIndex == 0 && CONFIG(cdmInputPin) != GPIO_UNASSIGNED) { int cdmKnockValue = getCurrentCdmValue(engine->triggerCentral.triggerState.getTotalRevolutionCounter()); engine->knockLogic(cdmKnockValue); } @@ -484,10 +471,6 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D warning(CUSTOM_SKIPPING_STROKE, "skipping stroke due to rpm=%d", rpm); } -#if EFI_HISTOGRAMS && EFI_PROD_CODE - int beforeCallback = hal_lld_get_counter_value(); -#endif - if (trgEventIndex == 0) { if (HAVE_CAM_INPUT()) { engine->triggerCentral.validateCamVvtCounters(); @@ -527,11 +510,6 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D * For spark we schedule both start of coil charge and actual spark based on trigger angle */ onTriggerEventSparkLogic(limitedSpark, trgEventIndex, rpm PASS_ENGINE_PARAMETER_SUFFIX); -#if EFI_HISTOGRAMS - int diff = hal_lld_get_counter_value() - beforeCallback; - if (diff > 0) - hsAdd(&mainLoopHistogram, diff); -#endif /* EFI_HISTOGRAMS */ if (trgEventIndex == 0) { ENGINE(m.mainTriggerCallbackTime) = getTimeNowLowerNt() - ENGINE(m.beforeMainTrigger); @@ -609,32 +587,20 @@ void updatePrimeInjectionPulseState(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #include "engine_sniffer.h" #endif -static void showTriggerHistogram(void) { - printAllCallbacksHistogram(); - showMainHistogram(); -#if EFI_ENGINE_SNIFFER - showWaveChartHistogram(); -#endif -} - static void showMainInfo(Engine *engine) { #if EFI_PROD_CODE int rpm = GET_RPM(); float el = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE); scheduleMsg(logger, "rpm %d engine_load %.2f", rpm, el); scheduleMsg(logger, "fuel %.2fms timing %.2f", getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX), engine->engineState.timingAdvance); -#endif +#endif /* EFI_PROD_CODE */ } void initMainEventListener(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { logger = sharedLogger; efiAssertVoid(CUSTOM_ERR_6631, engine!=NULL, "null engine"); - initSparkLogic(logger); - - initAuxValves(logger PASS_ENGINE_PARAMETER_SUFFIX); #if EFI_PROD_CODE - addConsoleAction("performanceinfo", showTriggerHistogram); addConsoleActionP("maininfo", (VoidPtr) showMainInfo, engine); printMsg(logger, "initMainLoop: %d", currentTimeMillis()); @@ -642,10 +608,6 @@ void initMainEventListener(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX printMsg(logger, "!!!!!!!!!!!!!!!!!!! injection disabled"); #endif -#if EFI_HISTOGRAMS - initHistogram(&mainLoopHistogram, "main callback"); -#endif /* EFI_HISTOGRAMS */ - addTriggerEventListener(mainTriggerCallback, "main loop", engine); // We start prime injection pulse at the early init stage - don't wait for the engine to start spinning! diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.h b/firmware/controllers/engine_cycle/main_trigger_callback.h index 2c965aab61..884ebaf8e2 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.h +++ b/firmware/controllers/engine_cycle/main_trigger_callback.h @@ -4,32 +4,23 @@ * * * @date Feb 9, 2013 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef MAIN_LOOP_H_ -#define MAIN_LOOP_H_ +#pragma once #include "engine.h" #include "event_registry.h" void initMainEventListener(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); -void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECLARE_ENGINE_PARAMETER_SUFFIX); -int isIgnitionTimingError(void); void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE); -void showMainHistogram(void); - void startSimultaniousInjection(Engine *engine); void endSimultaniousInjection(InjectionEvent *event); void seTurnPinHigh(InjectionEvent *event); void seTurnPinLow(InjectionEvent *event); -float getFuel(int rpm, float key); - // reset injection switch counter if the engine started spinning void updatePrimeInjectionPulseState(DECLARE_ENGINE_PARAMETER_SIGNATURE); - -#endif /* MAIN_LOOP_H_ */ diff --git a/firmware/controllers/engine_cycle/map_averaging.cpp b/firmware/controllers/engine_cycle/map_averaging.cpp index 070408753a..6e7b354b35 100644 --- a/firmware/controllers/engine_cycle/map_averaging.cpp +++ b/firmware/controllers/engine_cycle/map_averaging.cpp @@ -211,7 +211,7 @@ static void endAveraging(void *arg) { static void applyMapMinBufferLength(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // check range - mapMinBufferLength = maxI(minI(CONFIGB(mapMinBufferLength), MAX_MAP_BUFFER_LENGTH), 1); + mapMinBufferLength = maxI(minI(CONFIG(mapMinBufferLength), MAX_MAP_BUFFER_LENGTH), 1); // reset index averagedMapBufIdx = 0; // fill with maximum values @@ -279,14 +279,14 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType, return; } - if (CONFIGB(mapMinBufferLength) != mapMinBufferLength) { + if (CONFIG(mapMinBufferLength) != mapMinBufferLength) { applyMapMinBufferLength(PASS_ENGINE_PARAMETER_SIGNATURE); } measurementsPerRevolution = measurementsPerRevolutionCounter; measurementsPerRevolutionCounter = 0; - int samplingCount = CONFIGB(measureMapOnlyInOneCylinder) ? 1 : engineConfiguration->specs.cylindersCount; + int samplingCount = CONFIG(measureMapOnlyInOneCylinder) ? 1 : engineConfiguration->specs.cylindersCount; for (int i = 0; i < samplingCount; i++) { angle_t samplingStart = ENGINE(engineState.mapAveragingStart[i]); @@ -359,7 +359,11 @@ void initMapAveraging(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_SHAFT_POSITION_INPUT addTriggerEventListener(&mapAveragingTriggerCallback, "MAP averaging", engine); #endif /* EFI_SHAFT_POSITION_INPUT */ + +#if !EFI_UNIT_TEST addConsoleAction("faststat", showMapStats); +#endif /* EFI_UNIT_TEST */ + applyMapMinBufferLength(PASS_ENGINE_PARAMETER_SIGNATURE); } diff --git a/firmware/controllers/engine_cycle/rpm_calculator.cpp b/firmware/controllers/engine_cycle/rpm_calculator.cpp index 980e3eb3ba..1709ea55fb 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.cpp +++ b/firmware/controllers/engine_cycle/rpm_calculator.cpp @@ -96,7 +96,7 @@ RpmCalculator::RpmCalculator() { // which we cannot provide inside this parameter-less constructor. need a solution for this minor mess // we need this initial to have not_running at first invocation - lastRpmEventTimeNt = (efitime_t) -10 * US2NT(US_PER_SECOND_LL); + lastRpmEventTimeNt = (efitick_t) -10 * US2NT(US_PER_SECOND_LL); } /** @@ -200,8 +200,8 @@ void RpmCalculator::setStopSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) { setStopped(PASS_ENGINE_PARAMETER_SIGNATURE); } -void RpmCalculator::setSpinningUp(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { - if (!CONFIGB(isFasterEngineSpinUpEnabled)) +void RpmCalculator::setSpinningUp(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { + if (!CONFIG(isFasterEngineSpinUpEnabled)) return; // Only a completely stopped and non-spinning engine can enter the spinning-up state. if (isStopped(PASS_ENGINE_PARAMETER_SIGNATURE) && !isSpinning) { @@ -229,7 +229,7 @@ void RpmCalculator::setSpinningUp(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFI void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) { efitick_t nowNt = getTimeNowNt(); - efiAssertVoid(CUSTOM_ERR_6632, getCurrentRemainingStack() > 256, "lowstckRCL"); + efiAssertVoid(CUSTOM_ERR_6632, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstckRCL"); RpmCalculator *rpmState = &engine->rpmCalculator; @@ -239,7 +239,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, bool hadRpmRecently = rpmState->checkIfSpinning(nowNt PASS_ENGINE_PARAMETER_SUFFIX); if (hadRpmRecently) { - efitime_t diffNt = nowNt - rpmState->lastRpmEventTimeNt; + efitick_t diffNt = nowNt - rpmState->lastRpmEventTimeNt; /** * Four stroke cycle is two crankshaft revolutions * @@ -296,9 +296,11 @@ static char rpmBuffer[_MAX_FILLER]; * digital sniffer. */ static void onTdcCallback(Engine *engine) { +#if EFI_UNIT_TEST if (!engine->needTdcCallback) { return; } +#endif /* EFI_UNIT_TEST */ EXPAND_Engine; itoa10(rpmBuffer, GET_RPM()); #if EFI_ENGINE_SNIFFER @@ -315,6 +317,7 @@ static void tdcMarkCallback(trigger_event_e ckpSignalType, (void) ckpSignalType; bool isTriggerSynchronizationPoint = index0 == 0; if (isTriggerSynchronizationPoint && ENGINE(isEngineChartEnabled)) { + // two instances of scheduling_s are needed to properly handle event overlap int revIndex2 = getRevolutionCounter() % 2; int rpm = GET_RPM(); // todo: use tooth event-based scheduling, not just time-based scheduling @@ -329,8 +332,8 @@ static void tdcMarkCallback(trigger_event_e ckpSignalType, /** * @return Current crankshaft angle, 0 to 720 for four-stroke */ -float getCrankshaftAngleNt(efitime_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX) { - efitime_t timeSinceZeroAngleNt = timeNt +float getCrankshaftAngleNt(efitick_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX) { + efitick_t timeSinceZeroAngleNt = timeNt - engine->rpmCalculator.lastRpmEventTimeNt; /** diff --git a/firmware/controllers/engine_cycle/rpm_calculator.h b/firmware/controllers/engine_cycle/rpm_calculator.h index e7be215c06..551ec8b72f 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.h +++ b/firmware/controllers/engine_cycle/rpm_calculator.h @@ -3,11 +3,10 @@ * @brief Shaft position sensor(s) decoder header * * @date Jan 1, 2013 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef RPM_REPORTER_H_ -#define RPM_REPORTER_H_ +#pragma once #include "globalaccess.h" #include "scheduler.h" @@ -74,7 +73,7 @@ public: /** * Should be called on every trigger event when the engine is just starting to spin up. */ - void setSpinningUp(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX); + void setSpinningUp(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX); /** * Called if the synchronization is lost due to a trigger timeout. */ @@ -116,7 +115,7 @@ public: * NaN while engine is not spinning */ volatile floatus_t oneDegreeUs = NAN; - volatile efitime_t lastRpmEventTimeNt = 0; + volatile efitick_t lastRpmEventTimeNt = 0; private: /** * Should be called once we've realized engine is not spinning any more. @@ -156,7 +155,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECL */ void initRpmCalculator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); -float getCrankshaftAngleNt(efitime_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX); +float getCrankshaftAngleNt(efitick_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX); #define getRevolutionCounter() ENGINE(rpmCalculator.getRevolutionCounterM()) @@ -168,4 +167,3 @@ float getCrankshaftAngleNt(efitime_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX); void scheduleByAngle(scheduling_s *timer, angle_t angle, schfunc_t callback, void *param DECLARE_ENGINE_PARAMETER_SUFFIX); -#endif /* RPM_REPORTER_H_ */ diff --git a/firmware/controllers/engine_cycle/spark_logic.h b/firmware/controllers/engine_cycle/spark_logic.h index 914bf332ae..0a740c2a30 100644 --- a/firmware/controllers/engine_cycle/spark_logic.h +++ b/firmware/controllers/engine_cycle/spark_logic.h @@ -2,7 +2,7 @@ * @file spark_logic.h * * @date Sep 15, 2016 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #pragma once @@ -18,6 +18,8 @@ int getNumberOfSparks(ignition_mode_e mode DECLARE_ENGINE_PARAMETER_SUFFIX); percent_t getCoilDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX); void initializeIgnitionActions(DECLARE_ENGINE_PARAMETER_SIGNATURE); +int isIgnitionTimingError(void); + #define TRIGGER_EVENT_UNDEFINED -1 bool scheduleOrQueue(AngleBasedEvent *event, uint32_t trgEventIndex, diff --git a/firmware/controllers/flash_main.cpp b/firmware/controllers/flash_main.cpp index cc46897a04..02473d8ce4 100644 --- a/firmware/controllers/flash_main.cpp +++ b/firmware/controllers/flash_main.cpp @@ -134,7 +134,7 @@ static persisted_configuration_state_e doReadConfiguration(flashaddr_t address, * connectivity so no console output here */ persisted_configuration_state_e readConfiguration(Logging * logger) { - efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 256, "read f", PC_ERROR); + efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "read f", PC_ERROR); persisted_configuration_state_e result = doReadConfiguration(FLASH_ADDR, logger); if (result != PC_OK) { printMsg(logger, "Reading second configuration copy"); diff --git a/firmware/controllers/gauges/lcd_controller.cpp b/firmware/controllers/gauges/lcd_controller.cpp index d01aa69617..6e9ca2c70c 100644 --- a/firmware/controllers/gauges/lcd_controller.cpp +++ b/firmware/controllers/gauges/lcd_controller.cpp @@ -219,7 +219,7 @@ static void showLine(lcd_line_e line, int screenY) { #if EFI_FILE_LOGGING { char sdState; - if (CONFIGB(isSdCardEnabled)) { + if (CONFIG(isSdCardEnabled)) { sdState = isSdCardAlive() ? 'L' : 'n'; } else { sdState = 'D'; diff --git a/firmware/controllers/gauges/malfunction_central.cpp b/firmware/controllers/gauges/malfunction_central.cpp index 310d10116a..a009cd49c5 100644 --- a/firmware/controllers/gauges/malfunction_central.cpp +++ b/firmware/controllers/gauges/malfunction_central.cpp @@ -53,8 +53,7 @@ void setError(bool isError, obd_code_e errorCode) { void getErrorCodes(error_codes_set_s * copy) { copy->count = error_codes_set.count; - for (int i = 0; i < copy->count; i++) - copy->error_codes[i] = error_codes_set.error_codes[i]; + copyArray(copy->error_codes, error_codes_set.error_codes); } bool hasErrorCodes(void) { diff --git a/firmware/controllers/gauges/malfunction_indicator.cpp b/firmware/controllers/gauges/malfunction_indicator.cpp index 83684c0256..bda744dade 100644 --- a/firmware/controllers/gauges/malfunction_indicator.cpp +++ b/firmware/controllers/gauges/malfunction_indicator.cpp @@ -84,10 +84,10 @@ class MILController : public PeriodicController { public: MILController() : PeriodicController("MFIndicator") { } private: - void PeriodicTask(efitime_t nowNt) override { + void PeriodicTask(efitick_t nowNt) override { UNUSED(nowNt); - if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < US2NT(MS2US(500))) { + if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < MS2NT(500)) { enginePins.checkEnginePin.setValue(1); chThdSleepMilliseconds(500); enginePins.checkEnginePin.setValue(0); @@ -114,7 +114,7 @@ static void testMil(void) { #endif /* TEST_MIL_CODE */ bool isMilEnabled() { - return CONFIGB(malfunctionIndicatorPin) != GPIO_UNASSIGNED; + return CONFIG(malfunctionIndicatorPin) != GPIO_UNASSIGNED; } void initMalfunctionIndicator(void) { diff --git a/firmware/controllers/gauges/tachometer.cpp b/firmware/controllers/gauges/tachometer.cpp index c0b7982e0a..4dbdd6c29f 100644 --- a/firmware/controllers/gauges/tachometer.cpp +++ b/firmware/controllers/gauges/tachometer.cpp @@ -41,11 +41,11 @@ static void tachSignalCallback(trigger_event_e ckpSignalType, } void initTachometer(void) { - if (CONFIGB(tachOutputPin) == GPIO_UNASSIGNED) { + if (CONFIG(tachOutputPin) == GPIO_UNASSIGNED) { return; } - enginePins.tachOut.initPin("analog tach output", CONFIGB(tachOutputPin), &CONFIGB(tachOutputPinMode)); + enginePins.tachOut.initPin("analog tach output", CONFIG(tachOutputPin), &CONFIG(tachOutputPinMode)); #if EFI_SHAFT_POSITION_INPUT addTriggerEventListener(tachSignalCallback, "tach", engine); diff --git a/firmware/controllers/generated/engine_configuration_generated_structures.h b/firmware/controllers/generated/engine_configuration_generated_structures.h index 9cb32cec57..59af060253 100644 --- a/firmware/controllers/generated/engine_configuration_generated_structures.h +++ b/firmware/controllers/generated/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Dec 08 00:34:44 EST 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sat Dec 14 16:03:19 EST 2019 // by class com.rusefi.output.CHeaderConsumer // begin #ifndef CONTROLLERS_GENERATED_ENGINE_CONFIGURATION_GENERATED_STRUCTURES_H @@ -347,6 +347,93 @@ struct trigger_config_s { * This option could be used if your second trigger channel is broken offset 4 bit 2 */ bool useOnlyFirstChannel : 1; + /** + offset 4 bit 3 */ + bool unusedBit_4_3 : 1; + /** + offset 4 bit 4 */ + bool unusedBit_4_4 : 1; + /** + offset 4 bit 5 */ + bool unusedBit_4_5 : 1; + /** + offset 4 bit 6 */ + bool unusedBit_4_6 : 1; + /** + offset 4 bit 7 */ + bool unusedBit_4_7 : 1; + /** + offset 4 bit 8 */ + bool unusedBit_4_8 : 1; + /** + offset 4 bit 9 */ + bool unusedBit_4_9 : 1; + /** + offset 4 bit 10 */ + bool unusedBit_4_10 : 1; + /** + offset 4 bit 11 */ + bool unusedBit_4_11 : 1; + /** + offset 4 bit 12 */ + bool unusedBit_4_12 : 1; + /** + offset 4 bit 13 */ + bool unusedBit_4_13 : 1; + /** + offset 4 bit 14 */ + bool unusedBit_4_14 : 1; + /** + offset 4 bit 15 */ + bool unusedBit_4_15 : 1; + /** + offset 4 bit 16 */ + bool unusedBit_4_16 : 1; + /** + offset 4 bit 17 */ + bool unusedBit_4_17 : 1; + /** + offset 4 bit 18 */ + bool unusedBit_4_18 : 1; + /** + offset 4 bit 19 */ + bool unusedBit_4_19 : 1; + /** + offset 4 bit 20 */ + bool unusedBit_4_20 : 1; + /** + offset 4 bit 21 */ + bool unusedBit_4_21 : 1; + /** + offset 4 bit 22 */ + bool unusedBit_4_22 : 1; + /** + offset 4 bit 23 */ + bool unusedBit_4_23 : 1; + /** + offset 4 bit 24 */ + bool unusedBit_4_24 : 1; + /** + offset 4 bit 25 */ + bool unusedBit_4_25 : 1; + /** + offset 4 bit 26 */ + bool unusedBit_4_26 : 1; + /** + offset 4 bit 27 */ + bool unusedBit_4_27 : 1; + /** + offset 4 bit 28 */ + bool unusedBit_4_28 : 1; + /** + offset 4 bit 29 */ + bool unusedBit_4_29 : 1; + /** + offset 4 bit 30 */ + bool unusedBit_4_30 : 1; + /** + offset 4 bit 31 */ + bool unusedBit_4_31 : 1; /** * offset 8 */ @@ -441,564 +528,6 @@ struct etb_io { typedef struct etb_io etb_io; -// start of board_configuration_s -struct board_configuration_s { - /** - * offset 0 - */ - idle_hardware_s idle; - /** - * value between 0 and 100 used in Manual mode - * offset 8 - */ - float manIdlePosition; - /** - * offset 12 - */ - float mapFrequency0Kpa; - /** - * offset 16 - */ - float mapFrequency100Kpa; - /** - * Same RPM is used for two ways of producing simulated RPM. See also triggerSimulatorPins (with wires) - * See also directSelfStimulation (no wires, bypassing input hardware) - * rpm X - * offset 20 - */ - int triggerSimulatorFrequency; - /** - * offset 24 - */ - output_pin_e injectionPins[INJECTION_PIN_COUNT]; - /** - * offset 36 - */ - output_pin_e ignitionPins[IGNITION_PIN_COUNT]; - /** - * offset 48 - */ - pin_output_mode_e injectionPinMode; - /** - * offset 49 - */ - pin_output_mode_e ignitionPinMode; - /** - * offset 50 - */ - brain_pin_e HD44780_rs; - /** - * offset 51 - */ - brain_pin_e HD44780_e; - /** - * offset 52 - */ - brain_pin_e HD44780_db4; - /** - * offset 53 - */ - brain_pin_e HD44780_db5; - /** - * offset 54 - */ - brain_pin_e HD44780_db6; - /** - * offset 55 - */ - brain_pin_e HD44780_db7; - /** - * offset 56 - */ - brain_pin_e gps_rx_pin; - /** - * offset 57 - */ - brain_pin_e gps_tx_pin; - /** - * offset 58 - */ - output_pin_e fuelPumpPin; - /** - * offset 59 - */ - pin_output_mode_e fuelPumpPinMode; - /** - * Check engine light, also malfunction indicator light. Always blinks once on boot. - * offset 60 - */ - output_pin_e malfunctionIndicatorPin; - /** - * offset 61 - */ - pin_output_mode_e malfunctionIndicatorPinMode; - /** - * offset 62 - */ - pin_output_mode_e fanPinMode; - /** - * offset 63 - */ - output_pin_e fanPin; - /** - * some cars have a switch to indicate that clutch pedal is all the way down - * offset 64 - */ - switch_input_pin_e clutchDownPin; - /** - * offset 65 - */ - output_pin_e alternatorControlPin; - /** - * offset 66 - */ - pin_output_mode_e alternatorControlPinMode; - /** - * offset 67 - */ - pin_input_mode_e clutchDownPinMode; - /** - * offset 68 - */ - brain_pin_e digitalPotentiometerChipSelect[DIGIPOT_COUNT]; - /** - * offset 72 - */ - pin_output_mode_e electronicThrottlePin1Mode; - /** - * offset 73 - */ - brain_pin_e wboHeaterPin; - /** - * offset 74 - */ - brain_pin_e cj125CsPin; - /** - * offset 75 - */ - spi_device_e max31855spiDevice; - /** - * offset 76 - */ - brain_pin_e debugTriggerSync; - /** - * Digital Potentiometer is used by stock ECU stimulation code - * offset 77 - */ - spi_device_e digitalPotentiometerSpiDevice; - /** - * offset 78 - */ - brain_pin_e mc33972_cs; - /** - * offset 79 - */ - pin_output_mode_e mc33972_csPinMode; - /** - * Useful in Research&Development phase - * offset 80 - */ - adc_channel_e auxFastSensor1_adcChannel; - /** - * offset 81 - */ - uint8_t unused556[3]; - /** - * offset 84 - */ - float fuelLevelEmptyTankVoltage; - /** - * offset 88 - */ - float fuelLevelFullTankVoltage; - /** - * AFR, WBO, EGO - whatever you like to call it - * offset 92 - */ - ego_sensor_e afr_type; - /** - * offset 96 - */ - float fuelClosedLoopAfrLowThreshold; - /** - * offset 100 - */ - brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]; - /** - * offset 103 - */ - pin_output_mode_e hip9011CsPinMode; - /** - * This implementation produces one pulse per engine cycle. See also dizzySparkOutputPin. - * offset 104 - */ - output_pin_e tachOutputPin; - /** - * offset 105 - */ - pin_output_mode_e tachOutputPinMode; - /** - * offset 106 - */ - output_pin_e mainRelayPin; - /** - * offset 107 - */ - brain_pin_e sdCardCsPin; - /** - * offset 108 - */ - brain_pin_e canTxPin; - /** - * offset 109 - */ - brain_pin_e canRxPin; - /** - * offset 110 - */ - pin_input_mode_e throttlePedalUpPinMode; - /** - * offset 111 - */ - brain_pin_e debugTimerCallback; - /** - * offset 112 - */ - int idleThreadPeriodMs; - /** - * offset 116 - */ - int consoleLoopPeriodMs; - /** - * offset 120 - */ - int lcdThreadPeriodMs; - /** - * offset 124 - */ - int generalPeriodicThreadPeriodMs; - /** - * offset 128 - */ - uint32_t tunerStudioSerialSpeed; - /** - * offset 132 - */ - can_device_mode_e canDeviceMode; - /** - * Each rusEfi piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEfi board. - * See also directSelfStimulation which is different. - * offset 136 - */ - brain_pin_e triggerSimulatorPins[TRIGGER_SIMULATOR_PIN_COUNT]; - /** - * offset 139 - */ - pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT]; - /** - * Narrow band o2 heater, not used for CJ125. See wboHeaterPin - * offset 142 - */ - output_pin_e o2heaterPin; - /** - * offset 143 - */ - pin_output_mode_e o2heaterPinModeTodO; - /** - offset 144 bit 0 */ - bool is_enabled_spi_1 : 1; - /** - offset 144 bit 1 */ - bool is_enabled_spi_2 : 1; - /** - offset 144 bit 2 */ - bool is_enabled_spi_3 : 1; - /** - offset 144 bit 3 */ - bool isSdCardEnabled : 1; - /** - offset 144 bit 4 */ - bool isFastAdcEnabled : 1; - /** - offset 144 bit 5 */ - bool isEngineControlEnabled : 1; - /** - offset 144 bit 6 */ - bool isHip9011Enabled : 1; - /** - offset 144 bit 7 */ - bool isVerboseAlternator : 1; - /** - offset 144 bit 8 */ - bool useSerialPort : 1; - /** - * This setting should only be used if you have a stepper motor idle valve and a stepper motor driver installed. - offset 144 bit 9 */ - bool useStepperIdle : 1; - /** - offset 144 bit 10 */ - bool enabledStep1Limiter : 1; - /** - offset 144 bit 11 */ - bool useTpicAdvancedMode : 1; - /** - offset 144 bit 12 */ - bool useLcdScreen : 1; - /** - offset 144 bit 13 */ - bool unusedAnotherOne : 1; - /** - offset 144 bit 14 */ - bool unusedOldWarmupAfr : 1; - /** - * +This will cause the alternator to be operated in a basic on or off mode, this is the simplest alternator control. - offset 144 bit 15 */ - bool onOffAlternatorLogic : 1; - /** - offset 144 bit 16 */ - bool isCJ125Enabled : 1; - /** - * Use rise or fall signal front - offset 144 bit 17 */ - bool vvtCamSensorUseRise : 1; - /** - * Useful for individual intakes - offset 144 bit 18 */ - bool measureMapOnlyInOneCylinder : 1; - /** - offset 144 bit 19 */ - bool stepperForceParkingEveryRestart : 1; - /** - * Smarter cranking logic. - * See also startOfCrankingPrimingPulse - offset 144 bit 20 */ - bool isFasterEngineSpinUpEnabled : 1; - /** - * This setting disables fuel injection while the engine is in overrun, this is useful as a fuel saving measure and to prevent back firing. - offset 144 bit 21 */ - bool coastingFuelCutEnabled : 1; - /** - * This setting allows the ECU to open the IAC during overrun conditions to help reduce engine breaking, this can be helpful for large engines in light weight cars. - offset 144 bit 22 */ - bool useIacTableForCoasting : 1; - /** - offset 144 bit 23 */ - bool useNoiselessTriggerDecoder : 1; - /** - offset 144 bit 24 */ - bool useIdleTimingPidControl : 1; - /** - offset 144 bit 25 */ - bool useTPSBasedVeTable : 1; - /** - offset 144 bit 26 */ - bool is_enabled_spi_4 : 1; - /** - offset 144 bit 27 */ - bool pauseEtbControl : 1; - /** - offset 144 bit 28 */ - bool alignEngineSnifferAtTDC : 1; - /** - * This setting allows the ETB to act as the idle air control valve and move to regulate the airflow at idle. - offset 144 bit 29 */ - bool useETBforIdleControl : 1; - /** - offset 144 bit 30 */ - bool idleIncrementalPidCic : 1; - /** - offset 144 bit 31 */ - bool unused_board_984_31 : 1; - /** - * offset 148 - */ - brain_input_pin_e logicAnalyzerPins[LOGIC_ANALYZER_CHANNEL_COUNT]; - /** - * offset 152 - */ - pin_output_mode_e mainRelayPinMode; - /** - * offset 153 - */ - brain_pin_e hip9011CsPin; - /** - * offset 154 - */ - brain_pin_e hip9011IntHoldPin; - /** - * offset 155 - */ - pin_output_mode_e hip9011IntHoldPinMode; - /** - * default or inverted input - * offset 156 - */ - uint8_t logicAnalyzerMode[LOGIC_ANALYZER_CHANNEL_COUNT]; - /** - * offset 160 - */ - int unrealisticRpmThreashold; - /** - * offset 164 - */ - pin_output_mode_e gpioPinModes[FSIO_COMMAND_COUNT]; - /** - * todo: more comments - * offset 180 - */ - output_pin_e fsioOutputPins[FSIO_COMMAND_COUNT]; - /** - * offset 196 - */ - brain_pin_e max31855_cs[EGT_CHANNEL_COUNT]; - /** - * SD card logging period, in milliseconds - * offset 204 - */ - int16_t sdCardPeriodMs; - /** - * offset 206 - */ - brain_pin_e debugSetTimer; - /** - * offset 207 - */ - brain_pin_e debugMapAveraging; - /** - * offset 208 - */ - brain_pin_e starterRelayPin; - /** - * offset 209 - */ - pin_output_mode_e starterRelayPinMode; - /** - * offset 210 - */ - uint8_t unuseduartPadding1[2]; - /** - * offset 212 - */ - int mapMinBufferLength; - /** - * offset 216 - */ - int16_t idlePidDeactivationTpsThreshold; - /** - * offset 218 - */ - int16_t stepperParkingExtraSteps; - /** - * This magic property is specific to Mazda Miata NB2 - * offset 220 - */ - float miataNb2VVTRatioFrom; - /** - * This magic property is specific to Mazda Miata NB2 - * offset 224 - */ - float miataNb2VVTRatioTo; - /** - * This pin is used for debugging - snap a logic analyzer on it and see if it's ever high - * offset 228 - */ - brain_pin_e triggerErrorPin; - /** - * offset 229 - */ - pin_output_mode_e triggerErrorPinMode; - /** - * offset 230 - */ - output_pin_e acRelayPin; - /** - * offset 231 - */ - pin_output_mode_e acRelayPinMode; - /** - * offset 232 - */ - fsio_pwm_freq_t fsioFrequency[FSIO_COMMAND_COUNT]; - /** - * offset 264 - */ - fsio_setting_t fsio_setting[FSIO_COMMAND_COUNT]; - /** - * offset 328 - */ - brain_pin_e spi1mosiPin; - /** - * offset 329 - */ - brain_pin_e spi1misoPin; - /** - * offset 330 - */ - brain_pin_e spi1sckPin; - /** - * offset 331 - */ - brain_pin_e spi2mosiPin; - /** - * offset 332 - */ - brain_pin_e spi2misoPin; - /** - * offset 333 - */ - brain_pin_e spi2sckPin; - /** - * offset 334 - */ - brain_pin_e spi3mosiPin; - /** - * offset 335 - */ - brain_pin_e spi3misoPin; - /** - * offset 336 - */ - brain_pin_e spi3sckPin; - /** - * Saab Combustion Detection Module knock signal input pin - * also known as Saab Ion Sensing Module - * offset 337 - */ - brain_pin_e cdmInputPin; - /** - * offset 338 - */ - brain_pin_e joystickCenterPin; - /** - * offset 339 - */ - brain_pin_e joystickAPin; - /** - * offset 340 - */ - brain_pin_e joystickBPin; - /** - * offset 341 - */ - brain_pin_e joystickCPin; - /** - * offset 342 - */ - brain_pin_e joystickDPin; - /** - * offset 343 - */ - uart_device_e consoleUartDevice; - /** - * rusEfi console Sensor Sniffer mode - * offset 344 - */ - sensor_chart_e sensorChartMode; - /** total size 348*/ -}; - -typedef struct board_configuration_s board_configuration_s; - // start of engine_configuration_s struct engine_configuration_s { /** @@ -1115,6 +644,9 @@ struct engine_configuration_s { /** offset 76 bit 30 */ bool issue_294_31 : 1; + /** + offset 76 bit 31 */ + bool unusedBit_34_31 : 1; /** * Closed throttle. todo: extract these two fields into a structure * See also tps1_1AdcChannel @@ -1449,7 +981,554 @@ struct engine_configuration_s { /** * offset 600 */ - board_configuration_s bc; + idle_hardware_s idle; + /** + * value between 0 and 100 used in Manual mode + * offset 608 + */ + float manIdlePosition; + /** + * offset 612 + */ + float mapFrequency0Kpa; + /** + * offset 616 + */ + float mapFrequency100Kpa; + /** + * Same RPM is used for two ways of producing simulated RPM. See also triggerSimulatorPins (with wires) + * See also directSelfStimulation (no wires, bypassing input hardware) + * rpm X + * offset 620 + */ + int triggerSimulatorFrequency; + /** + * offset 624 + */ + output_pin_e injectionPins[INJECTION_PIN_COUNT]; + /** + * offset 636 + */ + output_pin_e ignitionPins[IGNITION_PIN_COUNT]; + /** + * offset 648 + */ + pin_output_mode_e injectionPinMode; + /** + * offset 649 + */ + pin_output_mode_e ignitionPinMode; + /** + * offset 650 + */ + brain_pin_e HD44780_rs; + /** + * offset 651 + */ + brain_pin_e HD44780_e; + /** + * offset 652 + */ + brain_pin_e HD44780_db4; + /** + * offset 653 + */ + brain_pin_e HD44780_db5; + /** + * offset 654 + */ + brain_pin_e HD44780_db6; + /** + * offset 655 + */ + brain_pin_e HD44780_db7; + /** + * offset 656 + */ + brain_pin_e gps_rx_pin; + /** + * offset 657 + */ + brain_pin_e gps_tx_pin; + /** + * offset 658 + */ + output_pin_e fuelPumpPin; + /** + * offset 659 + */ + pin_output_mode_e fuelPumpPinMode; + /** + * Check engine light, also malfunction indicator light. Always blinks once on boot. + * offset 660 + */ + output_pin_e malfunctionIndicatorPin; + /** + * offset 661 + */ + pin_output_mode_e malfunctionIndicatorPinMode; + /** + * offset 662 + */ + pin_output_mode_e fanPinMode; + /** + * offset 663 + */ + output_pin_e fanPin; + /** + * some cars have a switch to indicate that clutch pedal is all the way down + * offset 664 + */ + switch_input_pin_e clutchDownPin; + /** + * offset 665 + */ + output_pin_e alternatorControlPin; + /** + * offset 666 + */ + pin_output_mode_e alternatorControlPinMode; + /** + * offset 667 + */ + pin_input_mode_e clutchDownPinMode; + /** + * offset 668 + */ + brain_pin_e digitalPotentiometerChipSelect[DIGIPOT_COUNT]; + /** + * offset 672 + */ + pin_output_mode_e electronicThrottlePin1Mode; + /** + * offset 673 + */ + brain_pin_e wboHeaterPin; + /** + * offset 674 + */ + brain_pin_e cj125CsPin; + /** + * offset 675 + */ + spi_device_e max31855spiDevice; + /** + * offset 676 + */ + brain_pin_e debugTriggerSync; + /** + * Digital Potentiometer is used by stock ECU stimulation code + * offset 677 + */ + spi_device_e digitalPotentiometerSpiDevice; + /** + * offset 678 + */ + brain_pin_e mc33972_cs; + /** + * offset 679 + */ + pin_output_mode_e mc33972_csPinMode; + /** + * Useful in Research&Development phase + * offset 680 + */ + adc_channel_e auxFastSensor1_adcChannel; + /** + * offset 681 + */ + uint8_t unused556[3]; + /** + * offset 684 + */ + float fuelLevelEmptyTankVoltage; + /** + * offset 688 + */ + float fuelLevelFullTankVoltage; + /** + * AFR, WBO, EGO - whatever you like to call it + * offset 692 + */ + ego_sensor_e afr_type; + /** + * offset 696 + */ + float fuelClosedLoopAfrLowThreshold; + /** + * offset 700 + */ + brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]; + /** + * offset 703 + */ + pin_output_mode_e hip9011CsPinMode; + /** + * This implementation produces one pulse per engine cycle. See also dizzySparkOutputPin. + * offset 704 + */ + output_pin_e tachOutputPin; + /** + * offset 705 + */ + pin_output_mode_e tachOutputPinMode; + /** + * offset 706 + */ + output_pin_e mainRelayPin; + /** + * offset 707 + */ + brain_pin_e sdCardCsPin; + /** + * offset 708 + */ + brain_pin_e canTxPin; + /** + * offset 709 + */ + brain_pin_e canRxPin; + /** + * offset 710 + */ + pin_input_mode_e throttlePedalUpPinMode; + /** + * offset 711 + */ + brain_pin_e debugTimerCallback; + /** + * offset 712 + */ + int idleThreadPeriodMs; + /** + * offset 716 + */ + int consoleLoopPeriodMs; + /** + * offset 720 + */ + int lcdThreadPeriodMs; + /** + * offset 724 + */ + int generalPeriodicThreadPeriodMs; + /** + * offset 728 + */ + uint32_t tunerStudioSerialSpeed; + /** + * offset 732 + */ + can_device_mode_e canDeviceMode; + /** + * Each rusEfi piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEfi board. + * See also directSelfStimulation which is different. + * offset 736 + */ + brain_pin_e triggerSimulatorPins[TRIGGER_SIMULATOR_PIN_COUNT]; + /** + * offset 739 + */ + pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT]; + /** + * Narrow band o2 heater, not used for CJ125. See wboHeaterPin + * offset 742 + */ + output_pin_e o2heaterPin; + /** + * offset 743 + */ + pin_output_mode_e o2heaterPinModeTodO; + /** + offset 744 bit 0 */ + bool is_enabled_spi_1 : 1; + /** + offset 744 bit 1 */ + bool is_enabled_spi_2 : 1; + /** + offset 744 bit 2 */ + bool is_enabled_spi_3 : 1; + /** + offset 744 bit 3 */ + bool isSdCardEnabled : 1; + /** + offset 744 bit 4 */ + bool isFastAdcEnabled : 1; + /** + offset 744 bit 5 */ + bool isEngineControlEnabled : 1; + /** + offset 744 bit 6 */ + bool isHip9011Enabled : 1; + /** + offset 744 bit 7 */ + bool isVerboseAlternator : 1; + /** + offset 744 bit 8 */ + bool useSerialPort : 1; + /** + * This setting should only be used if you have a stepper motor idle valve and a stepper motor driver installed. + offset 744 bit 9 */ + bool useStepperIdle : 1; + /** + offset 744 bit 10 */ + bool enabledStep1Limiter : 1; + /** + offset 744 bit 11 */ + bool useTpicAdvancedMode : 1; + /** + offset 744 bit 12 */ + bool useLcdScreen : 1; + /** + offset 744 bit 13 */ + bool unusedAnotherOne : 1; + /** + offset 744 bit 14 */ + bool unusedOldWarmupAfr : 1; + /** + * +This will cause the alternator to be operated in a basic on or off mode, this is the simplest alternator control. + offset 744 bit 15 */ + bool onOffAlternatorLogic : 1; + /** + offset 744 bit 16 */ + bool isCJ125Enabled : 1; + /** + * Use rise or fall signal front + offset 744 bit 17 */ + bool vvtCamSensorUseRise : 1; + /** + * Useful for individual intakes + offset 744 bit 18 */ + bool measureMapOnlyInOneCylinder : 1; + /** + offset 744 bit 19 */ + bool stepperForceParkingEveryRestart : 1; + /** + * Smarter cranking logic. + * See also startOfCrankingPrimingPulse + offset 744 bit 20 */ + bool isFasterEngineSpinUpEnabled : 1; + /** + * This setting disables fuel injection while the engine is in overrun, this is useful as a fuel saving measure and to prevent back firing. + offset 744 bit 21 */ + bool coastingFuelCutEnabled : 1; + /** + * This setting allows the ECU to open the IAC during overrun conditions to help reduce engine breaking, this can be helpful for large engines in light weight cars. + offset 744 bit 22 */ + bool useIacTableForCoasting : 1; + /** + offset 744 bit 23 */ + bool useNoiselessTriggerDecoder : 1; + /** + offset 744 bit 24 */ + bool useIdleTimingPidControl : 1; + /** + offset 744 bit 25 */ + bool useTPSBasedVeTable : 1; + /** + offset 744 bit 26 */ + bool is_enabled_spi_4 : 1; + /** + offset 744 bit 27 */ + bool pauseEtbControl : 1; + /** + offset 744 bit 28 */ + bool alignEngineSnifferAtTDC : 1; + /** + * This setting allows the ETB to act as the idle air control valve and move to regulate the airflow at idle. + offset 744 bit 29 */ + bool useETBforIdleControl : 1; + /** + offset 744 bit 30 */ + bool idleIncrementalPidCic : 1; + /** + offset 744 bit 31 */ + bool unused_board_984_31 : 1; + /** + * offset 748 + */ + brain_input_pin_e logicAnalyzerPins[LOGIC_ANALYZER_CHANNEL_COUNT]; + /** + * offset 752 + */ + pin_output_mode_e mainRelayPinMode; + /** + * offset 753 + */ + brain_pin_e hip9011CsPin; + /** + * offset 754 + */ + brain_pin_e hip9011IntHoldPin; + /** + * offset 755 + */ + pin_output_mode_e hip9011IntHoldPinMode; + /** + * default or inverted input + * offset 756 + */ + uint8_t logicAnalyzerMode[LOGIC_ANALYZER_CHANNEL_COUNT]; + /** + * offset 760 + */ + int unrealisticRpmThreashold; + /** + * offset 764 + */ + pin_output_mode_e gpioPinModes[FSIO_COMMAND_COUNT]; + /** + * todo: more comments + * offset 780 + */ + output_pin_e fsioOutputPins[FSIO_COMMAND_COUNT]; + /** + * offset 796 + */ + brain_pin_e max31855_cs[EGT_CHANNEL_COUNT]; + /** + * SD card logging period, in milliseconds + * offset 804 + */ + int16_t sdCardPeriodMs; + /** + * offset 806 + */ + brain_pin_e debugSetTimer; + /** + * offset 807 + */ + brain_pin_e debugMapAveraging; + /** + * offset 808 + */ + brain_pin_e starterRelayPin; + /** + * offset 809 + */ + pin_output_mode_e starterRelayPinMode; + /** + * offset 810 + */ + uint8_t unuseduartPadding1[2]; + /** + * offset 812 + */ + int mapMinBufferLength; + /** + * offset 816 + */ + int16_t idlePidDeactivationTpsThreshold; + /** + * offset 818 + */ + int16_t stepperParkingExtraSteps; + /** + * This magic property is specific to Mazda Miata NB2 + * offset 820 + */ + float miataNb2VVTRatioFrom; + /** + * This magic property is specific to Mazda Miata NB2 + * offset 824 + */ + float miataNb2VVTRatioTo; + /** + * This pin is used for debugging - snap a logic analyzer on it and see if it's ever high + * offset 828 + */ + brain_pin_e triggerErrorPin; + /** + * offset 829 + */ + pin_output_mode_e triggerErrorPinMode; + /** + * offset 830 + */ + output_pin_e acRelayPin; + /** + * offset 831 + */ + pin_output_mode_e acRelayPinMode; + /** + * offset 832 + */ + fsio_pwm_freq_t fsioFrequency[FSIO_COMMAND_COUNT]; + /** + * offset 864 + */ + fsio_setting_t fsio_setting[FSIO_COMMAND_COUNT]; + /** + * offset 928 + */ + brain_pin_e spi1mosiPin; + /** + * offset 929 + */ + brain_pin_e spi1misoPin; + /** + * offset 930 + */ + brain_pin_e spi1sckPin; + /** + * offset 931 + */ + brain_pin_e spi2mosiPin; + /** + * offset 932 + */ + brain_pin_e spi2misoPin; + /** + * offset 933 + */ + brain_pin_e spi2sckPin; + /** + * offset 934 + */ + brain_pin_e spi3mosiPin; + /** + * offset 935 + */ + brain_pin_e spi3misoPin; + /** + * offset 936 + */ + brain_pin_e spi3sckPin; + /** + * Saab Combustion Detection Module knock signal input pin + * also known as Saab Ion Sensing Module + * offset 937 + */ + brain_pin_e cdmInputPin; + /** + * offset 938 + */ + brain_pin_e joystickCenterPin; + /** + * offset 939 + */ + brain_pin_e joystickAPin; + /** + * offset 940 + */ + brain_pin_e joystickBPin; + /** + * offset 941 + */ + brain_pin_e joystickCPin; + /** + * offset 942 + */ + brain_pin_e joystickDPin; + /** + * offset 943 + */ + uart_device_e consoleUartDevice; + /** + * rusEfi console Sensor Sniffer mode + * offset 944 + */ + sensor_chart_e sensorChartMode; /** * offset 948 */ @@ -1487,6 +1566,96 @@ struct engine_configuration_s { /** offset 976 bit 1 */ bool todoClutchDownPinInverted : 1; + /** + offset 976 bit 2 */ + bool unusedBit_247_2 : 1; + /** + offset 976 bit 3 */ + bool unusedBit_247_3 : 1; + /** + offset 976 bit 4 */ + bool unusedBit_247_4 : 1; + /** + offset 976 bit 5 */ + bool unusedBit_247_5 : 1; + /** + offset 976 bit 6 */ + bool unusedBit_247_6 : 1; + /** + offset 976 bit 7 */ + bool unusedBit_247_7 : 1; + /** + offset 976 bit 8 */ + bool unusedBit_247_8 : 1; + /** + offset 976 bit 9 */ + bool unusedBit_247_9 : 1; + /** + offset 976 bit 10 */ + bool unusedBit_247_10 : 1; + /** + offset 976 bit 11 */ + bool unusedBit_247_11 : 1; + /** + offset 976 bit 12 */ + bool unusedBit_247_12 : 1; + /** + offset 976 bit 13 */ + bool unusedBit_247_13 : 1; + /** + offset 976 bit 14 */ + bool unusedBit_247_14 : 1; + /** + offset 976 bit 15 */ + bool unusedBit_247_15 : 1; + /** + offset 976 bit 16 */ + bool unusedBit_247_16 : 1; + /** + offset 976 bit 17 */ + bool unusedBit_247_17 : 1; + /** + offset 976 bit 18 */ + bool unusedBit_247_18 : 1; + /** + offset 976 bit 19 */ + bool unusedBit_247_19 : 1; + /** + offset 976 bit 20 */ + bool unusedBit_247_20 : 1; + /** + offset 976 bit 21 */ + bool unusedBit_247_21 : 1; + /** + offset 976 bit 22 */ + bool unusedBit_247_22 : 1; + /** + offset 976 bit 23 */ + bool unusedBit_247_23 : 1; + /** + offset 976 bit 24 */ + bool unusedBit_247_24 : 1; + /** + offset 976 bit 25 */ + bool unusedBit_247_25 : 1; + /** + offset 976 bit 26 */ + bool unusedBit_247_26 : 1; + /** + offset 976 bit 27 */ + bool unusedBit_247_27 : 1; + /** + offset 976 bit 28 */ + bool unusedBit_247_28 : 1; + /** + offset 976 bit 29 */ + bool unusedBit_247_29 : 1; + /** + offset 976 bit 30 */ + bool unusedBit_247_30 : 1; + /** + offset 976 bit 31 */ + bool unusedBit_247_31 : 1; /** * offset 980 */ @@ -2939,4 +3108,4 @@ typedef struct persistent_config_s persistent_config_s; #endif // end -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Dec 08 00:34:44 EST 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sat Dec 14 16:03:19 EST 2019 diff --git a/firmware/controllers/generated/rusefi_generated.h b/firmware/controllers/generated/rusefi_generated.h index 39e6501f06..1402bdd941 100644 --- a/firmware/controllers/generated/rusefi_generated.h +++ b/firmware/controllers/generated/rusefi_generated.h @@ -246,8 +246,6 @@ #define baroSensor_offset_hex 248 #define baroSensor_type_offset 592 #define baroSensor_type_offset_hex 250 -#define bc_offset 600 -#define bc_offset_hex 258 #define binarySerialRxPin_offset 1815 #define binarySerialRxPin_offset_hex 717 #define binarySerialTxPin_offset 1814 @@ -377,9 +375,11 @@ #define CMD_ENABLE "enable" #define CMD_ENGINE_TYPE "engine_type" #define CMD_ETB_DUTY "set_etb_duty" +#define CMD_FUNCTIONAL_TEST_MODE "test_mode" #define CMD_PINS "pins" #define CMD_REBOOT "reboot" #define CMD_REBOOT_DFU "reboot_dfu" +#define CMD_RESET_ENGINE_SNIFFER "reset_engine_chart" #define CMD_TRIGGER_HW_INPUT "trigger_hw_input" #define CMD_TRIGGERINFO "triggerinfo" #define CMD_WRITECONFIG "writeconfig" @@ -1552,6 +1552,13 @@ #define overrideCrankingIacSetting_offset_hex 5c4 #define overrideCrankingIgnition_offset 516 #define overrideCrankingIgnition_offset_hex 204 +#define PACK_MULT_AFR 1000 +#define PACK_MULT_ANGLE 50 +#define PACK_MULT_MS 300 +#define PACK_MULT_PERCENT 100 +#define PACK_MULT_PRESSURE 30 +#define PACK_MULT_TEMPERATURE 100 +#define PACK_MULT_VOLTAGE 1000 #define pauseEtbControl_offset 744 #define pauseEtbControl_offset_hex 2e8 #define PEDAL_TO_TPS_SIZE 8 @@ -1851,6 +1858,64 @@ #define trigger_type_e_enum "custom toothed wheel", "Ford Aspire", "Dodge Neon 1995", "Miata NA", "Miata NB", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Honda 4+24+1", "Mitsubishi", "Honda 4+24", "Honda 1+4+24", "Dodge Neon 2003", "Mazda DOHC 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Honda 1+24", "Dodge Stratus", "36_2_2_2", "Nissan Primera", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped" , "Dodge Neon 2003 crank", "Miata VVT", "trg34", "trg35", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "trg43", "trg44", "trg45", "INVALID" #define trigger_type_offset 524 #define trigger_type_offset_hex 20c +#define trigger_unusedBit_4_10_offset 528 +#define trigger_unusedBit_4_10_offset_hex 210 +#define trigger_unusedBit_4_11_offset 528 +#define trigger_unusedBit_4_11_offset_hex 210 +#define trigger_unusedBit_4_12_offset 528 +#define trigger_unusedBit_4_12_offset_hex 210 +#define trigger_unusedBit_4_13_offset 528 +#define trigger_unusedBit_4_13_offset_hex 210 +#define trigger_unusedBit_4_14_offset 528 +#define trigger_unusedBit_4_14_offset_hex 210 +#define trigger_unusedBit_4_15_offset 528 +#define trigger_unusedBit_4_15_offset_hex 210 +#define trigger_unusedBit_4_16_offset 528 +#define trigger_unusedBit_4_16_offset_hex 210 +#define trigger_unusedBit_4_17_offset 528 +#define trigger_unusedBit_4_17_offset_hex 210 +#define trigger_unusedBit_4_18_offset 528 +#define trigger_unusedBit_4_18_offset_hex 210 +#define trigger_unusedBit_4_19_offset 528 +#define trigger_unusedBit_4_19_offset_hex 210 +#define trigger_unusedBit_4_20_offset 528 +#define trigger_unusedBit_4_20_offset_hex 210 +#define trigger_unusedBit_4_21_offset 528 +#define trigger_unusedBit_4_21_offset_hex 210 +#define trigger_unusedBit_4_22_offset 528 +#define trigger_unusedBit_4_22_offset_hex 210 +#define trigger_unusedBit_4_23_offset 528 +#define trigger_unusedBit_4_23_offset_hex 210 +#define trigger_unusedBit_4_24_offset 528 +#define trigger_unusedBit_4_24_offset_hex 210 +#define trigger_unusedBit_4_25_offset 528 +#define trigger_unusedBit_4_25_offset_hex 210 +#define trigger_unusedBit_4_26_offset 528 +#define trigger_unusedBit_4_26_offset_hex 210 +#define trigger_unusedBit_4_27_offset 528 +#define trigger_unusedBit_4_27_offset_hex 210 +#define trigger_unusedBit_4_28_offset 528 +#define trigger_unusedBit_4_28_offset_hex 210 +#define trigger_unusedBit_4_29_offset 528 +#define trigger_unusedBit_4_29_offset_hex 210 +#define trigger_unusedBit_4_30_offset 528 +#define trigger_unusedBit_4_30_offset_hex 210 +#define trigger_unusedBit_4_31_offset 528 +#define trigger_unusedBit_4_31_offset_hex 210 +#define trigger_unusedBit_4_3_offset 528 +#define trigger_unusedBit_4_3_offset_hex 210 +#define trigger_unusedBit_4_4_offset 528 +#define trigger_unusedBit_4_4_offset_hex 210 +#define trigger_unusedBit_4_5_offset 528 +#define trigger_unusedBit_4_5_offset_hex 210 +#define trigger_unusedBit_4_6_offset 528 +#define trigger_unusedBit_4_6_offset_hex 210 +#define trigger_unusedBit_4_7_offset 528 +#define trigger_unusedBit_4_7_offset_hex 210 +#define trigger_unusedBit_4_8_offset 528 +#define trigger_unusedBit_4_8_offset_hex 210 +#define trigger_unusedBit_4_9_offset 528 +#define trigger_unusedBit_4_9_offset_hex 210 #define trigger_unusedCustomIsSynchronizationNeeded_offset 528 #define trigger_unusedCustomIsSynchronizationNeeded_offset_hex 210 #define trigger_unusedCustomNeedSecondTriggerInput_offset 528 @@ -1889,8 +1954,8 @@ #define triggerSimulatorPins2_offset_hex 2e1 #define triggerSimulatorPins3_offset 738 #define triggerSimulatorPins3_offset_hex 2e2 -#define TS_FILE_VERSION 20190701 -#define TS_OUTPUT_SIZE 356 +#define TS_FILE_VERSION 20191221 +#define TS_OUTPUT_SIZE 220 #define ts_show_cj125 true #define ts_show_egt true #define ts_show_etb true @@ -1900,7 +1965,7 @@ #define ts_show_hip9011 true #define ts_show_joystick true #define ts_show_lcd true -#define TS_SIGNATURE "rusEFI v1.07" +#define TS_SIGNATURE "rusEFI v1.08" #define tunerStudioSerialSpeed_offset 728 #define tunerStudioSerialSpeed_offset_hex 2d8 #define twoWireBatchIgnition_offset 1476 @@ -1947,6 +2012,68 @@ #define unusedAnotherOne_offset_hex 2e8 #define unusedAtOldBoardConfigurationEnd_offset 988 #define unusedAtOldBoardConfigurationEnd_offset_hex 3dc +#define unusedBit_247_10_offset 976 +#define unusedBit_247_10_offset_hex 3d0 +#define unusedBit_247_11_offset 976 +#define unusedBit_247_11_offset_hex 3d0 +#define unusedBit_247_12_offset 976 +#define unusedBit_247_12_offset_hex 3d0 +#define unusedBit_247_13_offset 976 +#define unusedBit_247_13_offset_hex 3d0 +#define unusedBit_247_14_offset 976 +#define unusedBit_247_14_offset_hex 3d0 +#define unusedBit_247_15_offset 976 +#define unusedBit_247_15_offset_hex 3d0 +#define unusedBit_247_16_offset 976 +#define unusedBit_247_16_offset_hex 3d0 +#define unusedBit_247_17_offset 976 +#define unusedBit_247_17_offset_hex 3d0 +#define unusedBit_247_18_offset 976 +#define unusedBit_247_18_offset_hex 3d0 +#define unusedBit_247_19_offset 976 +#define unusedBit_247_19_offset_hex 3d0 +#define unusedBit_247_20_offset 976 +#define unusedBit_247_20_offset_hex 3d0 +#define unusedBit_247_21_offset 976 +#define unusedBit_247_21_offset_hex 3d0 +#define unusedBit_247_22_offset 976 +#define unusedBit_247_22_offset_hex 3d0 +#define unusedBit_247_23_offset 976 +#define unusedBit_247_23_offset_hex 3d0 +#define unusedBit_247_24_offset 976 +#define unusedBit_247_24_offset_hex 3d0 +#define unusedBit_247_25_offset 976 +#define unusedBit_247_25_offset_hex 3d0 +#define unusedBit_247_26_offset 976 +#define unusedBit_247_26_offset_hex 3d0 +#define unusedBit_247_27_offset 976 +#define unusedBit_247_27_offset_hex 3d0 +#define unusedBit_247_28_offset 976 +#define unusedBit_247_28_offset_hex 3d0 +#define unusedBit_247_29_offset 976 +#define unusedBit_247_29_offset_hex 3d0 +#define unusedBit_247_2_offset 976 +#define unusedBit_247_2_offset_hex 3d0 +#define unusedBit_247_30_offset 976 +#define unusedBit_247_30_offset_hex 3d0 +#define unusedBit_247_31_offset 976 +#define unusedBit_247_31_offset_hex 3d0 +#define unusedBit_247_3_offset 976 +#define unusedBit_247_3_offset_hex 3d0 +#define unusedBit_247_4_offset 976 +#define unusedBit_247_4_offset_hex 3d0 +#define unusedBit_247_5_offset 976 +#define unusedBit_247_5_offset_hex 3d0 +#define unusedBit_247_6_offset 976 +#define unusedBit_247_6_offset_hex 3d0 +#define unusedBit_247_7_offset 976 +#define unusedBit_247_7_offset_hex 3d0 +#define unusedBit_247_8_offset 976 +#define unusedBit_247_8_offset_hex 3d0 +#define unusedBit_247_9_offset 976 +#define unusedBit_247_9_offset_hex 3d0 +#define unusedBit_34_31_offset 76 +#define unusedBit_34_31_offset_hex 4c #define unusedErrorPin_offset 2040 #define unusedErrorPin_offset_hex 7f8 #define unusedFlexFuelSensor_offset 3100 diff --git a/firmware/controllers/global_shared.h b/firmware/controllers/global_shared.h index 956e0d59cb..91ba1adb65 100644 --- a/firmware/controllers/global_shared.h +++ b/firmware/controllers/global_shared.h @@ -13,11 +13,15 @@ /** * The following obscurantism is a hack to reduce stack usage, maybe even a questionable performance * optimization. - * - * rusEfi main processing happens on IRQ so PORT_INT_REQUIRED_STACK has to be pretty large. Problem - * is that PORT_INT_REQUIRED_STACK is included within each user thread stack, thus this large stack multiplies - * and this consumes a lot of valueable RAM. While forcing the compiler to inline helps to some degree, - * it would be even better not to waste stack on passing the parameter. + * + * Of note is that interrupts are NOT serviced on the stack of the thread that was running when the + * interrupt occurred. The only thing that happens on that thread's stack is that its registers are + * pushed (by hardware) when an interrupt occurs, just before swapping the stack pointer out for the + * main stack (currently 0x400=1024 bytes), where the ISR actually runs. + * see also __main_stack_size__ + * see also __process_stack_size__ + * + * see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks * * In the firmware we are using 'extern *Engine' - in the firmware Engine is a signleton * @@ -28,7 +32,7 @@ #define EXTERN_CONFIG \ extern engine_configuration_s *engineConfiguration; \ - extern board_configuration_s *boardConfiguration; \ + extern engine_configuration_s *engineConfiguration; \ extern engine_configuration_s & activeConfiguration; \ extern persistent_config_container_s persistentState; \ extern persistent_config_s *config; \ @@ -64,10 +68,10 @@ * access in unit tests */ #define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x -#define CONFIGB(x) persistentState.persistentConfiguration.engineConfiguration.bc.x #define ENGINE(x) ___engine.x #define DEFINE_CONFIG_PARAM(x, y) #define CONFIG_PARAM(x) CONFIG(x) #define PASS_CONFIG_PARAM(x) +#define EXPECTED_REMAINING_STACK 128 diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index 5effd8280f..30af1cff42 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -154,7 +154,7 @@ static void doRunFuel(int humanIndex, const char *delayStr, const char * onTimeS scheduleMsg(logger, "Invalid index: %d", humanIndex); return; } - brain_pin_e b = CONFIGB(injectionPins)[humanIndex - 1]; + brain_pin_e b = CONFIG(injectionPins)[humanIndex - 1]; pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.injectors[humanIndex - 1], b); } @@ -169,7 +169,7 @@ static void fuelbench2(const char *delayStr, const char *indexStr, const char * } static void fanBenchExt(const char *durationMs) { - pinbench("0", durationMs, "100", "1", &enginePins.fanRelay, CONFIGB(fanPin)); + pinbench("0", durationMs, "100", "1", &enginePins.fanRelay, CONFIG(fanPin)); } void fanBench(void) { @@ -180,15 +180,15 @@ void fanBench(void) { * we are blinking for 16 seconds so that one can click the button and walk around to see the light blinking */ void milBench(void) { - pinbench("0", "500", "500", "16", &enginePins.checkEnginePin, CONFIGB(malfunctionIndicatorPin)); + pinbench("0", "500", "500", "16", &enginePins.checkEnginePin, CONFIG(malfunctionIndicatorPin)); } void fuelPumpBenchExt(const char *durationMs) { - pinbench("0", durationMs, "100", "1", &enginePins.fuelPumpRelay, CONFIGB(fuelPumpPin)); + pinbench("0", durationMs, "100", "1", &enginePins.fuelPumpRelay, CONFIG(fuelPumpPin)); } void acRelayBench(void) { - pinbench("0", "1000", "100", "1", &enginePins.acRelay, CONFIGB(acRelayPin)); + pinbench("0", "1000", "100", "1", &enginePins.acRelay, CONFIG(acRelayPin)); } void fuelPumpBench(void) { @@ -206,7 +206,7 @@ static void doRunSpark(int humanIndex, const char *delayStr, const char * onTime scheduleMsg(logger, "Invalid index: %d", humanIndex); return; } - brain_pin_e b = CONFIGB(ignitionPins)[humanIndex - 1]; + brain_pin_e b = CONFIG(ignitionPins)[humanIndex - 1]; pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.coils[humanIndex - 1], b); } @@ -236,7 +236,7 @@ class BenchController : public PeriodicController { public: BenchController() : PeriodicController("BenchThread") { } private: - void PeriodicTask(efitime_t nowNt) override { + void PeriodicTask(efitick_t nowNt) override { UNUSED(nowNt); setPeriod(50 /* ms */); diff --git a/firmware/controllers/injector_central.h b/firmware/controllers/injector_central.h index de9cdc0c2c..b66dd85fa8 100644 --- a/firmware/controllers/injector_central.h +++ b/firmware/controllers/injector_central.h @@ -5,12 +5,12 @@ * todo: rename this file * * @date Sep 8, 2013 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #pragma once -#include "engine.h" +#include "global.h" void fanBench(void); void fuelPumpBench(void); diff --git a/firmware/controllers/math/config_engine_specs.h b/firmware/controllers/math/config_engine_specs.h index 82628654d0..50d551432e 100644 --- a/firmware/controllers/math/config_engine_specs.h +++ b/firmware/controllers/math/config_engine_specs.h @@ -18,9 +18,9 @@ */ #if EFI_UNIT_TEST -#define DECLARE_GLOBAL_SIGNATURE Engine *engine, engine_configuration_s *___engineConfiguration, persistent_config_s *config, board_configuration_s *boardConfiguration +#define DECLARE_GLOBAL_SIGNATURE Engine *engine, engine_configuration_s *___engineConfiguration, persistent_config_s *config #define DECLARE_GLOBAL_SUFFIX , DECLARE_GLOBAL_SIGNATURE -#define PASS_GLOBAL_SIGNATURE engine, ___engineConfiguration, config, boardConfiguration +#define PASS_GLOBAL_SIGNATURE engine, ___engineConfiguration, config #define PASS_GLOBAL_SUFFIX , PASS_GLOBAL_SIGNATURE #define CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(x) ___engineConfiguration->x #else /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/math/speed_density.h b/firmware/controllers/math/speed_density.h index 06f19b98ab..05806ef020 100644 --- a/firmware/controllers/math/speed_density.h +++ b/firmware/controllers/math/speed_density.h @@ -2,10 +2,10 @@ * @file speed_density.h * * @date May 29, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef SPEED_DENSITY_H_ -#define SPEED_DENSITY_H_ + +#pragma once #define gramm_second_to_cc_minute(gs) ((gs) / 0.0119997981) #define cc_minute_to_gramm_second(ccm) ((ccm) * 0.0119997981) @@ -17,5 +17,3 @@ float sdMath(float airMass, float AFR DECLARE_ENGINE_PARAMETER_SUFFIX); void setDefaultVETable(DECLARE_ENGINE_PARAMETER_SIGNATURE); void initSpeedDensity(DECLARE_ENGINE_PARAMETER_SIGNATURE); floatms_t getSpeedDensityFuel(float map DECLARE_ENGINE_PARAMETER_SUFFIX); - -#endif /* SPEED_DENSITY_H_ */ diff --git a/firmware/controllers/persistent_store.cpp b/firmware/controllers/persistent_store.cpp index 359e222cdf..402fd05c5c 100644 --- a/firmware/controllers/persistent_store.cpp +++ b/firmware/controllers/persistent_store.cpp @@ -28,7 +28,6 @@ #include "trigger_central.h" #include "engine_controller.h" - persistent_config_container_s persistentState CCM_OPTIONAL; persistent_config_s *config = &persistentState.persistentConfiguration; @@ -39,6 +38,5 @@ persistent_config_s *config = &persistentState.persistentConfiguration; * would be a smaller evil. Whatever is needed should be passed into methods/modules/files as an explicit parameter. */ engine_configuration_s *engineConfiguration = &persistentState.persistentConfiguration.engineConfiguration; -board_configuration_s *boardConfiguration = &persistentState.persistentConfiguration.engineConfiguration.bc; #endif /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/sensors/converters/func_chain.h b/firmware/controllers/sensors/converters/func_chain.h new file mode 100644 index 0000000000..f28aa371ca --- /dev/null +++ b/firmware/controllers/sensors/converters/func_chain.h @@ -0,0 +1,82 @@ +/** + * @author Matthew Kennedy, (c) 2019 + * + * This lets us compose multiple functions in to a single function. If we have + * conversion functions F(x), G(x), and H(x), we can define a new function + * FuncChain that will compute H(G(F(X))). F first, then G, then H. + */ + +#pragma once + +#include "sensor_converter_func.h" + +#include +#include + +namespace priv { +template +class FuncChain; + +template <> +class FuncChain<> { +protected: + SensorResult convert(float input) const { + // Base case is the identity function + return {true, input}; + } +}; + +template +class FuncChain : private FuncChain { + static_assert(std::is_base_of_v, "Template parameters must inherit from SensorConverter"); + +private: + using TBase = FuncChain; + +public: + SensorResult convert(float input) const { + // Convert the current step + SensorResult currentStep = m_f.convert(input); + + // if it was valid, pass this result to the chain of (n-1) functions that remain + if (currentStep.Valid) { + return TBase::convert(currentStep.Value); + } else { + return {false, 0}; + } + } + + // Get the element in the current level + template + std::enable_if_t, TGet &> get() { + return m_f; + } + + // We don't have it - check level (n - 1) + template + std::enable_if_t, TGet &> get() { + return TBase::template get(); + } + +private: + TFirst m_f; +}; +} // namespace priv + +template +class FuncChain : public SensorConverter { +public: + // Perform chained conversion of all functions in TFuncs + SensorResult convert(float input) const override { + return m_fs.convert(input); + } + + // Access the sub-function of type TGet + template + TGet &get() { + return m_fs.template get(); + } + +private: + priv::FuncChain m_fs; +}; diff --git a/firmware/controllers/sensors/converters/resistance_func.cpp b/firmware/controllers/sensors/converters/resistance_func.cpp new file mode 100644 index 0000000000..8f39c71c3f --- /dev/null +++ b/firmware/controllers/sensors/converters/resistance_func.cpp @@ -0,0 +1,27 @@ +/** + * @author Matthew Kennedy, (c) 2019 + */ + +#include "resistance_func.h" + +void ResistanceFunc::configure(float supplyVoltage, float pullupResistor) { + m_pullupResistor = pullupResistor; + m_supplyVoltage = supplyVoltage; +} + +SensorResult ResistanceFunc::convert(float raw) const { + // If the voltage is very low, the sensor is a dead short. + if (raw < 0.05f) { + return {false, 0.0f}; + } + + // If the voltage is very high (95% VCC), the sensor is open circuit. + if (raw > (m_supplyVoltage * 0.95f)) { + return {false, 1e6}; + } + + // Voltage is in a sensible range - convert + float resistance = m_pullupResistor / (m_supplyVoltage / raw - 1); + + return {true, resistance}; +} diff --git a/firmware/controllers/sensors/converters/resistance_func.h b/firmware/controllers/sensors/converters/resistance_func.h new file mode 100644 index 0000000000..8f12577135 --- /dev/null +++ b/firmware/controllers/sensors/converters/resistance_func.h @@ -0,0 +1,22 @@ +/** + * @author Matthew Kennedy, (c) 2019 + * + * A function to convert input voltage to resistance in a voltage divider. + * Configured with the value of the pullup resistor, and the voltage to which + * it's connected. + */ + +#pragma once + +#include "sensor_converter_func.h" + +class ResistanceFunc final : public SensorConverter { +public: + void configure(float supplyVoltage, float pullupResistor); + + SensorResult convert(float inputValue) const override; + +private: + float m_supplyVoltage = 5.0f; + float m_pullupResistor = 1000.0f; +}; diff --git a/firmware/controllers/sensors/converters/thermistor_func.cpp b/firmware/controllers/sensors/converters/thermistor_func.cpp new file mode 100644 index 0000000000..8253d50da9 --- /dev/null +++ b/firmware/controllers/sensors/converters/thermistor_func.cpp @@ -0,0 +1,47 @@ +/** + * @author Matthew Kennedy, (c) 2019 + */ + +#include "thermistor_func.h" + +#include "thermistors.h" + +#include + +SensorResult ThermistorFunc::convert(float ohms) const { + // This resistance should have already been validated - only + // thing we can check is that it's non-negative + if (ohms <= 0) { + return {false, 0}; + } + + float lnR = logf(ohms); + + float lnR3 = lnR * lnR * lnR; + + float recip = m_a + m_b * lnR + m_c * lnR3; + + float kelvin = 1 / recip; + + float celsius = convertKelvinToCelcius(kelvin); + + return {true, celsius}; +} + +void ThermistorFunc::configure(thermistor_conf_s &cfg) { + // https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation + float l1 = logf(cfg.resistance_1); + float l2 = logf(cfg.resistance_2); + float l3 = logf(cfg.resistance_3); + + float y1 = 1 / convertCelsiusToKelvin(cfg.tempC_1); + float y2 = 1 / convertCelsiusToKelvin(cfg.tempC_2); + float y3 = 1 / convertCelsiusToKelvin(cfg.tempC_3); + + float u2 = (y2 - y1) / (l2 - l1); + float u3 = (y3 - y1) / (l3 - l1); + + m_c = ((u3 - u2) / (l3 - l2)) / (l1 + l2 + l3); + m_b = u2 - m_c * (l1 * l1 + l1 * l2 + l2 * l2); + m_a = y1 - (m_b + l1 * l1 * m_c) * l1; +} diff --git a/firmware/controllers/sensors/converters/thermistor_func.h b/firmware/controllers/sensors/converters/thermistor_func.h new file mode 100644 index 0000000000..ea9f2e715e --- /dev/null +++ b/firmware/controllers/sensors/converters/thermistor_func.h @@ -0,0 +1,24 @@ +/** + * @author Matthew Kennedy, (c) 2019 + * + * A function to convert resistance to thermistor temperature (NTC). Uses the + * Steinhart-Hart equation to prevent having to compute many logarithms at runtime. + */ + +#pragma once + +#include "engine_configuration_generated_structures.h" +#include "sensor_converter_func.h" + +class ThermistorFunc final : public SensorConverter { +public: + SensorResult convert(float ohms) const override; + + void configure(thermistor_conf_s &cfg); + +private: + // Steinhart-Hart coefficients + float m_a; + float m_b; + float m_c; +}; diff --git a/firmware/controllers/sensors/ego.cpp b/firmware/controllers/sensors/ego.cpp index d03813aa2b..71ab0232c9 100644 --- a/firmware/controllers/sensors/ego.cpp +++ b/firmware/controllers/sensors/ego.cpp @@ -49,7 +49,7 @@ static float lastAfr = stoichAfr; void initEgoAveraging(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // Our averaging is intended for use only with Narrow EGOs. - if (CONFIGB(afr_type) == ES_NarrowBand) { + if (CONFIG(afr_type) == ES_NarrowBand) { totalEgoCnt = prevEgoCnt = 0; egoAfrBuf.clear(); useAveraging = true; @@ -96,7 +96,7 @@ void initEgoAveraging(DECLARE_ENGINE_PARAMETER_SIGNATURE) { bool hasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_CJ125 && HAL_USE_SPI - if (CONFIGB(isCJ125Enabled)) { + if (CONFIG(isCJ125Enabled)) { return cjHasAfrSensor(PASS_ENGINE_PARAMETER_SIGNATURE); } #endif /* EFI_CJ125 && HAL_USE_SPI */ @@ -105,7 +105,7 @@ bool hasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float getAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_CJ125 && HAL_USE_SPI - if (CONFIGB(isCJ125Enabled)) { + if (CONFIG(isCJ125Enabled)) { return cjGetAfr(PASS_ENGINE_PARAMETER_SIGNATURE); } #endif /* EFI_CJ125 && HAL_USE_SPI */ @@ -113,7 +113,7 @@ float getAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float volts = getVoltageDivided("ego", sensor->hwChannel PASS_ENGINE_PARAMETER_SUFFIX); - if (CONFIGB(afr_type) == ES_NarrowBand) { + if (CONFIG(afr_type) == ES_NarrowBand) { float afr = interpolate2d("narrow", volts, engineConfiguration->narrowToWideOxygenBins, engineConfiguration->narrowToWideOxygen); #ifdef EFI_NARROW_EGO_AVERAGING if (useAveraging) @@ -173,6 +173,6 @@ static void initEgoSensor(afr_sensor_s *sensor, ego_sensor_e type) { } void setEgoSensor(ego_sensor_e type DECLARE_CONFIG_PARAMETER_SUFFIX) { - CONFIGB(afr_type) = type; + CONFIG(afr_type) = type; initEgoSensor(&engineConfiguration->afr, type); } diff --git a/firmware/controllers/sensors/functional_sensor.cpp b/firmware/controllers/sensors/functional_sensor.cpp index bc45bb0a9b..2626cbf677 100644 --- a/firmware/controllers/sensors/functional_sensor.cpp +++ b/firmware/controllers/sensors/functional_sensor.cpp @@ -1,12 +1,6 @@ #include "functional_sensor.h" void FunctionalSensor::postRawValue(float inputValue) { - // Report the raw value - float *rawReportLocation = m_rawReportingLocation; - if (rawReportLocation) { - *rawReportLocation = inputValue; - } - // If no function is set, this sensor isn't valid. if (!m_function) { invalidate(); diff --git a/firmware/controllers/sensors/functional_sensor.h b/firmware/controllers/sensors/functional_sensor.h index c9ffe0f5f4..ba3ae92e30 100644 --- a/firmware/controllers/sensors/functional_sensor.h +++ b/firmware/controllers/sensors/functional_sensor.h @@ -30,17 +30,11 @@ public: void postRawValue(float inputValue); - void setRawReportingLocation(float *rawReportingLocation) { - m_rawReportingLocation = rawReportingLocation; - } - void setFunction(SensorConverter& func) { m_function = &func; } private: - float *m_rawReportingLocation = nullptr; - // Conversion function for this sensor SensorConverter* m_function = nullptr; }; diff --git a/firmware/controllers/sensors/map.cpp b/firmware/controllers/sensors/map.cpp index 22e4deb748..152cf4a8e5 100644 --- a/firmware/controllers/sensors/map.cpp +++ b/firmware/controllers/sensors/map.cpp @@ -148,7 +148,7 @@ float getMapByVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX) { */ float getRawMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (engineConfiguration->hasFrequencyReportingMapSensor) { - return interpolateMsg("rmap", CONFIGB(mapFrequency0Kpa), 0, CONFIGB(mapFrequency100Kpa), 100, mapFreq); + return interpolateMsg("rmap", CONFIG(mapFrequency0Kpa), 0, CONFIG(mapFrequency100Kpa), 100, mapFreq); } float voltage = getVoltageDivided("map", engineConfiguration->map.sensor.hwChannel PASS_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/sensors/sensors.mk b/firmware/controllers/sensors/sensors.mk index 4bb3173353..06b9942578 100644 --- a/firmware/controllers/sensors/sensors.mk +++ b/firmware/controllers/sensors/sensors.mk @@ -12,4 +12,6 @@ CONTROLLERS_SENSORS_SRC_CPP = $(PROJECT_DIR)/controllers/sensors/thermistors.cp $(PROJECT_DIR)/controllers/sensors/hip9011_lookup.cpp \ $(PROJECT_DIR)/controllers/sensors/sensor.cpp \ $(PROJECT_DIR)/controllers/sensors/functional_sensor.cpp \ - $(PROJECT_DIR)/controllers/sensors/converters/linear_func.cpp + $(PROJECT_DIR)/controllers/sensors/converters/linear_func.cpp \ + $(PROJECT_DIR)/controllers/sensors/convreters/resistance_func.cpp \ + $(PROJECT_DIR)/controllers/sensors/convreters/thermistor_func.cpp diff --git a/firmware/controllers/sensors/stored_value_sensor.h b/firmware/controllers/sensors/stored_value_sensor.h index d8198567ee..597edc56b6 100644 --- a/firmware/controllers/sensors/stored_value_sensor.h +++ b/firmware/controllers/sensors/stored_value_sensor.h @@ -34,15 +34,11 @@ public: return {valid, value}; } - void setReportingLocation(float *reportLocation) { - m_reportingLocation = reportLocation; - } - protected: explicit StoredValueSensor(SensorType type) : Sensor(type) - //, m_reportingLocation(reportingLocation) - {} + { + } // Invalidate the stored value. void invalidate() { @@ -54,17 +50,9 @@ protected: // Set value before valid - so we don't briefly have the valid bit set on an invalid value m_value = value; m_isValid = true; - - // Report value - float *reportLoc = m_reportingLocation; - if (reportLoc) { - *reportLoc = value; - } } private: bool m_isValid = false; float m_value = 0.0f; - - float *m_reportingLocation = nullptr; }; diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index 76168ed211..bd4fee4742 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -272,7 +272,7 @@ static void testCltByR(float resistance) { void initThermistors(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { logger = sharedLogger; - efiAssertVoid(CUSTOM_ERR_6578, engine!=NULL, "e NULL initThermistors"); + efiAssertVoid(CUSTOM_NULL_ENGINE_PTR, engine!=NULL, "e NULL initThermistors"); #if EFI_PROD_CODE addConsoleActionF("test_clt_by_r", testCltByR); diff --git a/firmware/controllers/sensors/tps.cpp b/firmware/controllers/sensors/tps.cpp index 4ded0610bc..177389cb5b 100644 --- a/firmware/controllers/sensors/tps.cpp +++ b/firmware/controllers/sensors/tps.cpp @@ -1,5 +1,5 @@ /** - * @author Andrey Belomutskiy, (c) 2012-2018 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #include "engine.h" #include "tps.h" @@ -78,7 +78,7 @@ float getTpsRateOfChange(void) { * Return current TPS position based on configured ADC levels, and adc * * */ -percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX) { +percent_t getTpsValue(int index, int adc DECLARE_ENGINE_PARAMETER_SUFFIX) { DISPLAY_STATE(Engine) DISPLAY_TAG(TPS_SECTION); @@ -109,9 +109,16 @@ percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX) { DISPLAY_TEXT(Current_ADC) DISPLAY(DISPLAY_FIELD(currentTpsAdc)) DISPLAY_TEXT(interpolate_between) - float result = interpolateMsg("TPS", TPS_TS_CONVERSION * CONFIG(DISPLAY_CONFIG(tpsMax)), 100, - DISPLAY_TEXT(and) - TPS_TS_CONVERSION * CONFIG(DISPLAY_CONFIG(tpsMin)), 0, adc); + + DISPLAY(DISPLAY_CONFIG(tpsMax)) + DISPLAY_TEXT(and) + DISPLAY(DISPLAY_CONFIG(tpsMin)) + + int tpsMax = index == 0 ? CONFIG(tpsMax) : CONFIG(tps2Max); + int tpsMin = index == 0 ? CONFIG(tpsMin) : CONFIG(tps2Min); + + float result = interpolateMsg("TPS", TPS_TS_CONVERSION * tpsMax, 100, + TPS_TS_CONVERSION * tpsMin, 0, adc); if (result < engineConfiguration->tpsErrorDetectionTooLow) { #if EFI_PROD_CODE // too much noise with simulator @@ -140,6 +147,7 @@ float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE) { * Return TPS ADC readings. * We need ADC value because TunerStudio has a nice TPS configuration wizard, and this wizard * wants a TPS value. + * @param index [0, ETB_COUNT) */ int getTPS12bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { #if !EFI_PROD_CODE @@ -197,8 +205,9 @@ void grabPedalIsWideOpen() { /** * @brief Position on physical primary TPS */ -static percent_t getPrimatyRawTPS(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { - percent_t tpsValue = getTpsValue(getTPS12bitAdc(index PASS_ENGINE_PARAMETER_SUFFIX) PASS_ENGINE_PARAMETER_SUFFIX); +static percent_t getPrimaryRawTPS(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { + int adcValue = getTPS12bitAdc(index PASS_ENGINE_PARAMETER_SUFFIX); + percent_t tpsValue = getTpsValue(index, adcValue PASS_ENGINE_PARAMETER_SUFFIX); return tpsValue; } @@ -208,6 +217,10 @@ bool hasPedalPositionSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) { return engineConfiguration->throttlePedalPositionAdcChannel != EFI_ADC_NONE; } +bool hasTps2(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + return engineConfiguration->tps2_1AdcChannel != EFI_ADC_NONE; +} + percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (mockPedalPosition != MOCK_UNDEFINED) { return mockPedalPosition; @@ -238,7 +251,7 @@ percent_t getTPSWithIndex(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { // todo: blah blah // todo: if two TPS do not match - show OBD code via malfunction_central.c - return getPrimatyRawTPS(index PASS_ENGINE_PARAMETER_SUFFIX); + return getPrimaryRawTPS(index PASS_ENGINE_PARAMETER_SUFFIX); } percent_t getTPS(DECLARE_ENGINE_PARAMETER_SIGNATURE) { diff --git a/firmware/controllers/sensors/tps.h b/firmware/controllers/sensors/tps.h index cd12176012..556e3a2b85 100644 --- a/firmware/controllers/sensors/tps.h +++ b/firmware/controllers/sensors/tps.h @@ -28,9 +28,10 @@ percent_t getTPSWithIndex(int index DECLARE_ENGINE_PARAMETER_SUFFIX); bool hasTpsSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE); int convertVoltageTo10bitADC(float voltage); int getTPS12bitAdc(int index DECLARE_ENGINE_PARAMETER_SUFFIX); +bool hasTps2(DECLARE_ENGINE_PARAMETER_SIGNATURE); #define getTPS10bitAdc() (getTPS12bitAdc(0 PASS_ENGINE_PARAMETER_SUFFIX) / TPS_TS_CONVERSION) float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE); -percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX); +percent_t getTpsValue(int index, int adc DECLARE_ENGINE_PARAMETER_SUFFIX); void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE); void setMockTpsAdc(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX); void setMockTpsValue(percent_t tpsPosition DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/sensors/voltage.cpp b/firmware/controllers/sensors/voltage.cpp index 994aa9f31a..e74fe6e6bc 100644 --- a/firmware/controllers/sensors/voltage.cpp +++ b/firmware/controllers/sensors/voltage.cpp @@ -24,5 +24,10 @@ bool hasVBatt(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } float getVBatt(DECLARE_ENGINE_PARAMETER_SIGNATURE) { +#ifdef USE_ADC3_VBATT_HACK + extern adcsample_t vbattSampleProteus; + return adcToVolts(vbattSampleProteus) * engineConfiguration->vbattDividerCoeff; +#else return getVoltage("vbatt", engineConfiguration->vbattAdcChannel PASS_ENGINE_PARAMETER_SUFFIX) * engineConfiguration->vbattDividerCoeff; +#endif } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index bf82370028..065272b2ea 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -81,46 +81,46 @@ void printFloatArray(const char *prefix, float array[], int size) { scheduleLogging(&logger); } -void printSpiState(Logging *logger, board_configuration_s *boardConfiguration) { - scheduleMsg(logger, "spi 1=%s/2=%s/3=%s", boolToString(boardConfiguration->is_enabled_spi_1), - boolToString(boardConfiguration->is_enabled_spi_2), boolToString(boardConfiguration->is_enabled_spi_3)); +void printSpiState(Logging *logger, const engine_configuration_s *engineConfiguration) { + scheduleMsg(logger, "spi 1=%s/2=%s/3=%s", boolToString(engineConfiguration->is_enabled_spi_1), + boolToString(engineConfiguration->is_enabled_spi_2), boolToString(engineConfiguration->is_enabled_spi_3)); } -extern board_configuration_s *boardConfiguration; +extern engine_configuration_s *engineConfiguration; static void printOutputs(const engine_configuration_s *engineConfiguration) { - scheduleMsg(&logger, "injectionPins: mode %s", getPin_output_mode_e(boardConfiguration->injectionPinMode)); + scheduleMsg(&logger, "injectionPins: mode %s", getPin_output_mode_e(engineConfiguration->injectionPinMode)); for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { - brain_pin_e brainPin = boardConfiguration->injectionPins[i]; + brain_pin_e brainPin = engineConfiguration->injectionPins[i]; scheduleMsg(&logger, "injection #%d @ %s", (1 + i), hwPortname(brainPin)); } - scheduleMsg(&logger, "ignitionPins: mode %s", getPin_output_mode_e(boardConfiguration->ignitionPinMode)); + scheduleMsg(&logger, "ignitionPins: mode %s", getPin_output_mode_e(engineConfiguration->ignitionPinMode)); for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { - brain_pin_e brainPin = boardConfiguration->ignitionPins[i]; + brain_pin_e brainPin = engineConfiguration->ignitionPins[i]; scheduleMsg(&logger, "ignition #%d @ %s", (1 + i), hwPortname(brainPin)); } - scheduleMsg(&logger, "idlePin: mode %s @ %s freq=%d", getPin_output_mode_e(boardConfiguration->idle.solenoidPinMode), - hwPortname(boardConfiguration->idle.solenoidPin), boardConfiguration->idle.solenoidFrequency); - scheduleMsg(&logger, "malfunctionIndicator: %s mode=%s", hwPortname(boardConfiguration->malfunctionIndicatorPin), - getPin_output_mode_e(boardConfiguration->malfunctionIndicatorPinMode)); + scheduleMsg(&logger, "idlePin: mode %s @ %s freq=%d", getPin_output_mode_e(engineConfiguration->idle.solenoidPinMode), + hwPortname(engineConfiguration->idle.solenoidPin), engineConfiguration->idle.solenoidFrequency); + scheduleMsg(&logger, "malfunctionIndicator: %s mode=%s", hwPortname(engineConfiguration->malfunctionIndicatorPin), + getPin_output_mode_e(engineConfiguration->malfunctionIndicatorPinMode)); - scheduleMsg(&logger, "fuelPumpPin: mode %s @ %s", getPin_output_mode_e(boardConfiguration->fuelPumpPinMode), - hwPortname(boardConfiguration->fuelPumpPin)); + scheduleMsg(&logger, "fuelPumpPin: mode %s @ %s", getPin_output_mode_e(engineConfiguration->fuelPumpPinMode), + hwPortname(engineConfiguration->fuelPumpPin)); - scheduleMsg(&logger, "fanPin: mode %s @ %s", getPin_output_mode_e(boardConfiguration->fanPinMode), - hwPortname(boardConfiguration->fanPin)); + scheduleMsg(&logger, "fanPin: mode %s @ %s", getPin_output_mode_e(engineConfiguration->fanPinMode), + hwPortname(engineConfiguration->fanPin)); - scheduleMsg(&logger, "mainRelay: mode %s @ %s", getPin_output_mode_e(boardConfiguration->mainRelayPinMode), - hwPortname(boardConfiguration->mainRelayPin)); + scheduleMsg(&logger, "mainRelay: mode %s @ %s", getPin_output_mode_e(engineConfiguration->mainRelayPinMode), + hwPortname(engineConfiguration->mainRelayPin)); - scheduleMsg(&logger, "starterRelay: mode %s @ %s", getPin_output_mode_e(boardConfiguration->starterRelayPinMode), - hwPortname(boardConfiguration->starterRelayPin)); + scheduleMsg(&logger, "starterRelay: mode %s @ %s", getPin_output_mode_e(engineConfiguration->starterRelayPinMode), + hwPortname(engineConfiguration->starterRelayPin)); scheduleMsg(&logger, "alternator field: mode %s @ %s", - getPin_output_mode_e(boardConfiguration->alternatorControlPinMode), - hwPortname(boardConfiguration->alternatorControlPin)); + getPin_output_mode_e(engineConfiguration->alternatorControlPinMode), + hwPortname(engineConfiguration->alternatorControlPin)); } @@ -161,8 +161,6 @@ const char* getConfigurationName(engine_type_e engineType) { return "Gy6139"; case MAZDA_MIATA_NB1: return "MiataNB1"; - case MAZDA_323: - return "M323"; case MRE_MIATA_NA6: return "MRE Miata 1.6"; case MRE_MIATA_NB2: @@ -275,7 +273,7 @@ void printConfiguration(const engine_configuration_s *engineConfiguration) { boolToString(engineConfiguration->isMapAveragingEnabled), boolToString(engineConfiguration->isTunerStudioEnabled), boolToString(engineConfiguration->isWaveAnalyzerEnabled), - boolToString(boardConfiguration->isFastAdcEnabled)); + boolToString(engineConfiguration->isFastAdcEnabled)); scheduleMsg(&logger, "isManualSpinningMode=%s/isCylinderCleanupEnabled=%s", boolToString(engineConfiguration->isManualSpinningMode), @@ -283,20 +281,20 @@ void printConfiguration(const engine_configuration_s *engineConfiguration) { scheduleMsg(&logger, "clutchUp@%s: %s", hwPortname(engineConfiguration->clutchUpPin), boolToString(engine->clutchUpState)); - scheduleMsg(&logger, "clutchDown@%s: %s", hwPortname(boardConfiguration->clutchDownPin), + scheduleMsg(&logger, "clutchDown@%s: %s", hwPortname(engineConfiguration->clutchDownPin), boolToString(engine->clutchDownState)); scheduleMsg(&logger, "nesting=%d", maxNesting); - scheduleMsg(&logger, "digitalPotentiometerSpiDevice %d", boardConfiguration->digitalPotentiometerSpiDevice); + scheduleMsg(&logger, "digitalPotentiometerSpiDevice %d", engineConfiguration->digitalPotentiometerSpiDevice); for (int i = 0; i < DIGIPOT_COUNT; i++) { scheduleMsg(&logger, "digitalPotentiometer CS%d %s", i, - hwPortname(boardConfiguration->digitalPotentiometerChipSelect[i])); + hwPortname(engineConfiguration->digitalPotentiometerChipSelect[i])); } #if EFI_PROD_CODE - printSpiState(&logger, boardConfiguration); + printSpiState(&logger, engineConfiguration); #endif /* EFI_PROD_CODE */ } @@ -320,10 +318,7 @@ static void setTimingMode(int value) { void setEngineType(int value) { engineConfiguration->engineType = (engine_type_e) value; resetConfigurationExt(&logger, (engine_type_e) value PASS_ENGINE_PARAMETER_SUFFIX); -#if EFI_ENGINE_SNIFFER - if (engine->isTestMode) - waveChart.reset(); -#endif + engine->resetEngineSnifferIfInTestMode(); #if EFI_INTERNAL_FLASH writeToFlashNow(); @@ -334,22 +329,22 @@ void setEngineType(int value) { } static void setIdleSolenoidFrequency(int value) { - boardConfiguration->idle.solenoidFrequency = value; + engineConfiguration->idle.solenoidFrequency = value; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } static void setInjectionPinMode(int value) { - boardConfiguration->injectionPinMode = (pin_output_mode_e) value; + engineConfiguration->injectionPinMode = (pin_output_mode_e) value; doPrintConfiguration(); } static void setIgnitionPinMode(int value) { - boardConfiguration->ignitionPinMode = (pin_output_mode_e) value; + engineConfiguration->ignitionPinMode = (pin_output_mode_e) value; doPrintConfiguration(); } static void setIdlePinMode(int value) { - boardConfiguration->idle.solenoidPinMode = (pin_output_mode_e) value; + engineConfiguration->idle.solenoidPinMode = (pin_output_mode_e) value; doPrintConfiguration(); } @@ -366,17 +361,17 @@ static void setIgnitionOffset(float value) { } static void setFuelPumpPinMode(int value) { - boardConfiguration->fuelPumpPinMode = (pin_output_mode_e) value; + engineConfiguration->fuelPumpPinMode = (pin_output_mode_e) value; doPrintConfiguration(); } static void setMalfunctionIndicatorPinMode(int value) { - boardConfiguration->malfunctionIndicatorPinMode = (pin_output_mode_e) value; + engineConfiguration->malfunctionIndicatorPinMode = (pin_output_mode_e) value; doPrintConfiguration(); } static void setSensorChartMode(int value) { - boardConfiguration->sensorChartMode = (sensor_chart_e) value; + engineConfiguration->sensorChartMode = (sensor_chart_e) value; doPrintConfiguration(); } @@ -446,10 +441,10 @@ static void printTemperatureInfo(void) { } scheduleMsg(&logger, "fan=%s @ %s", boolToString(enginePins.fanRelay.getLogicValue()), - hwPortname(boardConfiguration->fanPin)); + hwPortname(engineConfiguration->fanPin)); scheduleMsg(&logger, "A/C relay=%s @ %s", boolToString(enginePins.acRelay.getLogicValue()), - hwPortname(boardConfiguration->acRelayPin)); + hwPortname(engineConfiguration->acRelayPin)); #endif /* EFI_ANALOG_SENSORS */ } @@ -550,6 +545,7 @@ static void setTriggerType(int value) { incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); doPrintConfiguration(); scheduleMsg(&logger, "Do you need to also invoke set operation_mode X?"); + engine->resetEngineSnifferIfInTestMode(); } static void setDebugMode(int value) { @@ -630,6 +626,7 @@ static void setWholePhaseMapCmd(float value) { static void setWholeTimingMapCmd(float value) { scheduleMsg(&logger, "Setting whole timing advance map to %.2f", value); setWholeTimingMap(value); + engine->resetEngineSnifferIfInTestMode(); } static void setWholeVeCmd(float value) { @@ -638,6 +635,7 @@ static void setWholeVeCmd(float value) { scheduleMsg(&logger, "WARNING: setting VE map not in SD mode is pointless"); } setMap(config->veTable, value); + engine->resetEngineSnifferIfInTestMode(); } static void setWholeFuelMapCmd(float value) { @@ -646,16 +644,17 @@ static void setWholeFuelMapCmd(float value) { scheduleMsg(&logger, "WARNING: setting fuel map in SD mode is pointless"); } setWholeFuelMap(value PASS_CONFIG_PARAMETER_SUFFIX); + engine->resetEngineSnifferIfInTestMode(); } #if EFI_PROD_CODE static void setEgtSpi(int spi) { - boardConfiguration->max31855spiDevice = (spi_device_e) spi; + engineConfiguration->max31855spiDevice = (spi_device_e) spi; } static void setPotSpi(int spi) { - boardConfiguration->digitalPotentiometerSpiDevice = (spi_device_e) spi; + engineConfiguration->digitalPotentiometerSpiDevice = (spi_device_e) spi; } /** @@ -675,7 +674,7 @@ static void setIgnitionPin(const char *indexStr, const char *pinName) { return; } scheduleMsg(&logger, "setting ignition pin[%d] to %s please save&restart", index, hwPortname(pin)); - boardConfiguration->ignitionPins[index] = pin; + engineConfiguration->ignitionPins[index] = pin; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } @@ -692,27 +691,27 @@ static void setIndividualPin(const char *pinName, brain_pin_e *targetPin, const // set_idle_pin none static void setIdlePin(const char *pinName) { - setIndividualPin(pinName, &boardConfiguration->idle.solenoidPin, "idle"); + setIndividualPin(pinName, &engineConfiguration->idle.solenoidPin, "idle"); } static void setMainRelayPin(const char *pinName) { - setIndividualPin(pinName, &boardConfiguration->mainRelayPin, "main relay"); + setIndividualPin(pinName, &engineConfiguration->mainRelayPin, "main relay"); } static void setStarterRelayPin(const char *pinName) { - setIndividualPin(pinName, &boardConfiguration->starterRelayPin, "starter relay"); + setIndividualPin(pinName, &engineConfiguration->starterRelayPin, "starter relay"); } static void setAlternatorPin(const char *pinName) { - setIndividualPin(pinName, &boardConfiguration->alternatorControlPin, "alternator"); + setIndividualPin(pinName, &engineConfiguration->alternatorControlPin, "alternator"); } static void setACRelayPin(const char *pinName) { - setIndividualPin(pinName, &boardConfiguration->acRelayPin, "A/C"); + setIndividualPin(pinName, &engineConfiguration->acRelayPin, "A/C"); } static void setFuelPumpPin(const char *pinName) { - setIndividualPin(pinName, &boardConfiguration->fuelPumpPin, "fuelPump"); + setIndividualPin(pinName, &engineConfiguration->fuelPumpPin, "fuelPump"); } static void setInjectionPin(const char *indexStr, const char *pinName) { @@ -726,7 +725,7 @@ static void setInjectionPin(const char *indexStr, const char *pinName) { return; } scheduleMsg(&logger, "setting injection pin[%d] to %s please save&restart", index, hwPortname(pin)); - boardConfiguration->injectionPins[index] = pin; + engineConfiguration->injectionPins[index] = pin; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } @@ -747,7 +746,7 @@ static void setTriggerInputPin(const char *indexStr, const char *pinName) { return; } scheduleMsg(&logger, "setting trigger pin[%d] to %s please save&restart", index, hwPortname(pin)); - boardConfiguration->triggerInputPins[index] = pin; + engineConfiguration->triggerInputPins[index] = pin; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } @@ -760,7 +759,7 @@ static void setTriggerSimulatorMode(const char *indexStr, const char *modeCode) if (absI(mode) == ERROR_CODE) { return; } - boardConfiguration->triggerSimulatorPinModes[index] = (pin_output_mode_e) mode; + engineConfiguration->triggerSimulatorPinModes[index] = (pin_output_mode_e) mode; } static void setEgtCSPin(const char *indexStr, const char *pinName) { @@ -773,7 +772,7 @@ static void setEgtCSPin(const char *indexStr, const char *pinName) { return; } scheduleMsg(&logger, "setting EGT CS pin[%d] to %s please save&restart", index, hwPortname(pin)); - boardConfiguration->max31855_cs[index] = pin; + engineConfiguration->max31855_cs[index] = pin; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } @@ -787,7 +786,7 @@ static void setTriggerSimulatorPin(const char *indexStr, const char *pinName) { return; } scheduleMsg(&logger, "setting trigger simulator pin[%d] to %s please save&restart", index, hwPortname(pin)); - boardConfiguration->triggerSimulatorPins[index] = pin; + engineConfiguration->triggerSimulatorPins[index] = pin; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } @@ -838,7 +837,7 @@ static void setLogicInputPin(const char *indexStr, const char *pinName) { return; } scheduleMsg(&logger, "setting logic input pin[%d] to %s please save&restart", index, hwPortname(pin)); - boardConfiguration->logicAnalyzerPins[index] = pin; + engineConfiguration->logicAnalyzerPins[index] = pin; } static void showPinFunction(const char *pinName) { @@ -878,29 +877,30 @@ static void setFuelMap(const char * rpmStr, const char *loadStr, const char *val config->fuelTable[loadIndex][rpmIndex] = value; scheduleMsg(&logger, "Setting fuel map entry %d:%d to %.2f", rpmIndex, loadIndex, value); + engine->resetEngineSnifferIfInTestMode(); } static void setSpiMode(int index, bool mode) { switch (index) { case 1: - boardConfiguration->is_enabled_spi_1 = mode; + engineConfiguration->is_enabled_spi_1 = mode; break; case 2: - boardConfiguration->is_enabled_spi_2 = mode; + engineConfiguration->is_enabled_spi_2 = mode; break; case 3: - boardConfiguration->is_enabled_spi_3 = mode; + engineConfiguration->is_enabled_spi_3 = mode; break; default: scheduleMsg(&logger, "invalid spi index %d", index); return; } - printSpiState(&logger, boardConfiguration); + printSpiState(&logger, engineConfiguration); } static void enableOrDisable(const char *param, bool isEnabled) { if (strEqualCaseInsensitive(param, "fastadc")) { - boardConfiguration->isFastAdcEnabled = isEnabled; + engineConfiguration->isFastAdcEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, CMD_TRIGGER_HW_INPUT)) { engine->hwTriggerInputEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, "etb_auto")) { @@ -908,11 +908,11 @@ static void enableOrDisable(const char *param, bool isEnabled) { } else if (strEqualCaseInsensitive(param, "cranking_constant_dwell")) { engineConfiguration->useConstantDwellDuringCranking = isEnabled; } else if (strEqualCaseInsensitive(param, "cj125")) { - boardConfiguration->isCJ125Enabled = isEnabled; + engineConfiguration->isCJ125Enabled = isEnabled; } else if (strEqualCaseInsensitive(param, "engine_sniffer")) { engineConfiguration->isEngineChartEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, "step1limimter")) { - boardConfiguration->enabledStep1Limiter = isEnabled; + engineConfiguration->enabledStep1Limiter = isEnabled; #if EFI_PROD_CODE } else if (strEqualCaseInsensitive(param, "auto_idle")) { #if EFI_IDLE_CONTROL @@ -920,9 +920,9 @@ static void enableOrDisable(const char *param, bool isEnabled) { #endif /* EFI_IDLE_CONTROL */ #endif /* EFI_PROD_CODE */ } else if (strEqualCaseInsensitive(param, "serial")) { - boardConfiguration->useSerialPort = isEnabled; + engineConfiguration->useSerialPort = isEnabled; } else if (strEqualCaseInsensitive(param, "stepperidle")) { - boardConfiguration->useStepperIdle = isEnabled; + engineConfiguration->useStepperIdle = isEnabled; } else if (strEqualCaseInsensitive(param, "trigger_only_front")) { engineConfiguration->useOnlyRisingEdgeForTrigger = isEnabled; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -936,7 +936,7 @@ static void enableOrDisable(const char *param, bool isEnabled) { engineConfiguration->twoWireBatchIgnition = isEnabled; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } else if (strEqualCaseInsensitive(param, "HIP9011")) { - boardConfiguration->isHip9011Enabled = isEnabled; + engineConfiguration->isHip9011Enabled = isEnabled; } else if (strEqualCaseInsensitive(param, "verbose_etb")) { engineConfiguration->isVerboseETB = isEnabled; } else if (strEqualCaseInsensitive(param, "verbose_idle")) { @@ -950,16 +950,16 @@ static void enableOrDisable(const char *param, bool isEnabled) { } else if (strEqualCaseInsensitive(param, "auxdebug4")) { engineConfiguration->isVerboseAuxPid4 = isEnabled; } else if (strEqualCaseInsensitive(param, "altdebug")) { - boardConfiguration->isVerboseAlternator = isEnabled; + engineConfiguration->isVerboseAlternator = isEnabled; } else if (strEqualCaseInsensitive(param, "tpic_advanced_mode")) { - boardConfiguration->useTpicAdvancedMode = isEnabled; + engineConfiguration->useTpicAdvancedMode = isEnabled; } else if (strEqualCaseInsensitive(param, "knockdebug")) { engine->knockDebug = isEnabled; } else if (strEqualCaseInsensitive(param, "altcontrol")) { engineConfiguration->isAlternatorControlEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, "sd")) { - boardConfiguration->isSdCardEnabled = isEnabled; - } else if (strEqualCaseInsensitive(param, "test_mode")) { + engineConfiguration->isSdCardEnabled = isEnabled; + } else if (strEqualCaseInsensitive(param, CMD_FUNCTIONAL_TEST_MODE)) { engine->isTestMode = isEnabled; } else if (strEqualCaseInsensitive(param, "can_read")) { engineConfiguration->canReadEnabled = isEnabled; @@ -974,7 +974,7 @@ static void enableOrDisable(const char *param, bool isEnabled) { } else if (strEqualCaseInsensitive(param, "self_stimulation")) { engineConfiguration->directSelfStimulation = isEnabled; } else if (strEqualCaseInsensitive(param, "engine_control")) { - boardConfiguration->isEngineControlEnabled = isEnabled; + engineConfiguration->isEngineControlEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, "map_avg")) { engineConfiguration->isMapAveragingEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, "tunerstudio")) { @@ -1086,7 +1086,7 @@ const plain_get_integer_s getI_plain[] = { const plain_get_float_s getF_plain[] = { {"adcVcc", &engineConfiguration->adcVcc}, {"cranking_dwell", &engineConfiguration->ignitionDwellForCrankingMs}, - {"idle_position", &boardConfiguration->manIdlePosition}, + {"idle_position", &engineConfiguration->manIdlePosition}, {"ignition_offset", &engineConfiguration->ignitionOffset}, {"injection_offset", &engineConfiguration->extraInjectionOffset}, {"global_trigger_offset_angle", &engineConfiguration->globalTriggerAngleOffset}, @@ -1126,7 +1126,7 @@ static void getValue(const char *paramStr) { if (strEqualCaseInsensitive(paramStr, "isCJ125Enabled")) { - scheduleMsg(&logger, "isCJ125Enabled=%d", boardConfiguration->isCJ125Enabled); + scheduleMsg(&logger, "isCJ125Enabled=%d", engineConfiguration->isCJ125Enabled); #if EFI_PROD_CODE } else if (strEqualCaseInsensitive(paramStr, "bor")) { showBor(); @@ -1142,7 +1142,7 @@ static void getValue(const char *paramStr) { } else if (strEqualCaseInsensitive(paramStr, "global_trigger_offset_angle")) { scheduleMsg(&logger, "global_trigger_offset=%.2f", engineConfiguration->globalTriggerAngleOffset); } else if (strEqualCaseInsensitive(paramStr, "isHip9011Enabled")) { - scheduleMsg(&logger, "isHip9011Enabled=%d", boardConfiguration->isHip9011Enabled); + scheduleMsg(&logger, "isHip9011Enabled=%d", engineConfiguration->isHip9011Enabled); } #if EFI_RTC @@ -1372,6 +1372,7 @@ static void setValue(const char *paramStr, const char *valueStr) { setDateTime(valueStr); #endif } + engine->resetEngineSnifferIfInTestMode(); } void initSettings(void) { diff --git a/firmware/controllers/settings.h b/firmware/controllers/settings.h index ba49d590fe..9535e12032 100644 --- a/firmware/controllers/settings.h +++ b/firmware/controllers/settings.h @@ -12,7 +12,7 @@ #include "engine.h" void initSettings(void); -void printSpiState(Logging *logger, board_configuration_s *boardConfiguration); +void printSpiState(Logging *logger, const engine_configuration_s *engineConfiguration); void printConfiguration(const engine_configuration_s *engineConfiguration); void scheduleStopEngine(void); void setCallFromPitStop(int durationMs); diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 3616753985..b209fed6b4 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -126,25 +126,25 @@ void EnginePins::unregisterPins() { unregisterEtbPins(); #endif /* EFI_ELECTRONIC_THROTTLE_BODY */ #if EFI_PROD_CODE - unregisterOutputIfPinOrModeChanged(fuelPumpRelay, bc.fuelPumpPin, bc.fuelPumpPinMode); - unregisterOutputIfPinOrModeChanged(fanRelay, bc.fanPin, bc.fanPinMode); - unregisterOutputIfPinOrModeChanged(acRelay, bc.acRelayPin, bc.acRelayPinMode); - unregisterOutputIfPinOrModeChanged(hipCs, bc.hip9011CsPin, bc.hip9011CsPinMode); - unregisterOutputIfPinOrModeChanged(triggerDecoderErrorPin, bc.triggerErrorPin, bc.triggerErrorPinMode); - unregisterOutputIfPinOrModeChanged(checkEnginePin, bc.malfunctionIndicatorPin, bc.malfunctionIndicatorPinMode); + unregisterOutputIfPinOrModeChanged(fuelPumpRelay, fuelPumpPin, fuelPumpPinMode); + unregisterOutputIfPinOrModeChanged(fanRelay, fanPin, fanPinMode); + unregisterOutputIfPinOrModeChanged(acRelay, acRelayPin, acRelayPinMode); + unregisterOutputIfPinOrModeChanged(hipCs, hip9011CsPin, hip9011CsPinMode); + unregisterOutputIfPinOrModeChanged(triggerDecoderErrorPin, triggerErrorPin, triggerErrorPinMode); + unregisterOutputIfPinOrModeChanged(checkEnginePin, malfunctionIndicatorPin, malfunctionIndicatorPinMode); unregisterOutputIfPinOrModeChanged(dizzyOutput, dizzySparkOutputPin, dizzySparkOutputPinMode); - unregisterOutputIfPinOrModeChanged(tachOut, bc.tachOutputPin, bc.tachOutputPinMode); - unregisterOutputIfPinOrModeChanged(idleSolenoidPin, bc.idle.solenoidPin, bc.idle.solenoidPinMode); - unregisterOutputIfPinChanged(sdCsPin, bc.sdCardCsPin); + unregisterOutputIfPinOrModeChanged(tachOut, tachOutputPin, tachOutputPinMode); + unregisterOutputIfPinOrModeChanged(idleSolenoidPin, idle.solenoidPin, idle.solenoidPinMode); + unregisterOutputIfPinChanged(sdCsPin, sdCardCsPin); unregisterOutputIfPinChanged(accelerometerCs, LIS302DLCsPin); for (int i = 0;i < FSIO_COMMAND_COUNT;i++) { - unregisterOutputIfPinChanged(fsioOutputs[i], bc.fsioOutputPins[i]); + unregisterOutputIfPinChanged(fsioOutputs[i], fsioOutputPins[i]); } - unregisterOutputIfPinOrModeChanged(alternatorPin, bc.alternatorControlPin, bc.alternatorControlPinMode); - unregisterOutputIfPinOrModeChanged(mainRelay, bc.mainRelayPin, bc.mainRelayPinMode); - unregisterOutputIfPinOrModeChanged(starterRelay, bc.starterRelayPin, bc.starterRelayPinMode); + unregisterOutputIfPinOrModeChanged(alternatorPin, alternatorControlPin, alternatorControlPinMode); + unregisterOutputIfPinOrModeChanged(mainRelay, mainRelayPin, mainRelayPinMode); + unregisterOutputIfPinOrModeChanged(starterRelay, starterRelayPin, starterRelayPinMode); #endif /* EFI_PROD_CODE */ } @@ -161,7 +161,7 @@ void EnginePins::reset() { void EnginePins::stopIgnitionPins(void) { #if EFI_PROD_CODE for (int i = 0; i < IGNITION_PIN_COUNT; i++) { - unregisterOutputIfPinOrModeChanged(enginePins.coils[i], bc.ignitionPins[i], bc.ignitionPinMode); + unregisterOutputIfPinOrModeChanged(enginePins.coils[i], ignitionPins[i], ignitionPinMode); } #endif /* EFI_PROD_CODE */ } @@ -169,7 +169,7 @@ void EnginePins::stopIgnitionPins(void) { void EnginePins::stopInjectionPins(void) { #if EFI_PROD_CODE for (int i = 0; i < INJECTION_PIN_COUNT; i++) { - unregisterOutputIfPinOrModeChanged(enginePins.injectors[i], bc.injectionPins[i], bc.injectionPinMode); + unregisterOutputIfPinOrModeChanged(enginePins.injectors[i], injectionPins[i], injectionPinMode); } #endif /* EFI_PROD_CODE */ } @@ -187,8 +187,8 @@ void EnginePins::startIgnitionPins(void) { #if EFI_PROD_CODE for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { NamedOutputPin *output = &enginePins.coils[i]; - if (isPinOrModeChanged(bc.ignitionPins[i], bc.ignitionPinMode)) { - output->initPin(output->name, CONFIGB(ignitionPins)[i], &CONFIGB(ignitionPinMode)); + if (isPinOrModeChanged(ignitionPins[i], ignitionPinMode)) { + output->initPin(output->name, CONFIG(ignitionPins)[i], &CONFIG(ignitionPinMode)); } } if (isPinOrModeChanged(dizzySparkOutputPin, dizzySparkOutputPinMode)) { @@ -204,9 +204,9 @@ void EnginePins::startInjectionPins(void) { // todo: should we move this code closer to the injection logic? for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { NamedOutputPin *output = &enginePins.injectors[i]; - if (isPinOrModeChanged(bc.injectionPins[i], bc.injectionPinMode)) { - output->initPin(output->name, CONFIGB(injectionPins)[i], - &CONFIGB(injectionPinMode)); + if (isPinOrModeChanged(injectionPins[i], injectionPinMode)) { + output->initPin(output->name, CONFIG(injectionPins)[i], + &CONFIG(injectionPinMode)); } } #endif /* EFI_PROD_CODE */ @@ -368,18 +368,18 @@ void initOutputPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // memset(&outputs, 0, sizeof(outputs)); #if HAL_USE_SPI - enginePins.sdCsPin.initPin("spi CS5", CONFIGB(sdCardCsPin)); + enginePins.sdCsPin.initPin("spi CS5", CONFIG(sdCardCsPin)); #endif /* HAL_USE_SPI */ // todo: should we move this code closer to the fuel pump logic? - enginePins.fuelPumpRelay.initPin("fuel pump relay", CONFIGB(fuelPumpPin), &CONFIGB(fuelPumpPinMode)); + enginePins.fuelPumpRelay.initPin("fuel pump relay", CONFIG(fuelPumpPin), &CONFIG(fuelPumpPinMode)); - enginePins.mainRelay.initPin("main relay", CONFIGB(mainRelayPin), &CONFIGB(mainRelayPinMode)); - enginePins.starterRelay.initPin("starter relay", CONFIGB(starterRelayPin), &CONFIGB(starterRelayPinMode)); + enginePins.mainRelay.initPin("main relay", CONFIG(mainRelayPin), &CONFIG(mainRelayPinMode)); + enginePins.starterRelay.initPin("starter relay", CONFIG(starterRelayPin), &CONFIG(starterRelayPinMode)); - enginePins.fanRelay.initPin("fan relay", CONFIGB(fanPin), &CONFIGB(fanPinMode)); - enginePins.o2heater.initPin("o2 heater", CONFIGB(o2heaterPin)); - enginePins.acRelay.initPin("A/C relay", CONFIGB(acRelayPin), &CONFIGB(acRelayPinMode)); + enginePins.fanRelay.initPin("fan relay", CONFIG(fanPin), &CONFIG(fanPinMode)); + enginePins.o2heater.initPin("o2 heater", CONFIG(o2heaterPin)); + enginePins.acRelay.initPin("A/C relay", CONFIG(acRelayPin), &CONFIG(acRelayPinMode)); // digit 1 /* diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h index e1b60f3c12..b59cab4ed9 100644 --- a/firmware/controllers/system/efi_gpio.h +++ b/firmware/controllers/system/efi_gpio.h @@ -4,10 +4,10 @@ * * * @date Sep 26, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef efi_gpio_H_ -#define efi_gpio_H_ + +#pragma once #include "global.h" #include "io_pins.h" @@ -191,5 +191,3 @@ const char *portname(ioportid_t GPIOx); brain_pin_e parseBrainPin(const char *str); const char *hwPortname(brain_pin_e brainPin); - -#endif /* efi_gpio_H_ */ diff --git a/firmware/controllers/system/periodic_task.h b/firmware/controllers/system/periodic_task.h index 1b3e4eccf6..c1586c1a9e 100644 --- a/firmware/controllers/system/periodic_task.h +++ b/firmware/controllers/system/periodic_task.h @@ -35,7 +35,7 @@ public: /** * This invokes PeriodicTask() immediately and starts the cycle of invocations and sleeps */ - void Start() { + virtual void Start() { runAndScheduleNext(this); } }; diff --git a/firmware/controllers/system/periodic_thread_controller.h b/firmware/controllers/system/periodic_thread_controller.h index d9981a848b..13e7e44d47 100644 --- a/firmware/controllers/system/periodic_thread_controller.h +++ b/firmware/controllers/system/periodic_thread_controller.h @@ -53,7 +53,7 @@ protected: /** * @brief Called periodically. Override this method to do work for your controller. */ - virtual void PeriodicTask(efitime_t nowNt) = 0; + virtual void PeriodicTask(efitick_t nowNt) = 0; private: void ThreadTask() override final @@ -63,7 +63,7 @@ private: while(true) { systime_t before = chVTGetSystemTime(); - efitime_t nowNt = getTimeNowNt(); + efitick_t nowNt = getTimeNowNt(); { ScopePerf perf(PE::PeriodicControllerPeriodicTask); diff --git a/firmware/controllers/system/timer/event_queue.cpp b/firmware/controllers/system/timer/event_queue.cpp index 47260cb044..994afa9f60 100644 --- a/firmware/controllers/system/timer/event_queue.cpp +++ b/firmware/controllers/system/timer/event_queue.cpp @@ -122,72 +122,52 @@ static uint32_t lastEventCallbackDuration; int EventQueue::executeAll(efitime_t now) { ScopePerf perf(PE::EventQueueExecuteAll); - - scheduling_s * current, *tmp; - - scheduling_s * executionList = nullptr; - scheduling_s * lastInExecutionList = nullptr; - - int listIterationCounter = 0; int executionCounter = 0; - // we need safe iteration because we are removing elements inside the loop - LL_FOREACH_SAFE2(head, current, tmp, nextScheduling_s) - { - if (++listIterationCounter > QUEUE_LENGTH_LIMIT) { - firmwareError(CUSTOM_LIST_LOOP, "Is this list looped?"); - return false; - } - if (current->momentX <= now) { - executionCounter++; - efiAssert(CUSTOM_ERR_ASSERT, head == current, "removing from head", -1); - //LL_DELETE(head, current); - head = head->nextScheduling_s; - if (executionList == NULL) { - lastInExecutionList = executionList = current; - } else { - lastInExecutionList->nextScheduling_s = current; - lastInExecutionList = current; - } - current->nextScheduling_s = nullptr; - } else { - /** - * The list is sorted. Once we find one action in the future, all the remaining ones - * are also in the future. - */ - break; - } - } + #if EFI_UNIT_TEST assertListIsSorted(); #endif - /* - * we need safe iteration here because 'callback' might change change 'current->next' - * while re-inserting it into the queue from within the callback - */ - LL_FOREACH_SAFE2(executionList, current, tmp, nextScheduling_s) { - uint32_t before = getTimeNowLowerNt(); + while (true) { + // Read the head every time - a previously executed event could + // have inserted something new at the head + scheduling_s* current = head; + + // Queue is empty - bail + if (!current) { + break; + } + + // Only execute events that occured in the past. + // The list is sorted, so as soon as we see an event + // in the future, we're done. + if (current->momentX > now) { + break; + } + + executionCounter++; + + // step the head forward, unlink this element, clear scheduled flag + head = current->nextScheduling_s; + current->nextScheduling_s = nullptr; current->isScheduled = false; - uint32_t howFarOff = now - current->momentX; - maxSchedulingPrecisionLoss = maxI(maxSchedulingPrecisionLoss, howFarOff); + #if EFI_UNIT_TEST printf("QUEUE: execute current=%d param=%d\r\n", (long)current, (long)current->action.getArgument()); #endif + // Execute the current element { ScopePerf perf2(PE::EventQueueExecuteCallback); current->action.execute(); } - // even with overflow it's safe to subtract here - lastEventCallbackDuration = getTimeNowLowerNt() - before; - if (lastEventCallbackDuration > maxEventCallbackDuration) - maxEventCallbackDuration = lastEventCallbackDuration; - if (lastEventCallbackDuration > 2000) { - longScheduling = current; -// what is this line about? lastEventCallbackDuration++; - } +#if EFI_UNIT_TEST + // (tests only) Ensure we didn't break anything + assertListIsSorted(); +#endif } + return executionCounter; } @@ -198,7 +178,6 @@ int EventQueue::size(void) const { return result; } -#if EFI_UNIT_TEST void EventQueue::assertListIsSorted() const { scheduling_s *current = head; while (current != NULL && current->nextScheduling_s != NULL) { @@ -206,7 +185,6 @@ void EventQueue::assertListIsSorted() const { current = current->nextScheduling_s; } } -#endif void EventQueue::setLateDelay(int value) { lateDelay = value; diff --git a/firmware/controllers/system/timer/pwm_generator_logic.cpp b/firmware/controllers/system/timer/pwm_generator_logic.cpp index c56e38d566..2a30ac0d7a 100644 --- a/firmware/controllers/system/timer/pwm_generator_logic.cpp +++ b/firmware/controllers/system/timer/pwm_generator_logic.cpp @@ -112,7 +112,7 @@ static efitimeus_t getNextSwitchTimeUs(PwmConfig *state) { * Once 'iteration' gets relatively high, we might lose calculation precision here. * This is addressed by ITERATION_LIMIT */ - efitime_t timeToSwitchNt = (efitime_t) ((iteration + switchTime) * periodNt); + efitick_t timeToSwitchNt = (efitick_t) ((iteration + switchTime) * periodNt); #if DEBUG_PWM scheduleMsg(&logger, "start=%d timeToSwitch=%d", state->safe.start, timeToSwitch); diff --git a/firmware/controllers/system/timer/single_timer_executor.cpp b/firmware/controllers/system/timer/single_timer_executor.cpp index c6309db0ac..0bebb2a226 100644 --- a/firmware/controllers/system/timer/single_timer_executor.cpp +++ b/firmware/controllers/system/timer/single_timer_executor.cpp @@ -37,8 +37,6 @@ EXTERN_ENGINE; extern schfunc_t globalTimerCallback; -//static int timerIsLate = 0; -//static efitime_t callbackTime = 0; /** * these fields are global in order to facilitate debugging */ @@ -49,7 +47,7 @@ uint32_t lastExecutionCount; static void executorCallback(void *arg) { (void)arg; - efiAssertVoid(CUSTOM_ERR_6624, getCurrentRemainingStack() > 256, "lowstck#2y"); + efiAssertVoid(CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y"); // callbackTime = getTimeNowNt(); // if ((callbackTime > nextEventTimeNt) && (callbackTime - nextEventTimeNt > US2NT(5000))) { diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 2a885c3ff5..55c6a0571b 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -418,7 +418,7 @@ void TriggerWaveform::setSecondTriggerSynchronizationGap(float syncRatio) { void TriggerWaveform::initializeTriggerWaveform(Logging *logger, operation_mode_e ambiguousOperationMode, bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig) { #if EFI_PROD_CODE - efiAssertVoid(CUSTOM_ERR_6641, getCurrentRemainingStack() > 256, "init t"); + efiAssertVoid(CUSTOM_ERR_6641, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init t"); scheduleMsg(logger, "initializeTriggerWaveform(%s/%d)", getTrigger_type_e(triggerConfig->type), (int) triggerConfig->type); #endif diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 71ab35c636..3d7c82583f 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -15,7 +15,6 @@ #include "engine_configuration.h" #include "listener_array.h" #include "data_buffer.h" -#include "histogram.h" #include "pwm_generator_logic.h" #include "tooth_logger.h" @@ -68,10 +67,6 @@ int TriggerCentral::getHwEventCounter(int index) const { EXTERN_ENGINE; -#if EFI_HISTOGRAMS -static histogram_s triggerCallbackHistogram; -#endif /* EFI_HISTOGRAMS */ - static Logging *logger; void TriggerCentral::addEventListener(ShaftPositionListener listener, const char *name, Engine *engine) { @@ -100,7 +95,7 @@ void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX) addEngineSnifferEvent(PROTOCOL_VVT_NAME, front == TV_RISE ? PROTOCOL_ES_UP : PROTOCOL_ES_DOWN); - if (CONFIGB(vvtCamSensorUseRise) ^ (front != TV_FALL)) { + if (CONFIG(vvtCamSensorUseRise) ^ (front != TV_FALL)) { return; } @@ -126,7 +121,7 @@ void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX) if (engineConfiguration->verboseTriggerSynchDetails) { scheduleMsg(logger, "vvt ratio %.2f", ratio); } - if (ratio < CONFIGB(miataNb2VVTRatioFrom) || ratio > CONFIGB(miataNb2VVTRatioTo)) { + if (ratio < CONFIG(miataNb2VVTRatioFrom) || ratio > CONFIG(miataNb2VVTRatioTo)) { return; } if (engineConfiguration->verboseTriggerSynchDetails) { @@ -210,7 +205,7 @@ void hwHandleShaftSignal(trigger_event_e signal) { // for effective noise filtering, we need both signal edges, // so we pass them to handleShaftSignal() and defer this test - if (!CONFIGB(useNoiselessTriggerDecoder)) { + if (!CONFIG(useNoiselessTriggerDecoder)) { if (!isUsefulSignal(signal PASS_ENGINE_PARAMETER_SUFFIX)) { return; } @@ -333,7 +328,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR nowNt = getTimeNowNt(); // This code gathers some statistics on signals and compares accumulated periods to filter interference - if (CONFIGB(useNoiselessTriggerDecoder)) { + if (CONFIG(useNoiselessTriggerDecoder)) { if (!noiseFilter(nowNt, signal PASS_ENGINE_PARAMETER_SUFFIX)) { return; } @@ -345,9 +340,6 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR engine->onTriggerSignalEvent(nowNt); -#if EFI_HISTOGRAMS && EFI_PROD_CODE - int beforeCallback = hal_lld_get_counter_value(); -#endif int eventIndex = (int) signal; efiAssertVoid(CUSTOM_ERR_6638, eventIndex >= 0 && eventIndex < HW_EVENT_TYPES, "signal type"); hwEventCounters[eventIndex]++; @@ -409,20 +401,6 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR } } -#if EFI_HISTOGRAMS - int afterCallback = hal_lld_get_counter_value(); - int diff = afterCallback - beforeCallback; - // this counter is only 32 bits so it overflows every minute, let's ignore the value in case of the overflow for simplicity - if (diff > 0) { - hsAdd(&triggerCallbackHistogram, diff); - } -#endif /* EFI_HISTOGRAMS */ -} - -void printAllCallbacksHistogram(void) { -#if EFI_HISTOGRAMS - printHistogram(logger, &triggerCallbackHistogram); -#endif } EXTERN_ENGINE @@ -469,7 +447,7 @@ void printAllTriggers() { Engine *engine = &e; persistent_config_s *config = &pc; engine_configuration_s *engineConfiguration = &pc.engineConfiguration; - board_configuration_s *boardConfiguration = &engineConfiguration->bc; + engineConfiguration->trigger.type = tt; engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR; @@ -604,27 +582,27 @@ void triggerInfo(void) { } - scheduleMsg(logger, "primary trigger input: %s", hwPortname(CONFIGB(triggerInputPins)[0])); + scheduleMsg(logger, "primary trigger input: %s", hwPortname(CONFIG(triggerInputPins)[0])); scheduleMsg(logger, "primary trigger simulator: %s %s freq=%d", - hwPortname(CONFIGB(triggerSimulatorPins)[0]), - getPin_output_mode_e(CONFIGB(triggerSimulatorPinModes)[0]), - CONFIGB(triggerSimulatorFrequency)); + hwPortname(CONFIG(triggerSimulatorPins)[0]), + getPin_output_mode_e(CONFIG(triggerSimulatorPinModes)[0]), + CONFIG(triggerSimulatorFrequency)); if (ts->needSecondTriggerInput) { - scheduleMsg(logger, "secondary trigger input: %s", hwPortname(CONFIGB(triggerInputPins)[1])); + scheduleMsg(logger, "secondary trigger input: %s", hwPortname(CONFIG(triggerInputPins)[1])); #if EFI_EMULATE_POSITION_SENSORS scheduleMsg(logger, "secondary trigger simulator: %s %s phase=%d", - hwPortname(CONFIGB(triggerSimulatorPins)[1]), - getPin_output_mode_e(CONFIGB(triggerSimulatorPinModes)[1]), triggerSignal.safe.phaseIndex); + hwPortname(CONFIG(triggerSimulatorPins)[1]), + getPin_output_mode_e(CONFIG(triggerSimulatorPinModes)[1]), triggerSignal.safe.phaseIndex); #endif /* EFI_EMULATE_POSITION_SENSORS */ } -// scheduleMsg(logger, "3rd trigger simulator: %s %s", hwPortname(CONFIGB(triggerSimulatorPins)[2]), -// getPin_output_mode_e(CONFIGB(triggerSimulatorPinModes)[2])); +// scheduleMsg(logger, "3rd trigger simulator: %s %s", hwPortname(CONFIG(triggerSimulatorPins)[2]), +// getPin_output_mode_e(CONFIG(triggerSimulatorPinModes)[2])); - scheduleMsg(logger, "trigger error extra LED: %s %s", hwPortname(CONFIGB(triggerErrorPin)), - getPin_output_mode_e(CONFIGB(triggerErrorPinMode))); - scheduleMsg(logger, "primary logic input: %s", hwPortname(CONFIGB(logicAnalyzerPins)[0])); - scheduleMsg(logger, "secondary logic input: %s", hwPortname(CONFIGB(logicAnalyzerPins)[1])); + scheduleMsg(logger, "trigger error extra LED: %s %s", hwPortname(CONFIG(triggerErrorPin)), + getPin_output_mode_e(CONFIG(triggerErrorPinMode))); + scheduleMsg(logger, "primary logic input: %s", hwPortname(CONFIG(logicAnalyzerPins)[0])); + scheduleMsg(logger, "secondary logic input: %s", hwPortname(CONFIG(logicAnalyzerPins)[1])); scheduleMsg(logger, "zeroTestTime=%d maxSchedulingPrecisionLoss=%d", engine->m.zeroTestTime, maxSchedulingPrecisionLoss); @@ -685,15 +663,15 @@ void onConfigurationChangeTriggerCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { isConfigurationChanged(globalTriggerAngleOffset) || isConfigurationChanged(trigger.customTotalToothCount) || isConfigurationChanged(trigger.customSkippedToothCount) || - isConfigurationChanged(bc.triggerInputPins[0]) || - isConfigurationChanged(bc.triggerInputPins[1]) || - isConfigurationChanged(bc.triggerInputPins[2]) || + isConfigurationChanged(triggerInputPins[0]) || + isConfigurationChanged(triggerInputPins[1]) || + isConfigurationChanged(triggerInputPins[2]) || isConfigurationChanged(vvtMode) || - isConfigurationChanged(bc.vvtCamSensorUseRise) || + isConfigurationChanged(vvtCamSensorUseRise) || isConfigurationChanged(vvtOffset) || isConfigurationChanged(vvtDisplayInverted) || - isConfigurationChanged(bc.miataNb2VVTRatioFrom) || - isConfigurationChanged(bc.miataNb2VVTRatioTo) || + isConfigurationChanged(miataNb2VVTRatioFrom) || + isConfigurationChanged(miataNb2VVTRatioTo) || isConfigurationChanged(nbVvtIndex); if (changed) { assertEngineReference(); @@ -738,9 +716,6 @@ void initTriggerCentral(Logging *sharedLogger) { addConsoleAction("reset_trigger", resetRunningTriggerCounters); #endif -#if EFI_HISTOGRAMS - initHistogram(&triggerCallbackHistogram, "all callbacks"); -#endif /* EFI_HISTOGRAMS */ } #endif diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 792feb997c..0a81c26416 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -2,11 +2,10 @@ * @file trigger_central.h * * @date Feb 23, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef TRIGGER_CENTRAL_H_ -#define TRIGGER_CENTRAL_H_ +#pragma once #include "rusefi_enums.h" #include "listener_array.h" @@ -46,7 +45,7 @@ public: efitick_t previousVvtCamTime = 0; efitick_t previousVvtCamDuration = 0; - volatile efitime_t previousShaftEventTimeNt; + volatile efitick_t previousShaftEventTimeNt; private: IntListenerArray<15> triggerListeneres; @@ -57,12 +56,10 @@ private: }; void triggerInfo(void); -efitime_t getCrankEventCounter(DECLARE_ENGINE_PARAMETER_SIGNATURE); void hwHandleShaftSignal(trigger_event_e signal); void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX); void initTriggerCentral(Logging *sharedLogger); -void printAllCallbacksHistogram(void); void printAllTriggers(); void addTriggerEventListener(ShaftPositionListener handler, const char *name, Engine *engine); @@ -73,4 +70,3 @@ void onConfigurationChangeTriggerCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE); bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE); bool isTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE); -#endif /* TRIGGER_CENTRAL_H_ */ diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index da07d6816b..6db793f07b 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -122,7 +122,7 @@ bool isTriggerDecoderError(void) { void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_PROD_CODE - efiAssertVoid(CUSTOM_ERR_6642, getCurrentRemainingStack() > 256, "calc s"); + efiAssertVoid(CUSTOM_ERR_6642, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "calc s"); #endif trigger_config_s const*triggerConfig = &engineConfiguration->trigger; @@ -172,7 +172,7 @@ void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECL } } -efitime_t TriggerState::getTotalEventCounter() const { +int64_t TriggerState::getTotalEventCounter() const { return totalEventCountBase + currentCycle.current_index; } @@ -188,7 +188,7 @@ void TriggerStateWithRunningStatistics::movePreSynchTimestamps(DECLARE_ENGINE_PA } } -float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndexOut, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { +float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndexOut, efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { int current_index = currentCycle.current_index; // local copy so that noone changes the value on us timeOfLastEvent[current_index] = nowNt; /** @@ -236,7 +236,7 @@ float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndexOut, return instantRpm; } -void TriggerStateWithRunningStatistics::setLastEventTimeForInstantRpm(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { +void TriggerStateWithRunningStatistics::setLastEventTimeForInstantRpm(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { if (shaft_is_synchronized) { return; } @@ -250,7 +250,7 @@ void TriggerStateWithRunningStatistics::setLastEventTimeForInstantRpm(efitime_t spinningEvents[spinningEventIndex++] = nowNt; } -void TriggerStateWithRunningStatistics::runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { +void TriggerStateWithRunningStatistics::runtimeStatistics(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { if (engineConfiguration->debugMode == DBG_INSTANT_RPM) { instantRpm = calculateInstantRpm(NULL, nowNt PASS_ENGINE_PARAMETER_SUFFIX); } @@ -260,7 +260,7 @@ void TriggerStateWithRunningStatistics::runtimeStatistics(efitime_t nowNt DECLAR #if EFI_SENSOR_CHART angle_t currentAngle = TRIGGER_WAVEFORM(eventAngles[currentCycle.current_index]); - if (CONFIGB(sensorChartMode) == SC_DETAILED_RPM) { + if (CONFIG(sensorChartMode) == SC_DETAILED_RPM) { scAddData(currentAngle, instantRpm); } else { scAddData(currentAngle, instantRpm / instantRpmValue[prevIndex]); @@ -385,7 +385,7 @@ void TriggerState::handleTriggerError(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } void TriggerState::onShaftSynchronization(const TriggerStateCallback triggerCycleCallback, - efitime_t nowNt, trigger_wheel_e triggerWheel DECLARE_ENGINE_PARAMETER_SUFFIX) { + efitick_t nowNt, trigger_wheel_e triggerWheel DECLARE_ENGINE_PARAMETER_SUFFIX) { setShaftSynchronized(true); // this call would update duty cycle values nextTriggerEvent() @@ -418,7 +418,7 @@ void TriggerState::onShaftSynchronization(const TriggerStateCallback triggerCycl */ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCallback, TriggerStateListener * triggerStateListener, - trigger_event_e const signal, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { + trigger_event_e const signal, efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { ScopePerf perf(PE::DecodeTriggerEvent, static_cast(signal)); bool useOnlyRisingEdgeForTrigger = CONFIG(useOnlyRisingEdgeForTrigger); @@ -441,7 +441,7 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal efiAssertVoid(CUSTOM_OBD_93, toothed_previous_time <= nowNt, "toothed_previous_time after nowNt"); - efitime_t currentDurationLong = getCurrentGapDuration(nowNt); + efitick_t currentDurationLong = getCurrentGapDuration(nowNt); /** * For performance reasons, we want to work with 32 bit values. If there has been more then @@ -562,6 +562,12 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal #if EFI_PROD_CODE || EFI_SIMULATOR if (CONFIG(verboseTriggerSynchDetails) || (someSortOfTriggerError && !silentTriggerError)) { for (int i = 0;ibc.triggerSimulatorFrequency = rpm; + engineConfiguration->triggerSimulatorFrequency = rpm; /** * All we need to do here is to change the periodMs * togglePwmState() would see that the periodMs has changed and act accordingly @@ -107,10 +107,7 @@ void setTriggerEmulatorRPM(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { float rPerSecond = rpm * rpmM / 60.0; // per minute converted to per second triggerSignal.setFrequency(rPerSecond); } -#if EFI_ENGINE_SNIFFER - if (engine->isTestMode) - waveChart.reset(); -#endif /* EFI_ENGINE_SNIFFER */ + engine->resetEngineSnifferIfInTestMode(); scheduleMsg(logger, "Emulating position sensor(s). RPM=%d", rpm); } @@ -165,7 +162,7 @@ void initTriggerEmulatorLogic(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUF logger = sharedLogger; TriggerWaveform *s = &engine->triggerCentral.triggerShape; - setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency PASS_ENGINE_PARAMETER_SUFFIX); + setTriggerEmulatorRPM(engineConfiguration->triggerSimulatorFrequency PASS_ENGINE_PARAMETER_SUFFIX); pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.channels[0].pinStates, s->wave.channels[1].pinStates, diff --git a/firmware/development/engine_emulator.cpp b/firmware/development/engine_emulator.cpp index bbd28ac21a..2598da02be 100644 --- a/firmware/development/engine_emulator.cpp +++ b/firmware/development/engine_emulator.cpp @@ -41,7 +41,6 @@ static void emulate(void) { print("Emulating...\r\n"); setDiag(1); chThdSleep(1); - setFullLog(1); for (int i = 400; i <= 1300; i++) { if (i % 50 != 0) @@ -52,7 +51,6 @@ static void emulate(void) { setTriggerEmulatorRPM(0 PASS_ENGINE_PARAMETER_SUFFIX); - setFullLog(0); setDiag(0); chThdSleep(1); print("Emulation DONE!\r\n"); diff --git a/firmware/development/engine_sniffer.cpp b/firmware/development/engine_sniffer.cpp index 6be646565a..32c7eba405 100644 --- a/firmware/development/engine_sniffer.cpp +++ b/firmware/development/engine_sniffer.cpp @@ -34,15 +34,10 @@ #include "engine_configuration.h" #include "eficonsole.h" #include "status_loop.h" +#include "perf_trace.h" #define CHART_DELIMETER '!' -#if EFI_HISTOGRAMS -#include "os_util.h" -#include "histogram.h" -static histogram_s engineSnifferHisto; -#endif /* EFI_HISTOGRAMS */ - EXTERN_ENGINE ; extern uint32_t maxLockedDuration; @@ -113,7 +108,7 @@ bool WaveChart::isStartedTooLongAgo() const { * engineChartSize/20 is the longest meaningful chart. * */ - efitime_t chartDurationNt = getTimeNowNt() - startTimeNt; + efitick_t chartDurationNt = getTimeNowNt() - startTimeNt; return startTimeNt != 0 && NT2US(chartDurationNt) > engineConfiguration->engineChartSize * 1000000 / 20; } @@ -165,6 +160,11 @@ void WaveChart::publish() { * @brief Register an event for digital sniffer */ void WaveChart::addEvent3(const char *name, const char * msg) { + ScopePerf perf(PE::EngineSniffer); + + if (getTimeNowNt() < pauseEngineSnifferUntilNt) { + return; + } #if EFI_TEXT_LOGGING if (!ENGINE(isEngineChartEnabled)) { return; @@ -192,9 +192,6 @@ void WaveChart::addEvent3(const char *name, const char * msg) { return; } -#if EFI_HISTOGRAMS && EFI_PROD_CODE - int beforeCallback = hal_lld_get_counter_value(); -#endif efitick_t nowNt = getTimeNowNt(); @@ -235,22 +232,9 @@ void WaveChart::addEvent3(const char *name, const char * msg) { if (!alreadyLocked) { unlockOutputBuffer(); } - -#if EFI_HISTOGRAMS && EFI_PROD_CODE - int64_t diff = hal_lld_get_counter_value() - beforeCallback; - if (diff > 0) { - hsAdd(&engineSnifferHisto, diff); - } -#endif /* EFI_HISTOGRAMS */ #endif /* EFI_TEXT_LOGGING */ } -void showWaveChartHistogram(void) { -#if EFI_HISTOGRAMS && EFI_PROD_CODE - printHistogram(&logger, &engineSnifferHisto); -#endif -} - void initWaveChart(WaveChart *chart) { /** * constructor does not work because we need specific initialization order @@ -270,7 +254,7 @@ void initWaveChart(WaveChart *chart) { addConsoleActionI("chartsize", setChartSize); addConsoleActionI("chart", setChartActive); #if ! EFI_UNIT_TEST - addConsoleAction("reset_engine_chart", resetNow); + addConsoleAction(CMD_RESET_ENGINE_SNIFFER, resetNow); #endif } diff --git a/firmware/development/engine_sniffer.h b/firmware/development/engine_sniffer.h index cbf1c9f05d..4968a26404 100644 --- a/firmware/development/engine_sniffer.h +++ b/firmware/development/engine_sniffer.h @@ -28,6 +28,8 @@ public: void publish(); bool isFull() const; bool isStartedTooLongAgo() const; + efitick_t pauseEngineSnifferUntilNt = 0; + private: Logging logging; char timeBuffer[_MAX_FILLER + 2]; @@ -37,12 +39,11 @@ private: * https://github.com/rusefi/rusefi/issues/780 */ bool collectingData = false; - efitime_t startTimeNt = 0; + efitick_t startTimeNt = 0; volatile int isInitialized = false; }; void initWaveChart(WaveChart *chart); -void showWaveChartHistogram(void); void setChartSize(int newSize); #endif /* EFI_ENGINE_SNIFFER */ diff --git a/firmware/development/hw_layer/poten.cpp b/firmware/development/hw_layer/poten.cpp index ab9d241938..a85ef6e0fa 100644 --- a/firmware/development/hw_layer/poten.cpp +++ b/firmware/development/hw_layer/poten.cpp @@ -97,19 +97,19 @@ static void setPotValue1(int value) { void initPotentiometers(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { logger = sharedLogger; #if EFI_POTENTIOMETER - if (CONFIGB(digitalPotentiometerSpiDevice) == SPI_NONE) { + if (CONFIG(digitalPotentiometerSpiDevice) == SPI_NONE) { scheduleMsg(logger, "digiPot spi disabled"); return; } - turnOnSpi(CONFIGB(digitalPotentiometerSpiDevice)); + turnOnSpi(CONFIG(digitalPotentiometerSpiDevice)); for (int i = 0; i < DIGIPOT_COUNT; i++) { - brain_pin_e csPin = CONFIGB(digitalPotentiometerChipSelect)[i]; + brain_pin_e csPin = CONFIG(digitalPotentiometerChipSelect)[i]; if (csPin == GPIO_UNASSIGNED) { continue; } - SPIDriver *driver = getSpiDevice(CONFIGB(digitalPotentiometerSpiDevice)); + SPIDriver *driver = getSpiDevice(CONFIG(digitalPotentiometerSpiDevice)); if (driver == NULL) { // error already reported return; diff --git a/firmware/development/logic_analyzer.cpp b/firmware/development/logic_analyzer.cpp index b9e0317bcd..cc48f30c44 100644 --- a/firmware/development/logic_analyzer.cpp +++ b/firmware/development/logic_analyzer.cpp @@ -43,7 +43,7 @@ extern bool hasFirmwareErrorFlag; * Difference between current 1st trigger event and previous 1st trigger event. */ static volatile uint32_t engineCycleDurationUs; -static volatile efitime_t previousEngineCycleTimeUs = 0; +static volatile efitimeus_t previousEngineCycleTimeUs = 0; static int waveReaderCount = 0; static WaveReader readers[MAX_ICU_COUNT]; @@ -101,12 +101,12 @@ static void waIcuPeriodCallback(WaveReader *reader) { } static void initWave(const char *name, int index) { - brain_pin_e brainPin = CONFIGB(logicAnalyzerPins)[index]; + brain_pin_e brainPin = CONFIG(logicAnalyzerPins)[index]; if (brainPin == GPIO_UNASSIGNED) return; - bool mode = CONFIGB(logicAnalyzerMode)[index]; + bool mode = CONFIG(logicAnalyzerMode)[index]; waveReaderCount++; efiAssertVoid(CUSTOM_ERR_6655, index < MAX_ICU_COUNT, "too many ICUs"); @@ -133,7 +133,7 @@ static void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index if (index != 0) { return; } - efitick_t nowUs = getTimeNowUs(); + efitimeus_t nowUs = getTimeNowUs(); engineCycleDurationUs = nowUs - previousEngineCycleTimeUs; previousEngineCycleTimeUs = nowUs; } diff --git a/firmware/development/perf_trace.h b/firmware/development/perf_trace.h index a45120480b..98ca956ef0 100644 --- a/firmware/development/perf_trace.h +++ b/firmware/development/perf_trace.h @@ -30,7 +30,7 @@ enum class PE : uint8_t { PeriodicControllerPeriodicTask, PeriodicTimerControllerPeriodicTask, AdcCallbackFast, - AdcCallbackSlow, + AdcProcessSlow, AdcConversionSlow, AdcConversionFast, AdcSubscriptionUpdateSubscribers, @@ -47,12 +47,17 @@ enum class PE : uint8_t { MapAveragingTriggerCallback, AdcCallbackFastComplete, SingleTimerExecutorScheduleByTimestamp, - ScheduleByAngle, + GetTimeNowUs, EventQueueExecuteCallback, PwmGeneratorCallback, TunerStudioHandleCrcCommand, PwmConfigTogglePwmState, PwmConfigStateChangeCallback, + Temporary1, + Temporary2, + Temporary3, + Temporary4, + EngineSniffer, // enum_end_tag // The tag above is consumed by PerfTraceTool.java // please note that the tool requires a comma at the end of last value diff --git a/firmware/development/trigger_emulator.cpp b/firmware/development/trigger_emulator.cpp index 55f910d080..cc7f1a1134 100644 --- a/firmware/development/trigger_emulator.cpp +++ b/firmware/development/trigger_emulator.cpp @@ -29,11 +29,11 @@ static OutputPin emulatorOutputs[3]; EXTERN_ENGINE; void onConfigurationChangeRpmEmulatorCallback(engine_configuration_s *previousConfiguration) { - if (engineConfiguration->bc.triggerSimulatorFrequency == - previousConfiguration->bc.triggerSimulatorFrequency) { + if (engineConfiguration->triggerSimulatorFrequency == + previousConfiguration->triggerSimulatorFrequency) { return; } - setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency); + setTriggerEmulatorRPM(engineConfiguration->triggerSimulatorFrequency); } void initTriggerEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { @@ -48,14 +48,14 @@ void initTriggerEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) #if EFI_PROD_CODE // todo: refactor, make this a loop - triggerSignal.outputPins[0]->initPin("trg emulator ch1", CONFIGB(triggerSimulatorPins)[0], - &CONFIGB(triggerSimulatorPinModes)[0]); + triggerSignal.outputPins[0]->initPin("trg emulator ch1", CONFIG(triggerSimulatorPins)[0], + &CONFIG(triggerSimulatorPinModes)[0]); - triggerSignal.outputPins[1]->initPin("trg emulator ch2", CONFIGB(triggerSimulatorPins)[1], - &CONFIGB(triggerSimulatorPinModes)[1]); + triggerSignal.outputPins[1]->initPin("trg emulator ch2", CONFIG(triggerSimulatorPins)[1], + &CONFIG(triggerSimulatorPinModes)[1]); - triggerSignal.outputPins[2]->initPin("trg emulator ch3", CONFIGB(triggerSimulatorPins)[2], - &CONFIGB(triggerSimulatorPinModes)[2]); + triggerSignal.outputPins[2]->initPin("trg emulator ch3", CONFIG(triggerSimulatorPins)[2], + &CONFIG(triggerSimulatorPinModes)[2]); #endif /* EFI_PROD_CODE */ initTriggerEmulatorLogic(sharedLogger); diff --git a/firmware/flash_dfu.bat b/firmware/flash_dfu.bat index fa12fe22db..20a5ee80e0 100644 --- a/firmware/flash_dfu.bat +++ b/firmware/flash_dfu.bat @@ -1,4 +1,7 @@ +rem +rem ..\misc\encedo_hex2dfu\hex2dfu.exe -i build/rusefi.hex -o build/rusefi.dfu + rem on linux that would be rem dfu-util -a 0 -D rusefi_no_asserts.dfu -R diff --git a/firmware/hw_layer/AdcConfiguration.h b/firmware/hw_layer/AdcConfiguration.h index 40beb64d4b..4d4ff615d3 100644 --- a/firmware/hw_layer/AdcConfiguration.h +++ b/firmware/hw_layer/AdcConfiguration.h @@ -37,7 +37,7 @@ public: // F4 does not care __ALIGNED(32) adcsample_t samples[ADC_MAX_CHANNELS_COUNT * MAX_ADC_GRP_BUF_DEPTH]; // Assert multiple of 32 bytes long so we don't stomp on the data after the buffer - static_assert(sizeof(samples) % 32 == 0, "ADC sample buffer alignment"); + static_assert(sizeof(samples) % 32 == 0, "ADC sample buffer size must be a multiple of 32 bytes"); int getAdcValueByHwChannel(int hwChannel) const; diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 70ba7f5104..d3952dcc93 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -30,6 +30,7 @@ #include "adc_subscription.h" #include "AdcConfiguration.h" #include "mpu_util.h" +#include "periodic_thread_controller.h" #include "pin_repository.h" #include "engine_math.h" @@ -71,14 +72,6 @@ AdcDevice::AdcDevice(ADCConversionGroup* hwConfig) { memset(internalAdcIndexByHardwareIndex, 0xFFFFFFFF, sizeof(internalAdcIndexByHardwareIndex)); } -#if !defined(PWM_FREQ_SLOW) || !defined(PWM_PERIOD_SLOW) -// todo: migrate from hardware timer to software ADC conversion triggering -// todo: I guess we would have to use ChibiOS timer and not our own timer because -// todo: adcStartConversionI requires OS lock. currently slow ADC is 20Hz -#define PWM_FREQ_SLOW 5000 /* PWM clock frequency. I wonder what does this setting mean? */ -#define PWM_PERIOD_SLOW 25 /* PWM period (in PWM ticks). */ -#endif /* PWM_FREQ_SLOW PWM_PERIOD_SLOW */ - #if !defined(PWM_FREQ_FAST) || !defined(PWM_PERIOD_FAST) /** * 8000 RPM is 133Hz @@ -109,15 +102,16 @@ static int adcDebugReporting = false; EXTERN_ENGINE; static adcsample_t getAvgAdcValue(int index, adcsample_t *samples, int bufDepth, int numChannels) { - adcsample_t result = 0; + uint32_t result = 0; for (int i = 0; i < bufDepth; i++) { result += samples[index]; index += numChannels; } - return result / bufDepth; + + // this truncation is guaranteed to not be lossy - the average can't be larger than adcsample_t + return static_cast(result / bufDepth); } -static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n); // See https://github.com/rusefi/rusefi/issues/976 for discussion on these values #define ADC_SAMPLING_SLOW ADC_SAMPLE_56 @@ -125,7 +119,7 @@ static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n); /* * ADC conversion group. */ -static ADCConversionGroup adcgrpcfgSlow = { FALSE, 0, adc_callback_slow, NULL, +static ADCConversionGroup adcgrpcfgSlow = { FALSE, 0, nullptr, NULL, /* HW dependent part.*/ ADC_TwoSamplingDelay_20Cycles, // cr1 ADC_CR2_SWSTART, // cr2 @@ -207,39 +201,7 @@ ADC_TwoSamplingDelay_5Cycles, // cr1 AdcDevice fastAdc(&adcgrpcfg_fast); -void doSlowAdc(void) { - - efiAssertVoid(CUSTOM_ERR_6658, getCurrentRemainingStack()> 32, "lwStAdcSlow"); - -#if EFI_INTERNAL_ADC - - /* Starts an asynchronous ADC conversion operation, the conversion - will be executed in parallel to the current PWM cycle and will - terminate before the next PWM cycle.*/ - slowAdc.conversionCount++; - chSysLockFromISR() - ; - if (ADC_SLOW_DEVICE.state != ADC_READY && - ADC_SLOW_DEVICE.state != ADC_COMPLETE && - ADC_SLOW_DEVICE.state != ADC_ERROR) { - // todo: why and when does this happen? firmwareError(OBD_PCM_Processor_Fault, "ADC slow not ready?"); - slowAdc.errorsCount++; - chSysUnlockFromISR() - ; - return; - } - - adcStartConversionI(&ADC_SLOW_DEVICE, &adcgrpcfgSlow, slowAdc.samples, ADC_BUF_DEPTH_SLOW); - chSysUnlockFromISR() - ; -#endif /* EFI_INTERNAL_ADC */ -} - #if HAL_USE_PWM -static void pwmpcb_slow(PWMDriver *pwmp) { - (void) pwmp; - doSlowAdc(); -} static void pwmpcb_fast(PWMDriver *pwmp) { efiAssertVoid(CUSTOM_ERR_6659, getCurrentRemainingStack()> 32, "lwStAdcFast"); @@ -311,12 +273,6 @@ int getInternalAdcValue(const char *msg, adc_channel_e hwChannel) { } #if HAL_USE_PWM -static PWMConfig pwmcfg_slow = { PWM_FREQ_SLOW, PWM_PERIOD_SLOW, pwmpcb_slow, { { -PWM_OUTPUT_DISABLED, NULL }, { PWM_OUTPUT_DISABLED, NULL }, { -PWM_OUTPUT_DISABLED, NULL }, { PWM_OUTPUT_DISABLED, NULL } }, -/* HW dependent part.*/ -0, 0 }; - static PWMConfig pwmcfg_fast = { PWM_FREQ_FAST, PWM_PERIOD_FAST, pwmpcb_fast, { { PWM_OUTPUT_DISABLED, NULL }, { PWM_OUTPUT_DISABLED, NULL }, { PWM_OUTPUT_DISABLED, NULL }, { PWM_OUTPUT_DISABLED, NULL } }, @@ -457,33 +413,53 @@ int getSlowAdcCounter() { return slowAdcCounter; } -static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) { - (void) buffer; - (void) n; - ScopePerf perf(PE::AdcCallbackSlow); - - /* Note, only in the ADC_COMPLETE state because the ADC driver fires - * an intermediate callback when the buffer is half full. */ - if (adcp->state == ADC_COMPLETE) { - slowAdc.invalidateSamplesCache(); - - efiAssertVoid(CUSTOM_STACK_ADC_6671, getCurrentRemainingStack() > 128, "lowstck#9c"); - - /* Calculates the average values from the ADC samples.*/ - for (int i = 0; i < slowAdc.size(); i++) { - int value = getAvgAdcValue(i, slowAdc.samples, ADC_BUF_DEPTH_SLOW, slowAdc.size()); - adcsample_t prev = slowAdc.values.adc_data[i]; - float result = (slowAdcCounter == 0) ? value : - CONFIG(slowAdcAlpha) * value + (1 - CONFIG(slowAdcAlpha)) * prev; - - slowAdc.values.adc_data[i] = (int)result; - } - slowAdcCounter++; - - AdcSubscription::UpdateSubscribers(); +class SlowAdcController : public PeriodicController<256> { +public: + SlowAdcController() + : PeriodicController("ADC", NORMALPRIO + 5, 200) + { } -} + + void PeriodicTask(efitick_t nowNt) override { + { + ScopePerf perf(PE::AdcConversionSlow); + + slowAdc.conversionCount++; + msg_t result = adcConvert(&ADC_SLOW_DEVICE, &adcgrpcfgSlow, slowAdc.samples, ADC_BUF_DEPTH_SLOW); + + // If something went wrong - try again later + if (result == MSG_RESET || result == MSG_TIMEOUT) { + slowAdc.errorsCount++; + return; + } + +#ifdef USE_ADC3_VBATT_HACK + void proteusAdcHack(); + proteusAdcHack(); +#endif + } + + { + ScopePerf perf(PE::AdcProcessSlow); + + slowAdc.invalidateSamplesCache(); + + /* Calculates the average values from the ADC samples.*/ + for (int i = 0; i < slowAdc.size(); i++) { + adcsample_t value = getAvgAdcValue(i, slowAdc.samples, ADC_BUF_DEPTH_SLOW, slowAdc.size()); + adcsample_t prev = slowAdc.values.adc_data[i]; + float result = (slowAdcCounter == 0) ? value : + CONFIG(slowAdcAlpha) * value + (1 - CONFIG(slowAdcAlpha)) * prev; + + slowAdc.values.adc_data[i] = (adcsample_t)result; + } + slowAdcCounter++; + + AdcSubscription::UpdateSubscribers(); + } + } +}; static char errorMsgBuff[_MAX_FILLER + 2]; @@ -543,9 +519,9 @@ static void configureInputs(void) { addChannel("IAT", engineConfiguration->iat.adcChannel, ADC_SLOW); addChannel("AUXT#1", engineConfiguration->auxTempSensor1.adcChannel, ADC_SLOW); addChannel("AUXT#2", engineConfiguration->auxTempSensor2.adcChannel, ADC_SLOW); - if (engineConfiguration->bc.auxFastSensor1_adcChannel != EFI_ADC_0) { + if (engineConfiguration->auxFastSensor1_adcChannel != EFI_ADC_0) { // allow EFI_ADC_0 next time we have an incompatible configuration change - addChannel("AUXF#1", engineConfiguration->bc.auxFastSensor1_adcChannel, ADC_FAST); + addChannel("AUXF#1", engineConfiguration->auxFastSensor1_adcChannel, ADC_FAST); } addChannel("AFR", engineConfiguration->afr.hwChannel, ADC_SLOW); addChannel("OilP", engineConfiguration->oilPressure.hwChannel, ADC_SLOW); @@ -555,7 +531,7 @@ static void configureInputs(void) { if (engineConfiguration->high_fuel_pressure_sensor_2 != INCOMPATIBLE_CONFIG_CHANGE) addChannel("HFP2", engineConfiguration->high_fuel_pressure_sensor_2, ADC_SLOW); - if (CONFIGB(isCJ125Enabled)) { + if (CONFIG(isCJ125Enabled)) { addChannel("cj125ur", engineConfiguration->cj125ur, ADC_SLOW); addChannel("cj125ua", engineConfiguration->cj125ua, ADC_SLOW); } @@ -567,6 +543,8 @@ static void configureInputs(void) { setAdcChannelOverrides(); } +static SlowAdcController slowAdcController; + void initAdcInputs() { printMsg(&logger, "initAdcInputs()"); if (ADC_BUF_DEPTH_FAST > MAX_ADC_GRP_BUF_DEPTH) @@ -606,12 +584,11 @@ void initAdcInputs() { #endif /* ADC_CHANNEL_SENSOR */ slowAdc.init(); -#if HAL_USE_PWM - pwmStart(EFI_INTERNAL_SLOW_ADC_PWM, &pwmcfg_slow); - pwmEnablePeriodicNotification(EFI_INTERNAL_SLOW_ADC_PWM); -#endif /* HAL_USE_PWM */ - if (CONFIGB(isFastAdcEnabled)) { + // Start the slow ADC thread + slowAdcController.Start(); + + if (CONFIG(isFastAdcEnabled)) { fastAdc.init(); /* * Initializes the PWM driver. diff --git a/firmware/hw_layer/can_hw.cpp b/firmware/hw_layer/can_hw.cpp index 692c9b8fb1..e37a752ce4 100644 --- a/firmware/hw_layer/can_hw.cpp +++ b/firmware/hw_layer/can_hw.cpp @@ -14,6 +14,7 @@ #if EFI_CAN_SUPPORT #include "engine_configuration.h" +#include "periodic_thread_controller.h" #include "pin_repository.h" #include "can_hw.h" #include "string.h" @@ -30,7 +31,6 @@ static int canWriteOk = 0; static int canWriteNotOk = 0; static bool isCanEnabled = false; static LoggingWithStorage logger("CAN driver"); -static THD_WORKING_AREA(canTreadStack, UTILITY_THREAD_STACK_SIZE); // Values below calculated with http://www.bittiming.can-wiki.info/ // Pick ST micro bxCAN @@ -71,8 +71,6 @@ static const CANConfig canConfig1000 = { CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP, CAN_BTR_1k0 }; - -static CANRxFrame rxBuffer; CANTxFrame txmsg; static void printPacket(CANRxFrame *rx) { @@ -111,16 +109,17 @@ void commonTxInit(int eid) { /** * send CAN message from txmsg buffer */ -static void sendCanMessage2(int size) { - CANDriver *device = detectCanDevice(CONFIGB(canRxPin), - CONFIGB(canTxPin)); +void sendCanMessage(int size) { + CANDriver *device = detectCanDevice(CONFIG(canRxPin), + CONFIG(canTxPin)); if (device == NULL) { warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN configuration issue"); return; } txmsg.DLC = size; - // 1 second timeout - msg_t result = canTransmit(device, CAN_ANY_MAILBOX, &txmsg, TIME_MS2I(1000)); + + // 100 ms timeout + msg_t result = canTransmit(device, CAN_ANY_MAILBOX, &txmsg, TIME_MS2I(100)); if (result == MSG_OK) { canWriteOk++; } else { @@ -128,13 +127,6 @@ static void sendCanMessage2(int size) { } } -/** - * send CAN message from txmsg buffer, using default packet size - */ -void sendCanMessage() { - sendCanMessage2(8); -} - static void canDashboardBMW(void) { //BMW Dashboard commonTxInit(CAN_BMW_E46_SPEED); @@ -222,68 +214,70 @@ static void canDashboardVAG(void) { sendCanMessage(); } -static void canInfoNBCBroadcast(can_nbc_e typeOfNBC) { - switch (typeOfNBC) { - case CAN_BUS_NBC_BMW: - canDashboardBMW(); - break; - case CAN_BUS_NBC_FIAT: - canDashboardFiat(); - break; - case CAN_BUS_NBC_VAG: - canDashboardVAG(); - break; - case CAN_BUS_MAZDA_RX8: - canMazdaRX8(); - break; - default: - break; - } -} - -static void canRead(void) { - CANDriver *device = detectCanDevice(CONFIGB(canRxPin), - CONFIGB(canTxPin)); - if (device == NULL) { - warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN configuration issue"); - return; - } -// scheduleMsg(&logger, "Waiting for CAN"); - msg_t result = canReceive(device, CAN_ANY_MAILBOX, &rxBuffer, TIME_MS2I(1000)); - if (result == MSG_TIMEOUT) { - return; +class CanWrite final : public PeriodicController<256> { +public: + CanWrite() + : PeriodicController("CAN TX", NORMALPRIO, 50) + { } - canReadCounter++; - printPacket(&rxBuffer); - obdOnCanPacketRx(&rxBuffer); -} + void PeriodicTask(efitime_t nowNt) { + switch (engineConfiguration->canNbcType) { + case CAN_BUS_NBC_BMW: + canDashboardBMW(); + break; + case CAN_BUS_NBC_FIAT: + canDashboardFiat(); + break; + case CAN_BUS_NBC_VAG: + canDashboardVAG(); + break; + case CAN_BUS_MAZDA_RX8: + canMazdaRX8(); + break; + default: + break; + } + } +}; -static void writeStateToCan(void) { - canInfoNBCBroadcast(engineConfiguration->canNbcType); -} +class CanRead final : public ThreadController<256> { +public: + CanRead() + : ThreadController("CAN RX", NORMALPRIO) + { + } -static msg_t canThread(void *arg) { - (void)arg; - chRegSetThreadName("CAN"); - while (true) { - if (engineConfiguration->canWriteEnabled) - writeStateToCan(); + void ThreadTask() override { + CANDriver* device = detectCanDevice(CONFIG(canRxPin), CONFIG(canTxPin)); - if (engineConfiguration->canReadEnabled) - canRead(); // todo: since this is a blocking operation, do we need a separate thread for 'write'? - - if (engineConfiguration->canSleepPeriodMs < 10) { - warning(CUSTOM_OBD_LOW_CAN_PERIOD, "%d too low CAN", engineConfiguration->canSleepPeriodMs); - engineConfiguration->canSleepPeriodMs = 50; + if (!device) { + warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN configuration issue"); + return; } - chThdSleepMilliseconds(engineConfiguration->canSleepPeriodMs); + while (true) { + // Block until we get a message + msg_t result = canReceiveTimeout(device, CAN_ANY_MAILBOX, &m_buffer, TIME_INFINITE); + + if (result != MSG_OK) { + continue; + } + + // Process the message + canReadCounter++; + printPacket(&m_buffer); + obdOnCanPacketRx(&m_buffer); + } } -#if defined __GNUC__ - return -1; -#endif -} + +private: + CANRxFrame m_buffer; +}; + +static CanRead canRead; +static CanWrite canWrite; + static void canInfo(void) { if (!isCanEnabled) { @@ -291,8 +285,8 @@ static void canInfo(void) { return; } - scheduleMsg(&logger, "CAN TX %s", hwPortname(CONFIGB(canTxPin))); - scheduleMsg(&logger, "CAN RX %s", hwPortname(CONFIGB(canRxPin))); + scheduleMsg(&logger, "CAN TX %s", hwPortname(CONFIG(canTxPin))); + scheduleMsg(&logger, "CAN RX %s", hwPortname(CONFIG(canRxPin))); scheduleMsg(&logger, "type=%d canReadEnabled=%s canWriteEnabled=%s period=%d", engineConfiguration->canNbcType, boolToString(engineConfiguration->canReadEnabled), boolToString(engineConfiguration->canWriteEnabled), engineConfiguration->canSleepPeriodMs); @@ -314,34 +308,46 @@ void postCanState(TunerStudioOutputChannels *tsOutputChannels) { #endif /* EFI_TUNER_STUDIO */ void enableFrankensoCan(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - CONFIGB(canTxPin) = GPIOB_6; - CONFIGB(canRxPin) = GPIOB_12; + CONFIG(canTxPin) = GPIOB_6; + CONFIG(canRxPin) = GPIOB_12; engineConfiguration->canReadEnabled = false; } void stopCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - brain_pin_markUnused(activeConfiguration.bc.canTxPin); - brain_pin_markUnused(activeConfiguration.bc.canRxPin); + brain_pin_markUnused(activeConfiguration.canTxPin); + brain_pin_markUnused(activeConfiguration.canRxPin); } void startCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - efiSetPadMode("CAN TX", CONFIGB(canTxPin), PAL_MODE_ALTERNATE(EFI_CAN_TX_AF)); - efiSetPadMode("CAN RX", CONFIGB(canRxPin), PAL_MODE_ALTERNATE(EFI_CAN_RX_AF)); + efiSetPadMode("CAN TX", CONFIG(canTxPin), PAL_MODE_ALTERNATE(EFI_CAN_TX_AF)); + efiSetPadMode("CAN RX", CONFIG(canRxPin), PAL_MODE_ALTERNATE(EFI_CAN_RX_AF)); } void initCan(void) { - isCanEnabled = (CONFIGB(canTxPin) != GPIO_UNASSIGNED) && (CONFIGB(canRxPin) != GPIO_UNASSIGNED); - if (isCanEnabled) { - if (!isValidCanTxPin(CONFIGB(canTxPin))) - firmwareError(CUSTOM_OBD_70, "invalid CAN TX %s", hwPortname(CONFIGB(canTxPin))); - if (!isValidCanRxPin(CONFIGB(canRxPin))) - firmwareError(CUSTOM_OBD_70, "invalid CAN RX %s", hwPortname(CONFIGB(canRxPin))); + addConsoleAction("caninfo", canInfo); + + isCanEnabled = + (CONFIG(canTxPin) != GPIO_UNASSIGNED) && // both pins are set... + (CONFIG(canRxPin) != GPIO_UNASSIGNED) && + (CONFIG(canWriteEnabled) || CONFIG(canReadEnabled)) ; // ...and either read or write is enabled + + // nothing to do if we aren't enabled... + if (!isCanEnabled) { + return; } - addConsoleAction("caninfo", canInfo); - if (!isCanEnabled) + // Validate pins + if (!isValidCanTxPin(CONFIG(canTxPin))) { + firmwareError(CUSTOM_OBD_70, "invalid CAN TX %s", hwPortname(CONFIG(canTxPin))); return; + } + if (!isValidCanRxPin(CONFIG(canRxPin))) { + firmwareError(CUSTOM_OBD_70, "invalid CAN RX %s", hwPortname(CONFIG(canRxPin))); + return; + } + + // Initialize hardware #if STM32_CAN_USE_CAN2 // CAN1 is required for CAN2 canStart(&CAND1, &canConfig500); @@ -350,10 +356,17 @@ void initCan(void) { canStart(&CAND1, &canConfig500); #endif /* STM32_CAN_USE_CAN2 */ - chThdCreateStatic(canTreadStack, sizeof(canTreadStack), NORMALPRIO, (tfunc_t)(void*) canThread, NULL); + // fire up threads, as necessary + if (CONFIG(canWriteEnabled)) { + canWrite.setPeriod(CONFIG(canSleepPeriodMs)); + canWrite.Start(); + } + + if (CONFIG(canReadEnabled)) { + canRead.Start(); + } startCanPins(); - } #endif /* EFI_CAN_SUPPORT */ diff --git a/firmware/hw_layer/can_hw.h b/firmware/hw_layer/can_hw.h index c3a3fa5015..539bbada5b 100644 --- a/firmware/hw_layer/can_hw.h +++ b/firmware/hw_layer/can_hw.h @@ -39,7 +39,7 @@ void initCan(void); void commonTxInit(int eid); -void sendCanMessage(); +void sendCanMessage(int size = 8); void setCanType(int type); void setTxBit(int offset, int index); diff --git a/firmware/hw_layer/cdm_ion_sense.cpp b/firmware/hw_layer/cdm_ion_sense.cpp index 65277d210f..ae509a22ce 100644 --- a/firmware/hw_layer/cdm_ion_sense.cpp +++ b/firmware/hw_layer/cdm_ion_sense.cpp @@ -74,16 +74,16 @@ static void extIonCallback(void *arg) { } void cdmIonInit(void) { - if (CONFIGB(cdmInputPin) == GPIO_UNASSIGNED) { + if (CONFIG(cdmInputPin) == GPIO_UNASSIGNED) { return; } - int pin = (int)CONFIGB(cdmInputPin); + int pin = (int)CONFIG(cdmInputPin); if (pin <= 0 || pin > (int)GPIO_UNASSIGNED) { // todo: remove this protection once we migrate to new mandatory configuration return; } - efiExtiEnablePin("ion", CONFIGB(cdmInputPin), PAL_EVENT_MODE_RISING_EDGE, extIonCallback, NULL); + efiExtiEnablePin("ion", CONFIG(cdmInputPin), PAL_EVENT_MODE_RISING_EDGE, extIonCallback, NULL); } #endif /* EFI_CDM_INTEGRATION */ diff --git a/firmware/hw_layer/digital_input_icu.cpp b/firmware/hw_layer/digital_input_icu.cpp index 028c8929ba..2a9cf68578 100644 --- a/firmware/hw_layer/digital_input_icu.cpp +++ b/firmware/hw_layer/digital_input_icu.cpp @@ -103,6 +103,11 @@ static uint32_t getAlternateFunctions(ICUDriver *driver) { return GPIO_AF_TIM4; } #endif +#if STM32_ICU_USE_TIM8 + if (driver == &ICUD8) { + return GPIO_AF_TIM8; + } +#endif #if STM32_ICU_USE_TIM9 if (driver == &ICUD9) { return GPIO_AF_TIM9; diff --git a/firmware/hw_layer/drivers/gpio/tle8888.c b/firmware/hw_layer/drivers/gpio/tle8888.c index e5df81e037..e5265e6b78 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.c +++ b/firmware/hw_layer/drivers/gpio/tle8888.c @@ -145,14 +145,14 @@ static const char* tle8888_pin_names[TLE8888_OUTPUTS] = { }; #if EFI_TUNER_STUDIO -void tle8888PostState(TunerStudioOutputChannels *tsOutputChannels) { - tsOutputChannels->debugIntField1 = tle8888SpiCounter; - tsOutputChannels->debugIntField2 = spiTxb; - tsOutputChannels->debugIntField3 = spiRxb; - tsOutputChannels->debugIntField4 = initResponsesAccumulator; - tsOutputChannels->debugIntField5 = reinitializationCounter; - tsOutputChannels->debugFloatField1 = initResponse0; - tsOutputChannels->debugFloatField2 = initResponse1; +void tle8888PostState(TsDebugChannels *debugChannels) { + debugChannels->debugIntField1 = tle8888SpiCounter; + debugChannels->debugIntField2 = spiTxb; + debugChannels->debugIntField3 = spiRxb; + debugChannels->debugIntField4 = initResponsesAccumulator; + debugChannels->debugIntField5 = reinitializationCounter; + debugChannels->debugFloatField1 = initResponse0; + debugChannels->debugFloatField2 = initResponse1; } #endif /* EFI_TUNER_STUDIO */ diff --git a/firmware/hw_layer/drivers/gpio/tle8888.h b/firmware/hw_layer/drivers/gpio/tle8888.h index a35312571e..17ea9e244f 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.h +++ b/firmware/hw_layer/drivers/gpio/tle8888.h @@ -54,8 +54,8 @@ int tle8888_add(unsigned int index, const struct tle8888_config *cfg); void requestTLE8888initialization(void); #if EFI_TUNER_STUDIO -#include "tunerstudio_configuration.h" -void tle8888PostState(TunerStudioOutputChannels *tsOutputChannels); +#include "tunerstudio_debug_struct.h" +void tle8888PostState(TsDebugChannels *tsDebugChannels); #endif /* EFI_TUNER_STUDIO */ #ifdef __cplusplus diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index c58a37d134..ef80e22b3f 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -42,7 +42,6 @@ #include "neo6m.h" #include "lcd_HD44780.h" #include "settings.h" -#include "algo.h" #include "joystick.h" #include "cdm_ion_sense.h" #include "trigger_central.h" @@ -103,15 +102,15 @@ void unlockSpi(void) { chMtxUnlock(&spiMtx); } -static void initSpiModules(board_configuration_s *boardConfiguration) { - UNUSED(boardConfiguration); - if (CONFIGB(is_enabled_spi_1)) { +static void initSpiModules(engine_configuration_s *engineConfiguration) { + UNUSED(engineConfiguration); + if (CONFIG(is_enabled_spi_1)) { turnOnSpi(SPI_DEVICE_1); } - if (CONFIGB(is_enabled_spi_2)) { + if (CONFIG(is_enabled_spi_2)) { turnOnSpi(SPI_DEVICE_2); } - if (CONFIGB(is_enabled_spi_3)) { + if (CONFIG(is_enabled_spi_3)) { turnOnSpi(SPI_DEVICE_3); } } @@ -217,7 +216,7 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) { #if EFI_SENSOR_CHART if (ENGINE(sensorChartMode) == SC_AUX_FAST1) { - float voltage = getAdcValue("fAux1", engineConfiguration->bc.auxFastSensor1_adcChannel); + float voltage = getAdcValue("fAux1", engineConfiguration->auxFastSensor1_adcChannel); scAddData(getCrankshaftAngleNt(getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX), voltage); } #endif /* EFI_SENSOR_CHART */ @@ -226,7 +225,7 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) { mapAveragingAdcCallback(fastAdc.samples[fastMapSampleIndex]); #endif /* EFI_MAP_AVERAGING */ #if EFI_HIP_9011 - if (CONFIGB(isHip9011Enabled)) { + if (CONFIG(isHip9011Enabled)) { hipAdcCallback(fastAdc.samples[hipSampleIndex]); } #endif /* EFI_HIP_9011 */ @@ -327,13 +326,13 @@ void applyNewHardwareSettings(void) { stopAuxPins(); #endif /* EFI_AUX_PID */ - if (isConfigurationChanged(bc.is_enabled_spi_1)) + if (isConfigurationChanged(is_enabled_spi_1)) stopSpi(SPI_DEVICE_1); - if (isConfigurationChanged(bc.is_enabled_spi_2)) + if (isConfigurationChanged(is_enabled_spi_2)) stopSpi(SPI_DEVICE_2); - if (isConfigurationChanged(bc.is_enabled_spi_3)) + if (isConfigurationChanged(is_enabled_spi_3)) stopSpi(SPI_DEVICE_3); #if EFI_HD44780_LCD @@ -403,11 +402,11 @@ void showBor(void) { } void initHardware(Logging *l) { - efiAssertVoid(CUSTOM_IH_STACK, getCurrentRemainingStack() > 256, "init h"); + efiAssertVoid(CUSTOM_IH_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init h"); sharedLogger = l; engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr; efiAssertVoid(CUSTOM_EC_NULL, engineConfiguration!=NULL, "engineConfiguration"); - board_configuration_s *boardConfiguration = &engineConfiguration->bc; + printMsg(sharedLogger, "initHardware()"); // todo: enable protection. it's disabled because it takes @@ -487,7 +486,7 @@ void initHardware(Logging *l) { initRtc(); #if HAL_USE_SPI - initSpiModules(boardConfiguration); + initSpiModules(engineConfiguration); #endif /* HAL_USE_SPI */ // initSmartGpio depends on 'initSpiModules' initSmartGpio(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -500,7 +499,7 @@ void initHardware(Logging *l) { #endif /* EFI_MC33816 */ #if EFI_MAX_31855 - initMax31855(sharedLogger, CONFIGB(max31855spiDevice), CONFIGB(max31855_cs)); + initMax31855(sharedLogger, CONFIG(max31855spiDevice), CONFIG(max31855_cs)); #endif /* EFI_MAX_31855 */ #if EFI_CAN_SUPPORT diff --git a/firmware/hw_layer/hip9011.cpp b/firmware/hw_layer/hip9011.cpp index f0dde59bde..9b11a5f7a0 100644 --- a/firmware/hw_layer/hip9011.cpp +++ b/firmware/hw_layer/hip9011.cpp @@ -132,14 +132,14 @@ EXTERN_ENGINE static char hipPinNameBuffer[16]; static void showHipInfo(void) { - if (!CONFIGB(isHip9011Enabled)) { + if (!CONFIG(isHip9011Enabled)) { scheduleMsg(logger, "hip9011 driver not active"); return; } - printSpiState(logger, boardConfiguration); + printSpiState(logger, engineConfiguration); scheduleMsg(logger, "enabled=%s state=%s bore=%.2fmm freq=%.2fkHz PaSDO=%d", - boolToString(CONFIGB(isHip9011Enabled)), + boolToString(CONFIG(isHip9011Enabled)), getHip_state_e(instance.state), engineConfiguration->cylinderBore, getHIP9011Band(PASS_HIP_PARAMS), engineConfiguration->hip9011PrescalerAndSDO); @@ -155,11 +155,11 @@ static void showHipInfo(void) { const char * msg = instance.invalidHip9011ResponsesCount > 0 ? "NOT GOOD" : "ok"; scheduleMsg(logger, "spi=%s IntHold@%s/%d response count=%d incorrect response=%d %s", getSpi_device_e(engineConfiguration->hip9011SpiDevice), - hwPortname(CONFIGB(hip9011IntHoldPin)), - CONFIGB(hip9011IntHoldPinMode), + hwPortname(CONFIG(hip9011IntHoldPin)), + CONFIG(hip9011IntHoldPinMode), instance.correctResponsesCount, instance.invalidHip9011ResponsesCount, msg); - scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(CONFIGB(hip9011CsPin)), instance.settingUpdateCount); + scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(CONFIG(hip9011CsPin)), instance.settingUpdateCount); #if EFI_PROD_CODE scheduleMsg(logger, "hip %.2fv/last=%.2f@%s/max=%.2f adv=%d", @@ -167,7 +167,7 @@ static void showHipInfo(void) { getVoltage("hipinfo", engineConfiguration->hipOutputChannel), getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, pinNameBuffer), hipValueMax, - CONFIGB(useTpicAdvancedMode)); + CONFIG(useTpicAdvancedMode)); scheduleMsg(logger, "mosi=%s", hwPortname(getMosiPin(engineConfiguration->hip9011SpiDevice))); scheduleMsg(logger, "miso=%s", hwPortname(getMisoPin(engineConfiguration->hip9011SpiDevice))); scheduleMsg(logger, "sck=%s", hwPortname(getSckPin(engineConfiguration->hip9011SpiDevice))); @@ -184,22 +184,22 @@ void setHip9011FrankensoPinout(void) { /** * SPI on PB13/14/15 */ - // CONFIGB(hip9011CsPin) = GPIOD_0; // rev 0.1 + // CONFIG(hip9011CsPin) = GPIOD_0; // rev 0.1 - CONFIGB(isHip9011Enabled) = true; + CONFIG(isHip9011Enabled) = true; engineConfiguration->hip9011PrescalerAndSDO = _8MHZ_PRESCALER; // 8MHz chip - CONFIGB(is_enabled_spi_2) = true; + CONFIG(is_enabled_spi_2) = true; // todo: convert this to rusEfi, hardware-independent enum #if EFI_PROD_CODE #ifdef EFI_HIP_CS_PIN - CONFIGB(hip9011CsPin) = EFI_HIP_CS_PIN; + CONFIG(hip9011CsPin) = EFI_HIP_CS_PIN; #else - CONFIGB(hip9011CsPin) = GPIOB_0; // rev 0.4 + CONFIG(hip9011CsPin) = GPIOB_0; // rev 0.4 #endif - CONFIGB(hip9011CsPinMode) = OM_OPENDRAIN; + CONFIG(hip9011CsPinMode) = OM_OPENDRAIN; - CONFIGB(hip9011IntHoldPin) = GPIOB_11; - CONFIGB(hip9011IntHoldPinMode) = OM_OPENDRAIN; + CONFIG(hip9011IntHoldPin) = GPIOB_11; + CONFIG(hip9011IntHoldPinMode) = OM_OPENDRAIN; engineConfiguration->spi2SckMode = PO_OPENDRAIN; // 4 engineConfiguration->spi2MosiMode = PO_OPENDRAIN; // 4 @@ -211,7 +211,7 @@ void setHip9011FrankensoPinout(void) { engineConfiguration->maxKnockSubDeg = 20; - if (!CONFIGB(useTpicAdvancedMode)) { + if (!CONFIG(useTpicAdvancedMode)) { engineConfiguration->hipOutputChannel = EFI_ADC_10; // PC0 } } @@ -341,7 +341,7 @@ static void hipStartupCode(void) { warning(CUSTOM_OBD_KNOCK_PROCESSOR, "TPIC/HIP does not respond"); } - if (CONFIGB(useTpicAdvancedMode)) { + if (CONFIG(useTpicAdvancedMode)) { // enable advanced mode for digital integrator output instance.hardware->sendSyncCommand(SET_ADVANCED_MODE); } @@ -384,20 +384,20 @@ static msg_t hipThread(void *arg) { void stopHip9001_pins() { #if EFI_PROD_CODE - brain_pin_markUnused(activeConfiguration.bc.hip9011IntHoldPin); - brain_pin_markUnused(activeConfiguration.bc.hip9011CsPin); + brain_pin_markUnused(activeConfiguration.hip9011IntHoldPin); + brain_pin_markUnused(activeConfiguration.hip9011CsPin); #endif /* EFI_PROD_CODE */ } void startHip9001_pins() { - intHold.initPin("hip int/hold", CONFIGB(hip9011IntHoldPin), &CONFIGB(hip9011IntHoldPinMode)); - enginePins.hipCs.initPin("hip CS", CONFIGB(hip9011CsPin), &CONFIGB(hip9011CsPinMode)); + intHold.initPin("hip int/hold", CONFIG(hip9011IntHoldPin), &CONFIG(hip9011IntHoldPinMode)); + enginePins.hipCs.initPin("hip CS", CONFIG(hip9011CsPin), &CONFIG(hip9011CsPinMode)); } void initHip9011(Logging *sharedLogger) { logger = sharedLogger; addConsoleAction("hipinfo", showHipInfo); - if (!CONFIGB(isHip9011Enabled)) + if (!CONFIG(isHip9011Enabled)) return; @@ -410,8 +410,8 @@ void initHip9011(Logging *sharedLogger) { return; } - hipSpiCfg.ssport = getHwPort("hip", CONFIGB(hip9011CsPin)); - hipSpiCfg.sspad = getHwPin("hip", CONFIGB(hip9011CsPin)); + hipSpiCfg.ssport = getHwPort("hip", CONFIG(hip9011CsPin)); + hipSpiCfg.sspad = getHwPin("hip", CONFIG(hip9011CsPin)); #endif /* EFI_PROD_CODE */ startHip9001_pins(); diff --git a/firmware/hw_layer/io_pins.h b/firmware/hw_layer/io_pins.h index 7f2344bedb..5b8e4332ff 100644 --- a/firmware/hw_layer/io_pins.h +++ b/firmware/hw_layer/io_pins.h @@ -16,7 +16,7 @@ // mode >= 0 is always true since that's an unsigned #define assertOMode(mode) { \ - efiAssertVoid(CUSTOM_ERR_6578, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \ + efiAssertVoid(CUSTOM_INVALID_MODE_SETTING, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \ } diff --git a/firmware/hw_layer/lcd/lcd_HD44780.cpp b/firmware/hw_layer/lcd/lcd_HD44780.cpp index 95ad1a30a1..23503eb9c1 100644 --- a/firmware/hw_layer/lcd/lcd_HD44780.cpp +++ b/firmware/hw_layer/lcd/lcd_HD44780.cpp @@ -83,18 +83,18 @@ static void writePad(const char *msg, brain_pin_e pin, int bit) { //----------------------------------------------------------------------------- static void lcd_HD44780_write(uint8_t data) { if (engineConfiguration->displayMode == DM_HD44780) { - writePad("lcd", CONFIGB(HD44780_db7), + writePad("lcd", CONFIG(HD44780_db7), data & 0x80 ? 1 : 0); - writePad("lcd", CONFIGB(HD44780_db6), + writePad("lcd", CONFIG(HD44780_db6), data & 0x40 ? 1 : 0); - writePad("lcd", CONFIGB(HD44780_db5), + writePad("lcd", CONFIG(HD44780_db5), data & 0x20 ? 1 : 0); - writePad("lcd", CONFIGB(HD44780_db4), + writePad("lcd", CONFIG(HD44780_db4), data & 0x10 ? 1 : 0); - writePad("lcd", CONFIGB(HD44780_e), 1); // En high + writePad("lcd", CONFIG(HD44780_e), 1); // En high lcdSleep(10); // enable pulse must be >450ns - writePad("lcd", CONFIGB(HD44780_e), 0); // En low + writePad("lcd", CONFIG(HD44780_e), 0); // En low lcdSleep(40); // commands need > 37us to settle } else { @@ -124,7 +124,7 @@ static void lcd_HD44780_write(uint8_t data) { //----------------------------------------------------------------------------- void lcd_HD44780_write_command(uint8_t data) { - palClearPad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs))); + palClearPad(getHwPort("lcd", CONFIG(HD44780_rs)), getHwPin("lcd", CONFIG(HD44780_rs))); lcd_HD44780_write(data); lcd_HD44780_write(data << 4); @@ -132,13 +132,13 @@ void lcd_HD44780_write_command(uint8_t data) { //----------------------------------------------------------------------------- void lcd_HD44780_write_data(uint8_t data) { - palSetPad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs))); + palSetPad(getHwPort("lcd", CONFIG(HD44780_rs)), getHwPin("lcd", CONFIG(HD44780_rs))); lcd_HD44780_write(data); lcd_HD44780_write(data << 4); currentColumn++; - palClearPad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs))); + palClearPad(getHwPort("lcd", CONFIG(HD44780_rs)), getHwPin("lcd", CONFIG(HD44780_rs))); } //----------------------------------------------------------------------------- @@ -170,41 +170,41 @@ void lcd_HD44780_print_string(const char* string) { lcd_HD44780_print_char(*string++); } -//getHwPin(CONFIGB(HD44780_db7)) +//getHwPin(CONFIG(HD44780_db7)) static void lcdInfo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - scheduleMsg(logger, "HD44780 RS=%s", hwPortname(CONFIGB(HD44780_rs))); - scheduleMsg(logger, "HD44780 E=%s", hwPortname(CONFIGB(HD44780_e))); - scheduleMsg(logger, "HD44780 D4=%s", hwPortname(CONFIGB(HD44780_db4))); - scheduleMsg(logger, "HD44780 D5=%s", hwPortname(CONFIGB(HD44780_db5))); - scheduleMsg(logger, "HD44780 D6=%s", hwPortname(CONFIGB(HD44780_db6))); - scheduleMsg(logger, "HD44780 D7=%s", hwPortname(CONFIGB(HD44780_db7))); + scheduleMsg(logger, "HD44780 RS=%s", hwPortname(CONFIG(HD44780_rs))); + scheduleMsg(logger, "HD44780 E=%s", hwPortname(CONFIG(HD44780_e))); + scheduleMsg(logger, "HD44780 D4=%s", hwPortname(CONFIG(HD44780_db4))); + scheduleMsg(logger, "HD44780 D5=%s", hwPortname(CONFIG(HD44780_db5))); + scheduleMsg(logger, "HD44780 D6=%s", hwPortname(CONFIG(HD44780_db6))); + scheduleMsg(logger, "HD44780 D7=%s", hwPortname(CONFIG(HD44780_db7))); } void stopHD44780_pins() { - brain_pin_markUnused(activeConfiguration.bc.HD44780_rs); - brain_pin_markUnused(activeConfiguration.bc.HD44780_e); - brain_pin_markUnused(activeConfiguration.bc.HD44780_db4); - brain_pin_markUnused(activeConfiguration.bc.HD44780_db5); - brain_pin_markUnused(activeConfiguration.bc.HD44780_db6); - brain_pin_markUnused(activeConfiguration.bc.HD44780_db7); + brain_pin_markUnused(activeConfiguration.HD44780_rs); + brain_pin_markUnused(activeConfiguration.HD44780_e); + brain_pin_markUnused(activeConfiguration.HD44780_db4); + brain_pin_markUnused(activeConfiguration.HD44780_db5); + brain_pin_markUnused(activeConfiguration.HD44780_db6); + brain_pin_markUnused(activeConfiguration.HD44780_db7); } void startHD44780_pins() { if (engineConfiguration->displayMode == DM_HD44780) { // initialize hardware lines - efiSetPadMode("lcd RS", CONFIGB(HD44780_rs), PAL_MODE_OUTPUT_PUSHPULL); - efiSetPadMode("lcd E", CONFIGB(HD44780_e), PAL_MODE_OUTPUT_PUSHPULL); - efiSetPadMode("lcd DB4", CONFIGB(HD44780_db4), PAL_MODE_OUTPUT_PUSHPULL); - efiSetPadMode("lcd DB5", CONFIGB(HD44780_db5), PAL_MODE_OUTPUT_PUSHPULL); - efiSetPadMode("lcd DB6", CONFIGB(HD44780_db6), PAL_MODE_OUTPUT_PUSHPULL); - efiSetPadMode("lcd DB7", CONFIGB(HD44780_db7), PAL_MODE_OUTPUT_PUSHPULL); + efiSetPadMode("lcd RS", CONFIG(HD44780_rs), PAL_MODE_OUTPUT_PUSHPULL); + efiSetPadMode("lcd E", CONFIG(HD44780_e), PAL_MODE_OUTPUT_PUSHPULL); + efiSetPadMode("lcd DB4", CONFIG(HD44780_db4), PAL_MODE_OUTPUT_PUSHPULL); + efiSetPadMode("lcd DB5", CONFIG(HD44780_db5), PAL_MODE_OUTPUT_PUSHPULL); + efiSetPadMode("lcd DB6", CONFIG(HD44780_db6), PAL_MODE_OUTPUT_PUSHPULL); + efiSetPadMode("lcd DB7", CONFIG(HD44780_db7), PAL_MODE_OUTPUT_PUSHPULL); // and zero values - palWritePad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs)), 0); - palWritePad(getHwPort("lcd", CONFIGB(HD44780_e)), getHwPin("lcd", CONFIGB(HD44780_e)), 0); - palWritePad(getHwPort("lcd", CONFIGB(HD44780_db4)), getHwPin("lcd", CONFIGB(HD44780_db4)), 0); - palWritePad(getHwPort("lcd", CONFIGB(HD44780_db5)), getHwPin("lcd", CONFIGB(HD44780_db5)), 0); - palWritePad(getHwPort("lcd", CONFIGB(HD44780_db6)), getHwPin("lcd", CONFIGB(HD44780_db6)), 0); - palWritePad(getHwPort("lcd", CONFIGB(HD44780_db7)), getHwPin("lcd", CONFIGB(HD44780_db7)), 0); + palWritePad(getHwPort("lcd", CONFIG(HD44780_rs)), getHwPin("lcd", CONFIG(HD44780_rs)), 0); + palWritePad(getHwPort("lcd", CONFIG(HD44780_e)), getHwPin("lcd", CONFIG(HD44780_e)), 0); + palWritePad(getHwPort("lcd", CONFIG(HD44780_db4)), getHwPin("lcd", CONFIG(HD44780_db4)), 0); + palWritePad(getHwPort("lcd", CONFIG(HD44780_db5)), getHwPin("lcd", CONFIG(HD44780_db5)), 0); + palWritePad(getHwPort("lcd", CONFIG(HD44780_db6)), getHwPin("lcd", CONFIG(HD44780_db6)), 0); + palWritePad(getHwPort("lcd", CONFIG(HD44780_db7)), getHwPin("lcd", CONFIG(HD44780_db7)), 0); } } diff --git a/firmware/hw_layer/max31855.cpp b/firmware/hw_layer/max31855.cpp index 75633db860..138f86b9ca 100644 --- a/firmware/hw_layer/max31855.cpp +++ b/firmware/hw_layer/max31855.cpp @@ -37,13 +37,13 @@ EXTERN_ENGINE; static void showEgtInfo(void) { #if EFI_PROD_CODE - printSpiState(logger, boardConfiguration); + printSpiState(logger, engineConfiguration); - scheduleMsg(logger, "EGT spi: %d", CONFIGB(max31855spiDevice)); + scheduleMsg(logger, "EGT spi: %d", CONFIG(max31855spiDevice)); for (int i = 0; i < EGT_CHANNEL_COUNT; i++) { - if (CONFIGB(max31855_cs)[i] != GPIO_UNASSIGNED) { - scheduleMsg(logger, "%d ETG @ %s", i, hwPortname(CONFIGB(max31855_cs)[i])); + if (CONFIG(max31855_cs)[i] != GPIO_UNASSIGNED) { + scheduleMsg(logger, "%d ETG @ %s", i, hwPortname(CONFIG(max31855_cs)[i])); } } #endif diff --git a/firmware/hw_layer/mc33816/mc33816.md b/firmware/hw_layer/mc33816/mc33816.md new file mode 100644 index 0000000000..d81761dd1b --- /dev/null +++ b/firmware/hw_layer/mc33816/mc33816.md @@ -0,0 +1,14 @@ + +https://www.nxp.com/files-static/training_pdf/FTF/2012/americas/WBNR_FTF12_AUT_F0098.pdf has many cool pictures explaining the whole thing. + +https://www.nxp.com/docs/en/application-note/AN4849.pdf is literaly a complete example of a four cylinder internal combustion engine (ICE) injector drive. + + +MC33816 has four independent microcores - four "threads" of execution. + +One thread has to be controlling variable frequency modulation (VFM) DC-to-DC converter, whatever it means. + +Two more threads are running two banks of two injectors each. + +Each injector has it's own low-side driver. +Each bank/pair of injectors share a "boosting" - i.e. high-voltage opening high-side driver, and a "holding" - i.e normal battery voltage high-side driver. (page 59) diff --git a/firmware/hw_layer/mc33816/rusefi/Logic_Wave/wave_list.do b/firmware/hw_layer/mc33816/rusefi/Logic_Wave/wave_list.do new file mode 100644 index 0000000000..c9f06122c3 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Logic_Wave/wave_list.do @@ -0,0 +1,198 @@ + + + STARTx + + + Start1 + + PT2000 + + 8 + Input + Decimal + + + Start2 + + PT2000 + + 9 + Input + Decimal + + + Start3 + + PT2000 + + 10 + Input + Decimal + + + Start4 + + PT2000 + + 11 + Input + Decimal + + + Start5 + + PT2000 + + 12 + Input + Decimal + + + Start6 + + PT2000 + + 13 + Input + Decimal + + + Start7 + + PT2000 + + 14 + Input + Decimal + + + INJ1 + + + Hs1Command + + PT2000 + + 6 + Output + Decimal + + + Hs2Command + + PT2000 + + 7 + Output + Decimal + + + Ls1Command + + PT2000 + + 13 + Output + Decimal + + + CurrentFeedback1 + + PT2000 + + 0 + Internal + Decimal + + + FeedbackHs1Vds + + PT2000 + + 10 + Internal + Decimal + + + FeedbackHs1Vsrc + + PT2000 + + 11 + Internal + Decimal + + + FeedbackLs1Vds + + PT2000 + + 24 + Internal + Decimal + + + DCDC + + + BoostFeedback + + PT2000 + + 35 + Internal + Decimal + + + Ls7Command + + PT2000 + + 19 + Output + Decimal + + + Ls8Command + + PT2000 + + 20 + Output + Decimal + + + Flag0Out + + PT2000 + + 4 + Output + Decimal + + + DEBUG + + + Irq + + PT2000 + + 5 + Output + Decimal + + + irqSource + + PT2000 + Injection Channel 1 + ChSequencers + MicroMachineSeq0 + UProgramCounter + + 7 + Output + Decimal + + \ No newline at end of file diff --git a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/ch1.psc b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/ch1.psc new file mode 100644 index 0000000000..afa20c1402 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/ch1.psc @@ -0,0 +1,202 @@ +******************************************************************************** +* Example Code +* +* Copyright(C) 2019 NXP Semiconductors +* NXP Semiconductors Confidential and Proprietary +* +* Software that is described herein is for illustrative purposes only +* which provides customers with programming information regarding the +* NXP products. This software is supplied "AS IS" without any warranties +* of any kind, and NXP Semiconductors and its licensor disclaim any and +* all warranties, express or implied, including all implied warranties of +* merchantability, fitness for a particular purpose and non-infringement of +* intellectual property rights. NXP Semiconductors assumes no responsibility +* or liability for the use of the software, conveys no license or rights +* under any patent, copyright, mask work right, or any other intellectual +* property rights in or to any products. NXP Semiconductors reserves the +* right to make changes in the software without notification. NXP +* Semiconductors also makes no representation or warranty that such +* application will be suitable for the specified use without further testing +* or modification. +* +* IN NO EVENT WILL NXP SEMICONDUCTORS BE LIABLE, WHETHER IN CONTRACT, +* TORT, OR OTHERWISE, FOR ANY INCIDENTAL, SPECIAL, INDIRECT, CONSEQUENTIAL +* OR PUNITIVE DAMAGES, INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR ANY +* LOSS OF USE, LOSS OF TIME, INCONVENIENCE, COMMERCIAL LOSS, OR LOST +* PROFITS, SAVINGS, OR REVENUES, TO THE FULL EXTENT SUCH MAY BE DISCLAIMED +* BY LAW. NXP SEMICONDUCTOR???S TOTAL LIABILITY FOR ALL COSTS, DAMAGES, +* CLAIMS, OR LOSSES WHATSOEVER ARISING OUT OF OR IN CONNECTION WITH THE +* SOFTWARE IS LIMITED TO THE AGGREGATE AMOUNT PAID BY YOU TO NXP SEMICONDUCTORS +* IN CONNECTION WITH THE SOFTWARE TO WHICH LOSSES OR DAMAGES ARE CLAIMED. +* +* Permission to use, copy, modify, and distribute this software and its +* documentation is hereby granted, under NXP Semiconductors' and its +* licensor's relevant copyrights in the software, without fee, provided +* that it is used in conjunction with NXP Semiconductors devices. This +* copyright, permission, and disclaimer notice must appear in all copies +* of this code. +******************************************************************************** + +#include "dram1.def"; + +* ### Channel 1 - uCore0 controls the injectors 1 and 2 ### + +* ### Variables declaration ### + +* Note: The data are stored into the dataRAM of the channel 1. +* Note: The Thold_tot variable defines the current profile time out. +* The active STARTx pin is expected to toggle in is low state before this time out. + +* ### Initialization phase ### +init0: stgn gain8.68 sssc; * Set the gain of the opamp of the current measure block 1 + ldjr1 eoinj0; * Load the eoinj line label Code RAM address into the register jr1 + ldjr2 idle0; * Load the idle line label Code RAM address into the register jr2 + cwef jr1 _start row1; * If the start signal goes low, go to eoinj phase + +* ### Idle phase- the uPC loops here until start signal is present ### +idle0: cwer CheckStart start row2; * Define entry table for high start pin + stoc on sssc; * Turn ON offset compensation +WaitLoop: wait row2; * uPC is stuck here for almost the whole idle time +CheckStart: joslr inj1_start start1; * Jump to inj1 if start 1 is high + joslr inj2_start start2; * Jump to inj2 if start 2 is high + jmpr WaitLoop; + + +* ### Shortcuts definition per the injector to be actuated ### +inj1_start: dfsct hs1 hs2 ls1; * Set the 3 shortcuts: VBAT, VBOOST, LS + jmpr boost0; * Jump to launch phase + +inj2_start: dfsct hs1 hs2 ls2; * Set the 3 shortcuts: VBAT, VBOOST, LS + jmpr boost0; * Jump to launch phase + +* ### Launch phase enable boost ### +boost0: stoc off sssc; * Turn OFF offset compensation + bias all on; * Enable all biasing structures, kept ON even during actuation + load Iboost dac_sssc _ofs; * Load the boost phase current threshold in the current DAC + cwer peak0 ocur row2; * Jump to peak phase when current is over threshold + stf low b0; * set flag0 low to force the DC-DC converter in idle mode + stos off on on; * Turn VBAT off, BOOST on, LS on + wait row12; * Wait for one of the previously defined conditions + +* ### Peak phase continue on Vbat ### +peak0: ldcd rst _ofs keep keep Tpeak_tot c1; * Load the length of the total peak phase in counter 1 + load Ipeak dac_sssc _ofs; * Load the peak current threshold in the current DAC + cwer bypass0 tc1 row2; * Jump to bypass phase when tc1 reaches end of count + cwer peak_on0 tc2 row3; * Jump to peak_on when tc2 reaches end of count + cwer peak_off0 ocur row4; * Jump to peak_off when current is over threshold + stf high b0; * set flag0 high to release the DC-DC converter idle mode + +peak_on0: stos on off on; * Turn VBAT on, BOOST off, LS on + wait row124; * Wait for one of the previously defined conditions + +peak_off0: ldcd rst ofs keep keep Tpeak_off c2; * Load in the counter 2 the length of the peak_off phase + stos off off on; * Turn VBAT off, BOOST off, LS on + wait row123; * Wait for one of the previously defined conditions + +* ### Bypass phase ### +bypass0: ldcd rst ofs keep keep Tbypass c3; * Load in the counter 3 the length of the off_phase phase + stos off off off; * Turn VBAT off, BOOST off, LS off + cwer hold0 tc3 row4; * Jump to hold when tc3 reaches end of count + wait row14; * Wait for one of the previously defined conditions + +* ### Hold phase on Vbat ### +hold0: ldcd rst _ofs keep keep Thold_tot c1; * Load the length of the total hold phase in counter 2 + load Ihold dac_sssc _ofs; * Load the hold current threshold in the DAC + cwer eoinj0 tc1 row2; * Jump to eoinj phase when tc1 reaches end of count + cwer hold_on0 tc2 row3; * Jump to hold_on when tc2 reaches end of count + cwer hold_off0 ocur row4; * Jump to hold_off when current is over threshold + +hold_on0: stos on off on; * Turn VBAT on, BOOST off, LS on + wait row124; * Wait for one of the previously defined conditions + +hold_off0: ldcd rst _ofs keep keep Thold_off c2; * Load the length of the hold_off phase in counter 1 + stos off off on; * Turn VBAT off, BOOST off, LS on + wait row123; * Wait for one of the previously defined conditions + +* ### End of injection phase ### +eoinj0: stos off off off; * Turn VBAT off, BOOST off, LS off + stf high b0; * set flag0 to high to release the DC-DC converter idle mode + jmpf jr2; * Jump back to idle phase + +* ### End of Channel 1 - uCore0 code ### + +********************************************************************************* + +* ### Channel 1 - uCore1 controls the injectors 3 and 4 ### + +* ### Variables declaration ### + +* Note: The data that defines the profiles are shared between the two microcores. + +* ### Initialization phase ### +init1: stgn gain8.68 sssc; * Set the gain of the opamp of the current measure block 1 + ldjr1 eoinj1; * Load the eoinj line label Code RAM address into the register jr1 + ldjr2 idle1; * Load the idle line label Code RAM address into the register jr2 + cwef jr1 _start row1; * If the start signal goes low, go to eoinj phase + + +* ### Idle phase- the uPC loops here until start signal is present ### +idle1: cwer CheckStart1 start row2; * Define entry table for high start pin + stoc on sssc; * Turn ON offset compensation +WaitLoop1: wait row2; * uPC is stuck here for almost the whole idle time +CheckStart1:joslr inj3_start start3; * Jump to inj1 if start 1 is high + joslr inj4_start start4; * Jump to inj2 if start 2 is high + jmpr WaitLoop1; + + +* ### Shortcuts definition per the injector to be actuated ### +inj3_start: dfsct hs3 hs4 ls3; * Set the 3 shortcuts: VBAT, VBOOST, LS + jmpr boost1; * Jump to launch phase + +inj4_start: dfsct hs3 hs4 ls4; * Set the 3 shortcuts: VBAT, VBOOST, LS + jmpr boost1; * Jump to launch phase + +* ### Launch phase enable boost ### +boost1: stoc off sssc; * Turn OFF offset compensation + load Iboost dac_sssc _ofs; * Load the boost phase current threshold in the current DAC + cwer peak1 ocur row2; * Jump to peak phase when current is over threshold + stf low b0; * set flag0 low to force the DC-DC converter in idle mode + stos off on on; * Turn VBAT off, BOOST on, LS on + wait row12; * Wait for one of the previously defined conditions + +* ### Peak phase continue on Vbat ### +peak1: ldcd rst _ofs keep keep Tpeak_tot c1; * Load the length of the total peak phase in counter 1 + load Ipeak dac_sssc _ofs; * Load the peak current threshold in the current DAC + cwer bypass1 tc1 row2; * Jump to bypass phase when tc1 reaches end of count + cwer peak_on1 tc2 row3; * Jump to peak_on when tc2 reaches end of count + cwer peak_off1 ocur row4; * Jump to peak_off when current is over threshold + stf high b0; * set flag0 high to release the DC-DC converter idle mode + +peak_on1: stos on off on; * Turn VBAT on, BOOST off, LS on + wait row124; * Wait for one of the previously defined conditions + +peak_off1: ldcd rst ofs keep keep Tpeak_off c2; * Load in the counter 2 the length of the peak_off phase + stos off off on; * Turn VBAT off, BOOST off, LS on + wait row123; * Wait for one of the previously defined conditions + +* ### Bypass phase ### +bypass1: ldcd rst ofs keep keep Tbypass c3; * Load in the counter 3 the length of the off_phase phase + stos off off off; * Turn VBAT off, BOOST off, LS off + cwer hold1 tc3 row4; * Jump to hold when tc3 reaches end of count + wait row14; * Wait for one of the previously defined conditions + +* ### Hold phase on Vbat ### +hold1: ldcd rst _ofs keep keep Thold_tot c1; * Load the length of the total hold phase in counter 2 + load Ihold dac_sssc _ofs; * Load the hold current threshold in the DAC + cwer eoinj1 tc1 row2; * Jump to eoinj phase when tc1 reaches end of count + cwer hold_on1 tc2 row3; * Jump to hold_on when tc2 reaches end of count + cwer hold_off1 ocur row4; * Jump to hold_off when current is over threshold + +hold_on1: stos on off on; * Turn VBAT on, BOOST off, LS on + wait row124; * Wait for one of the previously defined conditions + +hold_off1: ldcd rst _ofs keep keep Thold_off c2; * Load the length of the hold_off phase in counter 1 + stos off off on; * Turn VBAT off, BOOST off, LS on + wait row123; * Wait for one of the previously defined conditions + +* ### End of injection phase ### +eoinj1: stos off off off; * Turn VBAT off, BOOST off, LS off + stf high b0; * set flag0 to high to release the DC-DC converter idle mode + jmpf jr2; * Jump back to idle phase + +* ### End of Channel 1 - uCore1 code ### diff --git a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/dram1.def b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/dram1.def new file mode 100644 index 0000000000..c8db1f8aa4 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/dram1.def @@ -0,0 +1,8 @@ +#define Iboost 0; +#define Ipeak 1; +#define Ihold 2; +#define Tpeak_off 3; +#define Tpeak_tot 4; +#define Tbypass 5; +#define Thold_off 6; +#define Thold_tot 7; diff --git a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh2/ch2.psc b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh2/ch2.psc new file mode 100644 index 0000000000..8e7d6e921d --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh2/ch2.psc @@ -0,0 +1,117 @@ +******************************************************************************** +* Example Code +* +* Copyright(C) 2019 NXP Semiconductors +* NXP Semiconductors Confidential and Proprietary +* +* Software that is described herein is for illustrative purposes only +* which provides customers with programming information regarding the +* NXP products. This software is supplied "AS IS" without any warranties +* of any kind, and NXP Semiconductors and its licensor disclaim any and +* all warranties, express or implied, including all implied warranties of +* merchantability, fitness for a particular purpose and non-infringement of +* intellectual property rights. NXP Semiconductors assumes no responsibility +* or liability for the use of the software, conveys no license or rights +* under any patent, copyright, mask work right, or any other intellectual +* property rights in or to any products. NXP Semiconductors reserves the +* right to make changes in the software without notification. NXP +* Semiconductors also makes no representation or warranty that such +* application will be suitable for the specified use without further testing +* or modification. +* +* IN NO EVENT WILL NXP SEMICONDUCTORS BE LIABLE, WHETHER IN CONTRACT, +* TORT, OR OTHERWISE, FOR ANY INCIDENTAL, SPECIAL, INDIRECT, CONSEQUENTIAL +* OR PUNITIVE DAMAGES, INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR ANY +* LOSS OF USE, LOSS OF TIME, INCONVENIENCE, COMMERCIAL LOSS, OR LOST +* PROFITS, SAVINGS, OR REVENUES, TO THE FULL EXTENT SUCH MAY BE DISCLAIMED +* BY LAW. NXP SEMICONDUCTOR???S TOTAL LIABILITY FOR ALL COSTS, DAMAGES, +* CLAIMS, OR LOSSES WHATSOEVER ARISING OUT OF OR IN CONNECTION WITH THE +* SOFTWARE IS LIMITED TO THE AGGREGATE AMOUNT PAID BY YOU TO NXP SEMICONDUCTORS +* IN CONNECTION WITH THE SOFTWARE TO WHICH LOSSES OR DAMAGES ARE CLAIMED. +* +* Permission to use, copy, modify, and distribute this software and its +* documentation is hereby granted, under NXP Semiconductors' and its +* licensor's relevant copyrights in the software, without fee, provided +* that it is used in conjunction with NXP Semiconductors devices. This +* copyright, permission, and disclaimer notice must appear in all copies +* of this code. +******************************************************************************** + +#include "dram2.def"; + +* ### Channel 2 - uCore0 controls dc-dc ### + + +* ### Initialization phase ### +init0: stgn gain5.8 ossc; * Set the gain of the opamp of the current measure block 4 + load Isense4_low dac_ossc _ofs; * Load Isense4_high current threshold in DAC 4L + load Isense4_high dac4h4n _ofs; * Load Isense4_high current threshold in DAC 4H + stdm null; * Set the boost voltage DAC access mode + cwer dcdc_idle _f0 row1; * Wait table entry for Vboost under Vboost_low threshold condition + cwer dcdc_on _vb row2; * Wait table entry for Vboost under Vboost_low threshold condition + cwer dcdc_off vb row3; * Wait table entry for Vboost over Vboost_high threshold condition + +* ### Asynchronous phase ### +dcdc_on: load Vboost_high dac4h4n _ofs; * Load the upper Vboost threshold in vboost_dac register + stdcctl async; * Enable asynchronous mode + wait row13; * Wait for one of the previously defined conditions + +* ### Synchronous phase ### +dcdc_off: load Vboost_low dac4h4n _ofs; * Load the upper Vboost threshold in vboost_dac register + stdcctl sync; * Enable synchronous mode + wait row12; * Wait for one of the previously defined conditions + +* ### Idle phase ### +dcdc_idle: stdcctl sync; * Enable synchronous mode + jocr dcdc_idle _f0; * jump to previous line while flag 0 is low + jmpr dcdc_on; * force the DC-DC converter on when flag 0 goes high + +* ### End of Channel 2 - uCore0 code ### + +********************************************************************************* + +* ### Channel 2 - uCore1 drives fuel pump ### + + +* ### Initialization phase ### +init1: stgn gain19.4 ossc; * Set the gain of the opamp of the current measure block 1 + ldjr1 eoact1; * Load the eoinj line label Code RAM address into the register jr1 + ldjr2 idle1; * Load the idle line label Code RAM address into the register jr2 + cwef jr1 _start row1; * If the start signal goes low, go to eoinj phase + +* ### Idle phase- the uPC loops here until start signal is present ### +idle1: joslr act5_start start5; * Perform an actuation on act5 if start 5 (only) is active + joslr act6_start start6; * Perform an actuation on act6 if start 6 (only) is active + jmpf jr1; * If more than 1 start active at the same time(or none), no actuation + +* ### Shortcuts definition per the injector to be actuated ### +act5_start: dfsct hs5 ls5 undef; * Set the 2 shortcuts: VBAT, LS + jmpr peak1; * Jump to launch phase + +act6_start: dfsct hs5 ls6 undef; * Set the 2 shortcuts: VBAT, LS + jmpr peak1; * Jump to launch phase + +* ### Launch peak phase on bat ### +peak1: load Ipeak dac_ossc _ofs; * Load the boost phase current threshold in the current DAC + cwer hold1 cur3 row2; * Jump to peak phase when current is over threshold + stos on on keep; * Turn VBAT off, BOOST on, LS on + wait row12; * Wait for one of the previously defined conditions + +* ### Hold phase on Vbat ### +hold1: ldcd rst _ofs keep keep Thold_tot c1; * Load the length of the total hold phase in counter 2 + load Ihold dac_ossc _ofs; * Load the hold current threshold in the DAC + cwer eoact1 tc1 row2; * Jump to eoinj phase when tc1 reaches end of count + cwer hold_on1 tc2 row3; * Jump to hold_on when tc2 reaches end of count + cwer hold_off1 cur3 row4; * Jump to hold_off when current is over threshold + +hold_on1: stos on on keep; * Turn VBAT on, LS on + wait row124; * Wait for one of the previously defined conditions + +hold_off1: ldcd rst _ofs off on Thold_off c2; * Load the length of the hold_off phase in counter 1 and turn VBAT off, LS on + wait row123; * Wait for one of the previously defined conditions + +* ### End of injection phase ### +eoact1: stos off off keep; * Turn VBAT off, LS off + jmpf jr2; * Jump back to idle phase + +* ### End of Channel 2 - uCore1 code ### diff --git a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh2/dram2.def b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh2/dram2.def new file mode 100644 index 0000000000..e0f772d642 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh2/dram2.def @@ -0,0 +1,8 @@ +#define Vboost_low 0; +#define Vboost_high 1; +#define Isense4_low 2; +#define Isense4_high 3; +#define Thold_off 4; +#define Thold_tot 5; +#define Ipeak 6; +#define Ihold 7; diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/ch1_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/ch1_config_reg.bin new file mode 100644 index 0000000000..6a254f86c7 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/ch1_config_reg.bin @@ -0,0 +1,19 @@ +0000000000011000 +0000000000000000 +0000000000000000 +0000000000000000 +0000001100000011 +0000000000000000 +0000000000000000 +0000000000011011 +1100101000010010 +0100101101001010 +0000000000000000 +0000000000110001 +0000000000000000 +0000000000000000 +0000000000000000 +0000001111111111 +0000001111111111 +0000000000000000 +0000000000000000 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/ch2_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/ch2_config_reg.bin new file mode 100644 index 0000000000..8549616c30 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/ch2_config_reg.bin @@ -0,0 +1,19 @@ +0000000000011000 +0000000000000000 +0000000000000000 +0000000000000000 +0000110000000000 +0000000000000000 +0000000000000000 +0000000000101010 +0000110001111010 +1110111001110001 +0000000000000000 +0000000000010000 +0000000000000000 +0000000000000000 +0000000000000000 +0000001111111111 +0000001111111111 +0000000000000000 +0000000000000000 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/diag_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/diag_config_reg.bin new file mode 100644 index 0000000000..a3e2816a55 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/diag_config_reg.bin @@ -0,0 +1,44 @@ +0001110111011010 +0000000000001001 +0000000000011110 +0001110111011010 +0000000000001001 +0000000000011110 +0000001010001110 +0000000000001001 +0000000000011110 +0000001010001110 +0000000000001001 +0000000000011110 +0000001010001110 +0000000000001001 +0000000000011110 +0000001010001110 +0000000000001001 +0000000000011110 +0000000000011110 +0001110111011010 +0000000001101001 +0000000000011110 +0001110111011010 +0000000001101001 +0000000000011110 +0000001010001110 +0000000001101001 +0000000000011110 +0000001010001110 +0000000001101001 +0000000000011110 +0000000000000000 +0000000000000000 +0000000000011110 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000001 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/dram1.bin b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.bin new file mode 100644 index 0000000000..99d37d648d --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.bin @@ -0,0 +1,64 @@ +0000000011010100 +0000000001101001 +0000000001000001 +0000000100001110 +0000101110111000 +0000000100001110 +0000000100001110 +1110101001100000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/dram1.hex b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.hex new file mode 100644 index 0000000000..587409d42f --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.hex @@ -0,0 +1,72 @@ +// +// Application: +// Asic ID: MC33816 +// Version: +// DRAM +// Date: Thursday, December 26, 2019 +// Author: Andrey +// +0x00D4, +0x0069, +0x0041, +0x010E, +0x0BB8, +0x010E, +0x010E, +0xEA60, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/dram2.bin b/firmware/hw_layer/mc33816/rusefi/Registers/dram2.bin new file mode 100644 index 0000000000..a0478d0b09 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/dram2.bin @@ -0,0 +1,64 @@ +0000000011001101 +0000000011010000 +0000000000100101 +0000000000110111 +0000000100001110 +1110101001100000 +0000000001101001 +0000000001000001 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/dram2.hex b/firmware/hw_layer/mc33816/rusefi/Registers/dram2.hex new file mode 100644 index 0000000000..4f7e7b3188 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/dram2.hex @@ -0,0 +1,72 @@ +// +// Application: +// Asic ID: MC33816 +// Version: +// DRAM +// Date: Thursday, December 26, 2019 +// Author: Andrey +// +0x00CD, +0x00D0, +0x0025, +0x0037, +0x010E, +0xEA60, +0x0069, +0x0041, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000, +0x0000 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/io_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/io_config_reg.bin new file mode 100644 index 0000000000..fcd7655df6 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/io_config_reg.bin @@ -0,0 +1,44 @@ +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000001100011 +0000000110001100 +0000100000000000 +0000011000010000 +0000000001000001 +0000000010011000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000010010 +0000000000010010 +0000000000010010 +0000000000000000 +0000000000010101 +0000000000010101 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000010000000 +0000000010000000 +0000000010000000 +0000000000000001 +0000000010000001 +0000000001000001 +0000000000001000 +0000000000000100 +0000000000000001 +0000000010001100 +0000000000000000 +0000000000100000 +0000000000100000 +0000000000101110 +0000000000000000 diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/main_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/main_config_reg.bin new file mode 100644 index 0000000000..e9a15a99ee --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Registers/main_config_reg.bin @@ -0,0 +1,29 @@ +0000000000000011 +0001111111000000 +0000000000000000 +0001000000000000 +0000000000010111 +0010000000000000 +0000000000000001 +0000000000000000 +0000000000011111 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +1001110000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 diff --git a/firmware/hw_layer/mc33816/rusefi/Simulator/AutoLoad.xml b/firmware/hw_layer/mc33816/rusefi/Simulator/AutoLoad.xml new file mode 100644 index 0000000000..3a2735e668 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Simulator/AutoLoad.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/firmware/hw_layer/mc33816/rusefi/Stimulus/stim.xml b/firmware/hw_layer/mc33816/rusefi/Stimulus/stim.xml new file mode 100644 index 0000000000..69fd5e9267 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/Stimulus/stim.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/firmware/hw_layer/mc33816/rusefi/labels.xml b/firmware/hw_layer/mc33816/rusefi/labels.xml new file mode 100644 index 0000000000..0fac009540 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/labels.xml @@ -0,0 +1,23 @@ + + + + init0 + irq_sw + + irq_auto + init1 + + + + + + init0 + + + + init1 + + + + + \ No newline at end of file diff --git a/firmware/hw_layer/mc33816/rusefi/project.xml b/firmware/hw_layer/mc33816/rusefi/project.xml new file mode 100644 index 0000000000..a36057b5b1 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/project.xml @@ -0,0 +1,473 @@ + + + MC33816 + IDE Project + %APPLICATION% + %DEVICEID% + rusefi + %PREFIX% + + + Registers\main_config_reg.hex + Registers\ch1_config_reg.hex + Registers\ch2_config_reg.hex + Registers\ch3_config_reg.hex + Registers\diag_config_reg.hex + Registers\io_config_reg.hex + MicrocodeCh1\ch1.psc + MicrocodeCh2\ch2.psc + MicrocodeCh3\ch3.psc + Registers\dram1.hex + Registers\dram2.hex + Registers\dram3.hex + Simulator\AutoLoad.xml + + + 1 MHz + + + + + + True + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + + + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + + + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + + + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + + + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + + + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + Hex + + + + + + + + + + \ No newline at end of file diff --git a/firmware/hw_layer/mc33816/rusefi/readme.md b/firmware/hw_layer/mc33816/rusefi/readme.md new file mode 100644 index 0000000000..7459e997d6 --- /dev/null +++ b/firmware/hw_layer/mc33816/rusefi/readme.md @@ -0,0 +1 @@ +Completely default project as generated by MC33816 Dev Studio conveniently comes with default source code. \ No newline at end of file diff --git a/firmware/hw_layer/microsecond_timer.cpp b/firmware/hw_layer/microsecond_timer.cpp index f5e70acf4d..9887834c28 100644 --- a/firmware/hw_layer/microsecond_timer.cpp +++ b/firmware/hw_layer/microsecond_timer.cpp @@ -130,7 +130,7 @@ static void hwTimerCallback(GPTDriver *gptp) { class MicrosecondTimerWatchdogController : public PeriodicTimerController { void PeriodicTask() override { - efitime_t nowNt = getTimeNowNt(); + efitick_t nowNt = getTimeNowNt(); if (nowNt >= lastSetTimerTimeNt + 2 * CORE_CLOCK) { strcpy(buff, "no_event"); itoa10(&buff[8], lastSetTimerValue); diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index a113c81004..d12b718465 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -127,7 +127,7 @@ static int logFileIndex = 1; static char logName[_MAX_FILLER + 20]; static void printMmcPinout(void) { - scheduleMsg(&logger, "MMC CS %s", hwPortname(CONFIGB(sdCardCsPin))); + scheduleMsg(&logger, "MMC CS %s", hwPortname(CONFIG(sdCardCsPin))); // todo: we need to figure out the right SPI pinout, not just SPI2 // scheduleMsg(&logger, "MMC SCK %s:%d", portname(EFI_SPI2_SCK_PORT), EFI_SPI2_SCK_PIN); // scheduleMsg(&logger, "MMC MISO %s:%d", portname(EFI_SPI2_MISO_PORT), EFI_SPI2_MISO_PIN); @@ -136,7 +136,7 @@ static void printMmcPinout(void) { static void sdStatistics(void) { printMmcPinout(); - scheduleMsg(&logger, "SD enabled=%s status=%s", boolToString(CONFIGB(isSdCardEnabled)), + scheduleMsg(&logger, "SD enabled=%s status=%s", boolToString(CONFIG(isSdCardEnabled)), sdStatus); if (isSdCardAlive()) { scheduleMsg(&logger, "filename=%s size=%d", logName, totalLoggedBytes); @@ -462,8 +462,8 @@ static THD_FUNCTION(MMCmonThread, arg) { chThdSleepMilliseconds(100); } - if (boardConfiguration->sdCardPeriodMs > 0) { - chThdSleepMilliseconds(boardConfiguration->sdCardPeriodMs); + if (engineConfiguration->sdCardPeriodMs > 0) { + chThdSleepMilliseconds(engineConfiguration->sdCardPeriodMs); } } } @@ -475,13 +475,13 @@ bool isSdCardAlive(void) { void initMmcCard(void) { logName[0] = 0; addConsoleAction("sdinfo", sdStatistics); - if (!CONFIGB(isSdCardEnabled)) { + if (!CONFIG(isSdCardEnabled)) { return; } // todo: reuse initSpiCs method? - hs_spicfg.ssport = ls_spicfg.ssport = getHwPort("mmc", CONFIGB(sdCardCsPin)); - hs_spicfg.sspad = ls_spicfg.sspad = getHwPin("mmc", CONFIGB(sdCardCsPin)); + hs_spicfg.ssport = ls_spicfg.ssport = getHwPort("mmc", CONFIG(sdCardCsPin)); + hs_spicfg.sspad = ls_spicfg.sspad = getHwPin("mmc", CONFIG(sdCardCsPin)); mmccfg.spip = getSpiDevice(engineConfiguration->sdCardSpiDevice); /** diff --git a/firmware/hw_layer/neo6m.cpp b/firmware/hw_layer/neo6m.cpp index 376357d69f..0bcd458db1 100644 --- a/firmware/hw_layer/neo6m.cpp +++ b/firmware/hw_layer/neo6m.cpp @@ -46,8 +46,8 @@ float getCurrentSpeed(void) { EXTERN_ENGINE; static void printGpsInfo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - scheduleMsg(&logging, "GPS RX %s", hwPortname(CONFIGB(gps_rx_pin))); - scheduleMsg(&logging, "GPS TX %s", hwPortname(CONFIGB(gps_tx_pin))); + scheduleMsg(&logging, "GPS RX %s", hwPortname(CONFIG(gps_rx_pin))); + scheduleMsg(&logging, "GPS TX %s", hwPortname(CONFIG(gps_tx_pin))); scheduleMsg(&logging, "m=%d,e=%d: vehicle speed = %.2f\r\n", gpsMesagesCount, uartErrors, getCurrentSpeed()); @@ -101,8 +101,8 @@ static THD_FUNCTION(GpsThreadEntryPoint, arg) { } static bool isGpsEnabled() { - return CONFIGB(gps_rx_pin) != GPIO_UNASSIGNED || - CONFIGB(gps_tx_pin) != GPIO_UNASSIGNED; + return CONFIG(gps_rx_pin) != GPIO_UNASSIGNED || + CONFIG(gps_tx_pin) != GPIO_UNASSIGNED; } void initGps(void) { @@ -112,8 +112,8 @@ void initGps(void) { sdStart(GPS_SERIAL_DEVICE, &GPSserialConfig); // GPS we have USART1: PB7 -> USART1_RX and PB6 -> USART1_TX - efiSetPadMode("GPS tx", CONFIGB(gps_tx_pin), PAL_MODE_ALTERNATE(7)); - efiSetPadMode("GPS rx", CONFIGB(gps_rx_pin), PAL_MODE_ALTERNATE(7)); + efiSetPadMode("GPS tx", CONFIG(gps_tx_pin), PAL_MODE_ALTERNATE(7)); + efiSetPadMode("GPS rx", CONFIG(gps_rx_pin), PAL_MODE_ALTERNATE(7)); // todo: add a thread which would save location. If the GPS 5Hz - we should save the location each 200 ms chThdCreateStatic(gpsThreadStack, sizeof(gpsThreadStack), LOWPRIO, (tfunc_t)(void*) GpsThreadEntryPoint, NULL); diff --git a/firmware/hw_layer/ports/kinetis/mpu_util.cpp b/firmware/hw_layer/ports/kinetis/mpu_util.cpp index 78475108f3..1d6052555e 100644 --- a/firmware/hw_layer/ports/kinetis/mpu_util.cpp +++ b/firmware/hw_layer/ports/kinetis/mpu_util.cpp @@ -77,11 +77,11 @@ static int getSpiAf(SPIDriver *driver) { brain_pin_e getMisoPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1misoPin); + return CONFIG(spi1misoPin); case SPI_DEVICE_2: - return CONFIGB(spi2misoPin); + return CONFIG(spi2misoPin); case SPI_DEVICE_3: - return CONFIGB(spi3misoPin); + return CONFIG(spi3misoPin); default: break; } @@ -91,11 +91,11 @@ brain_pin_e getMisoPin(spi_device_e device) { brain_pin_e getMosiPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1mosiPin); + return CONFIG(spi1mosiPin); case SPI_DEVICE_2: - return CONFIGB(spi2mosiPin); + return CONFIG(spi2mosiPin); case SPI_DEVICE_3: - return CONFIGB(spi3mosiPin); + return CONFIG(spi3mosiPin); default: break; } @@ -105,11 +105,11 @@ brain_pin_e getMosiPin(spi_device_e device) { brain_pin_e getSckPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1sckPin); + return CONFIG(spi1sckPin); case SPI_DEVICE_2: - return CONFIGB(spi2sckPin); + return CONFIG(spi2sckPin); case SPI_DEVICE_3: - return CONFIGB(spi3sckPin); + return CONFIG(spi3sckPin); default: break; } diff --git a/firmware/hw_layer/ports/stm32/stm32_common_mpu_util.h b/firmware/hw_layer/ports/stm32/stm32_common_mpu_util.h index 15b9c51a64..ef22c44ff8 100644 --- a/firmware/hw_layer/ports/stm32/stm32_common_mpu_util.h +++ b/firmware/hw_layer/ports/stm32/stm32_common_mpu_util.h @@ -7,6 +7,9 @@ */ // burnout or 'Burn Out' + +#include "rusefi_enums.h" + typedef enum { BOR_Level_None = OB_BOR_OFF, // 0x0C=12 Supply voltage ranges from 1.62 to 2.10 V BOR_Level_1 = OB_BOR_LEVEL1, // 0x08 Supply voltage ranges from 2.10 to 2.40 V diff --git a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp index 3585257993..bdb52cc2c9 100644 --- a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp +++ b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp @@ -241,11 +241,11 @@ static int getSpiAf(SPIDriver *driver) { brain_pin_e getMisoPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1misoPin); + return CONFIG(spi1misoPin); case SPI_DEVICE_2: - return CONFIGB(spi2misoPin); + return CONFIG(spi2misoPin); case SPI_DEVICE_3: - return CONFIGB(spi3misoPin); + return CONFIG(spi3misoPin); default: break; } @@ -255,11 +255,11 @@ brain_pin_e getMisoPin(spi_device_e device) { brain_pin_e getMosiPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1mosiPin); + return CONFIG(spi1mosiPin); case SPI_DEVICE_2: - return CONFIGB(spi2mosiPin); + return CONFIG(spi2mosiPin); case SPI_DEVICE_3: - return CONFIGB(spi3mosiPin); + return CONFIG(spi3mosiPin); default: break; } @@ -269,11 +269,11 @@ brain_pin_e getMosiPin(spi_device_e device) { brain_pin_e getSckPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1sckPin); + return CONFIG(spi1sckPin); case SPI_DEVICE_2: - return CONFIGB(spi2sckPin); + return CONFIG(spi2sckPin); case SPI_DEVICE_3: - return CONFIGB(spi3sckPin); + return CONFIG(spi3sckPin); default: break; } diff --git a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h index dab40184d0..cecc89e295 100644 --- a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h +++ b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h @@ -2,10 +2,10 @@ * @file mpu_util.h * * @date Jul 27, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef MPU_UTIL_H_ -#define MPU_UTIL_H_ + +#pragma once #include "stm32f4xx_hal_flash_ex.h" #include "stm32_common_mpu_util.h" @@ -34,6 +34,10 @@ #define GPIO_AF_TIM5 2 #endif +#ifndef GPIO_AF_TIM8 +#define GPIO_AF_TIM8 3 +#endif + #ifndef GPIO_AF_TIM9 #define GPIO_AF_TIM9 3 #endif @@ -73,7 +77,6 @@ void HardFaultVector(void); } #endif /* __cplusplus */ -#endif /* MPU_UTIL_H_ */ #if HAL_USE_SPI void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, diff --git a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp index bce4e43da2..aa4f9203b9 100644 --- a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp +++ b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp @@ -236,11 +236,11 @@ static int getSpiAf(SPIDriver *driver) { brain_pin_e getMisoPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1misoPin); + return CONFIG(spi1misoPin); case SPI_DEVICE_2: - return CONFIGB(spi2misoPin); + return CONFIG(spi2misoPin); case SPI_DEVICE_3: - return CONFIGB(spi3misoPin); + return CONFIG(spi3misoPin); default: break; } @@ -250,11 +250,11 @@ brain_pin_e getMisoPin(spi_device_e device) { brain_pin_e getMosiPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1mosiPin); + return CONFIG(spi1mosiPin); case SPI_DEVICE_2: - return CONFIGB(spi2mosiPin); + return CONFIG(spi2mosiPin); case SPI_DEVICE_3: - return CONFIGB(spi3mosiPin); + return CONFIG(spi3mosiPin); default: break; } @@ -264,11 +264,11 @@ brain_pin_e getMosiPin(spi_device_e device) { brain_pin_e getSckPin(spi_device_e device) { switch(device) { case SPI_DEVICE_1: - return CONFIGB(spi1sckPin); + return CONFIG(spi1sckPin); case SPI_DEVICE_2: - return CONFIGB(spi2sckPin); + return CONFIG(spi2sckPin); case SPI_DEVICE_3: - return CONFIGB(spi3sckPin); + return CONFIG(spi3sckPin); default: break; } diff --git a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h index 77d003b3e9..347548d08e 100644 --- a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h +++ b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h @@ -2,10 +2,10 @@ * @file mpu_util.h * * @date Jul 27, 2014 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef MPU_UTIL_H_ -#define MPU_UTIL_H_ + +#pragma once #include "stm32f7xx_hal_flash_ex.h" #include "stm32_common_mpu_util.h" @@ -35,6 +35,10 @@ #define GPIO_AF_TIM5 2 #endif +#ifndef GPIO_AF_TIM8 +#define GPIO_AF_TIM8 3 +#endif + #ifndef GPIO_AF_TIM9 #define GPIO_AF_TIM9 3 #endif @@ -76,7 +80,6 @@ void HardFaultVector(void); } #endif /* __cplusplus */ -#endif /* MPU_UTIL_H_ */ #if HAL_USE_SPI void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, diff --git a/firmware/hw_layer/sensors/accelerometer.cpp b/firmware/hw_layer/sensors/accelerometer.cpp index 81e55a508d..f4c1bac5de 100644 --- a/firmware/hw_layer/sensors/accelerometer.cpp +++ b/firmware/hw_layer/sensors/accelerometer.cpp @@ -44,12 +44,12 @@ static const SPIConfig accelerometerCfg = { void configureAccelerometerPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // engineConfiguration->LIS302DLCsPin = GPIOE_3; // we have a conflict with VVT output on Miata -// CONFIGB(is_enabled_spi_1) = true; // we have a conflict with PA5 input pin +// CONFIG(is_enabled_spi_1) = true; // we have a conflict with PA5 input pin // stm32f4discovery defaults - CONFIGB(spi1mosiPin) = GPIOA_7; - CONFIGB(spi1misoPin) = GPIOA_6; - CONFIGB(spi1sckPin) = GPIOA_5; + CONFIG(spi1mosiPin) = GPIOA_7; + CONFIG(spi1misoPin) = GPIOA_6; + CONFIG(spi1sckPin) = GPIOA_5; } @@ -61,7 +61,7 @@ class AccelController : public PeriodicController { public: AccelController() : PeriodicController("Acc SPI") { } private: - void PeriodicTask(efitime_t nowNt) override { + void PeriodicTask(efitick_t nowNt) override { // has to be a thread since we want to use blocking method - blocking method only available in threads, not in interrupt handler // todo: migrate to async SPI API? engine->sensors.accelerometer.x = (int8_t)lis302dlReadRegister(driver, LIS302DL_OUTX); @@ -76,7 +76,7 @@ void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (engineConfiguration->LIS302DLCsPin == GPIO_UNASSIGNED) return; // not used - if (!CONFIGB(is_enabled_spi_1)) + if (!CONFIG(is_enabled_spi_1)) return; // temporary #if HAL_USE_SPI driver = getSpiDevice(engineConfiguration->accelerometerSpiDevice); @@ -90,8 +90,8 @@ void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) { initSpiCs((SPIConfig *)driver->config, engineConfiguration->LIS302DLCsPin); // memsCs.initPin("LIS302 CS", engineConfiguration->LIS302DLCsPin); -// memsCfg.ssport = getHwPort("mmc", CONFIGB(sdCardCsPin)); -// memsCfg.sspad = getHwPin("mmc", CONFIGB(sdCardCsPin)); +// memsCfg.ssport = getHwPort("mmc", CONFIG(sdCardCsPin)); +// memsCfg.sspad = getHwPin("mmc", CONFIG(sdCardCsPin)); /* LIS302DL initialization.*/ diff --git a/firmware/hw_layer/sensors/cj125.cpp b/firmware/hw_layer/sensors/cj125.cpp index d24f6c08d4..226b67d56c 100644 --- a/firmware/hw_layer/sensors/cj125.cpp +++ b/firmware/hw_layer/sensors/cj125.cpp @@ -266,7 +266,7 @@ static void cjCalibrate(void) { } static void cjStart(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (!CONFIGB(isCJ125Enabled)) { + if (!CONFIG(isCJ125Enabled)) { scheduleMsg(logger, "cj125 is disabled."); return; } @@ -313,35 +313,35 @@ void CJ125::setError(cj125_error_e errCode DECLARE_ENGINE_PARAMETER_SUFFIX) { // engineConfiguration->spi2SckMode = PAL_STM32_OTYPE_OPENDRAIN; // 4 // engineConfiguration->spi2MosiMode = PAL_STM32_OTYPE_OPENDRAIN; // 4 // engineConfiguration->spi2MisoMode = PAL_STM32_PUDR_PULLUP; // 32 -// CONFIGB(cj125CsPin) = GPIOA_15; +// CONFIG(cj125CsPin) = GPIOA_15; // engineConfiguration->cj125CsPinMode = OM_OPENDRAIN; void cj125defaultPinout(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->cj125ua = EFI_ADC_13; // PC3 engineConfiguration->cj125ur = EFI_ADC_4; // PA4 - CONFIGB(wboHeaterPin) = GPIOC_13; + CONFIG(wboHeaterPin) = GPIOC_13; - CONFIGB(isCJ125Enabled) = false; + CONFIG(isCJ125Enabled) = false; - CONFIGB(spi2mosiPin) = GPIOB_15; - CONFIGB(spi2misoPin) = GPIOB_14; - CONFIGB(spi2sckPin) = GPIOB_13; + CONFIG(spi2mosiPin) = GPIOB_15; + CONFIG(spi2misoPin) = GPIOB_14; + CONFIG(spi2sckPin) = GPIOB_13; - CONFIGB(cj125CsPin) = GPIOB_0; - CONFIGB(isCJ125Enabled) = true; - CONFIGB(is_enabled_spi_2) = true; + CONFIG(cj125CsPin) = GPIOB_0; + CONFIG(isCJ125Enabled) = true; + CONFIG(is_enabled_spi_2) = true; } static void cjStartSpi(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - globalInstance.cj125Cs.initPin("cj125 CS", CONFIGB(cj125CsPin), + globalInstance.cj125Cs.initPin("cj125 CS", CONFIG(cj125CsPin), &engineConfiguration->cj125CsPinMode); // Idle CS pin - SPI CS is high when idle globalInstance.cj125Cs.setValue(true); cj125spicfg.cr1 += getSpiPrescaler(_150KHz, engineConfiguration->cj125SpiDevice); - cj125spicfg.ssport = getHwPort("cj125", CONFIGB(cj125CsPin)); - cj125spicfg.sspad = getHwPin("cj125", CONFIGB(cj125CsPin)); + cj125spicfg.ssport = getHwPort("cj125", CONFIG(cj125CsPin)); + cj125spicfg.sspad = getHwPin("cj125", CONFIG(cj125CsPin)); driver = getSpiDevice(engineConfiguration->cj125SpiDevice); if (driver == NULL) { // error already reported @@ -463,7 +463,7 @@ static msg_t cjThread(void) #if ! EFI_UNIT_TEST static bool cjCheckConfig(void) { - if (!CONFIGB(isCJ125Enabled)) { + if (!CONFIG(isCJ125Enabled)) { scheduleMsg(logger, "cj125 is disabled. Failed!"); return false; } @@ -518,7 +518,7 @@ float cjGetAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } bool cjHasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (!CONFIGB(isCJ125Enabled)) + if (!CONFIG(isCJ125Enabled)) return false; return globalInstance.isValidState(); } @@ -543,7 +543,7 @@ void initCJ125(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { globalInstance.spi = &spi; globalInstance.logger = sharedLogger; - if (!CONFIGB(isCJ125Enabled)) { + if (!CONFIG(isCJ125Enabled)) { globalInstance.errorCode = CJ125_ERROR_DISABLED; return; } @@ -555,7 +555,7 @@ void initCJ125(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { return; } - if (CONFIGB(wboHeaterPin) == GPIO_UNASSIGNED) { + if (CONFIG(wboHeaterPin) == GPIO_UNASSIGNED) { scheduleMsg(logger, "cj125 init error! wboHeaterPin is required."); warning(CUSTOM_CJ125_1, "cj heater"); globalInstance.errorCode = CJ125_ERROR_DISABLED; diff --git a/firmware/hw_layer/sensors/cj125_logic.cpp b/firmware/hw_layer/sensors/cj125_logic.cpp index e8b017da1e..3411f815cc 100644 --- a/firmware/hw_layer/sensors/cj125_logic.cpp +++ b/firmware/hw_layer/sensors/cj125_logic.cpp @@ -43,7 +43,7 @@ void CJ125::StartHeaterControl(pwm_gen_callback *stateChangeCallback DECLARE_ENG // todo: use custom pin state method, turn pin off while not running startSimplePwmExt(&wboHeaterControl, "wboHeaterPin", &engine->executor, - CONFIGB(wboHeaterPin), + CONFIG(wboHeaterPin), &wboHeaterPin, CJ125_HEATER_PWM_FREQ, 0.0f, stateChangeCallback); SetIdleHeater(PASS_ENGINE_PARAMETER_SIGNATURE); } diff --git a/firmware/hw_layer/sensors/joystick.cpp b/firmware/hw_layer/sensors/joystick.cpp index 45bee159a8..f6f624de2b 100644 --- a/firmware/hw_layer/sensors/joystick.cpp +++ b/firmware/hw_layer/sensors/joystick.cpp @@ -50,21 +50,21 @@ static void extCallback(ioportmask_t channel) { joyTotal++; joystick_button_e button; // todo: I guess it's time to reduce code duplication and start working with an array - if (channel == getHwPin("joy", CONFIGB(joystickCenterPin))) { + if (channel == getHwPin("joy", CONFIG(joystickCenterPin))) { joyCenter++; button = JB_CENTER; - } else if (channel == getHwPin("joy", CONFIGB(joystickAPin))) { + } else if (channel == getHwPin("joy", CONFIG(joystickAPin))) { joyA++; button = JB_BUTTON_A; /* not used so far - } else if (channel == getHwPin("joy", CONFIGB(joystickBPin))) { + } else if (channel == getHwPin("joy", CONFIG(joystickBPin))) { joyB++; button = JB_BUTTON_B; - } else if (channel == getHwPin("joy", CONFIGB(joystickCPin))) { + } else if (channel == getHwPin("joy", CONFIG(joystickCPin))) { joyC++; button = JB_BUTTON_C; */ - } else if (channel == getHwPin("joy", CONFIGB(joystickDPin))) { + } else if (channel == getHwPin("joy", CONFIG(joystickDPin))) { joyD++; button = JB_BUTTON_D; } else { @@ -80,34 +80,34 @@ static void extCallback(ioportmask_t channel) { static void joystickInfo(void) { scheduleMsg(sharedLogger, "total %d center=%d@%s", joyTotal, joyCenter, - hwPortname(CONFIGB(joystickCenterPin))); - scheduleMsg(sharedLogger, "a=%d@%s", joyA, hwPortname(CONFIGB(joystickAPin))); - scheduleMsg(sharedLogger, "b=%d@%s", joyB, hwPortname(CONFIGB(joystickBPin))); - scheduleMsg(sharedLogger, "c=%d@%s", joyC, hwPortname(CONFIGB(joystickCPin))); - scheduleMsg(sharedLogger, "d=%d@%s", joyD, hwPortname(CONFIGB(joystickDPin))); + hwPortname(CONFIG(joystickCenterPin))); + scheduleMsg(sharedLogger, "a=%d@%s", joyA, hwPortname(CONFIG(joystickAPin))); + scheduleMsg(sharedLogger, "b=%d@%s", joyB, hwPortname(CONFIG(joystickBPin))); + scheduleMsg(sharedLogger, "c=%d@%s", joyC, hwPortname(CONFIG(joystickCPin))); + scheduleMsg(sharedLogger, "d=%d@%s", joyD, hwPortname(CONFIG(joystickDPin))); } static bool isJoystickEnabled() { - return CONFIGB(joystickCenterPin) != GPIO_UNASSIGNED || - CONFIGB(joystickAPin) != GPIO_UNASSIGNED || - // not used so far CONFIGB(joystickBPin) != GPIO_UNASSIGNED || - // not used so far CONFIGB(joystickCPin) != GPIO_UNASSIGNED || - CONFIGB(joystickDPin) != GPIO_UNASSIGNED; + return CONFIG(joystickCenterPin) != GPIO_UNASSIGNED || + CONFIG(joystickAPin) != GPIO_UNASSIGNED || + // not used so far CONFIG(joystickBPin) != GPIO_UNASSIGNED || + // not used so far CONFIG(joystickCPin) != GPIO_UNASSIGNED || + CONFIG(joystickDPin) != GPIO_UNASSIGNED; } void stopJoystickPins() { - brain_pin_markUnused(activeConfiguration.bc.joystickCenterPin); - brain_pin_markUnused(activeConfiguration.bc.joystickAPin); - brain_pin_markUnused(activeConfiguration.bc.joystickDPin); + brain_pin_markUnused(activeConfiguration.joystickCenterPin); + brain_pin_markUnused(activeConfiguration.joystickAPin); + brain_pin_markUnused(activeConfiguration.joystickDPin); } void startJoystickPins() { // todo: extract 'configurePalInputPin() method? - efiSetPadMode("joy center", CONFIGB(joystickCenterPin), PAL_MODE_INPUT_PULLUP); - efiSetPadMode("joy A", CONFIGB(joystickAPin), PAL_MODE_INPUT_PULLUP); - // not used so far efiSetPadMode("joy B", CONFIGB(joystickBPin), PAL_MODE_INPUT_PULLUP); - // not used so far efiSetPadMode("joy C", CONFIGB(joystickCPin), PAL_MODE_INPUT_PULLUP); - efiSetPadMode("joy D", CONFIGB(joystickDPin), PAL_MODE_INPUT_PULLUP); + efiSetPadMode("joy center", CONFIG(joystickCenterPin), PAL_MODE_INPUT_PULLUP); + efiSetPadMode("joy A", CONFIG(joystickAPin), PAL_MODE_INPUT_PULLUP); + // not used so far efiSetPadMode("joy B", CONFIG(joystickBPin), PAL_MODE_INPUT_PULLUP); + // not used so far efiSetPadMode("joy C", CONFIG(joystickCPin), PAL_MODE_INPUT_PULLUP); + efiSetPadMode("joy D", CONFIG(joystickDPin), PAL_MODE_INPUT_PULLUP); } void initJoystick(Logging *shared) { @@ -117,14 +117,14 @@ void initJoystick(Logging *shared) { return; sharedLogger = shared; - channel = getHwPin("joy", CONFIGB(joystickCenterPin)); - efiExtiEnablePin("joy", CONFIGB(joystickCenterPin), PAL_EVENT_MODE_RISING_EDGE, (palcallback_t)(void *)extCallback, (void *)channel); - channel = getHwPin("joy", CONFIGB(joystickAPin)); - efiExtiEnablePin("joy", CONFIGB(joystickAPin), PAL_EVENT_MODE_RISING_EDGE, (palcallback_t)(void *)extCallback, (void *)channel); -// not used so far applyPin(CONFIGB(joystickBPin)); -// not used so far applyPin(CONFIGB(joystickCPin)); - channel = getHwPin("joy", CONFIGB(joystickDPin)); - efiExtiEnablePin("joy", CONFIGB(joystickDPin), PAL_EVENT_MODE_RISING_EDGE, (palcallback_t)(void *)extCallback, (void *)channel); + channel = getHwPin("joy", CONFIG(joystickCenterPin)); + efiExtiEnablePin("joy", CONFIG(joystickCenterPin), PAL_EVENT_MODE_RISING_EDGE, (palcallback_t)(void *)extCallback, (void *)channel); + channel = getHwPin("joy", CONFIG(joystickAPin)); + efiExtiEnablePin("joy", CONFIG(joystickAPin), PAL_EVENT_MODE_RISING_EDGE, (palcallback_t)(void *)extCallback, (void *)channel); +// not used so far applyPin(CONFIG(joystickBPin)); +// not used so far applyPin(CONFIG(joystickCPin)); + channel = getHwPin("joy", CONFIG(joystickDPin)); + efiExtiEnablePin("joy", CONFIG(joystickDPin), PAL_EVENT_MODE_RISING_EDGE, (palcallback_t)(void *)extCallback, (void *)channel); startJoystickPins(); } diff --git a/firmware/hw_layer/servo.cpp b/firmware/hw_layer/servo.cpp index 191657dd73..0a398eb3f3 100644 --- a/firmware/hw_layer/servo.cpp +++ b/firmware/hw_layer/servo.cpp @@ -20,7 +20,10 @@ EXTERN_ENGINE; -THD_WORKING_AREA(servoThreadStack, UTILITY_THREAD_STACK_SIZE); +// This thread calls scheduleForLater which eventually could trip the main trigger callback +// if self stimulation (heh) is enabled, which uses a TON of stack space. +// So this stack has to be pretty big, unfortunately. +THD_WORKING_AREA(servoThreadStack, UTILITY_THREAD_STACK_SIZE * 3); static OutputPin pins[SERVO_COUNT]; diff --git a/firmware/hw_layer/smart_gpio.cpp b/firmware/hw_layer/smart_gpio.cpp index 40c5c97053..26ab59f0c4 100644 --- a/firmware/hw_layer/smart_gpio.cpp +++ b/firmware/hw_layer/smart_gpio.cpp @@ -156,10 +156,10 @@ void initSmartGpio() { gpiochip_use_gpio_base(TLE6240_OUTPUTS); #if (BOARD_MC33972_COUNT > 0) - if (boardConfiguration->mc33972_cs != GPIO_UNASSIGNED) { + if (engineConfiguration->mc33972_cs != GPIO_UNASSIGNED) { // todo: reuse initSpiCs method? - mc33972.spi_config.ssport = getHwPort("mc33972 CS", boardConfiguration->mc33972_cs); - mc33972.spi_config.sspad = getHwPin("mc33972 CS", boardConfiguration->mc33972_cs); + mc33972.spi_config.ssport = getHwPort("mc33972 CS", engineConfiguration->mc33972_cs); + mc33972.spi_config.sspad = getHwPin("mc33972 CS", engineConfiguration->mc33972_cs); mc33972.spi_bus = getSpiDevice(engineConfiguration->mc33972spiDevice); // todo: propogate 'basePinOffset' parameter ret = mc33972_add(0, &mc33972); @@ -209,7 +209,7 @@ void stopSmartCsPins() { brain_pin_markUnused(activeConfiguration.tle6240_cs); #endif /* BOARD_TLE6240_COUNT */ #if (BOARD_MC33972_COUNT > 0) - brain_pin_markUnused(activeConfiguration.bc.mc33972_cs); + brain_pin_markUnused(activeConfiguration.mc33972_cs); #endif /* BOARD_MC33972_COUNT */ } @@ -225,8 +225,8 @@ void startSmartCsPins() { tle6240Cs.setValue(true); #endif /* BOARD_TLE6240_COUNT */ #if (BOARD_MC33972_COUNT > 0) - mc33972Cs.initPin("mc33972 CS", boardConfiguration->mc33972_cs, - &boardConfiguration->mc33972_csPinMode); + mc33972Cs.initPin("mc33972 CS", engineConfiguration->mc33972_cs, + &engineConfiguration->mc33972_csPinMode); mc33972Cs.setValue(true); #endif /* BOARD_MC33972_COUNT */ } diff --git a/firmware/hw_layer/stepper.cpp b/firmware/hw_layer/stepper.cpp index 663804a243..58ddb11103 100644 --- a/firmware/hw_layer/stepper.cpp +++ b/firmware/hw_layer/stepper.cpp @@ -53,7 +53,7 @@ static msg_t stThread(StepperMotor *motor) { #endif /* EFI_SHAFT_POSITION_INPUT */ // now check if stepper motor re-initialization is requested - if the throttle pedal is pressed at startup bool forceStepperParking = !isRunning && getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > STEPPER_PARKING_TPS; - if (CONFIGB(stepperForceParkingEveryRestart)) + if (CONFIG(stepperForceParkingEveryRestart)) forceStepperParking = true; scheduleMsg(logger, "Stepper: savedStepperPos=%d forceStepperParking=%d (tps=%.2f)", motor->currentPosition, (forceStepperParking ? 1 : 0), getTPS(PASS_ENGINE_PARAMETER_SIGNATURE)); @@ -69,7 +69,7 @@ static msg_t stThread(StepperMotor *motor) { * * Add extra steps to compensate step skipping by some old motors. */ - int numParkingSteps = (int)efiRound((1.0f + (float)CONFIGB(stepperParkingExtraSteps) / PERCENT_MULT) * motor->totalSteps, 1.0f); + int numParkingSteps = (int)efiRound((1.0f + (float)CONFIG(stepperParkingExtraSteps) / PERCENT_MULT) * motor->totalSteps, 1.0f); for (int i = 0; i < numParkingSteps; i++) { motor->pulse(); } diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index 3bf42ff9e2..476d7b9b1e 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -15,8 +15,8 @@ EXTERN_ENGINE; #if (HAL_USE_ICU == TRUE) || (HAL_TRIGGER_USE_PAL == TRUE) void stopTriggerInputPins(void) { for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) { - if (isConfigurationChanged(bc.triggerInputPins[i])) { - turnOffTriggerInputPin(activeConfiguration.bc.triggerInputPins[i]); + if (isConfigurationChanged(triggerInputPins[i])) { + turnOffTriggerInputPin(activeConfiguration.triggerInputPins[i]); } } for (int i = 0; i < CAM_INPUTS_COUNT; i++) { @@ -28,7 +28,7 @@ void stopTriggerInputPins(void) { void startTriggerInputPins(void) { for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) { - if (isConfigurationChanged(bc.triggerInputPins[i])) { + if (isConfigurationChanged(triggerInputPins[i])) { const char * msg = (i == 0 ? "trigger#1" : (i == 1 ? "trigger#2" : "trigger#3")); turnOnTriggerInputPin(msg, i, true); } @@ -40,7 +40,7 @@ void startTriggerInputPins(void) { } } - setPrimaryChannel(CONFIGB(triggerInputPins)[0]); + setPrimaryChannel(CONFIG(triggerInputPins)[0]); } #endif diff --git a/firmware/hw_layer/trigger_input_exti.cpp b/firmware/hw_layer/trigger_input_exti.cpp index ac136bbdf1..9fd75b6289 100644 --- a/firmware/hw_layer/trigger_input_exti.cpp +++ b/firmware/hw_layer/trigger_input_exti.cpp @@ -65,7 +65,7 @@ static void cam_callback(void *arg) { } void turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft) { - brain_pin_e brainPin = isTriggerShaft ? CONFIGB(triggerInputPins)[index] : engineConfiguration->camInputs[index]; + brain_pin_e brainPin = isTriggerShaft ? CONFIG(triggerInputPins)[index] : engineConfiguration->camInputs[index]; scheduleMsg(logger, "turnOnTriggerInputPin(PAL) %s %s", msg, hwPortname(brainPin)); diff --git a/firmware/hw_layer/trigger_input_icu.cpp b/firmware/hw_layer/trigger_input_icu.cpp index f3f0eb2260..50a601694a 100644 --- a/firmware/hw_layer/trigger_input_icu.cpp +++ b/firmware/hw_layer/trigger_input_icu.cpp @@ -81,7 +81,7 @@ static void shaftPeriodCallback(bool isPrimary) { void turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft) { (void)msg; - brain_pin_e brainPin = isTriggerShaft ? CONFIGB(triggerInputPins)[index] : engineConfiguration->camInputs[index]; + brain_pin_e brainPin = isTriggerShaft ? CONFIG(triggerInputPins)[index] : engineConfiguration->camInputs[index]; if (brainPin == GPIO_UNASSIGNED) { return; } diff --git a/firmware/init/sensor/init_oil_pressure.cpp b/firmware/init/sensor/init_oil_pressure.cpp index f1069ab644..bf7f167c72 100644 --- a/firmware/init/sensor/init_oil_pressure.cpp +++ b/firmware/init/sensor/init_oil_pressure.cpp @@ -33,11 +33,6 @@ void initOilPressure() { oilpSensorFunc.configure(sensorCfg->v1, val1, sensorCfg->v2, val2, /*minOutput*/ -5, greaterOutput); oilpSensor.setFunction(oilpSensorFunc); -#if EFI_TUNER_STUDIO - // Tell it to report to its output channel - oilpSensor.setReportingLocation(&tsOutputChannels.oilPressure); -#endif - // Subscribe the sensor to the ADC AdcSubscription::SubscribeSensor(oilpSensor, channel); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index f94af55680..6208409d3b 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -23,12 +23,12 @@ ! type name;comment -#define TS_SIGNATURE "rusEFI v1.07" +#define TS_SIGNATURE "rusEFI v1.08" ! ! this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version ! so not forget to change fileVersion in rusefi.ini ! todo: is this not needed in light of TS_SIGNATURE? -#define TS_FILE_VERSION 20190701 +#define TS_FILE_VERSION 20191221 ! all the sub-structures are going to be nested within the primary structure, that's @@ -68,7 +68,7 @@ struct_no_prefix engine_configuration_s #define ETB_BIAS_CURVE_LENGTH 8 ! this is here so that rusEfi console can access it, too -#define TS_OUTPUT_SIZE 356 +#define TS_OUTPUT_SIZE 220 #define MAP_ANGLE_SIZE 8 #define MAP_WINDOW_SIZE 8 @@ -128,6 +128,15 @@ struct_no_prefix engine_configuration_s #define RPM_1_BYTE_PACKING_MULT 50 #define VOLTAGE_1_BYTE_PACKING_DIV 0.02 +! These are used currently only for output channels - but could be for config as well +#define PACK_MULT_PRESSURE 30 +#define PACK_MULT_PERCENT 100 +#define PACK_MULT_TEMPERATURE 100 +#define PACK_MULT_MS 300 +#define PACK_MULT_AFR 1000 +#define PACK_MULT_ANGLE 50 +#define PACK_MULT_VOLTAGE 1000 + #define FSIO_TABLE_8 8 #define FSIO_CURVE_8 8 @@ -508,7 +517,6 @@ struct etb_io pin_output_mode_e controlPinMode; end_struct -struct_no_prefix board_configuration_s idle_hardware_s idle; float manIdlePosition;value between 0 and 100 used in Manual mode;"%", 1, 0, 0, 100, 0 @@ -712,10 +720,7 @@ custom maf_sensor_type_e 4 bits, S32, @OFFSET@, [0:7], @@maf_sensor_type_e_enum@ ! todo: keep moving all these fields at the end of board_configuration_s below 'board_configuration_s bc' ! end of board_configuration_s -end_struct - -board_configuration_s bc; maf_sensor_type_e mafSensorType; custom le_formula_t 200 string, ASCII, @OFFSET@, 200 @@ -1305,6 +1310,9 @@ end_struct #define CMD_CALIBRATE_PEDAL_DOWN "calibrate_pedal_down" #define CMD_ETB_DUTY "set_etb_duty" +#define CMD_RESET_ENGINE_SNIFFER "reset_engine_chart" +#define CMD_FUNCTIONAL_TEST_MODE "test_mode" + #define CMD_ENGINE_TYPE "engine_type" #define CMD_TRIGGERINFO "triggerinfo" #define CMD_WRITECONFIG "writeconfig" diff --git a/firmware/run_hw_test.bat b/firmware/run_hw_test.bat new file mode 100644 index 0000000000..7beca67165 --- /dev/null +++ b/firmware/run_hw_test.bat @@ -0,0 +1,8 @@ +rem +rem this takes about 12 minutes to run unfortunatelly, current implementation is pretty inefficient :( See comments around 'nextChart()' method +rem pa +rem + +set port=%1 +echo "Port (optional): %port%" +java -jar ../java_console_binary/rusefi_console.jar functional_test %port% diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 04399d7aa9..6686835aa4 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -119,7 +119,6 @@ #include "status_loop.h" #include "pin_repository.h" #include "flash_main.h" -#include "algo.h" #include "custom_engine.h" #include "engine_math.h" #include "mpu_util.h" @@ -244,7 +243,7 @@ void runRusEfi(void) { updateDevConsoleState(); #endif /* EFI_CLI_SUPPORT */ - chThdSleepMilliseconds(CONFIGB(consoleLoopPeriodMs)); + chThdSleepMilliseconds(CONFIG(consoleLoopPeriodMs)); } } diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 85d6ffc978..8d52b13d8a 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -44,7 +44,7 @@ enable2ndByteCanID = false [TunerStudio] queryCommand = "S" versionInfo = "V" ; firmwave version for title bar. - signature = "rusEFI v1.07" ; signature is expected to be 7 or more characters. + signature = "rusEFI v1.08" ; signature is expected to be 7 or more characters. [Constants] ; new packet serial format with CRC @@ -85,7 +85,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Dec 08 00:32:28 EST 2019 +; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Dec 25 15:54:40 EST 2019 pageSize = 20000 page = 1 @@ -125,6 +125,7 @@ page = 1 issue_294_29 = bits, U32, 76, [28:28], "false", "true" issue_294_30 = bits, U32, 76, [29:29], "false", "true" issue_294_31 = bits, U32, 76, [30:30], "false", "true" + unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true" tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0 tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0 tpsErrorDetectionTooLow = scalar, S16, 84, "%", 1, 0, -40, 200, 0 @@ -207,6 +208,35 @@ page = 1 trigger_unusedCustomIsSynchronizationNeeded= bits, U32, 528, [0:0], "false", "true" trigger_unusedCustomNeedSecondTriggerInput= bits, U32, 528, [1:1], "false", "true" trigger_useOnlyFirstChannel= bits, U32, 528, [2:2], "false", "true" + trigger_unusedBit_4_3 = bits, U32, 528, [3:3], "false", "true" + trigger_unusedBit_4_4 = bits, U32, 528, [4:4], "false", "true" + trigger_unusedBit_4_5 = bits, U32, 528, [5:5], "false", "true" + trigger_unusedBit_4_6 = bits, U32, 528, [6:6], "false", "true" + trigger_unusedBit_4_7 = bits, U32, 528, [7:7], "false", "true" + trigger_unusedBit_4_8 = bits, U32, 528, [8:8], "false", "true" + trigger_unusedBit_4_9 = bits, U32, 528, [9:9], "false", "true" + trigger_unusedBit_4_10 = bits, U32, 528, [10:10], "false", "true" + trigger_unusedBit_4_11 = bits, U32, 528, [11:11], "false", "true" + trigger_unusedBit_4_12 = bits, U32, 528, [12:12], "false", "true" + trigger_unusedBit_4_13 = bits, U32, 528, [13:13], "false", "true" + trigger_unusedBit_4_14 = bits, U32, 528, [14:14], "false", "true" + trigger_unusedBit_4_15 = bits, U32, 528, [15:15], "false", "true" + trigger_unusedBit_4_16 = bits, U32, 528, [16:16], "false", "true" + trigger_unusedBit_4_17 = bits, U32, 528, [17:17], "false", "true" + trigger_unusedBit_4_18 = bits, U32, 528, [18:18], "false", "true" + trigger_unusedBit_4_19 = bits, U32, 528, [19:19], "false", "true" + trigger_unusedBit_4_20 = bits, U32, 528, [20:20], "false", "true" + trigger_unusedBit_4_21 = bits, U32, 528, [21:21], "false", "true" + trigger_unusedBit_4_22 = bits, U32, 528, [22:22], "false", "true" + trigger_unusedBit_4_23 = bits, U32, 528, [23:23], "false", "true" + trigger_unusedBit_4_24 = bits, U32, 528, [24:24], "false", "true" + trigger_unusedBit_4_25 = bits, U32, 528, [25:25], "false", "true" + trigger_unusedBit_4_26 = bits, U32, 528, [26:26], "false", "true" + trigger_unusedBit_4_27 = bits, U32, 528, [27:27], "false", "true" + trigger_unusedBit_4_28 = bits, U32, 528, [28:28], "false", "true" + trigger_unusedBit_4_29 = bits, U32, 528, [29:29], "false", "true" + trigger_unusedBit_4_30 = bits, U32, 528, [30:30], "false", "true" + trigger_unusedBit_4_31 = bits, U32, 528, [31:31], "false", "true" trigger_customTotalToothCount = scalar, S32, 532, "number", 1, 0.0, 0, 500.0, 0 trigger_customSkippedToothCount = scalar, S32, 536, "number", 1, 0.0, 0, 500.0, 0 hip9011SpiDevice = bits,U32, 540, [0:7], "Off", "SPI1", "SPI2", "SPI3", "SPI4" @@ -502,6 +532,36 @@ page = 1 ;no TS info - skipping unused offset 972 todoClutchUpPinInverted = bits, U32, 976, [0:0], "false", "true" todoClutchDownPinInverted= bits, U32, 976, [1:1], "false", "true" + unusedBit_247_2 = bits, U32, 976, [2:2], "false", "true" + unusedBit_247_3 = bits, U32, 976, [3:3], "false", "true" + unusedBit_247_4 = bits, U32, 976, [4:4], "false", "true" + unusedBit_247_5 = bits, U32, 976, [5:5], "false", "true" + unusedBit_247_6 = bits, U32, 976, [6:6], "false", "true" + unusedBit_247_7 = bits, U32, 976, [7:7], "false", "true" + unusedBit_247_8 = bits, U32, 976, [8:8], "false", "true" + unusedBit_247_9 = bits, U32, 976, [9:9], "false", "true" + unusedBit_247_10 = bits, U32, 976, [10:10], "false", "true" + unusedBit_247_11 = bits, U32, 976, [11:11], "false", "true" + unusedBit_247_12 = bits, U32, 976, [12:12], "false", "true" + unusedBit_247_13 = bits, U32, 976, [13:13], "false", "true" + unusedBit_247_14 = bits, U32, 976, [14:14], "false", "true" + unusedBit_247_15 = bits, U32, 976, [15:15], "false", "true" + unusedBit_247_16 = bits, U32, 976, [16:16], "false", "true" + unusedBit_247_17 = bits, U32, 976, [17:17], "false", "true" + unusedBit_247_18 = bits, U32, 976, [18:18], "false", "true" + unusedBit_247_19 = bits, U32, 976, [19:19], "false", "true" + unusedBit_247_20 = bits, U32, 976, [20:20], "false", "true" + unusedBit_247_21 = bits, U32, 976, [21:21], "false", "true" + unusedBit_247_22 = bits, U32, 976, [22:22], "false", "true" + unusedBit_247_23 = bits, U32, 976, [23:23], "false", "true" + unusedBit_247_24 = bits, U32, 976, [24:24], "false", "true" + unusedBit_247_25 = bits, U32, 976, [25:25], "false", "true" + unusedBit_247_26 = bits, U32, 976, [26:26], "false", "true" + unusedBit_247_27 = bits, U32, 976, [27:27], "false", "true" + unusedBit_247_28 = bits, U32, 976, [28:28], "false", "true" + unusedBit_247_29 = bits, U32, 976, [29:29], "false", "true" + unusedBit_247_30 = bits, U32, 976, [30:30], "false", "true" + unusedBit_247_31 = bits, U32, 976, [31:31], "false", "true" etbIo1_directionPin1 = bits, U08, 980, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_directionPin2 = bits, U08, 981, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_controlPin1 = bits, U08, 982, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" @@ -1182,147 +1242,182 @@ page = 1 [OutputChannels] -; see TS_FILE_VERSION in firmware code -fileVersion = { 20190701 } +fileVersion = { 20191221 } ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 356 + ochBlockSize = 220 ; ; see TunerStudioOutputChannels struct ; - RPMValue = scalar, U32, 0, "RPM", 1, 0.00000 + +; Bit flags + hasSdCard = bits, U32, 0, [0:0], "true", "false"; + isIgnitionEnabledIndicator=bits,U32, 0, [1:1], "true", "false"; + ind_injection_enabled=bits,U32, 0, [2:2], "true", "false"; + isCylinderCleanupEnabled=bits,U32, 0, [3:3], "true", "false"; + isCylinderCleanupActivated=bits,U32, 0, [4:4], "true", "false"; + ind_fuel_pump = bits, U32, 0, [5:5], "true", "false"; + ind_fan = bits, U32, 0, [6:6], "true", "false"; + ind_o2_heater = bits, U32, 0, [7:7], "true", "false"; + ind_check_engine= bits, U32, 0, [8:8], "true", "false"; + needBurn = bits, U32, 0, [9:9], "true", "false"; + ind_2nd_trigger_en=bits, U32, 0, [10:10], "true", "false"; + clutchUpState =bits, U32, 0, [11:11], "true", "false"; + clutchDownState =bits, U32, 0, [12:12], "true", "false"; + knockEverIndicator=bits, U32, 0, [13:13], "true", "false"; + knockNowIndicator=bits, U32, 0, [14:14], "true", "false"; + brakePedalIndicator=bits, U32, 0, [15:15], "true", "false"; + toothLogReady =bits, U32, 0, [16:16], "true", "false"; + acSwitchIndicator =bits, U32, 0, [17:17], "true", "false"; + ind_tps_error = bits, U32, 0, [18:18], "true", "false"; + ind_clt_error = bits, U32, 0, [19:19], "true", "false"; + ind_map_error = bits, U32, 0, [20:21], "true", "false"; + ind_iat_error = bits, U32, 0, [21:22], "true", "false"; + ind_isTriggerError = bits, U32, 0, [23:23], "true", "false"; + ind_hasFatalError=bits, U32, 0, [24:24], "true", "false"; + ind_isWarnNow =bits, U32, 0, [25:25], "true", "false"; + +; RPM, vss + RPMValue = scalar, U16, 4, "RPM", 1, 0.00000 + rpmAcceleration = scalar, S16, 6, "dRpm",{1/100}, 0 + speedToRpmRatio = scalar, S16, 8, "value",{1/100}, 0 + vehicleSpeedKph = scalar, U08, 10, "kph", 1, 0.0 + +; temperatures + internalMcuTemperature = scalar,S08, 11, "deg C", 1, 0 #if CELSIUS - coolant = scalar, F32, 4, "deg C", 1, 0.0 + coolant = scalar, S16, 12, "deg C",{1/100}, 0.0 #else - coolant = scalar, F32, 4, "deg F", {9/5}, 17.77777 + coolant = scalar, S16, 12, "deg F",{9/(5 * 100)}, 17.77777 #endif #if CELSIUS - intake = scalar, F32, 8, "deg C", 1, 0.0 + intake = scalar, S16, 14, "deg C",{1/100}, 0.0 #else - intake = scalar, F32, 8, "deg F", {9/5}, 17.77777 + intake = scalar, S16, 14, "deg F",{9/(5 * 100)}, 17.77777 #endif - TPSValue = scalar, F32, 12, "%", 1, 0 - MAFValue = scalar, F32, 16, "V", 1, 0 - AFRValue = scalar, F32, 20, "AFR", 1, 0.0 - engineLoad = scalar, F32, 24, "%", 1, 0.0 ; Blend of MAP and TPS, depends on algorithm - VBatt = scalar, F32, 28, "V", 1, 0.0 +; todo: aux1 +; todo: aux2 + + +; throttle, pedal + TPSValue = scalar, U16, 20, "%",{1/100}, 0 + throttlePedalPosition = scalar,U16, 22, "%",{1/100}, 0 + tpsADC = scalar, U16, 24, "ADC", 1, 0.0; + +; air flow/mass measurments + MAFValue = scalar, U16, 26, "V",,{1/1000},, 0 + massAirFlowValue= scalar, U16, 28, "Kg/h", 0.01, 0 + MAPValue = scalar, U16, 30, "kPa",{1/30}, 0.0 + baroPressure = scalar, U16, 32, "kPa",{1/30}, 0.0 + AFRValue = scalar, U16, 34, "AFR",,{1/1000},, 0.0 + engineLoad = scalar, U16, 36, "%",{1/100}, 0.0 ; Blend of MAP and TPS, depends on algorithm + +; misc sensors + VBatt = scalar, U16, 38, "V",,{1/1000},, 0.0 + oilPressure = scalar, U16, 40, "kPa",{1/30}, 0.0 + vvtPosition = scalar, U16, 42, "deg",{1/50}, 0 + ; 10 bit TPS ADC value (from 0 to 1023 in 5v scale) - tpsADC = scalar, U16, 32, "ADC", 1, 0.0; - tpsADC2 = scalar, U16, 34, "ADC", 1, 0.0; - baroPressure = scalar, F32, 36, "pres", 1, 0.0; - MAPValue = scalar, F32, 40, "MAP", 1, 0.0; - ; total fuel squirt duration (in MS) per engine cycle according to current CLT - crankingFuelMs = scalar, F32, 44, "ms", 1, 0.0; - baseFuel = scalar, F32, 48, "ms", 1, 0 - tCharge = scalar, F32, 52, "T", 1, 0.0; - ignitionAdvance = scalar, F32, 56, "deg", 1, 0.0; - sparkDwellValue = scalar, F32, 60, "ms", 1, 0.0; - ; actual total Ms time per engine cycle with all corrections - actualLastInjection = scalar, F32, 64, "ms", 1, 0.0; - debugFloatField1 = scalar, F32, 68, "val", 1, 0.0; - - hasSdCard = bits, U32, 72, [0:0], "true", "false"; - isIgnitionEnabledIndicator=bits, U32, 72, [1:1], "true", "false"; - ind_injection_enabled=bits,U32, 72, [2:2], "true", "false"; - isCylinderCleanupEnabled=bits, U32, 72, [3:3], "true", "false"; - isCylinderCleanupActivated=bits,U32,72, [4:4], "true", "false"; - ind_fuel_pump = bits, U32, 72, [5:5], "true", "false"; - ind_fan = bits, U32, 72, [6:6], "true", "false"; - ind_o2_heater = bits, U32, 72, [7:7], "true", "false"; - ind_check_engine= bits, U32, 72, [8:8], "true", "false"; - needBurn = bits, U32, 72, [9:9], "true", "false"; - ind_2nd_trigger_en=bits, U32, 72, [10:10], "true", "false"; - clutchUpState =bits, U32, 72, [11:11], "true", "false"; - clutchDownState =bits, U32, 72, [12:12], "true", "false"; - knockEverIndicator=bits, U32, 72, [13:13], "true", "false"; - knockNowIndicator=bits, U32, 72, [14:14], "true", "false"; - brakePedalIndicator=bits, U32, 72, [15:15], "true", "false"; - toothLogReady =bits, U32, 72, [16:16], "true", "false"; - acSwitchIndicator =bits, U32, 72, [17:17], "true", "false"; - vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0; - - ind_tps_error = bits, U32, 80, [0:0], "true", "false"; - ind_clt_error = bits, U32, 80, [1:1], "true", "false"; - ind_map_error = bits, U32, 80, [2:2], "true", "false"; - ind_iat_error = bits, U32, 80, [3:3], "true", "false"; - ind_isTriggerError = bits, U32, 80, [5:5], "true", "false"; - ind_hasFatalError=bits, U32, 80, [6:6], "true", "false"; - ind_isWarnNow =bits, U32, 80, [7:7], "true", "false"; - firmwareTsVersion = scalar,U32, 84, "version_p", 1, 0 - egt1 = scalar, S16, 88, "deg C", 1, 0 - egt2 = scalar, S16, 90, "deg C", 1, 0 - egt3 = scalar, S16, 92, "deg C", 1, 0 - egt4 = scalar, S16, 94, "deg C", 1, 0 - egt5 = scalar, S16, 96, "deg C", 1, 0 - egt6 = scalar, S16, 98, "deg C", 1, 0 - egt7 = scalar, S16, 100, "deg C", 1, 0 - egt8 = scalar, S16, 102, "deg C", 1, 0 - rpmAcceleration = scalar, F32, 104, "dRpm", 1, 0 - massAirFlowValue= scalar, F32, 108, "Kg/h", 1, 0 - veValue = scalar, F32, 112, "ratio", 1, 0 - deltaTps = scalar, F32, 116, "ratio", 1, 0 - triggerErrorsCounter = scalar, U32,120, "counter", 1, 0 - engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0 - tpsAccelFuel = scalar, F32, 128, "ms", 1, 0 - baroCorrection = scalar, F32, 132, "%", 1, 0 - throttlePedalPosition = scalar, F32, 136, "%", 1, 0 - injectorDutyCycle= scalar, F32, 140, "%", 1, 0 - knockCount = scalar, U32, 144, "counter", 1, 0 - fuelTankLevel = scalar, F32, 148, "amount", 1, 0 - knockLevel = scalar, F32, 152, "Volts", 1, 0 - ; totalTriggerErrorCounter 156 - wallFuelAmount = scalar, F32, 160, "ms", 1, 0 - iatCorrection = scalar, F32, 164, "%", 1, 0 - wallFuelCorrection = scalar, F32, 168, "ms", 1, 0 - idleAirValvePosition = scalar, F32, 172, "percent", 1, 0 - currentTargetAfr = scalar, F32, 176, "ratio", 1, 0 - chargeAirMass = scalar, F32, 180, "g", 1, 0 - cltCorrection = scalar, F32, 184, "%", 1, 0 - fuelRunning = scalar, F32, 188, "g", 1, 0 - debugIntField1 = scalar, S32, 192, "val", 1, 0.0; - injectorLagMs = scalar, F32, 196, "ms", 1, 0.0; - debugFloatField2 = scalar, F32, 200, "val", 1, 0.0; - debugFloatField3 = scalar, F32, 204, "val", 1, 0.0; - debugFloatField4 = scalar, F32, 208, "val", 1, 0.0; - debugFloatField5 = scalar, F32, 212, "val", 1, 0.0; - debugIntField2 = scalar, S32, 216, "val", 1, 0.0; - debugIntField3 = scalar, S32, 220, "val", 1, 0.0; - timeSeconds = scalar, U32, 224, "sec", 1, 0.0; - engineLoadDelta = scalar,F32, 228, "value", 1, 0 - speedToRpmRatio = scalar,F32, 232, "value", 1, 0 - warningCounter = scalar,U16, 236, "count", 1, 0 - - lastErrorCode = scalar,U16, 240, "error", 1, 0 - - internalMcuTemperature = scalar,F32, 244, "C", 1, 0 - vvtPosition = scalar,F32, 248, "deg", 1, 0 - engineMode = scalar, U32, 252, "em", 1, 0.0; - debugFloatField6 = scalar, F32, 256, "val", 1, 0.0; - debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; - firmwareVersion = scalar,U32, 264, "version_f", 1, 0 - fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 - coilDutyCycle = scalar, F32, 272, "perc", 1, 0 - accelerationX = scalar, S16, 276, "G", 0.01, 0 - accelerationY = scalar, S16, 278, "G", 0.01, 0 - oilPressure = scalar, F32, 280, "kPa", 1, 0.0 - fuelConsumptionPerHour=scalar, F32, 284, "kPa", 1, 0.0 - injectionOffset = scalar, F32, 288, "deg", 1, 0; - debugIntField4 = scalar, S16, 292, "val", 1, 0.0; - debugIntField5 = scalar, S16, 294, "val", 1, 0.0; - recentErrorCode0 = scalar,U16, 296, "error", 1, 0 - recentErrorCode1 = scalar,U16, 298, "error", 1, 0 - recentErrorCode2 = scalar,U16, 300, "error", 1, 0 - recentErrorCode3 = scalar,U16, 302, "error", 1, 0 - recentErrorCode4 = scalar,U16, 304, "error", 1, 0 - recentErrorCode5 = scalar,U16, 306, "error", 1, 0 - recentErrorCode6 = scalar,U16, 308, "error", 1, 0 - recentErrorCode7 = scalar,U16, 310, "error", 1, 0 - etbTarget = scalar,F32, 312, "%", 1, 0 - etb1DutyCycle = scalar,F32, 316, "%", 1, 0 - etb1Error = scalar,F32, 320, "%", 1, 0 + ;tpsADC2 = scalar, U16, 44, "ADC", 1, 0.0; + +; fuel math + chargeAirMass = scalar, U16, 44, "g",0.001, 0 + crankingFuelMs = scalar, U16, 46, "ms",{1/300}, 0.0 + currentTargetAfr= scalar, U16, 48, "ratio",,{1/1000},, 0 + baseFuel = scalar, U16, 50, "ms",{1/300}, 0 + fuelRunning = scalar, U16, 52, "ms",{1/300}, 0 + actualLastInjection=scalar,U16, 54, "ms",{1/300}, 0.0 + injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0 + veValue = scalar, U08, 57, "ratio", 0.5, 0 + injectionOffset = scalar, S16, 58, "deg",{1/50}, 0 + tCharge = scalar, U16, 60, "deg C",{1/100}, 0.0 + +; Corrections + injectorLagMs = scalar, U16, 62, "ms",{1/300}, 0.0 + iatCorrection = scalar, U16, 64, "%",{1/100}, 0 + cltCorrection = scalar, U16, 66, "%",{1/100}, 0 + baroCorrection = scalar, U16, 68, "%",{1/100}, 0 + fuelPidCorrection=scalar, S16, 70, "ms",{1/300}, 0 + +; Wall model AE + wallFuelAmount = scalar, U16, 72, "ms",{1/300}, 0 + wallFuelCorrection=scalar, S16, 74, "ms",0.001, 0 + +; TPS/load AE + engineLoadDelta = scalar, S16, 76, "value",{1/100}, 0 + deltaTps = scalar, S16, 78, "ratio",{1/100}, 0 + engineLoadAccelExtra=scalar,S16, 80, "value",{1/100}, 0 + tpsAccelFuel = scalar, U16, 82, "ms",{1/300}, 0 + +; Ignition + ignitionAdvance = scalar, U16, 84, "deg",{1/50}, 0.0 + sparkDwellValue = scalar, U16, 86, "ms",{1/300}, 0.0 + coilDutyCycle = scalar, U16, 88, "%",{1/100}, 0 + +; Idle & ETB + idleAirValvePosition=scalar,S16, 90, "%",{1/100}, 0 + etbTarget = scalar, S16, 92, "%",{1/100}, 0 + etb1DutyCycle = scalar, S16, 94, "%",{1/100}, 0 + etb1Error = scalar, S16, 96, "%",{1/100}, 0 + +; Fuel system + fuelTankLevel = scalar, S16, 98, "amount",{1/100}, 0 + fuelConsumptionPerHour=scalar,F32, 100, "kPa", 1, 0.0 + +; Knock + knockCount = scalar, U32, 104,"counter", 1, 0 + knockLevel = scalar, F32, 108, "Volts", 1, 0 + +; Mode, firmware, protocol, run time + timeSeconds = scalar, U32, 112, "sec", 1, 0.0 + engineMode = scalar, U32, 116, "em", 1, 0.0; + firmwareVersion = scalar, U32, 120,"version_f", 1, 0 + firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0 + +; Errors + totalTriggerErrorCounter=scalar,U32, 128,"counter", 1, 0 + ; orderingErrorCounter 132 + warningCounter = scalar, U16, 136, "count", 1, 0 + lastErrorCode = scalar, U16, 138, "error", 1, 0 + recentErrorCode0= scalar, U16, 140, "error", 1, 0 + recentErrorCode1= scalar, U16, 142, "error", 1, 0 + recentErrorCode2= scalar, U16, 144, "error", 1, 0 + recentErrorCode3= scalar, U16, 146, "error", 1, 0 + recentErrorCode4= scalar, U16, 148, "error", 1, 0 + recentErrorCode5= scalar, U16, 150, "error", 1, 0 + recentErrorCode6= scalar, U16, 152, "error", 1, 0 + recentErrorCode7= scalar, U16, 154, "error", 1, 0 + +; Debug + debugFloatField1= scalar, F32, 156, "val", 1, 0.0 + debugFloatField2= scalar, F32, 160, "val", 1, 0.0 + debugFloatField3= scalar, F32, 164, "val", 1, 0.0 + debugFloatField4= scalar, F32, 168, "val", 1, 0.0 + debugFloatField5= scalar, F32, 172, "val", 1, 0.0 + debugFloatField6= scalar, F32, 176, "val", 1, 0.0 + debugFloatField7= scalar, F32, 180, "val", 1, 0.0 + debugIntField1 = scalar, S32, 184, "val", 1, 0.0 + debugIntField2 = scalar, S32, 188, "val", 1, 0.0 + debugIntField3 = scalar, S32, 192, "val", 1, 0.0 + debugIntField4 = scalar, S16, 196, "val", 1, 0.0 + debugIntField5 = scalar, S16, 198, "val", 1, 0.0 + +; Accel + accelerationX = scalar, S16, 200, "G", 0.01, 0 + accelerationY = scalar, S16, 202, "G", 0.01, 0 + +; egt + egt1 = scalar, S16, 204, "deg C", 1, 0 + egt2 = scalar, S16, 206, "deg C", 1, 0 + egt3 = scalar, S16, 208, "deg C", 1, 0 + egt4 = scalar, S16, 210, "deg C", 1, 0 + egt5 = scalar, S16, 212, "deg C", 1, 0 + egt6 = scalar, S16, 214, "deg C", 1, 0 + egt7 = scalar, S16, 216, "deg C", 1, 0 + egt8 = scalar, S16, 218, "deg C", 1, 0 ; @@ -1344,6 +1439,10 @@ fileVersion = { 20190701 } wueAfrTargetOffset = array, S16, [ 16], ":1", 0.1, 0.0, -3.0, 3.0, 1; wueAnalRecommend = array, U08, [ 16], "%", 1.00, 0.0, 100, 255.00, 0 +; These are inverted (false = "Yes") so that they default to enabled + enableLogDebugChannels = bits, U08, [0:0], "Yes", "No" + enableLogErrorList = bits, U08, [0:0], "Yes", "No" + [ConstantsExtensions] defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 @@ -1792,7 +1891,7 @@ gaugeCategory = Sensors - Extra 2 gaugeCategory = ECU Status warningCounterGauge = warningCounter, "Warning count", "", 0, 100, 0, 0, 100, 100, 0, 0 lastErrorCodeGauge = lastErrorCode, "Last error", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 - triggerErrorsCounterGauge = triggerErrorsCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 + triggerErrorsCounterGauge = totalTriggerErrorCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 recentErrorCode0Gauge = recentErrorCode0, "Error#1", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode1Gauge = recentErrorCode1, "Error#2", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode2Gauge = recentErrorCode2, "Error#3", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 @@ -1990,7 +2089,7 @@ gaugeCategory = Throttle Body (incl. ETB) entry = massAirFlowValue,"air flow", float, "%.3f" entry = chargeAirMass, "air mass", float, "%.3f" entry = throttlePedalPosition, "Throttle pedal position", float, "%.3f" - entry = triggerErrorsCounter, "trg err",int, "%d" + entry = totalTriggerErrorCounter, "trg err",int, "%d" entry = idleAirValvePosition, "Idle Air Valve", float, "%.3f" @@ -2004,16 +2103,16 @@ gaugeCategory = Throttle Body (incl. ETB) entry = coilDutyCycle, "dwell: coil duty cycle", float,"%.3f" entry = currentTargetAfr,"fuel: target AFR", float,"%.3f" - entry = accelerationX, "Acceleration: X", float,"%.2f" - entry = accelerationY, "Acceleration: Y", float,"%.2f" - entry = egt1, "EGT1", float,"%.1f" - entry = egt2, "EGT2", float,"%.1f" - entry = egt3, "EGT3", float,"%.1f" - entry = egt4, "EGT4", float,"%.1f" - entry = egt5, "EGT5", float,"%.1f" - entry = egt6, "EGT6", float,"%.1f" - entry = egt7, "EGT7", float,"%.1f" - entry = egt8, "EGT8", float,"%.1f" + entry = accelerationX, "Acceleration: X", float,"%.2f", { LIS302DLCsPin != 0 } + entry = accelerationY, "Acceleration: Y", float,"%.2f", { LIS302DLCsPin != 0 } + entry = egt1, "EGT1", float,"%.1f", { max31855_cs1 != 0} + entry = egt2, "EGT2", float,"%.1f", { max31855_cs2 != 0} + entry = egt3, "EGT3", float,"%.1f", { max31855_cs3 != 0} + entry = egt4, "EGT4", float,"%.1f", { max31855_cs4 != 0} + entry = egt5, "EGT5", float,"%.1f", { max31855_cs5 != 0} + entry = egt6, "EGT6", float,"%.1f", { max31855_cs6 != 0} + entry = egt7, "EGT7", float,"%.1f", { max31855_cs7 != 0} + entry = egt8, "EGT8", float,"%.1f", { max31855_cs8 != 0} entry = engineLoadAccelExtra, "fuel: engine load acceleration extra fuel",float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f" @@ -2035,54 +2134,54 @@ gaugeCategory = Throttle Body (incl. ETB) ; is there a way to log parameter? entry = debugMode, "debugMode",int,"%d" ; Alternator_PID: alternator duty cycle ; DBG_TPS_ACCEL: from TPS - entry = debugFloatField1, "debug f1",float,"%.4f" + entry = debugFloatField1, "debug f1",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: current integration term ; DBG_TPS_ACCEL: to TPS - entry = debugFloatField2, "debug f2: iTerm",float,"%.4f" + entry = debugFloatField2, "debug f2: iTerm",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: previous error ; DBG_TPS_ACCEL: tps<>tps table value - entry = debugFloatField3, "debug f3: prevError",float,"%.4f" + entry = debugFloatField3, "debug f3: prevError",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: I setting ; DBG_TPS_ACCEL: extra fuel - entry = debugFloatField4, "debug f4: iParam",float,"%.4f" + entry = debugFloatField4, "debug f4: iParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: D setting - entry = debugFloatField5, "debug f5: dParam",float,"%.4f" + entry = debugFloatField5, "debug f5: dParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: dTerm - entry = debugFloatField6, "debug f6: dTerm",float,"%.4f" + entry = debugFloatField6, "debug f6: dTerm",float,"%.4f", { !enableLogDebugChannels } - entry = debugFloatField7, "debug f7",float,"%.4f" + entry = debugFloatField7, "debug f7",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: P setting - entry = debugIntField1, "debug i1: pParam",int,"%d" + entry = debugIntField1, "debug i1: pParam",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: offset setting - entry = debugIntField2, "debug i2: offset",int,"%d" + entry = debugIntField2, "debug i2: offset",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: PID reset counter - entry = debugIntField3, "debug i3",int,"%d" + entry = debugIntField3, "debug i3",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField4, "debug i4",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField5, "debug i5",int,"%d", { !enableLogDebugChannels } - entry = debugIntField4, "debug i4",int,"%d" - entry = debugIntField5, "debug i5",int,"%d" - - entry = engineMode, "Engine Mode",int,"%d" entry = warningCounter, "warning: counter",int,"%d" entry = lastErrorCode, "warning: last",int,"%d" - entry = recentErrorCode0, "error 0",int,"%d" - entry = recentErrorCode1, "error 1",int,"%d" - entry = recentErrorCode2, "error 2",int,"%d" - entry = recentErrorCode3, "error 3",int,"%d" - entry = recentErrorCode4, "error 4",int,"%d" - entry = recentErrorCode5, "error 5",int,"%d" - entry = recentErrorCode6, "error 6",int,"%d" - entry = recentErrorCode7, "error 7",int,"%d" + entry = recentErrorCode0, "error 0",int,"%d", { !enableLogErrorList } + entry = recentErrorCode1, "error 1",int,"%d", { !enableLogErrorList } + entry = recentErrorCode2, "error 2",int,"%d", { !enableLogErrorList } + entry = recentErrorCode3, "error 3",int,"%d", { !enableLogErrorList } + entry = recentErrorCode4, "error 4",int,"%d", { !enableLogErrorList } + entry = recentErrorCode5, "error 5",int,"%d", { !enableLogErrorList } + entry = recentErrorCode6, "error 6",int,"%d", { !enableLogErrorList } + entry = recentErrorCode7, "error 7",int,"%d", { !enableLogErrorList } entry = internalMcuTemperature, "CPU Temperature",float,"%.2f" entry = tCharge, "tCharge",float,"%.3f" @@ -2258,6 +2357,7 @@ menuDialog = main menu = "&Controller" subMenu = ecuStimulator, "ECU stimulator" + subMenu = datalogSettings, "Datalogging" subMenu = ioTest, "Bench test" subMenu = engineTypeDialog, "Popular vehicles" subMenu = std_separator @@ -2629,6 +2729,10 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" panel = triggerInputComparator dialog = allPinsSensors, "Sensors" + field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel + field = "Primary input channel", triggerInputPins1 + field = "Secondary channel", triggerInputPins2 + field = "Cam Sync/VVT input", camInputs1 field = "CLT ADC input", clt_adcChannel field = "IAT ADC input", iat_adcChannel field = "vBatt ADC input", vbattAdcChannel @@ -2662,10 +2766,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "mc33972_cs", mc33972_cs field = "mc33972 SPI", mc33972spiDevice panel = allPinsSensors - field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel - field = "Primary input channel", triggerInputPins1 - field = "Secondary channel", triggerInputPins2 - field = "Cam Sync/VVT input", camInputs1 dialog = allPins1_2 field = "Tachometer output Pin", tachOutputPin @@ -2678,13 +2778,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "Idle Stepper Enable", stepperEnablePin field = "Fuel Pump Pin", fuelPumpPin field = "Fuel Pump Pin Mode", fuelPumpPinMode - field = "ETB#1 Dir #1", etb1_directionPin1 - field = "ETB#1 Dir #2", etb1_directionPin2 - field = "ETB#1 Control #1", etb1_controlPin1 - field = "etb1_controlPinMode", etb1_controlPinMode - field = "ETB#2 Dir #1", etb2_directionPin1 - field = "ETB#2 Dir #2", etb2_directionPin2 - field = "ETB#2 Control #1", etb2_controlPin1 + field = "ETB#1 Dir #1", etbIo1_directionPin1 + field = "ETB#1 Dir #2", etbIo1_directionPin2 + field = "ETB#1 Control #1", etbIo1_controlPin1 + field = "etb1_controlPinMode", etbIo1_controlPinMode + field = "ETB#2 Dir #1", etbIo2_directionPin1 + field = "ETB#2 Dir #2", etbIo2_directionPin2 + field = "ETB#2 Control #1", etbIo2_controlPin1 field = "SD CS Pin", sdCardCsPin field = "MIL / Check Engine Pin", malfunctionIndicatorPin field = "MIL / Check Engine Pin Mode", malfunctionIndicatorPinMode @@ -3531,7 +3631,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "No1 Control #1", etbIo1_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "No2 Direction #1", etbIo2_directionPin1, {throttlePedalPositionAdcChannel != 16} field = "No2 Direction #2", etbIo2_directionPin2, {throttlePedalPositionAdcChannel != 16} - field = "No2 Control #1", etb2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} + field = "No2 Control #1", etbIo2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "TPS#2 min", tps2Min, {etbIo2_directionPin1 != 0} field = "TPS#2 max", tps2Max, {etbIo2_directionPin1 != 0} panel = etbPidDialog @@ -3632,6 +3732,11 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "" field = "Engine chart size", engineChartSize + dialog = datalogSettings, "Datalogging Settings" + field = "#Disabling optional logging may increase update rate!" + field = "Log debug channels", enableLogDebugChannels + field = "Log recent errors list", enableLogErrorList + ; Racing Features->Launch Control dialog = smLaunchControl, "Launch Control Settings NOT WORKING" field = "RPM Step1 Limit", step1rpm diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index db5f327758..3d13165c6b 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -156,147 +156,182 @@ enable2ndByteCanID = false [OutputChannels] -; see TS_FILE_VERSION in firmware code -fileVersion = { 20190701 } +fileVersion = { @@TS_FILE_VERSION@@ } ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 356 + ochBlockSize = @@TS_OUTPUT_SIZE@@ ; ; see TunerStudioOutputChannels struct ; - RPMValue = scalar, U32, 0, "RPM", 1, 0.00000 + +; Bit flags + hasSdCard = bits, U32, 0, [0:0], "true", "false"; + isIgnitionEnabledIndicator=bits,U32, 0, [1:1], "true", "false"; + ind_injection_enabled=bits,U32, 0, [2:2], "true", "false"; + isCylinderCleanupEnabled=bits,U32, 0, [3:3], "true", "false"; + isCylinderCleanupActivated=bits,U32, 0, [4:4], "true", "false"; + ind_fuel_pump = bits, U32, 0, [5:5], "true", "false"; + ind_fan = bits, U32, 0, [6:6], "true", "false"; + ind_o2_heater = bits, U32, 0, [7:7], "true", "false"; + ind_check_engine= bits, U32, 0, [8:8], "true", "false"; + needBurn = bits, U32, 0, [9:9], "true", "false"; + ind_2nd_trigger_en=bits, U32, 0, [10:10], "true", "false"; + clutchUpState =bits, U32, 0, [11:11], "true", "false"; + clutchDownState =bits, U32, 0, [12:12], "true", "false"; + knockEverIndicator=bits, U32, 0, [13:13], "true", "false"; + knockNowIndicator=bits, U32, 0, [14:14], "true", "false"; + brakePedalIndicator=bits, U32, 0, [15:15], "true", "false"; + toothLogReady =bits, U32, 0, [16:16], "true", "false"; + acSwitchIndicator =bits, U32, 0, [17:17], "true", "false"; + ind_tps_error = bits, U32, 0, [18:18], "true", "false"; + ind_clt_error = bits, U32, 0, [19:19], "true", "false"; + ind_map_error = bits, U32, 0, [20:21], "true", "false"; + ind_iat_error = bits, U32, 0, [21:22], "true", "false"; + ind_isTriggerError = bits, U32, 0, [23:23], "true", "false"; + ind_hasFatalError=bits, U32, 0, [24:24], "true", "false"; + ind_isWarnNow =bits, U32, 0, [25:25], "true", "false"; + +; RPM, vss + RPMValue = scalar, U16, 4, "RPM", 1, 0.00000 + rpmAcceleration = scalar, S16, 6, "dRpm",{1/@@PACK_MULT_PERCENT@@}, 0 + speedToRpmRatio = scalar, S16, 8, "value",{1/@@PACK_MULT_PERCENT@@}, 0 + vehicleSpeedKph = scalar, U08, 10, "kph", 1, 0.0 + +; temperatures + internalMcuTemperature = scalar,S08, 11, "deg C", 1, 0 #if CELSIUS - coolant = scalar, F32, 4, "deg C", 1, 0.0 + coolant = scalar, S16, 12, "deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0.0 #else - coolant = scalar, F32, 4, "deg F", {9/5}, 17.77777 + coolant = scalar, S16, 12, "deg F",{9/(5 * @@PACK_MULT_TEMPERATURE@@)}, 17.77777 #endif #if CELSIUS - intake = scalar, F32, 8, "deg C", 1, 0.0 + intake = scalar, S16, 14, "deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0.0 #else - intake = scalar, F32, 8, "deg F", {9/5}, 17.77777 + intake = scalar, S16, 14, "deg F",{9/(5 * @@PACK_MULT_TEMPERATURE@@)}, 17.77777 #endif - TPSValue = scalar, F32, 12, "%", 1, 0 - MAFValue = scalar, F32, 16, "V", 1, 0 - AFRValue = scalar, F32, 20, "AFR", 1, 0.0 - engineLoad = scalar, F32, 24, "%", 1, 0.0 ; Blend of MAP and TPS, depends on algorithm - VBatt = scalar, F32, 28, "V", 1, 0.0 +; todo: aux1 +; todo: aux2 + + +; throttle, pedal + TPSValue = scalar, U16, 20, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + throttlePedalPosition = scalar,U16, 22, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + tpsADC = scalar, U16, 24, "ADC", 1, 0.0; + +; air flow/mass measurments + MAFValue = scalar, U16, 26, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0 + massAirFlowValue= scalar, U16, 28, "Kg/h", 0.01, 0 + MAPValue = scalar, U16, 30, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0 + baroPressure = scalar, U16, 32, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0 + AFRValue = scalar, U16, 34, "AFR",,{1/@@PACK_MULT_AFR@@},, 0.0 + engineLoad = scalar, U16, 36, "%",{1/@@PACK_MULT_PERCENT@@}, 0.0 ; Blend of MAP and TPS, depends on algorithm + +; misc sensors + VBatt = scalar, U16, 38, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0.0 + oilPressure = scalar, U16, 40, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0 + vvtPosition = scalar, U16, 42, "deg",{1/@@PACK_MULT_ANGLE@@}, 0 + ; 10 bit TPS ADC value (from 0 to 1023 in 5v scale) - tpsADC = scalar, U16, 32, "ADC", 1, 0.0; - tpsADC2 = scalar, U16, 34, "ADC", 1, 0.0; - baroPressure = scalar, F32, 36, "pres", 1, 0.0; - MAPValue = scalar, F32, 40, "MAP", 1, 0.0; - ; total fuel squirt duration (in MS) per engine cycle according to current CLT - crankingFuelMs = scalar, F32, 44, "ms", 1, 0.0; - baseFuel = scalar, F32, 48, "ms", 1, 0 - tCharge = scalar, F32, 52, "T", 1, 0.0; - ignitionAdvance = scalar, F32, 56, "deg", 1, 0.0; - sparkDwellValue = scalar, F32, 60, "ms", 1, 0.0; - ; actual total Ms time per engine cycle with all corrections - actualLastInjection = scalar, F32, 64, "ms", 1, 0.0; - debugFloatField1 = scalar, F32, 68, "val", 1, 0.0; - - hasSdCard = bits, U32, 72, [0:0], "true", "false"; - isIgnitionEnabledIndicator=bits, U32, 72, [1:1], "true", "false"; - ind_injection_enabled=bits,U32, 72, [2:2], "true", "false"; - isCylinderCleanupEnabled=bits, U32, 72, [3:3], "true", "false"; - isCylinderCleanupActivated=bits,U32,72, [4:4], "true", "false"; - ind_fuel_pump = bits, U32, 72, [5:5], "true", "false"; - ind_fan = bits, U32, 72, [6:6], "true", "false"; - ind_o2_heater = bits, U32, 72, [7:7], "true", "false"; - ind_check_engine= bits, U32, 72, [8:8], "true", "false"; - needBurn = bits, U32, 72, [9:9], "true", "false"; - ind_2nd_trigger_en=bits, U32, 72, [10:10], "true", "false"; - clutchUpState =bits, U32, 72, [11:11], "true", "false"; - clutchDownState =bits, U32, 72, [12:12], "true", "false"; - knockEverIndicator=bits, U32, 72, [13:13], "true", "false"; - knockNowIndicator=bits, U32, 72, [14:14], "true", "false"; - brakePedalIndicator=bits, U32, 72, [15:15], "true", "false"; - toothLogReady =bits, U32, 72, [16:16], "true", "false"; - acSwitchIndicator =bits, U32, 72, [17:17], "true", "false"; - vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0; - - ind_tps_error = bits, U32, 80, [0:0], "true", "false"; - ind_clt_error = bits, U32, 80, [1:1], "true", "false"; - ind_map_error = bits, U32, 80, [2:2], "true", "false"; - ind_iat_error = bits, U32, 80, [3:3], "true", "false"; - ind_isTriggerError = bits, U32, 80, [5:5], "true", "false"; - ind_hasFatalError=bits, U32, 80, [6:6], "true", "false"; - ind_isWarnNow =bits, U32, 80, [7:7], "true", "false"; - firmwareTsVersion = scalar,U32, 84, "version_p", 1, 0 - egt1 = scalar, S16, 88, "deg C", 1, 0 - egt2 = scalar, S16, 90, "deg C", 1, 0 - egt3 = scalar, S16, 92, "deg C", 1, 0 - egt4 = scalar, S16, 94, "deg C", 1, 0 - egt5 = scalar, S16, 96, "deg C", 1, 0 - egt6 = scalar, S16, 98, "deg C", 1, 0 - egt7 = scalar, S16, 100, "deg C", 1, 0 - egt8 = scalar, S16, 102, "deg C", 1, 0 - rpmAcceleration = scalar, F32, 104, "dRpm", 1, 0 - massAirFlowValue= scalar, F32, 108, "Kg/h", 1, 0 - veValue = scalar, F32, 112, "ratio", 1, 0 - deltaTps = scalar, F32, 116, "ratio", 1, 0 - triggerErrorsCounter = scalar, U32,120, "counter", 1, 0 - engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0 - tpsAccelFuel = scalar, F32, 128, "ms", 1, 0 - baroCorrection = scalar, F32, 132, "%", 1, 0 - throttlePedalPosition = scalar, F32, 136, "%", 1, 0 - injectorDutyCycle= scalar, F32, 140, "%", 1, 0 - knockCount = scalar, U32, 144, "counter", 1, 0 - fuelTankLevel = scalar, F32, 148, "amount", 1, 0 - knockLevel = scalar, F32, 152, "Volts", 1, 0 - ; totalTriggerErrorCounter 156 - wallFuelAmount = scalar, F32, 160, "ms", 1, 0 - iatCorrection = scalar, F32, 164, "%", 1, 0 - wallFuelCorrection = scalar, F32, 168, "ms", 1, 0 - idleAirValvePosition = scalar, F32, 172, "percent", 1, 0 - currentTargetAfr = scalar, F32, 176, "ratio", 1, 0 - chargeAirMass = scalar, F32, 180, "g", 1, 0 - cltCorrection = scalar, F32, 184, "%", 1, 0 - fuelRunning = scalar, F32, 188, "g", 1, 0 - debugIntField1 = scalar, S32, 192, "val", 1, 0.0; - injectorLagMs = scalar, F32, 196, "ms", 1, 0.0; - debugFloatField2 = scalar, F32, 200, "val", 1, 0.0; - debugFloatField3 = scalar, F32, 204, "val", 1, 0.0; - debugFloatField4 = scalar, F32, 208, "val", 1, 0.0; - debugFloatField5 = scalar, F32, 212, "val", 1, 0.0; - debugIntField2 = scalar, S32, 216, "val", 1, 0.0; - debugIntField3 = scalar, S32, 220, "val", 1, 0.0; - timeSeconds = scalar, U32, 224, "sec", 1, 0.0; - engineLoadDelta = scalar,F32, 228, "value", 1, 0 - speedToRpmRatio = scalar,F32, 232, "value", 1, 0 - warningCounter = scalar,U16, 236, "count", 1, 0 - - lastErrorCode = scalar,U16, 240, "error", 1, 0 - - internalMcuTemperature = scalar,F32, 244, "C", 1, 0 - vvtPosition = scalar,F32, 248, "deg", 1, 0 - engineMode = scalar, U32, 252, "em", 1, 0.0; - debugFloatField6 = scalar, F32, 256, "val", 1, 0.0; - debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; - firmwareVersion = scalar,U32, 264, "version_f", 1, 0 - fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 - coilDutyCycle = scalar, F32, 272, "perc", 1, 0 - accelerationX = scalar, S16, 276, "G", 0.01, 0 - accelerationY = scalar, S16, 278, "G", 0.01, 0 - oilPressure = scalar, F32, 280, "kPa", 1, 0.0 - fuelConsumptionPerHour=scalar, F32, 284, "kPa", 1, 0.0 - injectionOffset = scalar, F32, 288, "deg", 1, 0; - debugIntField4 = scalar, S16, 292, "val", 1, 0.0; - debugIntField5 = scalar, S16, 294, "val", 1, 0.0; - recentErrorCode0 = scalar,U16, 296, "error", 1, 0 - recentErrorCode1 = scalar,U16, 298, "error", 1, 0 - recentErrorCode2 = scalar,U16, 300, "error", 1, 0 - recentErrorCode3 = scalar,U16, 302, "error", 1, 0 - recentErrorCode4 = scalar,U16, 304, "error", 1, 0 - recentErrorCode5 = scalar,U16, 306, "error", 1, 0 - recentErrorCode6 = scalar,U16, 308, "error", 1, 0 - recentErrorCode7 = scalar,U16, 310, "error", 1, 0 - etbTarget = scalar,F32, 312, "%", 1, 0 - etb1DutyCycle = scalar,F32, 316, "%", 1, 0 - etb1Error = scalar,F32, 320, "%", 1, 0 + ;tpsADC2 = scalar, U16, 44, "ADC", 1, 0.0; + +; fuel math + chargeAirMass = scalar, U16, 44, "g",0.001, 0 + crankingFuelMs = scalar, U16, 46, "ms",{1/@@PACK_MULT_MS@@}, 0.0 + currentTargetAfr= scalar, U16, 48, "ratio",,{1/@@PACK_MULT_AFR@@},, 0 + baseFuel = scalar, U16, 50, "ms",{1/@@PACK_MULT_MS@@}, 0 + fuelRunning = scalar, U16, 52, "ms",{1/@@PACK_MULT_MS@@}, 0 + actualLastInjection=scalar,U16, 54, "ms",{1/@@PACK_MULT_MS@@}, 0.0 + injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0 + veValue = scalar, U08, 57, "ratio", 0.5, 0 + injectionOffset = scalar, S16, 58, "deg",{1/@@PACK_MULT_ANGLE@@}, 0 + tCharge = scalar, U16, 60, "deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0.0 + +; Corrections + injectorLagMs = scalar, U16, 62, "ms",{1/@@PACK_MULT_MS@@}, 0.0 + iatCorrection = scalar, U16, 64, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + cltCorrection = scalar, U16, 66, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + baroCorrection = scalar, U16, 68, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + fuelPidCorrection=scalar, S16, 70, "ms",{1/@@PACK_MULT_MS@@}, 0 + +; Wall model AE + wallFuelAmount = scalar, U16, 72, "ms",{1/@@PACK_MULT_MS@@}, 0 + wallFuelCorrection=scalar, S16, 74, "ms",0.001, 0 + +; TPS/load AE + engineLoadDelta = scalar, S16, 76, "value",{1/@@PACK_MULT_PERCENT@@}, 0 + deltaTps = scalar, S16, 78, "ratio",{1/@@PACK_MULT_PERCENT@@}, 0 + engineLoadAccelExtra=scalar,S16, 80, "value",{1/@@PACK_MULT_PERCENT@@}, 0 + tpsAccelFuel = scalar, U16, 82, "ms",{1/@@PACK_MULT_MS@@}, 0 + +; Ignition + ignitionAdvance = scalar, U16, 84, "deg",{1/@@PACK_MULT_ANGLE@@}, 0.0 + sparkDwellValue = scalar, U16, 86, "ms",{1/@@PACK_MULT_MS@@}, 0.0 + coilDutyCycle = scalar, U16, 88, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + +; Idle & ETB + idleAirValvePosition=scalar,S16, 90, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + etbTarget = scalar, S16, 92, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + etb1DutyCycle = scalar, S16, 94, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + etb1Error = scalar, S16, 96, "%",{1/@@PACK_MULT_PERCENT@@}, 0 + +; Fuel system + fuelTankLevel = scalar, S16, 98, "amount",{1/@@PACK_MULT_PERCENT@@}, 0 + fuelConsumptionPerHour=scalar,F32, 100, "kPa", 1, 0.0 + +; Knock + knockCount = scalar, U32, 104,"counter", 1, 0 + knockLevel = scalar, F32, 108, "Volts", 1, 0 + +; Mode, firmware, protocol, run time + timeSeconds = scalar, U32, 112, "sec", 1, 0.0 + engineMode = scalar, U32, 116, "em", 1, 0.0; + firmwareVersion = scalar, U32, 120,"version_f", 1, 0 + firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0 + +; Errors + totalTriggerErrorCounter=scalar,U32, 128,"counter", 1, 0 + ; orderingErrorCounter 132 + warningCounter = scalar, U16, 136, "count", 1, 0 + lastErrorCode = scalar, U16, 138, "error", 1, 0 + recentErrorCode0= scalar, U16, 140, "error", 1, 0 + recentErrorCode1= scalar, U16, 142, "error", 1, 0 + recentErrorCode2= scalar, U16, 144, "error", 1, 0 + recentErrorCode3= scalar, U16, 146, "error", 1, 0 + recentErrorCode4= scalar, U16, 148, "error", 1, 0 + recentErrorCode5= scalar, U16, 150, "error", 1, 0 + recentErrorCode6= scalar, U16, 152, "error", 1, 0 + recentErrorCode7= scalar, U16, 154, "error", 1, 0 + +; Debug + debugFloatField1= scalar, F32, 156, "val", 1, 0.0 + debugFloatField2= scalar, F32, 160, "val", 1, 0.0 + debugFloatField3= scalar, F32, 164, "val", 1, 0.0 + debugFloatField4= scalar, F32, 168, "val", 1, 0.0 + debugFloatField5= scalar, F32, 172, "val", 1, 0.0 + debugFloatField6= scalar, F32, 176, "val", 1, 0.0 + debugFloatField7= scalar, F32, 180, "val", 1, 0.0 + debugIntField1 = scalar, S32, 184, "val", 1, 0.0 + debugIntField2 = scalar, S32, 188, "val", 1, 0.0 + debugIntField3 = scalar, S32, 192, "val", 1, 0.0 + debugIntField4 = scalar, S16, 196, "val", 1, 0.0 + debugIntField5 = scalar, S16, 198, "val", 1, 0.0 + +; Accel + accelerationX = scalar, S16, 200, "G", 0.01, 0 + accelerationY = scalar, S16, 202, "G", 0.01, 0 + +; egt + egt1 = scalar, S16, 204, "deg C", 1, 0 + egt2 = scalar, S16, 206, "deg C", 1, 0 + egt3 = scalar, S16, 208, "deg C", 1, 0 + egt4 = scalar, S16, 210, "deg C", 1, 0 + egt5 = scalar, S16, 212, "deg C", 1, 0 + egt6 = scalar, S16, 214, "deg C", 1, 0 + egt7 = scalar, S16, 216, "deg C", 1, 0 + egt8 = scalar, S16, 218, "deg C", 1, 0 ; @@ -318,6 +353,10 @@ fileVersion = { 20190701 } wueAfrTargetOffset = array, S16, [ 16], ":1", 0.1, 0.0, -3.0, 3.0, 1; wueAnalRecommend = array, U08, [ 16], "%", 1.00, 0.0, 100, 255.00, 0 +; These are inverted (false = "Yes") so that they default to enabled + enableLogDebugChannels = bits, U08, [0:0], "Yes", "No" + enableLogErrorList = bits, U08, [0:0], "Yes", "No" + [ConstantsExtensions] defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 @@ -766,7 +805,7 @@ gaugeCategory = Sensors - Extra 2 gaugeCategory = ECU Status warningCounterGauge = warningCounter, "Warning count", "", 0, 100, 0, 0, 100, 100, 0, 0 lastErrorCodeGauge = lastErrorCode, "Last error", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 - triggerErrorsCounterGauge = triggerErrorsCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 + triggerErrorsCounterGauge = totalTriggerErrorCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 recentErrorCode0Gauge = recentErrorCode0, "Error#1", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode1Gauge = recentErrorCode1, "Error#2", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode2Gauge = recentErrorCode2, "Error#3", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 @@ -964,7 +1003,7 @@ gaugeCategory = Throttle Body (incl. ETB) entry = massAirFlowValue,@@GAUGE_NAME_AIR_FLOW@@, float, "%.3f" entry = chargeAirMass, @@GAUGE_NAME_AIR_MASS@@, float, "%.3f" entry = throttlePedalPosition, @@GAUGE_NAME_THROTTLE_PEDAL@@, float, "%.3f" - entry = triggerErrorsCounter, "trg err",int, "%d" + entry = totalTriggerErrorCounter, "trg err",int, "%d" entry = idleAirValvePosition, @@GAUGE_NAME_IAC@@, float, "%.3f" @@ -978,16 +1017,16 @@ gaugeCategory = Throttle Body (incl. ETB) entry = coilDutyCycle, @@GAUGE_NAME_DWELL_DUTY@@, float,"%.3f" entry = currentTargetAfr,@@GAUGE_NAME_TARGET_AFR@@, float,"%.3f" - entry = accelerationX, @@GAUGE_NAME_ACCEL_X@@, float,"%.2f" - entry = accelerationY, @@GAUGE_NAME_ACCEL_Y@@, float,"%.2f" - entry = egt1, "EGT1", float,"%.1f" - entry = egt2, "EGT2", float,"%.1f" - entry = egt3, "EGT3", float,"%.1f" - entry = egt4, "EGT4", float,"%.1f" - entry = egt5, "EGT5", float,"%.1f" - entry = egt6, "EGT6", float,"%.1f" - entry = egt7, "EGT7", float,"%.1f" - entry = egt8, "EGT8", float,"%.1f" + entry = accelerationX, @@GAUGE_NAME_ACCEL_X@@, float,"%.2f", { LIS302DLCsPin != 0 } + entry = accelerationY, @@GAUGE_NAME_ACCEL_Y@@, float,"%.2f", { LIS302DLCsPin != 0 } + entry = egt1, "EGT1", float,"%.1f", { max31855_cs1 != 0} + entry = egt2, "EGT2", float,"%.1f", { max31855_cs2 != 0} + entry = egt3, "EGT3", float,"%.1f", { max31855_cs3 != 0} + entry = egt4, "EGT4", float,"%.1f", { max31855_cs4 != 0} + entry = egt5, "EGT5", float,"%.1f", { max31855_cs5 != 0} + entry = egt6, "EGT6", float,"%.1f", { max31855_cs6 != 0} + entry = egt7, "EGT7", float,"%.1f", { max31855_cs7 != 0} + entry = egt8, "EGT8", float,"%.1f", { max31855_cs8 != 0} entry = engineLoadAccelExtra, @@GAUGE_NAME_FUEL_EL_EXTRA@@,float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f" @@ -1009,54 +1048,54 @@ gaugeCategory = Throttle Body (incl. ETB) ; is there a way to log parameter? entry = debugMode, "debugMode",int,"%d" ; Alternator_PID: alternator duty cycle ; DBG_TPS_ACCEL: from TPS - entry = debugFloatField1, @@GAUGE_NAME_DEBUG_F1@@,float,"%.4f" + entry = debugFloatField1, @@GAUGE_NAME_DEBUG_F1@@,float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: current integration term ; DBG_TPS_ACCEL: to TPS - entry = debugFloatField2, @@GAUGE_NAME_DEBUG_F2@@,float,"%.4f" + entry = debugFloatField2, @@GAUGE_NAME_DEBUG_F2@@,float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: previous error ; DBG_TPS_ACCEL: tps<>tps table value - entry = debugFloatField3, @@GAUGE_NAME_DEBUG_F3@@,float,"%.4f" + entry = debugFloatField3, @@GAUGE_NAME_DEBUG_F3@@,float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: I setting ; DBG_TPS_ACCEL: extra fuel - entry = debugFloatField4, @@GAUGE_NAME_DEBUG_F4@@,float,"%.4f" + entry = debugFloatField4, @@GAUGE_NAME_DEBUG_F4@@,float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: D setting - entry = debugFloatField5, @@GAUGE_NAME_DEBUG_F5@@,float,"%.4f" + entry = debugFloatField5, @@GAUGE_NAME_DEBUG_F5@@,float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: dTerm - entry = debugFloatField6, @@GAUGE_NAME_DEBUG_F6@@,float,"%.4f" + entry = debugFloatField6, @@GAUGE_NAME_DEBUG_F6@@,float,"%.4f", { !enableLogDebugChannels } - entry = debugFloatField7, @@GAUGE_NAME_DEBUG_F7@@,float,"%.4f" + entry = debugFloatField7, @@GAUGE_NAME_DEBUG_F7@@,float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: P setting - entry = debugIntField1, @@GAUGE_NAME_DEBUG_I1@@,int,"%d" + entry = debugIntField1, @@GAUGE_NAME_DEBUG_I1@@,int,"%d", { !enableLogDebugChannels } ; Alternator_PID: offset setting - entry = debugIntField2, @@GAUGE_NAME_DEBUG_I2@@,int,"%d" + entry = debugIntField2, @@GAUGE_NAME_DEBUG_I2@@,int,"%d", { !enableLogDebugChannels } ; Alternator_PID: PID reset counter - entry = debugIntField3, @@GAUGE_NAME_DEBUG_I3@@,int,"%d" + entry = debugIntField3, @@GAUGE_NAME_DEBUG_I3@@,int,"%d", { !enableLogDebugChannels } + + entry = debugIntField4, @@GAUGE_NAME_DEBUG_I4@@,int,"%d", { !enableLogDebugChannels } + + entry = debugIntField5, @@GAUGE_NAME_DEBUG_I5@@,int,"%d", { !enableLogDebugChannels } - entry = debugIntField4, @@GAUGE_NAME_DEBUG_I4@@,int,"%d" - entry = debugIntField5, @@GAUGE_NAME_DEBUG_I5@@,int,"%d" - - entry = engineMode, "Engine Mode",int,"%d" entry = warningCounter, @@GAUGE_NAME_WARNING_COUNTER@@,int,"%d" entry = lastErrorCode, @@GAUGE_NAME_WARNING_LAST@@,int,"%d" - entry = recentErrorCode0, "error 0",int,"%d" - entry = recentErrorCode1, "error 1",int,"%d" - entry = recentErrorCode2, "error 2",int,"%d" - entry = recentErrorCode3, "error 3",int,"%d" - entry = recentErrorCode4, "error 4",int,"%d" - entry = recentErrorCode5, "error 5",int,"%d" - entry = recentErrorCode6, "error 6",int,"%d" - entry = recentErrorCode7, "error 7",int,"%d" + entry = recentErrorCode0, "error 0",int,"%d", { !enableLogErrorList } + entry = recentErrorCode1, "error 1",int,"%d", { !enableLogErrorList } + entry = recentErrorCode2, "error 2",int,"%d", { !enableLogErrorList } + entry = recentErrorCode3, "error 3",int,"%d", { !enableLogErrorList } + entry = recentErrorCode4, "error 4",int,"%d", { !enableLogErrorList } + entry = recentErrorCode5, "error 5",int,"%d", { !enableLogErrorList } + entry = recentErrorCode6, "error 6",int,"%d", { !enableLogErrorList } + entry = recentErrorCode7, "error 7",int,"%d", { !enableLogErrorList } entry = internalMcuTemperature, @@GAUGE_NAME_CPU_TEMP@@,float,"%.2f" entry = tCharge, "tCharge",float,"%.3f" @@ -1232,6 +1271,7 @@ menuDialog = main menu = "&Controller" subMenu = ecuStimulator, "ECU stimulator" + subMenu = datalogSettings, "Datalogging" subMenu = ioTest, "Bench test" subMenu = engineTypeDialog, "Popular vehicles" subMenu = std_separator @@ -1603,6 +1643,10 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" panel = triggerInputComparator dialog = allPinsSensors, "Sensors" + field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel + field = "Primary input channel", triggerInputPins1 + field = "Secondary channel", triggerInputPins2 + field = "Cam Sync/VVT input", camInputs1 field = "CLT ADC input", clt_adcChannel field = "IAT ADC input", iat_adcChannel field = "vBatt ADC input", vbattAdcChannel @@ -1636,10 +1680,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "mc33972_cs", mc33972_cs field = "mc33972 SPI", mc33972spiDevice panel = allPinsSensors - field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel - field = "Primary input channel", triggerInputPins1 - field = "Secondary channel", triggerInputPins2 - field = "Cam Sync/VVT input", camInputs1 dialog = allPins1_2 field = "Tachometer output Pin", tachOutputPin @@ -1652,13 +1692,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "Idle Stepper Enable", stepperEnablePin field = "Fuel Pump Pin", fuelPumpPin field = "Fuel Pump Pin Mode", fuelPumpPinMode - field = "ETB#1 Dir #1", etb1_directionPin1 @@if_ts_show_etb_pins - field = "ETB#1 Dir #2", etb1_directionPin2 @@if_ts_show_etb_pins - field = "ETB#1 Control #1", etb1_controlPin1 @@if_ts_show_etb_pins - field = "etb1_controlPinMode", etb1_controlPinMode @@if_ts_show_etb_pins - field = "ETB#2 Dir #1", etb2_directionPin1 @@if_ts_show_etb_pins - field = "ETB#2 Dir #2", etb2_directionPin2 @@if_ts_show_etb_pins - field = "ETB#2 Control #1", etb2_controlPin1 @@if_ts_show_etb_pins + field = "ETB#1 Dir #1", etbIo1_directionPin1 @@if_ts_show_etb_pins + field = "ETB#1 Dir #2", etbIo1_directionPin2 @@if_ts_show_etb_pins + field = "ETB#1 Control #1", etbIo1_controlPin1 @@if_ts_show_etb_pins + field = "etb1_controlPinMode", etbIo1_controlPinMode @@if_ts_show_etb_pins + field = "ETB#2 Dir #1", etbIo2_directionPin1 @@if_ts_show_etb_pins + field = "ETB#2 Dir #2", etbIo2_directionPin2 @@if_ts_show_etb_pins + field = "ETB#2 Control #1", etbIo2_controlPin1 @@if_ts_show_etb_pins field = "SD CS Pin", sdCardCsPin field = "MIL / Check Engine Pin", malfunctionIndicatorPin field = "MIL / Check Engine Pin Mode", malfunctionIndicatorPinMode @@ -2505,7 +2545,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "No1 Control #1", etbIo1_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "No2 Direction #1", etbIo2_directionPin1, {throttlePedalPositionAdcChannel != 16} field = "No2 Direction #2", etbIo2_directionPin2, {throttlePedalPositionAdcChannel != 16} - field = "No2 Control #1", etb2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} + field = "No2 Control #1", etbIo2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "TPS#2 min", tps2Min, {etbIo2_directionPin1 != 0} field = "TPS#2 max", tps2Max, {etbIo2_directionPin1 != 0} panel = etbPidDialog @@ -2606,6 +2646,11 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "" field = "Engine chart size", engineChartSize + dialog = datalogSettings, "Datalogging Settings" + field = "#Disabling optional logging may increase update rate!" + field = "Log debug channels", enableLogDebugChannels + field = "Log recent errors list", enableLogErrorList + ; Racing Features->Launch Control dialog = smLaunchControl, "Launch Control Settings NOT WORKING" field = "RPM Step1 Limit", step1rpm diff --git a/firmware/tunerstudio/rusefi_frankenso.ini b/firmware/tunerstudio/rusefi_frankenso.ini index f5ab316d62..a4c1573242 100644 --- a/firmware/tunerstudio/rusefi_frankenso.ini +++ b/firmware/tunerstudio/rusefi_frankenso.ini @@ -44,7 +44,7 @@ enable2ndByteCanID = false [TunerStudio] queryCommand = "S" versionInfo = "V" ; firmwave version for title bar. - signature = "rusEFI v1.07" ; signature is expected to be 7 or more characters. + signature = "rusEFI v1.08" ; signature is expected to be 7 or more characters. [Constants] ; new packet serial format with CRC @@ -85,7 +85,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Dec 08 00:32:34 EST 2019 +; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Dec 25 15:54:44 EST 2019 pageSize = 20000 page = 1 @@ -125,6 +125,7 @@ page = 1 issue_294_29 = bits, U32, 76, [28:28], "false", "true" issue_294_30 = bits, U32, 76, [29:29], "false", "true" issue_294_31 = bits, U32, 76, [30:30], "false", "true" + unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true" tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0 tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0 tpsErrorDetectionTooLow = scalar, S16, 84, "%", 1, 0, -40, 200, 0 @@ -207,6 +208,35 @@ page = 1 trigger_unusedCustomIsSynchronizationNeeded= bits, U32, 528, [0:0], "false", "true" trigger_unusedCustomNeedSecondTriggerInput= bits, U32, 528, [1:1], "false", "true" trigger_useOnlyFirstChannel= bits, U32, 528, [2:2], "false", "true" + trigger_unusedBit_4_3 = bits, U32, 528, [3:3], "false", "true" + trigger_unusedBit_4_4 = bits, U32, 528, [4:4], "false", "true" + trigger_unusedBit_4_5 = bits, U32, 528, [5:5], "false", "true" + trigger_unusedBit_4_6 = bits, U32, 528, [6:6], "false", "true" + trigger_unusedBit_4_7 = bits, U32, 528, [7:7], "false", "true" + trigger_unusedBit_4_8 = bits, U32, 528, [8:8], "false", "true" + trigger_unusedBit_4_9 = bits, U32, 528, [9:9], "false", "true" + trigger_unusedBit_4_10 = bits, U32, 528, [10:10], "false", "true" + trigger_unusedBit_4_11 = bits, U32, 528, [11:11], "false", "true" + trigger_unusedBit_4_12 = bits, U32, 528, [12:12], "false", "true" + trigger_unusedBit_4_13 = bits, U32, 528, [13:13], "false", "true" + trigger_unusedBit_4_14 = bits, U32, 528, [14:14], "false", "true" + trigger_unusedBit_4_15 = bits, U32, 528, [15:15], "false", "true" + trigger_unusedBit_4_16 = bits, U32, 528, [16:16], "false", "true" + trigger_unusedBit_4_17 = bits, U32, 528, [17:17], "false", "true" + trigger_unusedBit_4_18 = bits, U32, 528, [18:18], "false", "true" + trigger_unusedBit_4_19 = bits, U32, 528, [19:19], "false", "true" + trigger_unusedBit_4_20 = bits, U32, 528, [20:20], "false", "true" + trigger_unusedBit_4_21 = bits, U32, 528, [21:21], "false", "true" + trigger_unusedBit_4_22 = bits, U32, 528, [22:22], "false", "true" + trigger_unusedBit_4_23 = bits, U32, 528, [23:23], "false", "true" + trigger_unusedBit_4_24 = bits, U32, 528, [24:24], "false", "true" + trigger_unusedBit_4_25 = bits, U32, 528, [25:25], "false", "true" + trigger_unusedBit_4_26 = bits, U32, 528, [26:26], "false", "true" + trigger_unusedBit_4_27 = bits, U32, 528, [27:27], "false", "true" + trigger_unusedBit_4_28 = bits, U32, 528, [28:28], "false", "true" + trigger_unusedBit_4_29 = bits, U32, 528, [29:29], "false", "true" + trigger_unusedBit_4_30 = bits, U32, 528, [30:30], "false", "true" + trigger_unusedBit_4_31 = bits, U32, 528, [31:31], "false", "true" trigger_customTotalToothCount = scalar, S32, 532, "number", 1, 0.0, 0, 500.0, 0 trigger_customSkippedToothCount = scalar, S32, 536, "number", 1, 0.0, 0, 500.0, 0 hip9011SpiDevice = bits,U32, 540, [0:7], "Off", "SPI1", "SPI2", "SPI3", "SPI4" @@ -502,6 +532,36 @@ page = 1 ;no TS info - skipping unused offset 972 todoClutchUpPinInverted = bits, U32, 976, [0:0], "false", "true" todoClutchDownPinInverted= bits, U32, 976, [1:1], "false", "true" + unusedBit_247_2 = bits, U32, 976, [2:2], "false", "true" + unusedBit_247_3 = bits, U32, 976, [3:3], "false", "true" + unusedBit_247_4 = bits, U32, 976, [4:4], "false", "true" + unusedBit_247_5 = bits, U32, 976, [5:5], "false", "true" + unusedBit_247_6 = bits, U32, 976, [6:6], "false", "true" + unusedBit_247_7 = bits, U32, 976, [7:7], "false", "true" + unusedBit_247_8 = bits, U32, 976, [8:8], "false", "true" + unusedBit_247_9 = bits, U32, 976, [9:9], "false", "true" + unusedBit_247_10 = bits, U32, 976, [10:10], "false", "true" + unusedBit_247_11 = bits, U32, 976, [11:11], "false", "true" + unusedBit_247_12 = bits, U32, 976, [12:12], "false", "true" + unusedBit_247_13 = bits, U32, 976, [13:13], "false", "true" + unusedBit_247_14 = bits, U32, 976, [14:14], "false", "true" + unusedBit_247_15 = bits, U32, 976, [15:15], "false", "true" + unusedBit_247_16 = bits, U32, 976, [16:16], "false", "true" + unusedBit_247_17 = bits, U32, 976, [17:17], "false", "true" + unusedBit_247_18 = bits, U32, 976, [18:18], "false", "true" + unusedBit_247_19 = bits, U32, 976, [19:19], "false", "true" + unusedBit_247_20 = bits, U32, 976, [20:20], "false", "true" + unusedBit_247_21 = bits, U32, 976, [21:21], "false", "true" + unusedBit_247_22 = bits, U32, 976, [22:22], "false", "true" + unusedBit_247_23 = bits, U32, 976, [23:23], "false", "true" + unusedBit_247_24 = bits, U32, 976, [24:24], "false", "true" + unusedBit_247_25 = bits, U32, 976, [25:25], "false", "true" + unusedBit_247_26 = bits, U32, 976, [26:26], "false", "true" + unusedBit_247_27 = bits, U32, 976, [27:27], "false", "true" + unusedBit_247_28 = bits, U32, 976, [28:28], "false", "true" + unusedBit_247_29 = bits, U32, 976, [29:29], "false", "true" + unusedBit_247_30 = bits, U32, 976, [30:30], "false", "true" + unusedBit_247_31 = bits, U32, 976, [31:31], "false", "true" etbIo1_directionPin1 = bits, U08, 980, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_directionPin2 = bits, U08, 981, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_controlPin1 = bits, U08, 982, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" @@ -1182,147 +1242,182 @@ page = 1 [OutputChannels] -; see TS_FILE_VERSION in firmware code -fileVersion = { 20190701 } +fileVersion = { 20191221 } ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 356 + ochBlockSize = 220 ; ; see TunerStudioOutputChannels struct ; - RPMValue = scalar, U32, 0, "RPM", 1, 0.00000 + +; Bit flags + hasSdCard = bits, U32, 0, [0:0], "true", "false"; + isIgnitionEnabledIndicator=bits,U32, 0, [1:1], "true", "false"; + ind_injection_enabled=bits,U32, 0, [2:2], "true", "false"; + isCylinderCleanupEnabled=bits,U32, 0, [3:3], "true", "false"; + isCylinderCleanupActivated=bits,U32, 0, [4:4], "true", "false"; + ind_fuel_pump = bits, U32, 0, [5:5], "true", "false"; + ind_fan = bits, U32, 0, [6:6], "true", "false"; + ind_o2_heater = bits, U32, 0, [7:7], "true", "false"; + ind_check_engine= bits, U32, 0, [8:8], "true", "false"; + needBurn = bits, U32, 0, [9:9], "true", "false"; + ind_2nd_trigger_en=bits, U32, 0, [10:10], "true", "false"; + clutchUpState =bits, U32, 0, [11:11], "true", "false"; + clutchDownState =bits, U32, 0, [12:12], "true", "false"; + knockEverIndicator=bits, U32, 0, [13:13], "true", "false"; + knockNowIndicator=bits, U32, 0, [14:14], "true", "false"; + brakePedalIndicator=bits, U32, 0, [15:15], "true", "false"; + toothLogReady =bits, U32, 0, [16:16], "true", "false"; + acSwitchIndicator =bits, U32, 0, [17:17], "true", "false"; + ind_tps_error = bits, U32, 0, [18:18], "true", "false"; + ind_clt_error = bits, U32, 0, [19:19], "true", "false"; + ind_map_error = bits, U32, 0, [20:21], "true", "false"; + ind_iat_error = bits, U32, 0, [21:22], "true", "false"; + ind_isTriggerError = bits, U32, 0, [23:23], "true", "false"; + ind_hasFatalError=bits, U32, 0, [24:24], "true", "false"; + ind_isWarnNow =bits, U32, 0, [25:25], "true", "false"; + +; RPM, vss + RPMValue = scalar, U16, 4, "RPM", 1, 0.00000 + rpmAcceleration = scalar, S16, 6, "dRpm",{1/100}, 0 + speedToRpmRatio = scalar, S16, 8, "value",{1/100}, 0 + vehicleSpeedKph = scalar, U08, 10, "kph", 1, 0.0 + +; temperatures + internalMcuTemperature = scalar,S08, 11, "deg C", 1, 0 #if CELSIUS - coolant = scalar, F32, 4, "deg C", 1, 0.0 + coolant = scalar, S16, 12, "deg C",{1/100}, 0.0 #else - coolant = scalar, F32, 4, "deg F", {9/5}, 17.77777 + coolant = scalar, S16, 12, "deg F",{9/(5 * 100)}, 17.77777 #endif #if CELSIUS - intake = scalar, F32, 8, "deg C", 1, 0.0 + intake = scalar, S16, 14, "deg C",{1/100}, 0.0 #else - intake = scalar, F32, 8, "deg F", {9/5}, 17.77777 + intake = scalar, S16, 14, "deg F",{9/(5 * 100)}, 17.77777 #endif - TPSValue = scalar, F32, 12, "%", 1, 0 - MAFValue = scalar, F32, 16, "V", 1, 0 - AFRValue = scalar, F32, 20, "AFR", 1, 0.0 - engineLoad = scalar, F32, 24, "%", 1, 0.0 ; Blend of MAP and TPS, depends on algorithm - VBatt = scalar, F32, 28, "V", 1, 0.0 +; todo: aux1 +; todo: aux2 + + +; throttle, pedal + TPSValue = scalar, U16, 20, "%",{1/100}, 0 + throttlePedalPosition = scalar,U16, 22, "%",{1/100}, 0 + tpsADC = scalar, U16, 24, "ADC", 1, 0.0; + +; air flow/mass measurments + MAFValue = scalar, U16, 26, "V",,{1/1000},, 0 + massAirFlowValue= scalar, U16, 28, "Kg/h", 0.01, 0 + MAPValue = scalar, U16, 30, "kPa",{1/30}, 0.0 + baroPressure = scalar, U16, 32, "kPa",{1/30}, 0.0 + AFRValue = scalar, U16, 34, "AFR",,{1/1000},, 0.0 + engineLoad = scalar, U16, 36, "%",{1/100}, 0.0 ; Blend of MAP and TPS, depends on algorithm + +; misc sensors + VBatt = scalar, U16, 38, "V",,{1/1000},, 0.0 + oilPressure = scalar, U16, 40, "kPa",{1/30}, 0.0 + vvtPosition = scalar, U16, 42, "deg",{1/50}, 0 + ; 10 bit TPS ADC value (from 0 to 1023 in 5v scale) - tpsADC = scalar, U16, 32, "ADC", 1, 0.0; - tpsADC2 = scalar, U16, 34, "ADC", 1, 0.0; - baroPressure = scalar, F32, 36, "pres", 1, 0.0; - MAPValue = scalar, F32, 40, "MAP", 1, 0.0; - ; total fuel squirt duration (in MS) per engine cycle according to current CLT - crankingFuelMs = scalar, F32, 44, "ms", 1, 0.0; - baseFuel = scalar, F32, 48, "ms", 1, 0 - tCharge = scalar, F32, 52, "T", 1, 0.0; - ignitionAdvance = scalar, F32, 56, "deg", 1, 0.0; - sparkDwellValue = scalar, F32, 60, "ms", 1, 0.0; - ; actual total Ms time per engine cycle with all corrections - actualLastInjection = scalar, F32, 64, "ms", 1, 0.0; - debugFloatField1 = scalar, F32, 68, "val", 1, 0.0; - - hasSdCard = bits, U32, 72, [0:0], "true", "false"; - isIgnitionEnabledIndicator=bits, U32, 72, [1:1], "true", "false"; - ind_injection_enabled=bits,U32, 72, [2:2], "true", "false"; - isCylinderCleanupEnabled=bits, U32, 72, [3:3], "true", "false"; - isCylinderCleanupActivated=bits,U32,72, [4:4], "true", "false"; - ind_fuel_pump = bits, U32, 72, [5:5], "true", "false"; - ind_fan = bits, U32, 72, [6:6], "true", "false"; - ind_o2_heater = bits, U32, 72, [7:7], "true", "false"; - ind_check_engine= bits, U32, 72, [8:8], "true", "false"; - needBurn = bits, U32, 72, [9:9], "true", "false"; - ind_2nd_trigger_en=bits, U32, 72, [10:10], "true", "false"; - clutchUpState =bits, U32, 72, [11:11], "true", "false"; - clutchDownState =bits, U32, 72, [12:12], "true", "false"; - knockEverIndicator=bits, U32, 72, [13:13], "true", "false"; - knockNowIndicator=bits, U32, 72, [14:14], "true", "false"; - brakePedalIndicator=bits, U32, 72, [15:15], "true", "false"; - toothLogReady =bits, U32, 72, [16:16], "true", "false"; - acSwitchIndicator =bits, U32, 72, [17:17], "true", "false"; - vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0; - - ind_tps_error = bits, U32, 80, [0:0], "true", "false"; - ind_clt_error = bits, U32, 80, [1:1], "true", "false"; - ind_map_error = bits, U32, 80, [2:2], "true", "false"; - ind_iat_error = bits, U32, 80, [3:3], "true", "false"; - ind_isTriggerError = bits, U32, 80, [5:5], "true", "false"; - ind_hasFatalError=bits, U32, 80, [6:6], "true", "false"; - ind_isWarnNow =bits, U32, 80, [7:7], "true", "false"; - firmwareTsVersion = scalar,U32, 84, "version_p", 1, 0 - egt1 = scalar, S16, 88, "deg C", 1, 0 - egt2 = scalar, S16, 90, "deg C", 1, 0 - egt3 = scalar, S16, 92, "deg C", 1, 0 - egt4 = scalar, S16, 94, "deg C", 1, 0 - egt5 = scalar, S16, 96, "deg C", 1, 0 - egt6 = scalar, S16, 98, "deg C", 1, 0 - egt7 = scalar, S16, 100, "deg C", 1, 0 - egt8 = scalar, S16, 102, "deg C", 1, 0 - rpmAcceleration = scalar, F32, 104, "dRpm", 1, 0 - massAirFlowValue= scalar, F32, 108, "Kg/h", 1, 0 - veValue = scalar, F32, 112, "ratio", 1, 0 - deltaTps = scalar, F32, 116, "ratio", 1, 0 - triggerErrorsCounter = scalar, U32,120, "counter", 1, 0 - engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0 - tpsAccelFuel = scalar, F32, 128, "ms", 1, 0 - baroCorrection = scalar, F32, 132, "%", 1, 0 - throttlePedalPosition = scalar, F32, 136, "%", 1, 0 - injectorDutyCycle= scalar, F32, 140, "%", 1, 0 - knockCount = scalar, U32, 144, "counter", 1, 0 - fuelTankLevel = scalar, F32, 148, "amount", 1, 0 - knockLevel = scalar, F32, 152, "Volts", 1, 0 - ; totalTriggerErrorCounter 156 - wallFuelAmount = scalar, F32, 160, "ms", 1, 0 - iatCorrection = scalar, F32, 164, "%", 1, 0 - wallFuelCorrection = scalar, F32, 168, "ms", 1, 0 - idleAirValvePosition = scalar, F32, 172, "percent", 1, 0 - currentTargetAfr = scalar, F32, 176, "ratio", 1, 0 - chargeAirMass = scalar, F32, 180, "g", 1, 0 - cltCorrection = scalar, F32, 184, "%", 1, 0 - fuelRunning = scalar, F32, 188, "g", 1, 0 - debugIntField1 = scalar, S32, 192, "val", 1, 0.0; - injectorLagMs = scalar, F32, 196, "ms", 1, 0.0; - debugFloatField2 = scalar, F32, 200, "val", 1, 0.0; - debugFloatField3 = scalar, F32, 204, "val", 1, 0.0; - debugFloatField4 = scalar, F32, 208, "val", 1, 0.0; - debugFloatField5 = scalar, F32, 212, "val", 1, 0.0; - debugIntField2 = scalar, S32, 216, "val", 1, 0.0; - debugIntField3 = scalar, S32, 220, "val", 1, 0.0; - timeSeconds = scalar, U32, 224, "sec", 1, 0.0; - engineLoadDelta = scalar,F32, 228, "value", 1, 0 - speedToRpmRatio = scalar,F32, 232, "value", 1, 0 - warningCounter = scalar,U16, 236, "count", 1, 0 - - lastErrorCode = scalar,U16, 240, "error", 1, 0 - - internalMcuTemperature = scalar,F32, 244, "C", 1, 0 - vvtPosition = scalar,F32, 248, "deg", 1, 0 - engineMode = scalar, U32, 252, "em", 1, 0.0; - debugFloatField6 = scalar, F32, 256, "val", 1, 0.0; - debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; - firmwareVersion = scalar,U32, 264, "version_f", 1, 0 - fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 - coilDutyCycle = scalar, F32, 272, "perc", 1, 0 - accelerationX = scalar, S16, 276, "G", 0.01, 0 - accelerationY = scalar, S16, 278, "G", 0.01, 0 - oilPressure = scalar, F32, 280, "kPa", 1, 0.0 - fuelConsumptionPerHour=scalar, F32, 284, "kPa", 1, 0.0 - injectionOffset = scalar, F32, 288, "deg", 1, 0; - debugIntField4 = scalar, S16, 292, "val", 1, 0.0; - debugIntField5 = scalar, S16, 294, "val", 1, 0.0; - recentErrorCode0 = scalar,U16, 296, "error", 1, 0 - recentErrorCode1 = scalar,U16, 298, "error", 1, 0 - recentErrorCode2 = scalar,U16, 300, "error", 1, 0 - recentErrorCode3 = scalar,U16, 302, "error", 1, 0 - recentErrorCode4 = scalar,U16, 304, "error", 1, 0 - recentErrorCode5 = scalar,U16, 306, "error", 1, 0 - recentErrorCode6 = scalar,U16, 308, "error", 1, 0 - recentErrorCode7 = scalar,U16, 310, "error", 1, 0 - etbTarget = scalar,F32, 312, "%", 1, 0 - etb1DutyCycle = scalar,F32, 316, "%", 1, 0 - etb1Error = scalar,F32, 320, "%", 1, 0 + ;tpsADC2 = scalar, U16, 44, "ADC", 1, 0.0; + +; fuel math + chargeAirMass = scalar, U16, 44, "g",0.001, 0 + crankingFuelMs = scalar, U16, 46, "ms",{1/300}, 0.0 + currentTargetAfr= scalar, U16, 48, "ratio",,{1/1000},, 0 + baseFuel = scalar, U16, 50, "ms",{1/300}, 0 + fuelRunning = scalar, U16, 52, "ms",{1/300}, 0 + actualLastInjection=scalar,U16, 54, "ms",{1/300}, 0.0 + injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0 + veValue = scalar, U08, 57, "ratio", 0.5, 0 + injectionOffset = scalar, S16, 58, "deg",{1/50}, 0 + tCharge = scalar, U16, 60, "deg C",{1/100}, 0.0 + +; Corrections + injectorLagMs = scalar, U16, 62, "ms",{1/300}, 0.0 + iatCorrection = scalar, U16, 64, "%",{1/100}, 0 + cltCorrection = scalar, U16, 66, "%",{1/100}, 0 + baroCorrection = scalar, U16, 68, "%",{1/100}, 0 + fuelPidCorrection=scalar, S16, 70, "ms",{1/300}, 0 + +; Wall model AE + wallFuelAmount = scalar, U16, 72, "ms",{1/300}, 0 + wallFuelCorrection=scalar, S16, 74, "ms",0.001, 0 + +; TPS/load AE + engineLoadDelta = scalar, S16, 76, "value",{1/100}, 0 + deltaTps = scalar, S16, 78, "ratio",{1/100}, 0 + engineLoadAccelExtra=scalar,S16, 80, "value",{1/100}, 0 + tpsAccelFuel = scalar, U16, 82, "ms",{1/300}, 0 + +; Ignition + ignitionAdvance = scalar, U16, 84, "deg",{1/50}, 0.0 + sparkDwellValue = scalar, U16, 86, "ms",{1/300}, 0.0 + coilDutyCycle = scalar, U16, 88, "%",{1/100}, 0 + +; Idle & ETB + idleAirValvePosition=scalar,S16, 90, "%",{1/100}, 0 + etbTarget = scalar, S16, 92, "%",{1/100}, 0 + etb1DutyCycle = scalar, S16, 94, "%",{1/100}, 0 + etb1Error = scalar, S16, 96, "%",{1/100}, 0 + +; Fuel system + fuelTankLevel = scalar, S16, 98, "amount",{1/100}, 0 + fuelConsumptionPerHour=scalar,F32, 100, "kPa", 1, 0.0 + +; Knock + knockCount = scalar, U32, 104,"counter", 1, 0 + knockLevel = scalar, F32, 108, "Volts", 1, 0 + +; Mode, firmware, protocol, run time + timeSeconds = scalar, U32, 112, "sec", 1, 0.0 + engineMode = scalar, U32, 116, "em", 1, 0.0; + firmwareVersion = scalar, U32, 120,"version_f", 1, 0 + firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0 + +; Errors + totalTriggerErrorCounter=scalar,U32, 128,"counter", 1, 0 + ; orderingErrorCounter 132 + warningCounter = scalar, U16, 136, "count", 1, 0 + lastErrorCode = scalar, U16, 138, "error", 1, 0 + recentErrorCode0= scalar, U16, 140, "error", 1, 0 + recentErrorCode1= scalar, U16, 142, "error", 1, 0 + recentErrorCode2= scalar, U16, 144, "error", 1, 0 + recentErrorCode3= scalar, U16, 146, "error", 1, 0 + recentErrorCode4= scalar, U16, 148, "error", 1, 0 + recentErrorCode5= scalar, U16, 150, "error", 1, 0 + recentErrorCode6= scalar, U16, 152, "error", 1, 0 + recentErrorCode7= scalar, U16, 154, "error", 1, 0 + +; Debug + debugFloatField1= scalar, F32, 156, "val", 1, 0.0 + debugFloatField2= scalar, F32, 160, "val", 1, 0.0 + debugFloatField3= scalar, F32, 164, "val", 1, 0.0 + debugFloatField4= scalar, F32, 168, "val", 1, 0.0 + debugFloatField5= scalar, F32, 172, "val", 1, 0.0 + debugFloatField6= scalar, F32, 176, "val", 1, 0.0 + debugFloatField7= scalar, F32, 180, "val", 1, 0.0 + debugIntField1 = scalar, S32, 184, "val", 1, 0.0 + debugIntField2 = scalar, S32, 188, "val", 1, 0.0 + debugIntField3 = scalar, S32, 192, "val", 1, 0.0 + debugIntField4 = scalar, S16, 196, "val", 1, 0.0 + debugIntField5 = scalar, S16, 198, "val", 1, 0.0 + +; Accel + accelerationX = scalar, S16, 200, "G", 0.01, 0 + accelerationY = scalar, S16, 202, "G", 0.01, 0 + +; egt + egt1 = scalar, S16, 204, "deg C", 1, 0 + egt2 = scalar, S16, 206, "deg C", 1, 0 + egt3 = scalar, S16, 208, "deg C", 1, 0 + egt4 = scalar, S16, 210, "deg C", 1, 0 + egt5 = scalar, S16, 212, "deg C", 1, 0 + egt6 = scalar, S16, 214, "deg C", 1, 0 + egt7 = scalar, S16, 216, "deg C", 1, 0 + egt8 = scalar, S16, 218, "deg C", 1, 0 ; @@ -1344,6 +1439,10 @@ fileVersion = { 20190701 } wueAfrTargetOffset = array, S16, [ 16], ":1", 0.1, 0.0, -3.0, 3.0, 1; wueAnalRecommend = array, U08, [ 16], "%", 1.00, 0.0, 100, 255.00, 0 +; These are inverted (false = "Yes") so that they default to enabled + enableLogDebugChannels = bits, U08, [0:0], "Yes", "No" + enableLogErrorList = bits, U08, [0:0], "Yes", "No" + [ConstantsExtensions] defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 @@ -1792,7 +1891,7 @@ gaugeCategory = Sensors - Extra 2 gaugeCategory = ECU Status warningCounterGauge = warningCounter, "Warning count", "", 0, 100, 0, 0, 100, 100, 0, 0 lastErrorCodeGauge = lastErrorCode, "Last error", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 - triggerErrorsCounterGauge = triggerErrorsCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 + triggerErrorsCounterGauge = totalTriggerErrorCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 recentErrorCode0Gauge = recentErrorCode0, "Error#1", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode1Gauge = recentErrorCode1, "Error#2", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode2Gauge = recentErrorCode2, "Error#3", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 @@ -1990,7 +2089,7 @@ gaugeCategory = Throttle Body (incl. ETB) entry = massAirFlowValue,"air flow", float, "%.3f" entry = chargeAirMass, "air mass", float, "%.3f" entry = throttlePedalPosition, "Throttle pedal position", float, "%.3f" - entry = triggerErrorsCounter, "trg err",int, "%d" + entry = totalTriggerErrorCounter, "trg err",int, "%d" entry = idleAirValvePosition, "Idle Air Valve", float, "%.3f" @@ -2004,16 +2103,16 @@ gaugeCategory = Throttle Body (incl. ETB) entry = coilDutyCycle, "dwell: coil duty cycle", float,"%.3f" entry = currentTargetAfr,"fuel: target AFR", float,"%.3f" - entry = accelerationX, "Acceleration: X", float,"%.2f" - entry = accelerationY, "Acceleration: Y", float,"%.2f" - entry = egt1, "EGT1", float,"%.1f" - entry = egt2, "EGT2", float,"%.1f" - entry = egt3, "EGT3", float,"%.1f" - entry = egt4, "EGT4", float,"%.1f" - entry = egt5, "EGT5", float,"%.1f" - entry = egt6, "EGT6", float,"%.1f" - entry = egt7, "EGT7", float,"%.1f" - entry = egt8, "EGT8", float,"%.1f" + entry = accelerationX, "Acceleration: X", float,"%.2f", { LIS302DLCsPin != 0 } + entry = accelerationY, "Acceleration: Y", float,"%.2f", { LIS302DLCsPin != 0 } + entry = egt1, "EGT1", float,"%.1f", { max31855_cs1 != 0} + entry = egt2, "EGT2", float,"%.1f", { max31855_cs2 != 0} + entry = egt3, "EGT3", float,"%.1f", { max31855_cs3 != 0} + entry = egt4, "EGT4", float,"%.1f", { max31855_cs4 != 0} + entry = egt5, "EGT5", float,"%.1f", { max31855_cs5 != 0} + entry = egt6, "EGT6", float,"%.1f", { max31855_cs6 != 0} + entry = egt7, "EGT7", float,"%.1f", { max31855_cs7 != 0} + entry = egt8, "EGT8", float,"%.1f", { max31855_cs8 != 0} entry = engineLoadAccelExtra, "fuel: engine load acceleration extra fuel",float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f" @@ -2035,54 +2134,54 @@ gaugeCategory = Throttle Body (incl. ETB) ; is there a way to log parameter? entry = debugMode, "debugMode",int,"%d" ; Alternator_PID: alternator duty cycle ; DBG_TPS_ACCEL: from TPS - entry = debugFloatField1, "debug f1",float,"%.4f" + entry = debugFloatField1, "debug f1",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: current integration term ; DBG_TPS_ACCEL: to TPS - entry = debugFloatField2, "debug f2: iTerm",float,"%.4f" + entry = debugFloatField2, "debug f2: iTerm",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: previous error ; DBG_TPS_ACCEL: tps<>tps table value - entry = debugFloatField3, "debug f3: prevError",float,"%.4f" + entry = debugFloatField3, "debug f3: prevError",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: I setting ; DBG_TPS_ACCEL: extra fuel - entry = debugFloatField4, "debug f4: iParam",float,"%.4f" + entry = debugFloatField4, "debug f4: iParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: D setting - entry = debugFloatField5, "debug f5: dParam",float,"%.4f" + entry = debugFloatField5, "debug f5: dParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: dTerm - entry = debugFloatField6, "debug f6: dTerm",float,"%.4f" + entry = debugFloatField6, "debug f6: dTerm",float,"%.4f", { !enableLogDebugChannels } - entry = debugFloatField7, "debug f7",float,"%.4f" + entry = debugFloatField7, "debug f7",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: P setting - entry = debugIntField1, "debug i1: pParam",int,"%d" + entry = debugIntField1, "debug i1: pParam",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: offset setting - entry = debugIntField2, "debug i2: offset",int,"%d" + entry = debugIntField2, "debug i2: offset",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: PID reset counter - entry = debugIntField3, "debug i3",int,"%d" + entry = debugIntField3, "debug i3",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField4, "debug i4",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField5, "debug i5",int,"%d", { !enableLogDebugChannels } - entry = debugIntField4, "debug i4",int,"%d" - entry = debugIntField5, "debug i5",int,"%d" - - entry = engineMode, "Engine Mode",int,"%d" entry = warningCounter, "warning: counter",int,"%d" entry = lastErrorCode, "warning: last",int,"%d" - entry = recentErrorCode0, "error 0",int,"%d" - entry = recentErrorCode1, "error 1",int,"%d" - entry = recentErrorCode2, "error 2",int,"%d" - entry = recentErrorCode3, "error 3",int,"%d" - entry = recentErrorCode4, "error 4",int,"%d" - entry = recentErrorCode5, "error 5",int,"%d" - entry = recentErrorCode6, "error 6",int,"%d" - entry = recentErrorCode7, "error 7",int,"%d" + entry = recentErrorCode0, "error 0",int,"%d", { !enableLogErrorList } + entry = recentErrorCode1, "error 1",int,"%d", { !enableLogErrorList } + entry = recentErrorCode2, "error 2",int,"%d", { !enableLogErrorList } + entry = recentErrorCode3, "error 3",int,"%d", { !enableLogErrorList } + entry = recentErrorCode4, "error 4",int,"%d", { !enableLogErrorList } + entry = recentErrorCode5, "error 5",int,"%d", { !enableLogErrorList } + entry = recentErrorCode6, "error 6",int,"%d", { !enableLogErrorList } + entry = recentErrorCode7, "error 7",int,"%d", { !enableLogErrorList } entry = internalMcuTemperature, "CPU Temperature",float,"%.2f" entry = tCharge, "tCharge",float,"%.3f" @@ -2258,6 +2357,7 @@ menuDialog = main menu = "&Controller" subMenu = ecuStimulator, "ECU stimulator" + subMenu = datalogSettings, "Datalogging" subMenu = ioTest, "Bench test" subMenu = engineTypeDialog, "Popular vehicles" subMenu = std_separator @@ -2629,6 +2729,10 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" panel = triggerInputComparator dialog = allPinsSensors, "Sensors" + field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel + field = "Primary input channel", triggerInputPins1 + field = "Secondary channel", triggerInputPins2 + field = "Cam Sync/VVT input", camInputs1 field = "CLT ADC input", clt_adcChannel field = "IAT ADC input", iat_adcChannel field = "vBatt ADC input", vbattAdcChannel @@ -2662,10 +2766,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "mc33972_cs", mc33972_cs field = "mc33972 SPI", mc33972spiDevice panel = allPinsSensors - field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel - field = "Primary input channel", triggerInputPins1 - field = "Secondary channel", triggerInputPins2 - field = "Cam Sync/VVT input", camInputs1 dialog = allPins1_2 field = "Tachometer output Pin", tachOutputPin @@ -2678,13 +2778,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "Idle Stepper Enable", stepperEnablePin field = "Fuel Pump Pin", fuelPumpPin field = "Fuel Pump Pin Mode", fuelPumpPinMode - field = "ETB#1 Dir #1", etb1_directionPin1 - field = "ETB#1 Dir #2", etb1_directionPin2 - field = "ETB#1 Control #1", etb1_controlPin1 - field = "etb1_controlPinMode", etb1_controlPinMode - field = "ETB#2 Dir #1", etb2_directionPin1 - field = "ETB#2 Dir #2", etb2_directionPin2 - field = "ETB#2 Control #1", etb2_controlPin1 + field = "ETB#1 Dir #1", etbIo1_directionPin1 + field = "ETB#1 Dir #2", etbIo1_directionPin2 + field = "ETB#1 Control #1", etbIo1_controlPin1 + field = "etb1_controlPinMode", etbIo1_controlPinMode + field = "ETB#2 Dir #1", etbIo2_directionPin1 + field = "ETB#2 Dir #2", etbIo2_directionPin2 + field = "ETB#2 Control #1", etbIo2_controlPin1 field = "SD CS Pin", sdCardCsPin field = "MIL / Check Engine Pin", malfunctionIndicatorPin field = "MIL / Check Engine Pin Mode", malfunctionIndicatorPinMode @@ -3531,7 +3631,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "No1 Control #1", etbIo1_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "No2 Direction #1", etbIo2_directionPin1, {throttlePedalPositionAdcChannel != 16} field = "No2 Direction #2", etbIo2_directionPin2, {throttlePedalPositionAdcChannel != 16} - field = "No2 Control #1", etb2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} + field = "No2 Control #1", etbIo2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "TPS#2 min", tps2Min, {etbIo2_directionPin1 != 0} field = "TPS#2 max", tps2Max, {etbIo2_directionPin1 != 0} panel = etbPidDialog @@ -3632,6 +3732,11 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "" field = "Engine chart size", engineChartSize + dialog = datalogSettings, "Datalogging Settings" + field = "#Disabling optional logging may increase update rate!" + field = "Log debug channels", enableLogDebugChannels + field = "Log recent errors list", enableLogErrorList + ; Racing Features->Launch Control dialog = smLaunchControl, "Launch Control Settings NOT WORKING" field = "RPM Step1 Limit", step1rpm diff --git a/firmware/tunerstudio/rusefi_kinetis.ini b/firmware/tunerstudio/rusefi_kinetis.ini index de38ec4432..0070d2939e 100644 --- a/firmware/tunerstudio/rusefi_kinetis.ini +++ b/firmware/tunerstudio/rusefi_kinetis.ini @@ -44,7 +44,7 @@ enable2ndByteCanID = false [TunerStudio] queryCommand = "S" versionInfo = "V" ; firmwave version for title bar. - signature = "rusEFI v1.07" ; signature is expected to be 7 or more characters. + signature = "rusEFI v1.08" ; signature is expected to be 7 or more characters. [Constants] ; new packet serial format with CRC @@ -85,7 +85,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Sun Dec 08 00:34:54 EST 2019 +; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/rusefi_config.txt Sun Dec 22 20:14:34 EST 2019 pageSize = 20000 page = 1 @@ -125,6 +125,7 @@ page = 1 issue_294_29 = bits, U32, 76, [28:28], "false", "true" issue_294_30 = bits, U32, 76, [29:29], "false", "true" issue_294_31 = bits, U32, 76, [30:30], "false", "true" + unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true" tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0 tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0 tpsErrorDetectionTooLow = scalar, S16, 84, "%", 1, 0, -40, 200, 0 @@ -207,6 +208,35 @@ page = 1 trigger_unusedCustomIsSynchronizationNeeded= bits, U32, 528, [0:0], "false", "true" trigger_unusedCustomNeedSecondTriggerInput= bits, U32, 528, [1:1], "false", "true" trigger_useOnlyFirstChannel= bits, U32, 528, [2:2], "false", "true" + trigger_unusedBit_4_3 = bits, U32, 528, [3:3], "false", "true" + trigger_unusedBit_4_4 = bits, U32, 528, [4:4], "false", "true" + trigger_unusedBit_4_5 = bits, U32, 528, [5:5], "false", "true" + trigger_unusedBit_4_6 = bits, U32, 528, [6:6], "false", "true" + trigger_unusedBit_4_7 = bits, U32, 528, [7:7], "false", "true" + trigger_unusedBit_4_8 = bits, U32, 528, [8:8], "false", "true" + trigger_unusedBit_4_9 = bits, U32, 528, [9:9], "false", "true" + trigger_unusedBit_4_10 = bits, U32, 528, [10:10], "false", "true" + trigger_unusedBit_4_11 = bits, U32, 528, [11:11], "false", "true" + trigger_unusedBit_4_12 = bits, U32, 528, [12:12], "false", "true" + trigger_unusedBit_4_13 = bits, U32, 528, [13:13], "false", "true" + trigger_unusedBit_4_14 = bits, U32, 528, [14:14], "false", "true" + trigger_unusedBit_4_15 = bits, U32, 528, [15:15], "false", "true" + trigger_unusedBit_4_16 = bits, U32, 528, [16:16], "false", "true" + trigger_unusedBit_4_17 = bits, U32, 528, [17:17], "false", "true" + trigger_unusedBit_4_18 = bits, U32, 528, [18:18], "false", "true" + trigger_unusedBit_4_19 = bits, U32, 528, [19:19], "false", "true" + trigger_unusedBit_4_20 = bits, U32, 528, [20:20], "false", "true" + trigger_unusedBit_4_21 = bits, U32, 528, [21:21], "false", "true" + trigger_unusedBit_4_22 = bits, U32, 528, [22:22], "false", "true" + trigger_unusedBit_4_23 = bits, U32, 528, [23:23], "false", "true" + trigger_unusedBit_4_24 = bits, U32, 528, [24:24], "false", "true" + trigger_unusedBit_4_25 = bits, U32, 528, [25:25], "false", "true" + trigger_unusedBit_4_26 = bits, U32, 528, [26:26], "false", "true" + trigger_unusedBit_4_27 = bits, U32, 528, [27:27], "false", "true" + trigger_unusedBit_4_28 = bits, U32, 528, [28:28], "false", "true" + trigger_unusedBit_4_29 = bits, U32, 528, [29:29], "false", "true" + trigger_unusedBit_4_30 = bits, U32, 528, [30:30], "false", "true" + trigger_unusedBit_4_31 = bits, U32, 528, [31:31], "false", "true" trigger_customTotalToothCount = scalar, S32, 532, "number", 1, 0.0, 0, 500.0, 0 trigger_customSkippedToothCount = scalar, S32, 536, "number", 1, 0.0, 0, 500.0, 0 hip9011SpiDevice = bits,U32, 540, [0:7], "Off", "SPI1", "SPI2", "SPI3", "SPI4" @@ -502,6 +532,36 @@ page = 1 ;no TS info - skipping unused offset 972 todoClutchUpPinInverted = bits, U32, 976, [0:0], "false", "true" todoClutchDownPinInverted= bits, U32, 976, [1:1], "false", "true" + unusedBit_247_2 = bits, U32, 976, [2:2], "false", "true" + unusedBit_247_3 = bits, U32, 976, [3:3], "false", "true" + unusedBit_247_4 = bits, U32, 976, [4:4], "false", "true" + unusedBit_247_5 = bits, U32, 976, [5:5], "false", "true" + unusedBit_247_6 = bits, U32, 976, [6:6], "false", "true" + unusedBit_247_7 = bits, U32, 976, [7:7], "false", "true" + unusedBit_247_8 = bits, U32, 976, [8:8], "false", "true" + unusedBit_247_9 = bits, U32, 976, [9:9], "false", "true" + unusedBit_247_10 = bits, U32, 976, [10:10], "false", "true" + unusedBit_247_11 = bits, U32, 976, [11:11], "false", "true" + unusedBit_247_12 = bits, U32, 976, [12:12], "false", "true" + unusedBit_247_13 = bits, U32, 976, [13:13], "false", "true" + unusedBit_247_14 = bits, U32, 976, [14:14], "false", "true" + unusedBit_247_15 = bits, U32, 976, [15:15], "false", "true" + unusedBit_247_16 = bits, U32, 976, [16:16], "false", "true" + unusedBit_247_17 = bits, U32, 976, [17:17], "false", "true" + unusedBit_247_18 = bits, U32, 976, [18:18], "false", "true" + unusedBit_247_19 = bits, U32, 976, [19:19], "false", "true" + unusedBit_247_20 = bits, U32, 976, [20:20], "false", "true" + unusedBit_247_21 = bits, U32, 976, [21:21], "false", "true" + unusedBit_247_22 = bits, U32, 976, [22:22], "false", "true" + unusedBit_247_23 = bits, U32, 976, [23:23], "false", "true" + unusedBit_247_24 = bits, U32, 976, [24:24], "false", "true" + unusedBit_247_25 = bits, U32, 976, [25:25], "false", "true" + unusedBit_247_26 = bits, U32, 976, [26:26], "false", "true" + unusedBit_247_27 = bits, U32, 976, [27:27], "false", "true" + unusedBit_247_28 = bits, U32, 976, [28:28], "false", "true" + unusedBit_247_29 = bits, U32, 976, [29:29], "false", "true" + unusedBit_247_30 = bits, U32, 976, [30:30], "false", "true" + unusedBit_247_31 = bits, U32, 976, [31:31], "false", "true" etbIo1_directionPin1 = bits, U08, 980, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PA16", "PA17", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PB16", "PB17", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PE16", "PE17", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16" etbIo1_directionPin2 = bits, U08, 981, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PA16", "PA17", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PB16", "PB17", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PE16", "PE17", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16" etbIo1_controlPin1 = bits, U08, 982, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PA16", "PA17", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PB16", "PB17", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PE16", "PE17", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16" @@ -1182,147 +1242,182 @@ page = 1 [OutputChannels] -; see TS_FILE_VERSION in firmware code -fileVersion = { 20190701 } +fileVersion = { 20191221 } ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 356 + ochBlockSize = 220 ; ; see TunerStudioOutputChannels struct ; - RPMValue = scalar, U32, 0, "RPM", 1, 0.00000 + +; Bit flags + hasSdCard = bits, U32, 0, [0:0], "true", "false"; + isIgnitionEnabledIndicator=bits,U32, 0, [1:1], "true", "false"; + ind_injection_enabled=bits,U32, 0, [2:2], "true", "false"; + isCylinderCleanupEnabled=bits,U32, 0, [3:3], "true", "false"; + isCylinderCleanupActivated=bits,U32, 0, [4:4], "true", "false"; + ind_fuel_pump = bits, U32, 0, [5:5], "true", "false"; + ind_fan = bits, U32, 0, [6:6], "true", "false"; + ind_o2_heater = bits, U32, 0, [7:7], "true", "false"; + ind_check_engine= bits, U32, 0, [8:8], "true", "false"; + needBurn = bits, U32, 0, [9:9], "true", "false"; + ind_2nd_trigger_en=bits, U32, 0, [10:10], "true", "false"; + clutchUpState =bits, U32, 0, [11:11], "true", "false"; + clutchDownState =bits, U32, 0, [12:12], "true", "false"; + knockEverIndicator=bits, U32, 0, [13:13], "true", "false"; + knockNowIndicator=bits, U32, 0, [14:14], "true", "false"; + brakePedalIndicator=bits, U32, 0, [15:15], "true", "false"; + toothLogReady =bits, U32, 0, [16:16], "true", "false"; + acSwitchIndicator =bits, U32, 0, [17:17], "true", "false"; + ind_tps_error = bits, U32, 0, [18:18], "true", "false"; + ind_clt_error = bits, U32, 0, [19:19], "true", "false"; + ind_map_error = bits, U32, 0, [20:21], "true", "false"; + ind_iat_error = bits, U32, 0, [21:22], "true", "false"; + ind_isTriggerError = bits, U32, 0, [23:23], "true", "false"; + ind_hasFatalError=bits, U32, 0, [24:24], "true", "false"; + ind_isWarnNow =bits, U32, 0, [25:25], "true", "false"; + +; RPM, vss + RPMValue = scalar, U16, 4, "RPM", 1, 0.00000 + rpmAcceleration = scalar, S16, 6, "dRpm",{1/100}, 0 + speedToRpmRatio = scalar, S16, 8, "value",{1/100}, 0 + vehicleSpeedKph = scalar, U08, 10, "kph", 1, 0.0 + +; temperatures + internalMcuTemperature = scalar,S08, 11, "deg C", 1, 0 #if CELSIUS - coolant = scalar, F32, 4, "deg C", 1, 0.0 + coolant = scalar, S16, 12, "deg C",{1/100}, 0.0 #else - coolant = scalar, F32, 4, "deg F", {9/5}, 17.77777 + coolant = scalar, S16, 12, "deg F",{9/(5 * 100)}, 17.77777 #endif #if CELSIUS - intake = scalar, F32, 8, "deg C", 1, 0.0 + intake = scalar, S16, 14, "deg C",{1/100}, 0.0 #else - intake = scalar, F32, 8, "deg F", {9/5}, 17.77777 + intake = scalar, S16, 14, "deg F",{9/(5 * 100)}, 17.77777 #endif - TPSValue = scalar, F32, 12, "%", 1, 0 - MAFValue = scalar, F32, 16, "V", 1, 0 - AFRValue = scalar, F32, 20, "AFR", 1, 0.0 - engineLoad = scalar, F32, 24, "%", 1, 0.0 ; Blend of MAP and TPS, depends on algorithm - VBatt = scalar, F32, 28, "V", 1, 0.0 +; todo: aux1 +; todo: aux2 + + +; throttle, pedal + TPSValue = scalar, U16, 20, "%",{1/100}, 0 + throttlePedalPosition = scalar,U16, 22, "%",{1/100}, 0 + tpsADC = scalar, U16, 24, "ADC", 1, 0.0; + +; air flow/mass measurments + MAFValue = scalar, U16, 26, "V",,{1/1000},, 0 + massAirFlowValue= scalar, U16, 28, "Kg/h", 0.01, 0 + MAPValue = scalar, U16, 30, "kPa",{1/30}, 0.0 + baroPressure = scalar, U16, 32, "kPa",{1/30}, 0.0 + AFRValue = scalar, U16, 34, "AFR",,{1/1000},, 0.0 + engineLoad = scalar, U16, 36, "%",{1/100}, 0.0 ; Blend of MAP and TPS, depends on algorithm + +; misc sensors + VBatt = scalar, U16, 38, "V",,{1/1000},, 0.0 + oilPressure = scalar, U16, 40, "kPa",{1/30}, 0.0 + vvtPosition = scalar, U16, 42, "deg",{1/50}, 0 + ; 10 bit TPS ADC value (from 0 to 1023 in 5v scale) - tpsADC = scalar, U16, 32, "ADC", 1, 0.0; - tpsADC2 = scalar, U16, 34, "ADC", 1, 0.0; - baroPressure = scalar, F32, 36, "pres", 1, 0.0; - MAPValue = scalar, F32, 40, "MAP", 1, 0.0; - ; total fuel squirt duration (in MS) per engine cycle according to current CLT - crankingFuelMs = scalar, F32, 44, "ms", 1, 0.0; - baseFuel = scalar, F32, 48, "ms", 1, 0 - tCharge = scalar, F32, 52, "T", 1, 0.0; - ignitionAdvance = scalar, F32, 56, "deg", 1, 0.0; - sparkDwellValue = scalar, F32, 60, "ms", 1, 0.0; - ; actual total Ms time per engine cycle with all corrections - actualLastInjection = scalar, F32, 64, "ms", 1, 0.0; - debugFloatField1 = scalar, F32, 68, "val", 1, 0.0; - - hasSdCard = bits, U32, 72, [0:0], "true", "false"; - isIgnitionEnabledIndicator=bits, U32, 72, [1:1], "true", "false"; - ind_injection_enabled=bits,U32, 72, [2:2], "true", "false"; - isCylinderCleanupEnabled=bits, U32, 72, [3:3], "true", "false"; - isCylinderCleanupActivated=bits,U32,72, [4:4], "true", "false"; - ind_fuel_pump = bits, U32, 72, [5:5], "true", "false"; - ind_fan = bits, U32, 72, [6:6], "true", "false"; - ind_o2_heater = bits, U32, 72, [7:7], "true", "false"; - ind_check_engine= bits, U32, 72, [8:8], "true", "false"; - needBurn = bits, U32, 72, [9:9], "true", "false"; - ind_2nd_trigger_en=bits, U32, 72, [10:10], "true", "false"; - clutchUpState =bits, U32, 72, [11:11], "true", "false"; - clutchDownState =bits, U32, 72, [12:12], "true", "false"; - knockEverIndicator=bits, U32, 72, [13:13], "true", "false"; - knockNowIndicator=bits, U32, 72, [14:14], "true", "false"; - brakePedalIndicator=bits, U32, 72, [15:15], "true", "false"; - toothLogReady =bits, U32, 72, [16:16], "true", "false"; - acSwitchIndicator =bits, U32, 72, [17:17], "true", "false"; - vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0; - - ind_tps_error = bits, U32, 80, [0:0], "true", "false"; - ind_clt_error = bits, U32, 80, [1:1], "true", "false"; - ind_map_error = bits, U32, 80, [2:2], "true", "false"; - ind_iat_error = bits, U32, 80, [3:3], "true", "false"; - ind_isTriggerError = bits, U32, 80, [5:5], "true", "false"; - ind_hasFatalError=bits, U32, 80, [6:6], "true", "false"; - ind_isWarnNow =bits, U32, 80, [7:7], "true", "false"; - firmwareTsVersion = scalar,U32, 84, "version_p", 1, 0 - egt1 = scalar, S16, 88, "deg C", 1, 0 - egt2 = scalar, S16, 90, "deg C", 1, 0 - egt3 = scalar, S16, 92, "deg C", 1, 0 - egt4 = scalar, S16, 94, "deg C", 1, 0 - egt5 = scalar, S16, 96, "deg C", 1, 0 - egt6 = scalar, S16, 98, "deg C", 1, 0 - egt7 = scalar, S16, 100, "deg C", 1, 0 - egt8 = scalar, S16, 102, "deg C", 1, 0 - rpmAcceleration = scalar, F32, 104, "dRpm", 1, 0 - massAirFlowValue= scalar, F32, 108, "Kg/h", 1, 0 - veValue = scalar, F32, 112, "ratio", 1, 0 - deltaTps = scalar, F32, 116, "ratio", 1, 0 - triggerErrorsCounter = scalar, U32,120, "counter", 1, 0 - engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0 - tpsAccelFuel = scalar, F32, 128, "ms", 1, 0 - baroCorrection = scalar, F32, 132, "%", 1, 0 - throttlePedalPosition = scalar, F32, 136, "%", 1, 0 - injectorDutyCycle= scalar, F32, 140, "%", 1, 0 - knockCount = scalar, U32, 144, "counter", 1, 0 - fuelTankLevel = scalar, F32, 148, "amount", 1, 0 - knockLevel = scalar, F32, 152, "Volts", 1, 0 - ; totalTriggerErrorCounter 156 - wallFuelAmount = scalar, F32, 160, "ms", 1, 0 - iatCorrection = scalar, F32, 164, "%", 1, 0 - wallFuelCorrection = scalar, F32, 168, "ms", 1, 0 - idleAirValvePosition = scalar, F32, 172, "percent", 1, 0 - currentTargetAfr = scalar, F32, 176, "ratio", 1, 0 - chargeAirMass = scalar, F32, 180, "g", 1, 0 - cltCorrection = scalar, F32, 184, "%", 1, 0 - fuelRunning = scalar, F32, 188, "g", 1, 0 - debugIntField1 = scalar, S32, 192, "val", 1, 0.0; - injectorLagMs = scalar, F32, 196, "ms", 1, 0.0; - debugFloatField2 = scalar, F32, 200, "val", 1, 0.0; - debugFloatField3 = scalar, F32, 204, "val", 1, 0.0; - debugFloatField4 = scalar, F32, 208, "val", 1, 0.0; - debugFloatField5 = scalar, F32, 212, "val", 1, 0.0; - debugIntField2 = scalar, S32, 216, "val", 1, 0.0; - debugIntField3 = scalar, S32, 220, "val", 1, 0.0; - timeSeconds = scalar, U32, 224, "sec", 1, 0.0; - engineLoadDelta = scalar,F32, 228, "value", 1, 0 - speedToRpmRatio = scalar,F32, 232, "value", 1, 0 - warningCounter = scalar,U16, 236, "count", 1, 0 - - lastErrorCode = scalar,U16, 240, "error", 1, 0 - - internalMcuTemperature = scalar,F32, 244, "C", 1, 0 - vvtPosition = scalar,F32, 248, "deg", 1, 0 - engineMode = scalar, U32, 252, "em", 1, 0.0; - debugFloatField6 = scalar, F32, 256, "val", 1, 0.0; - debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; - firmwareVersion = scalar,U32, 264, "version_f", 1, 0 - fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 - coilDutyCycle = scalar, F32, 272, "perc", 1, 0 - accelerationX = scalar, S16, 276, "G", 0.01, 0 - accelerationY = scalar, S16, 278, "G", 0.01, 0 - oilPressure = scalar, F32, 280, "kPa", 1, 0.0 - fuelConsumptionPerHour=scalar, F32, 284, "kPa", 1, 0.0 - injectionOffset = scalar, F32, 288, "deg", 1, 0; - debugIntField4 = scalar, S16, 292, "val", 1, 0.0; - debugIntField5 = scalar, S16, 294, "val", 1, 0.0; - recentErrorCode0 = scalar,U16, 296, "error", 1, 0 - recentErrorCode1 = scalar,U16, 298, "error", 1, 0 - recentErrorCode2 = scalar,U16, 300, "error", 1, 0 - recentErrorCode3 = scalar,U16, 302, "error", 1, 0 - recentErrorCode4 = scalar,U16, 304, "error", 1, 0 - recentErrorCode5 = scalar,U16, 306, "error", 1, 0 - recentErrorCode6 = scalar,U16, 308, "error", 1, 0 - recentErrorCode7 = scalar,U16, 310, "error", 1, 0 - etbTarget = scalar,F32, 312, "%", 1, 0 - etb1DutyCycle = scalar,F32, 316, "%", 1, 0 - etb1Error = scalar,F32, 320, "%", 1, 0 + ;tpsADC2 = scalar, U16, 44, "ADC", 1, 0.0; + +; fuel math + chargeAirMass = scalar, U16, 44, "g",0.001, 0 + crankingFuelMs = scalar, U16, 46, "ms",{1/300}, 0.0 + currentTargetAfr= scalar, U16, 48, "ratio",,{1/1000},, 0 + baseFuel = scalar, U16, 50, "ms",{1/300}, 0 + fuelRunning = scalar, U16, 52, "ms",{1/300}, 0 + actualLastInjection=scalar,U16, 54, "ms",{1/300}, 0.0 + injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0 + veValue = scalar, U08, 57, "ratio", 0.5, 0 + injectionOffset = scalar, S16, 58, "deg",{1/50}, 0 + tCharge = scalar, U16, 60, "deg C",{1/100}, 0.0 + +; Corrections + injectorLagMs = scalar, U16, 62, "ms",{1/300}, 0.0 + iatCorrection = scalar, U16, 64, "%",{1/100}, 0 + cltCorrection = scalar, U16, 66, "%",{1/100}, 0 + baroCorrection = scalar, U16, 68, "%",{1/100}, 0 + fuelPidCorrection=scalar, S16, 70, "ms",{1/300}, 0 + +; Wall model AE + wallFuelAmount = scalar, U16, 72, "ms",{1/300}, 0 + wallFuelCorrection=scalar, S16, 74, "ms",0.001, 0 + +; TPS/load AE + engineLoadDelta = scalar, S16, 76, "value",{1/100}, 0 + deltaTps = scalar, S16, 78, "ratio",{1/100}, 0 + engineLoadAccelExtra=scalar,S16, 80, "value",{1/100}, 0 + tpsAccelFuel = scalar, U16, 82, "ms",{1/300}, 0 + +; Ignition + ignitionAdvance = scalar, U16, 84, "deg",{1/50}, 0.0 + sparkDwellValue = scalar, U16, 86, "ms",{1/300}, 0.0 + coilDutyCycle = scalar, U16, 88, "%",{1/100}, 0 + +; Idle & ETB + idleAirValvePosition=scalar,S16, 90, "%",{1/100}, 0 + etbTarget = scalar, S16, 92, "%",{1/100}, 0 + etb1DutyCycle = scalar, S16, 94, "%",{1/100}, 0 + etb1Error = scalar, S16, 96, "%",{1/100}, 0 + +; Fuel system + fuelTankLevel = scalar, S16, 98, "amount",{1/100}, 0 + fuelConsumptionPerHour=scalar,F32, 100, "kPa", 1, 0.0 + +; Knock + knockCount = scalar, U32, 104,"counter", 1, 0 + knockLevel = scalar, F32, 108, "Volts", 1, 0 + +; Mode, firmware, protocol, run time + timeSeconds = scalar, U32, 112, "sec", 1, 0.0 + engineMode = scalar, U32, 116, "em", 1, 0.0; + firmwareVersion = scalar, U32, 120,"version_f", 1, 0 + firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0 + +; Errors + triggerErrorsCounter=scalar,U32, 128,"counter", 1, 0 + ; totalTriggerErrorCounter 132 + warningCounter = scalar, U16, 136, "count", 1, 0 + lastErrorCode = scalar, U16, 138, "error", 1, 0 + recentErrorCode0= scalar, U16, 140, "error", 1, 0 + recentErrorCode1= scalar, U16, 142, "error", 1, 0 + recentErrorCode2= scalar, U16, 144, "error", 1, 0 + recentErrorCode3= scalar, U16, 146, "error", 1, 0 + recentErrorCode4= scalar, U16, 148, "error", 1, 0 + recentErrorCode5= scalar, U16, 150, "error", 1, 0 + recentErrorCode6= scalar, U16, 152, "error", 1, 0 + recentErrorCode7= scalar, U16, 154, "error", 1, 0 + +; Debug + debugFloatField1= scalar, F32, 156, "val", 1, 0.0 + debugFloatField2= scalar, F32, 160, "val", 1, 0.0 + debugFloatField3= scalar, F32, 164, "val", 1, 0.0 + debugFloatField4= scalar, F32, 168, "val", 1, 0.0 + debugFloatField5= scalar, F32, 172, "val", 1, 0.0 + debugFloatField6= scalar, F32, 176, "val", 1, 0.0 + debugFloatField7= scalar, F32, 180, "val", 1, 0.0 + debugIntField1 = scalar, S32, 184, "val", 1, 0.0 + debugIntField2 = scalar, S32, 188, "val", 1, 0.0 + debugIntField3 = scalar, S32, 192, "val", 1, 0.0 + debugIntField4 = scalar, S16, 196, "val", 1, 0.0 + debugIntField5 = scalar, S16, 198, "val", 1, 0.0 + +; Accel + accelerationX = scalar, S16, 200, "G", 0.01, 0 + accelerationY = scalar, S16, 202, "G", 0.01, 0 + +; egt + egt1 = scalar, S16, 204, "deg C", 1, 0 + egt2 = scalar, S16, 206, "deg C", 1, 0 + egt3 = scalar, S16, 208, "deg C", 1, 0 + egt4 = scalar, S16, 210, "deg C", 1, 0 + egt5 = scalar, S16, 212, "deg C", 1, 0 + egt6 = scalar, S16, 214, "deg C", 1, 0 + egt7 = scalar, S16, 216, "deg C", 1, 0 + egt8 = scalar, S16, 218, "deg C", 1, 0 ; @@ -1344,6 +1439,10 @@ fileVersion = { 20190701 } wueAfrTargetOffset = array, S16, [ 16], ":1", 0.1, 0.0, -3.0, 3.0, 1; wueAnalRecommend = array, U08, [ 16], "%", 1.00, 0.0, 100, 255.00, 0 +; These are inverted (false = "Yes") so that they default to enabled + enableLogDebugChannels = bits, U08, [0:0], "Yes", "No" + enableLogErrorList = bits, U08, [0:0], "Yes", "No" + [ConstantsExtensions] defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 @@ -2004,16 +2103,16 @@ gaugeCategory = Throttle Body (incl. ETB) entry = coilDutyCycle, "dwell: coil duty cycle", float,"%.3f" entry = currentTargetAfr,"fuel: target AFR", float,"%.3f" - entry = accelerationX, "Acceleration: X", float,"%.2f" - entry = accelerationY, "Acceleration: Y", float,"%.2f" - entry = egt1, "EGT1", float,"%.1f" - entry = egt2, "EGT2", float,"%.1f" - entry = egt3, "EGT3", float,"%.1f" - entry = egt4, "EGT4", float,"%.1f" - entry = egt5, "EGT5", float,"%.1f" - entry = egt6, "EGT6", float,"%.1f" - entry = egt7, "EGT7", float,"%.1f" - entry = egt8, "EGT8", float,"%.1f" + entry = accelerationX, "Acceleration: X", float,"%.2f", { LIS302DLCsPin != 0 } + entry = accelerationY, "Acceleration: Y", float,"%.2f", { LIS302DLCsPin != 0 } + entry = egt1, "EGT1", float,"%.1f", { max31855_cs1 != 0} + entry = egt2, "EGT2", float,"%.1f", { max31855_cs2 != 0} + entry = egt3, "EGT3", float,"%.1f", { max31855_cs3 != 0} + entry = egt4, "EGT4", float,"%.1f", { max31855_cs4 != 0} + entry = egt5, "EGT5", float,"%.1f", { max31855_cs5 != 0} + entry = egt6, "EGT6", float,"%.1f", { max31855_cs6 != 0} + entry = egt7, "EGT7", float,"%.1f", { max31855_cs7 != 0} + entry = egt8, "EGT8", float,"%.1f", { max31855_cs8 != 0} entry = engineLoadAccelExtra, "fuel: engine load acceleration extra fuel",float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f" @@ -2035,54 +2134,54 @@ gaugeCategory = Throttle Body (incl. ETB) ; is there a way to log parameter? entry = debugMode, "debugMode",int,"%d" ; Alternator_PID: alternator duty cycle ; DBG_TPS_ACCEL: from TPS - entry = debugFloatField1, "debug f1",float,"%.4f" + entry = debugFloatField1, "debug f1",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: current integration term ; DBG_TPS_ACCEL: to TPS - entry = debugFloatField2, "debug f2: iTerm",float,"%.4f" + entry = debugFloatField2, "debug f2: iTerm",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: previous error ; DBG_TPS_ACCEL: tps<>tps table value - entry = debugFloatField3, "debug f3: prevError",float,"%.4f" + entry = debugFloatField3, "debug f3: prevError",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: I setting ; DBG_TPS_ACCEL: extra fuel - entry = debugFloatField4, "debug f4: iParam",float,"%.4f" + entry = debugFloatField4, "debug f4: iParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: D setting - entry = debugFloatField5, "debug f5: dParam",float,"%.4f" + entry = debugFloatField5, "debug f5: dParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: dTerm - entry = debugFloatField6, "debug f6: dTerm",float,"%.4f" + entry = debugFloatField6, "debug f6: dTerm",float,"%.4f", { !enableLogDebugChannels } - entry = debugFloatField7, "debug f7",float,"%.4f" + entry = debugFloatField7, "debug f7",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: P setting - entry = debugIntField1, "debug i1: pParam",int,"%d" + entry = debugIntField1, "debug i1: pParam",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: offset setting - entry = debugIntField2, "debug i2: offset",int,"%d" + entry = debugIntField2, "debug i2: offset",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: PID reset counter - entry = debugIntField3, "debug i3",int,"%d" + entry = debugIntField3, "debug i3",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField4, "debug i4",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField5, "debug i5",int,"%d", { !enableLogDebugChannels } - entry = debugIntField4, "debug i4",int,"%d" - entry = debugIntField5, "debug i5",int,"%d" - - entry = engineMode, "Engine Mode",int,"%d" entry = warningCounter, "warning: counter",int,"%d" entry = lastErrorCode, "warning: last",int,"%d" - entry = recentErrorCode0, "error 0",int,"%d" - entry = recentErrorCode1, "error 1",int,"%d" - entry = recentErrorCode2, "error 2",int,"%d" - entry = recentErrorCode3, "error 3",int,"%d" - entry = recentErrorCode4, "error 4",int,"%d" - entry = recentErrorCode5, "error 5",int,"%d" - entry = recentErrorCode6, "error 6",int,"%d" - entry = recentErrorCode7, "error 7",int,"%d" + entry = recentErrorCode0, "error 0",int,"%d", { !enableLogErrorList } + entry = recentErrorCode1, "error 1",int,"%d", { !enableLogErrorList } + entry = recentErrorCode2, "error 2",int,"%d", { !enableLogErrorList } + entry = recentErrorCode3, "error 3",int,"%d", { !enableLogErrorList } + entry = recentErrorCode4, "error 4",int,"%d", { !enableLogErrorList } + entry = recentErrorCode5, "error 5",int,"%d", { !enableLogErrorList } + entry = recentErrorCode6, "error 6",int,"%d", { !enableLogErrorList } + entry = recentErrorCode7, "error 7",int,"%d", { !enableLogErrorList } entry = internalMcuTemperature, "CPU Temperature",float,"%.2f" entry = tCharge, "tCharge",float,"%.3f" @@ -2258,6 +2357,7 @@ menuDialog = main menu = "&Controller" subMenu = ecuStimulator, "ECU stimulator" + subMenu = datalogSettings, "Datalogging" subMenu = ioTest, "Bench test" subMenu = engineTypeDialog, "Popular vehicles" subMenu = std_separator @@ -2678,13 +2778,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "Idle Stepper Enable", stepperEnablePin field = "Fuel Pump Pin", fuelPumpPin field = "Fuel Pump Pin Mode", fuelPumpPinMode - field = "ETB#1 Dir #1", etb1_directionPin1 - field = "ETB#1 Dir #2", etb1_directionPin2 - field = "ETB#1 Control #1", etb1_controlPin1 - field = "etb1_controlPinMode", etb1_controlPinMode - field = "ETB#2 Dir #1", etb2_directionPin1 - field = "ETB#2 Dir #2", etb2_directionPin2 - field = "ETB#2 Control #1", etb2_controlPin1 + field = "ETB#1 Dir #1", etbIo1_directionPin1 + field = "ETB#1 Dir #2", etbIo1_directionPin2 + field = "ETB#1 Control #1", etbIo1_controlPin1 + field = "etb1_controlPinMode", etbIo1_controlPinMode + field = "ETB#2 Dir #1", etbIo2_directionPin1 + field = "ETB#2 Dir #2", etbIo2_directionPin2 + field = "ETB#2 Control #1", etbIo2_controlPin1 field = "SD CS Pin", sdCardCsPin field = "MIL / Check Engine Pin", malfunctionIndicatorPin field = "MIL / Check Engine Pin Mode", malfunctionIndicatorPinMode @@ -3531,7 +3631,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "No1 Control #1", etbIo1_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "No2 Direction #1", etbIo2_directionPin1, {throttlePedalPositionAdcChannel != 16} field = "No2 Direction #2", etbIo2_directionPin2, {throttlePedalPositionAdcChannel != 16} - field = "No2 Control #1", etb2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} + field = "No2 Control #1", etbIo2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "TPS#2 min", tps2Min, {etbIo2_directionPin1 != 0} field = "TPS#2 max", tps2Max, {etbIo2_directionPin1 != 0} panel = etbPidDialog @@ -3632,6 +3732,11 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "" field = "Engine chart size", engineChartSize + dialog = datalogSettings, "Datalogging Settings" + field = "#Disabling optional logging may increase update rate!" + field = "Log debug channels", enableLogDebugChannels + field = "Log recent errors list", enableLogErrorList + ; Racing Features->Launch Control dialog = smLaunchControl, "Launch Control Settings NOT WORKING" field = "RPM Step1 Limit", step1rpm diff --git a/firmware/tunerstudio/rusefi_microrusefi.ini b/firmware/tunerstudio/rusefi_microrusefi.ini index fe06e7febc..588553923a 100644 --- a/firmware/tunerstudio/rusefi_microrusefi.ini +++ b/firmware/tunerstudio/rusefi_microrusefi.ini @@ -44,7 +44,7 @@ enable2ndByteCanID = false [TunerStudio] queryCommand = "S" versionInfo = "V" ; firmwave version for title bar. - signature = "rusEFI v1.07" ; signature is expected to be 7 or more characters. + signature = "rusEFI v1.08" ; signature is expected to be 7 or more characters. [Constants] ; new packet serial format with CRC @@ -85,7 +85,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Dec 08 00:32:31 EST 2019 +; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Dec 25 15:54:43 EST 2019 pageSize = 20000 page = 1 @@ -125,6 +125,7 @@ page = 1 issue_294_29 = bits, U32, 76, [28:28], "false", "true" issue_294_30 = bits, U32, 76, [29:29], "false", "true" issue_294_31 = bits, U32, 76, [30:30], "false", "true" + unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true" tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0 tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0 tpsErrorDetectionTooLow = scalar, S16, 84, "%", 1, 0, -40, 200, 0 @@ -207,6 +208,35 @@ page = 1 trigger_unusedCustomIsSynchronizationNeeded= bits, U32, 528, [0:0], "false", "true" trigger_unusedCustomNeedSecondTriggerInput= bits, U32, 528, [1:1], "false", "true" trigger_useOnlyFirstChannel= bits, U32, 528, [2:2], "false", "true" + trigger_unusedBit_4_3 = bits, U32, 528, [3:3], "false", "true" + trigger_unusedBit_4_4 = bits, U32, 528, [4:4], "false", "true" + trigger_unusedBit_4_5 = bits, U32, 528, [5:5], "false", "true" + trigger_unusedBit_4_6 = bits, U32, 528, [6:6], "false", "true" + trigger_unusedBit_4_7 = bits, U32, 528, [7:7], "false", "true" + trigger_unusedBit_4_8 = bits, U32, 528, [8:8], "false", "true" + trigger_unusedBit_4_9 = bits, U32, 528, [9:9], "false", "true" + trigger_unusedBit_4_10 = bits, U32, 528, [10:10], "false", "true" + trigger_unusedBit_4_11 = bits, U32, 528, [11:11], "false", "true" + trigger_unusedBit_4_12 = bits, U32, 528, [12:12], "false", "true" + trigger_unusedBit_4_13 = bits, U32, 528, [13:13], "false", "true" + trigger_unusedBit_4_14 = bits, U32, 528, [14:14], "false", "true" + trigger_unusedBit_4_15 = bits, U32, 528, [15:15], "false", "true" + trigger_unusedBit_4_16 = bits, U32, 528, [16:16], "false", "true" + trigger_unusedBit_4_17 = bits, U32, 528, [17:17], "false", "true" + trigger_unusedBit_4_18 = bits, U32, 528, [18:18], "false", "true" + trigger_unusedBit_4_19 = bits, U32, 528, [19:19], "false", "true" + trigger_unusedBit_4_20 = bits, U32, 528, [20:20], "false", "true" + trigger_unusedBit_4_21 = bits, U32, 528, [21:21], "false", "true" + trigger_unusedBit_4_22 = bits, U32, 528, [22:22], "false", "true" + trigger_unusedBit_4_23 = bits, U32, 528, [23:23], "false", "true" + trigger_unusedBit_4_24 = bits, U32, 528, [24:24], "false", "true" + trigger_unusedBit_4_25 = bits, U32, 528, [25:25], "false", "true" + trigger_unusedBit_4_26 = bits, U32, 528, [26:26], "false", "true" + trigger_unusedBit_4_27 = bits, U32, 528, [27:27], "false", "true" + trigger_unusedBit_4_28 = bits, U32, 528, [28:28], "false", "true" + trigger_unusedBit_4_29 = bits, U32, 528, [29:29], "false", "true" + trigger_unusedBit_4_30 = bits, U32, 528, [30:30], "false", "true" + trigger_unusedBit_4_31 = bits, U32, 528, [31:31], "false", "true" trigger_customTotalToothCount = scalar, S32, 532, "number", 1, 0.0, 0, 500.0, 0 trigger_customSkippedToothCount = scalar, S32, 536, "number", 1, 0.0, 0, 500.0, 0 hip9011SpiDevice = bits,U32, 540, [0:7], "Off", "SPI1", "SPI2", "SPI3", "SPI4" @@ -502,6 +532,36 @@ page = 1 ;no TS info - skipping unused offset 972 todoClutchUpPinInverted = bits, U32, 976, [0:0], "false", "true" todoClutchDownPinInverted= bits, U32, 976, [1:1], "false", "true" + unusedBit_247_2 = bits, U32, 976, [2:2], "false", "true" + unusedBit_247_3 = bits, U32, 976, [3:3], "false", "true" + unusedBit_247_4 = bits, U32, 976, [4:4], "false", "true" + unusedBit_247_5 = bits, U32, 976, [5:5], "false", "true" + unusedBit_247_6 = bits, U32, 976, [6:6], "false", "true" + unusedBit_247_7 = bits, U32, 976, [7:7], "false", "true" + unusedBit_247_8 = bits, U32, 976, [8:8], "false", "true" + unusedBit_247_9 = bits, U32, 976, [9:9], "false", "true" + unusedBit_247_10 = bits, U32, 976, [10:10], "false", "true" + unusedBit_247_11 = bits, U32, 976, [11:11], "false", "true" + unusedBit_247_12 = bits, U32, 976, [12:12], "false", "true" + unusedBit_247_13 = bits, U32, 976, [13:13], "false", "true" + unusedBit_247_14 = bits, U32, 976, [14:14], "false", "true" + unusedBit_247_15 = bits, U32, 976, [15:15], "false", "true" + unusedBit_247_16 = bits, U32, 976, [16:16], "false", "true" + unusedBit_247_17 = bits, U32, 976, [17:17], "false", "true" + unusedBit_247_18 = bits, U32, 976, [18:18], "false", "true" + unusedBit_247_19 = bits, U32, 976, [19:19], "false", "true" + unusedBit_247_20 = bits, U32, 976, [20:20], "false", "true" + unusedBit_247_21 = bits, U32, 976, [21:21], "false", "true" + unusedBit_247_22 = bits, U32, 976, [22:22], "false", "true" + unusedBit_247_23 = bits, U32, 976, [23:23], "false", "true" + unusedBit_247_24 = bits, U32, 976, [24:24], "false", "true" + unusedBit_247_25 = bits, U32, 976, [25:25], "false", "true" + unusedBit_247_26 = bits, U32, 976, [26:26], "false", "true" + unusedBit_247_27 = bits, U32, 976, [27:27], "false", "true" + unusedBit_247_28 = bits, U32, 976, [28:28], "false", "true" + unusedBit_247_29 = bits, U32, 976, [29:29], "false", "true" + unusedBit_247_30 = bits, U32, 976, [30:30], "false", "true" + unusedBit_247_31 = bits, U32, 976, [31:31], "false", "true" etbIo1_directionPin1 = bits, U08, 980, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_directionPin2 = bits, U08, 981, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_controlPin1 = bits, U08, 982, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" @@ -1182,147 +1242,182 @@ page = 1 [OutputChannels] -; see TS_FILE_VERSION in firmware code -fileVersion = { 20190701 } +fileVersion = { 20191221 } ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 356 + ochBlockSize = 220 ; ; see TunerStudioOutputChannels struct ; - RPMValue = scalar, U32, 0, "RPM", 1, 0.00000 + +; Bit flags + hasSdCard = bits, U32, 0, [0:0], "true", "false"; + isIgnitionEnabledIndicator=bits,U32, 0, [1:1], "true", "false"; + ind_injection_enabled=bits,U32, 0, [2:2], "true", "false"; + isCylinderCleanupEnabled=bits,U32, 0, [3:3], "true", "false"; + isCylinderCleanupActivated=bits,U32, 0, [4:4], "true", "false"; + ind_fuel_pump = bits, U32, 0, [5:5], "true", "false"; + ind_fan = bits, U32, 0, [6:6], "true", "false"; + ind_o2_heater = bits, U32, 0, [7:7], "true", "false"; + ind_check_engine= bits, U32, 0, [8:8], "true", "false"; + needBurn = bits, U32, 0, [9:9], "true", "false"; + ind_2nd_trigger_en=bits, U32, 0, [10:10], "true", "false"; + clutchUpState =bits, U32, 0, [11:11], "true", "false"; + clutchDownState =bits, U32, 0, [12:12], "true", "false"; + knockEverIndicator=bits, U32, 0, [13:13], "true", "false"; + knockNowIndicator=bits, U32, 0, [14:14], "true", "false"; + brakePedalIndicator=bits, U32, 0, [15:15], "true", "false"; + toothLogReady =bits, U32, 0, [16:16], "true", "false"; + acSwitchIndicator =bits, U32, 0, [17:17], "true", "false"; + ind_tps_error = bits, U32, 0, [18:18], "true", "false"; + ind_clt_error = bits, U32, 0, [19:19], "true", "false"; + ind_map_error = bits, U32, 0, [20:21], "true", "false"; + ind_iat_error = bits, U32, 0, [21:22], "true", "false"; + ind_isTriggerError = bits, U32, 0, [23:23], "true", "false"; + ind_hasFatalError=bits, U32, 0, [24:24], "true", "false"; + ind_isWarnNow =bits, U32, 0, [25:25], "true", "false"; + +; RPM, vss + RPMValue = scalar, U16, 4, "RPM", 1, 0.00000 + rpmAcceleration = scalar, S16, 6, "dRpm",{1/100}, 0 + speedToRpmRatio = scalar, S16, 8, "value",{1/100}, 0 + vehicleSpeedKph = scalar, U08, 10, "kph", 1, 0.0 + +; temperatures + internalMcuTemperature = scalar,S08, 11, "deg C", 1, 0 #if CELSIUS - coolant = scalar, F32, 4, "deg C", 1, 0.0 + coolant = scalar, S16, 12, "deg C",{1/100}, 0.0 #else - coolant = scalar, F32, 4, "deg F", {9/5}, 17.77777 + coolant = scalar, S16, 12, "deg F",{9/(5 * 100)}, 17.77777 #endif #if CELSIUS - intake = scalar, F32, 8, "deg C", 1, 0.0 + intake = scalar, S16, 14, "deg C",{1/100}, 0.0 #else - intake = scalar, F32, 8, "deg F", {9/5}, 17.77777 + intake = scalar, S16, 14, "deg F",{9/(5 * 100)}, 17.77777 #endif - TPSValue = scalar, F32, 12, "%", 1, 0 - MAFValue = scalar, F32, 16, "V", 1, 0 - AFRValue = scalar, F32, 20, "AFR", 1, 0.0 - engineLoad = scalar, F32, 24, "%", 1, 0.0 ; Blend of MAP and TPS, depends on algorithm - VBatt = scalar, F32, 28, "V", 1, 0.0 +; todo: aux1 +; todo: aux2 + + +; throttle, pedal + TPSValue = scalar, U16, 20, "%",{1/100}, 0 + throttlePedalPosition = scalar,U16, 22, "%",{1/100}, 0 + tpsADC = scalar, U16, 24, "ADC", 1, 0.0; + +; air flow/mass measurments + MAFValue = scalar, U16, 26, "V",,{1/1000},, 0 + massAirFlowValue= scalar, U16, 28, "Kg/h", 0.01, 0 + MAPValue = scalar, U16, 30, "kPa",{1/30}, 0.0 + baroPressure = scalar, U16, 32, "kPa",{1/30}, 0.0 + AFRValue = scalar, U16, 34, "AFR",,{1/1000},, 0.0 + engineLoad = scalar, U16, 36, "%",{1/100}, 0.0 ; Blend of MAP and TPS, depends on algorithm + +; misc sensors + VBatt = scalar, U16, 38, "V",,{1/1000},, 0.0 + oilPressure = scalar, U16, 40, "kPa",{1/30}, 0.0 + vvtPosition = scalar, U16, 42, "deg",{1/50}, 0 + ; 10 bit TPS ADC value (from 0 to 1023 in 5v scale) - tpsADC = scalar, U16, 32, "ADC", 1, 0.0; - tpsADC2 = scalar, U16, 34, "ADC", 1, 0.0; - baroPressure = scalar, F32, 36, "pres", 1, 0.0; - MAPValue = scalar, F32, 40, "MAP", 1, 0.0; - ; total fuel squirt duration (in MS) per engine cycle according to current CLT - crankingFuelMs = scalar, F32, 44, "ms", 1, 0.0; - baseFuel = scalar, F32, 48, "ms", 1, 0 - tCharge = scalar, F32, 52, "T", 1, 0.0; - ignitionAdvance = scalar, F32, 56, "deg", 1, 0.0; - sparkDwellValue = scalar, F32, 60, "ms", 1, 0.0; - ; actual total Ms time per engine cycle with all corrections - actualLastInjection = scalar, F32, 64, "ms", 1, 0.0; - debugFloatField1 = scalar, F32, 68, "val", 1, 0.0; - - hasSdCard = bits, U32, 72, [0:0], "true", "false"; - isIgnitionEnabledIndicator=bits, U32, 72, [1:1], "true", "false"; - ind_injection_enabled=bits,U32, 72, [2:2], "true", "false"; - isCylinderCleanupEnabled=bits, U32, 72, [3:3], "true", "false"; - isCylinderCleanupActivated=bits,U32,72, [4:4], "true", "false"; - ind_fuel_pump = bits, U32, 72, [5:5], "true", "false"; - ind_fan = bits, U32, 72, [6:6], "true", "false"; - ind_o2_heater = bits, U32, 72, [7:7], "true", "false"; - ind_check_engine= bits, U32, 72, [8:8], "true", "false"; - needBurn = bits, U32, 72, [9:9], "true", "false"; - ind_2nd_trigger_en=bits, U32, 72, [10:10], "true", "false"; - clutchUpState =bits, U32, 72, [11:11], "true", "false"; - clutchDownState =bits, U32, 72, [12:12], "true", "false"; - knockEverIndicator=bits, U32, 72, [13:13], "true", "false"; - knockNowIndicator=bits, U32, 72, [14:14], "true", "false"; - brakePedalIndicator=bits, U32, 72, [15:15], "true", "false"; - toothLogReady =bits, U32, 72, [16:16], "true", "false"; - acSwitchIndicator =bits, U32, 72, [17:17], "true", "false"; - vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0; - - ind_tps_error = bits, U32, 80, [0:0], "true", "false"; - ind_clt_error = bits, U32, 80, [1:1], "true", "false"; - ind_map_error = bits, U32, 80, [2:2], "true", "false"; - ind_iat_error = bits, U32, 80, [3:3], "true", "false"; - ind_isTriggerError = bits, U32, 80, [5:5], "true", "false"; - ind_hasFatalError=bits, U32, 80, [6:6], "true", "false"; - ind_isWarnNow =bits, U32, 80, [7:7], "true", "false"; - firmwareTsVersion = scalar,U32, 84, "version_p", 1, 0 - egt1 = scalar, S16, 88, "deg C", 1, 0 - egt2 = scalar, S16, 90, "deg C", 1, 0 - egt3 = scalar, S16, 92, "deg C", 1, 0 - egt4 = scalar, S16, 94, "deg C", 1, 0 - egt5 = scalar, S16, 96, "deg C", 1, 0 - egt6 = scalar, S16, 98, "deg C", 1, 0 - egt7 = scalar, S16, 100, "deg C", 1, 0 - egt8 = scalar, S16, 102, "deg C", 1, 0 - rpmAcceleration = scalar, F32, 104, "dRpm", 1, 0 - massAirFlowValue= scalar, F32, 108, "Kg/h", 1, 0 - veValue = scalar, F32, 112, "ratio", 1, 0 - deltaTps = scalar, F32, 116, "ratio", 1, 0 - triggerErrorsCounter = scalar, U32,120, "counter", 1, 0 - engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0 - tpsAccelFuel = scalar, F32, 128, "ms", 1, 0 - baroCorrection = scalar, F32, 132, "%", 1, 0 - throttlePedalPosition = scalar, F32, 136, "%", 1, 0 - injectorDutyCycle= scalar, F32, 140, "%", 1, 0 - knockCount = scalar, U32, 144, "counter", 1, 0 - fuelTankLevel = scalar, F32, 148, "amount", 1, 0 - knockLevel = scalar, F32, 152, "Volts", 1, 0 - ; totalTriggerErrorCounter 156 - wallFuelAmount = scalar, F32, 160, "ms", 1, 0 - iatCorrection = scalar, F32, 164, "%", 1, 0 - wallFuelCorrection = scalar, F32, 168, "ms", 1, 0 - idleAirValvePosition = scalar, F32, 172, "percent", 1, 0 - currentTargetAfr = scalar, F32, 176, "ratio", 1, 0 - chargeAirMass = scalar, F32, 180, "g", 1, 0 - cltCorrection = scalar, F32, 184, "%", 1, 0 - fuelRunning = scalar, F32, 188, "g", 1, 0 - debugIntField1 = scalar, S32, 192, "val", 1, 0.0; - injectorLagMs = scalar, F32, 196, "ms", 1, 0.0; - debugFloatField2 = scalar, F32, 200, "val", 1, 0.0; - debugFloatField3 = scalar, F32, 204, "val", 1, 0.0; - debugFloatField4 = scalar, F32, 208, "val", 1, 0.0; - debugFloatField5 = scalar, F32, 212, "val", 1, 0.0; - debugIntField2 = scalar, S32, 216, "val", 1, 0.0; - debugIntField3 = scalar, S32, 220, "val", 1, 0.0; - timeSeconds = scalar, U32, 224, "sec", 1, 0.0; - engineLoadDelta = scalar,F32, 228, "value", 1, 0 - speedToRpmRatio = scalar,F32, 232, "value", 1, 0 - warningCounter = scalar,U16, 236, "count", 1, 0 - - lastErrorCode = scalar,U16, 240, "error", 1, 0 - - internalMcuTemperature = scalar,F32, 244, "C", 1, 0 - vvtPosition = scalar,F32, 248, "deg", 1, 0 - engineMode = scalar, U32, 252, "em", 1, 0.0; - debugFloatField6 = scalar, F32, 256, "val", 1, 0.0; - debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; - firmwareVersion = scalar,U32, 264, "version_f", 1, 0 - fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 - coilDutyCycle = scalar, F32, 272, "perc", 1, 0 - accelerationX = scalar, S16, 276, "G", 0.01, 0 - accelerationY = scalar, S16, 278, "G", 0.01, 0 - oilPressure = scalar, F32, 280, "kPa", 1, 0.0 - fuelConsumptionPerHour=scalar, F32, 284, "kPa", 1, 0.0 - injectionOffset = scalar, F32, 288, "deg", 1, 0; - debugIntField4 = scalar, S16, 292, "val", 1, 0.0; - debugIntField5 = scalar, S16, 294, "val", 1, 0.0; - recentErrorCode0 = scalar,U16, 296, "error", 1, 0 - recentErrorCode1 = scalar,U16, 298, "error", 1, 0 - recentErrorCode2 = scalar,U16, 300, "error", 1, 0 - recentErrorCode3 = scalar,U16, 302, "error", 1, 0 - recentErrorCode4 = scalar,U16, 304, "error", 1, 0 - recentErrorCode5 = scalar,U16, 306, "error", 1, 0 - recentErrorCode6 = scalar,U16, 308, "error", 1, 0 - recentErrorCode7 = scalar,U16, 310, "error", 1, 0 - etbTarget = scalar,F32, 312, "%", 1, 0 - etb1DutyCycle = scalar,F32, 316, "%", 1, 0 - etb1Error = scalar,F32, 320, "%", 1, 0 + ;tpsADC2 = scalar, U16, 44, "ADC", 1, 0.0; + +; fuel math + chargeAirMass = scalar, U16, 44, "g",0.001, 0 + crankingFuelMs = scalar, U16, 46, "ms",{1/300}, 0.0 + currentTargetAfr= scalar, U16, 48, "ratio",,{1/1000},, 0 + baseFuel = scalar, U16, 50, "ms",{1/300}, 0 + fuelRunning = scalar, U16, 52, "ms",{1/300}, 0 + actualLastInjection=scalar,U16, 54, "ms",{1/300}, 0.0 + injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0 + veValue = scalar, U08, 57, "ratio", 0.5, 0 + injectionOffset = scalar, S16, 58, "deg",{1/50}, 0 + tCharge = scalar, U16, 60, "deg C",{1/100}, 0.0 + +; Corrections + injectorLagMs = scalar, U16, 62, "ms",{1/300}, 0.0 + iatCorrection = scalar, U16, 64, "%",{1/100}, 0 + cltCorrection = scalar, U16, 66, "%",{1/100}, 0 + baroCorrection = scalar, U16, 68, "%",{1/100}, 0 + fuelPidCorrection=scalar, S16, 70, "ms",{1/300}, 0 + +; Wall model AE + wallFuelAmount = scalar, U16, 72, "ms",{1/300}, 0 + wallFuelCorrection=scalar, S16, 74, "ms",0.001, 0 + +; TPS/load AE + engineLoadDelta = scalar, S16, 76, "value",{1/100}, 0 + deltaTps = scalar, S16, 78, "ratio",{1/100}, 0 + engineLoadAccelExtra=scalar,S16, 80, "value",{1/100}, 0 + tpsAccelFuel = scalar, U16, 82, "ms",{1/300}, 0 + +; Ignition + ignitionAdvance = scalar, U16, 84, "deg",{1/50}, 0.0 + sparkDwellValue = scalar, U16, 86, "ms",{1/300}, 0.0 + coilDutyCycle = scalar, U16, 88, "%",{1/100}, 0 + +; Idle & ETB + idleAirValvePosition=scalar,S16, 90, "%",{1/100}, 0 + etbTarget = scalar, S16, 92, "%",{1/100}, 0 + etb1DutyCycle = scalar, S16, 94, "%",{1/100}, 0 + etb1Error = scalar, S16, 96, "%",{1/100}, 0 + +; Fuel system + fuelTankLevel = scalar, S16, 98, "amount",{1/100}, 0 + fuelConsumptionPerHour=scalar,F32, 100, "kPa", 1, 0.0 + +; Knock + knockCount = scalar, U32, 104,"counter", 1, 0 + knockLevel = scalar, F32, 108, "Volts", 1, 0 + +; Mode, firmware, protocol, run time + timeSeconds = scalar, U32, 112, "sec", 1, 0.0 + engineMode = scalar, U32, 116, "em", 1, 0.0; + firmwareVersion = scalar, U32, 120,"version_f", 1, 0 + firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0 + +; Errors + totalTriggerErrorCounter=scalar,U32, 128,"counter", 1, 0 + ; orderingErrorCounter 132 + warningCounter = scalar, U16, 136, "count", 1, 0 + lastErrorCode = scalar, U16, 138, "error", 1, 0 + recentErrorCode0= scalar, U16, 140, "error", 1, 0 + recentErrorCode1= scalar, U16, 142, "error", 1, 0 + recentErrorCode2= scalar, U16, 144, "error", 1, 0 + recentErrorCode3= scalar, U16, 146, "error", 1, 0 + recentErrorCode4= scalar, U16, 148, "error", 1, 0 + recentErrorCode5= scalar, U16, 150, "error", 1, 0 + recentErrorCode6= scalar, U16, 152, "error", 1, 0 + recentErrorCode7= scalar, U16, 154, "error", 1, 0 + +; Debug + debugFloatField1= scalar, F32, 156, "val", 1, 0.0 + debugFloatField2= scalar, F32, 160, "val", 1, 0.0 + debugFloatField3= scalar, F32, 164, "val", 1, 0.0 + debugFloatField4= scalar, F32, 168, "val", 1, 0.0 + debugFloatField5= scalar, F32, 172, "val", 1, 0.0 + debugFloatField6= scalar, F32, 176, "val", 1, 0.0 + debugFloatField7= scalar, F32, 180, "val", 1, 0.0 + debugIntField1 = scalar, S32, 184, "val", 1, 0.0 + debugIntField2 = scalar, S32, 188, "val", 1, 0.0 + debugIntField3 = scalar, S32, 192, "val", 1, 0.0 + debugIntField4 = scalar, S16, 196, "val", 1, 0.0 + debugIntField5 = scalar, S16, 198, "val", 1, 0.0 + +; Accel + accelerationX = scalar, S16, 200, "G", 0.01, 0 + accelerationY = scalar, S16, 202, "G", 0.01, 0 + +; egt + egt1 = scalar, S16, 204, "deg C", 1, 0 + egt2 = scalar, S16, 206, "deg C", 1, 0 + egt3 = scalar, S16, 208, "deg C", 1, 0 + egt4 = scalar, S16, 210, "deg C", 1, 0 + egt5 = scalar, S16, 212, "deg C", 1, 0 + egt6 = scalar, S16, 214, "deg C", 1, 0 + egt7 = scalar, S16, 216, "deg C", 1, 0 + egt8 = scalar, S16, 218, "deg C", 1, 0 ; @@ -1344,6 +1439,10 @@ fileVersion = { 20190701 } wueAfrTargetOffset = array, S16, [ 16], ":1", 0.1, 0.0, -3.0, 3.0, 1; wueAnalRecommend = array, U08, [ 16], "%", 1.00, 0.0, 100, 255.00, 0 +; These are inverted (false = "Yes") so that they default to enabled + enableLogDebugChannels = bits, U08, [0:0], "Yes", "No" + enableLogErrorList = bits, U08, [0:0], "Yes", "No" + [ConstantsExtensions] defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 @@ -1792,7 +1891,7 @@ gaugeCategory = Sensors - Extra 2 gaugeCategory = ECU Status warningCounterGauge = warningCounter, "Warning count", "", 0, 100, 0, 0, 100, 100, 0, 0 lastErrorCodeGauge = lastErrorCode, "Last error", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 - triggerErrorsCounterGauge = triggerErrorsCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 + triggerErrorsCounterGauge = totalTriggerErrorCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 recentErrorCode0Gauge = recentErrorCode0, "Error#1", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode1Gauge = recentErrorCode1, "Error#2", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode2Gauge = recentErrorCode2, "Error#3", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 @@ -1990,7 +2089,7 @@ gaugeCategory = Throttle Body (incl. ETB) entry = massAirFlowValue,"air flow", float, "%.3f" entry = chargeAirMass, "air mass", float, "%.3f" entry = throttlePedalPosition, "Throttle pedal position", float, "%.3f" - entry = triggerErrorsCounter, "trg err",int, "%d" + entry = totalTriggerErrorCounter, "trg err",int, "%d" entry = idleAirValvePosition, "Idle Air Valve", float, "%.3f" @@ -2004,16 +2103,16 @@ gaugeCategory = Throttle Body (incl. ETB) entry = coilDutyCycle, "dwell: coil duty cycle", float,"%.3f" entry = currentTargetAfr,"fuel: target AFR", float,"%.3f" - entry = accelerationX, "Acceleration: X", float,"%.2f" - entry = accelerationY, "Acceleration: Y", float,"%.2f" - entry = egt1, "EGT1", float,"%.1f" - entry = egt2, "EGT2", float,"%.1f" - entry = egt3, "EGT3", float,"%.1f" - entry = egt4, "EGT4", float,"%.1f" - entry = egt5, "EGT5", float,"%.1f" - entry = egt6, "EGT6", float,"%.1f" - entry = egt7, "EGT7", float,"%.1f" - entry = egt8, "EGT8", float,"%.1f" + entry = accelerationX, "Acceleration: X", float,"%.2f", { LIS302DLCsPin != 0 } + entry = accelerationY, "Acceleration: Y", float,"%.2f", { LIS302DLCsPin != 0 } + entry = egt1, "EGT1", float,"%.1f", { max31855_cs1 != 0} + entry = egt2, "EGT2", float,"%.1f", { max31855_cs2 != 0} + entry = egt3, "EGT3", float,"%.1f", { max31855_cs3 != 0} + entry = egt4, "EGT4", float,"%.1f", { max31855_cs4 != 0} + entry = egt5, "EGT5", float,"%.1f", { max31855_cs5 != 0} + entry = egt6, "EGT6", float,"%.1f", { max31855_cs6 != 0} + entry = egt7, "EGT7", float,"%.1f", { max31855_cs7 != 0} + entry = egt8, "EGT8", float,"%.1f", { max31855_cs8 != 0} entry = engineLoadAccelExtra, "fuel: engine load acceleration extra fuel",float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f" @@ -2035,54 +2134,54 @@ gaugeCategory = Throttle Body (incl. ETB) ; is there a way to log parameter? entry = debugMode, "debugMode",int,"%d" ; Alternator_PID: alternator duty cycle ; DBG_TPS_ACCEL: from TPS - entry = debugFloatField1, "debug f1",float,"%.4f" + entry = debugFloatField1, "debug f1",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: current integration term ; DBG_TPS_ACCEL: to TPS - entry = debugFloatField2, "debug f2: iTerm",float,"%.4f" + entry = debugFloatField2, "debug f2: iTerm",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: previous error ; DBG_TPS_ACCEL: tps<>tps table value - entry = debugFloatField3, "debug f3: prevError",float,"%.4f" + entry = debugFloatField3, "debug f3: prevError",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: I setting ; DBG_TPS_ACCEL: extra fuel - entry = debugFloatField4, "debug f4: iParam",float,"%.4f" + entry = debugFloatField4, "debug f4: iParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: D setting - entry = debugFloatField5, "debug f5: dParam",float,"%.4f" + entry = debugFloatField5, "debug f5: dParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: dTerm - entry = debugFloatField6, "debug f6: dTerm",float,"%.4f" + entry = debugFloatField6, "debug f6: dTerm",float,"%.4f", { !enableLogDebugChannels } - entry = debugFloatField7, "debug f7",float,"%.4f" + entry = debugFloatField7, "debug f7",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: P setting - entry = debugIntField1, "debug i1: pParam",int,"%d" + entry = debugIntField1, "debug i1: pParam",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: offset setting - entry = debugIntField2, "debug i2: offset",int,"%d" + entry = debugIntField2, "debug i2: offset",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: PID reset counter - entry = debugIntField3, "debug i3",int,"%d" + entry = debugIntField3, "debug i3",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField4, "debug i4",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField5, "debug i5",int,"%d", { !enableLogDebugChannels } - entry = debugIntField4, "debug i4",int,"%d" - entry = debugIntField5, "debug i5",int,"%d" - - entry = engineMode, "Engine Mode",int,"%d" entry = warningCounter, "warning: counter",int,"%d" entry = lastErrorCode, "warning: last",int,"%d" - entry = recentErrorCode0, "error 0",int,"%d" - entry = recentErrorCode1, "error 1",int,"%d" - entry = recentErrorCode2, "error 2",int,"%d" - entry = recentErrorCode3, "error 3",int,"%d" - entry = recentErrorCode4, "error 4",int,"%d" - entry = recentErrorCode5, "error 5",int,"%d" - entry = recentErrorCode6, "error 6",int,"%d" - entry = recentErrorCode7, "error 7",int,"%d" + entry = recentErrorCode0, "error 0",int,"%d", { !enableLogErrorList } + entry = recentErrorCode1, "error 1",int,"%d", { !enableLogErrorList } + entry = recentErrorCode2, "error 2",int,"%d", { !enableLogErrorList } + entry = recentErrorCode3, "error 3",int,"%d", { !enableLogErrorList } + entry = recentErrorCode4, "error 4",int,"%d", { !enableLogErrorList } + entry = recentErrorCode5, "error 5",int,"%d", { !enableLogErrorList } + entry = recentErrorCode6, "error 6",int,"%d", { !enableLogErrorList } + entry = recentErrorCode7, "error 7",int,"%d", { !enableLogErrorList } entry = internalMcuTemperature, "CPU Temperature",float,"%.2f" entry = tCharge, "tCharge",float,"%.3f" @@ -2256,6 +2355,7 @@ menuDialog = main menu = "&Controller" subMenu = ecuStimulator, "ECU stimulator" + subMenu = datalogSettings, "Datalogging" subMenu = ioTest, "Bench test" subMenu = engineTypeDialog, "Popular vehicles" subMenu = std_separator @@ -2622,6 +2722,10 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" panel = triggerInputComparator dialog = allPinsSensors, "Sensors" + field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel + field = "Primary input channel", triggerInputPins1 + field = "Secondary channel", triggerInputPins2 + field = "Cam Sync/VVT input", camInputs1 field = "CLT ADC input", clt_adcChannel field = "IAT ADC input", iat_adcChannel field = "vBatt ADC input", vbattAdcChannel @@ -2655,10 +2759,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "mc33972_cs", mc33972_cs field = "mc33972 SPI", mc33972spiDevice panel = allPinsSensors - field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel - field = "Primary input channel", triggerInputPins1 - field = "Secondary channel", triggerInputPins2 - field = "Cam Sync/VVT input", camInputs1 dialog = allPins1_2 field = "Tachometer output Pin", tachOutputPin @@ -3514,7 +3614,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "No1 Control #1", etbIo1_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "No2 Direction #1", etbIo2_directionPin1, {throttlePedalPositionAdcChannel != 16} field = "No2 Direction #2", etbIo2_directionPin2, {throttlePedalPositionAdcChannel != 16} - field = "No2 Control #1", etb2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} + field = "No2 Control #1", etbIo2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "TPS#2 min", tps2Min, {etbIo2_directionPin1 != 0} field = "TPS#2 max", tps2Max, {etbIo2_directionPin1 != 0} panel = etbPidDialog @@ -3615,6 +3715,11 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "" field = "Engine chart size", engineChartSize + dialog = datalogSettings, "Datalogging Settings" + field = "#Disabling optional logging may increase update rate!" + field = "Log debug channels", enableLogDebugChannels + field = "Log recent errors list", enableLogErrorList + ; Racing Features->Launch Control dialog = smLaunchControl, "Launch Control Settings NOT WORKING" field = "RPM Step1 Limit", step1rpm diff --git a/firmware/tunerstudio/rusefi_prometheus.ini b/firmware/tunerstudio/rusefi_prometheus.ini index 51a4fdd8c1..2b942175e2 100644 --- a/firmware/tunerstudio/rusefi_prometheus.ini +++ b/firmware/tunerstudio/rusefi_prometheus.ini @@ -44,7 +44,7 @@ enable2ndByteCanID = false [TunerStudio] queryCommand = "S" versionInfo = "V" ; firmwave version for title bar. - signature = "rusEFI v1.07" ; signature is expected to be 7 or more characters. + signature = "rusEFI v1.08" ; signature is expected to be 7 or more characters. [Constants] ; new packet serial format with CRC @@ -85,7 +85,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Dec 08 00:32:37 EST 2019 +; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Dec 25 15:54:46 EST 2019 pageSize = 20000 page = 1 @@ -125,6 +125,7 @@ page = 1 issue_294_29 = bits, U32, 76, [28:28], "false", "true" issue_294_30 = bits, U32, 76, [29:29], "false", "true" issue_294_31 = bits, U32, 76, [30:30], "false", "true" + unusedBit_34_31 = bits, U32, 76, [31:31], "false", "true" tpsMin = scalar, S16, 80, "ADC", 1, 0, 0, 1023, 0 tpsMax = scalar, S16, 82, "ADC", 1, 0, 0, 1023, 0 tpsErrorDetectionTooLow = scalar, S16, 84, "%", 1, 0, -40, 200, 0 @@ -207,6 +208,35 @@ page = 1 trigger_unusedCustomIsSynchronizationNeeded= bits, U32, 528, [0:0], "false", "true" trigger_unusedCustomNeedSecondTriggerInput= bits, U32, 528, [1:1], "false", "true" trigger_useOnlyFirstChannel= bits, U32, 528, [2:2], "false", "true" + trigger_unusedBit_4_3 = bits, U32, 528, [3:3], "false", "true" + trigger_unusedBit_4_4 = bits, U32, 528, [4:4], "false", "true" + trigger_unusedBit_4_5 = bits, U32, 528, [5:5], "false", "true" + trigger_unusedBit_4_6 = bits, U32, 528, [6:6], "false", "true" + trigger_unusedBit_4_7 = bits, U32, 528, [7:7], "false", "true" + trigger_unusedBit_4_8 = bits, U32, 528, [8:8], "false", "true" + trigger_unusedBit_4_9 = bits, U32, 528, [9:9], "false", "true" + trigger_unusedBit_4_10 = bits, U32, 528, [10:10], "false", "true" + trigger_unusedBit_4_11 = bits, U32, 528, [11:11], "false", "true" + trigger_unusedBit_4_12 = bits, U32, 528, [12:12], "false", "true" + trigger_unusedBit_4_13 = bits, U32, 528, [13:13], "false", "true" + trigger_unusedBit_4_14 = bits, U32, 528, [14:14], "false", "true" + trigger_unusedBit_4_15 = bits, U32, 528, [15:15], "false", "true" + trigger_unusedBit_4_16 = bits, U32, 528, [16:16], "false", "true" + trigger_unusedBit_4_17 = bits, U32, 528, [17:17], "false", "true" + trigger_unusedBit_4_18 = bits, U32, 528, [18:18], "false", "true" + trigger_unusedBit_4_19 = bits, U32, 528, [19:19], "false", "true" + trigger_unusedBit_4_20 = bits, U32, 528, [20:20], "false", "true" + trigger_unusedBit_4_21 = bits, U32, 528, [21:21], "false", "true" + trigger_unusedBit_4_22 = bits, U32, 528, [22:22], "false", "true" + trigger_unusedBit_4_23 = bits, U32, 528, [23:23], "false", "true" + trigger_unusedBit_4_24 = bits, U32, 528, [24:24], "false", "true" + trigger_unusedBit_4_25 = bits, U32, 528, [25:25], "false", "true" + trigger_unusedBit_4_26 = bits, U32, 528, [26:26], "false", "true" + trigger_unusedBit_4_27 = bits, U32, 528, [27:27], "false", "true" + trigger_unusedBit_4_28 = bits, U32, 528, [28:28], "false", "true" + trigger_unusedBit_4_29 = bits, U32, 528, [29:29], "false", "true" + trigger_unusedBit_4_30 = bits, U32, 528, [30:30], "false", "true" + trigger_unusedBit_4_31 = bits, U32, 528, [31:31], "false", "true" trigger_customTotalToothCount = scalar, S32, 532, "number", 1, 0.0, 0, 500.0, 0 trigger_customSkippedToothCount = scalar, S32, 536, "number", 1, 0.0, 0, 500.0, 0 hip9011SpiDevice = bits,U32, 540, [0:7], "Off", "SPI1", "SPI2", "SPI3", "SPI4" @@ -502,6 +532,36 @@ page = 1 ;no TS info - skipping unused offset 972 todoClutchUpPinInverted = bits, U32, 976, [0:0], "false", "true" todoClutchDownPinInverted= bits, U32, 976, [1:1], "false", "true" + unusedBit_247_2 = bits, U32, 976, [2:2], "false", "true" + unusedBit_247_3 = bits, U32, 976, [3:3], "false", "true" + unusedBit_247_4 = bits, U32, 976, [4:4], "false", "true" + unusedBit_247_5 = bits, U32, 976, [5:5], "false", "true" + unusedBit_247_6 = bits, U32, 976, [6:6], "false", "true" + unusedBit_247_7 = bits, U32, 976, [7:7], "false", "true" + unusedBit_247_8 = bits, U32, 976, [8:8], "false", "true" + unusedBit_247_9 = bits, U32, 976, [9:9], "false", "true" + unusedBit_247_10 = bits, U32, 976, [10:10], "false", "true" + unusedBit_247_11 = bits, U32, 976, [11:11], "false", "true" + unusedBit_247_12 = bits, U32, 976, [12:12], "false", "true" + unusedBit_247_13 = bits, U32, 976, [13:13], "false", "true" + unusedBit_247_14 = bits, U32, 976, [14:14], "false", "true" + unusedBit_247_15 = bits, U32, 976, [15:15], "false", "true" + unusedBit_247_16 = bits, U32, 976, [16:16], "false", "true" + unusedBit_247_17 = bits, U32, 976, [17:17], "false", "true" + unusedBit_247_18 = bits, U32, 976, [18:18], "false", "true" + unusedBit_247_19 = bits, U32, 976, [19:19], "false", "true" + unusedBit_247_20 = bits, U32, 976, [20:20], "false", "true" + unusedBit_247_21 = bits, U32, 976, [21:21], "false", "true" + unusedBit_247_22 = bits, U32, 976, [22:22], "false", "true" + unusedBit_247_23 = bits, U32, 976, [23:23], "false", "true" + unusedBit_247_24 = bits, U32, 976, [24:24], "false", "true" + unusedBit_247_25 = bits, U32, 976, [25:25], "false", "true" + unusedBit_247_26 = bits, U32, 976, [26:26], "false", "true" + unusedBit_247_27 = bits, U32, 976, [27:27], "false", "true" + unusedBit_247_28 = bits, U32, 976, [28:28], "false", "true" + unusedBit_247_29 = bits, U32, 976, [29:29], "false", "true" + unusedBit_247_30 = bits, U32, 976, [30:30], "false", "true" + unusedBit_247_31 = bits, U32, 976, [31:31], "false", "true" etbIo1_directionPin1 = bits, U08, 980, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_directionPin2 = bits, U08, 981, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" etbIo1_controlPin1 = bits, U08, 982, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" @@ -1182,147 +1242,182 @@ page = 1 [OutputChannels] -; see TS_FILE_VERSION in firmware code -fileVersion = { 20190701 } +fileVersion = { 20191221 } ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 356 + ochBlockSize = 220 ; ; see TunerStudioOutputChannels struct ; - RPMValue = scalar, U32, 0, "RPM", 1, 0.00000 + +; Bit flags + hasSdCard = bits, U32, 0, [0:0], "true", "false"; + isIgnitionEnabledIndicator=bits,U32, 0, [1:1], "true", "false"; + ind_injection_enabled=bits,U32, 0, [2:2], "true", "false"; + isCylinderCleanupEnabled=bits,U32, 0, [3:3], "true", "false"; + isCylinderCleanupActivated=bits,U32, 0, [4:4], "true", "false"; + ind_fuel_pump = bits, U32, 0, [5:5], "true", "false"; + ind_fan = bits, U32, 0, [6:6], "true", "false"; + ind_o2_heater = bits, U32, 0, [7:7], "true", "false"; + ind_check_engine= bits, U32, 0, [8:8], "true", "false"; + needBurn = bits, U32, 0, [9:9], "true", "false"; + ind_2nd_trigger_en=bits, U32, 0, [10:10], "true", "false"; + clutchUpState =bits, U32, 0, [11:11], "true", "false"; + clutchDownState =bits, U32, 0, [12:12], "true", "false"; + knockEverIndicator=bits, U32, 0, [13:13], "true", "false"; + knockNowIndicator=bits, U32, 0, [14:14], "true", "false"; + brakePedalIndicator=bits, U32, 0, [15:15], "true", "false"; + toothLogReady =bits, U32, 0, [16:16], "true", "false"; + acSwitchIndicator =bits, U32, 0, [17:17], "true", "false"; + ind_tps_error = bits, U32, 0, [18:18], "true", "false"; + ind_clt_error = bits, U32, 0, [19:19], "true", "false"; + ind_map_error = bits, U32, 0, [20:21], "true", "false"; + ind_iat_error = bits, U32, 0, [21:22], "true", "false"; + ind_isTriggerError = bits, U32, 0, [23:23], "true", "false"; + ind_hasFatalError=bits, U32, 0, [24:24], "true", "false"; + ind_isWarnNow =bits, U32, 0, [25:25], "true", "false"; + +; RPM, vss + RPMValue = scalar, U16, 4, "RPM", 1, 0.00000 + rpmAcceleration = scalar, S16, 6, "dRpm",{1/100}, 0 + speedToRpmRatio = scalar, S16, 8, "value",{1/100}, 0 + vehicleSpeedKph = scalar, U08, 10, "kph", 1, 0.0 + +; temperatures + internalMcuTemperature = scalar,S08, 11, "deg C", 1, 0 #if CELSIUS - coolant = scalar, F32, 4, "deg C", 1, 0.0 + coolant = scalar, S16, 12, "deg C",{1/100}, 0.0 #else - coolant = scalar, F32, 4, "deg F", {9/5}, 17.77777 + coolant = scalar, S16, 12, "deg F",{9/(5 * 100)}, 17.77777 #endif #if CELSIUS - intake = scalar, F32, 8, "deg C", 1, 0.0 + intake = scalar, S16, 14, "deg C",{1/100}, 0.0 #else - intake = scalar, F32, 8, "deg F", {9/5}, 17.77777 + intake = scalar, S16, 14, "deg F",{9/(5 * 100)}, 17.77777 #endif - TPSValue = scalar, F32, 12, "%", 1, 0 - MAFValue = scalar, F32, 16, "V", 1, 0 - AFRValue = scalar, F32, 20, "AFR", 1, 0.0 - engineLoad = scalar, F32, 24, "%", 1, 0.0 ; Blend of MAP and TPS, depends on algorithm - VBatt = scalar, F32, 28, "V", 1, 0.0 +; todo: aux1 +; todo: aux2 + + +; throttle, pedal + TPSValue = scalar, U16, 20, "%",{1/100}, 0 + throttlePedalPosition = scalar,U16, 22, "%",{1/100}, 0 + tpsADC = scalar, U16, 24, "ADC", 1, 0.0; + +; air flow/mass measurments + MAFValue = scalar, U16, 26, "V",,{1/1000},, 0 + massAirFlowValue= scalar, U16, 28, "Kg/h", 0.01, 0 + MAPValue = scalar, U16, 30, "kPa",{1/30}, 0.0 + baroPressure = scalar, U16, 32, "kPa",{1/30}, 0.0 + AFRValue = scalar, U16, 34, "AFR",,{1/1000},, 0.0 + engineLoad = scalar, U16, 36, "%",{1/100}, 0.0 ; Blend of MAP and TPS, depends on algorithm + +; misc sensors + VBatt = scalar, U16, 38, "V",,{1/1000},, 0.0 + oilPressure = scalar, U16, 40, "kPa",{1/30}, 0.0 + vvtPosition = scalar, U16, 42, "deg",{1/50}, 0 + ; 10 bit TPS ADC value (from 0 to 1023 in 5v scale) - tpsADC = scalar, U16, 32, "ADC", 1, 0.0; - tpsADC2 = scalar, U16, 34, "ADC", 1, 0.0; - baroPressure = scalar, F32, 36, "pres", 1, 0.0; - MAPValue = scalar, F32, 40, "MAP", 1, 0.0; - ; total fuel squirt duration (in MS) per engine cycle according to current CLT - crankingFuelMs = scalar, F32, 44, "ms", 1, 0.0; - baseFuel = scalar, F32, 48, "ms", 1, 0 - tCharge = scalar, F32, 52, "T", 1, 0.0; - ignitionAdvance = scalar, F32, 56, "deg", 1, 0.0; - sparkDwellValue = scalar, F32, 60, "ms", 1, 0.0; - ; actual total Ms time per engine cycle with all corrections - actualLastInjection = scalar, F32, 64, "ms", 1, 0.0; - debugFloatField1 = scalar, F32, 68, "val", 1, 0.0; - - hasSdCard = bits, U32, 72, [0:0], "true", "false"; - isIgnitionEnabledIndicator=bits, U32, 72, [1:1], "true", "false"; - ind_injection_enabled=bits,U32, 72, [2:2], "true", "false"; - isCylinderCleanupEnabled=bits, U32, 72, [3:3], "true", "false"; - isCylinderCleanupActivated=bits,U32,72, [4:4], "true", "false"; - ind_fuel_pump = bits, U32, 72, [5:5], "true", "false"; - ind_fan = bits, U32, 72, [6:6], "true", "false"; - ind_o2_heater = bits, U32, 72, [7:7], "true", "false"; - ind_check_engine= bits, U32, 72, [8:8], "true", "false"; - needBurn = bits, U32, 72, [9:9], "true", "false"; - ind_2nd_trigger_en=bits, U32, 72, [10:10], "true", "false"; - clutchUpState =bits, U32, 72, [11:11], "true", "false"; - clutchDownState =bits, U32, 72, [12:12], "true", "false"; - knockEverIndicator=bits, U32, 72, [13:13], "true", "false"; - knockNowIndicator=bits, U32, 72, [14:14], "true", "false"; - brakePedalIndicator=bits, U32, 72, [15:15], "true", "false"; - toothLogReady =bits, U32, 72, [16:16], "true", "false"; - acSwitchIndicator =bits, U32, 72, [17:17], "true", "false"; - vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0; - - ind_tps_error = bits, U32, 80, [0:0], "true", "false"; - ind_clt_error = bits, U32, 80, [1:1], "true", "false"; - ind_map_error = bits, U32, 80, [2:2], "true", "false"; - ind_iat_error = bits, U32, 80, [3:3], "true", "false"; - ind_isTriggerError = bits, U32, 80, [5:5], "true", "false"; - ind_hasFatalError=bits, U32, 80, [6:6], "true", "false"; - ind_isWarnNow =bits, U32, 80, [7:7], "true", "false"; - firmwareTsVersion = scalar,U32, 84, "version_p", 1, 0 - egt1 = scalar, S16, 88, "deg C", 1, 0 - egt2 = scalar, S16, 90, "deg C", 1, 0 - egt3 = scalar, S16, 92, "deg C", 1, 0 - egt4 = scalar, S16, 94, "deg C", 1, 0 - egt5 = scalar, S16, 96, "deg C", 1, 0 - egt6 = scalar, S16, 98, "deg C", 1, 0 - egt7 = scalar, S16, 100, "deg C", 1, 0 - egt8 = scalar, S16, 102, "deg C", 1, 0 - rpmAcceleration = scalar, F32, 104, "dRpm", 1, 0 - massAirFlowValue= scalar, F32, 108, "Kg/h", 1, 0 - veValue = scalar, F32, 112, "ratio", 1, 0 - deltaTps = scalar, F32, 116, "ratio", 1, 0 - triggerErrorsCounter = scalar, U32,120, "counter", 1, 0 - engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0 - tpsAccelFuel = scalar, F32, 128, "ms", 1, 0 - baroCorrection = scalar, F32, 132, "%", 1, 0 - throttlePedalPosition = scalar, F32, 136, "%", 1, 0 - injectorDutyCycle= scalar, F32, 140, "%", 1, 0 - knockCount = scalar, U32, 144, "counter", 1, 0 - fuelTankLevel = scalar, F32, 148, "amount", 1, 0 - knockLevel = scalar, F32, 152, "Volts", 1, 0 - ; totalTriggerErrorCounter 156 - wallFuelAmount = scalar, F32, 160, "ms", 1, 0 - iatCorrection = scalar, F32, 164, "%", 1, 0 - wallFuelCorrection = scalar, F32, 168, "ms", 1, 0 - idleAirValvePosition = scalar, F32, 172, "percent", 1, 0 - currentTargetAfr = scalar, F32, 176, "ratio", 1, 0 - chargeAirMass = scalar, F32, 180, "g", 1, 0 - cltCorrection = scalar, F32, 184, "%", 1, 0 - fuelRunning = scalar, F32, 188, "g", 1, 0 - debugIntField1 = scalar, S32, 192, "val", 1, 0.0; - injectorLagMs = scalar, F32, 196, "ms", 1, 0.0; - debugFloatField2 = scalar, F32, 200, "val", 1, 0.0; - debugFloatField3 = scalar, F32, 204, "val", 1, 0.0; - debugFloatField4 = scalar, F32, 208, "val", 1, 0.0; - debugFloatField5 = scalar, F32, 212, "val", 1, 0.0; - debugIntField2 = scalar, S32, 216, "val", 1, 0.0; - debugIntField3 = scalar, S32, 220, "val", 1, 0.0; - timeSeconds = scalar, U32, 224, "sec", 1, 0.0; - engineLoadDelta = scalar,F32, 228, "value", 1, 0 - speedToRpmRatio = scalar,F32, 232, "value", 1, 0 - warningCounter = scalar,U16, 236, "count", 1, 0 - - lastErrorCode = scalar,U16, 240, "error", 1, 0 - - internalMcuTemperature = scalar,F32, 244, "C", 1, 0 - vvtPosition = scalar,F32, 248, "deg", 1, 0 - engineMode = scalar, U32, 252, "em", 1, 0.0; - debugFloatField6 = scalar, F32, 256, "val", 1, 0.0; - debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; - firmwareVersion = scalar,U32, 264, "version_f", 1, 0 - fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 - coilDutyCycle = scalar, F32, 272, "perc", 1, 0 - accelerationX = scalar, S16, 276, "G", 0.01, 0 - accelerationY = scalar, S16, 278, "G", 0.01, 0 - oilPressure = scalar, F32, 280, "kPa", 1, 0.0 - fuelConsumptionPerHour=scalar, F32, 284, "kPa", 1, 0.0 - injectionOffset = scalar, F32, 288, "deg", 1, 0; - debugIntField4 = scalar, S16, 292, "val", 1, 0.0; - debugIntField5 = scalar, S16, 294, "val", 1, 0.0; - recentErrorCode0 = scalar,U16, 296, "error", 1, 0 - recentErrorCode1 = scalar,U16, 298, "error", 1, 0 - recentErrorCode2 = scalar,U16, 300, "error", 1, 0 - recentErrorCode3 = scalar,U16, 302, "error", 1, 0 - recentErrorCode4 = scalar,U16, 304, "error", 1, 0 - recentErrorCode5 = scalar,U16, 306, "error", 1, 0 - recentErrorCode6 = scalar,U16, 308, "error", 1, 0 - recentErrorCode7 = scalar,U16, 310, "error", 1, 0 - etbTarget = scalar,F32, 312, "%", 1, 0 - etb1DutyCycle = scalar,F32, 316, "%", 1, 0 - etb1Error = scalar,F32, 320, "%", 1, 0 + ;tpsADC2 = scalar, U16, 44, "ADC", 1, 0.0; + +; fuel math + chargeAirMass = scalar, U16, 44, "g",0.001, 0 + crankingFuelMs = scalar, U16, 46, "ms",{1/300}, 0.0 + currentTargetAfr= scalar, U16, 48, "ratio",,{1/1000},, 0 + baseFuel = scalar, U16, 50, "ms",{1/300}, 0 + fuelRunning = scalar, U16, 52, "ms",{1/300}, 0 + actualLastInjection=scalar,U16, 54, "ms",{1/300}, 0.0 + injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0 + veValue = scalar, U08, 57, "ratio", 0.5, 0 + injectionOffset = scalar, S16, 58, "deg",{1/50}, 0 + tCharge = scalar, U16, 60, "deg C",{1/100}, 0.0 + +; Corrections + injectorLagMs = scalar, U16, 62, "ms",{1/300}, 0.0 + iatCorrection = scalar, U16, 64, "%",{1/100}, 0 + cltCorrection = scalar, U16, 66, "%",{1/100}, 0 + baroCorrection = scalar, U16, 68, "%",{1/100}, 0 + fuelPidCorrection=scalar, S16, 70, "ms",{1/300}, 0 + +; Wall model AE + wallFuelAmount = scalar, U16, 72, "ms",{1/300}, 0 + wallFuelCorrection=scalar, S16, 74, "ms",0.001, 0 + +; TPS/load AE + engineLoadDelta = scalar, S16, 76, "value",{1/100}, 0 + deltaTps = scalar, S16, 78, "ratio",{1/100}, 0 + engineLoadAccelExtra=scalar,S16, 80, "value",{1/100}, 0 + tpsAccelFuel = scalar, U16, 82, "ms",{1/300}, 0 + +; Ignition + ignitionAdvance = scalar, U16, 84, "deg",{1/50}, 0.0 + sparkDwellValue = scalar, U16, 86, "ms",{1/300}, 0.0 + coilDutyCycle = scalar, U16, 88, "%",{1/100}, 0 + +; Idle & ETB + idleAirValvePosition=scalar,S16, 90, "%",{1/100}, 0 + etbTarget = scalar, S16, 92, "%",{1/100}, 0 + etb1DutyCycle = scalar, S16, 94, "%",{1/100}, 0 + etb1Error = scalar, S16, 96, "%",{1/100}, 0 + +; Fuel system + fuelTankLevel = scalar, S16, 98, "amount",{1/100}, 0 + fuelConsumptionPerHour=scalar,F32, 100, "kPa", 1, 0.0 + +; Knock + knockCount = scalar, U32, 104,"counter", 1, 0 + knockLevel = scalar, F32, 108, "Volts", 1, 0 + +; Mode, firmware, protocol, run time + timeSeconds = scalar, U32, 112, "sec", 1, 0.0 + engineMode = scalar, U32, 116, "em", 1, 0.0; + firmwareVersion = scalar, U32, 120,"version_f", 1, 0 + firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0 + +; Errors + totalTriggerErrorCounter=scalar,U32, 128,"counter", 1, 0 + ; orderingErrorCounter 132 + warningCounter = scalar, U16, 136, "count", 1, 0 + lastErrorCode = scalar, U16, 138, "error", 1, 0 + recentErrorCode0= scalar, U16, 140, "error", 1, 0 + recentErrorCode1= scalar, U16, 142, "error", 1, 0 + recentErrorCode2= scalar, U16, 144, "error", 1, 0 + recentErrorCode3= scalar, U16, 146, "error", 1, 0 + recentErrorCode4= scalar, U16, 148, "error", 1, 0 + recentErrorCode5= scalar, U16, 150, "error", 1, 0 + recentErrorCode6= scalar, U16, 152, "error", 1, 0 + recentErrorCode7= scalar, U16, 154, "error", 1, 0 + +; Debug + debugFloatField1= scalar, F32, 156, "val", 1, 0.0 + debugFloatField2= scalar, F32, 160, "val", 1, 0.0 + debugFloatField3= scalar, F32, 164, "val", 1, 0.0 + debugFloatField4= scalar, F32, 168, "val", 1, 0.0 + debugFloatField5= scalar, F32, 172, "val", 1, 0.0 + debugFloatField6= scalar, F32, 176, "val", 1, 0.0 + debugFloatField7= scalar, F32, 180, "val", 1, 0.0 + debugIntField1 = scalar, S32, 184, "val", 1, 0.0 + debugIntField2 = scalar, S32, 188, "val", 1, 0.0 + debugIntField3 = scalar, S32, 192, "val", 1, 0.0 + debugIntField4 = scalar, S16, 196, "val", 1, 0.0 + debugIntField5 = scalar, S16, 198, "val", 1, 0.0 + +; Accel + accelerationX = scalar, S16, 200, "G", 0.01, 0 + accelerationY = scalar, S16, 202, "G", 0.01, 0 + +; egt + egt1 = scalar, S16, 204, "deg C", 1, 0 + egt2 = scalar, S16, 206, "deg C", 1, 0 + egt3 = scalar, S16, 208, "deg C", 1, 0 + egt4 = scalar, S16, 210, "deg C", 1, 0 + egt5 = scalar, S16, 212, "deg C", 1, 0 + egt6 = scalar, S16, 214, "deg C", 1, 0 + egt7 = scalar, S16, 216, "deg C", 1, 0 + egt8 = scalar, S16, 218, "deg C", 1, 0 ; @@ -1344,6 +1439,10 @@ fileVersion = { 20190701 } wueAfrTargetOffset = array, S16, [ 16], ":1", 0.1, 0.0, -3.0, 3.0, 1; wueAnalRecommend = array, U08, [ 16], "%", 1.00, 0.0, 100, 255.00, 0 +; These are inverted (false = "Yes") so that they default to enabled + enableLogDebugChannels = bits, U08, [0:0], "Yes", "No" + enableLogErrorList = bits, U08, [0:0], "Yes", "No" + [ConstantsExtensions] defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 @@ -1792,7 +1891,7 @@ gaugeCategory = Sensors - Extra 2 gaugeCategory = ECU Status warningCounterGauge = warningCounter, "Warning count", "", 0, 100, 0, 0, 100, 100, 0, 0 lastErrorCodeGauge = lastErrorCode, "Last error", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 - triggerErrorsCounterGauge = triggerErrorsCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 + triggerErrorsCounterGauge = totalTriggerErrorCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0 recentErrorCode0Gauge = recentErrorCode0, "Error#1", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode1Gauge = recentErrorCode1, "Error#2", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode2Gauge = recentErrorCode2, "Error#3", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 @@ -1990,7 +2089,7 @@ gaugeCategory = Throttle Body (incl. ETB) entry = massAirFlowValue,"air flow", float, "%.3f" entry = chargeAirMass, "air mass", float, "%.3f" entry = throttlePedalPosition, "Throttle pedal position", float, "%.3f" - entry = triggerErrorsCounter, "trg err",int, "%d" + entry = totalTriggerErrorCounter, "trg err",int, "%d" entry = idleAirValvePosition, "Idle Air Valve", float, "%.3f" @@ -2004,16 +2103,16 @@ gaugeCategory = Throttle Body (incl. ETB) entry = coilDutyCycle, "dwell: coil duty cycle", float,"%.3f" entry = currentTargetAfr,"fuel: target AFR", float,"%.3f" - entry = accelerationX, "Acceleration: X", float,"%.2f" - entry = accelerationY, "Acceleration: Y", float,"%.2f" - entry = egt1, "EGT1", float,"%.1f" - entry = egt2, "EGT2", float,"%.1f" - entry = egt3, "EGT3", float,"%.1f" - entry = egt4, "EGT4", float,"%.1f" - entry = egt5, "EGT5", float,"%.1f" - entry = egt6, "EGT6", float,"%.1f" - entry = egt7, "EGT7", float,"%.1f" - entry = egt8, "EGT8", float,"%.1f" + entry = accelerationX, "Acceleration: X", float,"%.2f", { LIS302DLCsPin != 0 } + entry = accelerationY, "Acceleration: Y", float,"%.2f", { LIS302DLCsPin != 0 } + entry = egt1, "EGT1", float,"%.1f", { max31855_cs1 != 0} + entry = egt2, "EGT2", float,"%.1f", { max31855_cs2 != 0} + entry = egt3, "EGT3", float,"%.1f", { max31855_cs3 != 0} + entry = egt4, "EGT4", float,"%.1f", { max31855_cs4 != 0} + entry = egt5, "EGT5", float,"%.1f", { max31855_cs5 != 0} + entry = egt6, "EGT6", float,"%.1f", { max31855_cs6 != 0} + entry = egt7, "EGT7", float,"%.1f", { max31855_cs7 != 0} + entry = egt8, "EGT8", float,"%.1f", { max31855_cs8 != 0} entry = engineLoadAccelExtra, "fuel: engine load acceleration extra fuel",float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f" @@ -2035,54 +2134,54 @@ gaugeCategory = Throttle Body (incl. ETB) ; is there a way to log parameter? entry = debugMode, "debugMode",int,"%d" ; Alternator_PID: alternator duty cycle ; DBG_TPS_ACCEL: from TPS - entry = debugFloatField1, "debug f1",float,"%.4f" + entry = debugFloatField1, "debug f1",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: current integration term ; DBG_TPS_ACCEL: to TPS - entry = debugFloatField2, "debug f2: iTerm",float,"%.4f" + entry = debugFloatField2, "debug f2: iTerm",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: previous error ; DBG_TPS_ACCEL: tps<>tps table value - entry = debugFloatField3, "debug f3: prevError",float,"%.4f" + entry = debugFloatField3, "debug f3: prevError",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: I setting ; DBG_TPS_ACCEL: extra fuel - entry = debugFloatField4, "debug f4: iParam",float,"%.4f" + entry = debugFloatField4, "debug f4: iParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: D setting - entry = debugFloatField5, "debug f5: dParam",float,"%.4f" + entry = debugFloatField5, "debug f5: dParam",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: dTerm - entry = debugFloatField6, "debug f6: dTerm",float,"%.4f" + entry = debugFloatField6, "debug f6: dTerm",float,"%.4f", { !enableLogDebugChannels } - entry = debugFloatField7, "debug f7",float,"%.4f" + entry = debugFloatField7, "debug f7",float,"%.4f", { !enableLogDebugChannels } ; Alternator_PID: P setting - entry = debugIntField1, "debug i1: pParam",int,"%d" + entry = debugIntField1, "debug i1: pParam",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: offset setting - entry = debugIntField2, "debug i2: offset",int,"%d" + entry = debugIntField2, "debug i2: offset",int,"%d", { !enableLogDebugChannels } ; Alternator_PID: PID reset counter - entry = debugIntField3, "debug i3",int,"%d" + entry = debugIntField3, "debug i3",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField4, "debug i4",int,"%d", { !enableLogDebugChannels } + + entry = debugIntField5, "debug i5",int,"%d", { !enableLogDebugChannels } - entry = debugIntField4, "debug i4",int,"%d" - entry = debugIntField5, "debug i5",int,"%d" - - entry = engineMode, "Engine Mode",int,"%d" entry = warningCounter, "warning: counter",int,"%d" entry = lastErrorCode, "warning: last",int,"%d" - entry = recentErrorCode0, "error 0",int,"%d" - entry = recentErrorCode1, "error 1",int,"%d" - entry = recentErrorCode2, "error 2",int,"%d" - entry = recentErrorCode3, "error 3",int,"%d" - entry = recentErrorCode4, "error 4",int,"%d" - entry = recentErrorCode5, "error 5",int,"%d" - entry = recentErrorCode6, "error 6",int,"%d" - entry = recentErrorCode7, "error 7",int,"%d" + entry = recentErrorCode0, "error 0",int,"%d", { !enableLogErrorList } + entry = recentErrorCode1, "error 1",int,"%d", { !enableLogErrorList } + entry = recentErrorCode2, "error 2",int,"%d", { !enableLogErrorList } + entry = recentErrorCode3, "error 3",int,"%d", { !enableLogErrorList } + entry = recentErrorCode4, "error 4",int,"%d", { !enableLogErrorList } + entry = recentErrorCode5, "error 5",int,"%d", { !enableLogErrorList } + entry = recentErrorCode6, "error 6",int,"%d", { !enableLogErrorList } + entry = recentErrorCode7, "error 7",int,"%d", { !enableLogErrorList } entry = internalMcuTemperature, "CPU Temperature",float,"%.2f" entry = tCharge, "tCharge",float,"%.3f" @@ -2258,6 +2357,7 @@ menuDialog = main menu = "&Controller" subMenu = ecuStimulator, "ECU stimulator" + subMenu = datalogSettings, "Datalogging" subMenu = ioTest, "Bench test" subMenu = engineTypeDialog, "Popular vehicles" subMenu = std_separator @@ -2625,6 +2725,10 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" panel = triggerInputComparator dialog = allPinsSensors, "Sensors" + field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel + field = "Primary input channel", triggerInputPins1 + field = "Secondary channel", triggerInputPins2 + field = "Cam Sync/VVT input", camInputs1 field = "CLT ADC input", clt_adcChannel field = "IAT ADC input", iat_adcChannel field = "vBatt ADC input", vbattAdcChannel @@ -2658,10 +2762,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "mc33972_cs", mc33972_cs field = "mc33972 SPI", mc33972spiDevice panel = allPinsSensors - field = "Throttle pedal Position Channel", throttlePedalPositionAdcChannel - field = "Primary input channel", triggerInputPins1 - field = "Secondary channel", triggerInputPins2 - field = "Cam Sync/VVT input", camInputs1 dialog = allPins1_2 field = "Tachometer output Pin", tachOutputPin @@ -2674,13 +2774,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "Idle Stepper Enable", stepperEnablePin field = "Fuel Pump Pin", fuelPumpPin field = "Fuel Pump Pin Mode", fuelPumpPinMode - field = "ETB#1 Dir #1", etb1_directionPin1 - field = "ETB#1 Dir #2", etb1_directionPin2 - field = "ETB#1 Control #1", etb1_controlPin1 - field = "etb1_controlPinMode", etb1_controlPinMode - field = "ETB#2 Dir #1", etb2_directionPin1 - field = "ETB#2 Dir #2", etb2_directionPin2 - field = "ETB#2 Control #1", etb2_controlPin1 + field = "ETB#1 Dir #1", etbIo1_directionPin1 + field = "ETB#1 Dir #2", etbIo1_directionPin2 + field = "ETB#1 Control #1", etbIo1_controlPin1 + field = "etb1_controlPinMode", etbIo1_controlPinMode + field = "ETB#2 Dir #1", etbIo2_directionPin1 + field = "ETB#2 Dir #2", etbIo2_directionPin2 + field = "ETB#2 Control #1", etbIo2_controlPin1 field = "SD CS Pin", sdCardCsPin field = "MIL / Check Engine Pin", malfunctionIndicatorPin field = "MIL / Check Engine Pin Mode", malfunctionIndicatorPinMode @@ -3527,7 +3627,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "No1 Control #1", etbIo1_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "No2 Direction #1", etbIo2_directionPin1, {throttlePedalPositionAdcChannel != 16} field = "No2 Direction #2", etbIo2_directionPin2, {throttlePedalPositionAdcChannel != 16} - field = "No2 Control #1", etb2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} + field = "No2 Control #1", etbIo2_controlPin1, {throttlePedalPositionAdcChannel != 16 && etb_use_two_wires == 0} field = "TPS#2 min", tps2Min, {etbIo2_directionPin1 != 0} field = "TPS#2 max", tps2Max, {etbIo2_directionPin1 != 0} panel = etbPidDialog @@ -3628,6 +3728,11 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "" field = "Engine chart size", engineChartSize + dialog = datalogSettings, "Datalogging Settings" + field = "#Disabling optional logging may increase update rate!" + field = "Log debug channels", enableLogDebugChannels + field = "Log recent errors list", enableLogErrorList + ; Racing Features->Launch Control dialog = smLaunchControl, "Launch Control Settings NOT WORKING" field = "RPM Step1 Limit", step1rpm diff --git a/firmware/util/containers/counter64.h b/firmware/util/containers/counter64.h index 0422e8905a..5f7cd7c9ee 100644 --- a/firmware/util/containers/counter64.h +++ b/firmware/util/containers/counter64.h @@ -1,5 +1,5 @@ /* - * counter64.h + * @file counter64.h * * Created on: Mar 31, 2019 * @author Andrey Belomutskiy, (c) 2012-2019 diff --git a/firmware/util/containers/cyclic_buffer.h b/firmware/util/containers/cyclic_buffer.h index 0a4f7bdf68..5c76adb9ed 100644 --- a/firmware/util/containers/cyclic_buffer.h +++ b/firmware/util/containers/cyclic_buffer.h @@ -26,14 +26,6 @@ class cyclic_buffer public: cyclic_buffer(); explicit cyclic_buffer(int size); - //cpctor - cyclic_buffer(const cyclic_buffer& cb); - //dtor - ~cyclic_buffer(); - - public: - //overloaded =operator - cyclic_buffer& operator=(const cyclic_buffer& rhCb); public: void add(T value); @@ -75,33 +67,6 @@ void cyclic_buffer::baseC(int size) { setSize(size); } -template -cyclic_buffer::cyclic_buffer(const cyclic_buffer& cb) { - //Deep copy the data - currentIndex = cb.currentIndex; - count = cb.count; - size = cb.size; - for (int i = 0; i < size; ++i) { - elements[i] = cb.elements[i]; - } -} - -template -cyclic_buffer::~cyclic_buffer() { - //No dynamic allocation - safe to leave -} - -//template -//cyclic_buffer& cyclic_buffer::operator=(const cyclic_buffer& rhCb) { -// //Deep copy -// currentIndex = rhCb.currentIndex; -// count = rhCb.count; -// for (int i = 0; i < size; ++i) { -// elements[i] = rhCb.elements[i]; -// } -// return *this; -//} - template void cyclic_buffer::add(T value) { elements[currentIndex] = value; diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 657b079f36..79a5f3b870 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -87,16 +87,41 @@ float expf_taylor(float x); #ifdef __cplusplus } +#include + // C++ helpers go here namespace efi { template -constexpr size_t size(const T(&)[N]) -{ +constexpr size_t size(const T(&)[N]) { return N; } } // namespace efi +/** + * Copies an array from src to dest. The lengths of the arrays must match. + */ +template +constexpr void copyArray(TElement (&dest)[N], const TElement (&src)[N]) { + for (size_t i = 0; i < N; i++) { + dest[i] = src[i]; + } +} + +/** + * Copies an array from src to the beginning of dst. If dst is larger + * than src, then only the elements copied from src will be touched. + * Any remaining elements at the end will be untouched. + */ +template +constexpr void copyArrayPartial(TElement (&dest)[NDest], const TElement (&src)[NSrc]) { + static_assert(NDest >= NSrc, "Source array must be larger than destination."); + + for (size_t i = 0; i < NSrc; i++) { + dest[i] = src[i]; + } +} + #endif /* __cplusplus */ #endif /* EFILIB_H_ */ diff --git a/firmware/util/efitime.h b/firmware/util/efitime.h index fe0f7597c4..5a11e869ef 100644 --- a/firmware/util/efitime.h +++ b/firmware/util/efitime.h @@ -19,6 +19,9 @@ #define MS2US(MS_TIME) ((MS_TIME) * 1000) +// milliseconds to ticks +#define MS2NT(msTime) US2NT(MS2US(msTime)) + // todo: implement a function to work with times considering counter overflow #define overflowDiff(now, time) ((now) - (time)) diff --git a/firmware/util/math/pid.cpp b/firmware/util/math/pid.cpp index 8546df9aa4..871a6af1a2 100644 --- a/firmware/util/math/pid.cpp +++ b/firmware/util/math/pid.cpp @@ -124,14 +124,14 @@ void Pid::setErrorAmplification(float coef) { } #if EFI_TUNER_STUDIO -void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) { +void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) const { postState(tsOutputChannels, 1); } /** * see https://rusefi.com/wiki/index.php?title=Manual:Debug_fields */ -void Pid::postState(TunerStudioOutputChannels *tsOutputChannels, int pMult) { +void Pid::postState(TunerStudioOutputChannels *tsOutputChannels, int pMult) const { tsOutputChannels->debugFloatField1 = output; tsOutputChannels->debugFloatField2 = iTerm; tsOutputChannels->debugFloatField3 = getPrevError(); diff --git a/firmware/util/math/pid.h b/firmware/util/math/pid.h index 1374894317..966cec8812 100644 --- a/firmware/util/math/pid.h +++ b/firmware/util/math/pid.h @@ -60,8 +60,8 @@ public: float getPrevError(void) const; void setErrorAmplification(float coef); #if EFI_TUNER_STUDIO - void postState(TunerStudioOutputChannels *tsOutputChannels); - void postState(TunerStudioOutputChannels *tsOutputChannels, int pMult); + void postState(TunerStudioOutputChannels *tsOutputChannels) const; + void postState(TunerStudioOutputChannels *tsOutputChannels, int pMult) const; #endif /* EFI_TUNER_STUDIO */ void showPidStatus(Logging *logging, const char*msg) const; void sleep(); @@ -122,8 +122,8 @@ public: public: // todo: move this to pid_s one day - float_t antiwindupFreq = 0.0f; // = 1/ResetTime - float_t derivativeFilterLoss = 0.0f; // = 1/Gain + float antiwindupFreq = 0.0f; // = 1/ResetTime + float derivativeFilterLoss = 0.0f; // = 1/Gain private: float limitOutput(float v) const; diff --git a/firmware/util/math/signal_filtering.c b/firmware/util/math/signal_filtering.c index 1287f42581..d137bdd054 100644 --- a/firmware/util/math/signal_filtering.c +++ b/firmware/util/math/signal_filtering.c @@ -21,8 +21,7 @@ static void addCopyAndSort(SignalFiltering *fs, float value) { fs->values[fs->pointer] = value; fs->pointer = ++fs->pointer == FILTER_SIZE ? 0 : fs->pointer; - for (int i = 0; i < FILTER_SIZE; i++) - fs->sorted[i] = fs->values[i]; + copyArray(fs->sorted, fs->values); for (int i = 0; i < FILTER_SIZE; i++) for (int j = i + 1; j < FILTER_SIZE; j++) diff --git a/hardware/Common_Rail_MC33816/gerbers/readme.md b/hardware/Common_Rail_MC33816/gerbers/readme.md new file mode 100644 index 0000000000..885c36fb08 --- /dev/null +++ b/hardware/Common_Rail_MC33816/gerbers/readme.md @@ -0,0 +1,11 @@ +# R0.1 +![img](https://raw.githubusercontent.com/wiki/rusefi/rusefi_documentation/Hardware/MC33816_test_board/MC33816_test_board_0_1_half_assembled.jpg) + +![img](https://raw.githubusercontent.com/wiki/rusefi/rusefi_documentation/Hardware/MC33816_test_board/MC33816_test_board_0_1_assembled_1.jpg) + +![img](https://raw.githubusercontent.com/wiki/rusefi/rusefi_documentation/Hardware/MC33816_test_board/MC33816_test_board_0_1_assembled_2.jpg) + +![img](https://raw.githubusercontent.com/wiki/rusefi/rusefi_documentation/Hardware/MC33816_test_board/MC33816_test_board_0_1_assembled_3.jpg) + +![img](https://raw.githubusercontent.com/wiki/rusefi/rusefi_documentation/Hardware/MC33816_test_board/MC33816_test_board_0_1_assembled_4.jpg) + diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index 99eae07a0a..e3a2c2f159 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -13,11 +13,11 @@ import com.rusefi.io.ConnectionStatus; import com.rusefi.waves.EngineChart; import com.rusefi.waves.EngineReport; -import static com.rusefi.IoUtil.sleep; +import static com.rusefi.IoUtil.*; +import static com.rusefi.IoUtil.getEnableCommand; import static com.rusefi.TestingUtils.*; import static com.rusefi.config.generated.Fields.CMD_PINS; import static com.rusefi.config.generated.Fields.MOCK_MAF_COMMAND; -import static com.rusefi.io.CommandQueue.disableCommand; import static com.rusefi.waves.EngineReport.isCloseEnough; /** @@ -46,8 +46,8 @@ public class AutoTest { // let's make sure 'burn' command works since sometimes it does not bp.burn(Logger.CONSOLE); - sendCommand("fl 1"); // just in case it was disabled - sendCommand(disableCommand(Fields.CMD_TRIGGER_HW_INPUT)); + sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT)); + sendCommand(getEnableCommand(Fields.CMD_FUNCTIONAL_TEST_MODE)); testCustomEngine(); testMazdaMiata2003(); test2003DodgeNeon(); @@ -101,13 +101,13 @@ public class AutoTest { String msg = "BMW"; EngineChart chart; IoUtil.changeRpm(200); - chart = nextChart(); + chart = nextChart1(); double x = 173.988; // something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle? assertWave(msg, chart, EngineChart.SPARK_1, 0.0199666, x, x + 180, x + 360, x + 540); IoUtil.changeRpm(1200); - chart = nextChart(); + chart = nextChart1(); x = 688.464; // something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle? @@ -136,20 +136,21 @@ public class AutoTest { } static void setEngineType(int type) { - sendCommand(CMD_PINS); + FileLog.MAIN.logLine("AUTOTEST setEngineType " + type); +// sendCommand(CMD_PINS); currentEngineType = type; sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, 30); - sleep(10); - sendCommand("enable self_stimulation"); + // TODO: document the reason for this sleep?! + sleep(1); + sendCommand(getEnableCommand("self_stimulation")); } private static void testMazda626() { setEngineType(28); String msg = "mazda 626 default cranking"; IoUtil.changeRpm(200); - sendCommand(Fields.CMD_TRIGGERINFO); EngineChart chart; - chart = nextChart(); + chart = nextChart1(); double x = 102; assertWave(msg, chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540); @@ -203,7 +204,7 @@ public class AutoTest { assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.29233, 0.15, EngineReport.RATIO, x + 540); assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.15, 0.2, x); - sendCommand("enable trigger_only_front"); + sendCommand(getEnableCommand("trigger_only_front")); chart = nextChart(); assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.29233, 0.1, 0.2, x + 360); assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.29233, EngineReport.RATIO, 0.2, x + 180); @@ -211,12 +212,12 @@ public class AutoTest { assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.1, 0.2, x); sendCommand("set_whole_timing_map 520"); - chart = nextChart(); + chart = nextChart1(); x = 328; assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540); sendCommand("set_whole_timing_map 0"); - chart = nextChart(); + chart = nextChart1(); x = 128; assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540); } @@ -229,7 +230,7 @@ public class AutoTest { IoUtil.changeRpm(260); IoUtil.changeRpm(200); String msg = "ProtegeLX cranking"; - chart = nextChart(); + chart = nextChart1(); assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1); double x = 107; assertWave(msg, chart, EngineChart.SPARK_3, 0.194433, x); @@ -240,7 +241,7 @@ public class AutoTest { msg = "ProtegeLX running"; IoUtil.changeRpm(2000); - chart = nextChart(); + chart = nextChart1(); x = 112; assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540); x = 0; @@ -257,7 +258,7 @@ public class AutoTest { * note that command order matters - RPM change resets wave chart */ IoUtil.changeRpm(2000); - chart = nextChart(); + chart = nextChart1(); String msg = "1995 Neon"; double x = -70; @@ -277,7 +278,7 @@ public class AutoTest { sendComplexCommand("set algorithm 3"); IoUtil.changeRpm(2600); IoUtil.changeRpm(2000); - chart = nextChart(); + chart = nextChart1(); x = -70; assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.493, x + 540); } @@ -290,7 +291,7 @@ public class AutoTest { setEngineType(4); EngineChart chart; IoUtil.changeRpm(2000); - chart = nextChart(); + chart = nextChart1(); String msg = "Fiesta"; double x = 312; @@ -304,7 +305,7 @@ public class AutoTest { setEngineType(7); EngineChart chart; IoUtil.changeRpm(2000); - chart = nextChart(); + chart = nextChart1(); String msg = "ford 6"; @@ -312,8 +313,8 @@ public class AutoTest { assertWave(msg, chart, EngineChart.SPARK_1, 0.01666, x, x + 120, x + 240, x + 360, x + 480, x + 600); assertWaveNull(msg, chart, EngineChart.TRIGGER_2); - sendComplexCommand("set trigger_type 1"); // TT_FORD_ASPIRE - chart = nextChart(); + sendComplexCommand("set " + "trigger_type" + " 1"); // TT_FORD_ASPIRE + chart = nextChart1(); assertTrue(msg, chart.get(EngineChart.TRIGGER_2) != null); } @@ -329,14 +330,14 @@ public class AutoTest { IoUtil.changeRpm(200); double x; - chart = nextChart(); + chart = nextChart1(); assertEquals(12, SensorCentral.getInstance().getValue(Sensor.VBATT)); x = 55; assertWave("aspire default cranking ", chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540); IoUtil.changeRpm(600); - chart = nextChart(); + chart = nextChart1(); x = 78; assertWave(true, "aspire default running ", chart, EngineChart.SPARK_1, 0.04, 0.1, 0.1, x, x + 180, x + 360, x + 540); @@ -424,7 +425,6 @@ public class AutoTest { sendComplexCommand("set algorithm 3"); IoUtil.changeRpm(2400); IoUtil.changeRpm(2000); - nextChart(); chart = nextChart(); assertEquals("MAP",69.12, SensorCentral.getInstance().getValue(Sensor.MAP)); //assertEquals(1, SensorCentral.getInstance().getValue(Sensor.)); diff --git a/java_console/autotest/src/com/rusefi/EnduranceTest.java b/java_console/autotest/src/com/rusefi/EnduranceTest.java index cb6ec4cfff..deb453ef07 100644 --- a/java_console/autotest/src/com/rusefi/EnduranceTest.java +++ b/java_console/autotest/src/com/rusefi/EnduranceTest.java @@ -2,8 +2,7 @@ package com.rusefi; import com.rusefi.config.generated.Fields; -import static com.rusefi.IoUtil.sendCommand; -import static com.rusefi.IoUtil.sleep; +import static com.rusefi.IoUtil.*; import static com.rusefi.RealHwTest.startRealHardwareTest; public class EnduranceTest { @@ -28,7 +27,7 @@ public class EnduranceTest { AutoTest.currentEngineType = 3; sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, AutoTest.COMPLEX_COMMAND_RETRY, 60); sleep(2); - sendCommand("enable self_stimulation"); + sendCommand(getEnableCommand("self_stimulation")); // IoUtil.changeRpm(1200); AutoTest.currentEngineType = 28; sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, AutoTest.COMPLEX_COMMAND_RETRY, 60); diff --git a/java_console/autotest/src/com/rusefi/IoUtil.java b/java_console/autotest/src/com/rusefi/IoUtil.java index a89f9697b0..63d74cf380 100644 --- a/java_console/autotest/src/com/rusefi/IoUtil.java +++ b/java_console/autotest/src/com/rusefi/IoUtil.java @@ -20,8 +20,6 @@ import static com.rusefi.waves.EngineReport.isCloseEnough; */ public class IoUtil { - public static final String RESET_ENGINE_CHART = "reset_engine_chart"; - /** * Send a command and wait for the confirmation * @@ -31,6 +29,17 @@ public class IoUtil { sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT); } + public static String getEnableCommand(String settingName) { + return Fields.CMD_ENABLE + " " + settingName; + } + + public static String getDisableCommand(String settingName) { + return Fields.CMD_DISABLE + " " + settingName; + } + + /** + * blocking method which would for confirmation from rusEfi + */ static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) { final CountDownLatch responseLatch = new CountDownLatch(1); long time = System.currentTimeMillis(); @@ -62,6 +71,7 @@ public class IoUtil { } static void changeRpm(final int rpm) { + FileLog.MAIN.logLine("AUTOTEST rpm EN " + rpm); sendCommand("rpm " + rpm); long time = System.currentTimeMillis(); @@ -80,25 +90,20 @@ public class IoUtil { } catch (InterruptedException e) { throw new IllegalStateException(e); } - FileLog.MAIN.logLine("RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time)); SensorCentral.getInstance().removeListener(Sensor.RPM, listener); double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPM); if (!isCloseEnough(rpm, actualRpm)) throw new IllegalStateException("rpm change did not happen: " + rpm + ", actual " + actualRpm); - sendCommand(RESET_ENGINE_CHART); +// sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER); + FileLog.MAIN.logLine("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time)); } static void waitForFirstResponse() throws InterruptedException { FileLog.MAIN.logLine("Let's give it some time to start..."); final CountDownLatch startup = new CountDownLatch(1); - SensorCentral.SensorListener listener = new SensorCentral.SensorListener() { - @Override - public void onSensorUpdate(double value) { - startup.countDown(); - } - }; + SensorCentral.SensorListener listener = value -> startup.countDown(); long waitStart = System.currentTimeMillis(); SensorCentral.getInstance().addListener(Sensor.RPM, listener); startup.await(5, TimeUnit.SECONDS); @@ -158,5 +163,4 @@ public class IoUtil { if (connected.getCount() > 0) throw new IllegalStateException("Not connected in time"); } - } diff --git a/java_console/autotest/src/com/rusefi/RealHwTest.java b/java_console/autotest/src/com/rusefi/RealHwTest.java index e503d2da22..66659e3ae4 100644 --- a/java_console/autotest/src/com/rusefi/RealHwTest.java +++ b/java_console/autotest/src/com/rusefi/RealHwTest.java @@ -1,44 +1,68 @@ package com.rusefi; import com.rusefi.io.LinkManager; +import org.jetbrains.annotations.NotNull; + +import java.io.PrintWriter; +import java.io.StringWriter; import static com.rusefi.AutoTest.mainTestBody; import static com.rusefi.Timeouts.SECOND; /** * this test connects to real hardware via serial port - * (c) Andrey Belomutskiy 2013-2018 + * (c) Andrey Belomutskiy 2013-2019 * 2/22/2015 */ public class RealHwTest { - private static final int STARTUP_SLEEP = 45; + private static final int STARTUP_SLEEP = 20; public static void main(String[] args) throws InterruptedException { System.out.println("Sleeping " + STARTUP_SLEEP + " seconds to give OS time to connect VCP driver"); Thread.sleep(STARTUP_SLEEP * SECOND); - long start = System.currentTimeMillis(); - String port = startRealHardwareTest(args); - if (port == null) - return; - boolean failed = false; - try { - runRealHardwareTest(port); - } catch (Throwable e) { - e.printStackTrace(); - failed = true; - } - if (failed) + boolean isSuccess = runHardwareTest(args); + if (!isSuccess) System.exit(-1); FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ Real Hardware Test Passed +++++++++++++++"); FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); - long time = (System.currentTimeMillis() - start) / 1000; - FileLog.MAIN.logLine("Done in " + time + "secs"); System.exit(0); // this is a safer method eliminating the issue of non-daemon threads } - static String startRealHardwareTest(String[] args) { + /** + * @return true if test is a SUCCESS, false if a FAILURE + */ + public static boolean runHardwareTest(String[] args) { + String port = startRealHardwareTest(args); + if (port == null) { + return false; + } else { + return runHardwareTest(port); + } + } + + /** + * @return true if test is a SUCCESS, false if a FAILURE + */ + public static boolean runHardwareTest(String port) { + long start = System.currentTimeMillis(); + try { + runRealHardwareTest(port); + } catch (Throwable e) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + FileLog.MAIN.logLine("Test failed: " + e + " at " + sw); + e.printStackTrace(); + return false; + } + long time = (System.currentTimeMillis() - start) / 1000; + FileLog.MAIN.logLine("Done in " + time + "secs"); + return true; + } + + static String startRealHardwareTest(@NotNull String[] args) { /** * with real hardware we have noise on all analog inputs which gives us random sensor data, we cannot really * test exact numbers yet @@ -49,6 +73,7 @@ public class RealHwTest { if (args.length == 1 || args.length == 2) { port = args[0]; } else if (args.length == 0) { + // todo: reuse 'PortDetector.autoDetectPort' here? port = LinkManager.getDefaultPort(); } else { System.out.println("Only one optional argument expected: port number"); diff --git a/java_console/autotest/src/com/rusefi/TestingUtils.java b/java_console/autotest/src/com/rusefi/TestingUtils.java index e8dec1793e..666fe8b157 100644 --- a/java_console/autotest/src/com/rusefi/TestingUtils.java +++ b/java_console/autotest/src/com/rusefi/TestingUtils.java @@ -1,5 +1,6 @@ package com.rusefi; +import com.rusefi.config.generated.Fields; import com.rusefi.core.EngineState; import com.rusefi.io.LinkManager; import com.rusefi.waves.EngineChart; @@ -105,13 +106,31 @@ public class TestingUtils { } static EngineChart nextChart() { - getNextWaveChart(); - getNextWaveChart(); + long start = System.currentTimeMillis(); + /** + * we are pretty inefficient here :( we wait for the next chart with new settings already applied + * a potential improvement would be maybe a special test mode which would reset engine sniffer buffer on each + * setting change? + * + * also open question why do we skip TWO full charts. maybe we account for fast or slow callback period? + * + * WOW, actually we DO have CMD_RESET_ENGINE_SNIFFER already and yet things are STILL pretty slow and unreliable?! + * @see Fields#CMD_FUNCTIONAL_TEST_MODE + * @see Fields#CMD_RESET_ENGINE_SNIFFER + */ +// getNextWaveChart(); +// getNextWaveChart(); + EngineChart chart = EngineChartParser.unpackToMap(getNextWaveChart()); + FileLog.MAIN.logLine("AUTOTEST nextChart() in " + (System.currentTimeMillis() - start)); + return chart; + } + + static EngineChart nextChart1() { return EngineChartParser.unpackToMap(getNextWaveChart()); } static String getNextWaveChart() { - IoUtil.sendCommand(IoUtil.RESET_ENGINE_CHART); + IoUtil.sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER); String result = getEngineChart(); FileLog.MAIN.logLine("current chart: " + result); return result; diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index 21d2516e62..ac8c8793c3 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -393,23 +393,41 @@ public class BinaryProtocol implements BinaryProtocolCommands { currentOutputs = response; for (Sensor sensor : Sensor.values()) { + if (sensor.getType() == null) { + // for example ETB_CONTROL_QUALITY, weird use-case + continue; + } + ByteBuffer bb = ByteBuffer.wrap(response, 1 + sensor.getOffset(), 4); bb.order(ByteOrder.LITTLE_ENDIAN); - if (sensor.getType() == FieldType.FLOAT) { - double value = bb.getFloat(); - SensorCentral.getInstance().setValue(value, sensor); - } else if (sensor.getType() == FieldType.INT) { - int value = bb.getInt(); - SensorCentral.getInstance().setValue(value, sensor); - } else if (sensor.getType() == FieldType.INT16) { - short value = (short) (bb.getInt() & 0xFFFF); - SensorCentral.getInstance().setValue(value, sensor); - } else if (sensor.getType() == null) { - // do nothing for old text sensors which I am suprised are still in the code - } else - throw new UnsupportedOperationException("type " + sensor.getType()); + double rawValue = getValueForChannel(bb, sensor); + double scaledValue = rawValue * sensor.getScale(); + SensorCentral.getInstance().setValue(scaledValue, sensor); } return true; } + + private static double getValueForChannel(ByteBuffer bb, Sensor sensor) { + switch (sensor.getType()) { + case FLOAT: + return bb.getFloat(); + case INT: + return bb.getInt(); + case UINT16: + // no cast - we want to discard sign + return bb.getInt() & 0xFFFF; + case INT16: + // cast - we want to retain sign + return (short)(bb.getInt() & 0xFFFF); + case UINT8: + // no cast - discard sign + return bb.getInt() & 0xFF; + case INT8: + // cast - retain sign + return (byte)(bb.getInt() & 0xFF); + default: + throw new UnsupportedOperationException("type " + sensor.getType()); + } + } } diff --git a/java_console/io/src/com/rusefi/io/CommandQueue.java b/java_console/io/src/com/rusefi/io/CommandQueue.java index 11bb5c393e..e92118ed32 100644 --- a/java_console/io/src/com/rusefi/io/CommandQueue.java +++ b/java_console/io/src/com/rusefi/io/CommandQueue.java @@ -230,7 +230,4 @@ public class CommandQueue { void onCommand(String command); } - public static String disableCommand(String command) { - return Fields.CMD_DISABLE + " " + command; - } } diff --git a/java_console/io/src/com/rusefi/io/LinkManager.java b/java_console/io/src/com/rusefi/io/LinkManager.java index 8f2920718d..1c298c9b44 100644 --- a/java_console/io/src/com/rusefi/io/LinkManager.java +++ b/java_console/io/src/com/rusefi/io/LinkManager.java @@ -182,6 +182,7 @@ public class LinkManager { return null; } String port = ports[ports.length - 1]; + // todo: reuse 'PortDetector.autoDetectPort' here? System.out.println("Using last of " + ports.length + " port(s)"); System.out.println("All ports: " + Arrays.toString(ports)); return port; diff --git a/java_console/models/src/com/rusefi/config/FieldType.java b/java_console/models/src/com/rusefi/config/FieldType.java index b1651ddee8..cbcf4f11a4 100644 --- a/java_console/models/src/com/rusefi/config/FieldType.java +++ b/java_console/models/src/com/rusefi/config/FieldType.java @@ -1,19 +1,25 @@ package com.rusefi.config; public enum FieldType { - INT(4), - /** - * signed 16 bit type - */ - INT16(2), + // Signed INT8(1), + INT16(2), + INT(4), + + // Unsigned + UINT8(1), + UINT16(2), + BIT(/*bits are stored in 4 byte packs */4), FLOAT(4); public static final String INT_TYPE_STRING = "int"; public static final String FLOAT_TYPE_STRING = "float"; public static final String BYTE_TYPE_STRING = "byte"; + public static final String UBYTE_TYPE_STRING = "ubyte"; public static final String SHORT_TYPE_STRING = "short"; + public static final String USHORT_TYPE_STRING = "ushort"; + private final int storageSize; FieldType(int storageSize) { @@ -26,8 +32,12 @@ public enum FieldType { return FLOAT_TYPE_STRING; case INT16: return SHORT_TYPE_STRING; + case UINT16: + return USHORT_TYPE_STRING; case INT8: return BYTE_TYPE_STRING; + case UINT8: + return UBYTE_TYPE_STRING; case INT: default: return INT_TYPE_STRING; 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 793263ad05..79bd255e52 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 integration\rusefi_config.txt Sun Dec 08 00:20:37 EST 2019 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sat Dec 21 20:09:07 EST 2019 // by class com.rusefi.output.FileJavaFieldsConsumer import com.rusefi.config.*; @@ -152,8 +152,6 @@ public class Fields { public static final int baroSensor_offset_hex = 248; public static final int baroSensor_type_offset = 592; public static final int baroSensor_type_offset_hex = 250; - public static final int bc_offset = 600; - public static final int bc_offset_hex = 258; public static final int binarySerialRxPin_offset = 1815; public static final int binarySerialRxPin_offset_hex = 717; public static final int binarySerialTxPin_offset = 1814; @@ -244,9 +242,11 @@ public class Fields { public static final String CMD_ENABLE = "enable"; public static final String CMD_ENGINE_TYPE = "engine_type"; public static final String CMD_ETB_DUTY = "set_etb_duty"; + public static final String CMD_FUNCTIONAL_TEST_MODE = "test_mode"; public static final String CMD_PINS = "pins"; public static final String CMD_REBOOT = "reboot"; public static final String CMD_REBOOT_DFU = "reboot_dfu"; + public static final String CMD_RESET_ENGINE_SNIFFER = "reset_engine_chart"; public static final String CMD_TRIGGER_HW_INPUT = "trigger_hw_input"; public static final String CMD_TRIGGERINFO = "triggerinfo"; public static final String CMD_WRITECONFIG = "writeconfig"; @@ -1024,6 +1024,13 @@ public class Fields { public static final int overrideCrankingIacSetting_offset = 1476; public static final int overrideCrankingIgnition_offset = 516; public static final int overrideCrankingIgnition_offset_hex = 204; + public static final int PACK_MULT_AFR = 1000; + public static final int PACK_MULT_ANGLE = 50; + public static final int PACK_MULT_MS = 300; + public static final int PACK_MULT_PERCENT = 100; + public static final int PACK_MULT_PRESSURE = 30; + public static final int PACK_MULT_TEMPERATURE = 100; + public static final int PACK_MULT_VOLTAGE = 1000; public static final int pauseEtbControl_offset = 744; public static final int PEDAL_TO_TPS_SIZE = 8; public static final int pedalToTpsPedalBins_offset = 6464; @@ -1218,6 +1225,64 @@ public class Fields { public static final int trigger_offset = 524; public static final int TRIGGER_SIMULATOR_PIN_COUNT = 3; public static final int trigger_type_offset = 524; + public static final int trigger_unusedBit_4_10_offset = 528; + public static final int trigger_unusedBit_4_10_offset_hex = 210; + public static final int trigger_unusedBit_4_11_offset = 528; + public static final int trigger_unusedBit_4_11_offset_hex = 210; + public static final int trigger_unusedBit_4_12_offset = 528; + public static final int trigger_unusedBit_4_12_offset_hex = 210; + public static final int trigger_unusedBit_4_13_offset = 528; + public static final int trigger_unusedBit_4_13_offset_hex = 210; + public static final int trigger_unusedBit_4_14_offset = 528; + public static final int trigger_unusedBit_4_14_offset_hex = 210; + public static final int trigger_unusedBit_4_15_offset = 528; + public static final int trigger_unusedBit_4_15_offset_hex = 210; + public static final int trigger_unusedBit_4_16_offset = 528; + public static final int trigger_unusedBit_4_16_offset_hex = 210; + public static final int trigger_unusedBit_4_17_offset = 528; + public static final int trigger_unusedBit_4_17_offset_hex = 210; + public static final int trigger_unusedBit_4_18_offset = 528; + public static final int trigger_unusedBit_4_18_offset_hex = 210; + public static final int trigger_unusedBit_4_19_offset = 528; + public static final int trigger_unusedBit_4_19_offset_hex = 210; + public static final int trigger_unusedBit_4_20_offset = 528; + public static final int trigger_unusedBit_4_20_offset_hex = 210; + public static final int trigger_unusedBit_4_21_offset = 528; + public static final int trigger_unusedBit_4_21_offset_hex = 210; + public static final int trigger_unusedBit_4_22_offset = 528; + public static final int trigger_unusedBit_4_22_offset_hex = 210; + public static final int trigger_unusedBit_4_23_offset = 528; + public static final int trigger_unusedBit_4_23_offset_hex = 210; + public static final int trigger_unusedBit_4_24_offset = 528; + public static final int trigger_unusedBit_4_24_offset_hex = 210; + public static final int trigger_unusedBit_4_25_offset = 528; + public static final int trigger_unusedBit_4_25_offset_hex = 210; + public static final int trigger_unusedBit_4_26_offset = 528; + public static final int trigger_unusedBit_4_26_offset_hex = 210; + public static final int trigger_unusedBit_4_27_offset = 528; + public static final int trigger_unusedBit_4_27_offset_hex = 210; + public static final int trigger_unusedBit_4_28_offset = 528; + public static final int trigger_unusedBit_4_28_offset_hex = 210; + public static final int trigger_unusedBit_4_29_offset = 528; + public static final int trigger_unusedBit_4_29_offset_hex = 210; + public static final int trigger_unusedBit_4_30_offset = 528; + public static final int trigger_unusedBit_4_30_offset_hex = 210; + public static final int trigger_unusedBit_4_31_offset = 528; + public static final int trigger_unusedBit_4_31_offset_hex = 210; + public static final int trigger_unusedBit_4_3_offset = 528; + public static final int trigger_unusedBit_4_3_offset_hex = 210; + public static final int trigger_unusedBit_4_4_offset = 528; + public static final int trigger_unusedBit_4_4_offset_hex = 210; + public static final int trigger_unusedBit_4_5_offset = 528; + public static final int trigger_unusedBit_4_5_offset_hex = 210; + public static final int trigger_unusedBit_4_6_offset = 528; + public static final int trigger_unusedBit_4_6_offset_hex = 210; + public static final int trigger_unusedBit_4_7_offset = 528; + public static final int trigger_unusedBit_4_7_offset_hex = 210; + public static final int trigger_unusedBit_4_8_offset = 528; + public static final int trigger_unusedBit_4_8_offset_hex = 210; + public static final int trigger_unusedBit_4_9_offset = 528; + public static final int trigger_unusedBit_4_9_offset_hex = 210; public static final int trigger_unusedCustomIsSynchronizationNeeded_offset = 528; public static final int trigger_unusedCustomIsSynchronizationNeeded_offset_hex = 210; public static final int trigger_unusedCustomNeedSecondTriggerInput_offset = 528; @@ -1240,9 +1305,9 @@ public class Fields { public static final int triggerSimulatorPins1_offset = 736; public static final int triggerSimulatorPins2_offset = 737; public static final int triggerSimulatorPins3_offset = 738; - public static final int TS_FILE_VERSION = 20190701; - public static final int TS_OUTPUT_SIZE = 356; - public static final String TS_SIGNATURE = "rusEFI v1.07"; + public static final int TS_FILE_VERSION = 20191221; + public static final int TS_OUTPUT_SIZE = 220; + public static final String TS_SIGNATURE = "rusEFI v1.08"; public static final int tunerStudioSerialSpeed_offset = 728; public static final int twoWireBatchIgnition_offset = 1476; public static final int twoWireBatchInjection_offset = 1476; @@ -1267,6 +1332,37 @@ public class Fields { public static final int unused_offset = 972; public static final int unusedAnotherOne_offset = 744; public static final int unusedAtOldBoardConfigurationEnd_offset = 988; + public static final int unusedBit_247_10_offset = 976; + public static final int unusedBit_247_11_offset = 976; + public static final int unusedBit_247_12_offset = 976; + public static final int unusedBit_247_13_offset = 976; + public static final int unusedBit_247_14_offset = 976; + public static final int unusedBit_247_15_offset = 976; + public static final int unusedBit_247_16_offset = 976; + public static final int unusedBit_247_17_offset = 976; + public static final int unusedBit_247_18_offset = 976; + public static final int unusedBit_247_19_offset = 976; + public static final int unusedBit_247_20_offset = 976; + public static final int unusedBit_247_21_offset = 976; + public static final int unusedBit_247_22_offset = 976; + public static final int unusedBit_247_23_offset = 976; + public static final int unusedBit_247_24_offset = 976; + public static final int unusedBit_247_25_offset = 976; + public static final int unusedBit_247_26_offset = 976; + public static final int unusedBit_247_27_offset = 976; + public static final int unusedBit_247_28_offset = 976; + public static final int unusedBit_247_29_offset = 976; + public static final int unusedBit_247_2_offset = 976; + public static final int unusedBit_247_30_offset = 976; + public static final int unusedBit_247_31_offset = 976; + public static final int unusedBit_247_3_offset = 976; + public static final int unusedBit_247_4_offset = 976; + public static final int unusedBit_247_5_offset = 976; + public static final int unusedBit_247_6_offset = 976; + public static final int unusedBit_247_7_offset = 976; + public static final int unusedBit_247_8_offset = 976; + public static final int unusedBit_247_9_offset = 976; + 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 = 1772; @@ -1375,6 +1471,7 @@ public class Fields { public static final Field ISSUE_294_29 = Field.create("ISSUE_294_29", 76, FieldType.BIT, 28); public static final Field ISSUE_294_30 = Field.create("ISSUE_294_30", 76, FieldType.BIT, 29); public static final Field ISSUE_294_31 = Field.create("ISSUE_294_31", 76, FieldType.BIT, 30); + public static final Field UNUSEDBIT_34_31 = Field.create("UNUSEDBIT_34_31", 76, FieldType.BIT, 31); public static final Field TPSMIN = Field.create("TPSMIN", 80, FieldType.INT16); public static final Field TPSMAX = Field.create("TPSMAX", 82, FieldType.INT16); public static final Field TPSERRORDETECTIONTOOLOW = Field.create("TPSERRORDETECTIONTOOLOW", 84, FieldType.INT16); @@ -1450,6 +1547,35 @@ public class Fields { public static final Field TRIGGER_UNUSEDCUSTOMISSYNCHRONIZATIONNEEDED = Field.create("TRIGGER_UNUSEDCUSTOMISSYNCHRONIZATIONNEEDED", 528, FieldType.BIT, 0); public static final Field TRIGGER_UNUSEDCUSTOMNEEDSECONDTRIGGERINPUT = Field.create("TRIGGER_UNUSEDCUSTOMNEEDSECONDTRIGGERINPUT", 528, FieldType.BIT, 1); public static final Field TRIGGER_USEONLYFIRSTCHANNEL = Field.create("TRIGGER_USEONLYFIRSTCHANNEL", 528, FieldType.BIT, 2); + public static final Field TRIGGER_UNUSEDBIT_4_3 = Field.create("TRIGGER_UNUSEDBIT_4_3", 528, FieldType.BIT, 3); + public static final Field TRIGGER_UNUSEDBIT_4_4 = Field.create("TRIGGER_UNUSEDBIT_4_4", 528, FieldType.BIT, 4); + public static final Field TRIGGER_UNUSEDBIT_4_5 = Field.create("TRIGGER_UNUSEDBIT_4_5", 528, FieldType.BIT, 5); + public static final Field TRIGGER_UNUSEDBIT_4_6 = Field.create("TRIGGER_UNUSEDBIT_4_6", 528, FieldType.BIT, 6); + public static final Field TRIGGER_UNUSEDBIT_4_7 = Field.create("TRIGGER_UNUSEDBIT_4_7", 528, FieldType.BIT, 7); + public static final Field TRIGGER_UNUSEDBIT_4_8 = Field.create("TRIGGER_UNUSEDBIT_4_8", 528, FieldType.BIT, 8); + public static final Field TRIGGER_UNUSEDBIT_4_9 = Field.create("TRIGGER_UNUSEDBIT_4_9", 528, FieldType.BIT, 9); + public static final Field TRIGGER_UNUSEDBIT_4_10 = Field.create("TRIGGER_UNUSEDBIT_4_10", 528, FieldType.BIT, 10); + public static final Field TRIGGER_UNUSEDBIT_4_11 = Field.create("TRIGGER_UNUSEDBIT_4_11", 528, FieldType.BIT, 11); + public static final Field TRIGGER_UNUSEDBIT_4_12 = Field.create("TRIGGER_UNUSEDBIT_4_12", 528, FieldType.BIT, 12); + public static final Field TRIGGER_UNUSEDBIT_4_13 = Field.create("TRIGGER_UNUSEDBIT_4_13", 528, FieldType.BIT, 13); + public static final Field TRIGGER_UNUSEDBIT_4_14 = Field.create("TRIGGER_UNUSEDBIT_4_14", 528, FieldType.BIT, 14); + public static final Field TRIGGER_UNUSEDBIT_4_15 = Field.create("TRIGGER_UNUSEDBIT_4_15", 528, FieldType.BIT, 15); + public static final Field TRIGGER_UNUSEDBIT_4_16 = Field.create("TRIGGER_UNUSEDBIT_4_16", 528, FieldType.BIT, 16); + public static final Field TRIGGER_UNUSEDBIT_4_17 = Field.create("TRIGGER_UNUSEDBIT_4_17", 528, FieldType.BIT, 17); + public static final Field TRIGGER_UNUSEDBIT_4_18 = Field.create("TRIGGER_UNUSEDBIT_4_18", 528, FieldType.BIT, 18); + public static final Field TRIGGER_UNUSEDBIT_4_19 = Field.create("TRIGGER_UNUSEDBIT_4_19", 528, FieldType.BIT, 19); + public static final Field TRIGGER_UNUSEDBIT_4_20 = Field.create("TRIGGER_UNUSEDBIT_4_20", 528, FieldType.BIT, 20); + public static final Field TRIGGER_UNUSEDBIT_4_21 = Field.create("TRIGGER_UNUSEDBIT_4_21", 528, FieldType.BIT, 21); + public static final Field TRIGGER_UNUSEDBIT_4_22 = Field.create("TRIGGER_UNUSEDBIT_4_22", 528, FieldType.BIT, 22); + public static final Field TRIGGER_UNUSEDBIT_4_23 = Field.create("TRIGGER_UNUSEDBIT_4_23", 528, FieldType.BIT, 23); + public static final Field TRIGGER_UNUSEDBIT_4_24 = Field.create("TRIGGER_UNUSEDBIT_4_24", 528, FieldType.BIT, 24); + public static final Field TRIGGER_UNUSEDBIT_4_25 = Field.create("TRIGGER_UNUSEDBIT_4_25", 528, FieldType.BIT, 25); + public static final Field TRIGGER_UNUSEDBIT_4_26 = Field.create("TRIGGER_UNUSEDBIT_4_26", 528, FieldType.BIT, 26); + public static final Field TRIGGER_UNUSEDBIT_4_27 = Field.create("TRIGGER_UNUSEDBIT_4_27", 528, FieldType.BIT, 27); + public static final Field TRIGGER_UNUSEDBIT_4_28 = Field.create("TRIGGER_UNUSEDBIT_4_28", 528, FieldType.BIT, 28); + public static final Field TRIGGER_UNUSEDBIT_4_29 = Field.create("TRIGGER_UNUSEDBIT_4_29", 528, FieldType.BIT, 29); + public static final Field TRIGGER_UNUSEDBIT_4_30 = Field.create("TRIGGER_UNUSEDBIT_4_30", 528, FieldType.BIT, 30); + public static final Field TRIGGER_UNUSEDBIT_4_31 = Field.create("TRIGGER_UNUSEDBIT_4_31", 528, FieldType.BIT, 31); public static final Field TRIGGER_CUSTOMTOTALTOOTHCOUNT = Field.create("TRIGGER_CUSTOMTOTALTOOTHCOUNT", 532, FieldType.INT); public static final Field TRIGGER_CUSTOMSKIPPEDTOOTHCOUNT = Field.create("TRIGGER_CUSTOMSKIPPEDTOOTHCOUNT", 536, FieldType.INT); public static final Field HIP9011SPIDEVICE = Field.create("HIP9011SPIDEVICE", 540, FieldType.INT8); @@ -1749,6 +1875,36 @@ public class Fields { public static final Field UNUSED = Field.create("UNUSED", 972, FieldType.FLOAT); public static final Field TODOCLUTCHUPPININVERTED = Field.create("TODOCLUTCHUPPININVERTED", 976, FieldType.BIT, 0); public static final Field TODOCLUTCHDOWNPININVERTED = Field.create("TODOCLUTCHDOWNPININVERTED", 976, FieldType.BIT, 1); + public static final Field UNUSEDBIT_247_2 = Field.create("UNUSEDBIT_247_2", 976, FieldType.BIT, 2); + public static final Field UNUSEDBIT_247_3 = Field.create("UNUSEDBIT_247_3", 976, FieldType.BIT, 3); + public static final Field UNUSEDBIT_247_4 = Field.create("UNUSEDBIT_247_4", 976, FieldType.BIT, 4); + public static final Field UNUSEDBIT_247_5 = Field.create("UNUSEDBIT_247_5", 976, FieldType.BIT, 5); + public static final Field UNUSEDBIT_247_6 = Field.create("UNUSEDBIT_247_6", 976, FieldType.BIT, 6); + public static final Field UNUSEDBIT_247_7 = Field.create("UNUSEDBIT_247_7", 976, FieldType.BIT, 7); + public static final Field UNUSEDBIT_247_8 = Field.create("UNUSEDBIT_247_8", 976, FieldType.BIT, 8); + public static final Field UNUSEDBIT_247_9 = Field.create("UNUSEDBIT_247_9", 976, FieldType.BIT, 9); + public static final Field UNUSEDBIT_247_10 = Field.create("UNUSEDBIT_247_10", 976, FieldType.BIT, 10); + public static final Field UNUSEDBIT_247_11 = Field.create("UNUSEDBIT_247_11", 976, FieldType.BIT, 11); + public static final Field UNUSEDBIT_247_12 = Field.create("UNUSEDBIT_247_12", 976, FieldType.BIT, 12); + public static final Field UNUSEDBIT_247_13 = Field.create("UNUSEDBIT_247_13", 976, FieldType.BIT, 13); + public static final Field UNUSEDBIT_247_14 = Field.create("UNUSEDBIT_247_14", 976, FieldType.BIT, 14); + public static final Field UNUSEDBIT_247_15 = Field.create("UNUSEDBIT_247_15", 976, FieldType.BIT, 15); + public static final Field UNUSEDBIT_247_16 = Field.create("UNUSEDBIT_247_16", 976, FieldType.BIT, 16); + public static final Field UNUSEDBIT_247_17 = Field.create("UNUSEDBIT_247_17", 976, FieldType.BIT, 17); + public static final Field UNUSEDBIT_247_18 = Field.create("UNUSEDBIT_247_18", 976, FieldType.BIT, 18); + public static final Field UNUSEDBIT_247_19 = Field.create("UNUSEDBIT_247_19", 976, FieldType.BIT, 19); + public static final Field UNUSEDBIT_247_20 = Field.create("UNUSEDBIT_247_20", 976, FieldType.BIT, 20); + public static final Field UNUSEDBIT_247_21 = Field.create("UNUSEDBIT_247_21", 976, FieldType.BIT, 21); + public static final Field UNUSEDBIT_247_22 = Field.create("UNUSEDBIT_247_22", 976, FieldType.BIT, 22); + public static final Field UNUSEDBIT_247_23 = Field.create("UNUSEDBIT_247_23", 976, FieldType.BIT, 23); + public static final Field UNUSEDBIT_247_24 = Field.create("UNUSEDBIT_247_24", 976, FieldType.BIT, 24); + public static final Field UNUSEDBIT_247_25 = Field.create("UNUSEDBIT_247_25", 976, FieldType.BIT, 25); + public static final Field UNUSEDBIT_247_26 = Field.create("UNUSEDBIT_247_26", 976, FieldType.BIT, 26); + public static final Field UNUSEDBIT_247_27 = Field.create("UNUSEDBIT_247_27", 976, FieldType.BIT, 27); + public static final Field UNUSEDBIT_247_28 = Field.create("UNUSEDBIT_247_28", 976, FieldType.BIT, 28); + public static final Field UNUSEDBIT_247_29 = Field.create("UNUSEDBIT_247_29", 976, FieldType.BIT, 29); + public static final Field UNUSEDBIT_247_30 = Field.create("UNUSEDBIT_247_30", 976, FieldType.BIT, 30); + public static final Field UNUSEDBIT_247_31 = Field.create("UNUSEDBIT_247_31", 976, FieldType.BIT, 31); public static final Field ETBIO1_DIRECTIONPIN1 = Field.create("ETBIO1_DIRECTIONPIN1", 980, FieldType.INT8, brain_pin_e); public static final Field ETBIO1_DIRECTIONPIN2 = Field.create("ETBIO1_DIRECTIONPIN2", 981, FieldType.INT8, brain_pin_e); public static final Field ETBIO1_CONTROLPIN1 = Field.create("ETBIO1_CONTROLPIN1", 982, FieldType.INT8, brain_pin_e); @@ -2193,6 +2349,7 @@ public class Fields { ISSUE_294_29, ISSUE_294_30, ISSUE_294_31, + UNUSEDBIT_34_31, TPSMIN, TPSMAX, TPSERRORDETECTIONTOOLOW, @@ -2265,6 +2422,35 @@ public class Fields { TRIGGER_UNUSEDCUSTOMISSYNCHRONIZATIONNEEDED, TRIGGER_UNUSEDCUSTOMNEEDSECONDTRIGGERINPUT, TRIGGER_USEONLYFIRSTCHANNEL, + TRIGGER_UNUSEDBIT_4_3, + TRIGGER_UNUSEDBIT_4_4, + TRIGGER_UNUSEDBIT_4_5, + TRIGGER_UNUSEDBIT_4_6, + TRIGGER_UNUSEDBIT_4_7, + TRIGGER_UNUSEDBIT_4_8, + TRIGGER_UNUSEDBIT_4_9, + TRIGGER_UNUSEDBIT_4_10, + TRIGGER_UNUSEDBIT_4_11, + TRIGGER_UNUSEDBIT_4_12, + TRIGGER_UNUSEDBIT_4_13, + TRIGGER_UNUSEDBIT_4_14, + TRIGGER_UNUSEDBIT_4_15, + TRIGGER_UNUSEDBIT_4_16, + TRIGGER_UNUSEDBIT_4_17, + TRIGGER_UNUSEDBIT_4_18, + TRIGGER_UNUSEDBIT_4_19, + TRIGGER_UNUSEDBIT_4_20, + TRIGGER_UNUSEDBIT_4_21, + TRIGGER_UNUSEDBIT_4_22, + TRIGGER_UNUSEDBIT_4_23, + TRIGGER_UNUSEDBIT_4_24, + TRIGGER_UNUSEDBIT_4_25, + TRIGGER_UNUSEDBIT_4_26, + TRIGGER_UNUSEDBIT_4_27, + TRIGGER_UNUSEDBIT_4_28, + TRIGGER_UNUSEDBIT_4_29, + TRIGGER_UNUSEDBIT_4_30, + TRIGGER_UNUSEDBIT_4_31, TRIGGER_CUSTOMTOTALTOOTHCOUNT, TRIGGER_CUSTOMSKIPPEDTOOTHCOUNT, HIP9011SPIDEVICE, @@ -2555,6 +2741,36 @@ public class Fields { UNUSED, TODOCLUTCHUPPININVERTED, TODOCLUTCHDOWNPININVERTED, + UNUSEDBIT_247_2, + UNUSEDBIT_247_3, + UNUSEDBIT_247_4, + UNUSEDBIT_247_5, + UNUSEDBIT_247_6, + UNUSEDBIT_247_7, + UNUSEDBIT_247_8, + UNUSEDBIT_247_9, + UNUSEDBIT_247_10, + UNUSEDBIT_247_11, + UNUSEDBIT_247_12, + UNUSEDBIT_247_13, + UNUSEDBIT_247_14, + UNUSEDBIT_247_15, + UNUSEDBIT_247_16, + UNUSEDBIT_247_17, + UNUSEDBIT_247_18, + UNUSEDBIT_247_19, + UNUSEDBIT_247_20, + UNUSEDBIT_247_21, + UNUSEDBIT_247_22, + UNUSEDBIT_247_23, + UNUSEDBIT_247_24, + UNUSEDBIT_247_25, + UNUSEDBIT_247_26, + UNUSEDBIT_247_27, + UNUSEDBIT_247_28, + UNUSEDBIT_247_29, + UNUSEDBIT_247_30, + UNUSEDBIT_247_31, ETBIO1_DIRECTIONPIN1, ETBIO1_DIRECTIONPIN2, ETBIO1_CONTROLPIN1, diff --git a/java_console/models/src/com/rusefi/core/Sensor.java b/java_console/models/src/com/rusefi/core/Sensor.java index fa6517d7b9..a1e12b297d 100644 --- a/java_console/models/src/com/rusefi/core/Sensor.java +++ b/java_console/models/src/com/rusefi/core/Sensor.java @@ -17,93 +17,102 @@ import static com.rusefi.config.generated.Fields.*; * 2/11/13 */ public enum Sensor { - MAP("MAP", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 40, BackgroundColor.MUD, 20, 300), - /** * Please note that these enum names are used to make 'set_mock_XXX_voltage' commands */ - CLT("Coolant", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 4, BackgroundColor.MUD, -40, 300), - AFR("A/F ratio", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 20, BackgroundColor.MUD, 0, 20), - MAF("MAF", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 16, BackgroundColor.MUD, 0, 5), -// knockCount("Knock", SensorCategory.SENSOR_INPUTS, "count", 30), -// KnockValue("Knock level", SensorCategory.SENSOR_INPUTS, "v", 6), + // RPM, vss + RPM("RPM", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 4, 1, BackgroundColor.RED, 0, 8000, "/min"), + SPEED2RPM("SpeedToRpm", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 6, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 5, "RPM/kph"), + VSS("VSS", SensorCategory.OPERATIONS, FieldType.UINT8, 8, 1, BackgroundColor.BLUE, 0, 150, "kph"), -// ENGINE_LOAD("Engine Load", SensorCategory.SENSOR_INPUTS, "x", 300), + // Temperatures + INT_TEMP("MCU Temp", SensorCategory.OPERATIONS, FieldType.INT8, 10, 1, BackgroundColor.MUD, 0, 5, "C"), + CLT("Coolant", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 12, 1.0 / PACK_MULT_TEMPERATURE,BackgroundColor.MUD, -40, 150, "C"), + IAT("IAT", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 14, 1.0 / PACK_MULT_TEMPERATURE, BackgroundColor.WHITE, -40, 150, "C"), + // throttle, pedal + TPS("TPS", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 20, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), // throttle position sensor + PPS("Throttle Pedal", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 22, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), // pedal position sensor -// MAFR_CFM("MAFR_CFM", SensorCategory.SENSOR_INPUTS, "cub f/m", 800), + // air flow/mass measurement + MAF("MAF", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 26, 1.0 / PACK_MULT_VOLTAGE, BackgroundColor.MUD, 0, 5, "Volts"), + MAP("MAP", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 30, 1.0 / PACK_MULT_PRESSURE, BackgroundColor.MUD, 20, 300, "kPa"), + AFR("A/F ratio", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 34, 1.0 / PACK_MULT_AFR, BackgroundColor.MUD, 10, 20, "afr"), -// COOLANT_WIDTH("c w", "", 30), -// INTAKE_AIR_WIDTH("air w", "", 30), + VBATT("VBatt", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 38, 1.0 / PACK_MULT_VOLTAGE, BackgroundColor.BEIGE, 4, 18, "Volts"), + vvtPosition("vvt position", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 42, 1.0 / PACK_MULT_ANGLE, BackgroundColor.MUD, 0, 5, "deg"), - // VREF("VRef", SensorCategory.SENSOR_INPUTS, "Volts", 6), - VBATT("VBatt", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 28, BackgroundColor.BEIGE, 4, 18, "Volts"), + // fuel math + CHARGE_AIR_MASS("airmass", SensorCategory.OPERATIONS, FieldType.UINT16, 44, 0.001, BackgroundColor.MUD, 0, 3, "g/cyl"), + crankingFuel(GAUGE_NAME_FUEL_CRANKING, SensorCategory.FUEL, FieldType.UINT16, 46, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 30, "ms"), + TARGET_AFR("A/F target", SensorCategory.OPERATIONS, FieldType.INT16, 48, 1.0 / PACK_MULT_AFR, BackgroundColor.MUD, 10, 20, "afr"), + baseFuel(Fields.GAUGE_NAME_FUEL_BASE, SensorCategory.FUEL, FieldType.UINT16, 50, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 30, "ms"), + runningFuel(GAUGE_NAME_FUEL_RUNNING, SensorCategory.FUEL, FieldType.UINT16, 52, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 15, "ms"), + actualLastInjection(GAUGE_NAME_FUEL_LAST_INJECTION, SensorCategory.FUEL, FieldType.UINT16, 54, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 30, "ms"), + injectorDutyCycle(Fields.GAUGE_NAME_FUEL_INJ_DUTY, SensorCategory.FUEL, FieldType.UINT8, 56, 0.5, BackgroundColor.MUD, 0, 100, "%"), + veValue(GAUGE_NAME_FUEL_VE, SensorCategory.FUEL, FieldType.FLOAT, 57, 0.5, BackgroundColor.MUD, 0, 100, "%"), + tCharge(GAUGE_NAME_TCHARGE, SensorCategory.FUEL, FieldType.FLOAT, 60, 1.0 / PACK_MULT_TEMPERATURE, BackgroundColor.MUD, 30, 140, "C"), + // Corrections + injectorLagMs(GAUGE_NAME_INJECTOR_LAG, SensorCategory.FUEL, FieldType.UINT16, 62, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 15, "ms"), + iatCorrection(GAUGE_NAME_FUEL_IAT_CORR, SensorCategory.FUEL, FieldType.INT16, 64, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 5, "ratio"), + cltCorrection(GAUGE_NAME_FUEL_CLT_CORR, SensorCategory.FUEL, FieldType.INT16, 66, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 5, "ratio"), + fuelPidCorrection("Fuel PID", SensorCategory.FUEL, FieldType.INT16, 70, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, -2, 2, "ms"), + + // Wall model AE + wallFuelAmount(GAUGE_NAME_FUEL_WALL_AMOUNT, SensorCategory.FUEL, FieldType.UINT16, 72, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 20, "ms"), + wallFuelCorrection(GAUGE_NAME_FUEL_WALL_CORRECTION, SensorCategory.FUEL, FieldType.INT16, 74, 0.001, BackgroundColor.MUD, -5, 5, "ms"), + + // TPS/load AE + engineLoadAccelDelta("load accel delta", SensorCategory.FUEL, FieldType.INT16, 76, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, -5, 5, "ratio"), + deltaTps(Fields.GAUGE_NAME_FUEL_TPS_ROC, SensorCategory.FUEL, FieldType.INT16, 78, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, -100, 100, "%"), + tpsAccelFuel(Fields.GAUGE_NAME_FUEL_TPS_EXTRA, SensorCategory.FUEL, FieldType.INT16, 82, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 200, "ms"), + + // Ignition + ignitionAdvance("ignition timing", SensorCategory.OPERATIONS, FieldType.INT16, 84, 1.0 / PACK_MULT_ANGLE, BackgroundColor.MUD, 30, 140, "deg"), + DWELL(Fields.GAUGE_COIL_DWELL_TIME, SensorCategory.OPERATIONS, FieldType.UINT16, 86, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 1, 10, "ms"), + coilDutyCycle(Fields.GAUGE_NAME_DWELL_DUTY, SensorCategory.OPERATIONS, FieldType.UINT16, 88, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), + + // Idle & ETB + idlePosition("Idle Position", SensorCategory.OPERATIONS, FieldType.INT16, 90, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), + etbTarget(GAUGE_NAME_ETB_TARGET, SensorCategory.OTHERS, FieldType.INT16, 92, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), + etb1DutyCycle(GAUGE_NAME_ETB_DUTY, SensorCategory.OTHERS, FieldType.INT16, 94, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), + etb1Error(GAUGE_NAME_ETB_ERROR, SensorCategory.OTHERS, FieldType.INT16, 96, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), + + // Fuel system + + // Knock + + // Mode, firmware, protocol, run time + TIME_SECONDS("uptime", SensorCategory.OPERATIONS, FieldType.INT, 112, BackgroundColor.MUD, 0, 5), + engineMode("mode", SensorCategory.OPERATIONS, FieldType.INT, 116, BackgroundColor.MUD, 0, 5), + FIRMWARE_VERSION("FW version", SensorCategory.OPERATIONS, FieldType.INT, 120, BackgroundColor.BLUE), + TS_CONFIG_VERSION(".ini version", SensorCategory.OPERATIONS, FieldType.INT, 124, BackgroundColor.BLUE), + + // Errors + totalTriggerErrorCounter("trigger total error counter", SensorCategory.STATUS, FieldType.INT, 128, BackgroundColor.MUD, 0, 5), + orderingErrorCounter("trigger order error counter", SensorCategory.STATUS, FieldType.INT, 132, BackgroundColor.MUD, 0, 5), + errorCodeCounter("error counter", SensorCategory.STATUS, FieldType.INT, 136, BackgroundColor.MUD, 0, 5), + lastErrorCode("last error", SensorCategory.STATUS, FieldType.INT, 138, BackgroundColor.MUD, 0, 5), + + // Debug + debugFloatField1(GAUGE_NAME_DEBUG_F1, SensorCategory.DEBUG, FieldType.FLOAT, 156, BackgroundColor.MUD, 0, 5), + debugFloatField2(GAUGE_NAME_DEBUG_F2, SensorCategory.DEBUG, FieldType.FLOAT, 160, BackgroundColor.MUD, 0, 5), + debugFloatField3(GAUGE_NAME_DEBUG_F3, SensorCategory.DEBUG, FieldType.FLOAT, 164, BackgroundColor.MUD, 0, 5), + debugFloatField4(GAUGE_NAME_DEBUG_F4, SensorCategory.DEBUG, FieldType.FLOAT, 168, BackgroundColor.MUD, 0, 5), + debugFloatField5(GAUGE_NAME_DEBUG_F5, SensorCategory.DEBUG, FieldType.FLOAT, 172, BackgroundColor.MUD, 0, 5), + debugFloatField6(GAUGE_NAME_DEBUG_F6, SensorCategory.DEBUG, FieldType.FLOAT, 176, BackgroundColor.MUD, 0, 5), + debugFloatField7(GAUGE_NAME_DEBUG_F7, SensorCategory.DEBUG, FieldType.FLOAT, 180, BackgroundColor.MUD, 0, 5), + debugIntField1(GAUGE_NAME_DEBUG_I1, SensorCategory.DEBUG, FieldType.INT, 184, BackgroundColor.MUD, 0, 5), + debugIntField2(GAUGE_NAME_DEBUG_I2, SensorCategory.DEBUG, FieldType.INT, 188, BackgroundColor.MUD, 0, 5), + debugIntField3(GAUGE_NAME_DEBUG_I3, SensorCategory.DEBUG, FieldType.INT, 192, BackgroundColor.MUD, 0, 5), + debugIntField4("debug i4", SensorCategory.DEBUG, FieldType.INT16, 196, BackgroundColor.MUD, 0, 5), + debugIntField5("debug i5", SensorCategory.DEBUG, FieldType.INT16, 198, BackgroundColor.MUD, 0, 5), + + // Synthetic (console only) channels ETB_CONTROL_QUALITY("ETB metric", SensorCategory.SNIFFING, "", 100), - - IAT(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 8, BackgroundColor.WHITE, -40, 150, "C"), - TPS(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 12, BackgroundColor.MUD, 0, 100, "%"), // throttle position sensor - crankingFuel(GAUGE_NAME_FUEL_CRANKING, SensorCategory.FUEL, FieldType.FLOAT, 44, BackgroundColor.MUD, 0, 30, "ms"), - baseFuel(Fields.GAUGE_NAME_FUEL_BASE, SensorCategory.FUEL, FieldType.FLOAT, 48, BackgroundColor.MUD, 0, 30, "ms"), - tCharge(GAUGE_NAME_TCHARGE, SensorCategory.FUEL, FieldType.FLOAT, 52, BackgroundColor.MUD, 30, 140), - // todo: unify with TIMING - ignitionAdvance(SensorCategory.OPERATIONS, FieldType.FLOAT, 56, BackgroundColor.MUD, 30, 140), - DWELL(Fields.GAUGE_COIL_DWELL_TIME, SensorCategory.OPERATIONS, FieldType.FLOAT, 60, BackgroundColor.MUD, 1, 10), - actualLastInjection(GAUGE_NAME_FUEL_LAST_INJECTION, SensorCategory.FUEL, FieldType.FLOAT, /*offset */ 64, BackgroundColor.MUD, 0, 30, "ms"), - debugFloatField1(GAUGE_NAME_DEBUG_F1, SensorCategory.DEBUG, FieldType.FLOAT, 68, BackgroundColor.MUD, 0, 5), - VSS(SensorCategory.OPERATIONS, FieldType.FLOAT, 76, BackgroundColor.BLUE), - FIRMWARE_VERSION(SensorCategory.OPERATIONS, FieldType.INT, 84, BackgroundColor.BLUE), - veValue(GAUGE_NAME_FUEL_VE, SensorCategory.FUEL, FieldType.FLOAT, 112, BackgroundColor.MUD), - - deltaTps(Fields.GAUGE_NAME_FUEL_TPS_ROC, SensorCategory.FUEL, FieldType.FLOAT, 116, BackgroundColor.MUD, -100, 100, "%"), - engineLoadAccelDelta(SensorCategory.FUEL, FieldType.FLOAT, 124, BackgroundColor.MUD), - tpsAccelFuel(Fields.GAUGE_NAME_FUEL_TPS_EXTRA, SensorCategory.FUEL, FieldType.FLOAT, 128, BackgroundColor.MUD, 0, 200, "ms"), - PPS("Throttle Pedal", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 136, BackgroundColor.MUD, 0, 100, "%"), // pedal position sensor - - injectorDutyCycle(Fields.GAUGE_NAME_FUEL_INJ_DUTY, SensorCategory.FUEL, FieldType.FLOAT, 140, BackgroundColor.MUD), - wallFuelAmount(GAUGE_NAME_FUEL_WALL_AMOUNT, SensorCategory.FUEL, FieldType.FLOAT, 160, BackgroundColor.MUD), - iatCorrection(GAUGE_NAME_FUEL_IAT_CORR, SensorCategory.FUEL, FieldType.FLOAT, 164, BackgroundColor.MUD, 0, 5), - wallFuelCorrection(GAUGE_NAME_FUEL_WALL_CORRECTION, SensorCategory.FUEL, FieldType.FLOAT, 168, BackgroundColor.MUD), - idlePosition(SensorCategory.OPERATIONS, FieldType.FLOAT, 172, BackgroundColor.MUD), - TARGET_AFR(SensorCategory.OPERATIONS, FieldType.FLOAT, 176, BackgroundColor.MUD), - CHARGE_AIR_MASS(SensorCategory.OPERATIONS, FieldType.FLOAT, 180, BackgroundColor.MUD), - cltCorrection(GAUGE_NAME_FUEL_CLT_CORR, SensorCategory.FUEL, FieldType.FLOAT, 184, BackgroundColor.MUD, 0, 5), - runningFuel(GAUGE_NAME_FUEL_RUNNING, SensorCategory.FUEL, FieldType.FLOAT, 188, BackgroundColor.MUD, 0, 15, "ms"), - debugIntField1(GAUGE_NAME_DEBUG_I1, SensorCategory.DEBUG, FieldType.INT, 192, BackgroundColor.MUD, 0, 5), - injectorLagMs(GAUGE_NAME_INJECTOR_LAG, SensorCategory.FUEL, FieldType.FLOAT, 196, BackgroundColor.MUD, 0, 15, "ms"), - - debugFloatField2(GAUGE_NAME_DEBUG_F2, SensorCategory.DEBUG, FieldType.FLOAT, 200, BackgroundColor.MUD, 0, 5), - debugFloatField3(GAUGE_NAME_DEBUG_F3, SensorCategory.DEBUG, FieldType.FLOAT, 204, BackgroundColor.MUD, 0, 5), - debugFloatField4(GAUGE_NAME_DEBUG_F4, SensorCategory.DEBUG, FieldType.FLOAT, 208, BackgroundColor.MUD, 0, 5), - debugFloatField5(GAUGE_NAME_DEBUG_F5, SensorCategory.DEBUG, FieldType.FLOAT, 212, BackgroundColor.MUD, 0, 5), - debugIntField2(GAUGE_NAME_DEBUG_I2, SensorCategory.DEBUG, FieldType.INT, 216, BackgroundColor.MUD, 0, 5), - debugIntField3(GAUGE_NAME_DEBUG_I3, SensorCategory.DEBUG, FieldType.INT, 220, BackgroundColor.MUD, 0, 5), - - errorCodeCounter(SensorCategory.STATUS, FieldType.INT, 236, BackgroundColor.MUD, 0, 5), - lastErrorCode(SensorCategory.STATUS, FieldType.INT, 240, BackgroundColor.MUD, 0, 5), - - RPM(SensorCategory.SENSOR_INPUTS, FieldType.INT, 0, BackgroundColor.RED, 0, 8000), - TIME_SECONDS(SensorCategory.OPERATIONS, FieldType.INT, 224, BackgroundColor.MUD, 0, 5), - SPEED2RPM(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 232, BackgroundColor.MUD, 0, 5), - INT_TEMP(SensorCategory.OPERATIONS, FieldType.FLOAT, 244, BackgroundColor.MUD, 0, 5), - vvtPosition(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 248, BackgroundColor.MUD, 0, 5), - engineMode(SensorCategory.OPERATIONS, FieldType.INT, 252, BackgroundColor.MUD, 0, 5), - - debugFloatField6(GAUGE_NAME_DEBUG_F6, SensorCategory.DEBUG, FieldType.FLOAT, 256, BackgroundColor.MUD, 0, 5), - debugFloatField7(GAUGE_NAME_DEBUG_F7, SensorCategory.DEBUG, FieldType.FLOAT, 260, BackgroundColor.MUD, 0, 5), - fuelPidCorrection(SensorCategory.FUEL, FieldType.FLOAT, 268, BackgroundColor.MUD), - coilDutyCycle(Fields.GAUGE_NAME_DWELL_DUTY, SensorCategory.OPERATIONS, FieldType.FLOAT, 272, BackgroundColor.MUD), - - debugIntField4("debug i4", SensorCategory.DEBUG, FieldType.INT16, 292, BackgroundColor.MUD, 0, 5), - debugIntField5("debug i5", SensorCategory.DEBUG, FieldType.INT16, 294, BackgroundColor.MUD, 0, 5), - - - etbTarget(GAUGE_NAME_ETB_TARGET, SensorCategory.OTHERS, FieldType.FLOAT, 312, BackgroundColor.MUD), - etb1DutyCycle(GAUGE_NAME_ETB_DUTY, SensorCategory.OTHERS, FieldType.FLOAT, 316, BackgroundColor.MUD), - etb1Error(GAUGE_NAME_ETB_ERROR, SensorCategory.OTHERS, FieldType.FLOAT, 320, BackgroundColor.MUD), - ; private final String name; @@ -115,11 +124,13 @@ public enum Sensor { @Nullable private final FieldType type; private final int offset; + private final double scale; - Sensor(String name, SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue, String units) { + Sensor(String name, SensorCategory category, FieldType type, int offset, double scale, BackgroundColor color, double minValue, double maxValue, String units) { this.name = name == null ? name() : name; this.type = type; this.offset = offset; + this.scale = scale; this.category = category; this.color = color; this.units = units; @@ -127,20 +138,8 @@ public enum Sensor { this.maxValue = maxValue; } - Sensor(SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue, String units) { - this(null, category, type, offset, color, minValue, maxValue, units); - } - Sensor(String name, SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue) { - this(name, category, type, offset, color, minValue, maxValue, "n/a"); - } - - Sensor(SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue) { - this(null, category, type, offset, color, minValue, maxValue); - } - - Sensor(SensorCategory category, FieldType type, int offset, BackgroundColor color) { - this(null, category, type, offset, color); + this(name, category, type, offset, 1.0, color, minValue, maxValue, "n/a"); } Sensor(String name, SensorCategory category, FieldType type, int offset, BackgroundColor color) { @@ -171,6 +170,7 @@ public enum Sensor { this.minValue = minValue; this.maxValue = maxValue; this.color = color; + this.scale = 1.0; type = null; offset = -1; } @@ -236,6 +236,10 @@ public enum Sensor { return offset; } + public double getScale() { + return scale; + } + public FieldType getType() { return type; } diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index f15db788ad..bc115f7a21 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -49,7 +49,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20191201; + public static final int CONSOLE_VERSION = 20191225; public static final String INI_FILE_PATH = System.getProperty("ini_file_path", ".."); public static final String INPUT_FILES_PATH = System.getProperty("input_files_path", ".."); public static final String TOOLS_PATH = System.getProperty("tools_path", "."); @@ -60,6 +60,7 @@ public class Launcher { private static final String TOOL_NAME_COMPILE_FSIO_FILE = "compile_fsio_file"; private static final String TOOL_NAME_REBOOT_ECU = "reboot_ecu"; private static final String TOOL_NAME_FIRING_ORDER = "firing_order"; + private static final String TOOL_NAME_FUNCTIONAL_TEST = "functional_test"; private static final String TOOL_NAME_PERF_ENUMS = "ptrace_enums"; // todo: rename to something more FSIO-specific? would need to update documentation somewhere private static final String TOOL_NAME_COMPILE = "compile"; @@ -322,6 +323,13 @@ public class Launcher { public static void main(final String[] args) throws Exception { String toolName = args.length == 0 ? null : args[0]; + if (TOOL_NAME_FUNCTIONAL_TEST.equals(toolName)) { + // passing port argument if it was specified + String[] toolArgs = args.length == 1 ? new String[0] : new String[]{args[1]}; + RealHwTest.main(toolArgs); + return; + } + if (TOOL_NAME_COMPILE_FSIO_FILE.equalsIgnoreCase(toolName)) { int returnCode = invokeCompileFileTool(args); System.exit(returnCode); @@ -413,11 +421,11 @@ public class Launcher { (int) value; JOptionPane.showMessageDialog(Launcher.getFrame(), message); assert wrongVersionListener != null; - SensorCentral.getInstance().removeListener(Sensor.FIRMWARE_VERSION, wrongVersionListener); + SensorCentral.getInstance().removeListener(Sensor.TS_CONFIG_VERSION, wrongVersionListener); } } }; - SensorCentral.getInstance().addListener(Sensor.FIRMWARE_VERSION, wrongVersionListener); + SensorCentral.getInstance().addListener(Sensor.TS_CONFIG_VERSION, wrongVersionListener); JustOneInstance.onStart(); try { boolean isPortDefined = args.length > 0; diff --git a/java_console/ui/src/com/rusefi/StartupFrame.java b/java_console/ui/src/com/rusefi/StartupFrame.java index fc81141881..48881d635e 100644 --- a/java_console/ui/src/com/rusefi/StartupFrame.java +++ b/java_console/ui/src/com/rusefi/StartupFrame.java @@ -14,17 +14,16 @@ import org.putgemin.VerticalFlowLayout; import javax.swing.*; import javax.swing.border.TitledBorder; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.awt.event.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; +import static com.rusefi.ui.util.UiUtils.getAllComponents; import static com.rusefi.ui.util.UiUtils.setToolTip; +import static javax.swing.JOptionPane.YES_NO_OPTION; /** * This frame is used on startup to select the port we would be using @@ -217,6 +216,43 @@ public class StartupFrame { frame.pack(); frame.setVisible(true); UiUtils.centerWindow(frame); + + KeyListener hwTestEasterEgg = functionalTestEasterEgg(); + + for (Component component : getAllComponents(frame)) { + component.addKeyListener(hwTestEasterEgg); + } + } + + /** + * Here we listen to keystrokes while console start-up frame is being displayed and if magic "test" word is typed + * we launch a functional test on real hardware, same as Jenkins runs within continues integration + */ + @NotNull + private KeyListener functionalTestEasterEgg() { + return new KeyAdapter() { + private final static String TEST = "test"; + private String recentKeyStrokes = ""; + + @Override + public void keyTyped(KeyEvent e) { + recentKeyStrokes = recentKeyStrokes + e.getKeyChar(); + if (recentKeyStrokes.toLowerCase().endsWith(TEST) && showTestConfirmation()) { + runFunctionalHardwareTest(); + } + } + + private boolean showTestConfirmation() { + return JOptionPane.showConfirmDialog(StartupFrame.this.frame, "Want to run functional test? This would freeze UI for the duration of the test", + "Better do not run while connected to vehicle!!!", YES_NO_OPTION) == JOptionPane.YES_OPTION; + } + + private void runFunctionalHardwareTest() { + String autoDetectedPort = PortDetector.autoDetectPort(null); + boolean isSuccess = RealHwTest.runHardwareTest(autoDetectedPort); + JOptionPane.showMessageDialog(null, "Function test passed: " + isSuccess + "\nSee log folder for details."); + } + }; } private Component createShowDeviceManagerButton() { diff --git a/java_console/ui/src/com/rusefi/autodetect/SerialAutoChecker.java b/java_console/ui/src/com/rusefi/autodetect/SerialAutoChecker.java index d62c9370b0..c675898b72 100644 --- a/java_console/ui/src/com/rusefi/autodetect/SerialAutoChecker.java +++ b/java_console/ui/src/com/rusefi/autodetect/SerialAutoChecker.java @@ -41,7 +41,8 @@ class SerialAutoChecker implements Runnable { return; String message = new String(response, 1, response.length - 1); System.out.println("Got " + message + " from " + serialPort); - if (message.startsWith(Fields.TS_SIGNATURE)) { + String signatureWithoutMinorVersion = Fields.TS_SIGNATURE.substring(0, Fields.TS_SIGNATURE.length() - 2); + if (message.startsWith(signatureWithoutMinorVersion)) { result.set(serialPort); portFound.countDown(); } diff --git a/java_console/ui/src/com/rusefi/ui/RecentCommands.java b/java_console/ui/src/com/rusefi/ui/RecentCommands.java index 853b4c865f..42abd8eeee 100644 --- a/java_console/ui/src/com/rusefi/ui/RecentCommands.java +++ b/java_console/ui/src/com/rusefi/ui/RecentCommands.java @@ -18,8 +18,9 @@ import java.util.*; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import static com.rusefi.IoUtil.getEnableCommand; import static com.rusefi.config.generated.Fields.CMD_TRIGGERINFO; -import static com.rusefi.io.CommandQueue.disableCommand; +import static com.rusefi.IoUtil.getDisableCommand; import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; /** @@ -126,13 +127,15 @@ public class RecentCommands { add(CANINFO); add(Fields.CMD_WRITECONFIG); add("rewriteconfig"); - add("enable injection"); - add(disableCommand("injection")); - add("enable ignition"); - add(disableCommand("ignition")); - add("enable self_stimulation"); - add("disable self_stimulation"); + add(getEnableCommand("injection")); + add(getDisableCommand("injection")); + + add(getEnableCommand("ignition")); + add(getDisableCommand("ignition")); + + add(getEnableCommand("self_stimulation")); + add(getDisableCommand("self_stimulation")); add("blipidle 80 2000"); add("set_idle_position 50"); diff --git a/java_console/ui/src/com/rusefi/ui/util/UiUtils.java b/java_console/ui/src/com/rusefi/ui/util/UiUtils.java index 74caba77af..4b53cf7019 100644 --- a/java_console/ui/src/com/rusefi/ui/util/UiUtils.java +++ b/java_console/ui/src/com/rusefi/ui/util/UiUtils.java @@ -12,6 +12,7 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URL; +import java.util.ArrayList; import static com.rusefi.ui.util.LocalizedMessages.CLEAR; import static com.rusefi.ui.util.LocalizedMessages.PAUSE; @@ -99,6 +100,17 @@ public class UiUtils { component.repaint(); } + public static java.util.List getAllComponents(final Container c) { + Component[] comps = c.getComponents(); + java.util.List compList = new ArrayList<>(); + for (Component comp : comps) { + compList.add(comp); + if (comp instanceof Container) + compList.addAll(getAllComponents((Container) comp)); + } + return compList; + } + /** * Utility method for multi-line tooltips */ diff --git a/java_console/ui/src/com/rusefi/ui/widgets/LogModeWidget.java b/java_console/ui/src/com/rusefi/ui/widgets/LogModeWidget.java deleted file mode 100644 index 4ff6833b7d..0000000000 --- a/java_console/ui/src/com/rusefi/ui/widgets/LogModeWidget.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.rusefi.ui.widgets; - -import com.rusefi.io.CommandQueue; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -/** - * Date: 3/29/13 - * (c) Andrey Belomutskiy - */ -public class LogModeWidget { - private final JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); - - private final JCheckBox mode = new JCheckBox("full logging"); - - public LogModeWidget() { - panel.setBorder(BorderFactory.createLineBorder(Color.black)); - panel.add(mode); - - mode.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - int code = mode.isSelected() ? 1 : 0; - CommandQueue.getInstance().write("fl " + code); - } - }); - } - - public JPanel getPanel() { - return panel; - } -} diff --git a/java_tools/ConfigDefinition.jar b/java_tools/ConfigDefinition.jar index a64ba22601..0dc5a1260a 100644 Binary files a/java_tools/ConfigDefinition.jar and b/java_tools/ConfigDefinition.jar differ diff --git a/java_tools/configuration_definition/src/com/rusefi/BitState.java b/java_tools/configuration_definition/src/com/rusefi/BitState.java index 42ee8cb3b1..ee672611e1 100644 --- a/java_tools/configuration_definition/src/com/rusefi/BitState.java +++ b/java_tools/configuration_definition/src/com/rusefi/BitState.java @@ -12,6 +12,10 @@ public class BitState { bitIndex = 0; return; } + incrementBitIndex(cf); + } + + public void incrementBitIndex(ConfigField cf) { if (bitIndex == 32) throw new IllegalStateException("Too many bits: " + cf.getName()); bitIndex++; diff --git a/java_tools/configuration_definition/src/com/rusefi/ConfigStructure.java b/java_tools/configuration_definition/src/com/rusefi/ConfigStructure.java index fd5e192f2f..751c52ddb7 100644 --- a/java_tools/configuration_definition/src/com/rusefi/ConfigStructure.java +++ b/java_tools/configuration_definition/src/com/rusefi/ConfigStructure.java @@ -3,9 +3,11 @@ package com.rusefi; import java.util.ArrayList; import java.util.List; +import static com.rusefi.ConfigField.BOOLEAN_T; + /** * Mutable representation of a list of related {@link ConfigField} - * + *

* (c) Andrey Belomutskiy * 1/15/15 */ @@ -22,9 +24,9 @@ public class ConfigStructure { public final List cFields = new ArrayList<>(); public final List tsFields = new ArrayList<>(); - public int currentOffset; public int totalSize; - public BitState bitState = new BitState(); + + public final BitState readingBitState = new BitState(); public ConfigStructure(String name, String comment, boolean withPrefix, boolean withConstructor) { this.name = name; @@ -33,6 +35,11 @@ public class ConfigStructure { this.withConstructor = withConstructor; } + void addBitField(ConfigField bitField) { + addBoth(bitField); + this.readingBitState.incrementBitIndex(bitField); + } + public boolean isWithConstructor() { return withConstructor; } @@ -42,9 +49,9 @@ public class ConfigStructure { } public void addAlignmentFill(ReaderState state) { - bitState.reset(); + BitState bitState = new BitState(); /** - * we make alignment decision based on C fields since we expect interation and non-iteration fields + * we make alignment decision based on C fields since we expect iteration and non-iteration fields * to match in size */ for (int i = 0; i < cFields.size(); i++) { @@ -77,4 +84,15 @@ public class ConfigStructure { public void addTs(ConfigField cf) { tsFields.add(cf); } + + public void addBitPadding(ReaderState readerState) { + if (readingBitState.get() == 0) + return; + int sizeAtStartOfPadding = cFields.size(); + while (readingBitState.get() < 32) { + ConfigField bitField = new ConfigField(readerState, "unusedBit_" + sizeAtStartOfPadding + "_" + readingBitState.get(), "", null, BOOLEAN_T, 0, null, false, false, null, -1); + addBitField(bitField); + } + readingBitState.reset(); + } } diff --git a/java_tools/configuration_definition/src/com/rusefi/ReaderState.java b/java_tools/configuration_definition/src/com/rusefi/ReaderState.java index 3062add732..17fe286d4d 100644 --- a/java_tools/configuration_definition/src/com/rusefi/ReaderState.java +++ b/java_tools/configuration_definition/src/com/rusefi/ReaderState.java @@ -46,7 +46,10 @@ public class ReaderState { } ConfigField bitField = new ConfigField(state, bitName, comment, null, BOOLEAN_T, 0, null, false, false, null, -1); - state.stack.peek().addBoth(bitField); + if (state.stack.isEmpty()) + throw new IllegalStateException("Parent structure expected"); + ConfigStructure structure = state.stack.peek(); + structure.addBitField(bitField); } static boolean isEmptyDefinitionLine(String line) { @@ -110,6 +113,7 @@ public class ReaderState { } else if (line.startsWith(STRUCT_NO_PREFIX)) { handleStartStructure(this, line.substring(STRUCT_NO_PREFIX.length()), false); } else if (line.startsWith(END_STRUCT)) { + addBitPadding(); handleEndStruct(this, consumers); } else if (line.startsWith(BIT)) { handleBitLine(this, line); @@ -124,6 +128,7 @@ public class ReaderState { */ ConfigDefinition.processDefine(line.substring(DEFINE.length()).trim()); } else { + addBitPadding(); processField(this, line); } } @@ -132,6 +137,11 @@ public class ReaderState { ensureEmptyAfterProcessing(); } + private void addBitPadding() { + ConfigStructure structure = stack.peek(); + structure.addBitPadding(this); + } + public void ensureEmptyAfterProcessing() { if (!this.stack.isEmpty()) throw new IllegalStateException("Unclosed structure: " + this.stack.peek().getName()); diff --git a/java_tools/configuration_definition/src/com/rusefi/output/CHeaderConsumer.java b/java_tools/configuration_definition/src/com/rusefi/output/CHeaderConsumer.java index 9c65de0679..e25942b6a1 100644 --- a/java_tools/configuration_definition/src/com/rusefi/output/CHeaderConsumer.java +++ b/java_tools/configuration_definition/src/com/rusefi/output/CHeaderConsumer.java @@ -67,17 +67,19 @@ public class CHeaderConsumer implements ConfigurationConsumer { content.append("\t" + structure.name + "();" + EOL); } - structure.bitState.reset(); + int currentOffset = 0; + + BitState bitState = new BitState(); for (int i = 0; i < structure.cFields.size(); i++) { ConfigField cf = structure.cFields.get(i); - content.append(getHeaderText(cf, structure.currentOffset, structure.bitState.get())); + content.append(getHeaderText(cf, currentOffset, bitState.get())); ConfigField next = i == structure.cFields.size() - 1 ? ConfigField.VOID : structure.cFields.get(i + 1); - structure.bitState.incrementBitIndex(cf, next); - structure.currentOffset += cf.getSize(next); + bitState.incrementBitIndex(cf, next); + currentOffset += cf.getSize(next); } - content.append("\t/** total size " + structure.currentOffset + "*/" + EOL); + content.append("\t/** total size " + currentOffset + "*/" + EOL); content.append("};" + EOL + EOL); // https://stackoverflow.com/questions/1675351/typedef-struct-vs-struct-definitions diff --git a/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserIssue1057Test.java b/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserIssue1057Test.java new file mode 100644 index 0000000000..61d06e81b8 --- /dev/null +++ b/java_tools/configuration_definition/src/com/rusefi/test/ConfigFieldParserIssue1057Test.java @@ -0,0 +1,71 @@ +package com.rusefi.test; + +import com.rusefi.ReaderState; +import com.rusefi.output.JavaFieldsConsumer; +import org.junit.Test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringReader; +import java.util.Arrays; + +import static org.junit.Assert.assertEquals; + +public class ConfigFieldParserIssue1057Test { + @Test + public void testBitsPadding() throws IOException { + ReaderState state = new ReaderState(); + JavaFieldsConsumer javaFieldsConsumer = new JavaFieldsConsumer(state) { + @Override + public void startFile() { + } + + @Override + public void endFile() { + } + }; + + String inputString = "struct pid_s\nbit activateAuxPid1;\n" + + "int fieldName;\n" + + "end_struct\n"; + BufferedReader reader = new BufferedReader(new StringReader(inputString)); + + + state.readBufferedReader(reader, Arrays.asList(javaFieldsConsumer)); + + assertEquals("\tpublic static final Field ACTIVATEAUXPID1 = Field.create(\"ACTIVATEAUXPID1\", 0, FieldType.BIT, 0);\n" + + "\tpublic static final Field UNUSEDBIT_1_1 = Field.create(\"UNUSEDBIT_1_1\", 0, FieldType.BIT, 1);\n" + + "\tpublic static final Field UNUSEDBIT_1_2 = Field.create(\"UNUSEDBIT_1_2\", 0, FieldType.BIT, 2);\n" + + "\tpublic static final Field UNUSEDBIT_1_3 = Field.create(\"UNUSEDBIT_1_3\", 0, FieldType.BIT, 3);\n" + + "\tpublic static final Field UNUSEDBIT_1_4 = Field.create(\"UNUSEDBIT_1_4\", 0, FieldType.BIT, 4);\n" + + "\tpublic static final Field UNUSEDBIT_1_5 = Field.create(\"UNUSEDBIT_1_5\", 0, FieldType.BIT, 5);\n" + + "\tpublic static final Field UNUSEDBIT_1_6 = Field.create(\"UNUSEDBIT_1_6\", 0, FieldType.BIT, 6);\n" + + "\tpublic static final Field UNUSEDBIT_1_7 = Field.create(\"UNUSEDBIT_1_7\", 0, FieldType.BIT, 7);\n" + + "\tpublic static final Field UNUSEDBIT_1_8 = Field.create(\"UNUSEDBIT_1_8\", 0, FieldType.BIT, 8);\n" + + "\tpublic static final Field UNUSEDBIT_1_9 = Field.create(\"UNUSEDBIT_1_9\", 0, FieldType.BIT, 9);\n" + + "\tpublic static final Field UNUSEDBIT_1_10 = Field.create(\"UNUSEDBIT_1_10\", 0, FieldType.BIT, 10);\n" + + "\tpublic static final Field UNUSEDBIT_1_11 = Field.create(\"UNUSEDBIT_1_11\", 0, FieldType.BIT, 11);\n" + + "\tpublic static final Field UNUSEDBIT_1_12 = Field.create(\"UNUSEDBIT_1_12\", 0, FieldType.BIT, 12);\n" + + "\tpublic static final Field UNUSEDBIT_1_13 = Field.create(\"UNUSEDBIT_1_13\", 0, FieldType.BIT, 13);\n" + + "\tpublic static final Field UNUSEDBIT_1_14 = Field.create(\"UNUSEDBIT_1_14\", 0, FieldType.BIT, 14);\n" + + "\tpublic static final Field UNUSEDBIT_1_15 = Field.create(\"UNUSEDBIT_1_15\", 0, FieldType.BIT, 15);\n" + + "\tpublic static final Field UNUSEDBIT_1_16 = Field.create(\"UNUSEDBIT_1_16\", 0, FieldType.BIT, 16);\n" + + "\tpublic static final Field UNUSEDBIT_1_17 = Field.create(\"UNUSEDBIT_1_17\", 0, FieldType.BIT, 17);\n" + + "\tpublic static final Field UNUSEDBIT_1_18 = Field.create(\"UNUSEDBIT_1_18\", 0, FieldType.BIT, 18);\n" + + "\tpublic static final Field UNUSEDBIT_1_19 = Field.create(\"UNUSEDBIT_1_19\", 0, FieldType.BIT, 19);\n" + + "\tpublic static final Field UNUSEDBIT_1_20 = Field.create(\"UNUSEDBIT_1_20\", 0, FieldType.BIT, 20);\n" + + "\tpublic static final Field UNUSEDBIT_1_21 = Field.create(\"UNUSEDBIT_1_21\", 0, FieldType.BIT, 21);\n" + + "\tpublic static final Field UNUSEDBIT_1_22 = Field.create(\"UNUSEDBIT_1_22\", 0, FieldType.BIT, 22);\n" + + "\tpublic static final Field UNUSEDBIT_1_23 = Field.create(\"UNUSEDBIT_1_23\", 0, FieldType.BIT, 23);\n" + + "\tpublic static final Field UNUSEDBIT_1_24 = Field.create(\"UNUSEDBIT_1_24\", 0, FieldType.BIT, 24);\n" + + "\tpublic static final Field UNUSEDBIT_1_25 = Field.create(\"UNUSEDBIT_1_25\", 0, FieldType.BIT, 25);\n" + + "\tpublic static final Field UNUSEDBIT_1_26 = Field.create(\"UNUSEDBIT_1_26\", 0, FieldType.BIT, 26);\n" + + "\tpublic static final Field UNUSEDBIT_1_27 = Field.create(\"UNUSEDBIT_1_27\", 0, FieldType.BIT, 27);\n" + + "\tpublic static final Field UNUSEDBIT_1_28 = Field.create(\"UNUSEDBIT_1_28\", 0, FieldType.BIT, 28);\n" + + "\tpublic static final Field UNUSEDBIT_1_29 = Field.create(\"UNUSEDBIT_1_29\", 0, FieldType.BIT, 29);\n" + + "\tpublic static final Field UNUSEDBIT_1_30 = Field.create(\"UNUSEDBIT_1_30\", 0, FieldType.BIT, 30);\n" + + "\tpublic static final Field UNUSEDBIT_1_31 = Field.create(\"UNUSEDBIT_1_31\", 0, FieldType.BIT, 31);\n" + + "\tpublic static final Field FIELDNAME = Field.create(\"FIELDNAME\", 4, FieldType.INT);\n", + javaFieldsConsumer.getJavaFieldsWriter()); + } +} diff --git a/simulator/simulator/rusEfiFunctionalTest.cpp b/simulator/simulator/rusEfiFunctionalTest.cpp index c1d9c3ceab..5692302b3d 100644 --- a/simulator/simulator/rusEfiFunctionalTest.cpp +++ b/simulator/simulator/rusEfiFunctionalTest.cpp @@ -15,7 +15,6 @@ #include "pwm_generator_logic.h" #include "trigger_central.h" #include "datalogging.h" -#include "algo.h" #include "rpm_calculator.h" #include "engine_sniffer.h" #include "status_loop.h" @@ -119,18 +118,12 @@ void rusEfiFunctionalTest(void) { // todo: reduce code duplication with initEngineContoller resetConfigurationExt(NULL, FORD_ESCORT_GT PASS_ENGINE_PARAMETER_SUFFIX); - prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE); - initAlgo(&sharedLogger); commonInitEngineController(&sharedLogger); - initRpmCalculator(&sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); - initTriggerCentral(&sharedLogger); initTriggerEmulator(&sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); - initMainEventListener(&sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); - startStatusThreads(); runChprintfTest(); diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index ae3e57da27..24cc2e4ee4 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -14,7 +14,6 @@ #include "allsensors.h" #include "engine_controller.h" #include "advance_map.h" -#include "algo.h" extern int timeNowUs; extern EnginePins enginePins; @@ -41,7 +40,6 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb Engine *engine = &this->engine; engine->setConfig(config); engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr; - board_configuration_s * boardConfiguration = &persistentConfig.engineConfiguration.bc; setCurveValue(config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5); setCurveValue(config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE, -30, 1.5); @@ -58,10 +56,10 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb initDataStructures(PASS_ENGINE_PARAMETER_SIGNATURE); - mostCommonInitEngineController(NULL PASS_ENGINE_PARAMETER_SUFFIX); - resetConfigurationExt(NULL, boardCallback, engineType PASS_ENGINE_PARAMETER_SUFFIX); - prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE); + + commonInitEngineController(NULL PASS_ENGINE_PARAMETER_SUFFIX); + engine->engineConfigurationPtr->mafAdcChannel = TEST_MAF_CHANNEL; engine->engineConfigurationPtr->clt.adcChannel = TEST_CLT_CHANNEL; engine->engineConfigurationPtr->iat.adcChannel = TEST_IAT_CHANNEL; @@ -75,9 +73,6 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb //todo: reuse initPeriodicEvents(PASS_ENGINE_PARAMETER_SIGNATURE) method engine->periodicSlowCallback(PASS_ENGINE_PARAMETER_SIGNATURE); - engine->initializeTriggerWaveform(NULL PASS_ENGINE_PARAMETER_SUFFIX); - initRpmCalculator(NULL PASS_ENGINE_PARAMETER_SUFFIX); - initMainEventListener(NULL PASS_ENGINE_PARAMETER_SUFFIX); } EngineTestHelper::EngineTestHelper(engine_type_e engineType) : EngineTestHelper(engineType, &emptyCallbackWithConfiguration) { @@ -95,8 +90,7 @@ void EngineTestHelper::fireRise(float delayMs) { * fire single RISE front event */ void EngineTestHelper::firePrimaryTriggerRise() { - board_configuration_s * boardConfiguration = &engine.engineConfigurationPtr->bc; - engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, &engine, engine.engineConfigurationPtr, &persistentConfig, boardConfiguration); + engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, &engine, engine.engineConfigurationPtr, &persistentConfig); } void EngineTestHelper::fireFall(float delayMs) { @@ -105,8 +99,7 @@ void EngineTestHelper::fireFall(float delayMs) { } void EngineTestHelper::firePrimaryTriggerFall() { - board_configuration_s * boardConfiguration = &engine.engineConfigurationPtr->bc; - engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, &engine, engine.engineConfigurationPtr, &persistentConfig, boardConfiguration); + engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, &engine, engine.engineConfigurationPtr, &persistentConfig); } void EngineTestHelper::fireTriggerEventsWithDuration(float durationMs) { diff --git a/unit_tests/global.h b/unit_tests/global.h index 8742efd29e..3f3ead46ee 100644 --- a/unit_tests/global.h +++ b/unit_tests/global.h @@ -18,8 +18,8 @@ typedef uint32_t iomode_t; typedef uint32_t ioportid_t; typedef uint32_t ioportmask_t; -//#define chThdGetSelfX() 0 -//#define getRemainingStack(x) (999999) +// just a stub implementation for unit tests +#define EXPECTED_REMAINING_STACK 1 #define getCurrentRemainingStack() (999999) // this is needed by all DECLARE_ENGINE_PARAMETER_* usages diff --git a/unit_tests/globalaccess.h b/unit_tests/globalaccess.h index 03171a25c8..82ba659ac6 100644 --- a/unit_tests/globalaccess.h +++ b/unit_tests/globalaccess.h @@ -9,9 +9,9 @@ #include "global.h" -#define DECLARE_CONFIG_PARAMETER_SIGNATURE engine_configuration_s *engineConfiguration, persistent_config_s *config, board_configuration_s *boardConfiguration +#define DECLARE_CONFIG_PARAMETER_SIGNATURE engine_configuration_s *engineConfiguration, persistent_config_s *config #define DECLARE_CONFIG_PARAMETER_SUFFIX , DECLARE_CONFIG_PARAMETER_SIGNATURE -#define PASS_CONFIG_PARAMETER_SIGNATURE engineConfiguration, config, boardConfiguration +#define PASS_CONFIG_PARAMETER_SIGNATURE engineConfiguration, config #define PASS_CONFIG_PARAMETER_SUFFIX , PASS_CONFIG_PARAMETER_SIGNATURE /** @@ -23,7 +23,4 @@ #define PASS_ENGINE_PARAMETER_SUFFIX , PASS_ENGINE_PARAMETER_SIGNATURE #define CONFIG(x) engineConfiguration->x -// todo: fix this! this does not work because of 'prepareVoidConfiguration(&activeConfiguration);' -//#define CONFIGB(x) engine->engineConfigurationPtr->bc.x -#define CONFIGB(x) CONFIG(bc.x) #define ENGINE(x) engine->x diff --git a/unit_tests/tests/sensor/func_chain.cpp b/unit_tests/tests/sensor/func_chain.cpp new file mode 100644 index 0000000000..b325a95675 --- /dev/null +++ b/unit_tests/tests/sensor/func_chain.cpp @@ -0,0 +1,84 @@ +#include "func_chain.h" + +#include + +struct AddOne final : public SensorConverter { + SensorResult convert(float input) const { + return {true, input + 1}; + } +}; + +struct SubOne final : public SensorConverter { + SensorResult convert(float input) const { + return {true, input - 1}; + } +}; + +struct Doubler final : public SensorConverter { + SensorResult convert(float input) const { + return {true, input * 2}; + } +}; + +TEST(FunctionChain, TestSingle) +{ + FuncChain fc; + + { + auto r = fc.convert(5); + EXPECT_TRUE(r.Valid); + EXPECT_EQ(r.Value, 6); + } + + { + auto r = fc.convert(10); + EXPECT_TRUE(r.Valid); + EXPECT_EQ(r.Value, 11); + } +} + +TEST(FunctionChain, TestDouble) +{ + // This computes fc(x) = (x + 1) * 2 + FuncChain fc; + + { + auto r = fc.convert(5); + EXPECT_TRUE(r.Valid); + EXPECT_EQ(r.Value, 12); + } + + { + auto r = fc.convert(10); + EXPECT_TRUE(r.Valid); + EXPECT_EQ(r.Value, 22); + } +} + +TEST(FunctionChain, TestTriple) +{ + // This computes fc(x) = ((x + 1) * 2) - 1 + FuncChain fc; + + { + auto r = fc.convert(5); + EXPECT_TRUE(r.Valid); + EXPECT_EQ(r.Value, 11); + } + + { + auto r = fc.convert(10); + EXPECT_TRUE(r.Valid); + EXPECT_EQ(r.Value, 21); + } +} + +TEST(FunctionChain, TestGet) +{ + // No logic here - the test is that it compiles + FuncChain fc; + + fc.get(); + fc.get(); + fc.get(); +} diff --git a/unit_tests/tests/sensor/resist_func.cpp b/unit_tests/tests/sensor/resist_func.cpp new file mode 100644 index 0000000000..8580e382b4 --- /dev/null +++ b/unit_tests/tests/sensor/resist_func.cpp @@ -0,0 +1,77 @@ +/* + * @author Matthew Kennedy, (c) 2019 + */ + +#include "unit_test_framework.h" +#include "resistance_func.h" + +TEST(resistance, OutOfRange) +{ + ResistanceFunc f; + f.configure(5, 10000); + + // Something in the middle should be valid + { + auto r = f.convert(2.5f); + ASSERT_TRUE(r.Valid); + } + + // Something near 0.05v should be valid + { + auto r = f.convert(0.051f); + EXPECT_TRUE(r.Valid); + } + + // Something just under 0.05v should be invalid + { + auto r = f.convert(0.049f); + EXPECT_FALSE(r.Valid); + } + + // Something near 0.95 * 5v should be valid + { + auto r = f.convert(0.94f * 5); + EXPECT_TRUE(r.Valid); + } + + // Something just above 0.95 * 5v should be invalid + { + auto r = f.convert(0.96f * 5); + EXPECT_FALSE(r.Valid); + } +} + +TEST(resistance, InRange) +{ + ResistanceFunc f; + f.configure(5, 10000); + + // 1 volt -> 2500 ohms low side + { + auto r = f.convert(1.0f); + EXPECT_TRUE(r.Valid); + EXPECT_FLOAT_EQ(r.Value, 2500); + } + + // 2 volt -> 6666.667 ohm ohms low side + // 20k/3 gives us an exact result + { + auto r = f.convert(2.0f); + EXPECT_TRUE(r.Valid); + EXPECT_FLOAT_EQ(r.Value, 20000.0f / 3); + } + + // 3 volt -> 15000 ohms low side + { + auto r = f.convert(3.0f); + EXPECT_TRUE(r.Valid); + EXPECT_FLOAT_EQ(r.Value, 15000); + } + + // 4 volt -> 40000 ohms low side + { + auto r = f.convert(4.0f); + EXPECT_TRUE(r.Valid); + EXPECT_FLOAT_EQ(r.Value, 40000); + } +} diff --git a/unit_tests/tests/sensor/therm_func.cpp b/unit_tests/tests/sensor/therm_func.cpp new file mode 100644 index 0000000000..1a7d434a2a --- /dev/null +++ b/unit_tests/tests/sensor/therm_func.cpp @@ -0,0 +1,36 @@ +/* + * @author Matthew Kennedy, (c) 2019 + */ + +#include "unit_test_framework.h" +#include "thermistor_func.h" +#include "thermistors.h" + +TEST(thermistor, Thermistor1) { + ThermistorFunc tf; + thermistor_conf_s tc = {32, 75, 120, 9500, 2100, 1000, 0}; + tf.configure(tc); + + SensorResult t = tf.convert(2100); + ASSERT_TRUE(t.Valid); + ASSERT_FLOAT_EQ(75, t.Value); + + ASSERT_NEAR(-0.003, tf.m_a, EPS4D); + ASSERT_NEAR(0.001, tf.m_b, EPS4D); + ASSERT_NEAR(0.0, tf.m_c, EPS5D); +} + +TEST(thermistor, ThermistorNeon) { + ThermistorFunc tf; + // 2003 Neon sensor + thermistor_conf_s tc = {0, 30, 100, 32500, 7550, 700, 0}; + tf.configure(tc); + + SensorResult t = tf.convert(38000); + ASSERT_TRUE(t.Valid); + ASSERT_NEAR(-2.7983, t.Value, EPS4D); + + assertEqualsM("A", 0.0009, tf.m_a); + assertEqualsM("B", 0.0003, tf.m_b); + ASSERT_NEAR(0.0, tf.m_c, EPS4D); +} diff --git a/unit_tests/tests/test_etb.cpp b/unit_tests/tests/test_etb.cpp new file mode 100644 index 0000000000..1571264036 --- /dev/null +++ b/unit_tests/tests/test_etb.cpp @@ -0,0 +1,67 @@ +/* + * @file test_etb.cpp + * + * @date Dec 13, 2019 + * @author Andrey Belomutskiy, (c) 2012-2019 + */ + +#include "engine_test_helper.h" +#include "electronic_throttle.h" +#include "dc_motor.h" + +class MockEtb : public IEtbController { +public: + // todo: somehow I am failinig to figure out GMOCK syntax here? + // todo: convert to GMOCK + int resetCount = 0; + int startCount = 0; + int initCount = 0; + + void reset() { + resetCount++; + } + + void Start() override { + startCount++; + } + + void init(DcMotor *motor, int ownIndex, pid_s *pidParameters) { + initCount++; + }; + + void PeriodicTask() { + }; + + int getPeriodMs() { + return 1; + }; +}; + + +TEST(etb, singleEtbInitialization) { + + MockEtb mocks[ETB_COUNT]; + + WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + + for (int i = 0; i < ETB_COUNT; i++) { + engine->etbControllers[i] = &mocks[i]; + } + + engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_9; + + doInitElectronicThrottle(PASS_ENGINE_PARAMETER_SIGNATURE); + + // assert that 1st ETB is initialized and started + ASSERT_EQ(1, mocks[0].initCount) << "1st init"; + ASSERT_EQ(1, mocks[0].startCount); + + // assert that 2nd ETB is initialized but not started + ASSERT_EQ(1, mocks[1].initCount) << "2nd init"; + ASSERT_EQ(0, mocks[1].startCount) << "2nd start"; + + +} + + + diff --git a/unit_tests/tests/test_fasterEngineSpinningUp.cpp b/unit_tests/tests/test_fasterEngineSpinningUp.cpp index fc92e1928d..1ee97d9926 100644 --- a/unit_tests/tests/test_fasterEngineSpinningUp.cpp +++ b/unit_tests/tests/test_fasterEngineSpinningUp.cpp @@ -12,7 +12,7 @@ TEST(cranking, testFasterEngineSpinningUp) { WITH_ENGINE_TEST_HELPER(TEST_ENGINE); // turn on FasterEngineSpinUp mode - engineConfiguration->bc.isFasterEngineSpinUpEnabled = true; + engineConfiguration->isFasterEngineSpinUpEnabled = true; // set ignition mode engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; @@ -100,7 +100,7 @@ TEST(cranking, testFasterEngineSpinningUp) { static void doTestFasterEngineSpinningUp60_2(int startUpDelayMs, int rpm1, int expectedRpm) { WITH_ENGINE_TEST_HELPER(TEST_ENGINE); // turn on FasterEngineSpinUp mode - engineConfiguration->bc.isFasterEngineSpinUpEnabled = true; + engineConfiguration->isFasterEngineSpinUpEnabled = true; setupSimpleTestEngineWithMaf(ð, IM_SEQUENTIAL, TT_TOOTHED_WHEEL_60_2); eth.moveTimeForwardMs(startUpDelayMs); diff --git a/unit_tests/tests/test_fuelCut.cpp b/unit_tests/tests/test_fuelCut.cpp index aac2da0cfa..20b0040c35 100644 --- a/unit_tests/tests/test_fuelCut.cpp +++ b/unit_tests/tests/test_fuelCut.cpp @@ -17,7 +17,7 @@ TEST(fuelCut, coasting) { WITH_ENGINE_TEST_HELPER(TEST_ENGINE); // configure coastingFuelCut - engineConfiguration->bc.coastingFuelCutEnabled = true; + engineConfiguration->coastingFuelCutEnabled = true; engineConfiguration->coastingFuelCutRpmLow = 1300; engineConfiguration->coastingFuelCutRpmHigh = 1500; engineConfiguration->coastingFuelCutTps = 2; diff --git a/unit_tests/tests/test_fuel_map.cpp b/unit_tests/tests/test_fuel_map.cpp index 4360bc4d5f..32d8617fdf 100644 --- a/unit_tests/tests/test_fuel_map.cpp +++ b/unit_tests/tests/test_fuel_map.cpp @@ -227,7 +227,7 @@ TEST(fuel, testTpsBasedVeDefect799) { WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); engineConfiguration->fuelAlgorithm = LM_SPEED_DENSITY; - CONFIGB(useTPSBasedVeTable) = true; + CONFIG(useTPSBasedVeTable) = true; int mapFrom = 100; // set MAP axis range diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index 69b0a23b38..b0557b2a6b 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -82,7 +82,7 @@ TEST(idle, timingPid) { // configure TPS engineConfiguration->tpsMin = 0; engineConfiguration->tpsMax = 100; - engineConfiguration->bc.idlePidDeactivationTpsThreshold = 10; + engineConfiguration->idlePidDeactivationTpsThreshold = 10; setMockTpsAdc(0 PASS_ENGINE_PARAMETER_SUFFIX); // disable temperature sensors @@ -90,12 +90,12 @@ TEST(idle, timingPid) { eth.engine.sensors.iat = NAN; // all corrections disabled, should be 0 - engineConfiguration->bc.useIdleTimingPidControl = false; + engineConfiguration->useIdleTimingPidControl = false; angle_t corr = getAdvanceCorrections(idleRpmTarget PASS_ENGINE_PARAMETER_SUFFIX); ASSERT_EQ(0, corr) << "getAdvanceCorrections#1"; // basic IDLE PID correction test - engineConfiguration->bc.useIdleTimingPidControl = true; + engineConfiguration->useIdleTimingPidControl = true; int baseTestRpm = idleRpmTarget + engineConfiguration->idleTimingPidWorkZone; corr = getAdvanceCorrections(baseTestRpm PASS_ENGINE_PARAMETER_SUFFIX); // (delta_rpm=-100) * (p-factor=0.1) = -10 degrees @@ -117,35 +117,34 @@ TEST(idle, timingPid) { ASSERT_FLOAT_EQ(-5.75f, corr) << "getAdvanceCorrections#5"; // check if PID correction is disabled in running mode (tps > threshold): - setMockTpsAdc(engineConfiguration->bc.idlePidDeactivationTpsThreshold + 1 PASS_ENGINE_PARAMETER_SUFFIX); + setMockTpsAdc(engineConfiguration->idlePidDeactivationTpsThreshold + 1 PASS_ENGINE_PARAMETER_SUFFIX); corr = getAdvanceCorrections(idleRpmTarget PASS_ENGINE_PARAMETER_SUFFIX); ASSERT_EQ(0, corr) << "getAdvanceCorrections#6"; // check if PID correction is interpolated for transient idle-running TPS positions - setMockTpsAdc(engineConfiguration->bc.idlePidDeactivationTpsThreshold / 2 PASS_ENGINE_PARAMETER_SUFFIX); + setMockTpsAdc(engineConfiguration->idlePidDeactivationTpsThreshold / 2 PASS_ENGINE_PARAMETER_SUFFIX); corr = getAdvanceCorrections(baseTestRpm PASS_ENGINE_PARAMETER_SUFFIX); ASSERT_FLOAT_EQ(-5.0f, corr) << "getAdvanceCorrections#7"; } // not great that we are reusing shared instance. todo: move EtbController to Engine? -extern EtbController etbController; TEST(idle, testTargetTpsIsFloatBug945) { WITH_ENGINE_TEST_HELPER(TEST_ENGINE); setMockThrottlePedalSensorVoltage(3 PASS_ENGINE_PARAMETER_SUFFIX); - etbController.PeriodicTask(); + engine->etbControllers[0]->PeriodicTask(); ASSERT_NEAR(50, engine->engineState.targetFromTable, EPS4D); setMockThrottlePedalSensorVoltage(3.05 PASS_ENGINE_PARAMETER_SUFFIX); ASSERT_NEAR(50.8302, getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE), EPS4D); - etbController.PeriodicTask(); + engine->etbControllers[0]->PeriodicTask(); ASSERT_NEAR(50.8302, engine->engineState.targetFromTable, EPS4D); setMockThrottlePedalSensorVoltage(3.1 PASS_ENGINE_PARAMETER_SUFFIX); - etbController.PeriodicTask(); + engine->etbControllers[0]->PeriodicTask(); ASSERT_NEAR(51.6605, engine->engineState.targetFromTable, EPS4D); } diff --git a/unit_tests/tests/test_ion.cpp b/unit_tests/tests/test_ion.cpp index 3ca7cbcfba..fca66ff6b4 100644 --- a/unit_tests/tests/test_ion.cpp +++ b/unit_tests/tests/test_ion.cpp @@ -5,9 +5,6 @@ * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef TEST_ION_CPP_ -#define TEST_ION_CPP_ - #include "gtest/gtest.h" #include "cdm_ion_sense.h" @@ -16,28 +13,22 @@ TEST(ion, signalCounter) { EXPECT_EQ(0, state.getValue(0)); - state.onNewSignal(2); - state.onNewSignal(2); - state.onNewSignal(2); + state.onNewSignal(/* currentRevolution= */ 2); + state.onNewSignal(/* currentRevolution= */ 2); + state.onNewSignal(/* currentRevolution= */ 2); // value is still '0' until we signal end of engine cycle - EXPECT_EQ(0, state.getValue(2)); + EXPECT_EQ(0, state.getValue(/* currentRevolution= */2)); // this invocation would flush current accumulation - EXPECT_EQ(3, state.getValue(3)); + EXPECT_EQ(3, state.getValue(/* currentRevolution= */3)); - state.onNewSignal(3); + state.onNewSignal(/* currentRevolution= */3); // returning previous full cycle value EXPECT_EQ(3, state.getValue(3)); - EXPECT_EQ(1, state.getValue(4)); - EXPECT_EQ(0, state.getValue(5)); - - - - + EXPECT_EQ(1, state.getValue(/* currentRevolution= */4)); + EXPECT_EQ(0, state.getValue(/* currentRevolution= */5)); } - -#endif /* TEST_ION_CPP_ */ diff --git a/unit_tests/tests/test_miata_na6_real_cranking.cpp b/unit_tests/tests/test_miata_na6_real_cranking.cpp index dc799e57aa..cc47a4252e 100644 --- a/unit_tests/tests/test_miata_na6_real_cranking.cpp +++ b/unit_tests/tests/test_miata_na6_real_cranking.cpp @@ -29,7 +29,7 @@ static void fireTriggerEvent(EngineTestHelper*eth, double timestampS, int channe EXPAND_Engine; timeNowUs = 1000000 * timestampS; printf("MIATANA: posting time=%d event=%d\r\n", timeNowUs, event); - engine->triggerCentral.handleShaftSignal(event, engine, engine->engineConfigurationPtr, ð->persistentConfig, boardConfiguration); + engine->triggerCentral.handleShaftSignal(event, engine, engine->engineConfigurationPtr, ð->persistentConfig); } TEST(miataNA6, realCranking) { diff --git a/unit_tests/tests/test_sensors.cpp b/unit_tests/tests/test_sensors.cpp index 4bfb6994b3..8852c2e21e 100644 --- a/unit_tests/tests/test_sensors.cpp +++ b/unit_tests/tests/test_sensors.cpp @@ -34,12 +34,12 @@ TEST(sensors, tps) { engineConfiguration->tpsMax = 193; engineConfiguration->tpsMin = 43; - ASSERT_NEAR(49.3333, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D); + ASSERT_NEAR(49.3333, getTpsValue(0, 4 * 117 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D); engineConfiguration->tpsMax = 43; engineConfiguration->tpsMin = 193; - assertEqualsM("test#2", 50.6667, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER_SUFFIX)); + assertEqualsM("test#2", 50.6667, getTpsValue(0, 4 * 117 PASS_ENGINE_PARAMETER_SUFFIX)); } TEST(sensors, testTpsRateOfChange) { diff --git a/unit_tests/tests/test_trigger_decoder.cpp b/unit_tests/tests/test_trigger_decoder.cpp index 7908947e6c..4cc6c205f6 100644 --- a/unit_tests/tests/test_trigger_decoder.cpp +++ b/unit_tests/tests/test_trigger_decoder.cpp @@ -5,26 +5,17 @@ * @author Andrey Belomutskiy, (c) 2012-2018 */ -#include "global.h" #include "engine_test_helper.h" #include "trigger_decoder.h" #include "engine_math.h" #include "allsensors.h" - +#include "engine_controller.h" #include "ford_aspire.h" #include "dodge_neon.h" #include "ford_1995_inline_6.h" -#include "mazda_323.h" -#include "rpm_calculator.h" #include "event_queue.h" -#include "algo.h" #include "trigger_mazda.h" #include "trigger_chrysler.h" -#include "tps.h" - -#include "trigger_central.h" -#include "main_trigger_callback.h" -#include "engine.h" #include "advance_map.h" #include "speed_density.h" #include "fuel_math.h" @@ -455,7 +446,6 @@ TEST(misc, testTriggerDecoder) { Engine *engine = &e; engine_configuration_s *engineConfiguration = &c.engineConfiguration; - board_configuration_s *boardConfiguration = &c.engineConfiguration.bc; initializeSkippedToothTriggerWaveformExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR); assertEqualsM("shape size", s->getSize(), 4); @@ -528,7 +518,7 @@ TEST(misc, testTriggerDecoder) { eth.persistentConfig.engineConfiguration.useOnlyRisingEdgeForTrigger = false; - eth.persistentConfig.engineConfiguration.bc.sensorChartMode = SC_DETAILED_RPM; + eth.persistentConfig.engineConfiguration.sensorChartMode = SC_DETAILED_RPM; applyNonPersistentConfiguration(NULL PASS_ENGINE_PARAMETER_SUFFIX); // assertEqualsM2("rpm#1", 16666.9746, eth.engine.triggerCentral.triggerState.instantRpmValue[0], 0.5); @@ -539,7 +529,6 @@ TEST(misc, testTriggerDecoder) { testTriggerDecoder3("miata 1994", MIATA_1994_DEVIATOR, 11, 0.2985, 0.3890, MIATA_NA_GAP); testTriggerDecoder3("citroen", CITROEN_TU3JP, 0, 0.4833, 0.0, 2.9994); - testTriggerDecoder2("MAZDA_323", MAZDA_323, 0, 0.4833, 0); testTriggerDecoder2("CAMARO_4", CAMARO_4, 40, 0.5, 0); testTriggerDecoder3("neon NGC4", DODGE_NEON_2003_CAM, 6, 0.5000, 0.0, CHRYSLER_NGC4_GAP); diff --git a/unit_tests/tests/test_trigger_noiseless.cpp b/unit_tests/tests/test_trigger_noiseless.cpp index 285394492b..cd009ef492 100644 --- a/unit_tests/tests/test_trigger_noiseless.cpp +++ b/unit_tests/tests/test_trigger_noiseless.cpp @@ -11,7 +11,6 @@ #include "allsensors.h" #include "rpm_calculator.h" #include "event_queue.h" -#include "algo.h" #include "trigger_central.h" #include "main_trigger_callback.h" #include "engine.h" @@ -29,7 +28,7 @@ static void fireEvent(EngineTestHelper *eth, bool isRise) { // but for noise filtering, both edges should be processed, so we fire falling events too if (isRise) eth->firePrimaryTriggerRise(); - else if (eth->engine.engineConfigurationPtr->bc.useNoiselessTriggerDecoder) + else if (eth->engine.engineConfigurationPtr->useNoiselessTriggerDecoder) eth->firePrimaryTriggerFall(); } @@ -92,7 +91,7 @@ static void resetTrigger(EngineTestHelper ð) { static void testNoiselessDecoderProcedure(EngineTestHelper ð, int errorToleranceCnt DECLARE_ENGINE_PARAMETER_SUFFIX) { printf("*** (bc->useNoiselessTriggerDecoder = %s)\r\n", - CONFIGB(useNoiselessTriggerDecoder) ? "true" : "false"); + CONFIG(useNoiselessTriggerDecoder) ? "true" : "false"); resetTrigger(eth); @@ -183,13 +182,13 @@ TEST(big, testNoiselessDecoder) { #if 0 // try normal trigger mode, no noise filtering - CONFIGB(useNoiselessTriggerDecoder) = false; + CONFIG(useNoiselessTriggerDecoder) = false; // for test validation, it should be 1 trigger error testNoiselessDecoderProcedure(eth, 1 PASS_ENGINE_PARAMETER_SUFFIX); #endif // now enable our noise filtering algo - CONFIGB(useNoiselessTriggerDecoder) = true; + CONFIG(useNoiselessTriggerDecoder) = true; // should be 0 errors! testNoiselessDecoderProcedure(eth, 0 PASS_ENGINE_PARAMETER_SUFFIX); diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index dc6e721b4f..f3f3b35a19 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -15,6 +15,7 @@ TESTS_SRC_CPP = \ tests/test_trigger_decoder.cpp \ tests/test_trigger_noiseless.cpp \ tests/test_issue_898.cpp \ + tests/test_etb.cpp \ tests/test_ignition_scheduling.cpp \ tests/test_fuel_map.cpp \ tests/test_fuel_wall_wetting.cpp \ @@ -37,4 +38,7 @@ TESTS_SRC_CPP = \ tests/sensor/function_pointer_sensor.cpp \ tests/sensor/mock_sensor.cpp \ tests/sensor/sensor_reader.cpp \ - tests/sensor/lin_func.cpp + tests/sensor/lin_func.cpp \ + tests/sensor/resist_func.cpp \ + tests/sensor/therm_func.cpp \ + tests/sensor/func_chain.cpp