From 10def24e7251de1cd915feb760c545870a329abe Mon Sep 17 00:00:00 2001 From: Paul Sbarra Date: Sun, 29 Dec 2024 23:33:18 -0600 Subject: [PATCH] fix embassy-time-driver example --- embassy-time-driver/Cargo.toml | 4 ++++ embassy-time-driver/src/lib.rs | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/embassy-time-driver/Cargo.toml b/embassy-time-driver/Cargo.toml index 2a1d5ee1d4..b709cafc13 100644 --- a/embassy-time-driver/Cargo.toml +++ b/embassy-time-driver/Cargo.toml @@ -368,3 +368,7 @@ tick-hz-5_242_880_000 = [] [dependencies] document-features = "0.2.7" + +[dev-dependencies] +critical-section = "1" +embassy-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 b77683a52e..f198a3ead3 100644 --- a/embassy-time-driver/src/lib.rs +++ b/embassy-time-driver/src/lib.rs @@ -49,15 +49,16 @@ //! Note that if you are using multiple queues, you will need to ensure that a single timer //! queue item is only ever enqueued into a single queue at a time. //! -//! ```ignore +//! ``` //! use core::cell::RefCell; //! use core::task::Waker; //! +//! use critical_section::{CriticalSection, Mutex}; //! use embassy_time_queue_utils::Queue; //! use embassy_time_driver::Driver; //! //! struct MyDriver { -//! timer_queue: critical_section::Mutex>, +//! queue: Mutex>, //! } //! //! impl MyDriver { @@ -67,14 +68,14 @@ //! } //! //! impl Driver for MyDriver { -//! // fn now(&self) -> u64 { ... } +//! fn now(&self) -> u64 { todo!() } //! //! fn schedule_wake(&self, at: u64, waker: &Waker) { //! critical_section::with(|cs| { //! let mut queue = self.queue.borrow(cs).borrow_mut(); //! if queue.schedule_wake(at, waker) { //! let mut next = queue.next_expiration(self.now()); -//! while !self.set_alarm(cs, next) { +//! while !self.set_alarm(&cs, next) { //! next = queue.next_expiration(self.now()); //! } //! }