Skip to main content

esp_storage/
lib.rs

1//! ## Feature Flags
2#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]
3#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46717278")]
4#![cfg_attr(not(all(test, feature = "emulation")), no_std)]
5
6#[cfg_attr(not(feature = "emulation"), path = "hardware.rs")]
7#[cfg_attr(feature = "emulation", path = "stub.rs")]
8mod chip_specific;
9
10mod buffer;
11mod common;
12
13pub use common::{FlashStorage, FlashStorageError};
14
15pub mod ll;
16mod nor_flash;
17mod storage;
18
19#[cfg(not(feature = "emulation"))]
20#[inline(always)]
21fn maybe_with_critical_section<R>(f: impl FnOnce() -> R) -> R {
22    #[cfg(feature = "critical-section")]
23    {
24        static LOCK: esp_sync::RawMutex = esp_sync::RawMutex::new();
25
26        LOCK.lock(f)
27    }
28
29    #[cfg(not(feature = "critical-section"))]
30    f()
31}
32
33#[cfg(feature = "emulation")]
34fn maybe_with_critical_section<R>(f: impl FnOnce() -> R) -> R {
35    f()
36}