void initElectronicThrottle(void) { addConsoleAction("ethinfo", showEthInfo); addConsoleAction("etbreset", etbReset); if (!hasPedalPositionSensor()) { return; } autoTune.SetOutputStep(0.1); startETBPins(); // manual duty cycle control without PID. Percent value from 0 to 100 addConsoleActionNANF("set_etb", setThrottleDutyCycle); tuneWorkingPidSettings.pFactor = 1; tuneWorkingPidSettings.iFactor = 0; tuneWorkingPidSettings.dFactor = 0; // tuneWorkingPidSettings.offset = 10; // todo: not hard-coded value //todo tuneWorkingPidSettings.periodMs = 10; tuneWorkingPidSettings.minValue = 0; tuneWorkingPidSettings.maxValue = 100; tuneWorkingPidSettings.periodMs = 100; // this is useful once you do "enable etb_auto" addConsoleActionF("set_etbat_output", setTempOutput); addConsoleActionF("set_etbat_step", setAutoStep); addConsoleActionI("set_etbat_period", setAutoPeriod); addConsoleActionI("set_etbat_offset", setAutoOffset); pid.reset(); etbController.Start(); }
void initSettings(void) { initLoggingExt(&logger, "settings control", LOGGING_BUFFER, sizeof(LOGGING_BUFFER)); addConsoleAction("showconfig", doPrintConfiguration); addConsoleAction("tempinfo", printTemperatureInfo); addConsoleAction("tpsinfo", printTPSInfo); addConsoleActionI("set_ignition_offset", setIgnitionOffset); addConsoleActionI("set_injection_offset", setInjectionOffset); addConsoleActionI("set_global_trigger_offset_angle", setGlobalTriggerAngleOffset); addConsoleActionI("set_analog_chart_mode", setAnalogChartMode); addConsoleActionI("set_fixed_mode_timing", setFixedModeTiming); addConsoleActionI("set_timing_mode", setTimingMode); addConsoleActionI("set_engine_type", setEngineType); addConsoleActionI("set_injection_pin_mode", setInjectionPinMode); addConsoleActionI("set_ignition_pin_mode", setIgnitionPinMode); addConsoleActionI("set_idle_pin", setIdlePin); addConsoleActionI("set_idle_pin_mode", setIdlePinMode); addConsoleActionI("set_fuel_pump_pin_mode", setFuelPumpPinMode); addConsoleActionI("set_malfunction_indicator_pin_mode", setMalfunctionIndicatorPinMode); addConsoleActionI("set_rpm_multiplier", setRpmMultiplier); // todo: start saving values into flash right away? addConsoleActionF("set_global_fuel_correction", setGlobalFuelCorrection); addConsoleActionII("set_cranking_fuel_min", setCrankingFuelMin); addConsoleActionII("set_cranking_fuel_max", setCrankingFuelMax); addConsoleActionI("set_cranking_rpm", setCrankingRpm); addConsoleActionF("set_cranking_timing_angle", setCrankingTimingAngle); addConsoleActionF("set_cranking_charge_angle", setCrankingChargeAngle); addConsoleActionI("set_ignition_mode", setIgnitionMode); addConsoleActionI("set_cranking_injection_mode", setCrankingInjectionMode); addConsoleActionI("set_injection_mode", setInjectionMode); addConsoleActionF("set_whole_fuel_map", setWholeFuelMapCmd); addConsoleActionSSS("set_fuel_map", setFuelMap); addConsoleActionF("set_whole_timing_map", setWholeTimingMap); addConsoleActionSSS("set_timing_map", setTimingMap); addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit); addConsoleActionI("set_firing_order", setFiringOrder); addConsoleAction("enable_injection", enableInjection); addConsoleAction("disable_injection", disableInjection); }
void initHip9011(Logging *sharedLogger) { driver = getSpiDevice(spiDevice); logger = sharedLogger; addConsoleAction("hipinfo", showHipInfo); if (!boardConfiguration->isHip9011Enabled) return; currentAngleWindowWidth = engineConfiguration->knockDetectionWindowEnd - engineConfiguration->knockDetectionWindowStart; prepareHip9011RpmLookup(currentAngleWindowWidth); // todo: configurable // driver = getSpiDevice(boardConfiguration->hip9011SpiDevice); spicfg.ssport = getHwPort(boardConfiguration->hip9011CsPin); spicfg.sspad = getHwPin(boardConfiguration->hip9011CsPin); outputPinRegisterExt2("hip int/hold", &intHold, boardConfiguration->hip9011IntHoldPin, &boardConfiguration->hip9011IntHoldPinMode); outputPinRegisterExt2("hip CS", &hipCs, boardConfiguration->hip9011CsPin, &boardConfiguration->hip9011CsPinMode); scheduleMsg(logger, "Starting HIP9011/TPIC8101 driver"); spiStart(driver, &spicfg); currentBandIndex = getBandIndex(); /** * this engine cycle callback would be scheduling actual integration start and end callbacks */ addTriggerEventListener(&intHoldCallback, "DD int/hold", engine); // MISO PB14 // palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(EFI_SPI2_AF) | PAL_STM32_PUDR_PULLUP); // MOSI PB15 // palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(EFI_SPI2_AF) | PAL_STM32_OTYPE_OPENDRAIN); addConsoleActionF("set_gain", setGain); addConsoleActionF("set_band", setBand); addConsoleActionI("set_hip_prescalerandsdo", setPrescalerAndSDO); addConsoleActionF("set_knock_threshold", setKnockThresh); addConsoleActionI("set_max_knock_sub_deg", setMaxKnockSubDeg); chThdCreateStatic(hipTreadStack, sizeof(hipTreadStack), NORMALPRIO, (tfunc_t) hipThread, NULL); }
void initHip9011(Logging *sharedLogger) { logger = sharedLogger; addConsoleAction("hipinfo", showHipInfo); if (!CONFIGB(isHip9011Enabled)) return; instance.setAngleWindowWidth(); #if EFI_PROD_CODE driver = getSpiDevice(engineConfiguration->hip9011SpiDevice); if (driver == NULL) { // error already reported return; } hipSpiCfg.ssport = getHwPort("hip", CONFIGB(hip9011CsPin)); hipSpiCfg.sspad = getHwPin("hip", CONFIGB(hip9011CsPin)); #endif /* EFI_PROD_CODE */ startHip9001_pins(); scheduleMsg(logger, "Starting HIP9011/TPIC8101 driver"); spiStart(driver, &hipSpiCfg); instance.currentBandIndex = getBandIndex(); /** * this engine cycle callback would be scheduling actual integration start and end callbacks */ addTriggerEventListener(&intHoldCallback, "DD int/hold", engine); // MISO PB14 // palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(EFI_SPI2_AF) | PAL_STM32_PUDR_PULLUP); // MOSI PB15 // palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(EFI_SPI2_AF) | PAL_STM32_OTYPE_OPENDRAIN); addConsoleActionF("set_gain", setHipGain); addConsoleActionF("set_band", setHipBand); addConsoleActionI("set_hip_prescalerandsdo", setPrescalerAndSDO); addConsoleActionF("set_knock_threshold", setKnockThresh); addConsoleActionI("set_max_knock_sub_deg", setMaxKnockSubDeg); chThdCreateStatic(hipTreadStack, sizeof(hipTreadStack), NORMALPRIO, (tfunc_t)(void*) hipThread, NULL); }
void initFakeBoard(void) { addConsoleActionF("set_mock_clt_voltage", setCltVoltage); addConsoleActionF("set_mock_iat_voltage", setIatVoltage); addConsoleActionF("set_mock_maf_voltage", setMafVoltage); addConsoleActionF("set_mock_afr_voltage", setAfrVoltage); addConsoleActionF("set_mock_tps_voltage", setTpsVoltage); addConsoleActionF("set_mock_map_voltage", setMapVoltage); }
void initAccelEnrichment(Logging *sharedLogger) { logger = sharedLogger; addConsoleActionI("set_tps_accel_len", setTpsAccelLen); addConsoleActionF("set_tps_accel_threshold", setTpsAccelThr); addConsoleActionF("set_tps_accel_multiplier", setTpsAccelMult); addConsoleActionF("set_tps_decel_threshold", setTpsDecelThr); addConsoleActionF("set_tps_decel_multiplier", setTpsDecelMult); addConsoleActionI("set_engine_load_accel_len", setEngineLoadAccelLen); addConsoleActionF("set_engine_load_accel_threshold", setEngineLoadAccelThr); addConsoleActionF("set_engine_load_accel_multiplier", setEngineLoadAccelMult); addConsoleActionF("set_engine_decel_threshold", setDecelThr); addConsoleActionF("set_engine_decel_multiplier", setDecelMult); addConsoleAction("accelinfo", accelInfo); updateAccelParameters(); }
void initFakeBoard(void) { initLogging(&logger, "simulator board"); addConsoleActionF("set_mock_clt_voltage", setCltVoltage); addConsoleActionF("set_mock_iat_voltage", setIatVoltage); addConsoleActionF("set_mock_maf_voltage", setMafVoltage); addConsoleActionF("set_mock_afr_voltage", setAfrVoltage); addConsoleActionF("set_mock_tps_voltage", setTpsVoltage); addConsoleActionF("set_mock_map_voltage", setMapVoltage); }
void initAccelEnrichment(Logging *sharedLogger) { logger = sharedLogger; addConsoleActionI("set_tps_accel_len", setTpsAccelLen); addConsoleActionF("set_tps_accel_threshold", setTpsAccelThr); addConsoleActionF("set_tps_ccel_multiplier", setTpsAccelMult); addConsoleActionI("set_map_accel_len", setMapAccelLen); addConsoleActionF("set_map_accel_threshold", setMapAccelThr); addConsoleActionF("set_map_ccel_multiplier", setMapAccelMult); addConsoleActionF("set_decel_threshold", setDecelThr); addConsoleActionF("set_decel_multiplier", setDecelMult); addConsoleAction("accelinfo", accelInfo); setMapAccelLen(engineConfiguration->mapAccelLength); setTpsAccelLen(engineConfiguration->tpsAccelLength); }
void initSettings(engine_configuration_s *engineConfiguration) { addConsoleActionP("showconfig", (VoidPtr) doPrintConfiguration, &engine); addConsoleAction("tempinfo", printTemperatureInfo); addConsoleAction("tpsinfo", printTPSInfo); addConsoleAction("info", printAllInfo); addConsoleActionF("set_ignition_offset", setIgnitionOffset); addConsoleActionF("set_injection_offset", setInjectionOffset); addConsoleActionF("set_global_trigger_offset_angle", setGlobalTriggerAngleOffset); addConsoleActionI("set_sensor_chart_mode", setSensorChartMode); addConsoleActionI("set_fixed_mode_timing", setFixedModeTiming); addConsoleActionI("set_timing_mode", setTimingMode); addConsoleActionI("set_engine_type", setEngineType); addConsoleActionI("set_injection_pin_mode", setInjectionPinMode); addConsoleActionI("set_ignition_pin_mode", setIgnitionPinMode); addConsoleActionI("set_idle_pin_mode", setIdlePinMode); addConsoleActionI("set_fuel_pump_pin_mode", setFuelPumpPinMode); addConsoleActionI("set_malfunction_indicator_pin_mode", setMalfunctionIndicatorPinMode); addConsoleActionI("set_operation_mode", setOM); // todo: start saving values into flash right away? addConsoleActionF("set_global_fuel_correction", setGlobalFuelCorrection); addConsoleActionF("set_cranking_fuel", setCrankingFuel); addConsoleActionI("set_cranking_rpm", setCrankingRpm); addConsoleActionF("set_cranking_timing_angle", setCrankingTimingAngle); addConsoleActionF("set_cranking_charge_angle", setCrankingChargeAngle); addConsoleActionI("set_ignition_mode", setIgnitionMode); addConsoleActionI("set_cranking_injection_mode", setCrankingInjectionMode); addConsoleActionI("set_injection_mode", setInjectionMode); addConsoleActionF("set_whole_phase_map", setWholePhaseMapCmd); addConsoleActionF("set_whole_timing_map", setWholeTimingMapCmd); addConsoleActionF("set_whole_fuel_map", setWholeFuelMapCmd); addConsoleActionF("set_whole_ve_map", setWholeVeCmd); addConsoleActionSSS("set_fuel_map", setFuelMap); addConsoleActionF("set_whole_timing_map", setWholeTimingMap); addConsoleActionSSS("set_timing_map", setTimingMap); addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit); addConsoleActionI("set_firing_order", setFiringOrder); addConsoleActionI("set_algorithm", setAlgorithmInt); addConsoleAction("stopengine", (Void) stopEngine); // todo: refactor this - looks like all boolean flags should be controlled with less code duplication addConsoleAction("enable_injection", enableInjection); addConsoleAction("disable_injection", disableInjection); addConsoleAction("enable_ignition", enableIgnition); addConsoleAction("disable_ignition", disableIgnition); addConsoleActionI("enable_spi", enableSpi); addConsoleActionI("disable_spi", disableSpi); addConsoleActionS("enable", enable); addConsoleActionS("disable", disable); addConsoleActionII("set_toothed_wheel", setToothedWheel); addConsoleActionI("set_trigger_type", setTriggerType); addConsoleActionF("set_vbatt_divider", setVBattDivider); addConsoleActionF("set_injector_lag", setInjectorLag); addConsoleActionF("set_clt_bias", setCltBias); addConsoleActionF("set_iat_bias", setIatBias); addConsoleActionI("set_idle_solenoid_freq", setIdleSolenoidFrequency); addConsoleActionFF("set_fan", setFanSetting); #if EFI_PROD_CODE addConsoleActionS("showpin", showPinFunction); addConsoleActionSS("set_injection_pin", setInjectionPin); addConsoleActionSS("set_ignition_pin", setIgnitionPin); addConsoleActionSS("set_trigger_input_pin", setTriggerInputPin); addConsoleActionSS("set_trigger_simulator_pin", setTriggerSimulatorPin); addConsoleActionSSP("set_egt_cs_pin", (VoidCharPtrCharPtrVoidPtr) setEgtCSPin, boardConfiguration); addConsoleActionI("set_egt_spi", setEgtSpi); addConsoleActionSS("set_trigger_simulator_mode", setTriggerSimulatorMode); addConsoleActionS("set_fuel_pump_pin", setFuelPumpPin); addConsoleActionS("set_ac_pin", setACPin); addConsoleActionS("set_alternator_pin", setAlternatorPin); addConsoleActionS("set_idle_pin", setIdlePin); addConsoleActionS("set_main_relay_pin", setMainRelayPin); addConsoleActionSS("set", setValue); addConsoleActionS("get", getValue); #if HAL_USE_ADC || defined(__DOXYGEN__) addConsoleActionSS("set_analog_input_pin", setAnalogInputPin); #endif addConsoleActionSS("set_logic_input_pin", setLogicInputPin); addConsoleActionI("set_pot_spi", setPotSpi); #endif /* EFI_PROD_CODE */ }