ds323x-rs/tests/ds323x.rs

28 lines
1.1 KiB
Rust
Raw Normal View History

2018-10-28 11:07:55 +00:00
#[deny(warnings)]
2018-10-28 10:52:07 +00:00
extern crate embedded_hal_mock as hal;
2018-10-28 11:06:25 +00:00
use hal::i2c::Transaction as I2cTrans;
use hal::spi::Transaction as SpiTrans;
2018-10-28 10:52:07 +00:00
mod common;
2018-10-28 11:06:25 +00:00
use common::{ DEVICE_ADDRESS, Register, new_ds3231,
new_ds3232, new_ds3234 };
2018-10-28 10:52:07 +00:00
get_test!(can_get_seconds_ds3231, get_seconds, new_ds3231, 1,
I2cTrans::write_read(DEVICE_ADDRESS, vec![Register::SECONDS], vec![1]));
get_test!(can_get_seconds_ds3232, get_seconds, new_ds3232, 1,
I2cTrans::write_read(DEVICE_ADDRESS, vec![Register::SECONDS], vec![1]));
get_test!(can_get_seconds_ds3234, get_seconds, new_ds3234, 1,
SpiTrans::transfer(vec![Register::SECONDS, 0], vec![Register::SECONDS, 1]));
set_test!(can_set_seconds_ds3231, set_seconds, new_ds3231, 1,
I2cTrans::write(DEVICE_ADDRESS, vec![Register::SECONDS, 1]));
set_test!(can_set_seconds_ds3232, set_seconds, new_ds3232, 1,
I2cTrans::write(DEVICE_ADDRESS, vec![Register::SECONDS, 1]));
set_test!(can_set_seconds_ds3234, set_seconds, new_ds3234, 1,
SpiTrans::write(vec![Register::SECONDS + 0x80, 1]));