Skip to content

Commit

Permalink
Use embedded-hal 1.0 i2c traits for temp-hal.
Browse files Browse the repository at this point in the history
  • Loading branch information
cr1901 committed Jan 29, 2022
1 parent 6577289 commit ac3c7da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ features = ["rt"]

{% if examples == "yes" %}
[dev-dependencies]
tcn75a = "0.1.0"
embedded-hal = "1.0.0-alpha.6"
embedded-hal-stable = { package = "embedded-hal", version = "0.2.6" }
nb = "1.0.0"
fixed = "1.6.0"
fixed-macro = "1.1.1"
Expand All @@ -30,6 +28,11 @@ fixed-macro = "1.1.1"
version = "1.7.2"
default_features = false

[dev-dependencies.tcn75a]
version = "0.2.0"
git = "https://github.com/cr1901/i2c-server"
branch = "embedded-hal-1.0"

[patch.crates-io.fixed-macro]
git = "https://github.com/kvinwang/fixed-macro"
version = "1.1.1"
Expand Down
9 changes: 6 additions & 3 deletions examples/temp-hal/hal.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use core::convert::Infallible;

use embedded_hal::i2c::{
self,
blocking::{Read as I2cRead, Write as I2cWrite}
};
use embedded_hal::serial::{self, nb::Write as SerWrite};
use embedded_hal::timer::{nb::CountDown, Periodic};
use embedded_hal::watchdog::blocking::{Disable, Enable, Watchdog};
use embedded_hal_stable::blocking::i2c::{Read as I2cRead, Write as I2cWrite};
use nb::Error as NbError;
use nb::Result as NbResult;

Expand Down Expand Up @@ -115,7 +118,7 @@ impl I2c {

impl I2cRead for I2c {
// FIXME: Handle various error cases.
type Error = Infallible;
type Error = i2c::ErrorKind;

fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.inner
Expand Down Expand Up @@ -148,7 +151,7 @@ impl I2cRead for I2c {

impl I2cWrite for I2c {
// FIXME: Handle various error cases.
type Error = Infallible;
type Error = i2c::ErrorKind;

fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> {
self.inner.ucb0i2csa.write(|w| w.ucsa().bits(addr.into()));
Expand Down

0 comments on commit ac3c7da

Please sign in to comment.