cfg_reg: add getter function

pull/4/head
occheung 2020-08-12 12:00:11 +08:00
parent 0543e98956
commit 8f4a97c97e
1 changed files with 5 additions and 1 deletions

View File

@ -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<SPI, E> Transfer<u8> for ConfigRegister<SPI>