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 initInjectorCentral(Logging *sharedLogger) { logger = sharedLogger; chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { is_injector_enabled[i] = true; } startInjectionPins(); startIgnitionPins(); printStatus(); addConsoleActionII("injector", setInjectorEnabled); addConsoleAction("fuelpumpbench", fuelPumpBench); addConsoleActionS("fuelpumpbench2", fuelPumpBenchExt); addConsoleAction("fanbench", fanBench); addConsoleAction("milbench", milBench); addConsoleActionSSS("fuelbench", fuelbench); addConsoleActionSSS("sparkbench", sparkbench); addConsoleActionSSSSS("fuelbench2", fuelbench2); addConsoleActionSSSSS("sparkbench2", sparkbench2); }
void startIdleThread(Logging*sharedLogger, Engine *engine) { logger = sharedLogger; // todo: re-initialize idle pins on the fly initIdleHardware(); idlePositionController.init(); scheduleMsg(logger, "initial idle %d", idlePositionController.value); chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL); // this is idle switch INPUT - sometimes there is a switch on the throttle pedal // this switch is not used yet if (boardConfiguration->clutchDownPin != GPIO_UNASSIGNED) mySetPadMode2("clutch down switch", boardConfiguration->clutchDownPin, getInputMode(boardConfiguration->clutchDownPinMode)); if (boardConfiguration->clutchUpPin != GPIO_UNASSIGNED) mySetPadMode2("clutch up switch", boardConfiguration->clutchUpPin, getInputMode(boardConfiguration->clutchUpPinMode)); addConsoleAction("idleinfo", showIdleInfo); addConsoleActionI("set_idle_enabled", (VoidInt) setIdleControlEnabled); addConsoleActionII("blipidle", blipIdle); // split this whole file into manual controller and auto controller? move these commands into the file // which would be dedicated to just auto-controller? addConsoleAction("idlebench", startIdleBench); apply(); }
void initFlash(void) { initLogging(&logger, "Flash memory"); addConsoleAction("readconfig", readFromFlash); addConsoleAction("writeconfig", writeToFlash); addConsoleAction("resetconfig", doResetConfiguration); }
void initTimePerfActions(Logging *sharedLogger) { logger = sharedLogger; #if EFI_RTC || defined(__DOXYGEN__) rtcStartTime = rtcGetTimeUnixSec(&RTCD1); #endif // initOutputPin("test pad", &testOutput, TEST_PORT, TEST_PIN); addConsoleActionI("perftest", runTests); addConsoleAction("timeinfo", timeInfo); addConsoleAction("chtest", runChibioTest); }
void initBoardTest(void) { is_board_test_mode = true; addConsoleAction("n", nextStep); addConsoleActionI("set", setIndex); chThdCreateStatic(btThreadStack, sizeof(btThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL); // this code is ugly as hell, I had no time to think. Todo: refactor processAdcPin(&fastAdc, 0, "fast"); while (currentIndex < slowAdc.size()) { processAdcPin(&slowAdc, currentIndex, "slow"); currentIndex++; } currentIndex = 0; int pinsCount = sizeof(BLINK_PINS) / sizeof(brain_pin_e); while (currentIndex < pinsCount) { currentPin = BLINK_PINS[currentIndex]; printBoardTestState(); mySetPadMode2("test", currentPin, PAL_STM32_MODE_OUTPUT); currentIndex++; waitForKey(); } // no buffered logger still, just plain old stdout while (1) { print("Board test done, thank you! Time to remove that jumper and reboot\r\n"); print("Bye!\r\n"); chThdSleepSeconds(1); } }
void initCan(void) { #if EFI_PROD_CODE || defined(__DOXYGEN__) addConsoleAction("caninfo", canInfo); if (!engineConfiguration->isCanEnabled) return; #endif /* EFI_PROD_CODE */ #if STM32_CAN_USE_CAN2 || defined(__DOXYGEN__) // CAN1 is required for CAN2 canStart(&CAND1, &canConfig); canStart(&CAND2, &canConfig); #else canStart(&CAND1, &canConfig); #endif canStart(&EFI_CAN_DEVICE, &canConfig); #if EFI_PROD_CODE || defined(__DOXYGEN__) chThdCreateStatic(canTreadStack, sizeof(canTreadStack), NORMALPRIO, (tfunc_t) canThread, NULL); mySetPadMode2("CAN TX", boardConfiguration->canTxPin, PAL_MODE_ALTERNATE(EFI_CAN_TX_AF)); mySetPadMode2("CAN RX", boardConfiguration->canRxPin, PAL_MODE_ALTERNATE(EFI_CAN_RX_AF)); #endif /* EFI_PROD_CODE */ }
void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p) { logger = sharedLogger; console_line_callback = console_line_callback_p; #if (defined(EFI_CONSOLE_UART_DEVICE) && ! EFI_SIMULATOR) || defined(__DOXYGEN__) palSetPadMode(CONSOLE_MODE_SWITCH_PORT, CONSOLE_MODE_SWITCH_PIN, PAL_MODE_INPUT_PULLUP); b_isCommandLineConsoleOverTTL = GET_CONSOLE_MODE_VALUE() == EFI_USE_UART_FOR_CONSOLE; if (isCommandLineConsoleOverTTL()) { /* * Activates the serial * it is important to set 'NONE' as flow control! in terminal application on the PC */ serialConfig.speed = engineConfiguration->uartConsoleSerialSpeed; sdStart(EFI_CONSOLE_UART_DEVICE, &serialConfig); // cannot use pin repository here because pin repository prints to console palSetPadMode(EFI_CONSOLE_RX_PORT, EFI_CONSOLE_RX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); palSetPadMode(EFI_CONSOLE_TX_PORT, EFI_CONSOLE_TX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); isSerialConsoleStarted = true; chEvtRegisterMask((event_source_t *) chnGetEventSource(EFI_CONSOLE_UART_DEVICE), &consoleEventListener, 1); } #else b_isCommandLineConsoleOverTTL = false; #endif /* EFI_PROD_CODE */ chThdCreateStatic(consoleThreadStack, sizeof(consoleThreadStack), NORMALPRIO, (tfunc_t)consoleThreadThreadEntryPoint, NULL); addConsoleAction(SWITCH_TO_BINARY_COMMAND, switchToBinaryProtocol); }
void startTunerStudioConnectivity(void) { initLogging(&logger, "tuner studio"); if (sizeof(engine_configuration_s) != getTunerStudioPageSize(0)) firmwareError("TS page size mismatch: %d/%d", sizeof(engine_configuration_s), getTunerStudioPageSize(0)); if (sizeof(TunerStudioOutputChannels) != TS_OUTPUT_SIZE) firmwareError("TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE); memset(&tsState, 0, sizeof(tsState)); #if EFI_PROD_CODE if (isSerialOverUart()) { print("TunerStudio over USB serial"); usb_serial_start(); } else { print("TunerStudio over USART"); mySetPadMode("tunerstudio rx", TS_SERIAL_RX_PORT, TS_SERIAL_RX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF)); mySetPadMode("tunerstudio tx", TS_SERIAL_TX_PORT, TS_SERIAL_TX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF)); sdStart(TS_SERIAL_UART_DEVICE, &tsSerialConfig); } #endif /* EFI_PROD_CODE */ syncTunerStudioCopy(); addConsoleAction("tsinfo", printStats); chThdCreateStatic(TS_WORKING_AREA, sizeof(TS_WORKING_AREA), NORMALPRIO, tsThreadEntryPoint, NULL); }
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 initFlash(Logging *sharedLogger) { logger = sharedLogger; addConsoleAction("readconfig", readFromFlash); /** * This would write NOW (you should not be doing this while connected to real engine) */ addConsoleAction("writeconfig", writeToFlashNow); #if EFI_TUNER_STUDIO || defined(__DOXYGEN__) /** * This would schedule write to flash once the engine is stopped */ addConsoleAction("burnconfig", requestBurn); #endif addConsoleAction("resetconfig", doResetConfiguration); addConsoleAction("rewriteconfig", rewriteConfig); }
void initConsoleLogic() { #if EFI_PROD_CODE || EFI_SIMULATOR initLogging(&logging, "rfi console"); #endif /* EFI_PROD_CODE */ resetConsoleActions(); addConsoleAction("help", helpCommand); addConsoleActionI("echo", echo); }
void initializeConsole() { initIntermediateLoggingBuffer(); initConsoleLogic(); startChibiosConsole(&handleConsoleLine); initLogging(&logger, "console"); sayHello(); addConsoleAction("hello", sayHello); #if EFI_HAS_RESET addConsoleAction("reset", scheduleReset); #endif addConsoleAction("fatal", myfatal); addConsoleAction("threadsinfo", cmd_threads); }
void initMalfunctionIndicator(void) { if (!isMilEnabled()) { return; } // create static thread chThdCreateStatic(mfiThreadStack, sizeof(mfiThreadStack), LOWPRIO, (tfunc_t) mfiThread, NULL); addConsoleAction("testmil", testMil); }
void lcd_HD44780_init(Logging *sharedLogger) { logger = sharedLogger; addConsoleAction("lcdinfo", lcdInfo); if (engineConfiguration->displayMode > DM_HD44780_OVER_PCF8574) { firmwareError("Unexpected displayMode %d", engineConfiguration->displayMode); return; } printMsg(logger, "lcd_HD44780_init %d", engineConfiguration->displayMode); if (engineConfiguration->displayMode == DM_HD44780) { // initialize hardware lines mySetPadMode2("lcd RS", boardConfiguration->HD44780_rs, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd E", boardConfiguration->HD44780_e, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB4", boardConfiguration->HD44780_db4, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB6", boardConfiguration->HD44780_db5, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB7", boardConfiguration->HD44780_db6, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB8", boardConfiguration->HD44780_db7, PAL_MODE_OUTPUT_PUSHPULL); // and zero values palWritePad(getHwPort(boardConfiguration->HD44780_rs), getHwPin(boardConfiguration->HD44780_rs), 0); palWritePad(getHwPort(boardConfiguration->HD44780_e), getHwPin(boardConfiguration->HD44780_e), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db4), getHwPin(boardConfiguration->HD44780_db4), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db5), getHwPin(boardConfiguration->HD44780_db5), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db6), getHwPin(boardConfiguration->HD44780_db6), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db7), getHwPin(boardConfiguration->HD44780_db7), 0); } chThdSleepMilliseconds(20); // LCD needs some time to wake up lcd_HD44780_write(LCD_HD44780_RESET); // reset 1x chThdSleepMilliseconds(1); lcd_HD44780_write(LCD_HD44780_RESET); // reset 2x lcd_HD44780_write(LCD_HD44780_RESET); // reset 3x lcd_HD44780_write(LCD_HD44780_4_BIT_BUS); // 4 bit, 2 line chThdSleepMicroseconds(40); lcd_HD44780_write(LCD_HD44780_4_BIT_BUS); // 4 bit, 2 line lcd_HD44780_write(0x80); chThdSleepMicroseconds(40); lcd_HD44780_write_command(0x08); // display and cursor control chThdSleepMicroseconds(40); lcd_HD44780_write_command(LCD_HD44780_DISPLAY_CLEAR); chThdSleepMilliseconds(2); lcd_HD44780_write_command(LCD_HD44780_SHIFT_CURSOR_RIGHT); chThdSleepMilliseconds(2); lcd_HD44780_write_command(LCD_HD44780_DISPLAY_ON); lcd_HD44780_set_position(0, 0); printMsg(logger, "lcd_HD44780_init() done"); }
void startTunerStudioConnectivity(void) { if (sizeof(persistent_config_s) != getTunerStudioPageSize(0)) firmwareError("TS page size mismatch: %d/%d", sizeof(persistent_config_s), getTunerStudioPageSize(0)); if (sizeof(TunerStudioOutputChannels) != TS_OUTPUT_SIZE) firmwareError("TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE); memset(&tsState, 0, sizeof(tsState)); syncTunerStudioCopy(); addConsoleAction("tsinfo", printTsStats); addConsoleAction("reset_ts", resetTs); addConsoleActionI("set_ts_speed", setTsSpeed); tsChannel.channel = getTsSerialDevice(); tsChannel.writeBuffer = tsCrcWriteBuffer; chThdCreateStatic(tsThreadStack, sizeof(tsThreadStack), NORMALPRIO, tsThreadEntryPoint, NULL); }
void initMax31855(Logging *sharedLogger, SPIDriver *drv, egt_cs_array_t max31855_cs) { logger = sharedLogger; // todo:spi device is now enabled separately - should probably be enabled here driver = drv; addConsoleAction("egtinfo", (Void) showEgtInfo); addConsoleAction("egtread", (Void) egtRead); for (int i = 0; i < EGT_CHANNEL_COUNT; i++) { if (max31855_cs[i] != GPIO_UNASSIGNED) { initSpiCs(&spiConfig[i], max31855_cs[i]); spiConfig[i].cr1 = SPI_BaudRatePrescaler_8; } } }
void initVehicleSpeed(Logging *l) { logger = l; if (boardConfiguration->vehicleSpeedSensorInputPin == GPIO_UNASSIGNED) return; digital_input_s* vehicleSpeedInput = initWaveAnalyzerDriver("VSS", boardConfiguration->vehicleSpeedSensorInputPin); startInputDriver(vehicleSpeedInput, true); vehicleSpeedInput->widthListeners.registerCallback((VoidInt) vsAnaWidthCallback, NULL); addConsoleAction("speedinfo", speedInfo); }
static void initECUstimulator(void) { mySetPadMode("TEN", DIAG_PORT, DIAG_PIN, PAL_MODE_OUTPUT_PUSHPULL); addConsoleActionI("diag", setDiag); addConsoleAction("emu", startEmulator); addConsoleActionII("ad", printAdvance); setDiag(1); chThdCreateStatic(eeThreadStack, sizeof(eeThreadStack), NORMALPRIO, (tfunc_t) eeThread, NULL); }
void lcd_HD44780_init(void) { initLogging(&logger, "HD44780 driver"); addConsoleAction("lcdinfo", lcdInfo); if (engineConfiguration->displayMode == DM_HD44780) { mySetPadMode("lcd RS", HD44780_PORT_RS, HD44780_PIN_RS, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd E", HD44780_PORT_E, HD44780_PIN_E, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB4", HD44780_PORT_DB4, HD44780_PIN_DB4, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB6", HD44780_PORT_DB5, HD44780_PIN_DB5, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB7", HD44780_PORT_DB6, HD44780_PIN_DB6, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB8", HD44780_PORT_DB7, HD44780_PIN_DB7, PAL_MODE_OUTPUT_PUSHPULL); palWritePad(HD44780_PORT_RS, HD44780_PIN_RS, 0); palWritePad(HD44780_PORT_E, HD44780_PIN_E, 0); palWritePad(HD44780_PORT_DB4, HD44780_PIN_DB4, 0); palWritePad(HD44780_PORT_DB5, HD44780_PIN_DB5, 0); palWritePad(HD44780_PORT_DB6, HD44780_PIN_DB6, 0); palWritePad(HD44780_PORT_DB7, HD44780_PIN_DB7, 0); } // LCD needs some time to wake up chThdSleepMilliseconds(50); lcd_HD44780_write(LCD_2X16_RESET); chThdSleepMilliseconds(1); lcd_HD44780_write(0x30); lcd_HD44780_write(LCD_2X16_4_BIT_BUS); // 4 bit, 2 line chThdSleepMicroseconds(40); lcd_HD44780_write(LCD_2X16_4_BIT_BUS); // 4 bit, 2 line lcd_HD44780_write(0x80); chThdSleepMicroseconds(40); lcd_HD44780_write(0x00); // display and cursor control lcd_HD44780_write(0xC0); chThdSleepMicroseconds(40); lcd_HD44780_write(0x00); // display clear lcd_HD44780_write(0x01); chThdSleepMilliseconds(2); lcd_HD44780_write(0x00); // entry mode set lcd_HD44780_write(0x60); lcd_HD44780_set_position(0, 0); lcd_HD44780_print_string("rusefi here\n"); lcd_HD44780_print_string(__DATE__); }
void initTriggerEmulatorLogic(Logging *sharedLogger) { logger = sharedLogger; TriggerShape *s = &engine->triggerCentral.triggerShape; setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency PASS_ENGINE_PARAMETER_SUFFIX); pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates, s->wave.waves[2].pinStates }; triggerSignal.weComplexInit("position sensor", s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, pinStates, updateTriggerShapeIfNeeded, emulatorApplyPinState); addConsoleActionI("rpm", setTriggerEmulatorRPM); addConsoleActionI("stop_stimulator_at_index", setEmulatorAtIndex); addConsoleAction("resume_stimulator", resumeStimulator); }
void initGps(void) { if(!engineConfiguration->isGpsEnabled) return; sdStart(GPS_SERIAL_DEVICE, &GPSserialConfig); // GPS we have USART1: PB7 -> USART1_RX and PB6 -> USART1_TX mySetPadMode2("GPS tx", boardConfiguration->gps_tx_pin, PAL_MODE_ALTERNATE(7)); mySetPadMode2("GPS rx", boardConfiguration->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)GpsThreadEntryPoint, NULL); addConsoleAction("gpsinfo", &printGpsInfo); }
void initMax31855(Logging *sharedLogger, spi_device_e device, egt_cs_array_t max31855_cs) { driver = getSpiDevice(device); if (driver == NULL) { // error already reported return; } logger = sharedLogger; // todo:spi device is now enabled separately - should probably be enabled here addConsoleAction("egtinfo", (Void) showEgtInfo); addConsoleAction("egtread", (Void) egtRead); for (int i = 0; i < EGT_CHANNEL_COUNT; i++) { if (max31855_cs[i] != GPIO_UNASSIGNED) { initSpiCs(&spiConfig[i], max31855_cs[i]); spiConfig[i].cr1 = getSpiPrescaler(_5MHz, device); } } }
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 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 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 initTriggerCentral(Logging *sharedLogger, Engine *engine) { logger = sharedLogger; strcpy((char*) shaft_signal_msg_index, "x_"); #if EFI_WAVE_CHART initWaveChart(&waveChart); #endif /* EFI_WAVE_CHART */ #if EFI_PROD_CODE || EFI_SIMULATOR addConsoleActionP("triggerinfo", (VoidPtr) triggerInfo, engine); addConsoleActionP("trigger_shape_info", (VoidPtr) triggerShapeInfo, engine); addConsoleAction("reset_trigger", resetRunningTriggerCounters); #endif #if EFI_HISTOGRAMS initHistogram(&triggerCallback, "all callbacks"); #endif /* EFI_HISTOGRAMS */ }
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 initWaveAnalyzer(Logging *sharedLogger) { logger = sharedLogger; if (hasFirmwareError()) { return; } #if EFI_WAVE_ANALYZER initWave(WA_CHANNEL_1, 0); initWave(WA_CHANNEL_2, 1); addTriggerEventListener(waTriggerEventListener, "wave analyzer", engine); addConsoleAction("waveinfo", showWaveInfo); addConsoleActionII("set_logic_input_mode", setWaveModeSilent); chThdCreateStatic(waThreadStack, sizeof(waThreadStack), NORMALPRIO, (tfunc_t)waThread, NULL); #else print("wave disabled\r\n"); #endif }
void initializeConsole(Logging *sharedLogger) { initConsoleLogic(sharedLogger); startConsole(sharedLogger, &handleConsoleLine); sayHello(); addConsoleAction("test", sayNothing); addConsoleAction("hello", sayHello); #if EFI_HAS_RESET addConsoleAction("reset", scheduleReset); #endif addConsoleAction("fatal", myfatal); addConsoleAction("error", myerror); addConsoleAction("threadsinfo", cmd_threads); }