Beispiel #1
0
void initTriggerEmulator(Engine *engine) {

	engine_configuration_s *engineConfiguration = engine->engineConfiguration;
	board_configuration_s *boardConfiguration = &engineConfiguration->bc;

#if EFI_EMULATE_POSITION_SENSORS || defined(__DOXYGEN__)
	print("Emulating %s\r\n", getConfigurationName(engineConfiguration->engineType));

	triggerSignal.outputPins[0] = TRIGGER_EMULATOR_PRIMARY;
	triggerSignal.outputPins[1] = TRIGGER_EMULATOR_SECONDARY;
	triggerSignal.outputPins[2] = TRIGGER_EMULATOR_3RD;

#if EFI_PROD_CODE
	// todo: refactor, make this a loop
	outputPinRegisterExt2("distributor ch1", triggerSignal.outputPins[0], boardConfiguration->triggerSimulatorPins[0],
			&boardConfiguration->triggerSimulatorPinModes[0]);

	outputPinRegisterExt2("distributor ch2", triggerSignal.outputPins[1], boardConfiguration->triggerSimulatorPins[1],
			&boardConfiguration->triggerSimulatorPinModes[1]);

	outputPinRegisterExt2("distributor ch3", triggerSignal.outputPins[2], boardConfiguration->triggerSimulatorPins[2],
			&boardConfiguration->triggerSimulatorPinModes[2]);
#endif /* EFI_PROD_CODE */

	initTriggerEmulatorLogic(engine);
#else
	print("No position sensor(s) emulation\r\n");
#endif /* EFI_EMULATE_POSITION_SENSORS */
}
Beispiel #2
0
void initIgnitionCentral(void) {
	initLogging(&logger, "IgnitionCentral");

	outputPinRegisterExt2("sparkout1", SPARKOUT_1_OUTPUT, boardConfiguration->ignitionPins[0], &boardConfiguration->ignitionPinMode);
	outputPinRegisterExt2("sparkout2", SPARKOUT_2_OUTPUT, boardConfiguration->ignitionPins[1], &boardConfiguration->ignitionPinMode);
	outputPinRegisterExt2("sparkout3", SPARKOUT_3_OUTPUT, boardConfiguration->ignitionPins[2], &boardConfiguration->ignitionPinMode);
	outputPinRegisterExt2("sparkout4", SPARKOUT_4_OUTPUT, boardConfiguration->ignitionPins[3], &boardConfiguration->ignitionPinMode);
}
Beispiel #3
0
static void initStatusLeds(void) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
	outputPinRegisterExt2("led: comm status", &communicationPin,
			engineConfiguration->communicationPin, &DEFAULT_OUTPUT);
	// we initialize this here so that we can blink it on start-up
	outputPinRegisterExt2("MalfunctionIndicator", &enginePins.checkEnginePin, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);
#endif

#if EFI_WARNING_LED || defined(__DOXYGEN__)
	outputPinRegister("led: warning status", &warningPin, LED_WARNING_PORT,
	LED_WARNING_PIN);
	outputPinRegisterExt2("led: running status", &runningPin, engineConfiguration->runningPin,
			&DEFAULT_OUTPUT);
#endif /* EFI_WARNING_LED */
}
Beispiel #4
0
void initInjectorCentral(void) {
	initLogging(&logger, "InjectorCentral");
	chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL);

	for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
		is_injector_enabled[i] = true;
        }

	// todo: should we move this code closer to the injection logic?
	for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
		io_pin_e pin = (io_pin_e) ((int) INJECTOR_1_OUTPUT + i);

		outputPinRegisterExt2(getPinName(pin), pin, boardConfiguration->injectionPins[i],
				&boardConfiguration->injectionPinMode);
	}

	printStatus();
	addConsoleActionII("injector", setInjectorEnabled);

	addConsoleActionII("fuelpumpbench", &fuelpumpbench);

	addConsoleActionSSS("fuelbench", &fuelbench);
	addConsoleActionSSS("sparkbench", &sparkbench);

	addConsoleActionSSSSS("fuelbench2", &fuelbench2);
	addConsoleActionSSSSS("sparkbench2", &sparkbench2);
}
Beispiel #5
0
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);
}
Beispiel #6
0
void initOutputPins(void) {
	/**
	 * want to make sure it's all zeros so that we can compare in initOutputPinExt() method
	 */
// todo: it's too late to clear now? this breaks default status LEDs
// todo: fix this?
//	memset(&outputs, 0, sizeof(outputs));
//	outputPinRegister("ext led 1", LED_EXT_1, EXTRA_LED_1_PORT, EXTRA_LED_1_PIN);
//	outputPinRegister("ext led 2", LED_EXT_2, EXTRA_LED_2_PORT, EXTRA_LED_2_PIN);
//	outputPinRegister("ext led 3", LED_EXT_3, EXTRA_LED_2_PORT, EXTRA_LED_3_PIN);
//	outputPinRegister("alive1", LED_DEBUG, GPIOD, 6);
	outputPinRegisterExt2("MalfunctionIndicator", &checkEnginePin, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);

// todo: are these needed here? todo: make configurable
//	outputPinRegister("spi CS1", SPI_CS_1, SPI_CS1_PORT, SPI_CS1_PIN);
//	outputPinRegister("spi CS2", SPI_CS_2, SPI_CS2_PORT, SPI_CS2_PIN);
//	outputPinRegister("spi CS3", SPI_CS_3, SPI_CS3_PORT, SPI_CS3_PIN);
//	outputPinRegister("spi CS4", SPI_CS_4, SPI_CS4_PORT, SPI_CS4_PIN);
#if HAL_USE_SPI || defined(__DOXYGEN__)
	outputPinRegisterExt2("spi CS5", &sdCsPin, boardConfiguration->sdCardCsPin, &DEFAULT_OUTPUT);
#endif

	// todo: should we move this code closer to the fuel pump logic?
	outputPinRegisterExt2("fuel pump relay", &enginePins.fuelPumpRelay, boardConfiguration->fuelPumpPin, &DEFAULT_OUTPUT);

	outputPinRegisterExt2("main relay", &enginePins.mainRelay, boardConfiguration->mainRelayPin, &boardConfiguration->mainRelayPinMode);

	outputPinRegisterExt2("fan relay", &enginePins.fanRelay, boardConfiguration->fanPin, &DEFAULT_OUTPUT);
	outputPinRegisterExt2("o2 heater", &enginePins.o2heater, boardConfiguration->o2heaterPin, &DEFAULT_OUTPUT);
	outputPinRegisterExt2("A/C relay", &enginePins.acRelay, boardConfiguration->acRelayPin, &boardConfiguration->acRelayPinMode);

	// digit 1
	/*
	 ledRegister(LED_HUGE_0, GPIOB, 2);
	 ledRegister(LED_HUGE_1, GPIOE, 7);
	 ledRegister(LED_HUGE_2, GPIOE, 8);
	 ledRegister(LED_HUGE_3, GPIOE, 9);
	 ledRegister(LED_HUGE_4, GPIOE, 10);
	 ledRegister(LED_HUGE_5, GPIOE, 11);
	 ledRegister(LED_HUGE_6, GPIOE, 12);

	 // digit 2
	 ledRegister(LED_HUGE_7, GPIOE, 13);
	 ledRegister(LED_HUGE_8, GPIOE, 14);
	 ledRegister(LED_HUGE_9, GPIOE, 15);
	 ledRegister(LED_HUGE_10, GPIOB, 10);
	 ledRegister(LED_HUGE_11, GPIOB, 11);
	 ledRegister(LED_HUGE_12, GPIOB, 12);
	 ledRegister(LED_HUGE_13, GPIOB, 13);

	 // digit 3
	 ledRegister(LED_HUGE_14, GPIOE, 0);
	 ledRegister(LED_HUGE_15, GPIOE, 2);
	 ledRegister(LED_HUGE_16, GPIOE, 4);
	 ledRegister(LED_HUGE_17, GPIOE, 6);
	 ledRegister(LED_HUGE_18, GPIOE, 5);
	 ledRegister(LED_HUGE_19, GPIOE, 3);
	 ledRegister(LED_HUGE_20, GPIOE, 1);
	 */
}
Beispiel #7
0
void startIgnitionPins(void) {
	for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
		NamedOutputPin *output = &enginePins.coils[i];
		if (boardConfiguration->ignitionPins[i] != activeConfiguration.bc.ignitionPins[i]) {
			outputPinRegisterExt2(output->name, output, boardConfiguration->ignitionPins[i],
				&boardConfiguration->ignitionPinMode);
		}
	}
}
Beispiel #8
0
void initTriggerEmulator(void) {
#if EFI_EMULATE_POSITION_SENSORS
	print("Emulating %s\r\n", getConfigurationName(engineConfiguration));

	configuration.outputPins[0] = TRIGGER_EMILATOR_PRIMARY;
	configuration.outputPins[1] = TRIGGER_EMILATOR_SECONDARY;

	outputPinRegisterExt2("distributor ch1", configuration.outputPins[0], boardConfiguration->triggerSimulatorPins[0],
			&boardConfiguration->triggerSimulatorPinModes[0]);

	outputPinRegisterExt2("distributor ch2", configuration.outputPins[1], boardConfiguration->triggerSimulatorPins[1],
			&boardConfiguration->triggerSimulatorPinModes[1]);

	initTriggerEmulatorLogic(applyPinState);
#else
	print("No position sensor(s) emulation\r\n");
#endif /* EFI_EMULATE_POSITION_SENSORS */
}
Beispiel #9
0
void 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 (engineConfiguration->bc.injectionPins[i] != activeConfiguration.bc.injectionPins[i]) {

			outputPinRegisterExt2(output->name, output, boardConfiguration->injectionPins[i],
					&boardConfiguration->injectionPinMode);
		}
	}
}