Skip to content

Commit

Permalink
Merge pull request #35 from rust-iot/update-embedded-hal
Browse files Browse the repository at this point in the history
update delay_us
  • Loading branch information
ryankurte authored Apr 18, 2024
2 parents 7aade85 + e1f6649 commit bc4d5f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/blocking.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Blocking APIs on top of the base radio traits
//!
//! These implementations use the radio's DelayNs implementation to
//! These implementations use the radio's DelayUs implementation to
//! poll on completion of operations.
//!
//! ## <https://github.com/rust-iot/radio-hal>
Expand Down Expand Up @@ -63,7 +63,7 @@ impl<E> From<E> for BlockingError<E> {
}

/// Blocking transmit function implemented over `radio::Transmit` and `radio::Power` using the provided
/// `BlockingOptions` and radio-internal `DelayNs` impl to poll for completion
/// `BlockingOptions` and radio-internal `DelayUs` impl to poll for completion
#[cfg_attr(
feature = "mock",
doc = r##"
Expand All @@ -75,7 +75,7 @@ use radio::{BlockingTransmit, BlockingOptions};
# let mut radio = MockRadio::new(&[
# Transaction::start_transmit(vec![0xaa, 0xbb], None),
# Transaction::check_transmit(Ok(false)),
# Transaction::delay_ns(100000),
# Transaction::delay_us(100),
# Transaction::check_transmit(Ok(true)),
# ]);
#
Expand Down Expand Up @@ -137,7 +137,7 @@ where
}

/// Blocking receive function implemented over `radio::Receive` using the provided `BlockingOptions`
/// and radio-internal `DelayNs` impl to poll for completion
/// and radio-internal `DelayUs` impl to poll for completion
#[cfg_attr(
feature = "mock",
doc = r##"
Expand All @@ -152,7 +152,7 @@ let info = BasicInfo::new(-81, 0);
# let mut radio = MockRadio::new(&[
# Transaction::start_receive(None),
# Transaction::check_receive(true, Ok(false)),
# Transaction::delay_ns(100000),
# Transaction::delay_us(100),
# Transaction::check_receive(true, Ok(true)),
# Transaction::get_received(Ok((data.to_vec(), info.clone()))),
# ]);
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::DelayNs;
use embedded_hal::delay::DelayUs;

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_ns(ns: u32) -> Self {
pub fn delay_us(us: u32) -> Self {
Self {
request: Request::DelayNs(ns),
request: Request::DelayUs(us),
response: Response::Ok,
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ enum Request<St, Reg, Ch> {
CheckReceive(bool),
GetReceived,

DelayNs(u32),
DelayUs(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> DelayNs for Radio<St, Reg, Ch, Inf, Irq, E>
impl<St, Reg, Ch, Inf, Irq, E> DelayUs 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_ns(&mut self, ns: u32) {
let n = self.next().expect("no expectation for delay_ns call");
fn delay_us(&mut self, us: u32) {
let n = self.next().expect("no expectation for delay_us call");

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

Expand Down

0 comments on commit bc4d5f0

Please sign in to comment.