Skip to content

Commit

Permalink
supply: derate current by 100 mA
Browse files Browse the repository at this point in the history
  • Loading branch information
surban committed Jul 8, 2024
1 parent 55f14b7 commit f670f2a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions openemc-firmware/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,19 @@ pub trait Board {
///
/// `active` specifies for how long the supplied power supply configuration has been unchanged.
fn input_current_limit(&mut self, power_supply: &PowerSupply, active: Duration) -> InputCurrentLimit {
let stable = active.to_secs() >= 3;

let mut max_input_current_ma = power_supply.max_current_ma();
if max_input_current_ma > 200 {
max_input_current_ma -= 100;
}
if !stable {
max_input_current_ma = max_input_current_ma.min(500);
}

InputCurrentLimit {
max_input_current_ma: if active.to_secs() >= 3 {
power_supply.max_current_ma()
} else {
power_supply.max_current_ma().min(500)
},
ico: matches!(power_supply, PowerSupply::UsbDcp | PowerSupply::UsbCdp) && active.to_secs() >= 3,
max_input_current_ma,
ico: matches!(power_supply, PowerSupply::UsbDcp | PowerSupply::UsbCdp) && stable,
}
}

Expand Down

0 comments on commit f670f2a

Please sign in to comment.