Add function to clear the has been stopped flag

pull/4/head
Diego Barrios Romero 2018-10-29 18:22:44 +01:00
parent 9d236eb8c6
commit 7f3d1220d0
2 changed files with 12 additions and 0 deletions

View File

@ -20,4 +20,15 @@ where
let status = self.iface.read_register(Register::STATUS)?;
Ok((status & BitFlags::OSC_STOP) != 0)
}
/// Clear the has been stopped flag.
///
/// (Does not alter the device register if already cleared).
pub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<E>> {
let status = self.iface.read_register(Register::STATUS)?;
if (status & BitFlags::OSC_STOP) != 0 {
self.iface.write_register(Register::STATUS, status & !BitFlags::OSC_STOP)?;
}
Ok(())
}
}

View File

@ -39,4 +39,5 @@ macro_rules! change_if_necessary_test {
change_if_necessary_test!(enable, enable, CONTROL, 0xFF & !BF::EOSC, 0xFF);
change_if_necessary_test!(disable, disable, CONTROL, 0xFF, 0xFF & !BF::EOSC);
change_if_necessary_test!(clr_stop, clear_has_been_stopped_flag, STATUS, 0xFF & !BF::OSC_STOP, 0xFF);