Merge time-driver and time-queue-driver traits, make HALs own and handle the queue.
This commit is contained in:
committed by
Dániel Buga
parent
ec96395d08
commit
b268b1795f
@@ -38,6 +38,8 @@
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! use core::task::Waker;
|
||||
//!
|
||||
//! use embassy_time_driver::Driver;
|
||||
//!
|
||||
//! struct MyDriver{} // not public!
|
||||
@@ -46,6 +48,10 @@
|
||||
//! fn now(&self) -> u64 {
|
||||
//! todo!()
|
||||
//! }
|
||||
//!
|
||||
//! fn schedule_wake(&self, at: u64, waker: &Waker) {
|
||||
//! todo!()
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! embassy_time_driver::time_driver_impl!(static DRIVER: MyDriver = MyDriver{});
|
||||
@@ -54,6 +60,8 @@
|
||||
//! ## Feature flags
|
||||
#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]
|
||||
|
||||
use core::task::Waker;
|
||||
|
||||
mod tick;
|
||||
|
||||
/// Ticks per second of the global timebase.
|
||||
@@ -74,6 +82,10 @@ pub trait Driver: Send + Sync + 'static {
|
||||
/// you MUST extend them to 64-bit, for example by counting overflows in software,
|
||||
/// or chaining multiple timers together.
|
||||
fn now(&self) -> u64;
|
||||
|
||||
/// Schedules a waker to be awoken at moment `at`.
|
||||
/// If this moment is in the past, the waker might be awoken immediately.
|
||||
fn schedule_wake(&self, at: u64, waker: &Waker);
|
||||
}
|
||||
|
||||
extern "Rust" {
|
||||
@@ -97,5 +109,10 @@ macro_rules! time_driver_impl {
|
||||
fn _embassy_time_now() -> u64 {
|
||||
<$t as $crate::Driver>::now(&$name)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
fn _embassy_time_schedule_wake(at: u64, waker: &core::task::Waker) {
|
||||
<$t as $crate::Driver>::schedule_wake(&$name, at, waker);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user