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
34#define BIT_SENSORS_AUX_ENBL 0
35#define BIT_SENSORS_BARO_SAVED 1
36#define BIT_SENSORS_UNUSED2 2
37#define BIT_SENSORS_UNUSED3 3
38#define BIT_SENSORS_UNUSED4 4
39#define BIT_SENSORS_UNUSED5 5
40#define BIT_SENSORS_UNUSED6 6
41#define BIT_SENSORS_UNUSED7 7
42extern uint8_t statusSensors; //Uses the above status bits
43
44void initialiseADC(void);
45void readTPS(bool useFilter=true); //Allows the option to override the use of the filter
46void readO2_2(void);
47void flexPulse(void);
48void knockPulse(void);
50void vssPulse(void);
51uint16_t getSpeed(void);
52byte getGear(void);
53byte getFuelPressure(void);
54byte getOilPressure(void);
57void readCLT(bool useFilter=true); //Allows the option to override the use of the filter
58void readIAT(void);
59void readO2(void);
60void readBat(void);
61void readBaro(void);
62
64void initialiseMAPBaro(void);
65void resetMAPcycleAndEvent(void);
66
67void readMAP(void);
68
70
73
76
80
81#endif // SENSORS_H
volatile unsigned int toothHistoryIndex
Current index to toothHistory array.
Definition globals.cpp:91
static uint32_t rshift(uint32_t a)
Bitwise right shift - generic, unoptimized, case.
Definition bit_shifts.h:348
byte getFuelPressure(void)
Definition sensors.cpp:837
byte getOilPressure(void)
Definition sensors.cpp:852
void readTPS(bool useFilter=true)
Definition sensors.cpp:555
void readMAP(void)
Definition sensors.cpp:506
void readBaro(void)
Definition sensors.cpp:647
uint8_t statusSensors
Definition sensors.cpp:26
byte getGear(void)
Definition sensors.cpp:813
uint32_t vssGetPulseGap(byte toothHistoryIndex)
Returns the VSS pulse gap for a given history point.
Definition sensors.cpp:754
void initialiseMAPBaro(void)
Initialize the MAP calculation & Baro values.
Definition sensors.cpp:661
void vssPulse(void)
The ISR function for VSS pulses.
Definition sensors.cpp:916
void readIAT(void)
Definition sensors.cpp:604
uint32_t getMAPDeltaTime(void)
Get the time in µS between the last 2 MAP readings.
Definition sensors.cpp:549
int16_t getMAPDelta(void)
Get the MAP change between the last 2 readings.
Definition sensors.cpp:544
uint16_t readAuxdigital(uint8_t digitalPin)
Definition sensors.cpp:931
void readO2_2(void)
Definition sensors.cpp:708
void resetMAPcycleAndEvent(void)
Definition sensors.cpp:683
void readBat(void)
Definition sensors.cpp:716
table2D_u16_u8_32 o2CalibrationTable
void readO2(void)
Definition sensors.cpp:692
void flexPulse(void)
Definition sensors.cpp:885
volatile byte flexCounter
Definition sensors.cpp:31
uint8_t getAnalogKnock(void)
Definition sensors.cpp:869
void knockPulse(void)
Definition sensors.cpp:903
uint16_t getSpeed(void)
Definition sensors.cpp:769
void initialiseADC(void)
Definition sensors.cpp:144
table2D_u16_u16_32 iatCalibrationTable
volatile uint32_t flexPulseWidth
Definition sensors.cpp:33
void readCLT(bool useFilter=true)
Definition sensors.cpp:594
uint16_t readAuxanalog(uint8_t analogPin)
Definition sensors.cpp:926
table2D_u16_u16_32 cltCalibrationTable
A 2D table.
Definition table2d.h:55