Speeduino
Loading...
Searching...
No Matches
speeduino
sensors_map_structs.h
Go to the documentation of this file.
1
#pragma once
2
4
#include <stdint.h>
5
6
// These are private to the MAP sampling algorithms but are broken out here
7
// to support unit testing of the algorithm implementations
8
9
struct
map_last_read_t
{
10
uint16_t
lastMAPValue
;
// kPA
11
uint32_t
currentReadingTime
;
// µS
12
#if defined(__UINT24_MAX__)
13
// Maximum time between readings is ~3s (at min RPM). 24 bits is enough for that
14
__uint24
timeDeltaReadings
;
15
#else
16
uint32_t
timeDeltaReadings
;
17
#endif
18
};
19
20
// A pair of ADC sensor readings
21
struct
map_adc_readings_t
{
22
uint16_t
mapADC
;
23
uint16_t
emapADC
;
24
};
25
26
// Working state for the cycle average sampling algorithm
27
struct
map_cycle_average_t
{
28
uint8_t
cycleStartIndex
;
29
#if defined(__UINT24_MAX__)
30
// Maximum revolution time is ~1.5s (at min RPM). At a 1KHz sampling rate & 2 revolutions,
31
// we'll store 3000 readings each at maximum of 1023 (~3000000 max). So a 24-bit value
32
// should be plenty.
33
__uint24
mapAdcRunningTotal
;
34
__uint24
emapAdcRunningTotal
;
35
#else
36
uint32_t
mapAdcRunningTotal
;
37
uint32_t
emapAdcRunningTotal
;
38
#endif
39
uint16_t
sampleCount
;
40
};
41
42
// Working state for the cycle minimum sampling algorithm
43
struct
map_cycle_min_t
{
44
uint8_t
cycleStartIndex
;
45
uint16_t
mapMinimum
;
46
};
47
48
// Working state for the event average sampling algorithm
49
struct
map_event_average_t
{
50
#if defined(__UINT24_MAX__)
51
__uint24
mapAdcRunningTotal
;
52
#else
53
uint32_t
mapAdcRunningTotal
;
54
#endif
55
uint16_t
sampleCount
;
56
uint8_t
eventStartIndex
;
57
};
58
59
// The overall MAP sampling system working state
60
struct
map_algorithm_t
{
61
map_last_read_t
lastReading
;
62
map_adc_readings_t
sensorReadings
;
63
64
union
{
65
map_cycle_average_t
cycle_average
;
66
map_cycle_min_t
cycle_min
;
67
map_event_average_t
event_average
;
68
};
69
};
70
71
rshift
static uint32_t rshift(uint32_t a)
Bitwise right shift - generic, unoptimized, case.
Definition
bit_shifts.h:349
Generated by
1.9.8