Add function to check if the oscillator has been stopped.

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

View File

@ -13,4 +13,11 @@ where
let status = self.iface.read_register(Register::STATUS)?;
Ok((status & BitFlags::BUSY) != 0)
}
/// Read whether the oscillator is stopped or has been stopped at
/// some point.
pub fn has_been_stopped(&mut self) -> Result<bool, Error<E>> {
let status = self.iface.read_register(Register::STATUS)?;
Ok((status & BitFlags::OSC_STOP) != 0)
}
}

View File

@ -296,6 +296,7 @@ impl BitFlags {
const CENTURY : u8 = 0b1000_0000;
const EOSC : u8 = 0b1000_0000;
const BUSY : u8 = 0b0000_0100;
const OSC_STOP : u8 = 0b1000_0000;
}
const DEVICE_ADDRESS: u8 = 0b110_1000;

View File

@ -26,6 +26,7 @@ pub struct BitFlags;
impl BitFlags {
pub const EOSC : u8 = 0b1000_0000;
pub const BUSY : u8 = 0b0000_0100;
pub const OSC_STOP : u8 = 0b1000_0000;
}
pub struct DummyOutputPin;

View File

@ -8,5 +8,8 @@ use common::{ DEVICE_ADDRESS as DEV_ADDR, Register, new_ds3231,
new_ds3232, new_ds3234, destroy_ds3231, destroy_ds3232,
destroy_ds3234, BitFlags as BF };
get_param_test!(is_busy, is_busy, STATUS, true, 0xFF);
get_param_test!(is_not_busy, is_busy, STATUS, false, 0xFF & !BF::BUSY);
get_param_test!(is_busy, is_busy, STATUS, true, 0xFF);
get_param_test!(is_not_busy, is_busy, STATUS, false, 0xFF & !BF::BUSY);
get_param_test!(stopped, has_been_stopped, STATUS, true, 0xFF);
get_param_test!(not_stopped, has_been_stopped, STATUS, false, 0xFF & !BF::OSC_STOP);