Skip to content

Commit fa0d9be

Browse files
thejpsterkorken89
authored andcommitted
Improved example and comments for the systick! macro.
1 parent 53ff4fe commit fa0d9be

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

rtic-monotonics/src/systick.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! [`Monotonic`](rtic_time::Monotonic) based on Cortex-M SysTick.
2+
//!
23
//! Note: this implementation is inefficient as it
34
//! ticks and generates interrupts at a constant rate.
45
//!
@@ -9,11 +10,9 @@
910
//! systick_monotonic!(Mono, 1_000);
1011
//!
1112
//! fn init() {
12-
//! # // This is normally provided by the selected PAC
13-
//! # let systick = unsafe { core::mem::transmute(()) };
14-
//! #
15-
//! // Start the monotonic
16-
//! Mono::start(systick, 12_000_000);
13+
//! let core_peripherals = cortex_m::Peripherals::take().unwrap();
14+
//! // Start the monotonic using the cortex-m crate's Systick driver
15+
//! Mono::start(core_peripherals.SYST, 12_000_000);
1716
//! }
1817
//!
1918
//! async fn usage() {
@@ -134,6 +133,15 @@ impl TimerQueueBackend for SystickBackend {
134133

135134
/// Create a Systick based monotonic and register the Systick interrupt for it.
136135
///
136+
/// This macro expands to produce a new type called `$name`, which has a `fn
137+
/// start()` function for you to call. The type has an implementation of the
138+
/// `rtic_monotonics::TimerQueueBasedMonotonic` trait, the
139+
/// `embedded_hal::delay::DelayNs` trait and the
140+
/// `embedded_hal_async::delay::DelayNs` trait.
141+
///
142+
/// This macro also produces an interrupt handler for the SysTick interrupt, by
143+
/// creating an `extern "C" fn SysTick() { ... }`.
144+
///
137145
/// See [`crate::systick`] for more details.
138146
///
139147
/// # Arguments

0 commit comments

Comments
 (0)