Skip to content

Commit 3ab9e38

Browse files
committed
zephyr: Add k_uptime_get
This function is safe, so add a simple wrapper around the unsafe version. Signed-off-by: David Brown <[email protected]>
1 parent 5f8ef5d commit 3ab9e38

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

zephyr/src/sys.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ pub const K_FOREVER: k_timeout_t = k_timeout_t { ticks: -1 };
3030
/// performed immediately.
3131
pub const K_NO_WAIT: k_timeout_t = k_timeout_t { ticks: 0 };
3232

33+
/// Return the current uptime of the system in ms.
34+
///
35+
/// Direct Zephyr call. Precision is limited by the system tick timer.
36+
#[inline]
37+
pub fn uptime_get() -> i64 {
38+
unsafe {
39+
crate::raw::k_uptime_get()
40+
}
41+
}
42+
3343
pub mod critical {
3444
//! Zephyr implementation of critical sections.
3545
//!

0 commit comments

Comments
 (0)