From 8f4a97c97ed99430652c0faa819f556d2499006b Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 12 Aug 2020 12:00:11 +0800 Subject: [PATCH] cfg_reg: add getter function --- src/config_register.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config_register.rs b/src/config_register.rs index 8871069..e987583 100644 --- a/src/config_register.rs +++ b/src/config_register.rs @@ -88,7 +88,7 @@ where ((self.data & 0x0000FF00) >> 8) as u8, ((self.data & 0x000000FF) >> 0) as u8, ]).map_err(Error::SPI) { - Ok(arr) => Ok(((arr[0] as u32) << 16) | ((arr[1] as u32) << 8) | arr[2] as u32), + Ok(arr) => Ok(self.data), Err(e) => Err(e), } } @@ -106,6 +106,10 @@ where // Write all configurations at the same time self.set_all_configurations() } + + pub fn get_configuration(&mut self, config_type: CFGMask) -> u8 { + ((self.data & config_type.get_bitmask()) >> config_type.get_shift()) as u8 + } } impl Transfer for ConfigRegister