diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 81deb928ad..9d5b140a70 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -38,6 +38,7 @@ // return interpolate(500, 0.5, 5000, 1.1, rpm); //} + /** * @return number of milliseconds in one crankshaft revolution */ @@ -101,8 +102,7 @@ int isCrankingRT(engine_configuration_s *engineConfiguration, int rpm) { return rpm > 0 && rpm < engineConfiguration->crankingSettings.crankingRpm; } -OutputSignalList injectonSignals CCM_OPTIONAL -; +OutputSignalList injectonSignals CCM_OPTIONAL; static void registerSparkEvent(engine_configuration_s const *engineConfiguration, trigger_shape_s * s, IgnitionEventList *list, io_pin_e pin, float localAdvance, float dwell) { @@ -131,8 +131,8 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura // todo: extract method float localAdvance = advance + 720.0f * i / engineConfiguration->cylindersCount; - registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, SPARKOUT_1_OUTPUT, - localAdvance, dwellAngle); + registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, + SPARKOUT_1_OUTPUT, localAdvance, dwellAngle); } break; case IM_WASTED_SPARK: @@ -144,8 +144,8 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura int id = getCylinderId(engineConfiguration->firingOrder, wastedIndex) - 1; io_pin_e ioPin = (io_pin_e) (SPARKOUT_1_OUTPUT + id); - registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, ioPin, localAdvance, - dwellAngle); + registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, + ioPin, localAdvance, dwellAngle); } @@ -155,8 +155,8 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura float localAdvance = advance + 720.0f * i / engineConfiguration->cylindersCount; io_pin_e pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + getCylinderId(engineConfiguration->firingOrder, i) - 1); - registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, pin, localAdvance, - dwellAngle); + registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, pin, + localAdvance, dwellAngle); } break; @@ -165,8 +165,12 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura } } -static void registerInjectionEvent(engine_configuration_s const *e, trigger_shape_s *s, ActuatorEventList *list, - io_pin_e pin, float angle) { +static void registerInjectionEvent(engine_configuration_s const *e, + trigger_shape_s *s, + ActuatorEventList *list, + io_pin_e pin, + float angle + ) { registerActuatorEventExt(e, s, list->getNextActuatorEvent(), injectonSignals.add(pin), angle); } @@ -248,6 +252,8 @@ void findTriggerPosition(engine_configuration_s const *engineConfiguration, trig int engineCycleEventCount = getEngineCycleEventCount(engineConfiguration, s); + efiAssertVoid(engineCycleEventCount > 0, "engineCycleEventCount"); + uint32_t middle; uint32_t left = 0; uint32_t right = engineCycleEventCount - 1; @@ -261,7 +267,7 @@ void findTriggerPosition(engine_configuration_s const *engineConfiguration, trig if (middle == left) { break; - } + } if (angleOffset < s->eventAngles[middle]) { right = middle; @@ -290,9 +296,9 @@ void registerActuatorEventExt(engine_configuration_s const *engineConfiguration, efiAssertVoid(s->getSize() > 0, "uninitialized trigger_shape_s"); if (e == NULL) { - // error already reported + // error already reported return; - } + } e->actuator = actuator; findTriggerPosition(engineConfiguration, s, &e->position, angleOffset); @@ -302,7 +308,7 @@ static int order_1_THEN_3_THEN_4_THEN2[] = { 1, 3, 4, 2 }; static int order_1_THEN_5_THEN_3_THEN_6_THEN_2_THEN_4[] = { 1, 5, 3, 6, 2, 4 }; -static int order_1_8_4_3_6_5_7_2[] = { 1, 8, 4, 3, 6, 5, 7, 2 }; +static int order_1_8_4_3_6_5_7_2[] = {1, 8, 4, 3, 6, 5, 7, 2}; /** * @param index from zero to cylindersCount - 1 diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index a86db4eb42..89fb4ba261 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -118,7 +118,7 @@ static void handleFuel(Engine *engine, MainTriggerCallback *mainTriggerCallback, } } -static void handleSparkEvent(MainTriggerCallback *mainTriggerCallback, int eventIndex, IgnitionEvent *iEvent, int rpm) { +static void handleSparkEvent(MainTriggerCallback *mainTriggerCallback, uint32_t eventIndex, IgnitionEvent *iEvent, int rpm) { engine_configuration_s *engineConfiguration = mainTriggerCallback->engineConfiguration; engine_configuration2_s *engineConfiguration2 = mainTriggerCallback->engineConfiguration2; @@ -182,7 +182,7 @@ static void handleSparkEvent(MainTriggerCallback *mainTriggerCallback, int event } } -static void handleSpark(MainTriggerCallback *mainTriggerCallback, int eventIndex, int rpm, IgnitionEventList *list) { +static void handleSpark(MainTriggerCallback *mainTriggerCallback, uint32_t eventIndex, int rpm, IgnitionEventList *list) { if (!isValidRpm(rpm) || !mainTriggerCallback->engineConfiguration->isIgnitionEnabled) return; // this might happen for instance in case of a single trigger event after a pause diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index 57d554e329..e69c3d2bbc 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -55,8 +55,10 @@ public: * Total count of shaft events per CAM or CRANK shaft revolution. * TODO this should be migrated to CRANKshaft revolution, this would go together * TODO with eliminating RPM_MULT magic constant + * + * todo: somehow changing the type of this to uint32_t breaks unit tests? WHY? */ - uint32_t shaftPositionEventCount; + int shaftPositionEventCount; /** * this one is per CRANKshaft revolution diff --git a/firmware/svnversion.h b/firmware/svnversion.h index 3e5ff8792a..c5e408ea51 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Fri Sep 12 10:36:39 EDT 2014 +// Wed Sep 24 12:19:23 EDT 2014 #ifndef VCS_VERSION -#define VCS_VERSION "4660" +#define VCS_VERSION "4756" #endif diff --git a/firmware/util/efilib.cpp b/firmware/util/efilib.cpp index 6e6c4f47f6..3f048dca9b 100644 --- a/firmware/util/efilib.cpp +++ b/firmware/util/efilib.cpp @@ -49,7 +49,7 @@ float maxF(float i1, float i2) { return i1 > i2 ? i1 : i2; } -int efiStrlen(const char *param) { +uint32_t efiStrlen(const char *param) { return strlen(param); } diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 9ab2dc6736..59fe61aae2 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -33,7 +33,7 @@ extern "C" const char * boolToString(bool value); -int efiStrlen(const char *param); +uint32_t efiStrlen(const char *param); int indexOf(const char *string, char ch); float atoff(const char *string); int atoi(const char *string);