From 249178cb49c98134adc5017de963ab681c296f5c Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 15 Jan 2024 20:36:44 -0500 Subject: [PATCH] only:Lamborghini Diablo 1995 CKP Pattern #5876 --- .../trigger/decoders/trigger_structure.cpp | 15 ++++++++++----- firmware/controllers/trigger/trigger_central.cpp | 9 ++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 7e5395b9a4..3fd7846571 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -110,9 +110,12 @@ angle_t TriggerWaveform::getCycleDuration() const { case FOUR_STROKE_CRANK_SENSOR: case TWO_STROKE: return TWO_STROKE_CYCLE_DURATION; - default: + case OM_NONE: + case FOUR_STROKE_CAM_SENSOR: return FOUR_STROKE_CYCLE_DURATION; } + criticalError("unreachable getCycleDuration"); + return 0; } bool TriggerWaveform::needsDisambiguation() const { @@ -120,15 +123,17 @@ bool TriggerWaveform::needsDisambiguation() const { case FOUR_STROKE_CRANK_SENSOR: case FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR: case FOUR_STROKE_THREE_TIMES_CRANK_SENSOR: + case FOUR_STROKE_SIX_TIMES_CRANK_SENSOR: case FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR: return true; case FOUR_STROKE_CAM_SENSOR: case TWO_STROKE: + case OM_NONE: return false; - default: - criticalError("bad operationMode() in needsDisambiguation"); - return true; + /* let's NOT handle default in order to benefit from -Werror=switch */ } + criticalError("unreachable needsDisambiguation"); + return true; } /** @@ -712,7 +717,7 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperatio break; case trigger_type_e::TT_6_TOOTH_CRANK: - configure3ToothCrank(this); + configure6ToothCrank(this); break; case trigger_type_e::TT_12_TOOTH_CRANK: diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index a7debc1610..8b8b9a6f7d 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -108,12 +108,19 @@ int getCrankDivider(operation_mode_e operationMode) { return SYMMETRICAL_SIX_TIMES_CRANK_SENSOR_DIVIDER; case FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR: return SYMMETRICAL_TWELVE_TIMES_CRANK_SENSOR_DIVIDER; - default: + case OM_NONE: case FOUR_STROKE_CAM_SENSOR: case TWO_STROKE: // That's easy - trigger cycle matches engine cycle return 1; + /* let's NOT handle default in order to benefit from -Werror=switch */ } + /** + wow even while we explicitly handle all enumerations in the switch above we still need a return statement due to + https://stackoverflow.com/questions/34112483/gcc-how-best-to-handle-warning-about-unreachable-end-of-function-after-switch + */ + criticalError("unreachable getCrankDivider"); + return 1; } static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {