aboutsummaryrefslogtreecommitdiff
path: root/rtic-monotonics
diff options
context:
space:
mode:
Diffstat (limited to 'rtic-monotonics')
-rw-r--r--rtic-monotonics/CHANGELOG.md2
-rw-r--r--rtic-monotonics/Cargo.toml4
-rw-r--r--rtic-monotonics/src/systick_monotonic.rs25
3 files changed, 18 insertions, 13 deletions
diff --git a/rtic-monotonics/CHANGELOG.md b/rtic-monotonics/CHANGELOG.md
index e990223..d3a9d84 100644
--- a/rtic-monotonics/CHANGELOG.md
+++ b/rtic-monotonics/CHANGELOG.md
@@ -13,4 +13,4 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
### Fixed
-## [v0.1.0] - 2023-xx-xx
+## [v1.0.0] - 2023-xx-xx
diff --git a/rtic-monotonics/Cargo.toml b/rtic-monotonics/Cargo.toml
index f94a78b..4014fe7 100644
--- a/rtic-monotonics/Cargo.toml
+++ b/rtic-monotonics/Cargo.toml
@@ -22,10 +22,8 @@ embedded-hal-async = "0.2.0-alpha.0"
fugit = { version = "0.3.6", features = ["defmt"] }
rtic-time = { version = "1.0.0-alpha.0", path = "../rtic-time" }
atomic-polyfill = "1"
+cfg-if = "1.0.0"
[features]
-default = ["systick_1khz"]
-
systick_100hz = []
-systick_1khz = []
systick_10khz = []
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 {