FreeEMS  0.2.0-SNAPSHOT-282-g9efc524
Macros | Functions
injectorISR.c File Reference

Injector ISR shared code. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define INJECTOR_MAIN_ON_MASK   (BIT2<<INJECTOR_CHANNEL_NUMBER)

Functions

void InjectorXISR ()
 A template function for ECT injector/coil operation.

Detailed Description

Injector ISR shared code.

This code is identical between all 6 channels, and thus we only want one copy of it. The X in each macro will be replaced with the number that is appropriate for the channel it is being used for at the time.

Each channel performs the following actions

See Also
injectionISRs.c

Definition in file injectorISR.c.

Macro Definition Documentation

#define INJECTOR_MAIN_ON_MASK   (BIT2<<INJECTOR_CHANNEL_NUMBER)

Definition at line 60 of file injectorISR.c.

Referenced by InjectorXISR().

Function Documentation

void InjectorXISR ( )

A template function for ECT injector/coil operation.

Note, this function does not exist in the binary, only in source and the Doxygen docs. In contrast the 6 real ones only exist in binary and not the source or Doxygen docs, hence if you want to look at the source, this is the place to do so.

Todo:
TODO *maybe* instead of checking min and increasing pulse, just force it straight off if diff between start and now+const is greater than desired pulsewidth

Definition at line 69 of file injectorISR.c.

References BIT2, Counters, DEBUG_TURN_PIN_OFF, DEBUG_TURN_PIN_ON, DECODER_BENCHMARKS, ectCodeCloseRuntimes, ectCodeLatencies, ectCodeOpenRuntimes, ectMainControlRegisters, ectMainDisableMasks, ectMainEnableMasks, ectMainEndTimes, ectMainGoHighMasks, ectMainGoLowMasks, ectMainOffMasks, ectMainStartOffsetHolding, ectMainTimeRegisters, ectSwitchOnCodeTime, edgeTimeStamp, INJECTOR_CHANNEL_NUMBER, INJECTOR_MAIN_ON_MASK, Counter::injectorSelfScheduleExtensions, Counter::injectorSelfSchedules, Counter::injectorSwitchOffs, Counter::injectorSwitchOns, Counter::injectorTimerExtensionFinals, Counter::injectorTimerExtensions, NBIT2, outputEventDelayFinalPeriodHolding, outputEventDelayFinalPeriodRealtime, outputEventExtendNumberOfRepeatsHolding, outputEventExtendNumberOfRepeatsRealtime, outputEventExtendRepeatPeriodHolding, outputEventExtendRepeatPeriodRealtime, outputEventPulseWidthsHolding, outputEventPulseWidthsRealtime, PORTB, PTIT, selfSetTimer, TCNT, TFLG, TFLGOF, TIE, LongTime::timeLong, timerExtensionClock, LongTime::timeShorts, and timeStamp.

{
/* Clear the interrupt flag for this channel */
/* Record the current time as start time */
unsigned short TCNTStart = TCNT;
/* Record the edge time stamp from the IC register */
/* If rising edge triggered this */
if(PTIT & INJECTOR_MAIN_ON_MASK){ // Stuff for switch on time
/* Find out what max and min for pulse width are */
unsigned short localPulseWidth = outputEventPulseWidthsRealtime[INJECTOR_CHANNEL_NUMBER];
unsigned short localMinimumPulseWidth = ectSwitchOnCodeTime + ectCodeLatencies[INJECTOR_CHANNEL_NUMBER];
/** @todo TODO *maybe* instead of checking min and increasing pulse, just force it straight off if diff between start and now+const is greater than desired pulsewidth */
/* Ensure we dont go under minimum pulsewidth */
if(localPulseWidth < localMinimumPulseWidth){
localPulseWidth = localMinimumPulseWidth;
}/* else{ just use the value } */
/* Install the low word */
timeStamp.timeShorts[1] = edgeTimeStamp;
/* Find out what our timer value means and put it in the high word */
if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
timeStamp.timeShorts[0] = timerExtensionClock + 1;
}else{
}
// store the end time for use in the scheduler
ectMainEndTimes[INJECTOR_CHANNEL_NUMBER] = timeStamp.timeLong + localPulseWidth;
/* Set the action for compare to switch off FIRST or it might inadvertently PWM the injector during opening... */
/* Set the time to turn off again */
/* This is the point we actually want the time to, but because the code is so simple, it can't help but be a nice short time */
/* Calculate and store code run time */
}else{ // Stuff for switch off time and repeat timer time.
if(outputEventExtendNumberOfRepeatsRealtime[INJECTOR_CHANNEL_NUMBER] > 0){
}else{
// this is already set from the decoder, we're just delaying use of it: outputEventPulseWidthsRealtime[INJECTOR_CHANNEL_NUMBER]
}
}else{ // if set to off action (implicit)
/* Set the action for compare to switch on and the time to next start time, clear the self timer flag */
if(selfSetTimer & INJECTOR_MAIN_ON_MASK){
if(outputEventExtendNumberOfRepeatsHolding[INJECTOR_CHANNEL_NUMBER] > 0){
}else{
}
}else{
// Disable interrupts and actions incase the period from this end to the next start is long (saves cpu)
}
}
/* Calculate and store code run time */
}
/* Calculate and store the latency based on compare time and start time */
ectCodeLatencies[INJECTOR_CHANNEL_NUMBER] = TCNTStart - edgeTimeStamp;
}