示例#1
0
static void auxValveTriggerCallback(trigger_event_e ckpSignalType,
		uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) {
	UNUSED(ckpSignalType);
#if EFI_PROD_CODE || EFI_SIMULATOR
	if (index != SCHEDULING_TRIGGER_INDEX) {
		return;
	}
	int rpm = GET_RPM_VALUE;
	if (!isValidRpm(rpm)) {
		return;
	}

	for (int valveIndex = 0; valveIndex < AUX_DIGITAL_VALVE_COUNT;
			valveIndex++) {

		NamedOutputPin *output = &enginePins.auxValve[valveIndex];

		for (int phaseIndex = 0; phaseIndex < 2; phaseIndex++) {
/* I believe a more correct implementation is the following:
 * here we properly account for trigger angle position in engine cycle coordinates
			// todo: at the moment this logic is assuming four-stroke 720-degree engine cycle
			angle_t extra = phaseIndex * 360 // cycle opens twice per 720 engine cycle
					+ valveIndex * 180 // 2nd valve is operating at 180 offset to first
					+ tdcPosition() // engine cycle position to trigger cycle position conversion
					- ENGINE(triggerCentral.triggerShape.eventAngles[SCHEDULING_TRIGGER_INDEX])
					;
*/
			angle_t extra = phaseIndex * 360 + valveIndex * 180;
			angle_t onTime = extra + engine->engineState.auxValveStart;
			fixAngle(onTime, "onTime", CUSTOM_ERR_6556);
			scheduleByAngle(rpm, &turnOnEvent[valveIndex][phaseIndex],
					onTime,
					(schfunc_t) &turnOn, output, &engine->rpmCalculator);
			angle_t offTime = extra + engine->engineState.auxValveEnd;
			fixAngle(offTime, "offTime", CUSTOM_ERR_6557);
			scheduleByAngle(rpm, &turnOffEvent[valveIndex][phaseIndex],
					offTime,
					(schfunc_t) &turnOff, output, &engine->rpmCalculator);

		}
	}

#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
}
示例#2
0
/**
 * Shaft Position callback used to start or finish HIP integration
 */
static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index DECLARE_ENGINE_PARAMETER_S) {
	// this callback is invoked on interrupt thread
	engine->m.beforeHipCb = GET_TIMESTAMP();
	if (index != 0)
		return;

	int rpm = engine->rpmCalculator.rpmValue;
	if (!isValidRpm(rpm))
		return;

	int structIndex = getRevolutionCounter() % 2;
	// todo: schedule this based on closest trigger event, same as ignition works
	scheduleByAngle(rpm, &startTimer[structIndex], engineConfiguration->knockDetectionWindowStart,
			(schfunc_t) &startIntegration, NULL, &engine->rpmCalculator);
	hipLastExecutionCount = lastExecutionCount;
	scheduleByAngle(rpm, &endTimer[structIndex], engineConfiguration->knockDetectionWindowEnd,
			(schfunc_t) &endIntegration,
			NULL, &engine->rpmCalculator);
	engine->m.hipCbTime = GET_TIMESTAMP() - engine->m.beforeHipCb;
}
示例#3
0
/**
 * This trigger callback schedules the actual physical TDC callback in relation to trigger synchronization point.
 */
static void tdcMarkCallback(trigger_event_e ckpSignalType, uint32_t index0 DECLARE_ENGINE_PARAMETER_S) {
	(void) ckpSignalType;
	bool isTriggerSynchronizationPoint = index0 == 0;
	if (isTriggerSynchronizationPoint) {
		int revIndex2 = engine->rpmCalculator.getRevolutionCounter() % 2;
		int rpm = getRpm();
		// todo: use event-based scheduling, not just time-based scheduling
		scheduleByAngle(rpm, &tdcScheduler[revIndex2], tdcPosition(),
				(schfunc_t) onTdcCallback, NULL);
	}
}
示例#4
0
文件: hip9011.cpp 项目: rusefi/rusefi
/**
 * Shaft Position callback used to start or finish HIP integration
 */
static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) {
	(void)ckpEventType;
	// this callback is invoked on interrupt thread
	if (index != 0)
		return;
	engine->m.beforeHipCb = getTimeNowLowerNt();

	int rpm = GET_RPM_VALUE;
	if (!isValidRpm(rpm))
		return;

	int structIndex = getRevolutionCounter() % 2;
	// todo: schedule this based on closest trigger event, same as ignition works
	scheduleByAngle(rpm, &startTimer[structIndex], engineConfiguration->knockDetectionWindowStart,
			(schfunc_t) &startIntegration, NULL, &engine->rpmCalculator);
#if EFI_PROD_CODE
	hipLastExecutionCount = lastExecutionCount;
#endif /* EFI_PROD_CODE */
	scheduleByAngle(rpm, &endTimer[structIndex], engineConfiguration->knockDetectionWindowEnd,
			(schfunc_t) &endIntegration,
			NULL, &engine->rpmCalculator);
	engine->m.hipCbTime = getTimeNowLowerNt() - engine->m.beforeHipCb;
}
示例#5
0
static void tdcMarkCallback(ShaftEvents ckpSignalType, int index) {
	if (index == 0) {
		scheduleByAngle(&tdcScheduler, engineConfiguration->globalTriggerAngleOffset, (schfunc_t) onTdcCallback, NULL);
	}
}