Skip to content

Commit 5f22818

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 8c04b64 commit 5f22818

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
@@ -20,6 +20,16 @@ use zephyr_sys::k_timeout_t;
2020
pub const K_FOREVER: k_timeout_t = k_timeout_t { ticks: -1 };
2121
pub const K_NO_WAIT: k_timeout_t = k_timeout_t { ticks: 0 };
2222

23+
/// Return the current uptime of the system in ms.
24+
///
25+
/// Direct Zephyr call. Precision is limited by the system tick timer.
26+
#[inline]
27+
pub fn uptime_get() -> i64 {
28+
unsafe {
29+
crate::raw::k_uptime_get()
30+
}
31+
}
32+
2333
pub mod critical {
2434
//! Zephyr implementation of critical sections.
2535
//!

0 commit comments

Comments
 (0)