Change: clear_has_been_stopped_flag always clears without checking first

pull/4/head
Diego Barrios Romero 2018-11-03 07:53:01 +01:00
parent 77820cf6d0
commit 2304e08d1f
3 changed files with 10 additions and 2 deletions

View File

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
... ...
### Changed
- [breaking-change] `clear_has_been_stopped_flag()` always sets the value of the status register.
## 0.1.0 - 2018-10-31 ## 0.1.0 - 2018-10-31
This is the initial release to crates.io. All changes will be documented in This is the initial release to crates.io. All changes will be documented in

View File

@ -35,9 +35,11 @@ where
/// Clear flag signalling whether the oscillator is stopped or has been /// Clear flag signalling whether the oscillator is stopped or has been
/// stopped at some point. /// stopped at some point.
/// ///
/// (Does not alter the device register if already cleared).
/// See also: [`has_been_stopped()`](#method.has_been_stopped) /// See also: [`has_been_stopped()`](#method.has_been_stopped)
pub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<E>> { pub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<E>> {
let status = self.status & !BitFlags::OSC_STOP;
self.write_status_without_clearing_alarm(status)
}
let status = self.iface.read_register(Register::STATUS)?; let status = self.iface.read_register(Register::STATUS)?;
if (status & BitFlags::OSC_STOP) != 0 { if (status & BitFlags::OSC_STOP) != 0 {
self.iface.write_register(Register::STATUS, status & !BitFlags::OSC_STOP)?; self.iface.write_register(Register::STATUS, status & !BitFlags::OSC_STOP)?;

View File

@ -72,7 +72,10 @@ call_method_status_test!(en_32khz_out, enable_32khz_output,
call_method_status_test!(dis_32khz_out, disable_32khz_output, call_method_status_test!(dis_32khz_out, disable_32khz_output,
DS3231_POR_STATUS & !BF::EN32KHZ | BF::ALARM2F | BF::ALARM1F, DS3231_POR_STATUS & !BF::EN32KHZ | BF::ALARM2F | BF::ALARM1F,
DS323X_POR_STATUS & !BF::EN32KHZ | BF::ALARM2F | BF::ALARM1F); DS323X_POR_STATUS & !BF::EN32KHZ | BF::ALARM2F | BF::ALARM1F);
change_if_necessary_test!(clr_stop, clear_has_been_stopped_flag, STATUS, 0xFF & !BF::OSC_STOP, 0xFF); call_method_status_test!(clr_stop, clear_has_been_stopped_flag,
DS3231_POR_STATUS & !BF::OSC_STOP | BF::ALARM2F | BF::ALARM1F,
DS323X_POR_STATUS & !BF::OSC_STOP | BF::ALARM2F | BF::ALARM1F);
change_if_necessary_test!(conv_temp, convert_temperature, CONTROL, CONTROL_POR_VALUE | BF::TEMP_CONV, CONTROL_POR_VALUE & !BF::TEMP_CONV); change_if_necessary_test!(conv_temp, convert_temperature, CONTROL, CONTROL_POR_VALUE | BF::TEMP_CONV, CONTROL_POR_VALUE & !BF::TEMP_CONV);
set_param_test!(set_aging_offset_min, set_aging_offset, AGING_OFFSET, -128, 0b1000_0000); set_param_test!(set_aging_offset_min, set_aging_offset, AGING_OFFSET, -128, 0b1000_0000);