diff options
| author | Henrik Tjäder <henrik@tjaders.com> | 2023-02-04 10:14:12 +0100 |
|---|---|---|
| committer | Henrik Tjäder <henrik@tjaders.com> | 2023-03-01 00:35:13 +0100 |
| commit | 858160a55d839bb4064006aa55ddb581259a3074 (patch) | |
| tree | 061990c8b008ab9ad3c9f21d5ec2f58f44877c9f /rtic-monotonics/src | |
| parent | ace010f4e9a7cf1d8b90e9a05eb1b7ea583c2c81 (diff) | |
rtic-monotonics: Simplify features, default is 1kHz
Make 100 Hz or 10 kHz opt in through features,
which are meant for testing primarily.
Diffstat (limited to 'rtic-monotonics/src')
| -rw-r--r-- | rtic-monotonics/src/systick_monotonic.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/rtic-monotonics/src/systick_monotonic.rs b/rtic-monotonics/src/systick_monotonic.rs index a5a0aef..885da92 100644 --- a/rtic-monotonics/src/systick_monotonic.rs +++ b/rtic-monotonics/src/systick_monotonic.rs @@ -8,16 +8,23 @@ use cortex_m::peripheral::SYST; use embedded_hal_async::delay::DelayUs; pub use fugit::ExtU32; -#[cfg(feature = "systick_100hz")] -const TIMER_HZ: u32 = 100; - -#[cfg(feature = "systick_1khz")] -const TIMER_HZ: u32 = 1_000; - -#[cfg(feature = "systick_10khz")] -const TIMER_HZ: u32 = 10_000; +// Features should be additive, here systick_100hz gets picked if both +// `systick_100hz` and `systick_10khz` are enabled. + +cfg_if::cfg_if! { + if #[cfg(feature = "systick_100hz")] + { + const TIMER_HZ: u32 = 100; + } else if #[cfg(feature = "systick_10khz")] + { + const TIMER_HZ: u32 = 10_000; + } else { + // Default case is 1 kHz + const TIMER_HZ: u32 = 1_000; + } +} -/// Systick implementing `rtic_monotonic::Monotonic` which runs at 1 kHz. +/// Systick implementing `rtic_monotonic::Monotonic` which runs at 1 kHz, 100Hz or 10 kHz. pub struct Systick; impl Systick { |
