Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix embassy-time-driver example #3697

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions embassy-time-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
9 changes: 5 additions & 4 deletions embassy-time-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RefCell<Queue>>,
//! queue: Mutex<RefCell<Queue>>,
//! }
//!
//! impl MyDriver {
Expand All @@ -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());
//! }
//! }
Expand Down
Loading