rusty_esp_core_esp/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(unsafe_code)]
3//! `rusty_esp_core-esp` — chip backends for `rusty_esp_core`.
4//!
5//! This is the **wrap** crate of the package: where the silicon must be
6//! touched, it calls the esp-rs HAL (Track B, `esp-hal`) or ESP-IDF (Track A,
7//! `esp-idf`) and exposes the core crate's traits over it. Nothing product- or
8//! codec-specific lives here; that is the core's job.
9//!
10//! `unsafe` is denied crate-wide; a backend that must use it at a DMA or FFI
11//! boundary opts in per block with `#[allow(unsafe_code)]` and a `// SAFETY:`
12//! comment stating the invariant.
13
14#[cfg(feature = "alloc")]
15extern crate alloc;
16
17#[cfg(all(feature = "esp-hal", feature = "esp-idf"))]
18compile_error!("enable exactly one track: `esp-hal` (no_std) or `esp-idf` (std)");
19
20pub use rusty_esp_core as core;
21
22/// Which track this build of the backend crate was compiled for.
23#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24pub enum Track {
25 /// No chip backend compiled in: host build, traits only.
26 Host,
27 /// Track B — bare metal, esp-hal + Embassy.
28 EspHal,
29 /// Track A — std on ESP-IDF.
30 EspIdf,
31}
32
33/// The track this crate was built with.
34pub const TRACK: Track = if cfg!(feature = "esp-hal") {
35 Track::EspHal
36} else if cfg!(feature = "esp-idf") {
37 Track::EspIdf
38} else {
39 Track::Host
40};
41
42#[cfg(feature = "esp-hal")]
43pub mod hal {
44 //! Track B backends. Drivers land here with their esp-hal pin.
45}
46
47#[cfg(feature = "esp-idf")]
48pub mod idf {
49 //! Track A backends. Drivers land here with their esp-idf-svc pin.
50}