ove/async_runtime/mod.rs
1// Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4//
5// This file is part of oveRTOS.
6
7//! Embassy-based async runtime hosted on the oveRTOS C substrate.
8//!
9//! Activated by the `async` Cargo feature combined with C-side
10//! `CONFIG_OVE_ASYNC=y` (build.rs detects this and emits
11//! `cfg(has_async)`). The module provides:
12//!
13//! - [`Executor`] — wraps `embassy_executor::raw::Executor` and blocks
14//! on `ove_event_wait` between polls. Yields cleanly to the
15//! underlying RTOS scheduler on FreeRTOS / Zephyr / NuttX; on POSIX
16//! blocks on a pthread condvar. Replaces the upstream `__pender`
17//! symbol with one that signals an `ove_event` via the right
18//! thread-vs-ISR variant.
19//! - `critical_section::Impl` backed by `ove_irq_lock` /
20//! `ove_irq_unlock` on every target.
21//! - `embassy_time_driver::Driver` backed by `ove_time_get_us` +
22//! `ove_timer_*_ns`.
23//! - Async wrappers around the comm primitives ([`AsyncStream`],
24//! [`AsyncQueue`], [`AsyncEventGroup`], [`AsyncSemaphore`],
25//! [`AsyncUart`], [`AsyncInput`]) that ride on the C-level
26//! `_set_notify` hooks.
27
28// Note: #[doc(cfg(...))] would surface the feature gate on docs.rs but
29// requires nightly. Skipped to keep the crate stable-only.
30
31pub(crate) mod critical_section;
32#[cfg(has_eventgroup)]
33pub mod eventgroup;
34pub mod executor;
35#[cfg(has_gpio)]
36pub mod gpio;
37#[cfg(has_i2c)]
38pub mod i2c;
39#[cfg(has_queue)]
40pub mod queue;
41#[cfg(has_sync)]
42pub mod semaphore;
43#[cfg(has_spi)]
44pub mod spi;
45#[cfg(has_stream)]
46pub mod stream;
47pub(crate) mod time_driver;
48#[cfg(has_uart)]
49pub mod uart;
50
51#[cfg(has_eventgroup)]
52pub use eventgroup::AsyncEventGroup;
53pub use executor::Executor;
54#[cfg(has_gpio)]
55pub use gpio::AsyncInput;
56#[cfg(has_i2c)]
57pub use i2c::AsyncI2c;
58#[cfg(has_queue)]
59pub use queue::AsyncQueue;
60#[cfg(has_sync)]
61pub use semaphore::AsyncSemaphore;
62#[cfg(has_spi)]
63pub use spi::AsyncSpi;
64#[cfg(has_stream)]
65pub use stream::AsyncStream;
66#[cfg(has_uart)]
67pub use uart::AsyncUart;
68
69/// Re-export of `embassy_executor::Spawner`. The Spawner returned by
70/// the executor's run-loop init closure is this type.
71pub use embassy_executor::Spawner;