Line |
Branch |
Decision |
Exec |
Source |
1 |
|
|
|
#include "pch.h" |
2 |
|
|
|
|
3 |
|
|
|
#include "init.h" |
4 |
|
|
|
#include "functional_sensor.h" |
5 |
|
|
|
#include "flex_sensor.h" |
6 |
|
|
|
|
7 |
|
|
|
#include "digital_input_exti.h" |
8 |
|
|
|
|
9 |
|
|
|
// 30 sec timeout to avoid issues around cranking |
10 |
|
|
|
static FlexSensor flexSensor(MS2NT(30000)); |
11 |
|
|
|
|
12 |
|
|
|
#if EFI_PROD_CODE |
13 |
|
|
|
static Gpio flexPin = Gpio::Unassigned; |
14 |
|
|
|
|
15 |
|
|
|
static void flexExtiCallback(void*, efitick_t nowNt) { |
16 |
|
|
|
flexSensor.callback(nowNt, efiReadPin(flexPin) ^ engineConfiguration->flexSensorInverted); |
17 |
|
|
|
} |
18 |
|
|
|
#endif |
19 |
|
|
|
|
20 |
|
|
|
// https://rusefi.com/forum/viewtopic.php?p=37452#p37452 |
21 |
|
|
|
|
22 |
|
|
2 |
void initFlexSensor(bool isFirstTime) { |
23 |
|
|
|
#if EFI_PROD_CODE |
24 |
|
|
|
if (efiExtiEnablePin("flex", engineConfiguration->flexSensorPin, |
25 |
|
|
|
PAL_EVENT_MODE_BOTH_EDGES, flexExtiCallback, nullptr) < 0) { |
26 |
|
|
|
return; |
27 |
|
|
|
} |
28 |
|
|
|
flexPin = engineConfiguration->flexSensorPin; |
29 |
|
|
|
|
30 |
|
|
|
if (isFirstTime) { |
31 |
|
|
|
addConsoleAction("flexinfo", []() { |
32 |
|
|
|
flexSensor.debug(); |
33 |
|
|
|
}); |
34 |
|
|
|
} |
35 |
|
|
|
#endif // EFI_PROD_CODE |
36 |
|
|
|
|
37 |
|
|
|
// If an analog fuel temp sensor is configured, don't use the flex sensor for fuel temp |
38 |
|
|
2 |
flexSensor.Register(!isAdcChannelValid(engineConfiguration->fuelTempSensor.adcChannel)); |
39 |
|
|
2 |
} |
40 |
|
|
|
|
41 |
|
|
✗ |
void deInitFlexSensor() { |
42 |
|
|
✗ |
flexSensor.unregister(); |
43 |
|
|
|
|
44 |
|
|
|
#if EFI_PROD_CODE |
45 |
|
|
|
if (!isBrainPinValid(flexPin)) { |
46 |
|
|
|
return; |
47 |
|
|
|
} |
48 |
|
|
|
|
49 |
|
|
|
efiExtiDisablePin(flexPin); |
50 |
|
|
|
|
51 |
|
|
|
flexPin = Gpio::Unassigned; |
52 |
|
|
|
#endif |
53 |
|
|
✗ |
} |
54 |
|
|
|
|