aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-time-driver/Cargo.toml4
-rw-r--r--embassy-time-driver/src/lib.rs9
2 files changed, 9 insertions, 4 deletions
diff --git a/embassy-time-driver/Cargo.toml b/embassy-time-driver/Cargo.toml
index 2a1d5ee1d..b709cafc1 100644
--- a/embassy-time-driver/Cargo.toml
+++ b/embassy-time-driver/Cargo.toml
@@ -368,3 +368,7 @@ tick-hz-5_242_880_000 = []
368 368
369[dependencies] 369[dependencies]
370document-features = "0.2.7" 370document-features = "0.2.7"
371
372[dev-dependencies]
373critical-section = "1"
374embassy-time-queue-utils = { path = "../embassy-time-queue-utils" } \ No newline at end of file
diff --git a/embassy-time-driver/src/lib.rs b/embassy-time-driver/src/lib.rs
index b77683a52..f198a3ead 100644
--- a/embassy-time-driver/src/lib.rs
+++ b/embassy-time-driver/src/lib.rs
@@ -49,15 +49,16 @@
49//! Note that if you are using multiple queues, you will need to ensure that a single timer 49//! Note that if you are using multiple queues, you will need to ensure that a single timer
50//! queue item is only ever enqueued into a single queue at a time. 50//! queue item is only ever enqueued into a single queue at a time.
51//! 51//!
52//! ```ignore 52//! ```
53//! use core::cell::RefCell; 53//! use core::cell::RefCell;
54//! use core::task::Waker; 54//! use core::task::Waker;
55//! 55//!
56//! use critical_section::{CriticalSection, Mutex};
56//! use embassy_time_queue_utils::Queue; 57//! use embassy_time_queue_utils::Queue;
57//! use embassy_time_driver::Driver; 58//! use embassy_time_driver::Driver;
58//! 59//!
59//! struct MyDriver { 60//! struct MyDriver {
60//! timer_queue: critical_section::Mutex<RefCell<Queue>>, 61//! queue: Mutex<RefCell<Queue>>,
61//! } 62//! }
62//! 63//!
63//! impl MyDriver { 64//! impl MyDriver {
@@ -67,14 +68,14 @@
67//! } 68//! }
68//! 69//!
69//! impl Driver for MyDriver { 70//! impl Driver for MyDriver {
70//! // fn now(&self) -> u64 { ... } 71//! fn now(&self) -> u64 { todo!() }
71//! 72//!
72//! fn schedule_wake(&self, at: u64, waker: &Waker) { 73//! fn schedule_wake(&self, at: u64, waker: &Waker) {
73//! critical_section::with(|cs| { 74//! critical_section::with(|cs| {
74//! let mut queue = self.queue.borrow(cs).borrow_mut(); 75//! let mut queue = self.queue.borrow(cs).borrow_mut();
75//! if queue.schedule_wake(at, waker) { 76//! if queue.schedule_wake(at, waker) {
76//! let mut next = queue.next_expiration(self.now()); 77//! let mut next = queue.next_expiration(self.now());
77//! while !self.set_alarm(cs, next) { 78//! while !self.set_alarm(&cs, next) {
78//! next = queue.next_expiration(self.now()); 79//! next = queue.next_expiration(self.now());
79//! } 80//! }
80//! } 81//! }