Unit test fuel and ignition scheduler initialisation (#1039)
* Unit test fuel schedule initialisation * Move initialisation tests to their own harness Saves memory * Rename test_misc to test_tables * Rename test_misc2 to test_math * Reduce memory usage * Fill out remaining ignition init unit tests
This commit is contained in:
parent
9ff33f0384
commit
4a509d19f2
|
@ -28,6 +28,7 @@ A full copy of the license may be found in the projects root directory
|
|||
#include "scheduler.h"
|
||||
#include "scheduledIO.h"
|
||||
#include "timers.h"
|
||||
#include "schedule_calcs.h"
|
||||
|
||||
FuelSchedule fuelSchedule1;
|
||||
FuelSchedule fuelSchedule2;
|
||||
|
@ -142,6 +143,33 @@ void initialiseSchedulers(void)
|
|||
ignitionSchedule6.schedulesSet = 0;
|
||||
ignitionSchedule7.schedulesSet = 0;
|
||||
ignitionSchedule8.schedulesSet = 0;
|
||||
|
||||
ignition1StartAngle = 0;
|
||||
ignition2StartAngle = 0;
|
||||
ignition3StartAngle = 0;
|
||||
ignition4StartAngle = 0;
|
||||
ignition5StartAngle = 0;
|
||||
ignition6StartAngle = 0;
|
||||
ignition7StartAngle = 0;
|
||||
ignition8StartAngle = 0;
|
||||
|
||||
channel1IgnDegrees = 0; /**< The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones) */
|
||||
channel2IgnDegrees = 0; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
|
||||
channel3IgnDegrees = 0; /**< The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC */
|
||||
channel4IgnDegrees = 0; /**< The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC */
|
||||
channel5IgnDegrees = 0; /**< The number of crank degrees until cylinder 5 is at TDC */
|
||||
channel6IgnDegrees = 0; /**< The number of crank degrees until cylinder 6 is at TDC */
|
||||
channel7IgnDegrees = 0; /**< The number of crank degrees until cylinder 7 is at TDC */
|
||||
channel8IgnDegrees = 0; /**< The number of crank degrees until cylinder 8 is at TDC */
|
||||
|
||||
channel1InjDegrees = 0; /**< The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones) */
|
||||
channel2InjDegrees = 0; /**< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC */
|
||||
channel3InjDegrees = 0; /**< The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC */
|
||||
channel4InjDegrees = 0; /**< The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC */
|
||||
channel5InjDegrees = 0; /**< The number of crank degrees until cylinder 5 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 */
|
||||
channel8InjDegrees = 0; /**< The number of crank degrees until cylinder 8 is at TDC */
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
|
||||
void testInitialisation(void);
|
||||
void testFuelScheduleInit(void);
|
||||
void testIgnitionScheduleInit(void);
|
||||
|
||||
#define UNITY_EXCLUDE_DETAILS
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
// NOTE!!! Wait for >2 secs
|
||||
// if board doesn't support software reset via Serial.DTR/RTS
|
||||
delay(2000);
|
||||
|
||||
UNITY_BEGIN(); // IMPORTANT LINE!
|
||||
|
||||
testInitialisation();
|
||||
testFuelScheduleInit();
|
||||
testIgnitionScheduleInit();
|
||||
|
||||
UNITY_END(); // stop unit testing
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Blink to indicate end of test
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
delay(250);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
delay(250);
|
||||
}
|
|
@ -0,0 +1,640 @@
|
|||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
#include "globals.h"
|
||||
#include "init.h"
|
||||
#include "schedule_calcs.h"
|
||||
|
||||
extern uint16_t req_fuel_uS;
|
||||
|
||||
static constexpr uint16_t reqFuel = 86; // ms * 10
|
||||
|
||||
static void assert_fuel_schedules(uint16_t crankAngle, uint16_t reqFuel, const bool enabled[], const uint16_t angle[])
|
||||
{
|
||||
char msg[32];
|
||||
|
||||
strcpy_P(msg, PSTR("CRANK_ANGLE_MAX_INJ"));
|
||||
TEST_ASSERT_EQUAL_INT16_MESSAGE(crankAngle, CRANK_ANGLE_MAX_INJ, msg);
|
||||
strcpy_P(msg, PSTR("req_fuel_uS"));
|
||||
TEST_ASSERT_EQUAL_UINT16_MESSAGE(reqFuel, req_fuel_uS, msg);
|
||||
|
||||
strcpy_P(msg, PSTR("channel1InjDegrees.isEnabled"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(enabled[0], BIT_CHECK(channelInjEnabled, INJ1_CMD_BIT), msg);
|
||||
strcpy_P(msg, PSTR("channel1InjDegrees"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(angle[0], channel1InjDegrees, msg);
|
||||
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
|
||||
strcpy_P(msg, PSTR("channel5InjDegrees.isEnabled"));
|
||||
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
|
||||
#if INJ_CHANNELS>=6
|
||||
strcpy_P(msg, PSTR("channel6InjDegrees.isEnabled"));
|
||||
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
|
||||
#if INJ_CHANNELS>=7
|
||||
strcpy_P(msg, PSTR("channel7InjDegrees.isEnabled"));
|
||||
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
|
||||
#if INJ_CHANNELS>=8
|
||||
strcpy_P(msg, PSTR("channel8InjDegrees.isEnabled"));
|
||||
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
|
||||
}
|
||||
|
||||
void test_fuel_schedule_1_cylinder_4stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 1;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 1;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, false, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, false, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
void test_fuel_schedule_1_cylinder_2stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 1;
|
||||
configPage2.strokes = TWO_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 1;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, false, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, false, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_fuel_schedule_2_cylinder_4stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 2;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 1;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,180,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,180,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
void test_fuel_schedule_2_cylinder_2stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 2;
|
||||
configPage2.strokes = TWO_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 1;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,180,0,0,0,0};
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,180,0,0,0,0};
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
void test_fuel_schedule_3_cylinder_4stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 3;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 1;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,240,480,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,0,0,0,0};
|
||||
assert_fuel_schedules(240U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS>=6
|
||||
const bool enabled[] = {true, true, true, true, true, true, false, false};
|
||||
const uint16_t angle[] = {0,240,480,0,240,480,0,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,240,480,0,0,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS>=6
|
||||
const bool enabled[] = {true, true, true, true, true, true, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,80,160,0,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,0,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(240U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_fuel_schedule_3_cylinder_2stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 3;
|
||||
configPage2.strokes = TWO_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 1;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,0,0,0,0};
|
||||
assert_fuel_schedules(120U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,0,0,0,0};
|
||||
assert_fuel_schedules(120U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS>=6
|
||||
const bool enabled[] = {true, true, true, true, true, true, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,80,160,0,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,0,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(120U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS>=6
|
||||
const bool enabled[] = {true, true, true, true, true, true, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,80,160,0,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,80,160,0,0,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(120U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_fuel_schedule_4_cylinder_4stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 4;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 2;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,360,540,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS>=8
|
||||
const bool enabled[] = {true, true, true, true, true, true, true, true};
|
||||
const uint16_t angle[] = {0,180,360,540,0,180,360,540};
|
||||
#elif INJ_CHANNELS >= 5
|
||||
const bool enabled[] = {true, true, true, true, true, false, false, false};
|
||||
const uint16_t angle[] = {0,180,360,540,0,0,0,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,360,540,0,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_PAIRED;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,180,0,0,0,0};
|
||||
assert_fuel_schedules(360U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
void test_fuel_schedule_4_cylinder_2stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 4;
|
||||
configPage2.strokes = TWO_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 2;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, false, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS>=8
|
||||
const bool enabled[] = {true, true, true, true, true, true, true, true};
|
||||
const uint16_t angle[] = {0,180,0,0,0,180,0,0};
|
||||
#elif INJ_CHANNELS >= 5
|
||||
const bool enabled[] = {true, true, true, true, true, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_PAIRED;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,180,0,180,0,0,0,0};
|
||||
assert_fuel_schedules(180U, reqFuel * 100U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_fuel_schedule_5_cylinder_4stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 5;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 5;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS >= 5
|
||||
const bool enabled[] = {true, true, true, true, true, false, false, false};
|
||||
const uint16_t angle[] = {0,144,288,432,576,0,0,0};
|
||||
uint16_t expectedFuel = reqFuel * 100U;
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
uint16_t expectedFuel = reqFuel * 50U;
|
||||
#endif
|
||||
assert_fuel_schedules(720U, expectedFuel, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,72,144,216,288,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS >= 6
|
||||
const bool enabled[] = {true, true, true, true, true, true, false, false};
|
||||
const uint16_t angle[] = {0,144,288,432,576,0,0,0};
|
||||
uint16_t expectedFuel = reqFuel * 100U;
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
uint16_t expectedFuel = reqFuel * 50U;
|
||||
#endif
|
||||
assert_fuel_schedules(720U, expectedFuel, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_PAIRED;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS >= 5
|
||||
const bool enabled[] = {true, true, true, true, true, false, false, false};
|
||||
const uint16_t angle[] = {0,72,144,216,288,0,0,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,72,144,216,288,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
void test_fuel_schedule_6_cylinder_4stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 6;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 6;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS >= 6
|
||||
const bool enabled[] = {true, true, true, true, true, true, false, false};
|
||||
const uint16_t angle[] = {0,120,240,360,480,600,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS >= 8
|
||||
const bool enabled[] = {true, true, true, true, true, true, false, false};
|
||||
const uint16_t angle[] = {0,120,240,360,480,600,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
configPage2.injLayout = INJ_SEMISEQUENTIAL;
|
||||
configPage10.stagingEnabled = true;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS >= 8
|
||||
const bool enabled[] = {true, true, true, true, true, true, true, true};
|
||||
const uint16_t angle[] = {0,120,240,0,0,120,240,0};
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, false, false, false, false, false};
|
||||
const uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
#endif
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_fuel_schedule_8_cylinder_4stroke(void)
|
||||
{
|
||||
configPage2.nCylinders = 8;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
configPage2.injTiming = true;
|
||||
configPage2.reqFuel = reqFuel;
|
||||
configPage2.divider = 8;
|
||||
|
||||
configPage2.injLayout = INJ_SEQUENTIAL;
|
||||
configPage10.stagingEnabled = false;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if INJ_CHANNELS >= 8
|
||||
const bool enabled[] = {true, true, true, true, true, true, true, true};
|
||||
const uint16_t angle[] = {0,90,180,270,360,450,540,630};
|
||||
assert_fuel_schedules(720U, reqFuel * 100U, enabled, angle);
|
||||
#else
|
||||
const bool enabled[] = {true, true, true, true, false, false, false, false};
|
||||
const uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_fuel_schedules(720U, reqFuel * 50U, enabled, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Staging not supported on 8 cylinders
|
||||
}
|
||||
|
||||
|
||||
void testFuelScheduleInit()
|
||||
{
|
||||
RUN_TEST(test_fuel_schedule_1_cylinder_4stroke);
|
||||
RUN_TEST(test_fuel_schedule_1_cylinder_2stroke);
|
||||
RUN_TEST(test_fuel_schedule_2_cylinder_4stroke);
|
||||
RUN_TEST(test_fuel_schedule_2_cylinder_2stroke);
|
||||
RUN_TEST(test_fuel_schedule_3_cylinder_4stroke);
|
||||
RUN_TEST(test_fuel_schedule_3_cylinder_2stroke);
|
||||
RUN_TEST(test_fuel_schedule_4_cylinder_4stroke);
|
||||
RUN_TEST(test_fuel_schedule_4_cylinder_2stroke);
|
||||
RUN_TEST(test_fuel_schedule_5_cylinder_4stroke);
|
||||
RUN_TEST(test_fuel_schedule_6_cylinder_4stroke);
|
||||
RUN_TEST(test_fuel_schedule_8_cylinder_4stroke);
|
||||
}
|
|
@ -0,0 +1,208 @@
|
|||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
#include "globals.h"
|
||||
#include "init.h"
|
||||
#include "schedule_calcs.h"
|
||||
|
||||
static void assert_ignition_schedules(uint16_t crankAngle, uint16_t expectedOutputs, uint16_t angle[])
|
||||
{
|
||||
char msg[48];
|
||||
|
||||
strcpy_P(msg, PSTR("CRANK_ANGLE_MAX_IGN"));
|
||||
TEST_ASSERT_EQUAL_INT16_MESSAGE(crankAngle, CRANK_ANGLE_MAX_IGN, msg);
|
||||
strcpy_P(msg, PSTR("maxIgnOutputs"));
|
||||
TEST_ASSERT_EQUAL_UINT16_MESSAGE(expectedOutputs, maxIgnOutputs, msg);
|
||||
|
||||
strcpy_P(msg, PSTR("channel1IgnDegrees"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(angle[0], channel1IgnDegrees, msg);
|
||||
strcpy_P(msg, PSTR("channel2IgnDegrees"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(angle[1], channel2IgnDegrees, msg);
|
||||
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
|
||||
strcpy_P(msg, PSTR("channel5IgnDegrees"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(angle[4], channel5IgnDegrees, msg);
|
||||
#endif
|
||||
#if IGN_CHANNELS>=6
|
||||
strcpy_P(msg, PSTR("channel6IgnDegrees"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(angle[5], channel6IgnDegrees, msg);
|
||||
#endif
|
||||
#if IGN_CHANNELS>=7
|
||||
strcpy_P(msg, PSTR("channel7IgnDegrees"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(angle[6], channel7IgnDegrees, msg);
|
||||
#endif
|
||||
#if IGN_CHANNELS>=8
|
||||
strcpy_P(msg, PSTR("channel8IgnDegrees"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(angle[7], channel8IgnDegrees, msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_1_cylinder(void)
|
||||
{
|
||||
configPage2.nCylinders = 1;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 1U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,0,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 1U, angle);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_2_cylinder(void)
|
||||
{
|
||||
configPage2.nCylinders = 2;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 2U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 2U, angle);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_3_cylinder(void)
|
||||
{
|
||||
configPage2.nCylinders = 3;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,240,480,0,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 3U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_4_cylinder(void)
|
||||
{
|
||||
configPage2.nCylinders = 4;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,360,540,0,0,0,0};
|
||||
assert_ignition_schedules(720U, 4U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,180,0,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 2U, angle);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_5_cylinder(void)
|
||||
{
|
||||
configPage2.nCylinders = 5;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,144,288,432,576,0,0,0};
|
||||
assert_ignition_schedules(720U, 5U, angle);
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,72,144,216,288,0,0,0};
|
||||
assert_ignition_schedules(360U, 5U, angle);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_6_cylinder(void)
|
||||
{
|
||||
configPage2.nCylinders = 6;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if IGN_CHANNELS >= 6
|
||||
uint16_t angle[] = {0,120,240,360,480,540,0,0};
|
||||
assert_ignition_schedules(720U, 6U, angle);
|
||||
#else
|
||||
uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,120,240,0,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 3U, angle);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_ignition_schedule_8_cylinder(void)
|
||||
{
|
||||
configPage2.nCylinders = 8;
|
||||
configPage2.strokes = FOUR_STROKE;
|
||||
configPage2.engineType = EVEN_FIRE;
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_SEQUENTIAL;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
#if IGN_CHANNELS >= 8
|
||||
uint16_t angle[] = {0,90,180,270,360,450,540,630};
|
||||
assert_ignition_schedules(720U, 8U, angle);
|
||||
#else
|
||||
uint16_t angle[] = {0,90,180,270,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 4U, angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
configPage4.sparkMode = IGN_MODE_WASTED;
|
||||
initialiseAll(); //Run the main initialise function
|
||||
{
|
||||
uint16_t angle[] = {0,90,180,270,0,0,0,0};
|
||||
assert_ignition_schedules(360U, 4U, angle);
|
||||
}
|
||||
}
|
||||
|
||||
void testIgnitionScheduleInit()
|
||||
{
|
||||
RUN_TEST(test_ignition_schedule_1_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_2_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_3_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_4_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_5_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_6_cylinder);
|
||||
RUN_TEST(test_ignition_schedule_8_cylinder);
|
||||
}
|
|
@ -0,0 +1,231 @@
|
|||
#include <unity.h>
|
||||
#include "globals.h"
|
||||
#include "init.h"
|
||||
|
||||
#define UNKNOWN_PIN 0xFF
|
||||
|
||||
#if !defined(NOT_A_PIN)
|
||||
#define NOT_A_PIN 0
|
||||
#endif
|
||||
|
||||
uint8_t getPinMode(uint8_t pin)
|
||||
{
|
||||
uint8_t bit = digitalPinToBitMask(pin);
|
||||
uint8_t port = digitalPinToPort(pin);
|
||||
|
||||
// I don't see an option for mega to return this, but whatever...
|
||||
if (NOT_A_PIN == port) return UNKNOWN_PIN;
|
||||
|
||||
// Is there a bit we can check?
|
||||
if (0 == bit) return UNKNOWN_PIN;
|
||||
|
||||
// Is there only a single bit set?
|
||||
if (bit & (bit - 1)) return UNKNOWN_PIN;
|
||||
|
||||
volatile uint8_t *reg, *out;
|
||||
reg = portModeRegister(port);
|
||||
out = portOutputRegister(port);
|
||||
|
||||
if (*reg & bit)
|
||||
return OUTPUT;
|
||||
else if (*out & bit)
|
||||
return INPUT_PULLUP;
|
||||
else
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
void test_initialisation_complete(void)
|
||||
{
|
||||
initialiseAll(); //Run the main initialise function
|
||||
TEST_ASSERT_EQUAL(true, initialisationComplete);
|
||||
}
|
||||
|
||||
void test_initialisation_ports(void)
|
||||
{
|
||||
//Test that all the port values have been set
|
||||
initialiseAll(); //Run the main initialise function
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj1_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj2_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj3_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj4_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign1_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign2_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign3_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign4_pin_port);
|
||||
}
|
||||
|
||||
//Test that all mandatory output pins have their mode correctly set to output
|
||||
void test_initialisation_outputs_V03(void)
|
||||
{
|
||||
configPage2.pinMapping = 2; //Set the board number to test
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
char msg[32];
|
||||
strcpy_P(msg, PSTR("Coil1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil1), msg);
|
||||
strcpy_P(msg, PSTR("Coil2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil2), msg);
|
||||
strcpy_P(msg, PSTR("Coil3"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil3), msg);
|
||||
strcpy_P(msg, PSTR("Coil4"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil4), msg);
|
||||
strcpy_P(msg, PSTR("Injector 1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector1), msg);
|
||||
strcpy_P(msg, PSTR("Injector 2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector2), msg);
|
||||
strcpy_P(msg, PSTR("Injector 3"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector3), msg);
|
||||
strcpy_P(msg, PSTR("Injector 4"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector4), msg);
|
||||
strcpy_P(msg, PSTR("Tacho Out"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinTachOut), msg);
|
||||
strcpy_P(msg, PSTR("Fuel Pump"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFuelPump), msg);
|
||||
strcpy_P(msg, PSTR("Fan"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFan), msg);
|
||||
}
|
||||
|
||||
//Test that all mandatory output pins have their mode correctly set to output
|
||||
void test_initialisation_outputs_V04(void)
|
||||
{
|
||||
configPage2.pinMapping = 3; //Set the board number to test
|
||||
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
char msg[32];
|
||||
strcpy_P(msg, PSTR("Coil1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil1), msg);
|
||||
strcpy_P(msg, PSTR("Coil2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil2), msg);
|
||||
strcpy_P(msg, PSTR("Coil3"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil3), msg);
|
||||
strcpy_P(msg, PSTR("Coil4"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil4), msg);
|
||||
strcpy_P(msg, PSTR("Injector 1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector1), msg);
|
||||
strcpy_P(msg, PSTR("Injector 2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector2), msg);
|
||||
strcpy_P(msg, PSTR("Injector 3"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector3), msg);
|
||||
strcpy_P(msg, PSTR("Injector 4"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector4), msg);
|
||||
strcpy_P(msg, PSTR("Tacho Out"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinTachOut), msg);
|
||||
strcpy_P(msg, PSTR("Fuel Pump"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFuelPump), msg);
|
||||
strcpy_P(msg, PSTR("Fan"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFan), msg);
|
||||
/*
|
||||
if(isIdlePWM)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle1), "Idle 1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle2), "Idle 2");
|
||||
}
|
||||
else if (isIdleStepper)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperDir), "Stepper Dir");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperStep), "Stepper Step");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperEnable), "Stepper Enable");
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFan), "Fan");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinBoost), "Boost");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_1), "VVT1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_2), "VVT2");
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
//Test that all mandatory output pins have their mode correctly set to output
|
||||
void test_initialisation_outputs_MX5_8995(void)
|
||||
{
|
||||
configPage2.pinMapping = 9; //Set the board number to test
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
char msg[32];
|
||||
strcpy_P(msg, PSTR("Coil1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil1), msg);
|
||||
strcpy_P(msg, PSTR("Coil2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil2), msg);
|
||||
strcpy_P(msg, PSTR("Coil3"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil3), msg);
|
||||
strcpy_P(msg, PSTR("Coil4"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil4), msg);
|
||||
strcpy_P(msg, PSTR("Injector 1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector1), msg);
|
||||
strcpy_P(msg, PSTR("Injector 2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector2), msg);
|
||||
strcpy_P(msg, PSTR("Injector 3"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector3), msg);
|
||||
strcpy_P(msg, PSTR("Injector 4"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector4), msg);
|
||||
strcpy_P(msg, PSTR("Tacho Out"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinTachOut), msg);
|
||||
strcpy_P(msg, PSTR("Fuel Pump"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFuelPump), msg);
|
||||
strcpy_P(msg, PSTR("Fan"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFan), msg);
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_PWM_idle(void)
|
||||
{
|
||||
configPage2.pinMapping = 3; //Set the board number to test (v0.4)
|
||||
//Force 2 channel PWM idle
|
||||
configPage6.iacChannels = 1;
|
||||
configPage6.iacAlgorithm = 2;
|
||||
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
bool isIdlePWM = (configPage6.iacAlgorithm > 0) && ((configPage6.iacAlgorithm <= 3) || (configPage6.iacAlgorithm == 6));
|
||||
|
||||
char msg[32];
|
||||
strcpy_P(msg, PSTR("Is PWM Idle"));
|
||||
TEST_ASSERT_TRUE_MESSAGE(isIdlePWM, msg);
|
||||
strcpy_P(msg, PSTR("Idle 1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle1), msg);
|
||||
strcpy_P(msg, PSTR("Idle 2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle2), msg);
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_stepper_idle(void)
|
||||
{
|
||||
bool isIdleStepper = (configPage6.iacAlgorithm > 3) && (configPage6.iacAlgorithm != 6);
|
||||
|
||||
char msg[32];
|
||||
strcpy_P(msg, PSTR("Is Stepper Idle"));
|
||||
TEST_ASSERT_TRUE_MESSAGE(isIdleStepper, msg);
|
||||
strcpy_P(msg, PSTR("Stepper Dir"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperDir), msg);
|
||||
strcpy_P(msg, PSTR("Stepper Step"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperStep), msg);
|
||||
strcpy_P(msg, PSTR("Stepper Enable"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperEnable), msg);
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_boost(void)
|
||||
{
|
||||
char msg[32];
|
||||
strcpy_P(msg, PSTR("Boost"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinBoost), msg);
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_VVT(void)
|
||||
{
|
||||
char msg[32];
|
||||
strcpy_P(msg, PSTR("VVT1"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_1), msg);
|
||||
strcpy_P(msg, PSTR("VVT2"));
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_2), msg);
|
||||
}
|
||||
|
||||
void testInitialisation()
|
||||
{
|
||||
RUN_TEST(test_initialisation_complete);
|
||||
RUN_TEST(test_initialisation_ports);
|
||||
RUN_TEST(test_initialisation_outputs_V03);
|
||||
RUN_TEST(test_initialisation_outputs_V04);
|
||||
RUN_TEST(test_initialisation_outputs_MX5_8995);
|
||||
RUN_TEST(test_initialisation_outputs_PWM_idle);
|
||||
RUN_TEST(test_initialisation_outputs_boost);
|
||||
RUN_TEST(test_initialisation_outputs_VVT);
|
||||
}
|
|
@ -1,181 +0,0 @@
|
|||
#include <unity.h>
|
||||
#include "globals.h"
|
||||
#include "init.h"
|
||||
#include "tests_init.h"
|
||||
|
||||
|
||||
void testInitialisation()
|
||||
{
|
||||
RUN_TEST(test_initialisation_complete);
|
||||
RUN_TEST(test_initialisation_ports);
|
||||
RUN_TEST(test_initialisation_outputs_V03);
|
||||
RUN_TEST(test_initialisation_outputs_V04);
|
||||
RUN_TEST(test_initialisation_outputs_MX5_8995);
|
||||
RUN_TEST(test_initialisation_outputs_PWM_idle);
|
||||
RUN_TEST(test_initialisation_outputs_boost);
|
||||
RUN_TEST(test_initialisation_outputs_VVT);
|
||||
}
|
||||
|
||||
void test_initialisation_complete(void)
|
||||
{
|
||||
initialiseAll(); //Run the main initialise function
|
||||
TEST_ASSERT_EQUAL(true, initialisationComplete);
|
||||
}
|
||||
|
||||
void test_initialisation_ports(void)
|
||||
{
|
||||
//Test that all the port values have been set
|
||||
initialiseAll(); //Run the main initialise function
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj1_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj2_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj3_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, inj4_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign1_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign2_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign3_pin_port);
|
||||
TEST_ASSERT_NOT_EQUAL(0, ign4_pin_port);
|
||||
}
|
||||
|
||||
//Test that all mandatory output pins have their mode correctly set to output
|
||||
void test_initialisation_outputs_V03(void)
|
||||
{
|
||||
configPage2.pinMapping = 2; //Set the board number to test
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil1), "Coil1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil2), "Coil2");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil3), "Coil3");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil4), "Coil4");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector1), "Injector 1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector2), "Injector 2");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector3), "Injector 3");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector4), "Injector 4");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinTachOut), "Tacho Out");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFuelPump), "Fuel Pump");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFan), "Fan");
|
||||
|
||||
}
|
||||
|
||||
//Test that all mandatory output pins have their mode correctly set to output
|
||||
void test_initialisation_outputs_V04(void)
|
||||
{
|
||||
configPage2.pinMapping = 3; //Set the board number to test
|
||||
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil1), "Coil1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil2), "Coil2");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil3), "Coil3");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil4), "Coil4");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector1), "Injector 1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector2), "Injector 2");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector3), "Injector 3");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector4), "Injector 4");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinTachOut), "Tacho Out");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFuelPump), "Fuel Pump");
|
||||
/*
|
||||
if(isIdlePWM)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle1), "Idle 1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle2), "Idle 2");
|
||||
}
|
||||
else if (isIdleStepper)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperDir), "Stepper Dir");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperStep), "Stepper Step");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperEnable), "Stepper Enable");
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFan), "Fan");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinBoost), "Boost");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_1), "VVT1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_2), "VVT2");
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
//Test that all mandatory output pins have their mode correctly set to output
|
||||
void test_initialisation_outputs_MX5_8995(void)
|
||||
{
|
||||
configPage2.pinMapping = 9; //Set the board number to test
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil1), "Coil1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil2), "Coil2");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil3), "Coil3");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinCoil4), "Coil4");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector1), "Injector 1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector2), "Injector 2");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector3), "Injector 3");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinInjector4), "Injector 4");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinTachOut), "Tacho Out");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFuelPump), "Fuel Pump");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinFan), "Fan");
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_PWM_idle(void)
|
||||
{
|
||||
configPage2.pinMapping = 3; //Set the board number to test (v0.4)
|
||||
//Force 2 channel PWM idle
|
||||
configPage6.iacChannels = 1;
|
||||
configPage6.iacAlgorithm = 2;
|
||||
|
||||
initialiseAll(); //Run the main initialise function
|
||||
|
||||
bool isIdlePWM = (configPage6.iacAlgorithm > 0) && ((configPage6.iacAlgorithm <= 3) || (configPage6.iacAlgorithm == 6));
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(isIdlePWM, "Is PWM Idle");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle1), "Idle 1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinIdle2), "Idle 2");
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_stepper_idle(void)
|
||||
{
|
||||
bool isIdleStepper = (configPage6.iacAlgorithm > 3) && (configPage6.iacAlgorithm != 6);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(isIdleStepper, "Is Stepper Idle");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperDir), "Stepper Dir");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperStep), "Stepper Step");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinStepperEnable), "Stepper Enable");
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_boost(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinBoost), "Boost");
|
||||
}
|
||||
|
||||
void test_initialisation_outputs_VVT(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_1), "VVT1");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(OUTPUT, getPinMode(pinVVT_2), "VVT2");
|
||||
}
|
||||
|
||||
#if !defined(NOT_A_PIN)
|
||||
#define NOT_A_PIN 0
|
||||
#endif
|
||||
|
||||
uint8_t getPinMode(uint8_t pin)
|
||||
{
|
||||
uint8_t bit = digitalPinToBitMask(pin);
|
||||
uint8_t port = digitalPinToPort(pin);
|
||||
|
||||
// I don't see an option for mega to return this, but whatever...
|
||||
if (NOT_A_PIN == port) return UNKNOWN_PIN;
|
||||
|
||||
// Is there a bit we can check?
|
||||
if (0 == bit) return UNKNOWN_PIN;
|
||||
|
||||
// Is there only a single bit set?
|
||||
if (bit & (bit - 1)) return UNKNOWN_PIN;
|
||||
|
||||
volatile uint8_t *reg, *out;
|
||||
reg = portModeRegister(port);
|
||||
out = portOutputRegister(port);
|
||||
|
||||
if (*reg & bit)
|
||||
return OUTPUT;
|
||||
else if (*out & bit)
|
||||
return INPUT_PULLUP;
|
||||
else
|
||||
return INPUT;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
#define UNKNOWN_PIN 0xFF
|
||||
|
||||
extern void testInitialisation();
|
||||
void test_initialisation_complete(void);
|
||||
void test_initialisation_ports(void);
|
||||
void test_initialisation_outputs_V03(void);
|
||||
void test_initialisation_outputs_V04(void);
|
||||
void test_initialisation_outputs_MX5_8995(void);
|
||||
void test_initialisation_outputs_PWM_idle(void);
|
||||
void test_initialisation_outputs_stepper_idle(void);
|
||||
void test_initialisation_outputs_boost(void);
|
||||
void test_initialisation_outputs_VVT(void);
|
||||
uint8_t getPinMode(uint8_t);
|
|
@ -1,7 +1,6 @@
|
|||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
|
||||
#include "tests_init.h"
|
||||
#include "tests_tables.h"
|
||||
#include "test_table2d.h"
|
||||
|
||||
|
@ -17,7 +16,6 @@ void setup()
|
|||
|
||||
UNITY_BEGIN(); // IMPORTANT LINE!
|
||||
|
||||
testInitialisation();
|
||||
testTables();
|
||||
testTable2d();
|
||||
|
Loading…
Reference in New Issue