From 1434d2f97a48f29cbe480a4d306ecf8716b1b2d4 Mon Sep 17 00:00:00 2001 From: Charles Edward Gagnon <76854355+carloskiki@users.noreply.github.com> Date: Sat, 2 Nov 2024 16:03:17 -0400 Subject: [PATCH 1/2] enhanced docs for time driver --- embassy-time-driver/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/embassy-time-driver/src/lib.rs b/embassy-time-driver/src/lib.rs index 8000a9dcb..75f7037e3 100644 --- a/embassy-time-driver/src/lib.rs +++ b/embassy-time-driver/src/lib.rs @@ -109,12 +109,20 @@ pub trait Driver: Send + Sync + 'static { /// Try allocating an alarm handle. Returns None if no alarms left. /// Initially the alarm has no callback set, and a null `ctx` pointer. /// + /// The allocated alarm is a reusable resource and can be used multiple times. + /// Once the alarm has fired, it remains allocated and can be set again without needing + /// to be reallocated. + /// /// # Safety /// It is UB to make the alarm fire before setting a callback. unsafe fn allocate_alarm(&self) -> Option; /// Set the callback function to be called when the alarm triggers. /// The callback may be called from any context (interrupt or thread mode). + /// + /// The callback is maintained after the alarm has fired. Callers do not need + /// to set a callback again before setting another alarm, unless they want to + /// change the callback function or context. fn set_alarm_callback(&self, alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()); /// Set an alarm at the given timestamp. From 5c1f9cf99cc0b6d0215357bb4041ce5b936e9095 Mon Sep 17 00:00:00 2001 From: Charles Edward Gagnon Date: Sat, 2 Nov 2024 16:11:53 -0400 Subject: [PATCH 2/2] rustfmt --- embassy-time-driver/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/embassy-time-driver/src/lib.rs b/embassy-time-driver/src/lib.rs index 75f7037e3..12f40b9b9 100644 --- a/embassy-time-driver/src/lib.rs +++ b/embassy-time-driver/src/lib.rs @@ -109,8 +109,8 @@ pub trait Driver: Send + Sync + 'static { /// Try allocating an alarm handle. Returns None if no alarms left. /// Initially the alarm has no callback set, and a null `ctx` pointer. /// - /// The allocated alarm is a reusable resource and can be used multiple times. - /// Once the alarm has fired, it remains allocated and can be set again without needing + /// The allocated alarm is a reusable resource and can be used multiple times. + /// Once the alarm has fired, it remains allocated and can be set again without needing /// to be reallocated. /// /// # Safety @@ -120,8 +120,8 @@ pub trait Driver: Send + Sync + 'static { /// Set the callback function to be called when the alarm triggers. /// The callback may be called from any context (interrupt or thread mode). /// - /// The callback is maintained after the alarm has fired. Callers do not need - /// to set a callback again before setting another alarm, unless they want to + /// The callback is maintained after the alarm has fired. Callers do not need + /// to set a callback again before setting another alarm, unless they want to /// change the callback function or context. fn set_alarm_callback(&self, alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ());