forked from speeduino/speeduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suzuki k6a fix & "improvements" (speeduino#1174)
* Add unit tests for triggerSetEndTeeth_SuzukiK6A * Bug fix - use correct parameter when calling stdGetRPM * Compute triggerToothAngle from the fixed tooth angle array. * triggerSetEndTeeth_SuzukiK6A - hoist duplicated code into calcEndTeeth_SuzukiK6A (like we did for some other decoders). * MISRA fixes for Suzuki K6A decoder
- Loading branch information
1 parent
8afead9
commit 4c29faa
Showing
5 changed files
with
404 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
void testSuzukiK6A_setEndTeeth(void); | ||
void testSuzukiK6A_getCrankAngle(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <unity.h> | ||
#include "decoders.h" | ||
#include "init.h" | ||
|
||
static void test_k6a_getCrankAngle_tooth(uint8_t toothNum, uint16_t expectedCrankAngle, uint16_t expectedToothAngle) { | ||
triggerSetup_SuzukiK6A(); | ||
configPage4.triggerAngle = 0U; | ||
|
||
toothLastToothTime = micros() - 150U; | ||
toothCurrentCount = toothNum; | ||
// Allow some variance since the algorithm relies on calling micros(); | ||
TEST_ASSERT_INT16_WITHIN_MESSAGE(2, expectedCrankAngle, getCrankAngle_SuzukiK6A(), "Crank Angle"); | ||
TEST_ASSERT_EQUAL_MESSAGE(expectedToothAngle, triggerToothAngle, "Tooth Angle"); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth0(void) { | ||
// Zero isn't a valid tooth, but just in case.... | ||
test_k6a_getCrankAngle_tooth(0, 650, 90); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth1(void) { | ||
test_k6a_getCrankAngle_tooth(1, 0, 70); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth2(void) { | ||
test_k6a_getCrankAngle_tooth(2, 170, 170); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth3(void) { | ||
test_k6a_getCrankAngle_tooth(3, 240, 70); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth4(void) { | ||
test_k6a_getCrankAngle_tooth(4, 410, 170); | ||
} | ||
|
||
|
||
static void test_k6a_getCrankAngle_tooth5(void) { | ||
test_k6a_getCrankAngle_tooth(5, 480, 70); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth6(void) { | ||
test_k6a_getCrankAngle_tooth(6, 515, 35); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth7(void) { | ||
test_k6a_getCrankAngle_tooth(7, 650, 135); | ||
} | ||
|
||
static void test_k6a_getCrankAngle_tooth8(void) { | ||
// 8 isn't a valid tooth, but just in case.... | ||
test_k6a_getCrankAngle_tooth(8, 0, 70); | ||
} | ||
|
||
void testSuzukiK6A_getCrankAngle() | ||
{ | ||
RUN_TEST(test_k6a_getCrankAngle_tooth0); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth1); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth2); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth3); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth4); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth5); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth6); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth7); | ||
RUN_TEST(test_k6a_getCrankAngle_tooth8); | ||
} |
Oops, something went wrong.