ds323x-rs/tests/status.rs

52 lines
1.3 KiB
Rust
Raw Normal View History

2020-07-10 20:24:29 +00:00
use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
2018-10-29 17:16:23 +00:00
mod common;
2020-07-10 20:42:39 +00:00
use self::common::{
2019-05-16 17:18:07 +00:00
destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234,
BitFlags as BF, Register, DEVICE_ADDRESS as DEV_ADDR,
};
2018-10-29 17:16:23 +00:00
2020-05-02 09:48:45 +00:00
get_param_test!(running, running, CONTROL, true, 0);
get_param_test!(is_not_running, running, CONTROL, false, BF::EOSC);
2020-05-02 09:48:45 +00:00
get_param_test!(busy, busy, STATUS, true, 0xFF);
get_param_test!(is_not_busy, busy, STATUS, false, !BF::BUSY);
2019-05-16 17:18:07 +00:00
get_param_test!(stopped, has_been_stopped, STATUS, true, 0xFF);
2019-04-08 17:18:14 +00:00
get_param_test!(not_stopped, has_been_stopped, STATUS, false, !BF::OSC_STOP);
2018-10-29 17:36:15 +00:00
2019-05-16 17:18:07 +00:00
get_param_test!(alarm1_matched, has_alarm1_matched, STATUS, true, 0xFF);
get_param_test!(
alarm1_not_matched,
has_alarm1_matched,
STATUS,
false,
!BF::ALARM1F
);
2019-05-16 17:18:07 +00:00
get_param_test!(alarm2_matched, has_alarm2_matched, STATUS, true, 0xFF);
get_param_test!(
alarm2_not_matched,
has_alarm2_matched,
STATUS,
false,
!BF::ALARM2F
);
2022-02-20 09:17:55 +00:00
get_param_read_array_test!(temp_0, temperature, 0.0, TEMP_MSB, [0, 0], [0, 0]);
2019-05-16 17:18:07 +00:00
get_param_read_array_test!(
temp_min,
2022-02-20 09:17:55 +00:00
temperature,
2019-05-16 17:18:07 +00:00
-128.0,
TEMP_MSB,
[0b1000_0000, 0],
[0, 0]
);
get_param_read_array_test!(
temp_max,
2022-02-20 09:17:55 +00:00
temperature,
2019-05-16 17:18:07 +00:00
127.75,
TEMP_MSB,
[0b0111_1111, 0b1100_0000],
[0, 0]
);