Subaru-36-2-2-2.c File Reference

Subaru 36 minus 2 2 2. More...

#include "inc/freeEMS.h"
#include "inc/interrupts.h"
#include "inc/DecoderInterface.h"
Include dependency graph for Subaru-36-2-2-2.c:

Go to the source code of this file.

Functions

void PrimaryRPMISR (void)
void SecondaryRPMISR (void)
 Use the rising and falling edges...................

Detailed Description

Subaru 36 minus 2 2 2.

Note:
Pseudo code that does not compile with zero warnings and errors MUST be commented out.
Todo:

TODO This file contains SFA but [anon] is going to fill it up with

TODO wonderful goodness very soon ;-)

Author:
Who Ever

Definition in file Subaru-36-2-2-2.c.


Function Documentation

void PrimaryRPMISR ( void   ) 

Primary RPM ISR

Todo:
TODO Docs here!

Todo:
TODO possibly add code to make sure we are in divide mode, if not error out
Todo:
TODO fill in or remove the else
Todo:
TODO discard narrow ones! test for tooth width and tooth period the width should be based on how the hardware is setup. IE the LM1815 is adjusted to have a pulse output of a particular width. This noise filter should be matched to that width as should the hardware filter.

Definition at line 51 of file Subaru-36-2-2-2.c.

References fixedConfig1::coreSettingsA, Counters, fixedConfigs1, ISRLatencyVars, PORTJ, PRIMARY_POLARITY, ISRLatencyVar::primaryInputLatency, RuntimeVar::primaryInputLeadingRuntime, RuntimeVar::primaryInputTrailingRuntime, primaryPulsesPerSecondaryPulse, Counter::primaryTeethSeen, PTIT, RuntimeVars, TC0, TCNT, TFLG, TFLGOF, timerExtensionClock, and LongTime::timeShorts.

00052 {
00053     /* Clear the interrupt flag for this input compare channel */
00054     TFLG = 0x01;
00055 
00056     /* Save all relevant available data here */
00057     unsigned short codeStartTimeStamp = TCNT;       /* Save the current timer count */
00058     unsigned short edgeTimeStamp = TC0;             /* Save the edge time stamp */
00059     unsigned char PTITCurrentState = PTIT;          /* Save the values on port T regardless of the state of DDRT */
00060 //  unsigned short PORTS_BACurrentState = PORTS_BA; /* Save ignition output state */
00061 
00062     /* Calculate the latency in ticks */
00063     ISRLatencyVars.primaryInputLatency = codeStartTimeStamp - edgeTimeStamp;
00064 
00065     // TODO discard narrow ones! test for tooth width and tooth period
00066 
00067     /* Set up edges as per config */
00068     unsigned char risingEdge;
00069     if(fixedConfigs1.coreSettingsA & PRIMARY_POLARITY){
00070         risingEdge = PTITCurrentState & 0x01;
00071     }else{
00072         risingEdge = !(PTITCurrentState & 0x01);
00073     }
00074 
00075     if(risingEdge){
00076         /* Echo input condition on J7 */
00077         PORTJ |= 0x80;
00078 
00079         // increment crank pulses TODO this needs to be wrapped in tooth period and width checking
00080         primaryPulsesPerSecondaryPulse++;
00081 
00082         LongTime timeStamp;
00083 
00084         /* Install the low word */
00085         timeStamp.timeShorts[1] = edgeTimeStamp;
00086         /* Find out what our timer value means and put it in the high word */
00087         if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
00088             timeStamp.timeShorts[0] = timerExtensionClock + 1;
00089         }else{
00090             timeStamp.timeShorts[0] = timerExtensionClock;
00091         }
00092         RuntimeVars.primaryInputLeadingRuntime = TCNT - codeStartTimeStamp;
00093     }else{
00094         PORTJ &= 0x7F;
00095         RuntimeVars.primaryInputTrailingRuntime = TCNT - codeStartTimeStamp;
00096     }
00097 
00098     Counters.primaryTeethSeen++;
00099 }

void SecondaryRPMISR ( void   ) 

Use the rising and falling edges...................

Secondary RPM ISR

Todo:
TODO Docs here!

Todo:
TODO fill in or remove the else
Todo:
TODO discard narrow ones! test for tooth width and tooth period the width should be based on how the hardware is setup. IE the LM1815 is adjusted to have a pulse output of a particular width. This noise filter should be matched to that width as should the hardware filter.
Todo:
TODO discard narrow ones! test for tooth width and tooth period the width should be based on how the hardware is setup. IE the LM1815 is adjusted to have a pulse output of a particular width. This noise filter should be matched to that width as should the hardware filter.

Definition at line 106 of file Subaru-36-2-2-2.c.

References fixedConfig1::coreSettingsA, Counters, fixedConfigs1, ISRLatencyVars, PORTJ, PTIT, RuntimeVars, SECONDARY_POLARITY, ISRLatencyVar::secondaryInputLatency, RuntimeVar::secondaryInputLeadingRuntime, RuntimeVar::secondaryInputTrailingRuntime, Counter::secondaryTeethSeen, TC1, TCNT, TFLG, TFLGOF, timerExtensionClock, and LongTime::timeShorts.

00107 {
00108     /* Clear the interrupt flag for this input compare channel */
00109     TFLG = 0x02;
00110 
00111     /* Save all relevant available data here */
00112     unsigned short codeStartTimeStamp = TCNT;       /* Save the current timer count */
00113     unsigned short edgeTimeStamp = TC1;             /* Save the timestamp */
00114     unsigned char PTITCurrentState = PTIT;          /* Save the values on port T regardless of the state of DDRT */
00115 //  unsigned short PORTS_BACurrentState = PORTS_BA; /* Save ignition output state */
00116 
00117     /* Calculate the latency in ticks */
00118     ISRLatencyVars.secondaryInputLatency = codeStartTimeStamp - edgeTimeStamp;
00119 
00120     // TODO discard narrow ones! test for tooth width and tooth period
00121 
00122     /* Set up edges as per config */
00123     unsigned char risingEdge;
00124     if(fixedConfigs1.coreSettingsA & SECONDARY_POLARITY){
00125         risingEdge = PTITCurrentState & 0x02;
00126     }else{
00127         risingEdge = !(PTITCurrentState & 0x02);
00128     }
00129 
00130     if(risingEdge){
00131         // echo input condition
00132         PORTJ |= 0x40;
00133 
00134         LongTime timeStamp;
00135 
00136         /* Install the low word */
00137         timeStamp.timeShorts[1] = edgeTimeStamp;
00138         /* Find out what our timer value means and put it in the high word */
00139         if(TFLGOF && !(edgeTimeStamp & 0x8000)){ /* see 10.3.5 paragraph 4 of 68hc11 ref manual for details */
00140             timeStamp.timeShorts[0] = timerExtensionClock + 1;
00141         }else{
00142             timeStamp.timeShorts[0] = timerExtensionClock;
00143         }
00144 
00145         RuntimeVars.secondaryInputLeadingRuntime = TCNT - codeStartTimeStamp;
00146     }else{
00147         PORTJ &= 0xBF;
00148         RuntimeVars.secondaryInputTrailingRuntime = TCNT - codeStartTimeStamp;
00149     }
00150 
00151     Counters.secondaryTeethSeen++;
00152 }

Generated on Sat Oct 16 21:29:21 2010 for FreeEMS by  doxygen 1.6.3