From c6709f8f00c7273db3634121702b90f019fe7c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Mon, 19 Oct 2020 15:22:51 +0200 Subject: [PATCH] Rename (Dcdc|PwmSwitch)::emergency_stop to stop The stop functions can be used in a generic way, not only in an emergency situation. The name was misleading. --- src/daq.cpp | 4 ++-- src/dcdc.cpp | 6 ++---- src/dcdc.h | 8 +++++--- src/pwm_switch.cpp | 2 +- src/pwm_switch.h | 9 ++++++--- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/daq.cpp b/src/daq.cpp index bf2ce7c..ec13b0c 100644 --- a/src/daq.cpp +++ b/src/daq.cpp @@ -253,10 +253,10 @@ void high_voltage_alert() { // disable any sort of input #if DT_NODE_EXISTS(DT_PATH(dcdc)) - dcdc.emergency_stop(); + dcdc.stop(); #endif #if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), pwm_switch)) - pwm_switch.emergency_stop(); + pwm_switch.stop(); #endif // do not use enter_state function, as we don't want to wait entire recharge delay charger.state = CHG_STATE_IDLE; diff --git a/src/dcdc.cpp b/src/dcdc.cpp index 15f4965..105698c 100644 --- a/src/dcdc.cpp +++ b/src/dcdc.cpp @@ -270,9 +270,7 @@ __weak void Dcdc::control() } if (stop_reason != NULL) { - half_bridge_stop(); - state = DCDC_CONTROL_OFF; - off_timestamp = uptime(); + stop(); printf("DC/DC Stop: %s.\n", stop_reason); } } @@ -306,7 +304,7 @@ void Dcdc::test() } } -void Dcdc::emergency_stop() +void Dcdc::stop() { half_bridge_stop(); state = DCDC_CONTROL_OFF; diff --git a/src/dcdc.h b/src/dcdc.h index 0e97e89..1fb7e24 100644 --- a/src/dcdc.h +++ b/src/dcdc.h @@ -113,11 +113,13 @@ public: void test(); /** - * Fast emergency stop function + * Fast stop function (bypassing control loop) * - * May be called from an ISR which detected overvoltage / overcurrent conditions + * May be called from an ISR which detected overvoltage / overcurrent conditions. + * + * DC/DC will be restarted automatically from control function if condtions are valid. */ - void emergency_stop(); + void stop(); /** * Prevent overcharging of battery in case of shorted HS MOSFET diff --git a/src/pwm_switch.cpp b/src/pwm_switch.cpp index cb5ab78..e30b121 100644 --- a/src/pwm_switch.cpp +++ b/src/pwm_switch.cpp @@ -132,7 +132,7 @@ void PwmSwitch::control() } } -void PwmSwitch::emergency_stop() +void PwmSwitch::stop() { pwm_signal_stop(); off_timestamp = uptime(); diff --git a/src/pwm_switch.h b/src/pwm_switch.h index 27c69f3..007c8bd 100644 --- a/src/pwm_switch.h +++ b/src/pwm_switch.h @@ -38,11 +38,14 @@ public: */ void test(); - /** Fast emergency stop function + /** + * Fast stop function (bypassing control loop) * - * May be called from an ISR which detected overvoltage / overcurrent conditions + * May be called from an ISR which detected overvoltage / overcurrent conditions. + * + * PWM port will be restarted automatically from control function if condtions are valid. */ - void emergency_stop(); + void stop(); /** Read the general on/off status of PWM switching *