Add function to set the aging offset

pull/4/head
Diego Barrios Romero 2018-10-29 18:26:03 +01:00
parent c41526b7ec
commit 03b7012ec3
4 changed files with 24 additions and 15 deletions

View File

@ -62,4 +62,9 @@ where
}
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)
}
}

View File

@ -286,6 +286,7 @@ impl Register {
const YEAR : u8 = 0x06;
const CONTROL : u8 = 0x0E;
const STATUS : u8 = 0x0F;
const AGING_OFFSET : u8 = 0x10;
}
struct BitFlags;

View File

@ -18,6 +18,7 @@ impl Register {
pub const MONTH : u8 = 0x05;
pub const CONTROL : u8 = 0x0E;
pub const STATUS : u8 = 0x0F;
pub const AGING_OFFSET : u8 = 0x10;
}
pub struct BitFlags;

View File

@ -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!(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);