From 3f9a4bf140cb7cc4978d32448073d76e2559d58a Mon Sep 17 00:00:00 2001 From: linuswck Date: Fri, 26 Jul 2024 11:02:05 +0800 Subject: [PATCH] ld: Block pwr on request if alarm is asserted - Align the alarm and pwr up behavior with thermostat temp_mon --- src/laser_diode/ld_pwr_exc_protector.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/laser_diode/ld_pwr_exc_protector.rs b/src/laser_diode/ld_pwr_exc_protector.rs index 114a734..01eaec3 100644 --- a/src/laser_diode/ld_pwr_exc_protector.rs +++ b/src/laser_diode/ld_pwr_exc_protector.rs @@ -211,12 +211,14 @@ impl LdPwrExcProtector { pub fn pwr_on_and_arm_protection() { if let Some(ref mut wdg) = LdPwrExcProtector::get() { - wdg.alarm_status = Status::default(); - LdPwrExcProtector::clear_interrupt_bit(); - LdPwrExcProtector::pwr_on(); - // Interrupt should be enabled after power on to tackle the following edge case: - // Pd_Mon pin voltage has already exceed threshold before LD Power is on. - LdPwrExcProtector::enable_watchdog_interrupt(); + if !wdg.alarm_status.pwr_excursion { + wdg.alarm_status = Status::default(); + LdPwrExcProtector::clear_interrupt_bit(); + LdPwrExcProtector::pwr_on(); + // Interrupt should be enabled after power on to tackle the following edge case: + // Pd_Mon pin voltage has already exceed threshold before LD Power is on. + LdPwrExcProtector::enable_watchdog_interrupt(); + } } }