mirror of https://github.com/eldruin/ds323x-rs
Add function to select function of int/sqw output pin
parent
70657dd917
commit
8c6b9ff777
|
@ -64,6 +64,19 @@ where
|
||||||
let offset = self.iface.read_register(Register::AGING_OFFSET)?;
|
let offset = self.iface.read_register(Register::AGING_OFFSET)?;
|
||||||
Ok(offset as i8)
|
Ok(offset as i8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the interrupt/square-wave output to be used as interrupt output.
|
||||||
|
pub fn use_int_sqw_output_as_interrupt(&mut self) -> Result<(), Error<E>> {
|
||||||
|
let control = self.control;
|
||||||
|
self.write_control(control | BitFlags::INTCN)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the interrupt/square-wave output to be used as square-wave output.
|
||||||
|
pub fn use_int_sqw_output_as_square_wave(&mut self) -> Result<(), Error<E>> {
|
||||||
|
let control = self.control;
|
||||||
|
self.write_control(control & !BitFlags::INTCN)
|
||||||
|
}
|
||||||
|
|
||||||
fn write_control(&mut self, control: u8) -> Result<(), Error<E>> {
|
fn write_control(&mut self, control: u8) -> Result<(), Error<E>> {
|
||||||
self.iface.write_register(Register::CONTROL, control)?;
|
self.iface.write_register(Register::CONTROL, control)?;
|
||||||
self.control = control;
|
self.control = control;
|
||||||
|
|
|
@ -357,6 +357,7 @@ impl BitFlags {
|
||||||
const CENTURY : u8 = 0b1000_0000;
|
const CENTURY : u8 = 0b1000_0000;
|
||||||
const EOSC : u8 = 0b1000_0000;
|
const EOSC : u8 = 0b1000_0000;
|
||||||
const TEMP_CONV : u8 = 0b0010_0000;
|
const TEMP_CONV : u8 = 0b0010_0000;
|
||||||
|
const INTCN : u8 = 0b0000_0100;
|
||||||
const BUSY : u8 = 0b0000_0100;
|
const BUSY : u8 = 0b0000_0100;
|
||||||
const EN32KHZ : u8 = 0b0000_1000;
|
const EN32KHZ : u8 = 0b0000_1000;
|
||||||
const OSC_STOP : u8 = 0b1000_0000;
|
const OSC_STOP : u8 = 0b1000_0000;
|
||||||
|
|
|
@ -30,6 +30,7 @@ pub struct BitFlags;
|
||||||
impl BitFlags {
|
impl BitFlags {
|
||||||
pub const EOSC : u8 = 0b1000_0000;
|
pub const EOSC : u8 = 0b1000_0000;
|
||||||
pub const TEMP_CONV : u8 = 0b0010_0000;
|
pub const TEMP_CONV : u8 = 0b0010_0000;
|
||||||
|
pub const INTCN : u8 = 0b0000_0100;
|
||||||
pub const BUSY : u8 = 0b0000_0100;
|
pub const BUSY : u8 = 0b0000_0100;
|
||||||
pub const EN32KHZ : u8 = 0b0000_1000;
|
pub const EN32KHZ : u8 = 0b0000_1000;
|
||||||
pub const OSC_STOP : u8 = 0b1000_0000;
|
pub const OSC_STOP : u8 = 0b1000_0000;
|
||||||
|
|
|
@ -59,3 +59,6 @@ set_param_test!(set_aging_offset_max, set_aging_offset, AGING_OFFSET, 127, 127)
|
||||||
get_param_test!(get_aging_offset_min, get_aging_offset, AGING_OFFSET, -128, 0b1000_0000);
|
get_param_test!(get_aging_offset_min, get_aging_offset, AGING_OFFSET, -128, 0b1000_0000);
|
||||||
get_param_test!(get_aging_offset_max, get_aging_offset, AGING_OFFSET, 127, 127);
|
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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue