Skip to content

Commit b1eec4a

Browse files
committed
add timer_src_clk_sys feature to support running RP2350x timer at system clock frequency
1 parent 716160e commit b1eec4a

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

embassy-rp/Cargo.toml

+11-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ critical-section-impl = ["critical-section/restore-state-u8"]
4242
unstable-pac = []
4343

4444
## Enable the timer for use with `embassy-time` with a 1MHz tick rate.
45-
time-driver = ["dep:embassy-time-driver", "embassy-time-driver?/tick-hz-1_000_000", "dep:embassy-time-queue-utils"]
45+
#time-driver = ["dep:embassy-time-driver", "embassy-time-driver?/tick-hz-1_000_000", "dep:embassy-time-queue-utils"]
46+
time-driver = ["dep:embassy-time-driver", "dep:embassy-time-queue-utils"]
4647

4748
## Enable ROM function cache. This will store the address of a ROM function when first used, improving performance of subsequent calls.
4849
rom-func-cache = []
@@ -122,7 +123,15 @@ _rp235x = ["rp-pac/rp235x"]
122123
rp235xa = ["_rp235x"]
123124
## Configure the hal for use with the rp235xB
124125
rp235xb = ["_rp235x"]
125-
126+
## Add a feature which configures `embassy-time-driver` with 150MHz `tick`s. This is an indication
127+
## by the upstream crate that the RP2350's `TIMER`s are configured with the system clock as their
128+
## source (typically 150MHz), instead of the usual 1MHz.
129+
## Compilation flag checks in `lib.rs` ensure this feature is only used together with `_rp235x`
130+
timer-src-clk-sys = [
131+
"dep:embassy-time-driver",
132+
"embassy-time-driver?/tick-hz-150_000_000",
133+
"dep:embassy-time-queue-utils",
134+
]
126135
# hack around cortex-m peripherals being wrong when running tests.
127136
_test = []
128137

embassy-rp/src/lib.rs

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66
//! ## Feature flags
77
#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]
88

9+
//! ## Compatible feature flags
10+
// `timer-src-clk-sys` only makes sense on RP235x silicon.
11+
#[cfg(all(
12+
feature = "timer-src-clk-sys",
13+
not(feature = "_rp235x"),
14+
))]
15+
compile_error!(
16+
"`embassy-rp` feature `timer-src-clk-sys` requires an `rp235x` feature (either `rp235xa` or \
17+
`rp235xb`) to be enabled."
18+
);
19+
20+
// // Prevent users from selecting both timer drivers (although this condition causes a redefinition
21+
// // error in our deps before this code can halt the compilation with an explanation...)
22+
// #[cfg(all(feature = "timer-src-clk-sys", feature = "time-driver"))]
23+
// compile_error!("Enable only one of `time-driver` or `timer-src-clk-sys`.");
24+
925
// This mod MUST go first, so that the others see its macros.
1026
pub(crate) mod fmt;
1127

0 commit comments

Comments
 (0)