esp-hal/examples/src/lib.rs
Jesse Braham 68a4fb29ed
[1/3] Timer abstraction: refactor systimer and timer modules into a common timer module (#1527)
* Refactor `systimer` and `timer` modules into a common `timer` module

* Update `CHANGELOG.md`

* Rebase and update new example
2024-05-02 13:27:33 +00:00

14 lines
242 B
Rust

#![no_std]
pub fn cycles() -> u64 {
#[cfg(feature = "esp32")]
{
esp_hal::xtensa_lx::timer::get_cycle_count() as u64
}
#[cfg(not(feature = "esp32"))]
{
esp_hal::timer::systimer::SystemTimer::now()
}
}