Skip to content

Commit

Permalink
fix mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankurte committed Apr 18, 2024
1 parent b8f152d commit 44e5547
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository = "https://github.com/rust-iot/radio-hal"
authors = ["Ryan Kurte <ryankurte@gmail.com>"]
license = "MIT"
edition = "2018"
version = "0.12.0"
version = "0.12.1"

[package.metadata.docs.rs]
features = [ "std", "nonblocking", "mock", "helpers" ]
Expand Down
16 changes: 8 additions & 8 deletions src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::vec::Vec;

use log::debug;

use embedded_hal::delay::DelayUs;
use embedded_hal::delay::DelayNs;

use embedded_hal_mock::common::Generic;

Expand Down Expand Up @@ -217,9 +217,9 @@ impl<St, Reg, Ch, Inf, Irq, E> Transaction<St, Reg, Ch, Inf, Irq, E> {
}

/// Delay for a certain time
pub fn delay_us(us: u32) -> Self {
pub fn delay_ns(ns: u32) -> Self {
Self {
request: Request::DelayUs(us),
request: Request::DelayNs(ns),
response: Response::Ok,
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ enum Request<St, Reg, Ch> {
CheckReceive(bool),
GetReceived,

DelayUs(u32),
DelayNs(u32),
}

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -271,7 +271,7 @@ impl<St, Inf, Irq, E> From<Option<E>> for Response<St, Inf, Irq, E> {
}
}

impl<St, Reg, Ch, Inf, Irq, E> DelayUs for Radio<St, Reg, Ch, Inf, Irq, E>
impl<St, Reg, Ch, Inf, Irq, E> DelayNs for Radio<St, Reg, Ch, Inf, Irq, E>
where
St: PartialEq + Debug + Clone,
Reg: PartialEq + Debug + Clone,
Expand All @@ -280,10 +280,10 @@ where
Irq: PartialEq + Debug + Clone,
E: PartialEq + Debug + Clone,
{
fn delay_us(&mut self, us: u32) {
let n = self.next().expect("no expectation for delay_us call");
fn delay_ns(&mut self, ns: u32) {
let n = self.next().expect("no expectation for delay_ns call");

assert_eq!(&n.request, &Request::DelayUs(us));
assert_eq!(&n.request, &Request::DelayNs(ns));
}
}

Expand Down

0 comments on commit 44e5547

Please sign in to comment.