We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I believe thread::sleep cannot provide microsecond precision on linux.
thread::sleep
Failing example:
extern crate embedded_hal; extern crate linux_embedded_hal as hal; use embedded_hal::blocking::delay::DelayUs; fn main() { let us = 10u8; let t = ::std::time::SystemTime::now(); let mut delay = hal::Delay{}; delay.delay_us(us); println!("Expecting {}us, got {}us", us, t.elapsed().unwrap().subsec_nanos() / 1000); }
Prints
Running `target/release/test_hal` Expecting 10us, got 84us
What is the recommended way to get this level of precision?
As an example this very bad loop works:
pub fn delay_us(us: u32) { let target = Instant::now() + Duration::new(0, us * 1000); while Instant::now() < target { } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I believe
thread::sleep
cannot provide microsecond precision on linux.Failing example:
Prints
Running `target/release/test_hal` Expecting 10us, got 84us
What is the recommended way to get this level of precision?
As an example this very bad loop works:
The text was updated successfully, but these errors were encountered: