Skip to content

doraneko94/rp2040_wait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Crate for more accurate wait times than `Delay` using `rp2040_hal::timer::Timer`.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages