rtic-monotonics: Simplify features, default is 1kHz

Make 100 Hz or 10 kHz opt in through features,
which are meant for testing primarily.
This commit is contained in:
Henrik Tjäder 2023-02-04 10:14:12 +01:00
parent ace010f4e9
commit 858160a55d
4 changed files with 18 additions and 13 deletions

View file

@ -13,4 +13,4 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
### Fixed ### Fixed
## [v0.1.0] - 2023-xx-xx ## [v1.0.0] - 2023-xx-xx

View file

@ -22,10 +22,8 @@ embedded-hal-async = "0.2.0-alpha.0"
fugit = { version = "0.3.6", features = ["defmt"] } fugit = { version = "0.3.6", features = ["defmt"] }
rtic-time = { version = "1.0.0-alpha.0", path = "../rtic-time" } rtic-time = { version = "1.0.0-alpha.0", path = "../rtic-time" }
atomic-polyfill = "1" atomic-polyfill = "1"
cfg-if = "1.0.0"
[features] [features]
default = ["systick_1khz"]
systick_100hz = [] systick_100hz = []
systick_1khz = []
systick_10khz = [] systick_10khz = []

View file

@ -8,16 +8,23 @@ use cortex_m::peripheral::SYST;
use embedded_hal_async::delay::DelayUs; use embedded_hal_async::delay::DelayUs;
pub use fugit::ExtU32; pub use fugit::ExtU32;
#[cfg(feature = "systick_100hz")] // Features should be additive, here systick_100hz gets picked if both
const TIMER_HZ: u32 = 100; // `systick_100hz` and `systick_10khz` are enabled.
#[cfg(feature = "systick_1khz")] cfg_if::cfg_if! {
const TIMER_HZ: u32 = 1_000; 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;
}
}
#[cfg(feature = "systick_10khz")] /// Systick implementing `rtic_monotonic::Monotonic` which runs at 1 kHz, 100Hz or 10 kHz.
const TIMER_HZ: u32 = 10_000;
/// Systick implementing `rtic_monotonic::Monotonic` which runs at 1 kHz.
pub struct Systick; pub struct Systick;
impl Systick { impl Systick {

View file

@ -51,7 +51,7 @@ lm3s6965 = "0.1.3"
cortex-m-semihosting = "0.5.0" cortex-m-semihosting = "0.5.0"
rtic-time = { path = "../rtic-time" } rtic-time = { path = "../rtic-time" }
rtic-channel = { path = "../rtic-channel" } rtic-channel = { path = "../rtic-channel" }
rtic-monotonics = { path = "../rtic-monotonics", default-features = false } rtic-monotonics = { path = "../rtic-monotonics" }
[dev-dependencies.futures] [dev-dependencies.futures]
version = "0.3.26" version = "0.3.26"