mirror of https://github.com/eldruin/ds323x-rs
Compare commits
6 Commits
b06eb59cd6
...
74009022bf
Author | SHA1 | Date |
---|---|---|
Diego Barrios Romero | 74009022bf | |
kirbylife | fd6a145825 | |
Diego Barrios Romero | de0231b958 | |
Diego Barrios Romero | a8b8428570 | |
Diego Barrios Romero | f7d48398dc | |
Diego Barrios Romero | fe990d7295 |
|
@ -1,8 +1,5 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
name: Build
|
name: Build
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RUSTFLAGS: '--deny warnings'
|
RUSTFLAGS: '--deny warnings'
|
||||||
|
@ -13,7 +10,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
rust: [stable, beta, 1.35.0]
|
rust: [stable, 1.60.0]
|
||||||
TARGET:
|
TARGET:
|
||||||
- x86_64-unknown-linux-gnu
|
- x86_64-unknown-linux-gnu
|
||||||
- x86_64-unknown-linux-musl
|
- x86_64-unknown-linux-musl
|
||||||
|
@ -26,16 +23,14 @@ jobs:
|
||||||
- thumbv7m-none-eabi
|
- thumbv7m-none-eabi
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
target: ${{ matrix.TARGET }}
|
targets: ${{ matrix.TARGET }}
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Checkout CI scripts
|
- name: Checkout CI scripts
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: 'eldruin/rust-driver-ci-scripts'
|
repository: 'eldruin/rust-driver-ci-scripts'
|
||||||
ref: 'master'
|
ref: 'master'
|
||||||
|
@ -44,114 +39,70 @@ jobs:
|
||||||
- run: ./ci/patch-no-std.sh
|
- run: ./ci/patch-no-std.sh
|
||||||
if: ${{ ! contains(matrix.TARGET, 'x86_64') }}
|
if: ${{ ! contains(matrix.TARGET, 'x86_64') }}
|
||||||
|
|
||||||
- name: Build
|
- run: cargo build --target=${{ matrix.TARGET }}
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: build
|
|
||||||
args: --target=${{ matrix.TARGET }}
|
|
||||||
|
|
||||||
checks:
|
checks:
|
||||||
name: Checks
|
name: Checks
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
rust: [stable, beta]
|
|
||||||
TARGET:
|
|
||||||
- x86_64-unknown-linux-gnu
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
targets: x86_64-unknown-linux-gnu
|
||||||
toolchain: ${{ matrix.rust }}
|
|
||||||
target: ${{ matrix.TARGET }}
|
|
||||||
override: true
|
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
|
|
||||||
- name: Doc
|
- run: cargo doc
|
||||||
uses: actions-rs/cargo@v1
|
- run: cargo fmt --all -- --check
|
||||||
with:
|
|
||||||
command: doc
|
|
||||||
|
|
||||||
- name: Formatting
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: --all -- --check
|
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
name: Clippy
|
name: Clippy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
rust: [1.58.1]
|
|
||||||
TARGET:
|
|
||||||
- x86_64-unknown-linux-gnu
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
toolchain: 1.70.0
|
||||||
toolchain: ${{ matrix.rust }}
|
targets: x86_64-unknown-linux-gnu
|
||||||
target: ${{ matrix.TARGET }}
|
|
||||||
override: true
|
|
||||||
components: clippy
|
components: clippy
|
||||||
|
|
||||||
- name: Clippy
|
- run: cargo clippy --all-targets
|
||||||
uses: actions-rs/clippy-check@v1
|
|
||||||
with:
|
|
||||||
args: --all-targets -- --allow clippy::bool_assert_comparison
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Tests
|
name: Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
rust: [stable, beta]
|
rust: [stable]
|
||||||
TARGET: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl]
|
TARGET: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
target: ${{ matrix.TARGET }}
|
targets: ${{ matrix.TARGET }}
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
uses: actions-rs/cargo@v1
|
run: cargo test --target=${{ matrix.TARGET }}
|
||||||
with:
|
|
||||||
command: test
|
|
||||||
args: --target=${{ matrix.TARGET }}
|
|
||||||
|
|
||||||
- name: Build examples
|
- name: Build examples
|
||||||
uses: actions-rs/cargo@v1
|
run: cargo build --target=${{ matrix.TARGET }} --examples
|
||||||
if: contains(matrix.TARGET, 'x86_64')
|
|
||||||
with:
|
|
||||||
command: build
|
|
||||||
args: --target=${{ matrix.TARGET }} --examples
|
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
name: Coverage
|
name: Coverage
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: xd009642/tarpaulin:latest
|
||||||
|
options: --security-opt seccomp=unconfined
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- uses: actions/checkout@v3
|
||||||
uses: actions-rs/toolchain@v1
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Run cargo-tarpaulin
|
- name: Run cargo-tarpaulin
|
||||||
uses: actions-rs/tarpaulin@v0.1
|
run: cargo tarpaulin --out Lcov -- --test-threads 1
|
||||||
with:
|
|
||||||
args: '--out Lcov -- --test-threads 1'
|
|
||||||
|
|
||||||
- name: upload to Coveralls
|
- name: upload to Coveralls
|
||||||
uses: coverallsapp/github-action@master
|
uses: coverallsapp/github-action@master
|
||||||
|
|
|
@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
...
|
### Fixed
|
||||||
|
- Fixed `set_day` method. See: [PR #9](https://github.com/eldruin/ds323x-rs/pull/9)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Raised MSRV to version 1.60.0
|
||||||
|
|
||||||
## [0.5.0] - 2022-02-21
|
## [0.5.0] - 2022-02-21
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ embedded-hal = "0.2.7"
|
||||||
rtcc = "0.3"
|
rtcc = "0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
embedded-hal-mock = "0.8.0"
|
embedded-hal-mock = "0.9.0"
|
||||||
linux-embedded-hal = "0.3.2"
|
linux-embedded-hal = "0.3.2"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (C) 2018-2022 Diego Barrios Romero
|
Copyright (C) 2018-2023 Diego Barrios Romero
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[![crates.io](https://img.shields.io/crates/v/ds323x.svg)](https://crates.io/crates/ds323x)
|
[![crates.io](https://img.shields.io/crates/v/ds323x.svg)](https://crates.io/crates/ds323x)
|
||||||
[![Docs](https://docs.rs/ds323x/badge.svg)](https://docs.rs/ds323x)
|
[![Docs](https://docs.rs/ds323x/badge.svg)](https://docs.rs/ds323x)
|
||||||
![MSRV](https://img.shields.io/badge/rustc-1.35+-blue.svg)
|
![MSRV](https://img.shields.io/badge/rustc-1.60+-blue.svg)
|
||||||
[![Build Status](https://github.com/eldruin/ds323x-rs/workflows/Build/badge.svg)](https://github.com/eldruin/ds323x-rs/actions?query=workflow%3ABuild)
|
[![Build Status](https://github.com/eldruin/ds323x-rs/workflows/Build/badge.svg)](https://github.com/eldruin/ds323x-rs/actions?query=workflow%3ABuild)
|
||||||
[![Coverage Status](https://coveralls.io/repos/eldruin/ds323x-rs/badge.svg?branch=master)](https://coveralls.io/r/eldruin/ds323x-rs?branch=master)
|
[![Coverage Status](https://coveralls.io/repos/eldruin/ds323x-rs/badge.svg?branch=master)](https://coveralls.io/r/eldruin/ds323x-rs?branch=master)
|
||||||
|
|
||||||
|
@ -117,7 +117,10 @@ use linux_embedded_hal::I2cdev;
|
||||||
fn main() {
|
fn main() {
|
||||||
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
||||||
let mut rtc = Ds323x::new_ds3231(dev);
|
let mut rtc = Ds323x::new_ds3231(dev);
|
||||||
let datetime = NaiveDate::from_ymd(2020, 5, 1).and_hms(19, 59, 58);
|
let datetime = NaiveDate::from_ymd_opt(2020, 5, 1)
|
||||||
|
.unwrap()
|
||||||
|
.and_hms_opt(19, 59, 58)
|
||||||
|
.unwrap();
|
||||||
rtc.set_datetime(&datetime).unwrap();
|
rtc.set_datetime(&datetime).unwrap();
|
||||||
// do something else...
|
// do something else...
|
||||||
let time = rtc.time().unwrap();
|
let time = rtc.time().unwrap();
|
||||||
|
|
|
@ -4,7 +4,10 @@ use linux_embedded_hal::I2cdev;
|
||||||
fn main() {
|
fn main() {
|
||||||
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
||||||
let mut rtc = Ds323x::new_ds3231(dev);
|
let mut rtc = Ds323x::new_ds3231(dev);
|
||||||
let datetime = NaiveDate::from_ymd(2020, 5, 1).and_hms(19, 59, 58);
|
let datetime = NaiveDate::from_ymd_opt(2020, 5, 1)
|
||||||
|
.unwrap()
|
||||||
|
.and_hms_opt(19, 59, 58)
|
||||||
|
.unwrap();
|
||||||
rtc.set_datetime(&datetime).unwrap();
|
rtc.set_datetime(&datetime).unwrap();
|
||||||
// do something else...
|
// do something else...
|
||||||
let time = rtc.time().unwrap();
|
let time = rtc.time().unwrap();
|
||||||
|
|
|
@ -84,13 +84,12 @@ where
|
||||||
|
|
||||||
/// Set the square-wave output frequency.
|
/// Set the square-wave output frequency.
|
||||||
pub fn set_square_wave_frequency(&mut self, freq: SqWFreq) -> Result<(), Error<CommE, PinE>> {
|
pub fn set_square_wave_frequency(&mut self, freq: SqWFreq) -> Result<(), Error<CommE, PinE>> {
|
||||||
let new_control;
|
let new_control = match freq {
|
||||||
match freq {
|
SqWFreq::_1Hz => self.control & !BitFlags::RS2 & !BitFlags::RS1,
|
||||||
SqWFreq::_1Hz => new_control = self.control & !BitFlags::RS2 & !BitFlags::RS1,
|
SqWFreq::_1_024Hz => self.control & !BitFlags::RS2 | BitFlags::RS1,
|
||||||
SqWFreq::_1_024Hz => new_control = self.control & !BitFlags::RS2 | BitFlags::RS1,
|
SqWFreq::_4_096Hz => self.control | BitFlags::RS2 & !BitFlags::RS1,
|
||||||
SqWFreq::_4_096Hz => new_control = self.control | BitFlags::RS2 & !BitFlags::RS1,
|
SqWFreq::_8_192Hz => self.control | BitFlags::RS2 | BitFlags::RS1,
|
||||||
SqWFreq::_8_192Hz => new_control = self.control | BitFlags::RS2 | BitFlags::RS1,
|
};
|
||||||
}
|
|
||||||
self.write_control(new_control)
|
self.write_control(new_control)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ where
|
||||||
if !(1..=31).contains(&day) {
|
if !(1..=31).contains(&day) {
|
||||||
return Err(Error::InvalidInputData);
|
return Err(Error::InvalidInputData);
|
||||||
}
|
}
|
||||||
self.iface.write_register(Register::DOM, day)
|
self.write_register_decimal(Register::DOM, day)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_month(&mut self, month: u8) -> Result<(), Self::Error> {
|
fn set_month(&mut self, month: u8) -> Result<(), Self::Error> {
|
||||||
|
|
|
@ -637,7 +637,7 @@ mod alarm1_day {
|
||||||
set_alarm1_hms,
|
set_alarm1_hms,
|
||||||
ALARM1_SECONDS,
|
ALARM1_SECONDS,
|
||||||
[4, 3, 2, AM | 1],
|
[4, 3, 2, AM | 1],
|
||||||
NaiveTime::from_hms(2, 3, 4)
|
NaiveTime::from_hms_opt(2, 3, 4).unwrap()
|
||||||
);
|
);
|
||||||
set_alarm_test!(
|
set_alarm_test!(
|
||||||
match_hms,
|
match_hms,
|
||||||
|
@ -922,7 +922,7 @@ mod alarm2_day {
|
||||||
set_alarm2_hm,
|
set_alarm2_hm,
|
||||||
ALARM2_MINUTES,
|
ALARM2_MINUTES,
|
||||||
[3, 2, AM | 1],
|
[3, 2, AM | 1],
|
||||||
NaiveTime::from_hms(2, 3, 0)
|
NaiveTime::from_hms_opt(2, 3, 0).unwrap()
|
||||||
);
|
);
|
||||||
set_alarm_test!(
|
set_alarm_test!(
|
||||||
match_hm,
|
match_hm,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
|
use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
|
||||||
|
use rtcc::NaiveDateTime;
|
||||||
mod common;
|
mod common;
|
||||||
use self::common::{
|
use self::common::{
|
||||||
destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234, Register,
|
destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234, Register,
|
||||||
|
@ -8,6 +9,17 @@ use self::common::{
|
||||||
use ds323x::Rtcc;
|
use ds323x::Rtcc;
|
||||||
use ds323x::{DateTimeAccess, Error, Hours, NaiveDate, NaiveTime};
|
use ds323x::{DateTimeAccess, Error, Hours, NaiveDate, NaiveTime};
|
||||||
|
|
||||||
|
fn new_datetime(y: i32, mo: u32, d: u32, h: u32, min: u32, s: u32) -> NaiveDateTime {
|
||||||
|
NaiveDate::from_ymd_opt(y, mo, d)
|
||||||
|
.unwrap()
|
||||||
|
.and_hms_opt(h, min, s)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_date(y: i32, mo: u32, d: u32) -> NaiveDate {
|
||||||
|
NaiveDate::from_ymd_opt(y, mo, d).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! read_set_param_write_two_test {
|
macro_rules! read_set_param_write_two_test {
|
||||||
($name:ident, $method:ident, $value:expr, $register:ident, $binary_value1_read:expr, $bin1:expr, $bin2:expr) => {
|
($name:ident, $method:ident, $value:expr, $register:ident, $binary_value1_read:expr, $bin1:expr, $bin2:expr) => {
|
||||||
_set_param_test!(
|
_set_param_test!(
|
||||||
|
@ -206,28 +218,28 @@ macro_rules! invalid_dt_test {
|
||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn datetime_too_small() {
|
fn datetime_too_small() {
|
||||||
let dt = NaiveDate::from_ymd(1999, 1, 2).and_hms(3, 4, 5);
|
let dt = new_datetime(1999, 1, 2, 3, 4, 5);
|
||||||
let mut dev = $create_method(&[]);
|
let mut dev = $create_method(&[]);
|
||||||
assert_invalid_input_data!(dev.set_datetime(&dt));
|
assert_invalid_input_data!(dev.set_datetime(&dt));
|
||||||
$destroy_method(dev);
|
$destroy_method(dev);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn datetime_too_big() {
|
fn datetime_too_big() {
|
||||||
let dt = NaiveDate::from_ymd(2101, 1, 2).and_hms(3, 4, 5);
|
let dt = new_datetime(2101, 1, 2, 3, 4, 5);
|
||||||
let mut dev = $create_method(&[]);
|
let mut dev = $create_method(&[]);
|
||||||
assert_invalid_input_data!(dev.set_datetime(&dt));
|
assert_invalid_input_data!(dev.set_datetime(&dt));
|
||||||
$destroy_method(dev);
|
$destroy_method(dev);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn date_too_small() {
|
fn date_too_small() {
|
||||||
let d = NaiveDate::from_ymd(1999, 1, 2);
|
let d = new_date(1999, 1, 2);
|
||||||
let mut dev = $create_method(&[]);
|
let mut dev = $create_method(&[]);
|
||||||
assert_invalid_input_data!(dev.set_date(&d));
|
assert_invalid_input_data!(dev.set_date(&d));
|
||||||
$destroy_method(dev);
|
$destroy_method(dev);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn date_too_big() {
|
fn date_too_big() {
|
||||||
let d = NaiveDate::from_ymd(2101, 1, 2);
|
let d = new_date(2101, 1, 2);
|
||||||
let mut dev = $create_method(&[]);
|
let mut dev = $create_method(&[]);
|
||||||
assert_invalid_input_data!(dev.set_date(&d));
|
assert_invalid_input_data!(dev.set_date(&d));
|
||||||
$destroy_method(dev);
|
$destroy_method(dev);
|
||||||
|
@ -255,7 +267,7 @@ macro_rules! dt_test {
|
||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn get_datetime() {
|
fn get_datetime() {
|
||||||
let dt = NaiveDate::from_ymd(2018, 8, 13).and_hms(23, 59, 58);
|
let dt = new_datetime(2018, 8, 13, 23, 59, 58);
|
||||||
let mut dev = $create_method(&$mac_trans_read!(
|
let mut dev = $create_method(&$mac_trans_read!(
|
||||||
SECONDS,
|
SECONDS,
|
||||||
[
|
[
|
||||||
|
@ -275,7 +287,7 @@ macro_rules! dt_test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_datetime() {
|
fn set_datetime() {
|
||||||
let dt = NaiveDate::from_ymd(2018, 8, 13).and_hms(23, 59, 58);
|
let dt = new_datetime(2018, 8, 13, 23, 59, 58);
|
||||||
let mut dev = $create_method(&$mac_trans_write!(
|
let mut dev = $create_method(&$mac_trans_write!(
|
||||||
SECONDS,
|
SECONDS,
|
||||||
[
|
[
|
||||||
|
@ -294,7 +306,7 @@ macro_rules! dt_test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_date() {
|
fn get_date() {
|
||||||
let d = NaiveDate::from_ymd(2018, 8, 13);
|
let d = new_date(2018, 8, 13);
|
||||||
let mut dev = $create_method(&$mac_trans_read!(
|
let mut dev = $create_method(&$mac_trans_read!(
|
||||||
DOM,
|
DOM,
|
||||||
[0b0001_0011, 0b0000_1000, 0b0001_1000],
|
[0b0001_0011, 0b0000_1000, 0b0001_1000],
|
||||||
|
@ -306,7 +318,7 @@ macro_rules! dt_test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_date() {
|
fn set_date() {
|
||||||
let d = NaiveDate::from_ymd(2018, 8, 13);
|
let d = new_date(2018, 8, 13);
|
||||||
let mut dev = $create_method(&$mac_trans_write!(
|
let mut dev = $create_method(&$mac_trans_write!(
|
||||||
DOW,
|
DOW,
|
||||||
[0b0000_0010, 0b0001_0011, 0b0000_1000, 0b0001_1000]
|
[0b0000_0010, 0b0001_0011, 0b0000_1000, 0b0001_1000]
|
||||||
|
@ -317,7 +329,7 @@ macro_rules! dt_test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_date_century() {
|
fn set_date_century() {
|
||||||
let d = NaiveDate::from_ymd(2100, 8, 13);
|
let d = new_date(2100, 8, 13);
|
||||||
let mut dev = $create_method(&$mac_trans_write!(
|
let mut dev = $create_method(&$mac_trans_write!(
|
||||||
DOW,
|
DOW,
|
||||||
[0b0000_0110, 0b0001_0011, 0b1000_1000, 0]
|
[0b0000_0110, 0b0001_0011, 0b1000_1000, 0]
|
||||||
|
@ -328,7 +340,7 @@ macro_rules! dt_test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_time() {
|
fn get_time() {
|
||||||
let t = NaiveTime::from_hms(23, 59, 58);
|
let t = NaiveTime::from_hms_opt(23, 59, 58).unwrap();
|
||||||
let mut dev = $create_method(&$mac_trans_read!(
|
let mut dev = $create_method(&$mac_trans_read!(
|
||||||
SECONDS,
|
SECONDS,
|
||||||
[0b0101_1000, 0b0101_1001, 0b0010_0011],
|
[0b0101_1000, 0b0101_1001, 0b0010_0011],
|
||||||
|
@ -340,7 +352,7 @@ macro_rules! dt_test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_time() {
|
fn set_time() {
|
||||||
let t = NaiveTime::from_hms(23, 59, 58);
|
let t = NaiveTime::from_hms_opt(23, 59, 58).unwrap();
|
||||||
let mut dev = $create_method(&$mac_trans_write!(
|
let mut dev = $create_method(&$mac_trans_write!(
|
||||||
SECONDS,
|
SECONDS,
|
||||||
[0b0101_1000, 0b0101_1001, 0b0010_0011]
|
[0b0101_1000, 0b0101_1001, 0b0010_0011]
|
||||||
|
|
Loading…
Reference in New Issue