Commit Graph

1 Commits

Author SHA1 Message Date
tx_haggis a4bbce63c3
Sensors.cpp: MISRA fixes & reduce conditional compilation blocks (#1157)
* Bug fix - consistent #ifdef (ANALOG_ISR/ANALOG_ISR_MAP)
Also  replace multiple #ifdefs with inline function.

* MISRA fixes for sensor.cpp

* Conditional compile to allow MAP sensor read pin even when using analog ISR
Useful for development testing

* Remove unused global variables
statuses::batADC
fpPrimed - duplicate of statuses::fpPrimed
injPrimed - duplicate of statuses::injPrimed

* Replace duplicate filter macros with one inline function: LOW_PASS_FILTER (which is MISRA compliant).

* Remove mapErrorCount - it's unused
(only ever written to, never read)

* Deduplicate MAP reading code

* Encapsulate MAP variables

* Add isEngineRunning() to capture duplicate code

* Make readBaro() independent of instanteneousMAPReading()
Removes a conditional and reduces module surafce area

* Use structs to capture the MAP algorithm state.
Also apply ATOMIC_BLOCK to prevent tearing of ISR modified variables.

* Force loop() inline
Reduces stack usage.

* Use 16-bit comparisons

* Remove validateMAP() - since we validate every sensor reading, it wasn't doing anything.

* Unit test engineIsRunning

* Apply SET_UNITY_FILENAME to K6A unit tests

* Unit test LOW_PASS_FILTER

* Unit test fastMap10Bit

* Reduce scope of MAP ADC variables - only used in sensors.cpp

* MAP: read the sensors in one place in the code & inject the values into the sampling algorithms

* MAP: encapsulate reset of state structures

* MAP: replace magic numbers wirth an enum

* MAP algorithms return a flag indicting whether they recomputed MAP/EMAP

* MAP sampling algorithms: push MAP value calculation up the call stack.

* Remove errors.* - it's never called an uses up RAM

* Unit Test: inject all MAP sampling algorithm dependencies

* Unit test MAP sampling algorithms

* Unit test validateFilterMapSensorReading

* Prevent torn reads during comparisons

* Don't skip readings on cycle/event boundaries
2024-10-01 12:22:29 +10:00