Closed reitermarkus closed 2 years ago
The improvement is not obvious in this PR since this only includes the traits but not any other changes using them.
With the other changes, the traits will allow reading registers like this:
pub fn temperature(&mut self) -> Result<Temperature, Error<CommE, PinE>> {
self.iface.read_accel_double_register::<Temperature>()
}
or writing configuration like this:
fn acc_enable_bdu(&mut self) -> Result<(), Error<CommE, PinE>> {
let reg4 = self.ctrl_reg4_a | CtrlReg4A::BDU;
self.iface.write_accel_register(reg4)?;
self.ctrl_reg4_a = reg4;
Ok(())
}
This add the
register!
macro andRegRead
andRegWrite
traits from https://github.com/eldruin/lsm303agr-rs/pull/17 as well as implements these traits for theStatusRegAuxA
register and theTemperature
type.