MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / check_ac

Function check_ac

framework_lib/src/power.rs:694–737  ·  view source on GitHub ↗
(ec: &CrosEc, port: u8)

Source from the content-addressed store, hash-verified

692}
693
694fn check_ac(ec: &CrosEc, port: u8) -> EcResult<UsbPdPowerInfo> {
695 // port=0 or port=1 to check right
696 // port=2 or port=3 to check left
697 // If dest returns 0x2 that means it's powered
698
699 let info = EcRequestUsbPdPowerInfo { port }.send_command(ec)?;
700
701 Ok(UsbPdPowerInfo {
702 role: match info.role {
703 0 => UsbPowerRoles::Disconnected,
704 1 => UsbPowerRoles::Source,
705 2 => UsbPowerRoles::Sink,
706 3 => UsbPowerRoles::SinkNotCharging,
707 _ => {
708 debug_assert!(false, "Unknown Role!!");
709 UsbPowerRoles::Disconnected
710 }
711 },
712 charging_type: match info.charging_type {
713 0 => UsbChargingType::None,
714 1 => UsbChargingType::PD,
715 2 => UsbChargingType::TypeC,
716 3 => UsbChargingType::Proprietary,
717 4 => UsbChargingType::Bc12Dcp,
718 5 => UsbChargingType::Bc12Cdp,
719 6 => UsbChargingType::Bc12Sdp,
720 7 => UsbChargingType::Other,
721 8 => UsbChargingType::VBus,
722 9 => UsbChargingType::Unknown,
723 _ => {
724 debug_assert!(false, "Unknown Role!!");
725 UsbChargingType::Unknown
726 }
727 },
728 dualrole: info.dualrole != 0,
729 meas: UsbChargeMeasures {
730 voltage_max: info.meas.voltage_max,
731 voltage_now: info.meas.voltage_now,
732 current_lim: info.meas.current_lim,
733 current_max: info.meas.current_max,
734 },
735 max_power: info.max_power,
736 })
737}
738
739pub fn get_pd_info(ec: &CrosEc, ports: u8) -> Vec<EcResult<UsbPdPowerInfo>> {
740 // 4 ports on our current laptops

Callers 2

get_pd_infoFunction · 0.85
is_chargingFunction · 0.85

Calls 1

send_commandMethod · 0.45

Tested by

no test coverage detected