esp_metadata_generated/
lib.rs

1// Do NOT edit this file directly. Make your changes to esp-metadata,
2// then run `cargo xtask update-metadata`.
3
4//! # (Generated) metadata for Espressif MCUs.
5//!
6//! This crate provides properties that are specific to various Espressif microcontrollers,
7//! and provides macros to work with peripherals, pins, and various other parts of the chips.
8//!
9//! This crate can be used both in firmware, as well as in build scripts, but the usage is
10//! different.
11//!
12//! ## Usage in build scripts
13//!
14//! To use the `Chip` enum, add the crate to your `Cargo.toml` build
15//! dependencies, with the `build-script` feature:
16//!
17//! ```toml
18//! [build-dependencies]
19//! esp-metadata-generated = { version = "...", features = ["build-script"] }
20//! ```
21//!
22//! ## Usage in firmware
23//!
24//! To use the various macros, add the crate to your `Cargo.toml` dependencies.
25//! A device-specific feature needs to be enabled in order to use the crate, usually
26//! picked by the user:
27//!
28//! ```toml
29//! [dependencies]
30//! esp-metadata-generated = { version = "..." }
31//! # ...
32//!
33//! [features]
34//! esp32 = ["esp-metadata-generated/esp32"]
35//! esp32c2 = ["esp-metadata-generated/esp32c2"]
36//! # ...
37//! ```
38//!
39//! ## `for_each` macros
40//!
41//! The basic syntax of this macro looks like a macro definition with two distinct syntax options:
42//!
43//! ```rust, no_run
44//! for_each_peripherals! {
45//!     // Individual matcher, invoked separately for each peripheral instance
46//!     ( <individual match syntax> ) => { /* some code */ };
47//!
48//!     // Repeated matcher, invoked once with all peripheral instances
49//!     ( all $( (<individual match syntax>) ),* ) => { /* some code */ };
50//! }
51//! ```
52//!
53//! You can specify any number of matchers in the same invocation.
54//!
55//! > The way code is generated, you will need to use the full `return` syntax to return any
56//! > values from code generated with these macros.
57//!
58//! ### Using the individual matcher
59//!
60//! In this use case, each item's data is individually passed through the macro. This can be used to
61//! generate code for each item separately, allowing specializing the implementation where needed.
62//!
63//! ```rust,no_run
64//! for_each_gpio! {
65//!   // Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input] [Output]))`
66//!   ($n:literal, $gpio:ident ($($digital_input_function:ident => $digital_input_signal:ident)*) ($($digital_output_function:ident => $digital_output_signal:ident)*) ($($pin_attribute:ident)*)) => { /* some code */ };
67//!
68//!   // You can create matchers with data filled in. This example will specifically match GPIO2
69//!   ($n:literal, GPIO2 $input_af:tt $output_af:tt $attributes:tt) => { /* Additional case only for GPIO2 */ };
70//! }
71//! ```
72//!
73//! Different macros can have multiple different syntax options for their individual matchers,
74//! usually to provide more detailed information, while preserving simpler syntax for more basic use
75//! cases. Consult each macro's documentation for available options.
76//!
77//! ### Repeated matcher
78//!
79//! With this option, all data is passed through the macro all at once. This form can be used to,
80//! for example, generate struct fields. If the macro has multiple individual matcher options,
81//! there are separate repeated matchers for each of the options.
82//!
83//! To use this option, start the match pattern with the name of the individual matcher option. When
84//! there is only a single individual matcher option, its repeated matcher is named `all` unless
85//! otherwise specified by the macro.
86//!
87//! ```rust,no_run
88//! // Example usage to create a struct containing all GPIOs:
89//! for_each_gpio! {
90//!     (all $( ($n:literal, $gpio:ident $_af_ins:tt $_af_outs:tt $_attrs:tt) ),*) => {
91//!         struct Gpios {
92//!             $(
93//!                 #[doc = concat!(" The ", stringify!($n), "th GPIO pin")]
94//!                 pub $gpio: Gpio<$n>,
95//!             )*
96//!         }
97//!     };
98//! }
99//! ```
100#![cfg_attr(docsrs, feature(doc_cfg))]
101#![cfg_attr(not(feature = "build-script"), no_std)]
102#[cfg(all(not(feature = "build-script"), feature = "esp32"))]
103include!("_generated_esp32.rs");
104#[cfg(all(not(feature = "build-script"), feature = "esp32c2"))]
105include!("_generated_esp32c2.rs");
106#[cfg(all(not(feature = "build-script"), feature = "esp32c3"))]
107include!("_generated_esp32c3.rs");
108#[cfg(all(not(feature = "build-script"), feature = "esp32c6"))]
109include!("_generated_esp32c6.rs");
110#[cfg(all(not(feature = "build-script"), feature = "esp32h2"))]
111include!("_generated_esp32h2.rs");
112#[cfg(all(not(feature = "build-script"), feature = "esp32s2"))]
113include!("_generated_esp32s2.rs");
114#[cfg(all(not(feature = "build-script"), feature = "esp32s3"))]
115include!("_generated_esp32s3.rs");
116#[cfg(any(feature = "build-script", docsrs))]
117include!("_build_script_utils.rs");