mirror of https://github.com/eldruin/ds323x-rs
Generate error when century bit is set in month method.
parent
459dfa9200
commit
57ecefccc3
|
|
@ -93,8 +93,13 @@ where
|
|||
|
||||
fn month(&mut self) -> Result<u8, Self::Error> {
|
||||
let data = self.iface.read_register(Register::MONTH)?;
|
||||
let value = data & !BitFlags::CENTURY;
|
||||
Ok(packed_bcd_to_decimal(value))
|
||||
|
||||
let century = data & BitFlags::CENTURY;
|
||||
if century != 0 {
|
||||
return Err(Error::InvalidDeviceCentury);
|
||||
}
|
||||
|
||||
Ok(packed_bcd_to_decimal(data))
|
||||
}
|
||||
|
||||
fn year(&mut self) -> Result<u16, Self::Error> {
|
||||
|
|
|
|||
|
|
@ -185,12 +185,6 @@ mod month {
|
|||
get_param_test!(get, month, MONTH, 1, 1);
|
||||
read_set_param_test!(set, set_month, MONTH, 12, 0b0000_0010, 0b0001_0010);
|
||||
set_invalid_param_range_test!(invalid, set_month, 0, 13);
|
||||
|
||||
mod keeps_century {
|
||||
use super::*;
|
||||
get_param_test!(get, month, MONTH, 12, 0b1001_0010);
|
||||
read_set_param_test!(set, set_month, MONTH, 12, 0b1000_0010, 0b1001_0010);
|
||||
}
|
||||
}
|
||||
|
||||
mod year {
|
||||
|
|
|
|||
Loading…
Reference in New Issue