Skip to content

Commit daa6f98

Browse files
committed
zephyr: Create Timer
Add a set of wrappers for Zephyr's timer. Timers start as `StoppedTimer`, which can be either dynamic or static (through object). This can then be started either with `start_simple` or `start_callback` which will return a `SimpleTimer` or a `CallbackTimer`. This can then be turned back into stopped timers with a `stop` method. Signed-off-by: David Brown <[email protected]>
1 parent cb766be commit daa6f98

File tree

5 files changed

+395
-0
lines changed

5 files changed

+395
-0
lines changed

zephyr/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub mod object;
1717
pub mod sync;
1818
pub mod sys;
1919
pub mod time;
20+
#[cfg(CONFIG_RUST_ALLOC)]
21+
pub mod timer;
2022

2123
pub use error::{Error, Result};
2224

zephyr/src/sync/spinmutex.rs

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub enum SpinTryLockError {
4141
/// This is modeled after [`sync::Mutex`] but instead of using `k_mutex` from Zephyr, it uses
4242
/// `k_spinlock`. It's main advantage is that it is usable from IRQ context. However, it also is
4343
/// uninterruptible, and prevents even IRQ handlers from running.
44+
///
45+
/// [`sync::Mutex`]: crate::sync::Mutex
4446
pub struct SpinMutex<T: ?Sized> {
4547
inner: UnsafeCell<raw::k_spinlock>,
4648
data: UnsafeCell<T>,

zephyr/src/sys.rs

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ pub mod critical {
5050
//! This provides the underlying critical section crate, which is useful for external crates
5151
//! that want this interface. However, it isn't a particularly hygienic interface to use. For
5252
//! something a bit nicer, please see [`sync::SpinMutex`].
53+
//!
54+
//! [`sync::SpinMutex`]: crate::sync::SpinMutex
5355
5456
use core::{ffi::c_int, ptr::addr_of_mut};
5557

zephyr/src/sys/queue.rs

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ impl Queue {
6565
/// The timeout value can be [`Forever`] to block until there is a message, [`NoWait`] to check
6666
/// and immediately return if there is no message, or a [`Duration`] to indicate a specific
6767
/// timeout.
68+
///
69+
/// [`Forever`]: crate::time::Forever
70+
/// [`NoWait`]: crate::time::NoWait
71+
/// [`Duration`]: crate::time::Duration
6872
pub unsafe fn recv<T>(&self, timeout: T) -> *mut c_void
6973
where T: Into<Timeout>
7074
{

0 commit comments

Comments
 (0)