Test start/end callback assignment (#1044)
This commit is contained in:
parent
f71b7e50e2
commit
424a96d9ea
|
@ -170,6 +170,40 @@ void initialiseSchedulers(void)
|
||||||
channel6InjDegrees = 0; /**< The number of crank degrees until cylinder 6 is at TDC */
|
channel6InjDegrees = 0; /**< The number of crank degrees until cylinder 6 is at TDC */
|
||||||
channel7InjDegrees = 0; /**< The number of crank degrees until cylinder 7 is at TDC */
|
channel7InjDegrees = 0; /**< The number of crank degrees until cylinder 7 is at TDC */
|
||||||
channel8InjDegrees = 0; /**< The number of crank degrees until cylinder 8 is at TDC */
|
channel8InjDegrees = 0; /**< The number of crank degrees until cylinder 8 is at TDC */
|
||||||
|
|
||||||
|
inj1StartFunction = nullCallback;
|
||||||
|
inj1EndFunction = nullCallback;
|
||||||
|
inj2StartFunction = nullCallback;
|
||||||
|
inj2EndFunction = nullCallback;
|
||||||
|
inj3StartFunction = nullCallback;
|
||||||
|
inj3EndFunction = nullCallback;
|
||||||
|
inj4StartFunction = nullCallback;
|
||||||
|
inj4EndFunction = nullCallback;
|
||||||
|
inj5StartFunction = nullCallback;
|
||||||
|
inj5EndFunction = nullCallback;
|
||||||
|
inj6StartFunction = nullCallback;
|
||||||
|
inj6EndFunction = nullCallback;
|
||||||
|
inj7StartFunction = nullCallback;
|
||||||
|
inj7EndFunction = nullCallback;
|
||||||
|
inj8StartFunction = nullCallback;
|
||||||
|
inj8EndFunction = nullCallback;
|
||||||
|
|
||||||
|
ign1StartFunction = nullCallback;
|
||||||
|
ign1EndFunction = nullCallback;
|
||||||
|
ign2StartFunction = nullCallback;
|
||||||
|
ign2EndFunction = nullCallback;
|
||||||
|
ign3StartFunction = nullCallback;
|
||||||
|
ign3EndFunction = nullCallback;
|
||||||
|
ign4StartFunction = nullCallback;
|
||||||
|
ign4EndFunction = nullCallback;
|
||||||
|
ign5StartFunction = nullCallback;
|
||||||
|
ign5EndFunction = nullCallback;
|
||||||
|
ign6StartFunction = nullCallback;
|
||||||
|
ign6EndFunction = nullCallback;
|
||||||
|
ign7StartFunction = nullCallback;
|
||||||
|
ign7EndFunction = nullCallback;
|
||||||
|
ign8StartFunction = nullCallback;
|
||||||
|
ign8EndFunction = nullCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -3,11 +3,26 @@
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "schedule_calcs.h"
|
#include "schedule_calcs.h"
|
||||||
|
#include "scheduledIO.h"
|
||||||
|
|
||||||
extern uint16_t req_fuel_uS;
|
extern uint16_t req_fuel_uS;
|
||||||
|
|
||||||
static constexpr uint16_t reqFuel = 86; // ms * 10
|
static constexpr uint16_t reqFuel = 86; // ms * 10
|
||||||
|
|
||||||
|
static void assert_fuel_channel(bool enabled, uint16_t angle, uint8_t cmdBit, int channelInjDegrees, void (*startFunction)(void), void (*endFunction)(void))
|
||||||
|
{
|
||||||
|
char msg[32];
|
||||||
|
|
||||||
|
sprintf_P(msg, PSTR("channel%" PRIu8 "1InjDegrees.isEnabled"), cmdBit+1);
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(enabled, BIT_CHECK(channelInjEnabled, cmdBit), msg);
|
||||||
|
sprintf_P(msg, PSTR("channe%" PRIu8 "1InjDegrees"), cmdBit+1);
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(angle, channelInjDegrees, msg);
|
||||||
|
sprintf_P(msg, PSTR("inj%" PRIu8 "StartFunction"), cmdBit+1);
|
||||||
|
TEST_ASSERT_TRUE_MESSAGE(!enabled || (startFunction!=nullCallback), msg);
|
||||||
|
sprintf_P(msg, PSTR("inj%" PRIu8 "EndFunction"), cmdBit+1);
|
||||||
|
TEST_ASSERT_TRUE_MESSAGE(!enabled || (endFunction!=nullCallback), msg);
|
||||||
|
}
|
||||||
|
|
||||||
static void assert_fuel_schedules(uint16_t crankAngle, uint16_t reqFuel, const bool enabled[], const uint16_t angle[])
|
static void assert_fuel_schedules(uint16_t crankAngle, uint16_t reqFuel, const bool enabled[], const uint16_t angle[])
|
||||||
{
|
{
|
||||||
char msg[32];
|
char msg[32];
|
||||||
|
@ -17,45 +32,25 @@ static void assert_fuel_schedules(uint16_t crankAngle, uint16_t reqFuel, const b
|
||||||
strcpy_P(msg, PSTR("req_fuel_uS"));
|
strcpy_P(msg, PSTR("req_fuel_uS"));
|
||||||
TEST_ASSERT_EQUAL_UINT16_MESSAGE(reqFuel, req_fuel_uS, msg);
|
TEST_ASSERT_EQUAL_UINT16_MESSAGE(reqFuel, req_fuel_uS, msg);
|
||||||
|
|
||||||
strcpy_P(msg, PSTR("channel1InjDegrees.isEnabled"));
|
assert_fuel_channel(enabled[0], angle[0], INJ1_CMD_BIT, channel1InjDegrees, inj1StartFunction, inj1EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[0], BIT_CHECK(channelInjEnabled, INJ1_CMD_BIT), msg);
|
assert_fuel_channel(enabled[1], angle[1], INJ2_CMD_BIT, channel2InjDegrees, inj2StartFunction, inj2EndFunction);
|
||||||
strcpy_P(msg, PSTR("channel1InjDegrees"));
|
assert_fuel_channel(enabled[2], angle[2], INJ3_CMD_BIT, channel3InjDegrees, inj3StartFunction, inj3EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[0], channel1InjDegrees, msg);
|
assert_fuel_channel(enabled[3], angle[3], INJ4_CMD_BIT, channel4InjDegrees, inj4StartFunction, inj4EndFunction);
|
||||||
strcpy_P(msg, PSTR("channel2InjDegrees.isEnabled"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[1], BIT_CHECK(channelInjEnabled, INJ2_CMD_BIT), msg);
|
|
||||||
strcpy_P(msg, PSTR("channel2InjDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[1], channel2InjDegrees, msg);
|
|
||||||
strcpy_P(msg, PSTR("channel3InjDegrees.isEnabled"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[2], BIT_CHECK(channelInjEnabled, INJ3_CMD_BIT), msg);
|
|
||||||
strcpy_P(msg, PSTR("channel3InjDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[2], channel3InjDegrees, msg);
|
|
||||||
strcpy_P(msg, PSTR("channel4InjDegrees.isEnabled"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[3], BIT_CHECK(channelInjEnabled, INJ4_CMD_BIT), msg);
|
|
||||||
strcpy_P(msg, PSTR("channel4InjDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[3], channel4InjDegrees, msg);
|
|
||||||
#if INJ_CHANNELS>=5
|
#if INJ_CHANNELS>=5
|
||||||
strcpy_P(msg, PSTR("channel5InjDegrees.isEnabled"));
|
assert_fuel_channel(enabled[4], angle[4], INJ5_CMD_BIT, channel5InjDegrees, inj5StartFunction, inj5EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[4], BIT_CHECK(channelInjEnabled, INJ5_CMD_BIT), msg);
|
|
||||||
strcpy_P(msg, PSTR("channel5InjDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[4], channel5InjDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if INJ_CHANNELS>=6
|
#if INJ_CHANNELS>=6
|
||||||
strcpy_P(msg, PSTR("channel6InjDegrees.isEnabled"));
|
assert_fuel_channel(enabled[5], angle[5], INJ6_CMD_BIT, channel6InjDegrees, inj6StartFunction, inj6EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[5], BIT_CHECK(channelInjEnabled, INJ6_CMD_BIT), msg);
|
|
||||||
strcpy_P(msg, PSTR("channel6InjDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[5], channel6InjDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if INJ_CHANNELS>=7
|
#if INJ_CHANNELS>=7
|
||||||
strcpy_P(msg, PSTR("channel7InjDegrees.isEnabled"));
|
assert_fuel_channel(enabled[6], angle[6], INJ7_CMD_BIT, channel7InjDegrees, inj7StartFunction, inj7EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[6], BIT_CHECK(channelInjEnabled, INJ7_CMD_BIT), msg);
|
|
||||||
strcpy_P(msg, PSTR("channel7InjDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[6], channel7InjDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if INJ_CHANNELS>=8
|
#if INJ_CHANNELS>=8
|
||||||
strcpy_P(msg, PSTR("channel8InjDegrees.isEnabled"));
|
assert_fuel_channel(enabled[7], angle[7], INJ8_CMD_BIT, channel8InjDegrees, inj8StartFunction, inj8EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[7], BIT_CHECK(channelInjEnabled, INJ8_CMD_BIT), msg);
|
|
||||||
strcpy_P(msg, PSTR("channel8InjDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[7], channel8InjDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,19 @@
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "schedule_calcs.h"
|
#include "schedule_calcs.h"
|
||||||
|
#include "scheduledIO.h"
|
||||||
|
|
||||||
|
static void assert_ignition_channel(uint16_t angle, uint8_t channel, int channelInjDegrees, void (*startFunction)(void), void (*endFunction)(void))
|
||||||
|
{
|
||||||
|
char msg[32];
|
||||||
|
|
||||||
|
sprintf_P(msg, PSTR("channe%" PRIu8 "1InjDegrees"), channel+1);
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(angle, channelInjDegrees, msg);
|
||||||
|
sprintf_P(msg, PSTR("ign%" PRIu8 "StartFunction"), channel+1);
|
||||||
|
TEST_ASSERT_TRUE_MESSAGE(channel>=maxIgnOutputs || (startFunction!=nullCallback), msg);
|
||||||
|
sprintf_P(msg, PSTR("ign%" PRIu8 "EndFunction"), channel+1);
|
||||||
|
TEST_ASSERT_TRUE_MESSAGE(channel>=maxIgnOutputs || (endFunction!=nullCallback), msg);
|
||||||
|
}
|
||||||
|
|
||||||
static void assert_ignition_schedules(uint16_t crankAngle, uint16_t expectedOutputs, uint16_t angle[])
|
static void assert_ignition_schedules(uint16_t crankAngle, uint16_t expectedOutputs, uint16_t angle[])
|
||||||
{
|
{
|
||||||
|
@ -13,29 +26,21 @@ static void assert_ignition_schedules(uint16_t crankAngle, uint16_t expectedOutp
|
||||||
strcpy_P(msg, PSTR("maxIgnOutputs"));
|
strcpy_P(msg, PSTR("maxIgnOutputs"));
|
||||||
TEST_ASSERT_EQUAL_UINT16_MESSAGE(expectedOutputs, maxIgnOutputs, msg);
|
TEST_ASSERT_EQUAL_UINT16_MESSAGE(expectedOutputs, maxIgnOutputs, msg);
|
||||||
|
|
||||||
strcpy_P(msg, PSTR("channel1IgnDegrees"));
|
assert_ignition_channel(angle[0], 0, channel1IgnDegrees, ign1StartFunction, ign1EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[0], channel1IgnDegrees, msg);
|
assert_ignition_channel(angle[1], 1, channel2IgnDegrees, ign2StartFunction, ign2EndFunction);
|
||||||
strcpy_P(msg, PSTR("channel2IgnDegrees"));
|
assert_ignition_channel(angle[2], 2, channel3IgnDegrees, ign3StartFunction, ign3EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[1], channel2IgnDegrees, msg);
|
assert_ignition_channel(angle[3], 3, channel4IgnDegrees, ign4StartFunction, ign4EndFunction);
|
||||||
strcpy_P(msg, PSTR("channel3IgnDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[2], channel3IgnDegrees, msg);
|
|
||||||
strcpy_P(msg, PSTR("channel4IgnDegrees"));
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[3], channel4IgnDegrees, msg);
|
|
||||||
#if IGN_CHANNELS>=5
|
#if IGN_CHANNELS>=5
|
||||||
strcpy_P(msg, PSTR("channel5IgnDegrees"));
|
assert_ignition_channel(angle[4], 4, channel5IgnDegrees, ign5StartFunction, ign5EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[4], channel5IgnDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
#if IGN_CHANNELS>=6
|
#if IGN_CHANNELS>=6
|
||||||
strcpy_P(msg, PSTR("channel6IgnDegrees"));
|
assert_ignition_channel(angle[5], 5, channel6IgnDegrees, ign6StartFunction, ign6EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[5], channel6IgnDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
#if IGN_CHANNELS>=7
|
#if IGN_CHANNELS>=7
|
||||||
strcpy_P(msg, PSTR("channel7IgnDegrees"));
|
assert_ignition_channel(angle[6], 6, channel7IgnDegrees, ign7StartFunction, ign7EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[6], channel7IgnDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
#if IGN_CHANNELS>=8
|
#if IGN_CHANNELS>=8
|
||||||
strcpy_P(msg, PSTR("channel8IgnDegrees"));
|
assert_ignition_channel(angle[7], 7, channel8IgnDegrees, ign8StartFunction, ign8EndFunction);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(angle[7], channel8IgnDegrees, msg);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue