diff --git a/src/common/include/common/command.h b/src/common/include/common/command.h index 66052dc..3174822 100644 --- a/src/common/include/common/command.h +++ b/src/common/include/common/command.h @@ -40,6 +40,8 @@ enum Command { CMD_LED_SET_MODE = 16, // Get key matrix state CMD_MATRIX_GET = 17, + // Save LED settings to ROM + CMD_LED_SAVE = 18, //TODO }; diff --git a/tool/src/ec.rs b/tool/src/ec.rs index c685181..d0085f9 100644 --- a/tool/src/ec.rs +++ b/tool/src/ec.rs @@ -34,6 +34,7 @@ enum Cmd { LedGetMode = 15, LedSetMode = 16, MatrixGet = 17, + LedSave = 18, } const CMD_SPI_FLAG_READ: u8 = 1 << 0; @@ -272,6 +273,10 @@ impl Ec { self.command(Cmd::LedSetMode, &mut data) } + pub unsafe fn led_save(&mut self) -> Result<(), Error> { + self.command(Cmd::LedSave, &mut []) + } + pub unsafe fn matrix_get(&mut self, matrix: &mut [u8]) -> Result<(), Error> { self.command(Cmd::MatrixGet, matrix) } diff --git a/tool/src/main.rs b/tool/src/main.rs index 90de8f4..e291bb5 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -371,6 +371,7 @@ fn main() { .validator(validate_from_str::) ) ) + .subcommand(SubCommand::with_name("led_save")) .subcommand(SubCommand::with_name("matrix")) .subcommand(SubCommand::with_name("print") .arg(Arg::with_name("message") @@ -571,6 +572,13 @@ fn main() { } } }, + ("led_save", Some(_sub_m)) => match unsafe { ec.led_save() } { + Ok(()) => (), + Err(err) => { + eprintln!("failed to save LED settings: {:X?}", err); + process::exit(1); + }, + }, ("matrix", Some(_sub_m)) => match unsafe { matrix(&mut ec) } { Ok(()) => (), Err(err) => {