mirror of https://github.com/eldruin/ds323x-rs
				
				
				
			Compare commits
	
		
			No commits in common. "c5fdd9057f20b17ac1ade52e9cf9d7484be371ac" and "fa431720876e0a8b47b32940fdeda91eba322cfc" have entirely different histories. 
		
	
	
		
			c5fdd9057f
			...
			fa43172087
		
	
		| 
						 | 
					@ -10,7 +10,7 @@ jobs:
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
    strategy:
 | 
					    strategy:
 | 
				
			||||||
      matrix:
 | 
					      matrix:
 | 
				
			||||||
        rust: [stable, 1.75.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
 | 
				
			||||||
| 
						 | 
					@ -23,14 +23,14 @@ jobs:
 | 
				
			||||||
          - thumbv7m-none-eabi
 | 
					          - thumbv7m-none-eabi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - uses: actions/checkout@v4
 | 
					      - uses: actions/checkout@v3
 | 
				
			||||||
      - uses: dtolnay/rust-toolchain@master
 | 
					      - uses: dtolnay/rust-toolchain@master
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          toolchain: ${{ matrix.rust }}
 | 
					          toolchain: ${{ matrix.rust }}
 | 
				
			||||||
          targets: ${{ matrix.TARGET }}
 | 
					          targets: ${{ matrix.TARGET }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Checkout CI scripts
 | 
					      - name: Checkout CI scripts
 | 
				
			||||||
        uses: actions/checkout@v4
 | 
					        uses: actions/checkout@v3
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          repository: 'eldruin/rust-driver-ci-scripts'
 | 
					          repository: 'eldruin/rust-driver-ci-scripts'
 | 
				
			||||||
          ref: 'master'
 | 
					          ref: 'master'
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ jobs:
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - uses: actions/checkout@v4
 | 
					      - uses: actions/checkout@v3
 | 
				
			||||||
      - uses: dtolnay/rust-toolchain@stable
 | 
					      - uses: dtolnay/rust-toolchain@stable
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          targets: x86_64-unknown-linux-gnu
 | 
					          targets: x86_64-unknown-linux-gnu
 | 
				
			||||||
| 
						 | 
					@ -60,10 +60,10 @@ jobs:
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - uses: actions/checkout@v4
 | 
					      - uses: actions/checkout@v3
 | 
				
			||||||
      - uses: dtolnay/rust-toolchain@master
 | 
					      - uses: dtolnay/rust-toolchain@master
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          toolchain: 1.83.0
 | 
					          toolchain: 1.70.0
 | 
				
			||||||
          targets: x86_64-unknown-linux-gnu
 | 
					          targets: x86_64-unknown-linux-gnu
 | 
				
			||||||
          components: clippy
 | 
					          components: clippy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +78,7 @@ jobs:
 | 
				
			||||||
        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@v4
 | 
					      - uses: actions/checkout@v3
 | 
				
			||||||
      - uses: dtolnay/rust-toolchain@master
 | 
					      - uses: dtolnay/rust-toolchain@master
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          toolchain: ${{ matrix.rust }}
 | 
					          toolchain: ${{ matrix.rust }}
 | 
				
			||||||
| 
						 | 
					@ -93,15 +93,16 @@ jobs:
 | 
				
			||||||
  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:
 | 
				
			||||||
      - uses: actions/checkout@v4
 | 
					
 | 
				
			||||||
 | 
					      - uses: actions/checkout@v3
 | 
				
			||||||
      - uses: dtolnay/rust-toolchain@stable
 | 
					      - uses: dtolnay/rust-toolchain@stable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Install cargo-llvm-cov
 | 
					      - name: Run cargo-tarpaulin
 | 
				
			||||||
        uses: taiki-e/install-action@cargo-llvm-cov
 | 
					        run: cargo tarpaulin --out Lcov -- --test-threads 1
 | 
				
			||||||
 | 
					 | 
				
			||||||
      - name: Generate code coverage
 | 
					 | 
				
			||||||
        run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: upload to Coveralls
 | 
					      - name: upload to Coveralls
 | 
				
			||||||
        uses: coverallsapp/github-action@master
 | 
					        uses: coverallsapp/github-action@master
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								CHANGELOG.md
								
								
								
								
							
							
						
						
									
										14
									
								
								CHANGELOG.md
								
								
								
								
							| 
						 | 
					@ -5,15 +5,7 @@ All notable changes to this project will be documented in this file.
 | 
				
			||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
 | 
					The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
 | 
				
			||||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
 | 
					and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!-- next-header -->
 | 
					## [Unreleased]
 | 
				
			||||||
## [Unreleased] - ReleaseDate
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## [0.6.0] - 2025-01-02
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Changed
 | 
					 | 
				
			||||||
- [breaking-change] Removed `Error::Pin` variant.
 | 
					 | 
				
			||||||
- [breaking-change] Update to `embedded-hal` 1.0.0.
 | 
					 | 
				
			||||||
- Raised MSRV to version 1.75.0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.5.1] - 2023-07-17
 | 
					## [0.5.1] - 2023-07-17
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,9 +82,7 @@ this CHANGELOG.
 | 
				
			||||||
[`chrono`]: https://crates.io/crates/chrono
 | 
					[`chrono`]: https://crates.io/crates/chrono
 | 
				
			||||||
[`rtcc`]: https://crates.io/crates/rtcc
 | 
					[`rtcc`]: https://crates.io/crates/rtcc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!-- next-url -->
 | 
					[Unreleased]: https://github.com/eldruin/ds323x-rs/compare/v0.5.1...HEAD
 | 
				
			||||||
[Unreleased]: https://github.com/eldruin/ds323x-rs/compare/v0.6.0...HEAD
 | 
					 | 
				
			||||||
[0.6.0]: https://github.com/eldruin/ds323x-rs/compare/v0.5.1...v0.6.0
 | 
					 | 
				
			||||||
[0.5.1]: https://github.com/eldruin/ds323x-rs/compare/v0.5.0...v0.5.1
 | 
					[0.5.1]: https://github.com/eldruin/ds323x-rs/compare/v0.5.0...v0.5.1
 | 
				
			||||||
[0.5.0]: https://github.com/eldruin/ds323x-rs/compare/v0.4.0...v0.5.0
 | 
					[0.5.0]: https://github.com/eldruin/ds323x-rs/compare/v0.4.0...v0.5.0
 | 
				
			||||||
[0.4.0]: https://github.com/eldruin/ds323x-rs/compare/v0.3.2...v0.4.0
 | 
					[0.4.0]: https://github.com/eldruin/ds323x-rs/compare/v0.3.2...v0.4.0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "ds323x"
 | 
					name = "ds323x"
 | 
				
			||||||
version = "0.6.0"
 | 
					version = "0.5.1"
 | 
				
			||||||
authors = ["Diego Barrios Romero <eldruin@gmail.com>"]
 | 
					authors = ["Diego Barrios Romero <eldruin@gmail.com>"]
 | 
				
			||||||
repository = "https://github.com/eldruin/ds323x-rs"
 | 
					repository = "https://github.com/eldruin/ds323x-rs"
 | 
				
			||||||
license = "MIT OR Apache-2.0"
 | 
					license = "MIT OR Apache-2.0"
 | 
				
			||||||
| 
						 | 
					@ -21,13 +21,12 @@ include = [
 | 
				
			||||||
edition = "2018"
 | 
					edition = "2018"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dependencies]
 | 
					[dependencies]
 | 
				
			||||||
embedded-hal = "1.0.0"
 | 
					embedded-hal = "0.2.7"
 | 
				
			||||||
rtcc = "0.3"
 | 
					rtcc = "0.3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dev-dependencies]
 | 
					[dev-dependencies]
 | 
				
			||||||
embedded-hal-mock = { version = "0.11.1", features = ["eh1"] }
 | 
					embedded-hal-mock = "0.9.0"
 | 
				
			||||||
embedded-hal-bus = "0.2"
 | 
					linux-embedded-hal = "0.3.2"
 | 
				
			||||||
linux-embedded-hal = "0.4.0"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[profile.release]
 | 
					[profile.release]
 | 
				
			||||||
lto = true
 | 
					lto = true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
Copyright (C) 2018-2025 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 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[](https://crates.io/crates/ds323x)
 | 
					[](https://crates.io/crates/ds323x)
 | 
				
			||||||
[](https://docs.rs/ds323x)
 | 
					[](https://docs.rs/ds323x)
 | 
				
			||||||

 | 
					
 | 
				
			||||||
[](https://github.com/eldruin/ds323x-rs/actions?query=workflow%3ABuild)
 | 
					[](https://github.com/eldruin/ds323x-rs/actions?query=workflow%3ABuild)
 | 
				
			||||||
[](https://coveralls.io/r/eldruin/ds323x-rs?branch=master)
 | 
					[](https://coveralls.io/r/eldruin/ds323x-rs?branch=master)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,7 @@ changes, please file an
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Minimum Supported Rust Version (MSRV)
 | 
					## Minimum Supported Rust Version (MSRV)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This crate is guaranteed to compile on stable Rust 1.75 and up. It *might*
 | 
					This crate is guaranteed to compile on stable Rust 1.35 and up. It *might*
 | 
				
			||||||
compile with older versions but that may change in any new patch release.
 | 
					compile with older versions but that may change in any new patch release.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## License
 | 
					## License
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +0,0 @@
 | 
				
			||||||
pre-release-replacements = [
 | 
					 | 
				
			||||||
    {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1},
 | 
					 | 
				
			||||||
    {file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1},
 | 
					 | 
				
			||||||
    {file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1},
 | 
					 | 
				
			||||||
    {file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n## [Unreleased] - ReleaseDate\n", exactly=1},
 | 
					 | 
				
			||||||
    {file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/eldruin/{{crate_name}}-rs/compare/{{tag_name}}...HEAD", exactly=1},
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
| 
						 | 
					@ -2,11 +2,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::{ic, interface::I2cInterface, BitFlags, Ds323x, CONTROL_POR_VALUE};
 | 
					use crate::{ic, interface::I2cInterface, BitFlags, Ds323x, CONTROL_POR_VALUE};
 | 
				
			||||||
use core::marker::PhantomData;
 | 
					use core::marker::PhantomData;
 | 
				
			||||||
use embedded_hal::i2c;
 | 
					use embedded_hal::blocking::i2c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<I2C, E> Ds323x<I2cInterface<I2C>, ic::DS3231>
 | 
					impl<I2C, E> Ds323x<I2cInterface<I2C>, ic::DS3231>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    I2C: i2c::I2c<Error = E>,
 | 
					    I2C: i2c::Write<Error = E> + i2c::WriteRead<Error = E>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /// Create a new instance of the DS3231 device.
 | 
					    /// Create a new instance of the DS3231 device.
 | 
				
			||||||
    pub fn new_ds3231(i2c: I2C) -> Self {
 | 
					    pub fn new_ds3231(i2c: I2C) -> Self {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,11 +4,11 @@ use crate::{
 | 
				
			||||||
    ic, interface::I2cInterface, BitFlags, Ds323x, Error, TempConvRate, CONTROL_POR_VALUE,
 | 
					    ic, interface::I2cInterface, BitFlags, Ds323x, Error, TempConvRate, CONTROL_POR_VALUE,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use core::marker::PhantomData;
 | 
					use core::marker::PhantomData;
 | 
				
			||||||
use embedded_hal::i2c;
 | 
					use embedded_hal::blocking::i2c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<I2C, E> Ds323x<I2cInterface<I2C>, ic::DS3232>
 | 
					impl<I2C, E> Ds323x<I2cInterface<I2C>, ic::DS3232>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    I2C: i2c::I2c<Error = E>,
 | 
					    I2C: i2c::Write<Error = E> + i2c::WriteRead<Error = E>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /// Create a new instance of the DS3232 device.
 | 
					    /// Create a new instance of the DS3232 device.
 | 
				
			||||||
    pub fn new_ds3232(i2c: I2C) -> Self {
 | 
					    pub fn new_ds3232(i2c: I2C) -> Self {
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ where
 | 
				
			||||||
    /// [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
					    /// [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
					    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
				
			||||||
    pub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<E, ()>> {
 | 
				
			||||||
        let status = self.status | BitFlags::BB32KHZ;
 | 
					        let status = self.status | BitFlags::BB32KHZ;
 | 
				
			||||||
        self.write_status_without_clearing_alarm(status)
 | 
					        self.write_status_without_clearing_alarm(status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,7 @@ where
 | 
				
			||||||
    /// it enabled. See [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
					    /// it enabled. See [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
					    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
				
			||||||
    pub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<E, ()>> {
 | 
				
			||||||
        let status = self.status & !BitFlags::BB32KHZ;
 | 
					        let status = self.status & !BitFlags::BB32KHZ;
 | 
				
			||||||
        self.write_status_without_clearing_alarm(status)
 | 
					        self.write_status_without_clearing_alarm(status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,10 @@ where
 | 
				
			||||||
    /// temperature changes will not be compensated for.
 | 
					    /// temperature changes will not be compensated for.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
					    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
				
			||||||
    pub fn set_temperature_conversion_rate(&mut self, rate: TempConvRate) -> Result<(), Error<E>> {
 | 
					    pub fn set_temperature_conversion_rate(
 | 
				
			||||||
 | 
					        &mut self,
 | 
				
			||||||
 | 
					        rate: TempConvRate,
 | 
				
			||||||
 | 
					    ) -> Result<(), Error<E, ()>> {
 | 
				
			||||||
        let status = match rate {
 | 
					        let status = match rate {
 | 
				
			||||||
            TempConvRate::_64s => self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
 | 
					            TempConvRate::_64s => self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
 | 
				
			||||||
            TempConvRate::_128s => self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
 | 
					            TempConvRate::_128s => self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,17 +2,21 @@
 | 
				
			||||||
use crate::interface::{SpiInterface, WriteData};
 | 
					use crate::interface::{SpiInterface, WriteData};
 | 
				
			||||||
use crate::{ic, BitFlags, Ds323x, Error, Register, TempConvRate, CONTROL_POR_VALUE};
 | 
					use crate::{ic, BitFlags, Ds323x, Error, Register, TempConvRate, CONTROL_POR_VALUE};
 | 
				
			||||||
use core::marker::PhantomData;
 | 
					use core::marker::PhantomData;
 | 
				
			||||||
use embedded_hal::spi;
 | 
					use embedded_hal::{blocking::spi, digital::v2::OutputPin};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<SPI, E> Ds323x<SpiInterface<SPI>, ic::DS3234>
 | 
					impl<SPI, CS, CommE, PinE> Ds323x<SpiInterface<SPI, CS>, ic::DS3234>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    SPI: spi::SpiDevice<u8, Error = E>,
 | 
					    SPI: spi::Transfer<u8, Error = CommE> + spi::Write<u8, Error = CommE>,
 | 
				
			||||||
 | 
					    CS: OutputPin<Error = PinE>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /// Create a new instance.
 | 
					    /// Create a new instance.
 | 
				
			||||||
    pub fn new_ds3234(spi: SPI) -> Self {
 | 
					    pub fn new_ds3234(spi: SPI, chip_select: CS) -> Self {
 | 
				
			||||||
        const STATUS_POR_VALUE: u8 = BitFlags::OSC_STOP | BitFlags::BB32KHZ | BitFlags::EN32KHZ;
 | 
					        const STATUS_POR_VALUE: u8 = BitFlags::OSC_STOP | BitFlags::BB32KHZ | BitFlags::EN32KHZ;
 | 
				
			||||||
        Ds323x {
 | 
					        Ds323x {
 | 
				
			||||||
            iface: SpiInterface { spi },
 | 
					            iface: SpiInterface {
 | 
				
			||||||
 | 
					                spi,
 | 
				
			||||||
 | 
					                cs: chip_select,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
            control: CONTROL_POR_VALUE,
 | 
					            control: CONTROL_POR_VALUE,
 | 
				
			||||||
            status: STATUS_POR_VALUE,
 | 
					            status: STATUS_POR_VALUE,
 | 
				
			||||||
            _ic: PhantomData,
 | 
					            _ic: PhantomData,
 | 
				
			||||||
| 
						 | 
					@ -20,8 +24,8 @@ where
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Destroy driver instance, return SPI bus instance and CS output pin.
 | 
					    /// Destroy driver instance, return SPI bus instance and CS output pin.
 | 
				
			||||||
    pub fn destroy_ds3234(self) -> SPI {
 | 
					    pub fn destroy_ds3234(self) -> (SPI, CS) {
 | 
				
			||||||
        self.iface.spi
 | 
					        (self.iface.spi, self.iface.cs)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Enable the 32kHz output when battery-powered. (enabled per default)
 | 
					    /// Enable the 32kHz output when battery-powered. (enabled per default)
 | 
				
			||||||
| 
						 | 
					@ -30,7 +34,7 @@ where
 | 
				
			||||||
    /// [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
					    /// [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
					    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
				
			||||||
    pub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.status | BitFlags::BB32KHZ;
 | 
					        let status = self.status | BitFlags::BB32KHZ;
 | 
				
			||||||
        self.write_status_without_clearing_alarm(status)
 | 
					        self.write_status_without_clearing_alarm(status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -41,7 +45,7 @@ where
 | 
				
			||||||
    /// it enabled. See [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
					    /// it enabled. See [`enable_32khz_output()`](#method.enable_32khz_output).
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
					    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
				
			||||||
    pub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.status & !BitFlags::BB32KHZ;
 | 
					        let status = self.status & !BitFlags::BB32KHZ;
 | 
				
			||||||
        self.write_status_without_clearing_alarm(status)
 | 
					        self.write_status_without_clearing_alarm(status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -53,7 +57,10 @@ where
 | 
				
			||||||
    /// temperature changes will not be compensated for.
 | 
					    /// temperature changes will not be compensated for.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
					    /// Note: This is only available for DS3232 and DS3234 devices.
 | 
				
			||||||
    pub fn set_temperature_conversion_rate(&mut self, rate: TempConvRate) -> Result<(), Error<E>> {
 | 
					    pub fn set_temperature_conversion_rate(
 | 
				
			||||||
 | 
					        &mut self,
 | 
				
			||||||
 | 
					        rate: TempConvRate,
 | 
				
			||||||
 | 
					    ) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = match rate {
 | 
					        let status = match rate {
 | 
				
			||||||
            TempConvRate::_64s => self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
 | 
					            TempConvRate::_64s => self.status & !BitFlags::CRATE1 & !BitFlags::CRATE0,
 | 
				
			||||||
            TempConvRate::_128s => self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
 | 
					            TempConvRate::_128s => self.status & !BitFlags::CRATE1 | BitFlags::CRATE0,
 | 
				
			||||||
| 
						 | 
					@ -66,14 +73,14 @@ where
 | 
				
			||||||
    /// Enable the temperature conversions when battery-powered. (enabled per default)
 | 
					    /// Enable the temperature conversions when battery-powered. (enabled per default)
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3234 devices.
 | 
					    /// Note: This is only available for DS3234 devices.
 | 
				
			||||||
    pub fn enable_temperature_conversions_on_battery(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable_temperature_conversions_on_battery(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        self.iface.write_register(Register::TEMP_CONV, 0)
 | 
					        self.iface.write_register(Register::TEMP_CONV, 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Disable the temperature conversions when battery-powered.
 | 
					    /// Disable the temperature conversions when battery-powered.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: This is only available for DS3234 devices.
 | 
					    /// Note: This is only available for DS3234 devices.
 | 
				
			||||||
    pub fn disable_temperature_conversions_on_battery(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable_temperature_conversions_on_battery(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        self.iface
 | 
					        self.iface
 | 
				
			||||||
            .write_register(Register::TEMP_CONV, BitFlags::TEMP_CONV_BAT)
 | 
					            .write_register(Register::TEMP_CONV, BitFlags::TEMP_CONV_BAT)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -150,9 +150,9 @@ fn amend_hour(hours: Hours) -> Hours {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<DI, IC, E> Ds323x<DI, IC>
 | 
					impl<DI, IC, CommE, PinE> Ds323x<DI, IC>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    DI: ReadData<Error = Error<E>> + WriteData<Error = Error<E>>,
 | 
					    DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /// Set Alarm1 for day of the month.
 | 
					    /// Set Alarm1 for day of the month.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
| 
						 | 
					@ -165,7 +165,7 @@ where
 | 
				
			||||||
        &mut self,
 | 
					        &mut self,
 | 
				
			||||||
        when: DayAlarm1,
 | 
					        when: DayAlarm1,
 | 
				
			||||||
        matching: Alarm1Matching,
 | 
					        matching: Alarm1Matching,
 | 
				
			||||||
    ) -> Result<(), Error<E>> {
 | 
					    ) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let day_invalid = when.day < 1 || when.day > 31;
 | 
					        let day_invalid = when.day < 1 || when.day > 31;
 | 
				
			||||||
        let hour_invalid = is_hour_valid(when.hour);
 | 
					        let hour_invalid = is_hour_valid(when.hour);
 | 
				
			||||||
        let minute_invalid = when.minute > 59;
 | 
					        let minute_invalid = when.minute > 59;
 | 
				
			||||||
| 
						 | 
					@ -200,7 +200,7 @@ where
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Will return an `Error::InvalidInputData` if any of the parameters is out of range.
 | 
					    /// Will return an `Error::InvalidInputData` if any of the parameters is out of range.
 | 
				
			||||||
    /// The day is not used by this matching strategy and is set to 1.
 | 
					    /// The day is not used by this matching strategy and is set to 1.
 | 
				
			||||||
    pub fn set_alarm1_hms(&mut self, when: NaiveTime) -> Result<(), Error<E>> {
 | 
					    pub fn set_alarm1_hms(&mut self, when: NaiveTime) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let alarm = DayAlarm1 {
 | 
					        let alarm = DayAlarm1 {
 | 
				
			||||||
            day: 1,
 | 
					            day: 1,
 | 
				
			||||||
            hour: Hours::H24(when.hour() as u8),
 | 
					            hour: Hours::H24(when.hour() as u8),
 | 
				
			||||||
| 
						 | 
					@ -221,7 +221,7 @@ where
 | 
				
			||||||
        &mut self,
 | 
					        &mut self,
 | 
				
			||||||
        when: WeekdayAlarm1,
 | 
					        when: WeekdayAlarm1,
 | 
				
			||||||
        matching: Alarm1Matching,
 | 
					        matching: Alarm1Matching,
 | 
				
			||||||
    ) -> Result<(), Error<E>> {
 | 
					    ) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let weekday_invalid = when.weekday < 1 || when.weekday > 7;
 | 
					        let weekday_invalid = when.weekday < 1 || when.weekday > 7;
 | 
				
			||||||
        let hour_invalid = is_hour_valid(when.hour);
 | 
					        let hour_invalid = is_hour_valid(when.hour);
 | 
				
			||||||
        let minute_invalid = when.minute > 59;
 | 
					        let minute_invalid = when.minute > 59;
 | 
				
			||||||
| 
						 | 
					@ -263,7 +263,7 @@ where
 | 
				
			||||||
        &mut self,
 | 
					        &mut self,
 | 
				
			||||||
        when: DayAlarm2,
 | 
					        when: DayAlarm2,
 | 
				
			||||||
        matching: Alarm2Matching,
 | 
					        matching: Alarm2Matching,
 | 
				
			||||||
    ) -> Result<(), Error<E>> {
 | 
					    ) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let day_invalid = when.day < 1 || when.day > 31;
 | 
					        let day_invalid = when.day < 1 || when.day > 31;
 | 
				
			||||||
        let hour_invalid = is_hour_valid(when.hour);
 | 
					        let hour_invalid = is_hour_valid(when.hour);
 | 
				
			||||||
        let minute_invalid = when.minute > 59;
 | 
					        let minute_invalid = when.minute > 59;
 | 
				
			||||||
| 
						 | 
					@ -293,7 +293,7 @@ where
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Will return an `Error::InvalidInputData` if any of the parameters is out of range.
 | 
					    /// Will return an `Error::InvalidInputData` if any of the parameters is out of range.
 | 
				
			||||||
    /// The day is not used by this matching strategy and is set to 1.
 | 
					    /// The day is not used by this matching strategy and is set to 1.
 | 
				
			||||||
    pub fn set_alarm2_hm(&mut self, when: NaiveTime) -> Result<(), Error<E>> {
 | 
					    pub fn set_alarm2_hm(&mut self, when: NaiveTime) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let alarm = DayAlarm2 {
 | 
					        let alarm = DayAlarm2 {
 | 
				
			||||||
            day: 1,
 | 
					            day: 1,
 | 
				
			||||||
            hour: Hours::H24(when.hour() as u8),
 | 
					            hour: Hours::H24(when.hour() as u8),
 | 
				
			||||||
| 
						 | 
					@ -313,7 +313,7 @@ where
 | 
				
			||||||
        &mut self,
 | 
					        &mut self,
 | 
				
			||||||
        when: WeekdayAlarm2,
 | 
					        when: WeekdayAlarm2,
 | 
				
			||||||
        matching: Alarm2Matching,
 | 
					        matching: Alarm2Matching,
 | 
				
			||||||
    ) -> Result<(), Error<E>> {
 | 
					    ) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let weekday_invalid = when.weekday < 1 || when.weekday > 7;
 | 
					        let weekday_invalid = when.weekday < 1 || when.weekday > 7;
 | 
				
			||||||
        let hour_invalid = is_hour_valid(when.hour);
 | 
					        let hour_invalid = is_hour_valid(when.hour);
 | 
				
			||||||
        let minute_invalid = when.minute > 59;
 | 
					        let minute_invalid = when.minute > 59;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,18 +5,18 @@ use crate::{
 | 
				
			||||||
    BitFlags, Ds323x, Error, Register, SqWFreq,
 | 
					    BitFlags, Ds323x, Error, Register, SqWFreq,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<DI, IC, E> Ds323x<DI, IC>
 | 
					impl<DI, IC, CommE, PinE> Ds323x<DI, IC>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    DI: ReadData<Error = Error<E>> + WriteData<Error = Error<E>>,
 | 
					    DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /// Enable the oscillator (set the clock running) (default).
 | 
					    /// Enable the oscillator (set the clock running) (default).
 | 
				
			||||||
    pub fn enable(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control & !BitFlags::EOSC)
 | 
					        self.write_control(control & !BitFlags::EOSC)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Disable the oscillator (stops the clock).
 | 
					    /// Disable the oscillator (stops the clock).
 | 
				
			||||||
    pub fn disable(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control | BitFlags::EOSC)
 | 
					        self.write_control(control | BitFlags::EOSC)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ where
 | 
				
			||||||
    /// Force a temperature conversion and time compensation with TXCO algorithm.
 | 
					    /// Force a temperature conversion and time compensation with TXCO algorithm.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The *busy* status should be checked before doing this. See [`busy()`](#method.busy)
 | 
					    /// The *busy* status should be checked before doing this. See [`busy()`](#method.busy)
 | 
				
			||||||
    pub fn convert_temperature(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn convert_temperature(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.iface.read_register(Register::CONTROL)?;
 | 
					        let control = self.iface.read_register(Register::CONTROL)?;
 | 
				
			||||||
        // do not overwrite if a conversion is in progress
 | 
					        // do not overwrite if a conversion is in progress
 | 
				
			||||||
        if (control & BitFlags::TEMP_CONV) == 0 {
 | 
					        if (control & BitFlags::TEMP_CONV) == 0 {
 | 
				
			||||||
| 
						 | 
					@ -35,55 +35,55 @@ where
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Enable the 32kHz output. (enabled per default)
 | 
					    /// Enable the 32kHz output. (enabled per default)
 | 
				
			||||||
    pub fn enable_32khz_output(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable_32khz_output(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.status | BitFlags::EN32KHZ;
 | 
					        let status = self.status | BitFlags::EN32KHZ;
 | 
				
			||||||
        self.write_status_without_clearing_alarm(status)
 | 
					        self.write_status_without_clearing_alarm(status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Disable the 32kHz output.
 | 
					    /// Disable the 32kHz output.
 | 
				
			||||||
    pub fn disable_32khz_output(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable_32khz_output(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.status & !BitFlags::EN32KHZ;
 | 
					        let status = self.status & !BitFlags::EN32KHZ;
 | 
				
			||||||
        self.write_status_without_clearing_alarm(status)
 | 
					        self.write_status_without_clearing_alarm(status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the aging offset.
 | 
					    /// Set the aging offset.
 | 
				
			||||||
    pub fn set_aging_offset(&mut self, offset: i8) -> Result<(), Error<E>> {
 | 
					    pub fn set_aging_offset(&mut self, offset: i8) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        self.iface
 | 
					        self.iface
 | 
				
			||||||
            .write_register(Register::AGING_OFFSET, offset as u8)
 | 
					            .write_register(Register::AGING_OFFSET, offset as u8)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Read the aging offset.
 | 
					    /// Read the aging offset.
 | 
				
			||||||
    pub fn aging_offset(&mut self) -> Result<i8, Error<E>> {
 | 
					    pub fn aging_offset(&mut self) -> Result<i8, Error<CommE, PinE>> {
 | 
				
			||||||
        let offset = self.iface.read_register(Register::AGING_OFFSET)?;
 | 
					        let offset = self.iface.read_register(Register::AGING_OFFSET)?;
 | 
				
			||||||
        Ok(offset as i8)
 | 
					        Ok(offset as i8)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the interrupt/square-wave output to be used as interrupt output.
 | 
					    /// Set the interrupt/square-wave output to be used as interrupt output.
 | 
				
			||||||
    pub fn use_int_sqw_output_as_interrupt(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn use_int_sqw_output_as_interrupt(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control | BitFlags::INTCN)
 | 
					        self.write_control(control | BitFlags::INTCN)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the interrupt/square-wave output to be used as square-wave output. (default)
 | 
					    /// Set the interrupt/square-wave output to be used as square-wave output. (default)
 | 
				
			||||||
    pub fn use_int_sqw_output_as_square_wave(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn use_int_sqw_output_as_square_wave(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control & !BitFlags::INTCN)
 | 
					        self.write_control(control & !BitFlags::INTCN)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Enable battery-backed square wave generation.
 | 
					    /// Enable battery-backed square wave generation.
 | 
				
			||||||
    pub fn enable_square_wave(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable_square_wave(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control | BitFlags::BBSQW)
 | 
					        self.write_control(control | BitFlags::BBSQW)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Disable battery-backed square wave generation.
 | 
					    /// Disable battery-backed square wave generation.
 | 
				
			||||||
    pub fn disable_square_wave(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable_square_wave(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control & !BitFlags::BBSQW)
 | 
					        self.write_control(control & !BitFlags::BBSQW)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the square-wave output frequency.
 | 
					    /// Set the square-wave output frequency.
 | 
				
			||||||
    pub fn set_square_wave_frequency(&mut self, freq: SqWFreq) -> Result<(), Error<E>> {
 | 
					    pub fn set_square_wave_frequency(&mut self, freq: SqWFreq) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let new_control = match freq {
 | 
					        let new_control = match freq {
 | 
				
			||||||
            SqWFreq::_1Hz => self.control & !BitFlags::RS2 & !BitFlags::RS1,
 | 
					            SqWFreq::_1Hz => self.control & !BitFlags::RS2 & !BitFlags::RS1,
 | 
				
			||||||
            SqWFreq::_1_024Hz => self.control & !BitFlags::RS2 | BitFlags::RS1,
 | 
					            SqWFreq::_1_024Hz => self.control & !BitFlags::RS2 | BitFlags::RS1,
 | 
				
			||||||
| 
						 | 
					@ -94,30 +94,30 @@ where
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Enable Alarm1 interrupts.
 | 
					    /// Enable Alarm1 interrupts.
 | 
				
			||||||
    pub fn enable_alarm1_interrupts(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable_alarm1_interrupts(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control | BitFlags::ALARM1_INT_EN)
 | 
					        self.write_control(control | BitFlags::ALARM1_INT_EN)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Disable Alarm1 interrupts.
 | 
					    /// Disable Alarm1 interrupts.
 | 
				
			||||||
    pub fn disable_alarm1_interrupts(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable_alarm1_interrupts(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control & !BitFlags::ALARM1_INT_EN)
 | 
					        self.write_control(control & !BitFlags::ALARM1_INT_EN)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Enable Alarm2 interrupts.
 | 
					    /// Enable Alarm2 interrupts.
 | 
				
			||||||
    pub fn enable_alarm2_interrupts(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn enable_alarm2_interrupts(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control | BitFlags::ALARM2_INT_EN)
 | 
					        self.write_control(control | BitFlags::ALARM2_INT_EN)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Disable Alarm2 interrupts.
 | 
					    /// Disable Alarm2 interrupts.
 | 
				
			||||||
    pub fn disable_alarm2_interrupts(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn disable_alarm2_interrupts(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.control;
 | 
					        let control = self.control;
 | 
				
			||||||
        self.write_control(control & !BitFlags::ALARM2_INT_EN)
 | 
					        self.write_control(control & !BitFlags::ALARM2_INT_EN)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn write_control(&mut self, control: u8) -> Result<(), Error<E>> {
 | 
					    fn write_control(&mut self, control: u8) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        self.iface.write_register(Register::CONTROL, control)?;
 | 
					        self.iface.write_register(Register::CONTROL, control)?;
 | 
				
			||||||
        self.control = control;
 | 
					        self.control = control;
 | 
				
			||||||
        Ok(())
 | 
					        Ok(())
 | 
				
			||||||
| 
						 | 
					@ -126,7 +126,7 @@ where
 | 
				
			||||||
    pub(crate) fn write_status_without_clearing_alarm(
 | 
					    pub(crate) fn write_status_without_clearing_alarm(
 | 
				
			||||||
        &mut self,
 | 
					        &mut self,
 | 
				
			||||||
        status: u8,
 | 
					        status: u8,
 | 
				
			||||||
    ) -> Result<(), Error<E>> {
 | 
					    ) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        // avoid clearing alarm flags
 | 
					        // avoid clearing alarm flags
 | 
				
			||||||
        let new_status = status | BitFlags::ALARM2F | BitFlags::ALARM1F;
 | 
					        let new_status = status | BitFlags::ALARM2F | BitFlags::ALARM1F;
 | 
				
			||||||
        self.iface.write_register(Register::STATUS, new_status)?;
 | 
					        self.iface.write_register(Register::STATUS, new_status)?;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,11 +9,11 @@ use crate::{
 | 
				
			||||||
    Register, Rtcc, Timelike,
 | 
					    Register, Rtcc, Timelike,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<DI, IC, E> DateTimeAccess for Ds323x<DI, IC>
 | 
					impl<DI, IC, CommE, PinE> DateTimeAccess for Ds323x<DI, IC>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    DI: ReadData<Error = Error<E>> + WriteData<Error = Error<E>>,
 | 
					    DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    type Error = Error<E>;
 | 
					    type Error = Error<CommE, PinE>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error> {
 | 
					    fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error> {
 | 
				
			||||||
        let mut data = [0; 8];
 | 
					        let mut data = [0; 8];
 | 
				
			||||||
| 
						 | 
					@ -54,9 +54,9 @@ where
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<DI, IC, E> Rtcc for Ds323x<DI, IC>
 | 
					impl<DI, IC, CommE, PinE> Rtcc for Ds323x<DI, IC>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    DI: ReadData<Error = Error<E>> + WriteData<Error = Error<E>>,
 | 
					    DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    fn seconds(&mut self) -> Result<u8, Self::Error> {
 | 
					    fn seconds(&mut self) -> Result<u8, Self::Error> {
 | 
				
			||||||
        self.read_register_decimal(Register::SECONDS)
 | 
					        self.read_register_decimal(Register::SECONDS)
 | 
				
			||||||
| 
						 | 
					@ -212,16 +212,20 @@ where
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<DI, IC, E> Ds323x<DI, IC>
 | 
					impl<DI, IC, CommE, PinE> Ds323x<DI, IC>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    DI: ReadData<Error = Error<E>> + WriteData<Error = Error<E>>,
 | 
					    DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    fn read_register_decimal(&mut self, register: u8) -> Result<u8, Error<E>> {
 | 
					    fn read_register_decimal(&mut self, register: u8) -> Result<u8, Error<CommE, PinE>> {
 | 
				
			||||||
        let data = self.iface.read_register(register)?;
 | 
					        let data = self.iface.read_register(register)?;
 | 
				
			||||||
        Ok(packed_bcd_to_decimal(data))
 | 
					        Ok(packed_bcd_to_decimal(data))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn write_register_decimal(&mut self, register: u8, decimal_number: u8) -> Result<(), Error<E>> {
 | 
					    fn write_register_decimal(
 | 
				
			||||||
 | 
					        &mut self,
 | 
				
			||||||
 | 
					        register: u8,
 | 
				
			||||||
 | 
					        decimal_number: u8,
 | 
				
			||||||
 | 
					    ) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        self.iface
 | 
					        self.iface
 | 
				
			||||||
            .write_register(register, decimal_to_packed_bcd(decimal_number))
 | 
					            .write_register(register, decimal_to_packed_bcd(decimal_number))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ fn packed_bcd_to_decimal(bcd: u8) -> u8 {
 | 
				
			||||||
    (bcd >> 4) * 10 + (bcd & 0xF)
 | 
					    (bcd >> 4) * 10 + (bcd & 0xF)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn hours_to_register<E>(hours: Hours) -> Result<u8, Error<E>> {
 | 
					fn hours_to_register<CommE, PinE>(hours: Hours) -> Result<u8, Error<CommE, PinE>> {
 | 
				
			||||||
    match hours {
 | 
					    match hours {
 | 
				
			||||||
        Hours::H24(h) if h > 23 => Err(Error::InvalidInputData),
 | 
					        Hours::H24(h) if h > 23 => Err(Error::InvalidInputData),
 | 
				
			||||||
        Hours::H24(h) => Ok(decimal_to_packed_bcd(h)),
 | 
					        Hours::H24(h) => Ok(decimal_to_packed_bcd(h)),
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ fn hours_to_register<E>(hours: Hours) -> Result<u8, Error<E>> {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn some_or_invalid_error<T, E>(data: Option<T>) -> Result<T, Error<E>> {
 | 
					fn some_or_invalid_error<T, CommE, PinE>(data: Option<T>) -> Result<T, Error<CommE, PinE>> {
 | 
				
			||||||
    if let Some(data) = data {
 | 
					    if let Some(data) = data {
 | 
				
			||||||
        Ok(data)
 | 
					        Ok(data)
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ mod tests {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
    fn if_some_then_get_inner() {
 | 
					    fn if_some_then_get_inner() {
 | 
				
			||||||
        match some_or_invalid_error::<u8, ()>(Some(1)) {
 | 
					        match some_or_invalid_error::<u8, (), ()>(Some(1)) {
 | 
				
			||||||
            Ok(1) => (),
 | 
					            Ok(1) => (),
 | 
				
			||||||
            _ => panic!(),
 | 
					            _ => panic!(),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,7 @@ mod tests {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
    fn if_none_then_error() {
 | 
					    fn if_none_then_error() {
 | 
				
			||||||
        match some_or_invalid_error::<u8, ()>(None) {
 | 
					        match some_or_invalid_error::<u8, (), ()>(None) {
 | 
				
			||||||
            Err(Error::InvalidDeviceState) => (),
 | 
					            Err(Error::InvalidDeviceState) => (),
 | 
				
			||||||
            _ => panic!(),
 | 
					            _ => panic!(),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,18 +5,18 @@ use crate::{
 | 
				
			||||||
    BitFlags, Ds323x, Error, Register,
 | 
					    BitFlags, Ds323x, Error, Register,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<DI, IC, E> Ds323x<DI, IC>
 | 
					impl<DI, IC, CommE, PinE> Ds323x<DI, IC>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    DI: ReadData<Error = Error<E>> + WriteData<Error = Error<E>>,
 | 
					    DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /// Read whether the oscillator is running
 | 
					    /// Read whether the oscillator is running
 | 
				
			||||||
    pub fn running(&mut self) -> Result<bool, Error<E>> {
 | 
					    pub fn running(&mut self) -> Result<bool, Error<CommE, PinE>> {
 | 
				
			||||||
        let control = self.iface.read_register(Register::CONTROL)?;
 | 
					        let control = self.iface.read_register(Register::CONTROL)?;
 | 
				
			||||||
        Ok((control & BitFlags::EOSC) == 0)
 | 
					        Ok((control & BitFlags::EOSC) == 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Read the busy status
 | 
					    /// Read the busy status
 | 
				
			||||||
    pub fn busy(&mut self) -> Result<bool, Error<E>> {
 | 
					    pub fn busy(&mut self) -> Result<bool, Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.iface.read_register(Register::STATUS)?;
 | 
					        let status = self.iface.read_register(Register::STATUS)?;
 | 
				
			||||||
        Ok((status & BitFlags::BUSY) != 0)
 | 
					        Ok((status & BitFlags::BUSY) != 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ where
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Once this is true, it will stay as such until cleared with
 | 
					    /// Once this is true, it will stay as such until cleared with
 | 
				
			||||||
    /// [`clear_has_been_stopped_flag()`](#method.clear_has_been_stopped_flag)
 | 
					    /// [`clear_has_been_stopped_flag()`](#method.clear_has_been_stopped_flag)
 | 
				
			||||||
    pub fn has_been_stopped(&mut self) -> Result<bool, Error<E>> {
 | 
					    pub fn has_been_stopped(&mut self) -> Result<bool, Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.iface.read_register(Register::STATUS)?;
 | 
					        let status = self.iface.read_register(Register::STATUS)?;
 | 
				
			||||||
        Ok((status & BitFlags::OSC_STOP) != 0)
 | 
					        Ok((status & BitFlags::OSC_STOP) != 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,7 @@ where
 | 
				
			||||||
    /// stopped at some point.
 | 
					    /// stopped at some point.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// See also: [`has_been_stopped()`](#method.has_been_stopped)
 | 
					    /// See also: [`has_been_stopped()`](#method.has_been_stopped)
 | 
				
			||||||
    pub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.status & !BitFlags::OSC_STOP;
 | 
					        let status = self.status & !BitFlags::OSC_STOP;
 | 
				
			||||||
        self.write_status_without_clearing_alarm(status)
 | 
					        self.write_status_without_clearing_alarm(status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ where
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Once this is true, it will stay as such until cleared with
 | 
					    /// Once this is true, it will stay as such until cleared with
 | 
				
			||||||
    /// [`clear_alarm1_matched_flag()`](#method.clear_alarm1_matched_flag)
 | 
					    /// [`clear_alarm1_matched_flag()`](#method.clear_alarm1_matched_flag)
 | 
				
			||||||
    pub fn has_alarm1_matched(&mut self) -> Result<bool, Error<E>> {
 | 
					    pub fn has_alarm1_matched(&mut self) -> Result<bool, Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.iface.read_register(Register::STATUS)?;
 | 
					        let status = self.iface.read_register(Register::STATUS)?;
 | 
				
			||||||
        Ok((status & BitFlags::ALARM1F) != 0)
 | 
					        Ok((status & BitFlags::ALARM1F) != 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ where
 | 
				
			||||||
    /// Clear flag signalling whether the Alarm1 has matched at some point.
 | 
					    /// Clear flag signalling whether the Alarm1 has matched at some point.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// See also: [`has_alarm1_matched()`](#method.has_alarm1_matched)
 | 
					    /// See also: [`has_alarm1_matched()`](#method.has_alarm1_matched)
 | 
				
			||||||
    pub fn clear_alarm1_matched_flag(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn clear_alarm1_matched_flag(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.status | BitFlags::ALARM2F;
 | 
					        let status = self.status | BitFlags::ALARM2F;
 | 
				
			||||||
        self.iface.write_register(Register::STATUS, status)
 | 
					        self.iface.write_register(Register::STATUS, status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ where
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Once this is true, it will stay as such until cleared with
 | 
					    /// Once this is true, it will stay as such until cleared with
 | 
				
			||||||
    /// [`clear_alarm2_matched_flag()`](#method.clear_alarm2_matched_flag)
 | 
					    /// [`clear_alarm2_matched_flag()`](#method.clear_alarm2_matched_flag)
 | 
				
			||||||
    pub fn has_alarm2_matched(&mut self) -> Result<bool, Error<E>> {
 | 
					    pub fn has_alarm2_matched(&mut self) -> Result<bool, Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.iface.read_register(Register::STATUS)?;
 | 
					        let status = self.iface.read_register(Register::STATUS)?;
 | 
				
			||||||
        Ok((status & BitFlags::ALARM2F) != 0)
 | 
					        Ok((status & BitFlags::ALARM2F) != 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ where
 | 
				
			||||||
    /// Clear flag signalling whether the Alarm2 has matched at some point.
 | 
					    /// Clear flag signalling whether the Alarm2 has matched at some point.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// See also: [`has_alarm2_matched()`](#method.has_alarm2_matched)
 | 
					    /// See also: [`has_alarm2_matched()`](#method.has_alarm2_matched)
 | 
				
			||||||
    pub fn clear_alarm2_matched_flag(&mut self) -> Result<(), Error<E>> {
 | 
					    pub fn clear_alarm2_matched_flag(&mut self) -> Result<(), Error<CommE, PinE>> {
 | 
				
			||||||
        let status = self.status | BitFlags::ALARM1F;
 | 
					        let status = self.status | BitFlags::ALARM1F;
 | 
				
			||||||
        self.iface.write_register(Register::STATUS, status)
 | 
					        self.iface.write_register(Register::STATUS, status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -80,7 +80,7 @@ where
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Note: It is possible to manually force a temperature conversion with
 | 
					    /// Note: It is possible to manually force a temperature conversion with
 | 
				
			||||||
    /// [`convert_temperature()`](#method.convert_temperature)
 | 
					    /// [`convert_temperature()`](#method.convert_temperature)
 | 
				
			||||||
    pub fn temperature(&mut self) -> Result<f32, Error<E>> {
 | 
					    pub fn temperature(&mut self) -> Result<f32, Error<CommE, PinE>> {
 | 
				
			||||||
        let mut data = [Register::TEMP_MSB, 0, 0];
 | 
					        let mut data = [Register::TEMP_MSB, 0, 0];
 | 
				
			||||||
        self.iface.read_data(&mut data)?;
 | 
					        self.iface.read_data(&mut data)?;
 | 
				
			||||||
        let is_negative = (data[1] & 0b1000_0000) != 0;
 | 
					        let is_negative = (data[1] & 0b1000_0000) != 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,10 @@
 | 
				
			||||||
//! I2C/SPI interfaces
 | 
					//! I2C/SPI interfaces
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::{private, Error, DEVICE_ADDRESS};
 | 
					use crate::{private, Error, DEVICE_ADDRESS};
 | 
				
			||||||
use embedded_hal::{i2c, spi};
 | 
					use embedded_hal::{
 | 
				
			||||||
 | 
					    blocking::{i2c, spi},
 | 
				
			||||||
 | 
					    digital::v2::OutputPin,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// I2C interface
 | 
					/// I2C interface
 | 
				
			||||||
#[derive(Debug, Default)]
 | 
					#[derive(Debug, Default)]
 | 
				
			||||||
| 
						 | 
					@ -11,8 +14,9 @@ pub struct I2cInterface<I2C> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// SPI interface
 | 
					/// SPI interface
 | 
				
			||||||
#[derive(Debug, Default)]
 | 
					#[derive(Debug, Default)]
 | 
				
			||||||
pub struct SpiInterface<SPI> {
 | 
					pub struct SpiInterface<SPI, CS> {
 | 
				
			||||||
    pub(crate) spi: SPI,
 | 
					    pub(crate) spi: SPI,
 | 
				
			||||||
 | 
					    pub(crate) cs: CS,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Write data
 | 
					/// Write data
 | 
				
			||||||
| 
						 | 
					@ -27,9 +31,9 @@ pub trait WriteData: private::Sealed {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<I2C, E> WriteData for I2cInterface<I2C>
 | 
					impl<I2C, E> WriteData for I2cInterface<I2C>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    I2C: i2c::I2c<Error = E>,
 | 
					    I2C: i2c::Write<Error = E>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    type Error = Error<E>;
 | 
					    type Error = Error<E, ()>;
 | 
				
			||||||
    fn write_register(&mut self, register: u8, data: u8) -> Result<(), Self::Error> {
 | 
					    fn write_register(&mut self, register: u8, data: u8) -> Result<(), Self::Error> {
 | 
				
			||||||
        let payload: [u8; 2] = [register, data];
 | 
					        let payload: [u8; 2] = [register, data];
 | 
				
			||||||
        self.i2c
 | 
					        self.i2c
 | 
				
			||||||
| 
						 | 
					@ -42,19 +46,29 @@ where
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<SPI, E> WriteData for SpiInterface<SPI>
 | 
					impl<SPI, CS, CommE, PinE> WriteData for SpiInterface<SPI, CS>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    SPI: spi::SpiDevice<u8, Error = E>,
 | 
					    SPI: spi::Write<u8, Error = CommE>,
 | 
				
			||||||
 | 
					    CS: OutputPin<Error = PinE>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    type Error = Error<E>;
 | 
					    type Error = Error<CommE, PinE>;
 | 
				
			||||||
    fn write_register(&mut self, register: u8, data: u8) -> Result<(), Self::Error> {
 | 
					    fn write_register(&mut self, register: u8, data: u8) -> Result<(), Self::Error> {
 | 
				
			||||||
 | 
					        self.cs.set_low().map_err(Error::Pin)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let payload: [u8; 2] = [register + 0x80, data];
 | 
					        let payload: [u8; 2] = [register + 0x80, data];
 | 
				
			||||||
        self.spi.write(&payload).map_err(Error::Comm)
 | 
					        let result = self.spi.write(&payload).map_err(Error::Comm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.cs.set_high().map_err(Error::Pin)?;
 | 
				
			||||||
 | 
					        result
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn write_data(&mut self, payload: &mut [u8]) -> Result<(), Self::Error> {
 | 
					    fn write_data(&mut self, payload: &mut [u8]) -> Result<(), Self::Error> {
 | 
				
			||||||
 | 
					        self.cs.set_low().map_err(Error::Pin)?;
 | 
				
			||||||
        payload[0] += 0x80;
 | 
					        payload[0] += 0x80;
 | 
				
			||||||
        self.spi.write(payload).map_err(Error::Comm)
 | 
					        let result = self.spi.write(payload).map_err(Error::Comm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.cs.set_high().map_err(Error::Pin)?;
 | 
				
			||||||
 | 
					        result
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,9 +84,9 @@ pub trait ReadData: private::Sealed {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<I2C, E> ReadData for I2cInterface<I2C>
 | 
					impl<I2C, E> ReadData for I2cInterface<I2C>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    I2C: i2c::I2c<Error = E>,
 | 
					    I2C: i2c::WriteRead<Error = E>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    type Error = Error<E>;
 | 
					    type Error = Error<E, ()>;
 | 
				
			||||||
    fn read_register(&mut self, register: u8) -> Result<u8, Self::Error> {
 | 
					    fn read_register(&mut self, register: u8) -> Result<u8, Self::Error> {
 | 
				
			||||||
        let mut data = [0];
 | 
					        let mut data = [0];
 | 
				
			||||||
        self.i2c
 | 
					        self.i2c
 | 
				
			||||||
| 
						 | 
					@ -89,18 +103,25 @@ where
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<SPI, E> ReadData for SpiInterface<SPI>
 | 
					impl<SPI, CS, CommE, PinE> ReadData for SpiInterface<SPI, CS>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    SPI: spi::SpiDevice<u8, Error = E>,
 | 
					    SPI: spi::Transfer<u8, Error = CommE>,
 | 
				
			||||||
 | 
					    CS: OutputPin<Error = PinE>,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    type Error = Error<E>;
 | 
					    type Error = Error<CommE, PinE>;
 | 
				
			||||||
    fn read_register(&mut self, register: u8) -> Result<u8, Self::Error> {
 | 
					    fn read_register(&mut self, register: u8) -> Result<u8, Self::Error> {
 | 
				
			||||||
 | 
					        self.cs.set_low().map_err(Error::Pin)?;
 | 
				
			||||||
        let mut data = [register, 0];
 | 
					        let mut data = [register, 0];
 | 
				
			||||||
        let result = self.spi.transfer_in_place(&mut data).map_err(Error::Comm);
 | 
					        let result = self.spi.transfer(&mut data).map_err(Error::Comm);
 | 
				
			||||||
        result.and(Ok(data[1]))
 | 
					        self.cs.set_high().map_err(Error::Pin)?;
 | 
				
			||||||
 | 
					        Ok(result?[1])
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn read_data(&mut self, payload: &mut [u8]) -> Result<(), Self::Error> {
 | 
					    fn read_data(&mut self, payload: &mut [u8]) -> Result<(), Self::Error> {
 | 
				
			||||||
        self.spi.transfer_in_place(payload).map_err(Error::Comm)
 | 
					        self.cs.set_low().map_err(Error::Pin)?;
 | 
				
			||||||
 | 
					        let result = self.spi.transfer(payload).map_err(Error::Comm);
 | 
				
			||||||
 | 
					        self.cs.set_high().map_err(Error::Pin)?;
 | 
				
			||||||
 | 
					        result?;
 | 
				
			||||||
 | 
					        Ok(())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										22
									
								
								src/lib.rs
								
								
								
								
							
							
						
						
									
										22
									
								
								src/lib.rs
								
								
								
								
							| 
						 | 
					@ -157,17 +157,15 @@
 | 
				
			||||||
//!
 | 
					//!
 | 
				
			||||||
//! ```no_run
 | 
					//! ```no_run
 | 
				
			||||||
//! use ds323x::Ds323x;
 | 
					//! use ds323x::Ds323x;
 | 
				
			||||||
//! use embedded_hal_bus::spi::ExclusiveDevice;
 | 
					//! use linux_embedded_hal::{SysfsPin as Pin, Spidev};
 | 
				
			||||||
//! use linux_embedded_hal::{Delay, SpidevBus, SysfsPin};
 | 
					 | 
				
			||||||
//!
 | 
					//!
 | 
				
			||||||
//! let spi = SpidevBus::open("/dev/spidev0.0").unwrap();
 | 
					//! let dev = Spidev::open("/dev/spidev0.0").unwrap();
 | 
				
			||||||
//! let chip_select = SysfsPin::new(25);
 | 
					//! let chip_select = Pin::new(24);
 | 
				
			||||||
//! let dev = ExclusiveDevice::new(spi, chip_select, Delay).unwrap();
 | 
					//! let rtc = Ds323x::new_ds3234(dev, chip_select);
 | 
				
			||||||
//! let rtc = Ds323x::new_ds3234(dev);
 | 
					 | 
				
			||||||
//! // do something...
 | 
					//! // do something...
 | 
				
			||||||
//!
 | 
					//!
 | 
				
			||||||
//! // get the SPI device back
 | 
					//! // get the SPI device and chip select pin back
 | 
				
			||||||
//! let dev = rtc.destroy_ds3234();
 | 
					//! let (dev, chip_select) = rtc.destroy_ds3234();
 | 
				
			||||||
//! ```
 | 
					//! ```
 | 
				
			||||||
//!
 | 
					//!
 | 
				
			||||||
//! ### Set the current date and time at once
 | 
					//! ### Set the current date and time at once
 | 
				
			||||||
| 
						 | 
					@ -377,9 +375,11 @@ pub const SPI_MODE_3: Mode = MODE_3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// All possible errors in this crate
 | 
					/// All possible errors in this crate
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
pub enum Error<E> {
 | 
					pub enum Error<CommE, PinE> {
 | 
				
			||||||
    /// I²C/SPI bus error
 | 
					    /// I²C/SPI bus error
 | 
				
			||||||
    Comm(E),
 | 
					    Comm(CommE),
 | 
				
			||||||
 | 
					    /// Pin setting error
 | 
				
			||||||
 | 
					    Pin(PinE),
 | 
				
			||||||
    /// Invalid input data provided
 | 
					    /// Invalid input data provided
 | 
				
			||||||
    InvalidInputData,
 | 
					    InvalidInputData,
 | 
				
			||||||
    /// Internal device state is invalid.
 | 
					    /// Internal device state is invalid.
 | 
				
			||||||
| 
						 | 
					@ -498,7 +498,7 @@ mod private {
 | 
				
			||||||
    use super::{ic, interface};
 | 
					    use super::{ic, interface};
 | 
				
			||||||
    pub trait Sealed {}
 | 
					    pub trait Sealed {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    impl<SPI> Sealed for interface::SpiInterface<SPI> {}
 | 
					    impl<SPI, CS> Sealed for interface::SpiInterface<SPI, CS> {}
 | 
				
			||||||
    impl<I2C> Sealed for interface::I2cInterface<I2C> {}
 | 
					    impl<I2C> Sealed for interface::I2cInterface<I2C> {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    impl Sealed for ic::DS3231 {}
 | 
					    impl Sealed for ic::DS3231 {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
use embedded_hal_mock::eh1::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
					use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
				
			||||||
mod common;
 | 
					mod common;
 | 
				
			||||||
use self::common::{
 | 
					use self::common::{
 | 
				
			||||||
    destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234,
 | 
					    destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234,
 | 
				
			||||||
| 
						 | 
					@ -583,7 +583,7 @@ macro_rules! set_alarm_test {
 | 
				
			||||||
    ($name:ident, $method:ident, $register:ident, [ $( $registers:expr ),+ ], $( $value:expr ),+) => {
 | 
					    ($name:ident, $method:ident, $register:ident, [ $( $registers:expr ),+ ], $( $value:expr ),+) => {
 | 
				
			||||||
        set_values_test!($name, $method,
 | 
					        set_values_test!($name, $method,
 | 
				
			||||||
            [ I2cTrans::write(DEV_ADDR, vec![Register::$register, $( $registers ),*]) ],
 | 
					            [ I2cTrans::write(DEV_ADDR, vec![Register::$register, $( $registers ),*]) ],
 | 
				
			||||||
            [ SpiTrans::transaction_start(), SpiTrans::write_vec(vec![Register::$register + 0x80, $( $registers ),*]), SpiTrans::transaction_end() ],
 | 
					            [ SpiTrans::write(vec![Register::$register + 0x80, $( $registers ),*]) ],
 | 
				
			||||||
            $($value),*
 | 
					            $($value),*
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
use ds323x::{ic, interface, Ds323x};
 | 
					use ds323x::{ic, interface, Ds323x};
 | 
				
			||||||
use embedded_hal_mock::eh1::{
 | 
					use embedded_hal_mock::{
 | 
				
			||||||
    i2c::{Mock as I2cMock, Transaction as I2cTrans},
 | 
					    i2c::{Mock as I2cMock, Transaction as I2cTrans},
 | 
				
			||||||
    spi::{Mock as SpiMock, Transaction as SpiTrans},
 | 
					    spi::{Mock as SpiMock, Transaction as SpiTrans},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -59,7 +59,8 @@ impl BitFlags {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct DummyOutputPin;
 | 
					pub struct DummyOutputPin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl embedded_hal::digital::OutputPin for DummyOutputPin {
 | 
					impl embedded_hal::digital::v2::OutputPin for DummyOutputPin {
 | 
				
			||||||
 | 
					    type Error = ();
 | 
				
			||||||
    fn set_low(&mut self) -> Result<(), Self::Error> {
 | 
					    fn set_low(&mut self) -> Result<(), Self::Error> {
 | 
				
			||||||
        Ok(())
 | 
					        Ok(())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -68,10 +69,6 @@ impl embedded_hal::digital::OutputPin for DummyOutputPin {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl embedded_hal::digital::ErrorType for DummyOutputPin {
 | 
					 | 
				
			||||||
    type Error = embedded_hal::digital::ErrorKind;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub fn new_ds3231(
 | 
					pub fn new_ds3231(
 | 
				
			||||||
    transactions: &[I2cTrans],
 | 
					    transactions: &[I2cTrans],
 | 
				
			||||||
) -> Ds323x<interface::I2cInterface<I2cMock>, ic::DS3231> {
 | 
					) -> Ds323x<interface::I2cInterface<I2cMock>, ic::DS3231> {
 | 
				
			||||||
| 
						 | 
					@ -85,9 +82,9 @@ pub fn new_ds3232(
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn new_ds3234(
 | 
					pub fn new_ds3234(
 | 
				
			||||||
    transactions: &[SpiTrans<u8>],
 | 
					    transactions: &[SpiTrans],
 | 
				
			||||||
) -> Ds323x<interface::SpiInterface<SpiMock<u8>>, ic::DS3234> {
 | 
					) -> Ds323x<interface::SpiInterface<SpiMock, DummyOutputPin>, ic::DS3234> {
 | 
				
			||||||
    Ds323x::new_ds3234(SpiMock::new(transactions))
 | 
					    Ds323x::new_ds3234(SpiMock::new(transactions), DummyOutputPin)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn destroy_ds3231(dev: Ds323x<interface::I2cInterface<I2cMock>, ic::DS3231>) {
 | 
					pub fn destroy_ds3231(dev: Ds323x<interface::I2cInterface<I2cMock>, ic::DS3231>) {
 | 
				
			||||||
| 
						 | 
					@ -98,8 +95,8 @@ pub fn destroy_ds3232(dev: Ds323x<interface::I2cInterface<I2cMock>, ic::DS3232>)
 | 
				
			||||||
    dev.destroy_ds3232().done();
 | 
					    dev.destroy_ds3232().done();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn destroy_ds3234(dev: Ds323x<interface::SpiInterface<SpiMock<u8>>, ic::DS3234>) {
 | 
					pub fn destroy_ds3234(dev: Ds323x<interface::SpiInterface<SpiMock, DummyOutputPin>, ic::DS3234>) {
 | 
				
			||||||
    dev.destroy_ds3234().done();
 | 
					    dev.destroy_ds3234().0.done();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[macro_export]
 | 
					#[macro_export]
 | 
				
			||||||
| 
						 | 
					@ -208,14 +205,10 @@ macro_rules! get_param_test {
 | 
				
			||||||
                vec![Register::$register],
 | 
					                vec![Register::$register],
 | 
				
			||||||
                vec![$binary_value]
 | 
					                vec![$binary_value]
 | 
				
			||||||
            )],
 | 
					            )],
 | 
				
			||||||
            [
 | 
					            [SpiTrans::transfer(
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					                vec![Register::$register, 0],
 | 
				
			||||||
                SpiTrans::transfer_in_place(
 | 
					                vec![Register::$register, $binary_value]
 | 
				
			||||||
                    vec![Register::$register, 0],
 | 
					            )]
 | 
				
			||||||
                    vec![Register::$register, $binary_value]
 | 
					 | 
				
			||||||
                ),
 | 
					 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -230,10 +223,7 @@ macro_rules! transactions_i2c_read {
 | 
				
			||||||
#[macro_export]
 | 
					#[macro_export]
 | 
				
			||||||
macro_rules! transactions_spi_read {
 | 
					macro_rules! transactions_spi_read {
 | 
				
			||||||
    ($register1:ident, [ $( $read_bin:expr ),+ ], [ $( $read_bin2:expr ),+ ]) => {
 | 
					    ($register1:ident, [ $( $read_bin:expr ),+ ], [ $( $read_bin2:expr ),+ ]) => {
 | 
				
			||||||
        [SpiTrans::transaction_start(),
 | 
					        [ SpiTrans::transfer(vec![Register::$register1, $( $read_bin2 ),*], vec![Register::$register1, $( $read_bin ),*]) ]
 | 
				
			||||||
         SpiTrans::transfer_in_place(vec![Register::$register1, $( $read_bin2 ),*], vec![Register::$register1, $( $read_bin ),*]),
 | 
					 | 
				
			||||||
         SpiTrans::transaction_end()
 | 
					 | 
				
			||||||
        ]
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -290,11 +280,10 @@ macro_rules! set_param_test {
 | 
				
			||||||
                DEV_ADDR,
 | 
					                DEV_ADDR,
 | 
				
			||||||
                vec![Register::$register, $binary_value]
 | 
					                vec![Register::$register, $binary_value]
 | 
				
			||||||
            )],
 | 
					            )],
 | 
				
			||||||
            [
 | 
					            [SpiTrans::write(vec![
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					                Register::$register + 0x80,
 | 
				
			||||||
                SpiTrans::write_vec(vec![Register::$register + 0x80, $binary_value]),
 | 
					                $binary_value
 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					            ])]
 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
use ds323x::SqWFreq;
 | 
					use ds323x::SqWFreq;
 | 
				
			||||||
use embedded_hal_mock::eh1::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
					use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mod common;
 | 
					mod common;
 | 
				
			||||||
use self::common::{
 | 
					use self::common::{
 | 
				
			||||||
| 
						 | 
					@ -46,11 +46,10 @@ macro_rules! call_method_test {
 | 
				
			||||||
                DEV_ADDR,
 | 
					                DEV_ADDR,
 | 
				
			||||||
                vec![Register::$register, $value_enabled]
 | 
					                vec![Register::$register, $value_enabled]
 | 
				
			||||||
            )],
 | 
					            )],
 | 
				
			||||||
            [
 | 
					            [SpiTrans::write(vec![
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					                Register::$register + 0x80,
 | 
				
			||||||
                SpiTrans::write_vec(vec![Register::$register + 0x80, $value_enabled]),
 | 
					                $value_enabled
 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					            ])]
 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -84,11 +83,10 @@ macro_rules! call_method_status_test {
 | 
				
			||||||
                $method,
 | 
					                $method,
 | 
				
			||||||
                new_ds3234,
 | 
					                new_ds3234,
 | 
				
			||||||
                destroy_ds3234,
 | 
					                destroy_ds3234,
 | 
				
			||||||
                [
 | 
					                [SpiTrans::write(vec![
 | 
				
			||||||
                    SpiTrans::transaction_start(),
 | 
					                    Register::STATUS + 0x80,
 | 
				
			||||||
                    SpiTrans::write_vec(vec![Register::STATUS + 0x80, $value_ds323x]),
 | 
					                    $value_ds323x
 | 
				
			||||||
                    SpiTrans::transaction_end(),
 | 
					                ])]
 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
| 
						 | 
					@ -106,14 +104,10 @@ macro_rules! change_if_necessary_test {
 | 
				
			||||||
                    vec![Register::$register],
 | 
					                    vec![Register::$register],
 | 
				
			||||||
                    vec![$value_enabled]
 | 
					                    vec![$value_enabled]
 | 
				
			||||||
                )],
 | 
					                )],
 | 
				
			||||||
                [
 | 
					                [SpiTrans::transfer(
 | 
				
			||||||
                    SpiTrans::transaction_start(),
 | 
					                    vec![Register::$register, 0],
 | 
				
			||||||
                    SpiTrans::transfer_in_place(
 | 
					                    vec![Register::$register, $value_enabled]
 | 
				
			||||||
                        vec![Register::$register, 0],
 | 
					                )]
 | 
				
			||||||
                        vec![Register::$register, $value_enabled]
 | 
					 | 
				
			||||||
                    ),
 | 
					 | 
				
			||||||
                    SpiTrans::transaction_end(),
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            call_triple_test!(
 | 
					            call_triple_test!(
 | 
				
			||||||
| 
						 | 
					@ -128,15 +122,11 @@ macro_rules! change_if_necessary_test {
 | 
				
			||||||
                    I2cTrans::write(DEV_ADDR, vec![Register::$register, $value_enabled])
 | 
					                    I2cTrans::write(DEV_ADDR, vec![Register::$register, $value_enabled])
 | 
				
			||||||
                ],
 | 
					                ],
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                    SpiTrans::transaction_start(),
 | 
					                    SpiTrans::transfer(
 | 
				
			||||||
                    SpiTrans::transfer_in_place(
 | 
					 | 
				
			||||||
                        vec![Register::$register, 0],
 | 
					                        vec![Register::$register, 0],
 | 
				
			||||||
                        vec![Register::$register, $value_disabled]
 | 
					                        vec![Register::$register, $value_disabled]
 | 
				
			||||||
                    ),
 | 
					                    ),
 | 
				
			||||||
                    SpiTrans::transaction_end(),
 | 
					                    SpiTrans::write(vec![Register::$register + 0x80, $value_enabled])
 | 
				
			||||||
                    SpiTrans::transaction_start(),
 | 
					 | 
				
			||||||
                    SpiTrans::write_vec(vec![Register::$register + 0x80, $value_enabled]),
 | 
					 | 
				
			||||||
                    SpiTrans::transaction_end(),
 | 
					 | 
				
			||||||
                ]
 | 
					                ]
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
use embedded_hal_mock::eh1::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
					use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
				
			||||||
use rtcc::NaiveDateTime;
 | 
					use rtcc::NaiveDateTime;
 | 
				
			||||||
mod common;
 | 
					mod common;
 | 
				
			||||||
use self::common::{
 | 
					use self::common::{
 | 
				
			||||||
| 
						 | 
					@ -35,15 +35,11 @@ macro_rules! read_set_param_write_two_test {
 | 
				
			||||||
                I2cTrans::write(DEV_ADDR, vec![Register::$register, $bin1, $bin2])
 | 
					                I2cTrans::write(DEV_ADDR, vec![Register::$register, $bin1, $bin2])
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					                SpiTrans::transfer(
 | 
				
			||||||
                SpiTrans::transfer_in_place(
 | 
					 | 
				
			||||||
                    vec![Register::$register, 0],
 | 
					                    vec![Register::$register, 0],
 | 
				
			||||||
                    vec![Register::$register, $binary_value1_read]
 | 
					                    vec![Register::$register, $binary_value1_read]
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					                SpiTrans::write(vec![Register::$register + 0x80, $bin1, $bin2])
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					 | 
				
			||||||
                SpiTrans::write_vec(vec![Register::$register + 0x80, $bin1, $bin2]),
 | 
					 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
| 
						 | 
					@ -64,15 +60,11 @@ macro_rules! read_set_param_test {
 | 
				
			||||||
                I2cTrans::write(DEV_ADDR, vec![Register::$register, $binary_value_write])
 | 
					                I2cTrans::write(DEV_ADDR, vec![Register::$register, $binary_value_write])
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					                SpiTrans::transfer(
 | 
				
			||||||
                SpiTrans::transfer_in_place(
 | 
					 | 
				
			||||||
                    vec![Register::$register, 0],
 | 
					                    vec![Register::$register, 0],
 | 
				
			||||||
                    vec![Register::$register, $binary_value_read]
 | 
					                    vec![Register::$register, $binary_value_read]
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					                SpiTrans::write(vec![Register::$register + 0x80, $binary_value_write])
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					 | 
				
			||||||
                SpiTrans::write_vec(vec![Register::$register + 0x80, $binary_value_write]),
 | 
					 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
| 
						 | 
					@ -264,11 +256,7 @@ macro_rules! transactions_i2c_write {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
macro_rules! transactions_spi_write {
 | 
					macro_rules! transactions_spi_write {
 | 
				
			||||||
    ($register:ident, [ $( $exp_bin:expr ),+ ]) => {
 | 
					    ($register:ident, [ $( $exp_bin:expr ),+ ]) => {
 | 
				
			||||||
            [
 | 
					            [ SpiTrans::write(vec![Register::$register + 0x80, $( $exp_bin ),*]) ]
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					 | 
				
			||||||
                SpiTrans::write_vec(vec![Register::$register + 0x80, $( $exp_bin ),*]),
 | 
					 | 
				
			||||||
                SpiTrans::transaction_end()
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
use ds323x::TempConvRate;
 | 
					use ds323x::TempConvRate;
 | 
				
			||||||
use embedded_hal_mock::eh1::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
					use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(unused)]
 | 
					#[allow(unused)]
 | 
				
			||||||
mod common;
 | 
					mod common;
 | 
				
			||||||
| 
						 | 
					@ -24,11 +24,7 @@ macro_rules! call_method_status_test {
 | 
				
			||||||
                $method,
 | 
					                $method,
 | 
				
			||||||
                new_ds3234,
 | 
					                new_ds3234,
 | 
				
			||||||
                destroy_ds3234,
 | 
					                destroy_ds3234,
 | 
				
			||||||
                [
 | 
					                [SpiTrans::write(vec![Register::STATUS + 0x80, $value])]
 | 
				
			||||||
                    SpiTrans::transaction_start(),
 | 
					 | 
				
			||||||
                    SpiTrans::write_vec(vec![Register::STATUS + 0x80, $value]),
 | 
					 | 
				
			||||||
                    SpiTrans::transaction_end(),
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
| 
						 | 
					@ -70,11 +66,10 @@ macro_rules! set_param_test_2_4 {
 | 
				
			||||||
                DEV_ADDR,
 | 
					                DEV_ADDR,
 | 
				
			||||||
                vec![Register::$register, $binary_value]
 | 
					                vec![Register::$register, $binary_value]
 | 
				
			||||||
            )],
 | 
					            )],
 | 
				
			||||||
            [
 | 
					            [SpiTrans::write(vec![
 | 
				
			||||||
                SpiTrans::transaction_start(),
 | 
					                Register::$register + 0x80,
 | 
				
			||||||
                SpiTrans::write_vec(vec![Register::$register + 0x80, $binary_value]),
 | 
					                $binary_value
 | 
				
			||||||
                SpiTrans::transaction_end(),
 | 
					            ])]
 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
use embedded_hal_mock::eh1::spi::Transaction as SpiTrans;
 | 
					use embedded_hal_mock::spi::Transaction as SpiTrans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(unused)]
 | 
					#[allow(unused)]
 | 
				
			||||||
mod common;
 | 
					mod common;
 | 
				
			||||||
| 
						 | 
					@ -9,11 +9,7 @@ call_test!(
 | 
				
			||||||
    enable_temperature_conversions_on_battery,
 | 
					    enable_temperature_conversions_on_battery,
 | 
				
			||||||
    new_ds3234,
 | 
					    new_ds3234,
 | 
				
			||||||
    destroy_ds3234,
 | 
					    destroy_ds3234,
 | 
				
			||||||
    [
 | 
					    [SpiTrans::write(vec![Register::TEMP_CONV + 0x80, 0])]
 | 
				
			||||||
        SpiTrans::transaction_start(),
 | 
					 | 
				
			||||||
        SpiTrans::write_vec(vec![Register::TEMP_CONV + 0x80, 0]),
 | 
					 | 
				
			||||||
        SpiTrans::transaction_end()
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
call_test!(
 | 
					call_test!(
 | 
				
			||||||
| 
						 | 
					@ -21,9 +17,8 @@ call_test!(
 | 
				
			||||||
    disable_temperature_conversions_on_battery,
 | 
					    disable_temperature_conversions_on_battery,
 | 
				
			||||||
    new_ds3234,
 | 
					    new_ds3234,
 | 
				
			||||||
    destroy_ds3234,
 | 
					    destroy_ds3234,
 | 
				
			||||||
    [
 | 
					    [SpiTrans::write(vec![
 | 
				
			||||||
        SpiTrans::transaction_start(),
 | 
					        Register::TEMP_CONV + 0x80,
 | 
				
			||||||
        SpiTrans::write_vec(vec![Register::TEMP_CONV + 0x80, BitFlags::TEMP_CONV_BAT]),
 | 
					        BitFlags::TEMP_CONV_BAT
 | 
				
			||||||
        SpiTrans::transaction_end(),
 | 
					    ])]
 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
use embedded_hal_mock::eh1::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
					use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans};
 | 
				
			||||||
mod common;
 | 
					mod common;
 | 
				
			||||||
use self::common::{
 | 
					use self::common::{
 | 
				
			||||||
    destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234,
 | 
					    destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue