aboutsummaryrefslogtreecommitdiff
path: root/rtic-monotonics/src/stm32.rs
diff options
context:
space:
mode:
authorJonathan 'theJPster' Pallant <github@thejpster.org.uk>2025-06-15 13:24:18 +0100
committerHenrik Tjäder <henrik@tjaders.com>2025-06-15 12:52:16 +0000
commit6a45bdefba2f8417410715c593f72a5fe95cfe2b (patch)
treec697742b7a6bac039a8d8cb4d868a929e16f61e3 /rtic-monotonics/src/stm32.rs
parentf4b0c20f8249049c88923de55912865c10741042 (diff)
Add details for all the other monotonic implementations.
Diffstat (limited to 'rtic-monotonics/src/stm32.rs')
-rw-r--r--rtic-monotonics/src/stm32.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/rtic-monotonics/src/stm32.rs b/rtic-monotonics/src/stm32.rs
index fbcee0c..e6cb71b 100644
--- a/rtic-monotonics/src/stm32.rs
+++ b/rtic-monotonics/src/stm32.rs
@@ -8,23 +8,28 @@
//! ```
//! use rtic_monotonics::stm32::prelude::*;
//!
-//! // Define the monotonic and set it to 1MHz tick rate
+//! // Create the type `Mono`. It will manage the TIM2 timer, and
+//! // run with a resolution of 1 µs (1,000,000 ticks per second).
//! stm32_tim2_monotonic!(Mono, 1_000_000);
//!
//! fn init() {
//! // If using `embassy-stm32` HAL, timer clock can be read out like this:
//! let timer_clock_hz = embassy_stm32::peripherals::TIM2::frequency();
-//! // Or define it manually if you are using other HAL or know correct frequency:
+//! // Or define it manually if you are using another HAL or know the
+//! // correct frequency:
//! let timer_clock_hz = 64_000_000;
//!
-//! // Start the monotonic
+//! // Start the monotonic. The TIM2 prescaler is calculated from the
+//! // clock frequency given here, and the resolution given to the
+//! // `stm32_tim2_monotonic!` macro call above. No PAC object is required.
//! Mono::start(timer_clock_hz);
//! }
//!
//! async fn usage() {
//! loop {
-//! // Use the monotonic
+//! // You can use the monotonic to get the time...
//! let timestamp = Mono::now();
+//! // ...and you can use it to add a delay to this async function
//! Mono::delay(100.millis()).await;
//! }
//! }