diff options
| author | Jonathan 'theJPster' Pallant <github@thejpster.org.uk> | 2025-06-15 13:24:18 +0100 |
|---|---|---|
| committer | Henrik Tjäder <henrik@tjaders.com> | 2025-06-15 12:52:16 +0000 |
| commit | 6a45bdefba2f8417410715c593f72a5fe95cfe2b (patch) | |
| tree | c697742b7a6bac039a8d8cb4d868a929e16f61e3 /rtic-monotonics/src/nrf | |
| parent | f4b0c20f8249049c88923de55912865c10741042 (diff) | |
Add details for all the other monotonic implementations.
Diffstat (limited to 'rtic-monotonics/src/nrf')
| -rw-r--r-- | rtic-monotonics/src/nrf/rtc.rs | 13 | ||||
| -rw-r--r-- | rtic-monotonics/src/nrf/timer.rs | 15 |
2 files changed, 19 insertions, 9 deletions
diff --git a/rtic-monotonics/src/nrf/rtc.rs b/rtic-monotonics/src/nrf/rtc.rs index f76e319..b63364b 100644 --- a/rtic-monotonics/src/nrf/rtc.rs +++ b/rtic-monotonics/src/nrf/rtc.rs @@ -4,19 +4,24 @@ //! //! ``` //! use rtic_monotonics::nrf::rtc::prelude::*; +//! +//! // Create the type `Mono`. It will manage the RTC timer, and +//! // run with a resolution of 30.517 µs (32,768 ticks per second). //! nrf_rtc0_monotonic!(Mono); //! //! fn init() { //! # // This is normally provided by the selected PAC -//! # let rtc = unsafe { core::mem::transmute(()) }; -//! // Start the monotonic -//! Mono::start(rtc); +//! # let RTC0 = unsafe { core::mem::transmute(()) }; +//! // Start the monotonic, passing ownership of the appropriate RTC object +//! // relevant nRF52x PAC. +//! Mono::start(RTC0); //! } //! //! 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; //! } //! } diff --git a/rtic-monotonics/src/nrf/timer.rs b/rtic-monotonics/src/nrf/timer.rs index 6bf1968..bd41496 100644 --- a/rtic-monotonics/src/nrf/timer.rs +++ b/rtic-monotonics/src/nrf/timer.rs @@ -7,19 +7,24 @@ //! //! ``` //! use rtic_monotonics::nrf::timer::prelude::*; -//! nrf_timer0_monotonic!(Mono); +//! +//! // Create the type `Mono`. It will manage the TIMER0 timer, and +//! // run with a resolution of 1 µs (1,000,000 ticks per second). +//! nrf_timer0_monotonic!(Mono, 1_000_000); //! //! fn init() { //! # // This is normally provided by the selected PAC -//! # let timer = unsafe { core::mem::transmute(()) }; -//! // Start the monotonic -//! Mono::start(timer); +//! # let TIMER0 = unsafe { core::mem::transmute(()) }; +//! // Start the monotonic, passing ownership of a TIMER0 object from the +//! // relevant nRF52x PAC. +//! Mono::start(TIMER0); //! } //! //! 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; //! } //! } |
