hella_oil_level: check for errors, deInit()

This commit is contained in:
Andrey Gusakov 2024-03-05 23:39:55 +03:00 committed by rusefillc
parent 6f564bd73b
commit 605b9c6db7
2 changed files with 19 additions and 5 deletions

View File

@ -15,17 +15,30 @@ void HellaOilLevelSensor::init(brain_pin_e pin) {
return;
}
m_pin = pin;
#if EFI_PROD_CODE
efiExtiEnablePin(getSensorName(), pin,
PAL_EVENT_MODE_BOTH_EDGES,
hellaSensorExtiCallback, reinterpret_cast<void*>(this));
if (efiExtiEnablePin(getSensorName(), pin, PAL_EVENT_MODE_BOTH_EDGES,
hellaSensorExtiCallback, reinterpret_cast<void*>(this)) < 0) {
return;
}
#endif // EFI_PROD_CODE
m_pin = pin;
Register();
}
void HellaOilLevelSensor::deInit() {
if (!isBrainPinValid(m_pin)) {
return;
}
#if EFI_PROD_CODE
efiExtiDisablePin(m_pin);
#endif
m_pin = Gpio::Unassigned;
}
void HellaOilLevelSensor::onEdge(efitick_t nowNt) {
if (efiReadPin(m_pin)) {
// Start pulse width timing at the rising edge

View File

@ -7,6 +7,7 @@ public:
HellaOilLevelSensor(SensorType type) : StoredValueSensor(type, MS2NT(2000)) {}
void init(brain_pin_e pin);
void deInit();
void onEdge(efitick_t nowNt);