![]() |
Speeduino
|
#include "sensors.h"#include "crankMaths.h"#include "globals.h"#include "maths.h"#include "storage.h"#include "comms.h"#include "idle.h"#include "corrections.h"#include "pages.h"#include "decoder_init.h"#include "auxiliaries.h"#include "elapsed_time.h"#include "unit_testing.h"#include "sensors_map_structs.h"#include "units.h"#include "atomic.h"#include "board_definition.h"#include "preprocessor.h"#include "static_for.hpp"#include "polling.hpp"#include "decoders.h"#include "src/pins/boardInputPin.h"#include "src/pins/pinMapping.h"Functions | |
| TESTABLE_INLINE_STATIC int16_t | fastMap10Bit (uint16_t value, int16_t rangeMin, int16_t rangeMax) |
| A specialist function to map a value in the range [0, 1023] (I.e. 10-bit) to a different range. | |
| TESTABLE_STATIC int16_t | postProcessAnalogRead (int16_t pinValue) |
| static uint16_t | readAnalogPin (uint8_t pin) |
| static uint16_t | readAnalogSensor (uint8_t pin) |
| static uint16_t | readMAPSensor (uint8_t pin) |
| void | initialiseADC (void) |
| TESTABLE_INLINE_STATIC bool | instanteneousMAPReading (void) |
| static bool | cycleAverageMAPReadingAccumulate (map_cycle_average_t &cycle_average, const map_adc_readings_t &sensorReadings) |
| static void | reset (const statuses ¤t, map_cycle_average_t &cycle_average, const map_adc_readings_t &sensorReadings) |
| static bool | cycleAverageEndCycle (const statuses ¤t, map_cycle_average_t &cycle_average, map_adc_readings_t &sensorReadings) |
| static bool | isCycleCurrent (const statuses ¤t, uint32_t cycleStartIndex) |
| static bool | isCycleCurrent (const statuses ¤t, const map_cycle_average_t &cycle_avg) |
| TESTABLE_INLINE_STATIC bool | canUseCycleAverage (const statuses ¤t, const config2 &page2) |
| TESTABLE_INLINE_STATIC bool | cycleAverageMAPReading (const statuses ¤t, const config2 &page2, map_cycle_average_t &cycle_average, map_adc_readings_t &sensorReadings) |
| static bool | cycleMinimumAccumulate (map_cycle_min_t &cycle_min, const map_adc_readings_t &sensorReadings) |
| static void | reset (const statuses ¤t, map_cycle_min_t &cycle_min, const map_adc_readings_t &sensorReadings) |
| static bool | cycleMinimumEndCycle (const statuses ¤t, map_cycle_min_t &cycle_min, map_adc_readings_t &sensorReadings) |
| static bool | isCycleCurrent (const statuses ¤t, const map_cycle_min_t &cycle_min) |
| TESTABLE_INLINE_STATIC bool | cycleMinimumMAPReading (const statuses ¤t, const config2 &page2, map_cycle_min_t &cycle_min, map_adc_readings_t &sensorReadings) |
| static bool | eventAverageAccumulate (map_event_average_t &eventAverage, const map_adc_readings_t &sensorReadings) |
| static bool | isIgnitionEventValid (const map_event_average_t &eventAverage) |
| static void | reset (map_event_average_t &eventAverage, const map_adc_readings_t &sensorReadings) |
| static bool | eventAverageEndEvent (map_event_average_t &eventAverage, map_adc_readings_t &sensorReadings) |
| static bool | isIgnitionEventCurrent (const map_event_average_t &eventAverage) |
| TESTABLE_INLINE_STATIC bool | canUseEventAverage (const statuses ¤t, const config2 &page2) |
| TESTABLE_INLINE_STATIC bool | eventAverageMAPReading (const statuses ¤t, const config2 &page2, map_event_average_t &eventAverage, map_adc_readings_t &sensorReadings) |
| static bool | isValidMapSensorReading (uint16_t reading) |
| TESTABLE_INLINE_STATIC uint16_t | validateFilterMapSensorReading (uint16_t reading, uint8_t alpha, uint16_t prior) |
| static uint16_t | readFilteredMapADC (uint8_t pin, uint8_t alpha, uint16_t prior) |
| static map_adc_readings_t | readMapSensors (const map_adc_readings_t &previousReadings, const config4 &page4, bool useEMAP) |
| TESTABLE_INLINE_STATIC void | storeLastMAPReadings (uint32_t currTime, map_last_read_t &lastRead, uint16_t oldMAPValue) |
| static uint16_t | mapADCToMAP (uint16_t mapADC, int8_t mapMin, uint16_t mapMax) |
| TESTABLE_INLINE_STATIC void | setMAPValuesFromReadings (const map_adc_readings_t &readings, const config2 &page2, bool useEMAP, statuses ¤t) |
| TESTABLE_INLINE_STATIC bool | applyMapAlgorithm (const config2 &page2, const statuses ¤t, map_algorithm_t &algorithmState) |
| static void | readMAP (void) |
| int16_t | getMAPDelta (void) |
| Get the MAP change between the last 2 readings. | |
| uint32_t | getMAPDeltaTime (void) |
| Get the time in µS between the last 2 MAP readings. | |
| static bool | isCTPSSensorActive (void) |
| static void | readTPS (uint8_t tpsADC) |
| static void | readTPS (void) |
| void | initialiseTPS (void) |
| Initial reading of the TPS sensor, primarily to detect flood clear state. | |
| static void | readCLT (void) |
| void | initialiseCLT (void) |
| Initial reading of the coolant sensor, primarily to make sure the priming pulsewidth is correct. | |
| static void | readIAT (void) |
| TESTABLE_INLINE_STATIC bool | isValidBaro (uint16_t baro) |
| static void | setBaroFromSensorReading (uint16_t sensorReading) |
| static void | setBaroFromMAP (void) |
| static void | readBaro (void) |
| void | initialiseMAPBaro (void) |
| Initialize the MAP calculation & Baro values. | |
| void | resetMAPcycleAndEvent (void) |
| static void | readO2_1 (void) |
| static void | readO2_2 (void) |
| static void | readO2 (void) |
| static void | readBat (void) |
| uint32_t | vssGetPulseGap (uint8_t historyIndex) |
| Returns the VSS pulse gap for a given history point. | |
| static uint16_t | getSpeed (void) |
| static void | readSpeed (void) |
| static byte | getGear (void) |
| static void | readGear (void) |
| static byte | getFuelPressure (void) |
| static void | updateFuelPressure (void) |
| static byte | getOilPressure (void) |
| static void | updateOilPressure (void) |
| BEGIN_LTO_ALWAYS_INLINE (void) readPolledSensors(byte loopTimer) | |
| uint8_t | getAnalogKnock (void) |
| void | flexPulse (void) |
| void | initialiseFlexSensor (config2 &page2, statuses ¤t, uint8_t pin) |
| void | knockPulse (void) |
| void | vssPulse (void) |
| The ISR function for VSS pulses. | |
| uint16_t | readAuxanalog (uint8_t analogPin) |
| uint16_t | readAuxdigital (uint8_t digitalPin) |
Variables | |
| uint8_t | statusSensors = 0 |
| static volatile uint32_t | vssTimes [VSS_SAMPLES] = {0} |
| static volatile uint8_t | vssIndex = 0U |
| volatile uint8_t | flexCounter = 0U |
| static volatile uint32_t | flexStartTime = 0UL |
| volatile uint32_t | flexPulseWidth = 0U |
| static map_algorithm_t | mapAlgorithmState |
| static uint16_t | cltCalibration_bins [32] |
| static uint8_t | cltCalibration_values [32] |
| static uint16_t | iatCalibration_bins [32] |
| static uint8_t | iatCalibration_values [32] |
| static uint16_t | o2Calibration_bins [32] |
| static uint8_t | o2Calibration_values [32] |
| static constexpr uint16_t | VALID_MAP_MAX =1022U |
| static constexpr uint16_t | VALID_MAP_MIN =2U |
| static boardInputPin_t | flex_pin |
Read sensors with appropriate timing / scheduling.
| TESTABLE_INLINE_STATIC bool applyMapAlgorithm | ( | const config2 & | page2, |
| const statuses & | current, | ||
| map_algorithm_t & | algorithmState | ||
| ) |


| BEGIN_LTO_ALWAYS_INLINE | ( | void | ) |

| TESTABLE_INLINE_STATIC bool canUseCycleAverage | ( | const statuses & | current, |
| const config2 & | page2 | ||
| ) |

| TESTABLE_INLINE_STATIC bool canUseEventAverage | ( | const statuses & | current, |
| const config2 & | page2 | ||
| ) |

|
inlinestatic |


| TESTABLE_INLINE_STATIC bool cycleAverageMAPReading | ( | const statuses & | current, |
| const config2 & | page2, | ||
| map_cycle_average_t & | cycle_average, | ||
| map_adc_readings_t & | sensorReadings | ||
| ) |


|
inlinestatic |

|
inlinestatic |


|
inlinestatic |


| TESTABLE_INLINE_STATIC bool cycleMinimumMAPReading | ( | const statuses & | current, |
| const config2 & | page2, | ||
| map_cycle_min_t & | cycle_min, | ||
| map_adc_readings_t & | sensorReadings | ||
| ) |


|
inlinestatic |

|
inlinestatic |


| TESTABLE_INLINE_STATIC bool eventAverageMAPReading | ( | const statuses & | current, |
| const config2 & | page2, | ||
| map_event_average_t & | eventAverage, | ||
| map_adc_readings_t & | sensorReadings | ||
| ) |


| TESTABLE_INLINE_STATIC int16_t fastMap10Bit | ( | uint16_t | value, |
| int16_t | rangeMin, | ||
| int16_t | rangeMax | ||
| ) |
A specialist function to map a value in the range [0, 1023] (I.e. 10-bit) to a different range.
Mostly used for analog input voltage level to real world value conversions.
analogRead returns a number in the range [0, 1023], representing the pin input voltage from min to max (typically 0V - 5V) We need to convert that value to the real world value the sensor is reading (pressure, temperature etc.) If:
then this function will return the real world measurement (kPa, °C etc)
| value | Value to map (should be in range [0, 1023]) |
| rangeMin | Minimum of the output range |
| rangeMax | Maximum of the output range |

| void flexPulse | ( | void | ) |


| uint8_t getAnalogKnock | ( | void | ) |


|
inlinestatic |


|
inlinestatic |

| int16_t getMAPDelta | ( | void | ) |
Get the MAP change between the last 2 readings.

| uint32_t getMAPDeltaTime | ( | void | ) |
Get the time in µS between the last 2 MAP readings.

|
inlinestatic |


|
inlinestatic |


| void initialiseADC | ( | void | ) |
Init all ADC conversions by setting resolutions, etc.


| void initialiseCLT | ( | void | ) |
Initial reading of the coolant sensor, primarily to make sure the priming pulsewidth is correct.




| void initialiseMAPBaro | ( | void | ) |
Initialize the MAP calculation & Baro values.


| void initialiseTPS | ( | void | ) |
Initial reading of the TPS sensor, primarily to detect flood clear state.


| TESTABLE_INLINE_STATIC bool instanteneousMAPReading | ( | void | ) |

|
inlinestatic |

|
inlinestatic |

|
inlinestatic |

|
inlinestatic |

|
inlinestatic |

|
inlinestatic |

| TESTABLE_INLINE_STATIC bool isValidBaro | ( | uint16_t | baro | ) |

|
inlinestatic |

| void knockPulse | ( | void | ) |

|
inlinestatic |


| TESTABLE_STATIC int16_t postProcessAnalogRead | ( | int16_t | pinValue | ) |

|
inlinestatic |


|
inlinestatic |


| uint16_t readAuxanalog | ( | uint8_t | analogPin | ) |


| uint16_t readAuxdigital | ( | uint8_t | digitalPin | ) |

|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |


|
inlinestatic |

|
inlinestatic |


|
inlinestatic |


|
inlinestatic |
|
inlinestatic |

| void resetMAPcycleAndEvent | ( | void | ) |

|
inlinestatic |


|
inlinestatic |


| TESTABLE_INLINE_STATIC void setMAPValuesFromReadings | ( | const map_adc_readings_t & | readings, |
| const config2 & | page2, | ||
| bool | useEMAP, | ||
| statuses & | current | ||
| ) |


| TESTABLE_INLINE_STATIC void storeLastMAPReadings | ( | uint32_t | currTime, |
| map_last_read_t & | lastRead, | ||
| uint16_t | oldMAPValue | ||
| ) |

|
inlinestatic |


|
inlinestatic |


| TESTABLE_INLINE_STATIC uint16_t validateFilterMapSensorReading | ( | uint16_t | reading, |
| uint8_t | alpha, | ||
| uint16_t | prior | ||
| ) |


| uint32_t vssGetPulseGap | ( | uint8_t | historyIndex | ) |
Returns the VSS pulse gap for a given history point.
| historyIndex | The gap number that is wanted. EG: historyIndex = 0 = Latest entry historyIndex = 1 = 2nd entry entry |

| void vssPulse | ( | void | ) |
The ISR function for VSS pulses.

|
static |
|
static |
|
static |
| volatile uint8_t flexCounter = 0U |
| volatile uint32_t flexPulseWidth = 0U |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| uint8_t statusSensors = 0 |
|
staticconstexpr |
|
staticconstexpr |
|
static |
|
static |