rp2040_wait

Crates.iorp2040_wait
lib.rsrp2040_wait
version0.1.0
sourcesrc
created_at2023-05-23 11:23:17.674078
updated_at2023-05-23 11:23:17.674078
descriptionCrate for more accurate wait times than Delay using rp2040_hal::timer::Timer.
homepage
repository
max_upload_size
id871920
size23,977
Shuntaro Ohno (doraneko94)

documentation

README

wait_timer

Crate for more accurate wait times than Delay using rp2040_hal::timer::Timer. In addition to wait function that waits for a specified number of seconds, gate function is implemented that keeps the time until it is re-executed constant.

How to use

  1. Create rp2040_hal::timer::Timer.
let timer = hal::timer::Timer::new(pac.TIMER, &mut pac.RESETS);
  1. Create wait_timer::Wait.
let wait = Wait::new(&timer);
  1. Use wait and/or gate methods.

Methods

wait functions

More accurate waiting times than Delay.

wait.wait_us(1_000_000);
wait.wait_ms(1_000);
wait.wait_sec(1);

gate functions

Wait a specified number of seconds since the last execution.

loop {
    wait.gate_sec(1); // A
    // ...
    wait.gate_ms(500); // B
    // ...
}
  1. A is ignored the first time.
  2. The process from A to B is executed in 500 milliseconds.
  3. Processes from B onwards (B to A) are executed in a second.
Commit count: 0

cargo fmt