@@ -34,14 +34,21 @@ use core::fmt::Debug;
34
34
compile_error ! ( "Rust does not (yet) support dynamic frequency timer" ) ;
35
35
36
36
// Given the above not defined, the system time base comes from a kconfig.
37
- /// The system time base. The system clock has this many ticks per second.
37
+ /// The system time base. The system clock has this many ticks per second. Values such as
38
+ /// timeouts are defined as some number of these ticks.
38
39
pub const SYS_FREQUENCY : u32 = crate :: kconfig:: CONFIG_SYS_CLOCK_TICKS_PER_SEC as u32 ;
39
40
40
- /// Zephyr can be configured for either 64-bit or 32-bit time values. Use the appropriate type
41
- /// internally to match. This should end up the same size as `k_ticks_t`, but unsigned instead of
42
- /// signed.
41
+ // Zephyr can be configured for either 64-bit or 32-bit time values. Use the appropriate type
42
+ // internally to match. This should end up the same size as `k_ticks_t`, but unsigned instead of
43
+ // signed.
44
+
45
+ /// Represnts a count of time ticks. Matches Zephyr's `crate::raw::k_ticks_t`, but as an unsigned
46
+ /// value, to match Fugit's time requirements.
43
47
#[ cfg( CONFIG_TIMEOUT_64BIT ) ]
44
48
pub type Tick = u64 ;
49
+
50
+ /// Represnts a count of time ticks. Matches Zephyr's `crate::raw::k_ticks_t`, but as an unsigned
51
+ /// value, to match Fugit's time requirements.
45
52
#[ cfg( not( CONFIG_TIMEOUT_64BIT ) ) ]
46
53
pub type Tick = u32 ;
47
54
@@ -66,7 +73,11 @@ pub type Instant = fugit::Instant<Tick, 1, SYS_FREQUENCY>;
66
73
// The absolute time offset is only implemented when time is a 64-bit value. This also means that
67
74
// "Instant" isn't available when time is defined as a 32-bit value.
68
75
69
- // Wrapper around the timeout type, so we can implement From/Info.
76
+ /// Wrapper around the timeout type, so we can implement From/Info.
77
+ ///
78
+ /// This wrapper allows us to implement `From` and `Info` from the Fugit types into the Zephyr
79
+ /// types. This allows various methods to accept either value, as well as the `Forever` and
80
+ /// `NoWait` values defined here.
70
81
pub struct Timeout ( pub k_timeout_t ) ;
71
82
72
83
// `From` allows methods to take a time of various types and convert it into a Zephyr timeout.
@@ -89,8 +100,9 @@ impl From<Instant> for Timeout {
89
100
}
90
101
}
91
102
92
- /// A sleep that waits forever. This is its own type, that is `Into<Timeout>` and can be used
93
- /// anywhere a timeout is needed.
103
+ /// A timeout that waits forever.
104
+ ///
105
+ /// This is its own type, that is `Into<Timeout>` and can be used anywhere a timeout is needed.
94
106
pub struct Forever ;
95
107
96
108
impl From < Forever > for Timeout {
@@ -99,8 +111,9 @@ impl From<Forever> for Timeout {
99
111
}
100
112
}
101
113
102
- /// A sleep that doesn't ever wait. This is its own type, that is `Info<Timeout>` and can be used
103
- /// anywhere a timeout is needed.
114
+ /// A timeout that doesn't ever wait.
115
+ ///
116
+ /// This is its own type, that is `Info<Timeout>` and can be used anywhere a timeout is needed.
104
117
pub struct NoWait ;
105
118
106
119
impl From < NoWait > for Timeout {
@@ -109,8 +122,10 @@ impl From<NoWait> for Timeout {
109
122
}
110
123
}
111
124
112
- /// Put the current thread to sleep, for the given duration. Uses `k_sleep` for the actual sleep.
113
- /// Returns a duration roughly representing the remaining amount of time if the sleep was woken.
125
+ /// Put the current thread to sleep, for the given duration.
126
+ ///
127
+ /// Uses `k_sleep` for the actual sleep. Returns a duration roughly representing the remaining
128
+ /// amount of time if the sleep was woken.
114
129
pub fn sleep < T > ( timeout : T ) -> Duration
115
130
where T : Into < Timeout > ,
116
131
{
0 commit comments