Skip to content

Commit 256309a

Browse files
committed
supply: no input current when disconnected
When any supply detector reports a disconnected status, treat the merged status as disconnected.
1 parent 3d8d59b commit 256309a

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

openemc-firmware/src/bq25713.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ where
510510
// Enable IDPM.
511511
self.modify(i2c, REG_CHARGE_OPTION_0_LO, |v| v | (1 << 1))?;
512512

513-
if self.chrg_ok {
513+
if self.chrg_ok && limit.max_input_current_ma > 0 {
514514
defmt::trace!("Programming maximum input current {} mA", limit.max_input_current_ma);
515515

516516
// Enable or disable ICO.

openemc-firmware/src/supply/max14636.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Max14636 {
6565
!chg_al_n_low,
6666
!chg_det_low
6767
);
68-
PowerSupply::Unknown
68+
PowerSupply::Disconnected
6969
}
7070
}
7171
}

openemc-firmware/src/supply/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ pub enum PowerSupply {
7272
impl PowerSupply {
7373
/// Merge two power supply reports, returning the best available power.
7474
pub fn merge(&self, other: &Self) -> Self {
75-
self.max(other).clone()
75+
if *self == Self::Disconnected || *other == Self::Disconnected {
76+
Self::Disconnected
77+
} else {
78+
self.max(other).clone()
79+
}
7680
}
7781

7882
/// Whether the power supply state is unknown.

0 commit comments

Comments
 (0)