esp_metadata/
lib.rs

1//! Metadata for Espressif devices, primarily intended for use in build scripts.
2#![cfg_attr(not(feature = "build"), no_std)]
3
4#[cfg(feature = "build")]
5mod generate_cfg;
6
7#[cfg(feature = "build")]
8pub use generate_cfg::*;
9
10/// Macro to get the start of the given memory region.
11///
12/// ```rust,no-run
13/// const DRAM_START: usize = esp_metadata::memory_region_start("DRAM");
14/// ```
15#[macro_export]
16macro_rules! memory_region_start {
17    ( $var:expr ) => {
18        const {
19            match usize::from_str_radix(env!(concat!("ESP_METADATA_REGION_", $var, "_START")), 10) {
20                Ok(val) => val,
21                Err(_) => {
22                    core::assert!(false, "Unable to parse memory region.");
23                    0
24                }
25            }
26        }
27    };
28}
29
30/// Macro to get the end of the given memory region.
31///
32/// ```rust,no-run
33/// const DRAM_END: usize = esp_metadata::memory_region_end("DRAM");
34/// ```
35#[macro_export]
36macro_rules! memory_region_end {
37    ( $var:expr ) => {
38        const {
39            match usize::from_str_radix(env!(concat!("ESP_METADATA_REGION_", $var, "_END")), 10) {
40                Ok(val) => val,
41                Err(_) => {
42                    core::assert!(false, "Unable to parse memory region.");
43                    0
44                }
45            }
46        }
47    };
48}