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

@ -277,15 +277,16 @@ pub enum Error<E> {
struct Register;
impl Register {
const SECONDS : u8 = 0x00;
const MINUTES : u8 = 0x01;
const HOURS : u8 = 0x02;
const DOW : u8 = 0x03;
const DOM : u8 = 0x04;
const MONTH : u8 = 0x05;
const YEAR : u8 = 0x06;
const CONTROL : u8 = 0x0E;
const SECONDS : u8 = 0x00;
const MINUTES : u8 = 0x01;
const HOURS : u8 = 0x02;
const DOW : u8 = 0x03;
const DOM : u8 = 0x04;
const MONTH : u8 = 0x05;
const YEAR : u8 = 0x06;
const CONTROL : u8 = 0x0E;
const STATUS : u8 = 0x0F;
const AGING_OFFSET : u8 = 0x10;
}
struct BitFlags;

View File

@ -10,14 +10,15 @@ pub struct Register;
#[allow(unused)]
impl Register {
pub const SECONDS : u8 = 0x00;
pub const MINUTES : u8 = 0x01;
pub const HOURS : u8 = 0x02;
pub const DOW : u8 = 0x03;
pub const DOM : u8 = 0x04;
pub const MONTH : u8 = 0x05;
pub const CONTROL : u8 = 0x0E;
pub const SECONDS : u8 = 0x00;
pub const MINUTES : u8 = 0x01;
pub const HOURS : u8 = 0x02;
pub const DOW : u8 = 0x03;
pub const DOM : u8 = 0x04;
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);