File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
framework_lib/src/chromium_ec Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ pub enum EcCommands {
46
46
RebootEc = 0x00D2 ,
47
47
/// Get information about PD controller power
48
48
UsbPdPowerInfo = 0x0103 ,
49
+ AdcRead = 0x0123 ,
49
50
RgbKbdSetColor = 0x013A ,
50
51
RgbKbd = 0x013B ,
51
52
Original file line number Diff line number Diff line change @@ -518,6 +518,22 @@ impl EcRequest<EcResponseUsbPdPowerInfo> for EcRequestUsbPdPowerInfo {
518
518
}
519
519
}
520
520
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
+
521
537
// TODO: Actually 128, but if we go above ~80 EC returns REQUEST_TRUNCATED
522
538
// At least when I use the portio driver
523
539
pub const EC_RGBKBD_MAX_KEY_COUNT : usize = 64 ;
Original file line number Diff line number Diff line change @@ -953,6 +953,11 @@ impl CrosEc {
953
953
Ok ( res. val == 1 )
954
954
}
955
955
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
+
956
961
pub fn rgbkbd_set_color ( & self , start_key : u8 , colors : Vec < RgbS > ) -> EcResult < ( ) > {
957
962
for ( chunk, colors) in colors. chunks ( EC_RGBKBD_MAX_KEY_COUNT ) . enumerate ( ) {
958
963
let mut request = EcRequestRgbKbdSetColor {
You can’t perform that action at this time.
0 commit comments