Equivalent to Arduino's millis

Hello!

I'm currently experimenting with Rust and avr-hal and my Arduino Nano. While I'm a professional developer for 13 years, I don't have much experience with Rust or embedded programming. So some easy to follow example code would be appreciated. :slight_smile:

I'm currently looking for a way to measure the time between 2 events. Is there something as easy to use as millis() from Arduino?

Thank you very much,

iGEL

crates.io and docs.rs are good places for finding things like this.
https://crates.io/crates/avr_delay

std::time::Instant is not available on #![no_std]-only targets like AVR, and avr_delay only provides delay routines, not a background timer like millis().

2 Likes

Someone else asked me the same question and I wrote a blog-post about a solution: Write your own Arduino millis() in Rust

If you just care about the code, you can find it here: https://github.com/Rahix/avr-hal/blob/master/boards/arduino-uno/examples/uno-millis.rs

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.