diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-11-03 12:44:49 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-11-03 12:44:49 +0000 |
| commit | c75e1e2a9ed58fbd6c4d08426a26d1505957c68b (patch) | |
| tree | 272e81091a08c7abba28541326d284c37850470e | |
| parent | fcbbef01cd3c5292be29b78b674f0593277545e7 (diff) | |
| parent | 5c1f9cf99cc0b6d0215357bb4041ce5b936e9095 (diff) | |
Merge pull request #3495 from carloskiki/patch-1
Enhanced docs for time driver
| -rw-r--r-- | embassy-time-driver/src/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/embassy-time-driver/src/lib.rs b/embassy-time-driver/src/lib.rs index 8000a9dcb..12f40b9b9 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 { | |||
| 109 | /// Try allocating an alarm handle. Returns None if no alarms left. | 109 | /// Try allocating an alarm handle. Returns None if no alarms left. |
| 110 | /// Initially the alarm has no callback set, and a null `ctx` pointer. | 110 | /// Initially the alarm has no callback set, and a null `ctx` pointer. |
| 111 | /// | 111 | /// |
| 112 | /// The allocated alarm is a reusable resource and can be used multiple times. | ||
| 113 | /// Once the alarm has fired, it remains allocated and can be set again without needing | ||
| 114 | /// to be reallocated. | ||
| 115 | /// | ||
| 112 | /// # Safety | 116 | /// # Safety |
| 113 | /// It is UB to make the alarm fire before setting a callback. | 117 | /// It is UB to make the alarm fire before setting a callback. |
| 114 | unsafe fn allocate_alarm(&self) -> Option<AlarmHandle>; | 118 | unsafe fn allocate_alarm(&self) -> Option<AlarmHandle>; |
| 115 | 119 | ||
| 116 | /// Set the callback function to be called when the alarm triggers. | 120 | /// Set the callback function to be called when the alarm triggers. |
| 117 | /// The callback may be called from any context (interrupt or thread mode). | 121 | /// The callback may be called from any context (interrupt or thread mode). |
| 122 | /// | ||
| 123 | /// The callback is maintained after the alarm has fired. Callers do not need | ||
| 124 | /// to set a callback again before setting another alarm, unless they want to | ||
| 125 | /// change the callback function or context. | ||
| 118 | fn set_alarm_callback(&self, alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()); | 126 | fn set_alarm_callback(&self, alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()); |
| 119 | 127 | ||
| 120 | /// Set an alarm at the given timestamp. | 128 | /// Set an alarm at the given timestamp. |
