aboutsummaryrefslogtreecommitdiff
path: root/rtic-monotonics/src/rp2040.rs
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2023-04-01 20:48:23 +0200
committerEmil Fresk <emil.fresk@gmail.com>2023-04-02 15:19:07 +0200
commita2f153249f926876e7169016f3dc8e861a9ef065 (patch)
tree1f2ccf36f5b8fc878792704d162924337f54eaf4 /rtic-monotonics/src/rp2040.rs
parent064cf19265f72d7f01e0847c545e6250391a2172 (diff)
Added nRF monotonics
Diffstat (limited to 'rtic-monotonics/src/rp2040.rs')
-rw-r--r--rtic-monotonics/src/rp2040.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs
index 9d2f4f3..5e880cd 100644
--- a/rtic-monotonics/src/rp2040.rs
+++ b/rtic-monotonics/src/rp2040.rs
@@ -1,4 +1,25 @@
//! A monotonic implementation for RP2040's Timer peripheral.
+//!
+//! # Example
+//!
+//! ```
+//! use rtic_monotonics::rp2040::*;
+//!
+//! # async fn usage() {
+//! # let timer = unsafe { core::mem::transmute(()) };
+//! # let mut resets = unsafe { core::mem::transmute(()) };
+//! // Generate the required token
+//! let token = rtic_monotonics::create_rp2040_monotonic_token!();
+//!
+//! // Start the monotonic
+//! Timer::start(timer, &mut resets, token);
+//!
+//! loop {
+//! // Use the monotonic
+//! Timer::delay(100.millis()).await;
+//! }
+//! # }
+//! ```
use super::Monotonic;
pub use super::{TimeoutError, TimerQueue};
@@ -41,6 +62,7 @@ impl Timer {
}
/// Timeout at a specific time.
+ #[inline]
pub async fn timeout_at<F: Future>(
instant: <Self as Monotonic>::Instant,
future: F,
@@ -64,6 +86,7 @@ impl Timer {
}
/// Delay to some specific time instant.
+ #[inline]
pub async fn delay_until(instant: <Self as Monotonic>::Instant) {
TIMER_QUEUE.delay_until(instant).await;
}