diff options
| author | Paul Sbarra <[email protected]> | 2024-12-29 23:33:18 -0600 |
|---|---|---|
| committer | Paul Sbarra <[email protected]> | 2024-12-29 23:33:33 -0600 |
| commit | 10def24e7251de1cd915feb760c545870a329abe (patch) | |
| tree | 1c020def0f2097875c30906efb052c126595b57d /embassy-time-driver/src/lib.rs | |
| parent | a4f8fddd696ca2e3705827ba4b3806cbadcb3134 (diff) | |
fix embassy-time-driver example
Diffstat (limited to 'embassy-time-driver/src/lib.rs')
| -rw-r--r-- | embassy-time-driver/src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
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 | //! } |
