2019-05-16 17:18:07 +00:00
|
|
|
extern crate ds323x;
|
2020-05-02 09:36:42 +00:00
|
|
|
extern crate linux_embedded_hal as hal;
|
|
|
|
use ds323x::{Ds323x, NaiveDate, Rtcc};
|
2018-10-28 09:32:41 +00:00
|
|
|
|
|
|
|
fn main() {
|
2020-05-02 09:36:42 +00:00
|
|
|
let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
|
2018-10-28 09:32:41 +00:00
|
|
|
let mut rtc = Ds323x::new_ds3231(dev);
|
2020-05-02 09:36:42 +00:00
|
|
|
let datetime = NaiveDate::from_ymd(2020, 5, 1).and_hms(19, 59, 58);
|
2018-11-16 16:36:15 +00:00
|
|
|
rtc.set_datetime(&datetime).unwrap();
|
|
|
|
// do something else...
|
2020-05-02 09:36:42 +00:00
|
|
|
let time = rtc.get_time().unwrap();
|
|
|
|
println!("Time: {}", time);
|
2018-11-16 18:48:56 +00:00
|
|
|
|
2018-11-16 18:42:47 +00:00
|
|
|
let _dev = rtc.destroy_ds3231();
|
2018-10-28 09:32:41 +00:00
|
|
|
}
|