mirror of https://github.com/eldruin/ds323x-rs
Rename methods due to Rust conventions
parent
3c8d378d6f
commit
c3106c0f49
|
@ -15,7 +15,7 @@ This driver allows you to:
|
|||
- Read and set date and time in 12-hour and 24-hour format. See: `get_datetime`.
|
||||
- Read and set date and time individual elements. For example, see: `get_year`.
|
||||
- Enable and disable the real-time clock. See: `enable`.
|
||||
- Read the busy status. See `is_busy`.
|
||||
- Read the busy status. See `busy`.
|
||||
- Read whether the oscillator is or has been stopped. See `has_been_stopped`.
|
||||
- Clear the has-been-stopped flag. See `clear_has_been_stopped_flag`.
|
||||
- Set and read the aging offset. See `set_aging_offset`.
|
||||
|
|
|
@ -21,7 +21,7 @@ where
|
|||
|
||||
/// Force a temperature conversion and time compensation with TXCO algorithm.
|
||||
///
|
||||
/// The *busy* status should be checked before doing this. See [`is_busy()`](#method.is_busy)
|
||||
/// The *busy* status should be checked before doing this. See [`busy()`](#method.busy)
|
||||
pub fn convert_temperature(&mut self) -> Result<(), Error<CommE, PinE>> {
|
||||
let control = self.iface.read_register(Register::CONTROL)?;
|
||||
// do not overwrite if a conversion is in progress
|
||||
|
|
|
@ -8,13 +8,13 @@ where
|
|||
DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
|
||||
{
|
||||
/// Read whether the oscillator is running
|
||||
pub fn is_running(&mut self) -> Result<bool, Error<CommE, PinE>> {
|
||||
pub fn running(&mut self) -> Result<bool, Error<CommE, PinE>> {
|
||||
let control = self.iface.read_register(Register::CONTROL)?;
|
||||
Ok((control & BitFlags::EOSC) == 0)
|
||||
}
|
||||
|
||||
/// Read the busy status
|
||||
pub fn is_busy(&mut self) -> Result<bool, Error<CommE, PinE>> {
|
||||
pub fn busy(&mut self) -> Result<bool, Error<CommE, PinE>> {
|
||||
let status = self.iface.read_register(Register::STATUS)?;
|
||||
Ok((status & BitFlags::BUSY) != 0)
|
||||
}
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -7,7 +7,7 @@
|
|||
//! - Read and set date and time in 12-hour and 24-hour format. See: [`get_datetime`].
|
||||
//! - Read and set date and time individual elements. For example, see: [`get_year`].
|
||||
//! - Enable and disable the real-time clock. See: [`enable`].
|
||||
//! - Read the busy status. See [`is_busy`].
|
||||
//! - Read the busy status. See [`busy`].
|
||||
//! - Read whether the oscillator is or has been stopped. See [`has_been_stopped`].
|
||||
//! - Clear the has-been-stopped flag. See [`clear_has_been_stopped_flag`].
|
||||
//! - Set and read the aging offset. See [`set_aging_offset`].
|
||||
|
@ -33,7 +33,7 @@
|
|||
//! [`enable`]: struct.Ds323x.html#method.enable
|
||||
//! [`get_temperature`]: struct.Ds323x.html#method.get_temperature
|
||||
//! [`convert_temperature`]: struct.Ds323x.html#method.convert_temperature
|
||||
//! [`is_busy`]: struct.Ds323x.html#method.is_busy
|
||||
//! [`busy`]: struct.Ds323x.html#method.busy
|
||||
//! [`has_been_stopped`]: struct.Ds323x.html#method.has_been_stopped
|
||||
//! [`clear_has_been_stopped_flag`]: struct.Ds323x.html#method.clear_has_been_stopped_flag
|
||||
//! [`set_aging_offset`]: struct.Ds323x.html#method.set_aging_offset
|
||||
|
@ -277,10 +277,10 @@
|
|||
//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
|
||||
//! let mut rtc = Ds323x::new_ds3231(dev);
|
||||
//! rtc.disable().unwrap(); // stops the clock
|
||||
//! let is_running = rtc.is_running().unwrap();
|
||||
//! println!("Is running: {}", is_running); // will print false
|
||||
//! let running = rtc.running().unwrap();
|
||||
//! println!("Is running: {}", running); // will print false
|
||||
//! rtc.enable().unwrap(); // set clock to run
|
||||
//! println!("Is running: {}", is_running); // will print true
|
||||
//! println!("Is running: {}", running); // will print true
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
|
@ -308,7 +308,7 @@
|
|||
//! # fn main() {
|
||||
//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
|
||||
//! let mut rtc = Ds323x::new_ds3231(dev);
|
||||
//! let is_busy = rtc.is_busy().unwrap();
|
||||
//! let busy = rtc.busy().unwrap();
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
|
|
|
@ -7,11 +7,11 @@ use common::{
|
|||
BitFlags as BF, Register, DEVICE_ADDRESS as DEV_ADDR,
|
||||
};
|
||||
|
||||
get_param_test!(is_running, is_running, CONTROL, true, 0);
|
||||
get_param_test!(is_not_running, is_running, CONTROL, false, BF::EOSC);
|
||||
get_param_test!(running, running, CONTROL, true, 0);
|
||||
get_param_test!(is_not_running, running, CONTROL, false, BF::EOSC);
|
||||
|
||||
get_param_test!(is_busy, is_busy, STATUS, true, 0xFF);
|
||||
get_param_test!(is_not_busy, is_busy, STATUS, false, !BF::BUSY);
|
||||
get_param_test!(busy, busy, STATUS, true, 0xFF);
|
||||
get_param_test!(is_not_busy, busy, STATUS, false, !BF::BUSY);
|
||||
|
||||
get_param_test!(stopped, has_been_stopped, STATUS, true, 0xFF);
|
||||
get_param_test!(not_stopped, has_been_stopped, STATUS, false, !BF::OSC_STOP);
|
||||
|
|
Loading…
Reference in New Issue