avr-rust / delay

arduino-like delay routines based on busy-wait loops
Apache License 2.0
15 stars 11 forks source link

Which branch of the library to release #35

Open lord-ne opened 2 years ago

lord-ne commented 2 years ago

Currently, there are three different versions of the delay code in this repository: The version in master (from the karabut branch), the version in rerewrite (my rewrite), and the version in cyacc (the cycle-accurate version by @bombela).

Before we potentially release this crate on crates.io, we need to decide which one of these versions we are going to release, and merge that version into master.

lord-ne commented 2 years ago

My personal opinion is we should release the cyacc implementation, since it guarantees that the delays are known at compile time, which is an important property for ensuring correctness.

I'm a little concerned about the syntax (do we really want the only way to delay on AVR in Rust to involve syntax like delay_ms::<{delay_time}>()?), which is why I introduced the macros PR, but even if that PR isn't accepted I still think it's the best version of the code.

bombela commented 2 years ago

Example with a number and an expression for the cycle accurate API as is:

delay_ms::<42>();
delay_cycles::<{42 * (CPU_FREQ_HZ as u64) / 1000}>();

The same example wrapped by the macros proposed by @lord-ne:

delay_ms!(42);
delay_cycles!(42 * (CPU_FREQ_HZ as u64) / 1000);