Save 600+ bytes RAM (step 5 of 9) - De-duplicate setSchedule functions (#1111)
* initialiseSchedulers: factor out shared code. * Proxy setFuelSchedule\d through generic setFuelSchedule() function * Directly call setFuelSchedule * Simplify unit tests * Proxy setIgnitionSchedule\d through generic setIgnitionSchedule() function * Directly call setIgnitionSchedule * Simplify unit tests * Optimize by partially inlining the set[Fuel|Ignition]Schedule funcs * Use the embedded schedule compare & counter members instead of using hardcoded individual channel macros. * Unit test adjustCrankAngle
This commit is contained in:
parent
1c9122ded3
commit
963f6317ba
|
@ -392,57 +392,48 @@ For each ignition channel, a check is made whether we're at the relevant tooth a
|
|||
Only if both these conditions are met will the schedule be updated with the latest timing information.
|
||||
If it's the correct tooth, but the schedule is not yet started, calculate and an end compare value (This situation occurs when both the start and end of the ignition pulse happen after the end tooth, but before the next tooth)
|
||||
*/
|
||||
#define MIN_CYCLES_FOR_ENDCOMPARE 6
|
||||
static inline void checkPerToothTiming(int16_t crankAngle, uint16_t currentTooth)
|
||||
{
|
||||
if ( (fixedCrankingOverride == 0) && (currentStatus.RPM > 0) )
|
||||
{
|
||||
if ( (currentTooth == ignition1EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule1.Status == RUNNING) ) { SET_COMPARE(IGN1_COMPARE, IGN1_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition1EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule1.endCompare = IGN1_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition1EndAngle - crankAngle) ) ) ); ignitionSchedule1.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule1, ignition1EndAngle, crankAngle);
|
||||
}
|
||||
else if ( (currentTooth == ignition2EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule2.Status == RUNNING) ) { SET_COMPARE(IGN2_COMPARE, IGN2_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition2EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule2.endCompare = IGN2_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition2EndAngle - crankAngle) ) ) ); ignitionSchedule2.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule2, ignition2EndAngle, crankAngle);
|
||||
}
|
||||
else if ( (currentTooth == ignition3EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule3.Status == RUNNING) ) { SET_COMPARE(IGN3_COMPARE, IGN3_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition3EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule3.endCompare = IGN3_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition3EndAngle - crankAngle) ) ) ); ignitionSchedule3.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule3, ignition3EndAngle, crankAngle);
|
||||
}
|
||||
else if ( (currentTooth == ignition4EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule4.Status == RUNNING) ) { SET_COMPARE(IGN4_COMPARE, IGN4_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition4EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule4.endCompare = IGN4_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition4EndAngle - crankAngle) ) ) ); ignitionSchedule4.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule4, ignition4EndAngle, crankAngle);
|
||||
}
|
||||
#if IGN_CHANNELS >= 5
|
||||
else if ( (currentTooth == ignition5EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule5.Status == RUNNING) ) { SET_COMPARE(IGN5_COMPARE, IGN5_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition5EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule5.endCompare = IGN5_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition5EndAngle - crankAngle) ) ) ); ignitionSchedule5.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule5, ignition5EndAngle, crankAngle);
|
||||
}
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 6
|
||||
else if ( (currentTooth == ignition6EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule6.Status == RUNNING) ) { SET_COMPARE(IGN6_COMPARE, IGN6_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition6EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule6.endCompare = IGN6_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition6EndAngle - crankAngle) ) ) ); ignitionSchedule6.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule6, ignition6EndAngle, crankAngle);
|
||||
}
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 7
|
||||
else if ( (currentTooth == ignition7EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule7.Status == RUNNING) ) { SET_COMPARE(IGN7_COMPARE, IGN7_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition7EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule7.endCompare = IGN7_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition7EndAngle - crankAngle) ) ) ); ignitionSchedule7.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule7, ignition7EndAngle, crankAngle);
|
||||
}
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 8
|
||||
else if ( (currentTooth == ignition8EndTooth) )
|
||||
{
|
||||
if( (ignitionSchedule8.Status == RUNNING) ) { SET_COMPARE(IGN8_COMPARE, IGN8_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition8EndAngle - crankAngle) ) ) ) ); }
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) { ignitionSchedule8.endCompare = IGN8_COUNTER + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (ignition8EndAngle - crankAngle) ) ) ); ignitionSchedule8.endScheduleSetByDecoder = true; }
|
||||
adjustCrankAngle(ignitionSchedule8, ignition8EndAngle, crankAngle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "scheduler.h"
|
||||
#include "crankMaths.h"
|
||||
#include "maths.h"
|
||||
#include "timers.h"
|
||||
|
||||
static inline uint16_t calculateInjectorStartAngle(uint16_t pwDegrees, int16_t injChannelDegrees, uint16_t injAngle)
|
||||
{
|
||||
|
@ -101,3 +103,15 @@ static inline uint32_t calculateIgnitionTimeout(const IgnitionSchedule &schedule
|
|||
}
|
||||
return _calculateIgnitionTimeout(schedule, _adjustToIgnChannel(startAngle, channelIgnDegrees), _adjustToIgnChannel(crankAngle, channelIgnDegrees));
|
||||
}
|
||||
|
||||
#define MIN_CYCLES_FOR_ENDCOMPARE 6
|
||||
|
||||
inline void adjustCrankAngle(IgnitionSchedule &schedule, int endAngle, int crankAngle) {
|
||||
if( (schedule.Status == RUNNING) ) {
|
||||
SET_COMPARE(schedule.compare, schedule.counter + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (endAngle - crankAngle) ) ) ) );
|
||||
}
|
||||
else if(currentStatus.startRevolutions > MIN_CYCLES_FOR_ENDCOMPARE) {
|
||||
schedule.endCompare = schedule.counter + uS_TO_TIMER_COMPARE( angleToTimeMicroSecPerDegree( ignitionLimits( (endAngle - crankAngle) ) ) );
|
||||
schedule.endScheduleSetByDecoder = true;
|
||||
}
|
||||
}
|
|
@ -64,59 +64,53 @@ IgnitionSchedule ignitionSchedule7(IGN7_COUNTER, IGN7_COMPARE, IGN7_TIMER_DISABL
|
|||
IgnitionSchedule ignitionSchedule8(IGN8_COUNTER, IGN8_COMPARE, IGN8_TIMER_DISABLE, IGN8_TIMER_ENABLE);
|
||||
#endif
|
||||
|
||||
static void reset(FuelSchedule &schedule)
|
||||
{
|
||||
schedule.Status = OFF;
|
||||
schedule.pTimerEnable();
|
||||
}
|
||||
|
||||
static void reset(IgnitionSchedule &schedule)
|
||||
{
|
||||
schedule.Status = OFF;
|
||||
schedule.pTimerEnable();
|
||||
}
|
||||
|
||||
void initialiseSchedulers()
|
||||
{
|
||||
fuelSchedule1.Status = OFF;
|
||||
fuelSchedule2.Status = OFF;
|
||||
fuelSchedule3.Status = OFF;
|
||||
fuelSchedule4.Status = OFF;
|
||||
reset(fuelSchedule1);
|
||||
reset(fuelSchedule2);
|
||||
reset(fuelSchedule3);
|
||||
reset(fuelSchedule4);
|
||||
#if INJ_CHANNELS >= 5
|
||||
fuelSchedule5.Status = OFF;
|
||||
reset(fuelSchedule5);
|
||||
#endif
|
||||
#if INJ_CHANNELS >= 6
|
||||
fuelSchedule6.Status = OFF;
|
||||
reset(fuelSchedule6);
|
||||
#endif
|
||||
#if INJ_CHANNELS >= 7
|
||||
fuelSchedule7.Status = OFF;
|
||||
reset(fuelSchedule7);
|
||||
#endif
|
||||
#if INJ_CHANNELS >= 8
|
||||
fuelSchedule8.Status = OFF;
|
||||
reset(fuelSchedule8);
|
||||
#endif
|
||||
|
||||
ignitionSchedule1.Status = OFF;
|
||||
IGN1_TIMER_ENABLE();
|
||||
ignitionSchedule2.Status = OFF;
|
||||
IGN2_TIMER_ENABLE();
|
||||
ignitionSchedule3.Status = OFF;
|
||||
IGN3_TIMER_ENABLE();
|
||||
ignitionSchedule4.Status = OFF;
|
||||
IGN4_TIMER_ENABLE();
|
||||
reset(ignitionSchedule1);
|
||||
reset(ignitionSchedule2);
|
||||
reset(ignitionSchedule3);
|
||||
reset(ignitionSchedule4);
|
||||
reset(ignitionSchedule5);
|
||||
#if (IGN_CHANNELS >= 5)
|
||||
ignitionSchedule5.Status = OFF;
|
||||
IGN5_TIMER_ENABLE();
|
||||
reset(ignitionSchedule5);
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 6
|
||||
ignitionSchedule6.Status = OFF;
|
||||
IGN6_TIMER_ENABLE();
|
||||
reset(ignitionSchedule6);
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 7
|
||||
ignitionSchedule7.Status = OFF;
|
||||
IGN7_TIMER_ENABLE();
|
||||
reset(ignitionSchedule7);
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 8
|
||||
ignitionSchedule8.Status = OFF;
|
||||
IGN8_TIMER_ENABLE();
|
||||
#endif
|
||||
|
||||
FUEL1_TIMER_ENABLE();
|
||||
FUEL2_TIMER_ENABLE();
|
||||
FUEL3_TIMER_ENABLE();
|
||||
FUEL4_TIMER_ENABLE();
|
||||
#if (INJ_CHANNELS >= 5)
|
||||
FUEL5_TIMER_ENABLE();
|
||||
FUEL6_TIMER_ENABLE();
|
||||
FUEL7_TIMER_ENABLE();
|
||||
FUEL8_TIMER_ENABLE();
|
||||
reset(ignitionSchedule8);
|
||||
#endif
|
||||
|
||||
fuelSchedule1.pStartFunction = nullCallback;
|
||||
|
@ -216,306 +210,32 @@ void initialiseSchedulers()
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
These 8 function turn a schedule on, provides the time to start and the duration and gives it callback functions.
|
||||
All 8 functions operate the same, just on different schedules
|
||||
Args:
|
||||
startCallback: The function to be called once the timeout is reached
|
||||
timeout: The number of uS in the future that the startCallback should be triggered
|
||||
duration: The number of uS after startCallback is called before endCallback is called
|
||||
endCallback: This function is called once the duration time has been reached
|
||||
*/
|
||||
|
||||
void setFuelSchedule1(unsigned long timeout, unsigned long duration) //Uses timer 3 compare A
|
||||
void _setFuelScheduleRunning(FuelSchedule &schedule, unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
//if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule1.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
if ((timeout+duration) < MAX_TIMER_PERIOD)
|
||||
{
|
||||
fuelSchedule1.duration = duration;
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule1.startCompare = FUEL1_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule1.endCompare = fuelSchedule1.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule1.Status = PENDING; //Turn this schedule on
|
||||
SET_COMPARE(FUEL1_COMPARE, fuelSchedule1.startCompare);
|
||||
interrupts();
|
||||
FUEL1_TIMER_ENABLE();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if( (timeout+duration) < MAX_TIMER_PERIOD )
|
||||
{
|
||||
noInterrupts();
|
||||
fuelSchedule1.nextStartCompare = FUEL1_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule1.nextEndCompare = fuelSchedule1.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule1.duration = duration;
|
||||
fuelSchedule1.hasNextSchedule = true;
|
||||
interrupts();
|
||||
}
|
||||
} //Schedule is RUNNING
|
||||
} //Timeout less than threshold
|
||||
}
|
||||
|
||||
void setFuelSchedule2(unsigned long timeout, unsigned long duration) //Uses timer 3 compare B
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule2.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
fuelSchedule2.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
schedule.duration = duration;
|
||||
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule2.startCompare = FUEL2_COUNTER + timeout_timer_compare;
|
||||
fuelSchedule2.endCompare = fuelSchedule2.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(FUEL2_COMPARE, fuelSchedule2.startCompare); //Use the B compare unit of timer 3
|
||||
fuelSchedule2.Status = PENDING; //Turn this schedule on
|
||||
schedule.startCompare = schedule.counter + uS_TO_TIMER_COMPARE(timeout);
|
||||
schedule.endCompare = schedule.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(schedule.compare, schedule.startCompare); //Use the B compare unit of timer 3
|
||||
schedule.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
FUEL2_TIMER_ENABLE();
|
||||
schedule.pTimerEnable();
|
||||
}
|
||||
else
|
||||
|
||||
void _setFuelScheduleNext(FuelSchedule &schedule, unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
fuelSchedule2.nextStartCompare = FUEL2_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule2.nextEndCompare = fuelSchedule2.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule2.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
schedule.nextStartCompare = schedule.counter + uS_TO_TIMER_COMPARE(timeout);
|
||||
schedule.nextEndCompare = schedule.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
schedule.hasNextSchedule = true;
|
||||
}
|
||||
|
||||
void setFuelSchedule3(unsigned long timeout, unsigned long duration) //Uses timer 3 compare C
|
||||
void _setIgnitionScheduleRunning(IgnitionSchedule &schedule, unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule3.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
fuelSchedule3.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule3.startCompare = FUEL3_COUNTER + timeout_timer_compare;
|
||||
fuelSchedule3.endCompare = fuelSchedule3.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(FUEL3_COMPARE, fuelSchedule3.startCompare); //Use the C compare unit of timer 3
|
||||
fuelSchedule3.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
FUEL3_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
fuelSchedule3.nextStartCompare = FUEL3_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule3.nextEndCompare = fuelSchedule3.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule3.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setFuelSchedule4(unsigned long timeout, unsigned long duration) //Uses timer 4 compare B
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule4.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
fuelSchedule4.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule4.startCompare = FUEL4_COUNTER + timeout_timer_compare;
|
||||
fuelSchedule4.endCompare = fuelSchedule4.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(FUEL4_COMPARE, fuelSchedule4.startCompare); //Use the B compare unit of timer 4
|
||||
fuelSchedule4.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
FUEL4_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
fuelSchedule4.nextStartCompare = FUEL4_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule4.nextEndCompare = fuelSchedule4.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule4.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if INJ_CHANNELS >= 5
|
||||
void setFuelSchedule5(unsigned long timeout, unsigned long duration) //Uses timer 4 compare C
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule5.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
fuelSchedule5.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule5.startCompare = FUEL5_COUNTER + timeout_timer_compare;
|
||||
fuelSchedule5.endCompare = fuelSchedule5.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(FUEL5_COMPARE, fuelSchedule5.startCompare); //Use the C compare unit of timer 4
|
||||
fuelSchedule5.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
FUEL5_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
fuelSchedule5.nextStartCompare = FUEL5_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule5.nextEndCompare = fuelSchedule5.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule5.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 6
|
||||
void setFuelSchedule6(unsigned long timeout, unsigned long duration) //Uses timer 4 compare A
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule6.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
fuelSchedule6.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule6.startCompare = FUEL6_COUNTER + timeout_timer_compare;
|
||||
fuelSchedule6.endCompare = fuelSchedule6.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(FUEL6_COMPARE, fuelSchedule6.startCompare); //Use the A compare unit of timer 4
|
||||
fuelSchedule6.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
FUEL6_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
fuelSchedule6.nextStartCompare = FUEL6_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule6.nextEndCompare = fuelSchedule6.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule6.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 7
|
||||
void setFuelSchedule7(unsigned long timeout, unsigned long duration) //Uses timer 5 compare C
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule7.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
fuelSchedule7.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule7.startCompare = FUEL7_COUNTER + timeout_timer_compare;
|
||||
fuelSchedule7.endCompare = fuelSchedule7.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(FUEL7_COMPARE, fuelSchedule7.startCompare); //Use the C compare unit of timer 5
|
||||
fuelSchedule7.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
FUEL7_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
fuelSchedule7.nextStartCompare = FUEL7_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule7.nextEndCompare = fuelSchedule7.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule7.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 8
|
||||
void setFuelSchedule8(unsigned long timeout, unsigned long duration) //Uses timer 5 compare B
|
||||
{
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
if(fuelSchedule8.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
fuelSchedule8.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
//The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupt fires before the state is fully set
|
||||
noInterrupts();
|
||||
fuelSchedule8.startCompare = FUEL8_COUNTER + timeout_timer_compare;
|
||||
fuelSchedule8.endCompare = fuelSchedule8.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
SET_COMPARE(FUEL8_COMPARE, fuelSchedule8.startCompare); //Use the B compare unit of timer 5
|
||||
fuelSchedule8.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
FUEL8_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
fuelSchedule8.nextStartCompare = FUEL8_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
fuelSchedule8.nextEndCompare = fuelSchedule8.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
fuelSchedule8.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//Ignition schedulers use Timer 5
|
||||
void setIgnitionSchedule1(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule1.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule1.duration = duration;
|
||||
schedule.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
|
@ -523,26 +243,23 @@ void setIgnitionSchedule1(unsigned long timeout, unsigned long duration)
|
|||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule1.startCompare = IGN1_COUNTER + timeout_timer_compare; //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4)
|
||||
if(ignitionSchedule1.endScheduleSetByDecoder == false) { ignitionSchedule1.endCompare = ignitionSchedule1.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN1_COMPARE, ignitionSchedule1.startCompare);
|
||||
ignitionSchedule1.Status = PENDING; //Turn this schedule on
|
||||
schedule.startCompare = schedule.counter + timeout_timer_compare; //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4)
|
||||
if(schedule.endScheduleSetByDecoder == false) { schedule.endCompare = schedule.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(schedule.compare, schedule.startCompare);
|
||||
schedule.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN1_TIMER_ENABLE();
|
||||
schedule.pTimerEnable();
|
||||
}
|
||||
else
|
||||
|
||||
void _setIgnitionScheduleNext(IgnitionSchedule &schedule, unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule1.nextStartCompare = IGN1_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule1.nextEndCompare = ignitionSchedule1.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule1.hasNextSchedule = true;
|
||||
schedule.nextStartCompare = schedule.counter + uS_TO_TIMER_COMPARE(timeout);
|
||||
schedule.nextEndCompare = schedule.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
schedule.hasNextSchedule = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void refreshIgnitionSchedule1(unsigned long timeToEnd)
|
||||
{
|
||||
|
@ -557,233 +274,6 @@ void refreshIgnitionSchedule1(unsigned long timeToEnd)
|
|||
}
|
||||
}
|
||||
|
||||
void setIgnitionSchedule2(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule2.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule2.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule2.startCompare = IGN2_COUNTER + timeout_timer_compare; //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4)
|
||||
if(ignitionSchedule2.endScheduleSetByDecoder == false) { ignitionSchedule2.endCompare = ignitionSchedule2.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN2_COMPARE, ignitionSchedule2.startCompare);
|
||||
ignitionSchedule2.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN2_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule2.nextStartCompare = IGN2_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule2.nextEndCompare = ignitionSchedule2.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule2.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
void setIgnitionSchedule3(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule3.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule3.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule3.startCompare = IGN3_COUNTER + timeout_timer_compare; //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4)
|
||||
if(ignitionSchedule3.endScheduleSetByDecoder == false) { ignitionSchedule3.endCompare = ignitionSchedule3.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN3_COMPARE, ignitionSchedule3.startCompare);
|
||||
ignitionSchedule3.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN3_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule3.nextStartCompare = IGN3_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule3.nextEndCompare = ignitionSchedule3.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule3.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
void setIgnitionSchedule4(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule4.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule4.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule4.startCompare = IGN4_COUNTER + timeout_timer_compare;
|
||||
if(ignitionSchedule4.endScheduleSetByDecoder == false) { ignitionSchedule4.endCompare = ignitionSchedule4.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN4_COMPARE, ignitionSchedule4.startCompare);
|
||||
ignitionSchedule4.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN4_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule4.nextStartCompare = IGN4_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule4.nextEndCompare = ignitionSchedule4.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule4.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
void setIgnitionSchedule5(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule5.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule5.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule5.startCompare = IGN5_COUNTER + timeout_timer_compare;
|
||||
if(ignitionSchedule5.endScheduleSetByDecoder == false) { ignitionSchedule5.endCompare = ignitionSchedule5.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN5_COMPARE, ignitionSchedule5.startCompare);
|
||||
ignitionSchedule5.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN5_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule5.nextStartCompare = IGN5_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule5.nextEndCompare = ignitionSchedule5.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule5.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if IGN_CHANNELS >= 6
|
||||
void setIgnitionSchedule6(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule6.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule6.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule6.startCompare = IGN6_COUNTER + timeout_timer_compare;
|
||||
if(ignitionSchedule6.endScheduleSetByDecoder == false) { ignitionSchedule6.endCompare = ignitionSchedule6.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN6_COMPARE, ignitionSchedule6.startCompare);
|
||||
ignitionSchedule6.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN6_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule6.nextStartCompare = IGN6_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule6.nextEndCompare = ignitionSchedule6.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule6.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IGN_CHANNELS >= 7
|
||||
void setIgnitionSchedule7(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule7.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule7.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule7.startCompare = IGN7_COUNTER + timeout_timer_compare;
|
||||
if(ignitionSchedule7.endScheduleSetByDecoder == false) { ignitionSchedule7.endCompare = ignitionSchedule7.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN7_COMPARE, ignitionSchedule7.startCompare);
|
||||
ignitionSchedule7.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN7_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule7.nextStartCompare = IGN7_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule7.nextEndCompare = ignitionSchedule7.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule7.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IGN_CHANNELS >= 8
|
||||
void setIgnitionSchedule8(unsigned long timeout, unsigned long duration)
|
||||
{
|
||||
if(ignitionSchedule8.Status != RUNNING) //Check that we're not already part way through a schedule
|
||||
{
|
||||
ignitionSchedule8.duration = duration;
|
||||
|
||||
//Need to check that the timeout doesn't exceed the overflow
|
||||
COMPARE_TYPE timeout_timer_compare;
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout_timer_compare = uS_TO_TIMER_COMPARE( (MAX_TIMER_PERIOD - 1) ); } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking.
|
||||
else { timeout_timer_compare = uS_TO_TIMER_COMPARE(timeout); } //Normal case
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule8.startCompare = IGN8_COUNTER + timeout_timer_compare;
|
||||
if(ignitionSchedule8.endScheduleSetByDecoder == false) { ignitionSchedule8.endCompare = ignitionSchedule8.startCompare + uS_TO_TIMER_COMPARE(duration); } //The .endCompare value is also set by the per tooth timing in decoders.ino. The check here is so that it's not getting overridden.
|
||||
SET_COMPARE(IGN8_COMPARE, ignitionSchedule8.startCompare);
|
||||
ignitionSchedule8.Status = PENDING; //Turn this schedule on
|
||||
interrupts();
|
||||
IGN8_TIMER_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the schedule is already running, we can set the next schedule so it is ready to go
|
||||
//This is required in cases of high rpm and high DC where there otherwise would not be enough time to set the schedule
|
||||
if (timeout < MAX_TIMER_PERIOD)
|
||||
{
|
||||
ignitionSchedule8.nextStartCompare = IGN8_COUNTER + uS_TO_TIMER_COMPARE(timeout);
|
||||
ignitionSchedule8.nextEndCompare = ignitionSchedule8.nextStartCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
ignitionSchedule8.hasNextSchedule = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Perform the injector priming pulses.
|
||||
* Set these to run at an arbitrary time in the future (100us).
|
||||
* The prime pulse value is in ms*10, so need to multiple by 100 to get to uS
|
||||
|
@ -794,27 +284,27 @@ extern void beginInjectorPriming(void)
|
|||
if( (primingValue > 0) && (currentStatus.TPS < configPage4.floodClear) )
|
||||
{
|
||||
primingValue = primingValue * 100 * 5; //to achieve long enough priming pulses, the values in tuner studio are divided by 0.5 instead of 0.1, so multiplier of 5 is required.
|
||||
if ( maxInjOutputs >= 1 ) { setFuelSchedule1(100, primingValue); }
|
||||
if ( maxInjOutputs >= 1 ) { setFuelSchedule(fuelSchedule1, 100, primingValue); }
|
||||
#if (INJ_CHANNELS >= 2)
|
||||
if ( maxInjOutputs >= 2 ) { setFuelSchedule2(100, primingValue); }
|
||||
if ( maxInjOutputs >= 2 ) { setFuelSchedule(fuelSchedule2, 100, primingValue); }
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 3)
|
||||
if ( maxInjOutputs >= 3 ) { setFuelSchedule3(100, primingValue); }
|
||||
if ( maxInjOutputs >= 3 ) { setFuelSchedule(fuelSchedule3, 100, primingValue); }
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 4)
|
||||
if ( maxInjOutputs >= 4 ) { setFuelSchedule4(100, primingValue); }
|
||||
if ( maxInjOutputs >= 4 ) { setFuelSchedule(fuelSchedule4, 100, primingValue); }
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 5)
|
||||
if ( maxInjOutputs >= 5 ) { setFuelSchedule5(100, primingValue); }
|
||||
if ( maxInjOutputs >= 5 ) { setFuelSchedule(fuelSchedule5, 100, primingValue); }
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 6)
|
||||
if ( maxInjOutputs >= 6 ) { setFuelSchedule6(100, primingValue); }
|
||||
if ( maxInjOutputs >= 6 ) { setFuelSchedule(fuelSchedule6, 100, primingValue); }
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 7)
|
||||
if ( maxInjOutputs >= 7 ) { setFuelSchedule7(100, primingValue); }
|
||||
if ( maxInjOutputs >= 7) { setFuelSchedule(fuelSchedule7, 100, primingValue); }
|
||||
#endif
|
||||
#if (INJ_CHANNELS >= 8)
|
||||
if ( maxInjOutputs >= 8 ) { setFuelSchedule8(100, primingValue); }
|
||||
if ( maxInjOutputs >= 8 ) { setFuelSchedule(fuelSchedule8, 100, primingValue); }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,38 +53,6 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd
|
|||
void initialiseSchedulers(void);
|
||||
void beginInjectorPriming(void);
|
||||
|
||||
void setFuelSchedule1(unsigned long timeout, unsigned long duration);
|
||||
void setFuelSchedule2(unsigned long timeout, unsigned long duration);
|
||||
void setFuelSchedule3(unsigned long timeout, unsigned long duration);
|
||||
void setFuelSchedule4(unsigned long timeout, unsigned long duration);
|
||||
#if INJ_CHANNELS >= 5
|
||||
void setFuelSchedule5(unsigned long timeout, unsigned long duration);
|
||||
#endif
|
||||
#if INJ_CHANNELS >= 6
|
||||
void setFuelSchedule6(unsigned long timeout, unsigned long duration);
|
||||
#endif
|
||||
#if INJ_CHANNELS >= 7
|
||||
void setFuelSchedule7(unsigned long timeout, unsigned long duration);
|
||||
#endif
|
||||
#if INJ_CHANNELS >= 8
|
||||
void setFuelSchedule8(unsigned long timeout, unsigned long duration);
|
||||
#endif
|
||||
|
||||
void setIgnitionSchedule1(unsigned long timeout, unsigned long duration);
|
||||
void setIgnitionSchedule2(unsigned long timeout, unsigned long duration);
|
||||
void setIgnitionSchedule3(unsigned long timeout, unsigned long duration);
|
||||
void setIgnitionSchedule4(unsigned long timeout, unsigned long duration);
|
||||
void setIgnitionSchedule5(unsigned long timeout, unsigned long duration);
|
||||
#if IGN_CHANNELS >= 6
|
||||
void setIgnitionSchedule6(unsigned long timeout, unsigned long duration);
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 7
|
||||
void setIgnitionSchedule7(unsigned long timeout, unsigned long duration);
|
||||
#endif
|
||||
#if IGN_CHANNELS >= 8
|
||||
void setIgnitionSchedule8(unsigned long timeout, unsigned long duration);
|
||||
#endif
|
||||
|
||||
void disablePendingFuelSchedule(byte channel);
|
||||
void disablePendingIgnSchedule(byte channel);
|
||||
|
||||
|
@ -179,6 +147,18 @@ struct IgnitionSchedule {
|
|||
void (&pTimerEnable)(); // Reference to the timer enable function
|
||||
};
|
||||
|
||||
void _setIgnitionScheduleRunning(IgnitionSchedule &schedule, unsigned long timeout, unsigned long duration);
|
||||
void _setIgnitionScheduleNext(IgnitionSchedule &schedule, unsigned long timeout, unsigned long duration);
|
||||
|
||||
inline __attribute__((always_inline)) void setIgnitionSchedule(IgnitionSchedule &schedule, unsigned long timeout, unsigned long duration) {
|
||||
if(schedule.Status != RUNNING) { //Check that we're not already part way through a schedule
|
||||
_setIgnitionScheduleRunning(schedule, timeout, duration);
|
||||
}
|
||||
// Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
else if(timeout < MAX_TIMER_PERIOD){
|
||||
_setIgnitionScheduleNext(schedule, timeout, duration);
|
||||
}
|
||||
}
|
||||
|
||||
/** Fuel injection schedule.
|
||||
* Fuel schedules don't use the callback pointers, or the startTime/endScheduleSetByDecoder variables.
|
||||
|
@ -217,6 +197,21 @@ struct FuelSchedule {
|
|||
void (&pTimerEnable)(); // Reference to the timer enable function
|
||||
};
|
||||
|
||||
void _setFuelScheduleRunning(FuelSchedule &schedule, unsigned long timeout, unsigned long duration);
|
||||
void _setFuelScheduleNext(FuelSchedule &schedule, unsigned long timeout, unsigned long duration);
|
||||
|
||||
inline __attribute__((always_inline)) void setFuelSchedule(FuelSchedule &schedule, unsigned long timeout, unsigned long duration) {
|
||||
//Check whether timeout exceeds the maximum future time. This can potentially occur on sequential setups when below ~115rpm
|
||||
if(timeout < MAX_TIMER_PERIOD) {
|
||||
if(schedule.Status != RUNNING) { //Check that we're not already part way through a schedule
|
||||
_setFuelScheduleRunning(schedule, timeout, duration);
|
||||
}
|
||||
else {
|
||||
_setFuelScheduleNext(schedule, timeout, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern FuelSchedule fuelSchedule1;
|
||||
extern FuelSchedule fuelSchedule2;
|
||||
extern FuelSchedule fuelSchedule3;
|
||||
|
|
|
@ -889,7 +889,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule1, channel1InjDegrees, injector1StartAngle, crankAngle);
|
||||
if (timeOut>0U)
|
||||
{
|
||||
setFuelSchedule1(
|
||||
setFuelSchedule(fuelSchedule1,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW1
|
||||
);
|
||||
|
@ -913,7 +913,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule2, channel2InjDegrees, injector2StartAngle, crankAngle);
|
||||
if ( timeOut>0U )
|
||||
{
|
||||
setFuelSchedule2(
|
||||
setFuelSchedule(fuelSchedule2,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW2
|
||||
);
|
||||
|
@ -927,7 +927,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule3, channel3InjDegrees, injector3StartAngle, crankAngle);
|
||||
if ( timeOut>0U )
|
||||
{
|
||||
setFuelSchedule3(
|
||||
setFuelSchedule(fuelSchedule3,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW3
|
||||
);
|
||||
|
@ -941,7 +941,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule4, channel4InjDegrees, injector4StartAngle, crankAngle);
|
||||
if ( timeOut>0U )
|
||||
{
|
||||
setFuelSchedule4(
|
||||
setFuelSchedule(fuelSchedule4,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW4
|
||||
);
|
||||
|
@ -955,7 +955,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule5, channel5InjDegrees, injector5StartAngle, crankAngle);
|
||||
if ( timeOut>0U )
|
||||
{
|
||||
setFuelSchedule5(
|
||||
setFuelSchedule(fuelSchedule5,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW5
|
||||
);
|
||||
|
@ -969,7 +969,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule6, channel6InjDegrees, injector6StartAngle, crankAngle);
|
||||
if ( timeOut>0U )
|
||||
{
|
||||
setFuelSchedule6(
|
||||
setFuelSchedule(fuelSchedule6,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW6
|
||||
);
|
||||
|
@ -983,7 +983,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule7, channel7InjDegrees, injector7StartAngle, crankAngle);
|
||||
if ( timeOut>0U )
|
||||
{
|
||||
setFuelSchedule7(
|
||||
setFuelSchedule(fuelSchedule7,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW7
|
||||
);
|
||||
|
@ -997,7 +997,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateInjectorTimeout(fuelSchedule8, channel8InjDegrees, injector8StartAngle, crankAngle);
|
||||
if ( timeOut>0U )
|
||||
{
|
||||
setFuelSchedule8(
|
||||
setFuelSchedule(fuelSchedule8,
|
||||
timeOut,
|
||||
(unsigned long)currentStatus.PW8
|
||||
);
|
||||
|
@ -1047,7 +1047,7 @@ void loop(void)
|
|||
uint32_t timeOut = calculateIgnitionTimeout(ignitionSchedule1, ignition1StartAngle, channel1IgnDegrees, crankAngle);
|
||||
if ( (timeOut > 0U) && (BIT_CHECK(ignitionChannelsOn, IGN1_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule1(timeOut,
|
||||
setIgnitionSchedule(ignitionSchedule1, timeOut,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
#endif
|
||||
|
@ -1079,7 +1079,7 @@ void loop(void)
|
|||
|
||||
if ( (ignition2StartTime > 0) && (BIT_CHECK(ignitionChannelsOn, IGN2_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule2(ignition2StartTime,
|
||||
setIgnitionSchedule(ignitionSchedule2, ignition2StartTime,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
}
|
||||
|
@ -1092,7 +1092,7 @@ void loop(void)
|
|||
|
||||
if ( (ignition3StartTime > 0) && (BIT_CHECK(ignitionChannelsOn, IGN3_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule3(ignition3StartTime,
|
||||
setIgnitionSchedule(ignitionSchedule3, ignition3StartTime,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
}
|
||||
|
@ -1105,7 +1105,7 @@ void loop(void)
|
|||
|
||||
if ( (ignition4StartTime > 0) && (BIT_CHECK(ignitionChannelsOn, IGN4_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule4(ignition4StartTime,
|
||||
setIgnitionSchedule(ignitionSchedule4, ignition4StartTime,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
}
|
||||
|
@ -1118,7 +1118,7 @@ void loop(void)
|
|||
|
||||
if ( (ignition5StartTime > 0) && (BIT_CHECK(ignitionChannelsOn, IGN5_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule5(ignition5StartTime,
|
||||
setIgnitionSchedule(ignitionSchedule5, ignition5StartTime,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
}
|
||||
|
@ -1131,7 +1131,7 @@ void loop(void)
|
|||
|
||||
if ( (ignition6StartTime > 0) && (BIT_CHECK(ignitionChannelsOn, IGN6_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule6(ignition6StartTime,
|
||||
setIgnitionSchedule(ignitionSchedule6, ignition6StartTime,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
}
|
||||
|
@ -1144,7 +1144,7 @@ void loop(void)
|
|||
|
||||
if ( (ignition7StartTime > 0) && (BIT_CHECK(ignitionChannelsOn, IGN7_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule7(ignition7StartTime,
|
||||
setIgnitionSchedule(ignitionSchedule7, ignition7StartTime,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
}
|
||||
|
@ -1157,7 +1157,7 @@ void loop(void)
|
|||
|
||||
if ( (ignition8StartTime > 0) && (BIT_CHECK(ignitionChannelsOn, IGN8_CMD_BIT)) )
|
||||
{
|
||||
setIgnitionSchedule8(ignition8StartTime,
|
||||
setIgnitionSchedule(ignitionSchedule8, ignition8StartTime,
|
||||
currentStatus.dwell + fixedCrankingOverride);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
#include "schedule_calcs.h"
|
||||
|
||||
static void nullIgnCallback(void) {};
|
||||
|
||||
void test_adjust_crank_angle_pending_below_minrevolutions()
|
||||
{
|
||||
auto counter = decltype(+IGN4_COUNTER){0};
|
||||
auto compare = decltype(+IGN4_COMPARE){0};
|
||||
IgnitionSchedule schedule(counter, compare, nullIgnCallback, nullIgnCallback);
|
||||
|
||||
schedule.Status = PENDING;
|
||||
currentStatus.startRevolutions = 0;
|
||||
|
||||
schedule.compare = 101;
|
||||
schedule.counter = 100;
|
||||
|
||||
// Should do nothing.
|
||||
adjustCrankAngle(schedule, 359, 180);
|
||||
|
||||
TEST_ASSERT_EQUAL(101, schedule.compare);
|
||||
TEST_ASSERT_EQUAL(100, schedule.counter);
|
||||
TEST_ASSERT_FALSE(schedule.endScheduleSetByDecoder);
|
||||
}
|
||||
|
||||
|
||||
void test_adjust_crank_angle_pending_above_minrevolutions()
|
||||
{
|
||||
auto counter = decltype(+IGN4_COUNTER){0};
|
||||
auto compare = decltype(+IGN4_COMPARE){0};
|
||||
IgnitionSchedule schedule(counter, compare, nullIgnCallback, nullIgnCallback);
|
||||
|
||||
schedule.Status = PENDING;
|
||||
currentStatus.startRevolutions = 2000;
|
||||
// timePerDegreex16 = 666;
|
||||
|
||||
schedule.compare = 101;
|
||||
schedule.counter = 100;
|
||||
schedule.endCompare = 100;
|
||||
constexpr uint16_t newCrankAngle = 180;
|
||||
constexpr uint16_t chargeAngle = 359;
|
||||
|
||||
adjustCrankAngle(schedule, chargeAngle, newCrankAngle);
|
||||
|
||||
TEST_ASSERT_EQUAL(101, schedule.compare);
|
||||
TEST_ASSERT_EQUAL(100, schedule.counter);
|
||||
TEST_ASSERT_EQUAL(schedule.counter+uS_TO_TIMER_COMPARE(angleToTimeMicroSecPerDegree(chargeAngle-newCrankAngle)), schedule.endCompare);
|
||||
TEST_ASSERT_TRUE(schedule.endScheduleSetByDecoder);
|
||||
}
|
||||
|
||||
void test_adjust_crank_angle_running()
|
||||
{
|
||||
auto counter = decltype(+IGN4_COUNTER){0};
|
||||
auto compare = decltype(+IGN4_COMPARE){0};
|
||||
IgnitionSchedule schedule(counter, compare, nullIgnCallback, nullIgnCallback);
|
||||
|
||||
schedule.Status = RUNNING;
|
||||
currentStatus.startRevolutions = 2000;
|
||||
// timePerDegreex16 = 666;
|
||||
|
||||
schedule.compare = 101;
|
||||
schedule.counter = 100;
|
||||
schedule.endCompare = 100;
|
||||
constexpr uint16_t newCrankAngle = 180;
|
||||
constexpr uint16_t chargeAngle = 359;
|
||||
|
||||
adjustCrankAngle(schedule, chargeAngle, newCrankAngle);
|
||||
|
||||
TEST_ASSERT_EQUAL(schedule.counter+uS_TO_TIMER_COMPARE(angleToTimeMicroSecPerDegree(chargeAngle-newCrankAngle)), schedule.compare);
|
||||
TEST_ASSERT_EQUAL(100, schedule.counter);
|
||||
TEST_ASSERT_EQUAL(100, schedule.endCompare);
|
||||
TEST_ASSERT_FALSE(schedule.endScheduleSetByDecoder);
|
||||
}
|
||||
|
||||
void test_adjust_crank_angle()
|
||||
{
|
||||
RUN_TEST(test_adjust_crank_angle_pending_below_minrevolutions);
|
||||
RUN_TEST(test_adjust_crank_angle_pending_above_minrevolutions);
|
||||
RUN_TEST(test_adjust_crank_angle_running);
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
extern void test_calc_ign_timeout();
|
||||
extern void test_calc_inj_timeout();
|
||||
extern void test_adjust_crank_angle();
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -14,6 +15,7 @@ void setup()
|
|||
|
||||
test_calc_ign_timeout();
|
||||
test_calc_inj_timeout();
|
||||
test_adjust_crank_angle();
|
||||
|
||||
UNITY_END(); // stop unit testing
|
||||
|
||||
|
|
|
@ -12,188 +12,119 @@ static uint32_t start_time, end_time;
|
|||
static void startCallback(void) { start_time = micros(); }
|
||||
static void endCallback(void) { end_time = micros(); }
|
||||
|
||||
void test_accuracy_duration_inj1(void)
|
||||
void test_accuracy_duration_inj(FuelSchedule &schedule)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule1(TIMEOUT, DURATION);
|
||||
while(fuelSchedule1.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule1.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
schedule.pStartFunction = startCallback;
|
||||
schedule.pEndFunction = endCallback;
|
||||
setFuelSchedule(schedule, TIMEOUT, DURATION);
|
||||
while(schedule.Status != OFF) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_inj1(void)
|
||||
{
|
||||
test_accuracy_duration_inj(fuelSchedule1);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_inj2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule2(TIMEOUT, DURATION);
|
||||
while(fuelSchedule2.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule2.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
test_accuracy_duration_inj(fuelSchedule2);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_inj3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule3(TIMEOUT, DURATION);
|
||||
while(fuelSchedule3.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule3.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
test_accuracy_duration_inj(fuelSchedule3);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_inj4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule4(TIMEOUT, DURATION);
|
||||
while(fuelSchedule4.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule4.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
test_accuracy_duration_inj(fuelSchedule4);
|
||||
}
|
||||
|
||||
#if INJ_CHANNELS >= 5
|
||||
void test_accuracy_duration_inj5(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule5(TIMEOUT, DURATION);
|
||||
while(fuelSchedule5.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule5.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
test_accuracy_duration_inj(fuelSchedule5);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 6
|
||||
void test_accuracy_duration_inj6(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule6(TIMEOUT, DURATION);
|
||||
while(fuelSchedule6.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule6.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
test_accuracy_duration_inj(fuelSchedule6);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 7
|
||||
void test_accuracy_duration_inj7(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule7(TIMEOUT, DURATION);
|
||||
while(fuelSchedule7.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule7.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
test_accuracy_duration_inj(fuelSchedule7);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 8
|
||||
void test_accuracy_duration_inj8(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule8(TIMEOUT, DURATION);
|
||||
while(fuelSchedule8.Status == PENDING) /*Wait*/ ;
|
||||
start_time = micros();
|
||||
while(fuelSchedule8.Status == RUNNING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
test_accuracy_duration_inj(fuelSchedule8);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void test_accuracy_duration_ign1(void)
|
||||
void test_accuracy_duration_ign(IgnitionSchedule &schedule)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule1.pStartCallback = startCallback;
|
||||
ignitionSchedule1.pEndCallback = endCallback;
|
||||
setIgnitionSchedule1(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule1.Status == PENDING) || (ignitionSchedule1.Status == RUNNING) ) /*Wait*/ ;
|
||||
schedule.pStartCallback = startCallback;
|
||||
schedule.pEndCallback = endCallback;
|
||||
setIgnitionSchedule(schedule, TIMEOUT, DURATION);
|
||||
while(schedule.Status != OFF) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, DURATION, end_time - start_time);
|
||||
|
||||
}
|
||||
void test_accuracy_duration_ign1(void)
|
||||
{
|
||||
test_accuracy_duration_ign(ignitionSchedule1);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_ign2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule2.pStartCallback = startCallback;
|
||||
ignitionSchedule2.pEndCallback = endCallback;
|
||||
setIgnitionSchedule2(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule2.Status == PENDING) || (ignitionSchedule2.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_duration_ign(ignitionSchedule2);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_ign3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule3.pStartCallback = startCallback;
|
||||
ignitionSchedule3.pEndCallback = endCallback;
|
||||
setIgnitionSchedule3(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule3.Status == PENDING) || (ignitionSchedule3.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_duration_ign(ignitionSchedule3);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_ign4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule4.pStartCallback = startCallback;
|
||||
ignitionSchedule4.pEndCallback = endCallback;
|
||||
setIgnitionSchedule4(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule4.Status == PENDING) || (ignitionSchedule4.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_duration_ign(ignitionSchedule4);
|
||||
}
|
||||
|
||||
void test_accuracy_duration_ign5(void)
|
||||
{
|
||||
#if IGN_CHANNELS >= 5
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule5.pStartCallback = startCallback;
|
||||
ignitionSchedule5.pEndCallback = endCallback;
|
||||
setIgnitionSchedule5(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule5.Status == PENDING) || (ignitionSchedule5.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_duration_ign(ignitionSchedule5);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if INJ_CHANNELS >= 6
|
||||
void test_accuracy_duration_ign6(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule6.pStartCallback = startCallback;
|
||||
ignitionSchedule6.pEndCallback = endCallback;
|
||||
setIgnitionSchedule6(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule6.Status == PENDING) || (ignitionSchedule6.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_duration_ign(ignitionSchedule6);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 7
|
||||
void test_accuracy_duration_ign7(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule7.pStartCallback = startCallback;
|
||||
ignitionSchedule7.pEndCallback = endCallback;
|
||||
setIgnitionSchedule7(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule7.Status == PENDING) || (ignitionSchedule7.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_duration_ign(ignitionSchedule7);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 8
|
||||
void test_accuracy_duration_ign8(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule8.pStartCallback = startCallback;
|
||||
ignitionSchedule8.pEndCallback = endCallback;
|
||||
setIgnitionSchedule8(TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule8.Status == PENDING) || (ignitionSchedule8.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_duration_ign(ignitionSchedule8);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,188 +13,121 @@ static uint32_t start_time, end_time;
|
|||
static void startCallback(void) { end_time = micros(); }
|
||||
static void endCallback(void) { /*Empty*/ }
|
||||
|
||||
void test_accuracy_timeout_inj1(void)
|
||||
void test_accuracy_timeout_inj(FuelSchedule &schedule)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
schedule.pStartFunction = startCallback;
|
||||
schedule.pEndFunction = endCallback;
|
||||
start_time = micros();
|
||||
setFuelSchedule1(TIMEOUT, DURATION);
|
||||
while(fuelSchedule1.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
setFuelSchedule(schedule, TIMEOUT, DURATION);
|
||||
while(schedule.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_inj1(void)
|
||||
{
|
||||
test_accuracy_timeout_inj(fuelSchedule1);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_inj2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
setFuelSchedule2(TIMEOUT, DURATION);
|
||||
while(fuelSchedule2.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_inj(fuelSchedule2);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_inj3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
setFuelSchedule3(TIMEOUT, DURATION);
|
||||
while(fuelSchedule3.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_inj(fuelSchedule3);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_inj4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
setFuelSchedule4(TIMEOUT, DURATION);
|
||||
while(fuelSchedule4.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_inj(fuelSchedule4);
|
||||
}
|
||||
|
||||
#if INJ_CHANNELS >= 5
|
||||
void test_accuracy_timeout_inj5(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
setFuelSchedule5(TIMEOUT, DURATION);
|
||||
while(fuelSchedule5.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_inj(fuelSchedule5);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 6
|
||||
void test_accuracy_timeout_inj6(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
setFuelSchedule6(TIMEOUT, DURATION);
|
||||
while(fuelSchedule6.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_inj(fuelSchedule6);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 7
|
||||
void test_accuracy_timeout_inj7(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
setFuelSchedule7(TIMEOUT, DURATION);
|
||||
while(fuelSchedule7.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_inj(fuelSchedule7);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INJ_CHANNELS >= 8
|
||||
void test_accuracy_timeout_inj8(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
setFuelSchedule8(TIMEOUT, DURATION);
|
||||
while(fuelSchedule8.Status == PENDING) /*Wait*/ ;
|
||||
end_time = micros();
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_inj(fuelSchedule8);
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_accuracy_timeout_ign(IgnitionSchedule &schedule)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
schedule.pStartCallback = startCallback;
|
||||
schedule.pEndCallback = endCallback;
|
||||
start_time = micros();
|
||||
setIgnitionSchedule(schedule, TIMEOUT, DURATION);
|
||||
while(schedule.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_ign1(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
ignitionSchedule1.pStartCallback = startCallback;
|
||||
ignitionSchedule1.pEndCallback = endCallback;
|
||||
setIgnitionSchedule1(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule1.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule1);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_ign2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
ignitionSchedule2.pStartCallback = startCallback;
|
||||
ignitionSchedule2.pEndCallback = endCallback;
|
||||
setIgnitionSchedule2(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule2.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule2);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_ign3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
ignitionSchedule3.pStartCallback = startCallback;
|
||||
ignitionSchedule3.pEndCallback = endCallback;
|
||||
setIgnitionSchedule3(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule3.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule3);
|
||||
}
|
||||
|
||||
void test_accuracy_timeout_ign4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
ignitionSchedule4.pStartCallback = startCallback;
|
||||
ignitionSchedule4.pEndCallback = endCallback;
|
||||
setIgnitionSchedule4(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule4.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule4);
|
||||
}
|
||||
|
||||
#if IGN_CHANNELS >= 5
|
||||
void test_accuracy_timeout_ign5(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
ignitionSchedule5.pStartCallback = startCallback;
|
||||
ignitionSchedule5.pEndCallback = endCallback;
|
||||
start_time = micros();
|
||||
setIgnitionSchedule5(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule5.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule5);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IGN_CHANNELS >= 6
|
||||
void test_accuracy_timeout_ign6(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
ignitionSchedule6.pStartCallback = startCallback;
|
||||
ignitionSchedule6.pEndCallback = endCallback;
|
||||
setIgnitionSchedule6(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule6.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule6);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IGN_CHANNELS >= 7
|
||||
void test_accuracy_timeout_ign7(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
ignitionSchedule7.pStartCallback = startCallback;
|
||||
ignitionSchedule7.pEndCallback = endCallback;
|
||||
setIgnitionSchedule7(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule7.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule7);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IGN_CHANNELS >= 8
|
||||
void test_accuracy_timeout_ign8(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
start_time = micros();
|
||||
ignitionSchedule8.pStartCallback = startCallback;
|
||||
ignitionSchedule8.pEndCallback = endCallback;
|
||||
setIgnitionSchedule8(TIMEOUT, DURATION);
|
||||
while(ignitionSchedule8.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_UINT32_WITHIN(DELTA, TIMEOUT, end_time - start_time);
|
||||
test_accuracy_timeout_ign(ignitionSchedule8);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -12,28 +12,28 @@ static void emptyCallback(void) { }
|
|||
void test_status_off_to_pending_inj1(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule1(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule1, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule1.Status);
|
||||
}
|
||||
|
||||
void test_status_off_to_pending_inj2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule2(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule2, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule2.Status);
|
||||
}
|
||||
|
||||
void test_status_off_to_pending_inj3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule3(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule3, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule3.Status);
|
||||
}
|
||||
|
||||
void test_status_off_to_pending_inj4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule4(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule4, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule4.Status);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ void test_status_off_to_pending_inj4(void)
|
|||
void test_status_off_to_pending_inj5(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule5(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule5, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule5.Status);
|
||||
}
|
||||
#endif
|
||||
|
@ -50,7 +50,7 @@ void test_status_off_to_pending_inj5(void)
|
|||
void test_status_off_to_pending_inj6(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule6(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule6, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule6.Status);
|
||||
}
|
||||
#endif
|
||||
|
@ -59,7 +59,7 @@ void test_status_off_to_pending_inj6(void)
|
|||
void test_status_off_to_pending_inj7(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule7(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule7, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule7.Status);
|
||||
}
|
||||
#endif
|
||||
|
@ -68,7 +68,7 @@ void test_status_off_to_pending_inj7(void)
|
|||
void test_status_off_to_pending_inj8(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule8(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule8, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule8.Status);
|
||||
}
|
||||
#endif
|
||||
|
@ -79,7 +79,7 @@ void test_status_off_to_pending_ign1(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule1.pStartCallback = emptyCallback;
|
||||
ignitionSchedule1.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule1(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule1, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule1.Status);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void test_status_off_to_pending_ign2(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule2.pStartCallback = emptyCallback;
|
||||
ignitionSchedule2.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule2(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule2, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule2.Status);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ void test_status_off_to_pending_ign3(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule3.pStartCallback = emptyCallback;
|
||||
ignitionSchedule3.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule3(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule3, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule3.Status);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ void test_status_off_to_pending_ign4(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule4.pStartCallback = emptyCallback;
|
||||
ignitionSchedule4.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule4(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule4, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule4.Status);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ void test_status_off_to_pending_ign5(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule5.pStartCallback = emptyCallback;
|
||||
ignitionSchedule5.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule5(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule5, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule5.Status);
|
||||
}
|
||||
#endif
|
||||
|
@ -127,7 +127,7 @@ void test_status_off_to_pending_ign6(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule6.pStartCallback = emptyCallback;
|
||||
ignitionSchedule6.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule6(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule6, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule6.Status);
|
||||
}
|
||||
#endif
|
||||
|
@ -138,7 +138,7 @@ void test_status_off_to_pending_ign7(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule7.pStartCallback = emptyCallback;
|
||||
ignitionSchedule7.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule7(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule7, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule7.Status);
|
||||
}
|
||||
#endif
|
||||
|
@ -149,7 +149,7 @@ void test_status_off_to_pending_ign8(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule8.pStartCallback = emptyCallback;
|
||||
ignitionSchedule8.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule8(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule8, TIMEOUT, DURATION);
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule8.Status);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -12,7 +12,7 @@ static void emptyCallback(void) { }
|
|||
void test_status_pending_to_running_inj1(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule1(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule1, TIMEOUT, DURATION);
|
||||
while(fuelSchedule1.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule1.Status);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ void test_status_pending_to_running_inj1(void)
|
|||
void test_status_pending_to_running_inj2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule2(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule2, TIMEOUT, DURATION);
|
||||
while(fuelSchedule2.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule2.Status);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ void test_status_pending_to_running_inj2(void)
|
|||
void test_status_pending_to_running_inj3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule3(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule3, TIMEOUT, DURATION);
|
||||
while(fuelSchedule3.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule3.Status);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void test_status_pending_to_running_inj3(void)
|
|||
void test_status_pending_to_running_inj4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule4(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule4, TIMEOUT, DURATION);
|
||||
while(fuelSchedule4.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule4.Status);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void test_status_pending_to_running_inj5(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 5
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule5(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule5, TIMEOUT, DURATION);
|
||||
while(fuelSchedule5.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule5.Status);
|
||||
#endif
|
||||
|
@ -55,7 +55,7 @@ void test_status_pending_to_running_inj6(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 6
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule6(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule6, TIMEOUT, DURATION);
|
||||
while(fuelSchedule6.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule6.Status);
|
||||
#endif
|
||||
|
@ -65,7 +65,7 @@ void test_status_pending_to_running_inj7(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 7
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule7(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule7, TIMEOUT, DURATION);
|
||||
while(fuelSchedule7.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule7.Status);
|
||||
#endif
|
||||
|
@ -75,7 +75,7 @@ void test_status_pending_to_running_inj8(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 8
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule8(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule8, TIMEOUT, DURATION);
|
||||
while(fuelSchedule8.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, fuelSchedule8.Status);
|
||||
#endif
|
||||
|
@ -87,7 +87,7 @@ void test_status_pending_to_running_ign1(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule1.pStartCallback = emptyCallback;
|
||||
ignitionSchedule1.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule1(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule1, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule1.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule1.Status);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ void test_status_pending_to_running_ign2(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule2.pStartCallback = emptyCallback;
|
||||
ignitionSchedule2.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule2(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule2, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule2.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule2.Status);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ void test_status_pending_to_running_ign3(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule3.pStartCallback = emptyCallback;
|
||||
ignitionSchedule3.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule3(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule3, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule3.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule3.Status);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void test_status_pending_to_running_ign4(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule4.pStartCallback = emptyCallback;
|
||||
ignitionSchedule4.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule4(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule4, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule4.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule4.Status);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ void test_status_pending_to_running_ign5(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule5.pStartCallback = emptyCallback;
|
||||
ignitionSchedule5.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule5(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule5, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule5.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule5.Status);
|
||||
#endif
|
||||
|
@ -140,7 +140,7 @@ void test_status_pending_to_running_ign6(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule6.pStartCallback = emptyCallback;
|
||||
ignitionSchedule6.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule6(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule6, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule6.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule6.Status);
|
||||
#endif
|
||||
|
@ -152,7 +152,7 @@ void test_status_pending_to_running_ign7(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule7.pStartCallback = emptyCallback;
|
||||
ignitionSchedule7.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule7(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule7, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule7.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule7.Status);
|
||||
#endif
|
||||
|
@ -164,7 +164,7 @@ void test_status_pending_to_running_ign8(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule8.pStartCallback = emptyCallback;
|
||||
ignitionSchedule8.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule8(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule8, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule8.Status == PENDING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(RUNNING, ignitionSchedule8.Status);
|
||||
#endif
|
||||
|
|
|
@ -12,7 +12,7 @@ static void emptyCallback(void) { }
|
|||
void test_status_running_to_off_inj1(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule1(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule1, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule1.Status == PENDING) || (fuelSchedule1.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule1.Status);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ void test_status_running_to_off_inj1(void)
|
|||
void test_status_running_to_off_inj2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule2(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule2, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule2.Status == PENDING) || (fuelSchedule2.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule2.Status);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ void test_status_running_to_off_inj2(void)
|
|||
void test_status_running_to_off_inj3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule3(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule3, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule3.Status == PENDING) || (fuelSchedule3.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule3.Status);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void test_status_running_to_off_inj3(void)
|
|||
void test_status_running_to_off_inj4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule4(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule4, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule4.Status == PENDING) || (fuelSchedule4.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule4.Status);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void test_status_running_to_off_inj5(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 5
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule5(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule5, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule5.Status == PENDING) || (fuelSchedule5.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule5.Status);
|
||||
#endif
|
||||
|
@ -55,7 +55,7 @@ void test_status_running_to_off_inj6(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 6
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule6(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule6, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule6.Status == PENDING) || (fuelSchedule6.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule6.Status);
|
||||
#endif
|
||||
|
@ -65,7 +65,7 @@ void test_status_running_to_off_inj7(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 7
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule7(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule7, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule7.Status == PENDING) || (fuelSchedule7.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule7.Status);
|
||||
#endif
|
||||
|
@ -75,7 +75,7 @@ void test_status_running_to_off_inj8(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 8
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule8(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule8, TIMEOUT, DURATION);
|
||||
while( (fuelSchedule8.Status == PENDING) || (fuelSchedule8.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, fuelSchedule8.Status);
|
||||
#endif
|
||||
|
@ -87,7 +87,7 @@ void test_status_running_to_off_ign1(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule1.pStartCallback = emptyCallback;
|
||||
ignitionSchedule1.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule1(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule1, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule1.Status == PENDING) || (ignitionSchedule1.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule1.Status);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ void test_status_running_to_off_ign2(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule2.pStartCallback = emptyCallback;
|
||||
ignitionSchedule2.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule2(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule2, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule2.Status == PENDING) || (ignitionSchedule2.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule2.Status);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ void test_status_running_to_off_ign3(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule3.pStartCallback = emptyCallback;
|
||||
ignitionSchedule3.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule3(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule3, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule3.Status == PENDING) || (ignitionSchedule3.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule3.Status);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void test_status_running_to_off_ign4(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule4.pStartCallback = emptyCallback;
|
||||
ignitionSchedule4.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule4(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule4, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule4.Status == PENDING) || (ignitionSchedule4.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule4.Status);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ void test_status_running_to_off_ign5(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule5.pStartCallback = emptyCallback;
|
||||
ignitionSchedule5.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule5(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule5, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule5.Status == PENDING) || (ignitionSchedule5.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule5.Status);
|
||||
#endif
|
||||
|
@ -140,7 +140,7 @@ void test_status_running_to_off_ign6(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule6.pStartCallback = emptyCallback;
|
||||
ignitionSchedule6.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule6(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule6, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule6.Status == PENDING) || (ignitionSchedule6.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule6.Status);
|
||||
#endif
|
||||
|
@ -152,7 +152,7 @@ void test_status_running_to_off_ign7(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule7.pStartCallback = emptyCallback;
|
||||
ignitionSchedule7.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule7(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule7, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule7.Status == PENDING) || (ignitionSchedule7.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule7.Status);
|
||||
#endif
|
||||
|
@ -164,7 +164,7 @@ void test_status_running_to_off_ign8(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule8.pStartCallback = emptyCallback;
|
||||
ignitionSchedule8.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule8(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule8, TIMEOUT, DURATION);
|
||||
while( (ignitionSchedule8.Status == PENDING) || (ignitionSchedule8.Status == RUNNING) ) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(OFF, ignitionSchedule8.Status);
|
||||
#endif
|
||||
|
|
|
@ -12,9 +12,9 @@ static void emptyCallback(void) { }
|
|||
void test_status_running_to_pending_inj1(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule1(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule1, TIMEOUT, DURATION);
|
||||
while(fuelSchedule1.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule1(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule1, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule1.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule1.Status);
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ void test_status_running_to_pending_inj1(void)
|
|||
void test_status_running_to_pending_inj2(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule2(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule2, TIMEOUT, DURATION);
|
||||
while(fuelSchedule2.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule2(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule2, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule2.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule2.Status);
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ void test_status_running_to_pending_inj2(void)
|
|||
void test_status_running_to_pending_inj3(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule3(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule3, TIMEOUT, DURATION);
|
||||
while(fuelSchedule3.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule3(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule3, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule3.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule3.Status);
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ void test_status_running_to_pending_inj3(void)
|
|||
void test_status_running_to_pending_inj4(void)
|
||||
{
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule4(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule4, TIMEOUT, DURATION);
|
||||
while(fuelSchedule4.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule4(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule4, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule4.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule4.Status);
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ void test_status_running_to_pending_inj5(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 5
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule5(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule5, TIMEOUT, DURATION);
|
||||
while(fuelSchedule5.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule5(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule5, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule5.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule5.Status);
|
||||
#endif
|
||||
|
@ -65,9 +65,9 @@ void test_status_running_to_pending_inj6(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 6
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule6(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule6, TIMEOUT, DURATION);
|
||||
while(fuelSchedule6.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule6(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule6, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule6.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule6.Status);
|
||||
#endif
|
||||
|
@ -77,9 +77,9 @@ void test_status_running_to_pending_inj7(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 7
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule7(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule7, TIMEOUT, DURATION);
|
||||
while(fuelSchedule7.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule7(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule7, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule7.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule7.Status);
|
||||
#endif
|
||||
|
@ -89,9 +89,9 @@ void test_status_running_to_pending_inj8(void)
|
|||
{
|
||||
#if INJ_CHANNELS >= 8
|
||||
initialiseSchedulers();
|
||||
setFuelSchedule8(TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule8, TIMEOUT, DURATION);
|
||||
while(fuelSchedule8.Status == PENDING) /*Wait*/ ;
|
||||
setFuelSchedule8(2*TIMEOUT, DURATION);
|
||||
setFuelSchedule(fuelSchedule8, 2*TIMEOUT, DURATION);
|
||||
while(fuelSchedule8.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, fuelSchedule8.Status);
|
||||
#endif
|
||||
|
@ -103,9 +103,9 @@ void test_status_running_to_pending_ign1(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule1.pStartCallback = emptyCallback;
|
||||
ignitionSchedule1.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule1(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule1, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule1.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule1(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule1, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule1.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule1.Status);
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ void test_status_running_to_pending_ign2(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule2.pStartCallback = emptyCallback;
|
||||
ignitionSchedule2.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule2(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule2, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule2.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule2(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule2, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule2.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule2.Status);
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ void test_status_running_to_pending_ign3(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule3.pStartCallback = emptyCallback;
|
||||
ignitionSchedule3.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule3(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule3, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule3.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule3(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule3, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule3.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule3.Status);
|
||||
}
|
||||
|
@ -139,9 +139,9 @@ void test_status_running_to_pending_ign4(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule4.pStartCallback = emptyCallback;
|
||||
ignitionSchedule4.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule4(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule4, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule4.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule4(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule4, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule4.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule4.Status);
|
||||
}
|
||||
|
@ -152,9 +152,9 @@ void test_status_running_to_pending_ign5(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule5.pStartCallback = emptyCallback;
|
||||
ignitionSchedule5.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule5(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule5, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule5.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule5(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule5, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule5.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule5.Status);
|
||||
#endif
|
||||
|
@ -166,9 +166,9 @@ void test_status_running_to_pending_ign6(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule6.pStartCallback = emptyCallback;
|
||||
ignitionSchedule6.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule6(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule6, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule6.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule6(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule6, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule6.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule6.Status);
|
||||
#endif
|
||||
|
@ -180,9 +180,9 @@ void test_status_running_to_pending_ign7(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule7.pStartCallback = emptyCallback;
|
||||
ignitionSchedule7.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule7(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule7, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule7.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule7(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule7, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule7.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule7.Status);
|
||||
#endif
|
||||
|
@ -194,9 +194,9 @@ void test_status_running_to_pending_ign8(void)
|
|||
initialiseSchedulers();
|
||||
ignitionSchedule8.pStartCallback = emptyCallback;
|
||||
ignitionSchedule8.pEndCallback = emptyCallback;
|
||||
setIgnitionSchedule8(TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule8, TIMEOUT, DURATION);
|
||||
while(ignitionSchedule8.Status == PENDING) /*Wait*/ ;
|
||||
setIgnitionSchedule8(2*TIMEOUT, DURATION);
|
||||
setIgnitionSchedule(ignitionSchedule8, 2*TIMEOUT, DURATION);
|
||||
while(ignitionSchedule8.Status == RUNNING) /*Wait*/ ;
|
||||
TEST_ASSERT_EQUAL(PENDING, ignitionSchedule8.Status);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue