Open FoxyHawk opened 5 years ago
Yes, but no. DelayUs
is often used for sub-ms delays, so it's better to use something more precise. You can see one of the examples here: https://github.com/riscv-rust/riscv-rust-quickstart/blob/5ff7048687e807b52d3df0d05dd0729a7c52bf79/examples/spi_wifi.rs#L106-L113, but I'm not sure it works correctly.
At this point it relies more on the frequency than anything else. I suppose >10MHz is a non issue to get the us accuracy on a busy loop. Although it is not the same for sub MHz...
I agree that this approach works good for >10MHz (and timer works even better for core frequency <32kHz). However, I do not see how to achieve better precision in general than with counting core clock ticks.
https://github.com/riscv-rust/e310x-hal/blob/f8cded2f409b737802bd9a424fdbc052db7798e7/src/delay.rs#L58
Changing 1000 by 1000000 could do it for Sleep ?