mirror of https://github.com/eldruin/ds323x-rs
Add function to enable/disable the square wave generation
parent
2aba6332e7
commit
5168dbe68f
|
@ -77,6 +77,17 @@ where
|
|||
self.write_control(control & !BitFlags::INTCN)
|
||||
}
|
||||
|
||||
/// Enable battery-backed square wave generation.
|
||||
pub fn enable_square_wave(&mut self) -> Result<(), Error<E>> {
|
||||
let control = self.control;
|
||||
self.write_control(control | BitFlags::BBSQW)
|
||||
}
|
||||
|
||||
/// Disable battery-backed square wave generation.
|
||||
pub fn disable_square_wave(&mut self) -> Result<(), Error<E>> {
|
||||
let control = self.control;
|
||||
self.write_control(control & !BitFlags::BBSQW)
|
||||
}
|
||||
fn write_control(&mut self, control: u8) -> Result<(), Error<E>> {
|
||||
self.iface.write_register(Register::CONTROL, control)?;
|
||||
self.control = control;
|
||||
|
|
|
@ -356,6 +356,7 @@ impl BitFlags {
|
|||
const AM_PM : u8 = 0b0010_0000;
|
||||
const CENTURY : u8 = 0b1000_0000;
|
||||
const EOSC : u8 = 0b1000_0000;
|
||||
const BBSQW : u8 = 0b0100_0000;
|
||||
const TEMP_CONV : u8 = 0b0010_0000;
|
||||
const INTCN : u8 = 0b0000_0100;
|
||||
const BUSY : u8 = 0b0000_0100;
|
||||
|
|
|
@ -29,6 +29,7 @@ pub struct BitFlags;
|
|||
#[allow(unused)]
|
||||
impl BitFlags {
|
||||
pub const EOSC : u8 = 0b1000_0000;
|
||||
pub const BBSQW : u8 = 0b0100_0000;
|
||||
pub const TEMP_CONV : u8 = 0b0010_0000;
|
||||
pub const INTCN : u8 = 0b0000_0100;
|
||||
pub const BUSY : u8 = 0b0000_0100;
|
||||
|
|
|
@ -62,3 +62,6 @@ get_param_test!(get_aging_offset_max, get_aging_offset, AGING_OFFSET, 127, 127)
|
|||
call_method_test!(int_sqw_out_int, use_int_sqw_output_as_interrupt, CONTROL, CONTROL_POR_VALUE | BF::INTCN);
|
||||
call_method_test!(int_sqw_out_sqw, use_int_sqw_output_as_square_wave, CONTROL, CONTROL_POR_VALUE & !BF::INTCN);
|
||||
|
||||
call_method_test!(enable_sqw, enable_square_wave, CONTROL, CONTROL_POR_VALUE | BF::BBSQW);
|
||||
call_method_test!(disable_sqw, disable_square_wave, CONTROL, CONTROL_POR_VALUE & !BF::BBSQW);
|
||||
|
||||
|
|
Loading…
Reference in New Issue