Small simplification

pull/4/head
Diego Barrios Romero 2020-05-02 12:17:49 +02:00
parent 1b13f482ae
commit b22cba6c63
2 changed files with 12 additions and 14 deletions

View File

@ -58,13 +58,12 @@ where
&mut self,
rate: TempConvRate,
) -> Result<(), Error<E, ()>> {
let status;
match rate {
TempConvRate::_64s => status = self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_128s => status = self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
TempConvRate::_256s => status = self.status | BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_512s => status = self.status | BitFlags::CRATE1 | BitFlags::CRATE0,
}
let status = match rate {
TempConvRate::_64s => self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_128s => self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
TempConvRate::_256s => self.status | BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_512s => self.status | BitFlags::CRATE1 | BitFlags::CRATE0,
};
self.write_status_without_clearing_alarm(status)
}
}

View File

@ -61,13 +61,12 @@ where
&mut self,
rate: TempConvRate,
) -> Result<(), Error<CommE, PinE>> {
let status;
match rate {
TempConvRate::_64s => status = self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_128s => status = self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
TempConvRate::_256s => status = self.status | BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_512s => status = self.status | BitFlags::CRATE1 | BitFlags::CRATE0,
}
let status = match rate {
TempConvRate::_64s => self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_128s => self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
TempConvRate::_256s => self.status | BitFlags::CRATE1 & !BitFlags::CRATE0,
TempConvRate::_512s => self.status | BitFlags::CRATE1 | BitFlags::CRATE0,
};
self.write_status_without_clearing_alarm(status)
}