diff --git a/openemc-firmware/src/bq25713.rs b/openemc-firmware/src/bq25713.rs index 7788ffd..5cd6d21 100644 --- a/openemc-firmware/src/bq25713.rs +++ b/openemc-firmware/src/bq25713.rs @@ -510,7 +510,7 @@ where // Enable IDPM. self.modify(i2c, REG_CHARGE_OPTION_0_LO, |v| v | (1 << 1))?; - if self.chrg_ok { + if self.chrg_ok && limit.max_input_current_ma > 0 { defmt::trace!("Programming maximum input current {} mA", limit.max_input_current_ma); // Enable or disable ICO. diff --git a/openemc-firmware/src/supply/max14636.rs b/openemc-firmware/src/supply/max14636.rs index 040d2cc..036c205 100644 --- a/openemc-firmware/src/supply/max14636.rs +++ b/openemc-firmware/src/supply/max14636.rs @@ -65,7 +65,7 @@ impl Max14636 { !chg_al_n_low, !chg_det_low ); - PowerSupply::Unknown + PowerSupply::Disconnected } } } diff --git a/openemc-firmware/src/supply/mod.rs b/openemc-firmware/src/supply/mod.rs index 9a34fe8..cb507fd 100644 --- a/openemc-firmware/src/supply/mod.rs +++ b/openemc-firmware/src/supply/mod.rs @@ -72,7 +72,11 @@ pub enum PowerSupply { impl PowerSupply { /// Merge two power supply reports, returning the best available power. pub fn merge(&self, other: &Self) -> Self { - self.max(other).clone() + if *self == Self::Disconnected || *other == Self::Disconnected { + Self::Disconnected + } else { + self.max(other).clone() + } } /// Whether the power supply state is unknown.