Skip to content

Commit

Permalink
Update embedded hal to 1.0.0 (#23)
Browse files Browse the repository at this point in the history
* Update embedded hal

* Call done on the mock

---------

Co-authored-by: Robosub UTD <robosub.utdallas@gmail.com>
  • Loading branch information
democat3457 and LittleBlueSub authored Apr 5, 2024
1 parent 52e4d83 commit aca98e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ categories = ["embedded"]
keywords = ["magnetometer", "sensor", "embedded", "ak09915", "AsahiKASEI"]

[dependencies]
embedded-hal = "0.2.5"
embedded-hal = "1.0.0"

[dev-dependencies]
clap = { version = "4.2.2", features = ["derive"] }
criterion = { version = "0.5.1", features = ["html_reports"] }
embedded-hal-mock = "0.9.0"
linux-embedded-hal = "0.3.2"
embedded-hal-mock = { version = "0.10.0", features = ["eh1"] }
linux-embedded-hal = "0.4"

[[bench]]
name = "bench"
Expand Down
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use embedded_hal::blocking::i2c::{Write, WriteRead};
use embedded_hal::i2c::I2c;

const AK09915_ADDRESS: u8 = 0x0C;
///Magnetic sensor sensitivity (BSE) for Ta = 25 ˚C [µT/LSB], Typical 0.15 +- 0.0075
Expand Down Expand Up @@ -87,7 +87,7 @@ pub struct Ak09915<I2C> {

impl<I2C, E> Ak09915<I2C>
where
I2C: Write<Error = E> + WriteRead<Error = E>,
I2C: I2c<Error = E>,
{
pub fn new(i2c: I2C) -> Self {
Self {
Expand Down Expand Up @@ -283,7 +283,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use embedded_hal_mock::i2c::{Mock as I2cMock, Transaction as I2cTrans};
use embedded_hal_mock::eh1::i2c::{Mock as I2cMock, Transaction as I2cTrans};
#[test]
fn read_sensor() {
let expected_trans = [
Expand All @@ -307,5 +307,7 @@ mod tests {
assert_eq!(x, 0x2304);
assert_eq!(y, 0x2405);
assert_eq!(z, 0x2506);

sensor.i2c.done();
}
}

0 comments on commit aca98e4

Please sign in to comment.