Speeduino
Loading...
Searching...
No Matches
sensors.h
Go to the documentation of this file.
1#ifndef SENSORS_H
2#define SENSORS_H
3
4#include "globals.h"
5
6// The following are alpha values for the ADC filters.
7// Their values are from 0 to 240, with 0 being no filtering and 240 being maximum
8#define ADCFILTER_TPS_DEFAULT 50U
9#define ADCFILTER_CLT_DEFAULT 180U
10#define ADCFILTER_IAT_DEFAULT 180U
11#define ADCFILTER_O2_DEFAULT 128U
12#define ADCFILTER_BAT_DEFAULT 128U
13#define ADCFILTER_MAP_DEFAULT 20U //This is only used on Instantaneous MAP readings and is intentionally very weak to allow for faster response
14#define ADCFILTER_BARO_DEFAULT 64U
15
16#define ADCFILTER_PSI_DEFAULT 150U //not currently configurable at runtime, used for misc pressure sensors, oil, fuel, etc.
17
18#define FILTER_FLEX_DEFAULT 75U
19
20#define VSS_GEAR_HYSTERESIS 10U
21#define VSS_SAMPLES 4U //Must be a power of 2 and smaller than 255
22
23#define TPS_READ_FREQUENCY 30 //ONLY VALID VALUES ARE 15 or 30!!!
24
25extern volatile byte flexCounter;
26extern volatile uint32_t flexPulseWidth;
27
28#if defined(CORE_AVR)
29 #define READ_FLEX() ((*flex_pin_port & flex_pin_mask) ? true : false)
30#else
31 #define READ_FLEX() digitalRead(pinFlex)
32#endif
33
34extern bool auxIsEnabled;
35
36void initialiseADC(void);
37void readTPS(bool useFilter=true); //Allows the option to override the use of the filter
38void readO2_2(void);
39void flexPulse(void);
40void knockPulse(void);
42void vssPulse(void);
43uint16_t getSpeed(void);
44byte getGear(void);
45byte getFuelPressure(void);
46byte getOilPressure(void);
49void readCLT(bool useFilter=true); //Allows the option to override the use of the filter
50void readIAT(void);
51void readO2(void);
52void readBat(void);
53void readBaro(void);
54
56void initialiseMAPBaro(void);
57
58void readMAP(void);
59
61
64
67
68#endif // SENSORS_H
volatile unsigned int toothHistoryIndex
Current index to toothHistory array.
Definition globals.cpp:121
static uint32_t rshift(uint32_t a)
Bitwise right shift - generic, unoptimized, case.
Definition bit_shifts.h:349
byte getFuelPressure(void)
Definition sensors.cpp:815
byte getOilPressure(void)
Definition sensors.cpp:830
void readTPS(bool useFilter=true)
Definition sensors.cpp:548
void readMAP(void)
Definition sensors.cpp:519
void readBaro(void)
Definition sensors.cpp:633
byte getGear(void)
Definition sensors.cpp:791
uint32_t vssGetPulseGap(byte toothHistoryIndex)
Returns the VSS pulse gap for a given history point.
Definition sensors.cpp:732
void initialiseMAPBaro(void)
Initialize the MAP calculation & Baro values.
Definition sensors.cpp:663
void vssPulse(void)
The ISR function for VSS pulses.
Definition sensors.cpp:894
void readIAT(void)
Definition sensors.cpp:597
uint32_t getMAPDeltaTime(void)
Get the time in µS between the last 2 MAP readings.
Definition sensors.cpp:542
int16_t getMAPDelta(void)
Get the MAP change between the last 2 readings.
Definition sensors.cpp:537
uint16_t readAuxdigital(uint8_t digitalPin)
Definition sensors.cpp:909
void readO2_2(void)
Definition sensors.cpp:686
void readBat(void)
Definition sensors.cpp:694
void readO2(void)
Definition sensors.cpp:670
void flexPulse(void)
Definition sensors.cpp:863
volatile byte flexCounter
Definition sensors.cpp:68
uint8_t getAnalogKnock(void)
Definition sensors.cpp:847
void knockPulse(void)
Definition sensors.cpp:881
uint16_t getSpeed(void)
Definition sensors.cpp:747
void initialiseADC(void)
Definition sensors.cpp:127
volatile uint32_t flexPulseWidth
Definition sensors.cpp:70
void readCLT(bool useFilter=true)
Definition sensors.cpp:587
bool auxIsEnabled
Definition sensors.cpp:63
uint16_t readAuxanalog(uint8_t analogPin)
Definition sensors.cpp:904