File tree Expand file tree Collapse file tree
framework_lib/src/chromium_ec Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ pub enum EcCommands {
4646 RebootEc = 0x00D2 ,
4747 /// Get information about PD controller power
4848 UsbPdPowerInfo = 0x0103 ,
49+ AdcRead = 0x0123 ,
4950 RgbKbdSetColor = 0x013A ,
5051 RgbKbd = 0x013B ,
5152
Original file line number Diff line number Diff line change @@ -518,6 +518,22 @@ impl EcRequest<EcResponseUsbPdPowerInfo> for EcRequestUsbPdPowerInfo {
518518 }
519519}
520520
521+ #[ repr( C , packed) ]
522+ pub struct EcRequestAdcRead {
523+ /// ADC Channel, specific to each mainboard schematic
524+ pub adc_channel : u8 ,
525+ }
526+
527+ pub struct EcResponseAdcRead {
528+ pub adc_value : i32 ,
529+ }
530+
531+ impl EcRequest < EcResponseAdcRead > for EcRequestAdcRead {
532+ fn command_id ( ) -> EcCommands {
533+ EcCommands :: AdcRead
534+ }
535+ }
536+
521537// TODO: Actually 128, but if we go above ~80 EC returns REQUEST_TRUNCATED
522538// At least when I use the portio driver
523539pub const EC_RGBKBD_MAX_KEY_COUNT : usize = 64 ;
Original file line number Diff line number Diff line change @@ -953,6 +953,11 @@ impl CrosEc {
953953 Ok ( res. val == 1 )
954954 }
955955
956+ pub fn adc_read ( & self , adc_channel : u8 ) -> EcResult < i32 > {
957+ let res = EcRequestAdcRead { adc_channel } . send_command ( self ) ?;
958+ Ok ( res. adc_value )
959+ }
960+
956961 pub fn rgbkbd_set_color ( & self , start_key : u8 , colors : Vec < RgbS > ) -> EcResult < ( ) > {
957962 for ( chunk, colors) in colors. chunks ( EC_RGBKBD_MAX_KEY_COUNT ) . enumerate ( ) {
958963 let mut request = EcRequestRgbKbdSetColor {
You can’t perform that action at this time.
0 commit comments