de init frequency sensor (#3183)
Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
044ed3272f
commit
ec9dcce377
|
@ -15,6 +15,8 @@ static void freqSensorExtiCallback(void* arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrequencySensor::init(brain_pin_e pin) {
|
void FrequencySensor::init(brain_pin_e pin) {
|
||||||
|
m_pin = pin;
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
// todo: refactor https://github.com/rusefi/rusefi/issues/2123
|
// todo: refactor https://github.com/rusefi/rusefi/issues/2123
|
||||||
efiExtiEnablePin("flex", pin,
|
efiExtiEnablePin("flex", pin,
|
||||||
|
@ -23,6 +25,18 @@ void FrequencySensor::init(brain_pin_e pin) {
|
||||||
#endif // EFI_PROD_CODE
|
#endif // EFI_PROD_CODE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrequencySensor::deInit() {
|
||||||
|
if (!isBrainPinValid(m_pin)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if EFI_PROD_CODE
|
||||||
|
efiExtiDisablePin(m_pin);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_pin = GPIO_UNASSIGNED;
|
||||||
|
}
|
||||||
|
|
||||||
void FrequencySensor::onEdge(efitick_t nowNt) {
|
void FrequencySensor::onEdge(efitick_t nowNt) {
|
||||||
float frequency = 1 / m_edgeTimer.getElapsedSecondsAndReset(nowNt);
|
float frequency = 1 / m_edgeTimer.getElapsedSecondsAndReset(nowNt);
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,11 @@ public:
|
||||||
: FunctionalSensor(type, timeoutPeriod) { }
|
: FunctionalSensor(type, timeoutPeriod) { }
|
||||||
|
|
||||||
void init(brain_pin_e pin);
|
void init(brain_pin_e pin);
|
||||||
|
void deInit();
|
||||||
|
|
||||||
void onEdge(efitick_t nowNt);
|
void onEdge(efitick_t nowNt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timer m_edgeTimer;
|
Timer m_edgeTimer;
|
||||||
|
brain_pin_e m_pin = GPIO_UNASSIGNED;
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,3 +36,4 @@ void reconfigureVbatt(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||||
void reconfigureTps(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
void reconfigureTps(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||||
void reconfigureThermistors(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
void reconfigureThermistors(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||||
void reconfigureOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
void reconfigureOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||||
|
void deInitFlexSensor();
|
||||||
|
|
|
@ -21,3 +21,7 @@ void initFlexSensor(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||||
flexSensor.init(pin);
|
flexSensor.init(pin);
|
||||||
flexSensor.Register();
|
flexSensor.Register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deInitFlexSensor() {
|
||||||
|
flexSensor.deInit();
|
||||||
|
}
|
||||||
|
|
|
@ -35,10 +35,12 @@ void initNewSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void reconfigureSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void reconfigureSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
deInitFlexSensor();
|
||||||
reconfigureVbatt(PASS_CONFIG_PARAMETER_SIGNATURE);
|
reconfigureVbatt(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||||
reconfigureTps(PASS_CONFIG_PARAMETER_SIGNATURE);
|
reconfigureTps(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||||
reconfigureOilPressure(PASS_CONFIG_PARAMETER_SIGNATURE);
|
reconfigureOilPressure(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||||
reconfigureThermistors(PASS_CONFIG_PARAMETER_SIGNATURE);
|
reconfigureThermistors(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||||
|
initFlexSensor(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mocking/testing helpers
|
// Mocking/testing helpers
|
||||||
|
|
Loading…
Reference in New Issue