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

To facilitate testing of output circuits and physical hardware such as injectors and coils on the bench or in the car. More...

#include "../inc/freeEMS.h"
#include "../inc/interrupts.h"
#include "../inc/decoderInterface.h"
#include "inc/BenchTest.h"
#include "inc/defaultSecondaryRPMISR.c"
Include dependency graph for BenchTest.c:

Go to the source code of this file.

Macros

#define DECODER_IMPLEMENTATION_C
#define DECODER_MAX_CODE_TIME   66
#define NUMBER_OF_REAL_EVENTS   1
#define NUMBER_OF_VIRTUAL_EVENTS   1

Functions

void decoderInitPreliminary ()
void perDecoderReset ()
void PrimaryRPMISR ()
 RPM ISRs, IC timer for engine position and RPM.

Variables

const unsigned short eventAngles [] = {0}
const unsigned char eventValidForCrankSync [] = {0}

Detailed Description

To facilitate testing of output circuits and physical hardware such as injectors and coils on the bench or in the car.

This "decoder" is intended to generate an output pattern that allows various testing to occur without any external stimulus. This is useful for scheduler testing, injector testing, output hardware testing, coil testing, etc. This will be the only decoder that will be usable with just a cpu and comms interface.

Todo:
TODO setup the timer registers as required.

Definition in file BenchTest.c.

Macro Definition Documentation

#define DECODER_IMPLEMENTATION_C

Definition at line 43 of file BenchTest.c.

#define DECODER_MAX_CODE_TIME   66

Definition at line 44 of file BenchTest.c.

#define NUMBER_OF_REAL_EVENTS   1

Definition at line 45 of file BenchTest.c.

Referenced by PrimaryRPMISR().

#define NUMBER_OF_VIRTUAL_EVENTS   1

Definition at line 46 of file BenchTest.c.

Function Documentation

void decoderInitPreliminary ( void  )
Todo:
TODO Perhaps use some of the space freed by shrinking all timing tables for this: /unsigned long wheelEventTimeStamps[numberOfWheelEvents]; // For logging wheel patterns as observed

Definition at line 56 of file BenchTest.c.

Referenced by initECTTimer().

{
// Configure 0 and 1 as outputs, but decouple them from the interrupts
TIOS = 0xFF; // All outputs
// Disable capture when in IC mode.
TCTL4 = 0x00; // TODO Unrequired, remove.
// Leave configured to not toggle the pin at all (0,0)
// Std behaviour, no change required
// Disable interrupts, to be enabled by a serial trigger
TIE = 0x00;
}

Here is the caller graph for this function:

void perDecoderReset ( void  )

Definition at line 71 of file BenchTest.c.

Referenced by resetToNonRunningState().

{} // Nothing special to reset for this code

Here is the caller graph for this function:

void PrimaryRPMISR ( void  )

RPM ISRs, IC timer for engine position and RPM.

There are multiple copies of this interrupt handler, each is linked with the rest of the code once such that if there are N decoder implementations and/or variants, then there are N loadable binaries produced after a full build.

For details on any specific decoder implementation, see the documentation for that specific file.

Definition at line 85 of file BenchTest.c.

{
TFLG = 0x01;
unsigned short edgeTimeStamp = TC0;
/* Reset the clock for reading timeout */
// call sched output with args
/* 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{
}
unsigned char shouldFire = 1;
// unsigned long localPeriod = 0; // mutlifire or busy wait, if doing this, check last period for some min, and if too small, shrink second to last and increase last
// unsigned short localPeriod = 0; // normal mode
// Disable the interrupt again, to be enabled by a serial trigger
TIE &= NBIT0;
return;
}
}
// TODO make this more sophisticated
// Disable the interrupt again, to be enabled by a serial trigger
TIE &= NBIT0;
return;
}
}
// Grab updated time period
// Output the sync pulse only once per "engine cycle"
// Schedule the cam pulse
}else{
}
// Generate crank strength signal
unsigned char fakeCurrentEvent = 0;
fakeCurrentEvent = KeyUserDebugs.currentEvent - (testEventsPerCycle/2);
}else{
fakeCurrentEvent = KeyUserDebugs.currentEvent;
}
// Schedule the main teeth, or not
if(fakeCurrentEvent < testNumberOfMissing){
}else{
unsigned short singleWidth = testTicksPerEvent/2;
// See if this is the last one before the gap
// Migrate this to a safeMultiply() inline function
unsigned long wideWideWidth = (unsigned long)singleWidth * (testNumberOfMissing + 1);
if(wideWideWidth < SHORTMAX){
outputEventPulseWidthsMath[0] = (unsigned short)wideWideWidth;
}else{
}
}else{
outputEventPulseWidthsMath[0] = singleWidth;
}
}
// sub modes of different patterns, use scheduler for this by setting the ADC array up and probing/triggering/touching/poking/starting/
// switch statement for selecting different const arrays of angles, use busy wait, or multiple interrupt to do larger gaps for lower rpms/coarse events
// perhaps accept the pattern in the input packet and busy wait on some "run completed" flag before returning and freeing the buffer.
// TEMP de-configure timers and leave shouldFire zeroed.
TIE &= NBIT0;
// reset all timer modes for first time around, then check for timer >= requested value, check appropriate units of time, obviously...
// TEMP de-configure timers and leave shouldFire zeroed.
TIE &= NBIT0;
// ditto
// TEMP de-configure timers and leave shouldFire zeroed.
TIE &= NBIT0;
// ditto again
// TEMP de-configure timers and leave shouldFire zeroed.
TIE &= NBIT0;
}else{
// de-configure timers and leave shouldFire zeroed.
TIE &= NBIT0;
}
if(shouldFire){
// configuration for multiple periods setup here?
// fire outputs here
unsigned char channel;
for(channel = 0;channel < 6;channel++){
schedulePortTPin(channel, timeStamp);
}
}
}
}

Variable Documentation

const unsigned short eventAngles[] = {0}

Definition at line 74 of file BenchTest.c.

Referenced by PrimaryRPMISR(), scheduleOutputs(), and SecondaryRPMISR().

const unsigned char eventValidForCrankSync[] = {0}

Definition at line 75 of file BenchTest.c.