mirror of https://github.com/eldruin/ds323x-rs
Add function to set the aging offset
parent
c41526b7ec
commit
03b7012ec3
|
@ -62,4 +62,9 @@ where
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the aging offset.
|
||||||
|
pub fn set_aging_offset(&mut self, offset: i8) -> Result<(), Error<E>> {
|
||||||
|
self.iface.write_register(Register::AGING_OFFSET, offset as u8)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
17
src/lib.rs
17
src/lib.rs
|
@ -277,15 +277,16 @@ pub enum Error<E> {
|
||||||
struct Register;
|
struct Register;
|
||||||
|
|
||||||
impl Register {
|
impl Register {
|
||||||
const SECONDS : u8 = 0x00;
|
const SECONDS : u8 = 0x00;
|
||||||
const MINUTES : u8 = 0x01;
|
const MINUTES : u8 = 0x01;
|
||||||
const HOURS : u8 = 0x02;
|
const HOURS : u8 = 0x02;
|
||||||
const DOW : u8 = 0x03;
|
const DOW : u8 = 0x03;
|
||||||
const DOM : u8 = 0x04;
|
const DOM : u8 = 0x04;
|
||||||
const MONTH : u8 = 0x05;
|
const MONTH : u8 = 0x05;
|
||||||
const YEAR : u8 = 0x06;
|
const YEAR : u8 = 0x06;
|
||||||
const CONTROL : u8 = 0x0E;
|
const CONTROL : u8 = 0x0E;
|
||||||
const STATUS : u8 = 0x0F;
|
const STATUS : u8 = 0x0F;
|
||||||
|
const AGING_OFFSET : u8 = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BitFlags;
|
struct BitFlags;
|
||||||
|
|
|
@ -10,14 +10,15 @@ pub struct Register;
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
impl Register {
|
impl Register {
|
||||||
pub const SECONDS : u8 = 0x00;
|
pub const SECONDS : u8 = 0x00;
|
||||||
pub const MINUTES : u8 = 0x01;
|
pub const MINUTES : u8 = 0x01;
|
||||||
pub const HOURS : u8 = 0x02;
|
pub const HOURS : u8 = 0x02;
|
||||||
pub const DOW : u8 = 0x03;
|
pub const DOW : u8 = 0x03;
|
||||||
pub const DOM : u8 = 0x04;
|
pub const DOM : u8 = 0x04;
|
||||||
pub const MONTH : u8 = 0x05;
|
pub const MONTH : u8 = 0x05;
|
||||||
pub const CONTROL : u8 = 0x0E;
|
pub const CONTROL : u8 = 0x0E;
|
||||||
pub const STATUS : u8 = 0x0F;
|
pub const STATUS : u8 = 0x0F;
|
||||||
|
pub const AGING_OFFSET : u8 = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BitFlags;
|
pub struct BitFlags;
|
||||||
|
|
|
@ -44,3 +44,5 @@ change_if_necessary_test!(en_32khz_out, enable_32khz_output, STATUS, 0xFF, 0xF
|
||||||
change_if_necessary_test!(dis_32khz_out, disable_32khz_output, STATUS, 0xFF & !BF::EN32KHZ, 0xFF);
|
change_if_necessary_test!(dis_32khz_out, disable_32khz_output, STATUS, 0xFF & !BF::EN32KHZ, 0xFF);
|
||||||
change_if_necessary_test!(clr_stop, clear_has_been_stopped_flag, STATUS, 0xFF & !BF::OSC_STOP, 0xFF);
|
change_if_necessary_test!(clr_stop, clear_has_been_stopped_flag, STATUS, 0xFF & !BF::OSC_STOP, 0xFF);
|
||||||
|
|
||||||
|
set_param_test!(aging_offset_min, set_aging_offset, AGING_OFFSET, -128, 128);
|
||||||
|
set_param_test!(aging_offset_max, set_aging_offset, AGING_OFFSET, 127, 127);
|
||||||
|
|
Loading…
Reference in New Issue