esp_metadata_generated/
_generated_esp32h2.rs

1// Do NOT edit this file directly. Make your changes to esp-metadata,
2// then run `cargo xtask update-metadata`.
3
4/// The name of the chip as `&str`
5///
6/// # Example
7///
8/// ```rust, no_run
9/// use esp_hal::chip;
10/// let chip_name = chip!();
11#[doc = concat!("assert_eq!(chip_name, ", chip!(), ")")]
12/// ```
13#[macro_export]
14#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
15macro_rules! chip {
16    () => {
17        "esp32h2"
18    };
19}
20/// The properties of this chip and its drivers.
21#[macro_export]
22#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
23macro_rules! property {
24    ("chip") => {
25        "esp32h2"
26    };
27    ("arch") => {
28        "riscv"
29    };
30    ("cores") => {
31        1
32    };
33    ("cores", str) => {
34        stringify!(1)
35    };
36    ("trm") => {
37        "https://www.espressif.com/sites/default/files/documentation/esp32-h2_technical_reference_manual_en.pdf"
38    };
39    ("assist_debug.has_sp_monitor") => {
40        true
41    };
42    ("assist_debug.has_region_monitor") => {
43        true
44    };
45    ("gpio.has_bank_1") => {
46        false
47    };
48    ("gpio.gpio_function") => {
49        1
50    };
51    ("gpio.gpio_function", str) => {
52        stringify!(1)
53    };
54    ("gpio.constant_0_input") => {
55        60
56    };
57    ("gpio.constant_0_input", str) => {
58        stringify!(60)
59    };
60    ("gpio.constant_1_input") => {
61        56
62    };
63    ("gpio.constant_1_input", str) => {
64        stringify!(56)
65    };
66    ("gpio.remap_iomux_pin_registers") => {
67        false
68    };
69    ("gpio.func_in_sel_offset") => {
70        0
71    };
72    ("gpio.func_in_sel_offset", str) => {
73        stringify!(0)
74    };
75    ("gpio.input_signal_max") => {
76        124
77    };
78    ("gpio.input_signal_max", str) => {
79        stringify!(124)
80    };
81    ("gpio.output_signal_max") => {
82        128
83    };
84    ("gpio.output_signal_max", str) => {
85        stringify!(128)
86    };
87    ("i2c_master.has_fsm_timeouts") => {
88        true
89    };
90    ("i2c_master.has_hw_bus_clear") => {
91        true
92    };
93    ("i2c_master.has_bus_timeout_enable") => {
94        true
95    };
96    ("i2c_master.separate_filter_config_registers") => {
97        false
98    };
99    ("i2c_master.can_estimate_nack_reason") => {
100        true
101    };
102    ("i2c_master.has_conf_update") => {
103        true
104    };
105    ("i2c_master.has_reliable_fsm_reset") => {
106        true
107    };
108    ("i2c_master.has_arbitration_en") => {
109        true
110    };
111    ("i2c_master.has_tx_fifo_watermark") => {
112        true
113    };
114    ("i2c_master.bus_timeout_is_exponential") => {
115        true
116    };
117    ("i2c_master.max_bus_timeout") => {
118        31
119    };
120    ("i2c_master.max_bus_timeout", str) => {
121        stringify!(31)
122    };
123    ("i2c_master.ll_intr_mask") => {
124        262143
125    };
126    ("i2c_master.ll_intr_mask", str) => {
127        stringify!(262143)
128    };
129    ("i2c_master.fifo_size") => {
130        32
131    };
132    ("i2c_master.fifo_size", str) => {
133        stringify!(32)
134    };
135    ("interrupts.status_registers") => {
136        2
137    };
138    ("interrupts.status_registers", str) => {
139        stringify!(2)
140    };
141    ("rmt.ram_start") => {
142        1610642432
143    };
144    ("rmt.ram_start", str) => {
145        stringify!(1610642432)
146    };
147    ("rmt.channel_ram_size") => {
148        48
149    };
150    ("rmt.channel_ram_size", str) => {
151        stringify!(48)
152    };
153    ("spi_master.has_octal") => {
154        false
155    };
156    ("timergroup.timg_has_timer1") => {
157        false
158    };
159}
160/// Macro to get the address range of the given memory region.
161#[macro_export]
162#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
163macro_rules! memory_range {
164    ("DRAM") => {
165        1082130432..1082458112
166    };
167}
168/// This macro can be used to generate code for each peripheral instance of the I2C master driver.
169///
170/// For an explanation on the general syntax, as well as usage of individual/repeated
171/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
172///
173/// This macro has one option for its "Individual matcher" case:
174///
175/// Syntax: `($instance:ident, $sys:ident, $scl:ident, $sda:ident)`
176///
177/// Macro fragments:
178///
179/// - `$instance`: the name of the I2C instance
180/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
181/// - `$scl`, `$sda`: peripheral signal names.
182///
183/// Example data: `(I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)`
184#[macro_export]
185#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
186macro_rules! for_each_i2c_master {
187    ($($pattern:tt => $code:tt;)*) => {
188        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
189        _for_each_inner!((I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA));
190        _for_each_inner!((I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA));
191        _for_each_inner!((all(I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA), (I2C1, I2cExt1,
192        I2CEXT1_SCL, I2CEXT1_SDA)));
193    };
194}
195/// This macro can be used to generate code for each peripheral instance of the UART driver.
196///
197/// For an explanation on the general syntax, as well as usage of individual/repeated
198/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
199///
200/// This macro has one option for its "Individual matcher" case:
201///
202/// Syntax: `($instance:ident, $sys:ident, $rx:ident, $tx:ident, $cts:ident, $rts:ident)`
203///
204/// Macro fragments:
205///
206/// - `$instance`: the name of the UART instance
207/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
208/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
209///
210/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
211#[macro_export]
212#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
213macro_rules! for_each_uart {
214    ($($pattern:tt => $code:tt;)*) => {
215        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
216        _for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
217        _for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
218        _for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
219        U1RXD, U1TXD, U1CTS, U1RTS)));
220    };
221}
222/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
223///
224/// For an explanation on the general syntax, as well as usage of individual/repeated
225/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
226///
227/// This macro has one option for its "Individual matcher" case:
228///
229/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, [$($cs:ident),*] [$($sio:ident),*
230/// $($is_qspi:iteral)?])`
231///
232/// Macro fragments:
233///
234/// - `$instance`: the name of the SPI instance
235/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
236/// - `$cs`, `$sio`: chip select and SIO signal names.
237/// - `$is_qspi`: a `true` literal present if the SPI instance supports QSPI.
238///
239/// Example data:
240/// - `(SPI2, Spi2, FSPICLK [FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ,
241///   FSPIWP, FSPIHD, FSPIIO4, FSPIIO5, FSPIIO6, FSPIIO7], true)`
242/// - `(SPI3, Spi3, SPI3_CLK [SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q])`
243#[macro_export]
244#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
245macro_rules! for_each_spi_master {
246    ($($pattern:tt => $code:tt;)*) => {
247        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
248        _for_each_inner!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3,
249        FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true));
250        _for_each_inner!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3,
251        FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
252    };
253}
254/// This macro can be used to generate code for each peripheral instance of the SPI slave driver.
255///
256/// For an explanation on the general syntax, as well as usage of individual/repeated
257/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
258///
259/// This macro has one option for its "Individual matcher" case:
260///
261/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, $mosi:ident, $miso:ident, $cs:ident)`
262///
263/// Macro fragments:
264///
265/// - `$instance`: the name of the I2C instance
266/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
267/// - `$mosi`, `$miso`, `$cs`: signal names.
268///
269/// Example data: `(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)`
270#[macro_export]
271#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
272macro_rules! for_each_spi_slave {
273    ($($pattern:tt => $code:tt;)*) => {
274        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
275        _for_each_inner!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
276        _for_each_inner!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
277    };
278}
279#[macro_export]
280#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
281macro_rules! for_each_peripheral {
282    ($($pattern:tt => $code:tt;)*) => {
283        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
284        _for_each_inner!((GPIO0 <= virtual())); _for_each_inner!((GPIO1 <= virtual()));
285        _for_each_inner!((GPIO2 <= virtual())); _for_each_inner!((GPIO3 <= virtual()));
286        _for_each_inner!((GPIO4 <= virtual())); _for_each_inner!((GPIO5 <= virtual()));
287        _for_each_inner!((GPIO6 <= virtual())); _for_each_inner!((GPIO7 <= virtual()));
288        _for_each_inner!((GPIO8 <= virtual())); _for_each_inner!((GPIO9 <= virtual()));
289        _for_each_inner!((GPIO10 <= virtual())); _for_each_inner!((GPIO11 <= virtual()));
290        _for_each_inner!((GPIO12 <= virtual())); _for_each_inner!((GPIO13 <= virtual()));
291        _for_each_inner!((GPIO14 <= virtual())); _for_each_inner!((GPIO22 <= virtual()));
292        _for_each_inner!((GPIO23 <= virtual())); _for_each_inner!((GPIO24 <= virtual()));
293        _for_each_inner!((GPIO25 <= virtual())); _for_each_inner!((GPIO26 <= virtual()));
294        _for_each_inner!((GPIO27 <= virtual())); _for_each_inner!((AES <= AES()
295        (unstable))); _for_each_inner!((APB_SARADC <= APB_SARADC() (unstable)));
296        _for_each_inner!((ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
297        _for_each_inner!((DMA <= DMA() (unstable))); _for_each_inner!((DS <= DS()
298        (unstable))); _for_each_inner!((ECC <= ECC() (unstable)));
299        _for_each_inner!((EFUSE <= EFUSE() (unstable))); _for_each_inner!((GPIO <= GPIO()
300        (unstable))); _for_each_inner!((GPIO_SD <= GPIO_SD() (unstable)));
301        _for_each_inner!((HMAC <= HMAC() (unstable))); _for_each_inner!((HP_APM <=
302        HP_APM() (unstable))); _for_each_inner!((HP_SYS <= HP_SYS() (unstable)));
303        _for_each_inner!((I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
304        _for_each_inner!((I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
305        enable_peri_interrupt, disable_peri_interrupt }))); _for_each_inner!((I2C1 <=
306        I2C1(I2C_EXT1 : { bind_peri_interrupt, enable_peri_interrupt,
307        disable_peri_interrupt }))); _for_each_inner!((I2S0 <= I2S0(I2S0 : {
308        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
309        (unstable))); _for_each_inner!((IEEE802154 <= IEEE802154() (unstable)));
310        _for_each_inner!((INTERRUPT_CORE0 <= INTERRUPT_CORE0() (unstable)));
311        _for_each_inner!((INTPRI <= INTPRI() (unstable))); _for_each_inner!((IO_MUX <=
312        IO_MUX() (unstable))); _for_each_inner!((LEDC <= LEDC() (unstable)));
313        _for_each_inner!((LPWR <= LP_CLKRST() (unstable))); _for_each_inner!((LP_ANA <=
314        LP_ANA() (unstable))); _for_each_inner!((LP_AON <= LP_AON() (unstable)));
315        _for_each_inner!((LP_APM <= LP_APM() (unstable))); _for_each_inner!((LP_APM0 <=
316        LP_APM0() (unstable))); _for_each_inner!((LP_CLKRST <= LP_CLKRST() (unstable)));
317        _for_each_inner!((LP_PERI <= LP_PERI() (unstable))); _for_each_inner!((LP_TIMER
318        <= LP_TIMER() (unstable))); _for_each_inner!((LP_WDT <= LP_WDT() (unstable)));
319        _for_each_inner!((MCPWM0 <= MCPWM0() (unstable))); _for_each_inner!((MEM_MONITOR
320        <= MEM_MONITOR() (unstable))); _for_each_inner!((MODEM_LPCON <= MODEM_LPCON()
321        (unstable))); _for_each_inner!((MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
322        _for_each_inner!((OTP_DEBUG <= OTP_DEBUG() (unstable)));
323        _for_each_inner!((PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt,
324        enable_rx_interrupt, disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt,
325        enable_tx_interrupt, disable_tx_interrupt }) (unstable))); _for_each_inner!((PAU
326        <= PAU() (unstable))); _for_each_inner!((PCNT <= PCNT() (unstable)));
327        _for_each_inner!((PCR <= PCR() (unstable))); _for_each_inner!((PLIC_MX <=
328        PLIC_MX() (unstable))); _for_each_inner!((PMU <= PMU() (unstable)));
329        _for_each_inner!((RMT <= RMT() (unstable))); _for_each_inner!((RNG <= RNG()
330        (unstable))); _for_each_inner!((RSA <= RSA() (unstable))); _for_each_inner!((SHA
331        <= SHA() (unstable))); _for_each_inner!((ETM <= SOC_ETM() (unstable)));
332        _for_each_inner!((SPI0 <= SPI0() (unstable))); _for_each_inner!((SPI1 <= SPI1()
333        (unstable))); _for_each_inner!((SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
334        enable_peri_interrupt, disable_peri_interrupt }))); _for_each_inner!((SYSTEM <=
335        PCR() (unstable))); _for_each_inner!((SYSTIMER <= SYSTIMER() (unstable)));
336        _for_each_inner!((TEE <= TEE() (unstable))); _for_each_inner!((TIMG0 <= TIMG0()
337        (unstable))); _for_each_inner!((TIMG1 <= TIMG1() (unstable)));
338        _for_each_inner!((TRACE0 <= TRACE() (unstable))); _for_each_inner!((TWAI0 <=
339        TWAI0() (unstable))); _for_each_inner!((UART0 <= UART0(UART0 : {
340        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })));
341        _for_each_inner!((UART1 <= UART1(UART1 : { bind_peri_interrupt,
342        enable_peri_interrupt, disable_peri_interrupt }))); _for_each_inner!((UHCI0 <=
343        UHCI0() (unstable))); _for_each_inner!((USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
344        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
345        (unstable))); _for_each_inner!((DMA_CH0 <= virtual() (unstable)));
346        _for_each_inner!((DMA_CH1 <= virtual() (unstable))); _for_each_inner!((DMA_CH2 <=
347        virtual() (unstable))); _for_each_inner!((ADC1 <= virtual() (unstable)));
348        _for_each_inner!((BT <= virtual() (unstable))); _for_each_inner!((SW_INTERRUPT <=
349        virtual() (unstable))); _for_each_inner!((MEM2MEM1 <= virtual() (unstable)));
350        _for_each_inner!((MEM2MEM4 <= virtual() (unstable))); _for_each_inner!((MEM2MEM5
351        <= virtual() (unstable))); _for_each_inner!((MEM2MEM10 <= virtual() (unstable)));
352        _for_each_inner!((MEM2MEM11 <= virtual() (unstable)));
353        _for_each_inner!((MEM2MEM12 <= virtual() (unstable)));
354        _for_each_inner!((MEM2MEM13 <= virtual() (unstable)));
355        _for_each_inner!((MEM2MEM14 <= virtual() (unstable)));
356        _for_each_inner!((MEM2MEM15 <= virtual() (unstable)));
357        _for_each_inner!((all(GPIO0 <= virtual()), (GPIO1 <= virtual()), (GPIO2 <=
358        virtual()), (GPIO3 <= virtual()), (GPIO4 <= virtual()), (GPIO5 <= virtual()),
359        (GPIO6 <= virtual()), (GPIO7 <= virtual()), (GPIO8 <= virtual()), (GPIO9 <=
360        virtual()), (GPIO10 <= virtual()), (GPIO11 <= virtual()), (GPIO12 <= virtual()),
361        (GPIO13 <= virtual()), (GPIO14 <= virtual()), (GPIO22 <= virtual()), (GPIO23 <=
362        virtual()), (GPIO24 <= virtual()), (GPIO25 <= virtual()), (GPIO26 <= virtual()),
363        (GPIO27 <= virtual()), (AES <= AES() (unstable)), (APB_SARADC <= APB_SARADC()
364        (unstable)), (ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)), (DMA <= DMA()
365        (unstable)), (DS <= DS() (unstable)), (ECC <= ECC() (unstable)), (EFUSE <=
366        EFUSE() (unstable)), (GPIO <= GPIO() (unstable)), (GPIO_SD <= GPIO_SD()
367        (unstable)), (HMAC <= HMAC() (unstable)), (HP_APM <= HP_APM() (unstable)),
368        (HP_SYS <= HP_SYS() (unstable)), (I2C_ANA_MST <= I2C_ANA_MST() (unstable)), (I2C0
369        <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
370        disable_peri_interrupt })), (I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
371        enable_peri_interrupt, disable_peri_interrupt })), (I2S0 <= I2S0(I2S0 : {
372        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
373        (unstable)), (IEEE802154 <= IEEE802154() (unstable)), (INTERRUPT_CORE0 <=
374        INTERRUPT_CORE0() (unstable)), (INTPRI <= INTPRI() (unstable)), (IO_MUX <=
375        IO_MUX() (unstable)), (LEDC <= LEDC() (unstable)), (LPWR <= LP_CLKRST()
376        (unstable)), (LP_ANA <= LP_ANA() (unstable)), (LP_AON <= LP_AON() (unstable)),
377        (LP_APM <= LP_APM() (unstable)), (LP_APM0 <= LP_APM0() (unstable)), (LP_CLKRST <=
378        LP_CLKRST() (unstable)), (LP_PERI <= LP_PERI() (unstable)), (LP_TIMER <=
379        LP_TIMER() (unstable)), (LP_WDT <= LP_WDT() (unstable)), (MCPWM0 <= MCPWM0()
380        (unstable)), (MEM_MONITOR <= MEM_MONITOR() (unstable)), (MODEM_LPCON <=
381        MODEM_LPCON() (unstable)), (MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
382        (OTP_DEBUG <= OTP_DEBUG() (unstable)), (PARL_IO <= PARL_IO(PARL_IO_RX : {
383        bind_rx_interrupt, enable_rx_interrupt, disable_rx_interrupt }, PARL_IO_TX : {
384        bind_tx_interrupt, enable_tx_interrupt, disable_tx_interrupt }) (unstable)), (PAU
385        <= PAU() (unstable)), (PCNT <= PCNT() (unstable)), (PCR <= PCR() (unstable)),
386        (PLIC_MX <= PLIC_MX() (unstable)), (PMU <= PMU() (unstable)), (RMT <= RMT()
387        (unstable)), (RNG <= RNG() (unstable)), (RSA <= RSA() (unstable)), (SHA <= SHA()
388        (unstable)), (ETM <= SOC_ETM() (unstable)), (SPI0 <= SPI0() (unstable)), (SPI1 <=
389        SPI1() (unstable)), (SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
390        enable_peri_interrupt, disable_peri_interrupt })), (SYSTEM <= PCR() (unstable)),
391        (SYSTIMER <= SYSTIMER() (unstable)), (TEE <= TEE() (unstable)), (TIMG0 <= TIMG0()
392        (unstable)), (TIMG1 <= TIMG1() (unstable)), (TRACE0 <= TRACE() (unstable)),
393        (TWAI0 <= TWAI0() (unstable)), (UART0 <= UART0(UART0 : { bind_peri_interrupt,
394        enable_peri_interrupt, disable_peri_interrupt })), (UART1 <= UART1(UART1 : {
395        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (UHCI0 <=
396        UHCI0() (unstable)), (USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
397        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
398        (unstable)), (DMA_CH0 <= virtual() (unstable)), (DMA_CH1 <= virtual()
399        (unstable)), (DMA_CH2 <= virtual() (unstable)), (ADC1 <= virtual() (unstable)),
400        (BT <= virtual() (unstable)), (SW_INTERRUPT <= virtual() (unstable)), (MEM2MEM1
401        <= virtual() (unstable)), (MEM2MEM4 <= virtual() (unstable)), (MEM2MEM5 <=
402        virtual() (unstable)), (MEM2MEM10 <= virtual() (unstable)), (MEM2MEM11 <=
403        virtual() (unstable)), (MEM2MEM12 <= virtual() (unstable)), (MEM2MEM13 <=
404        virtual() (unstable)), (MEM2MEM14 <= virtual() (unstable)), (MEM2MEM15 <=
405        virtual() (unstable))));
406    };
407}
408/// This macro can be used to generate code for each `GPIOn` instance.
409///
410/// For an explanation on the general syntax, as well as usage of individual/repeated
411/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
412///
413/// This macro has one option for its "Individual matcher" case:
414///
415/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
416/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
417/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
418///
419/// Macro fragments:
420///
421/// - `$n`: the number of the GPIO. For `GPIO0`, `$n` is 0.
422/// - `$gpio`: the name of the GPIO.
423/// - `$digital_input_function`: the number of the digital function, as an identifier (i.e. for
424///   function 0 this is `_0`).
425/// - `$digital_input_function`: the name of the digital function, as an identifier.
426/// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for
427///   function 0 this is `_0`).
428/// - `$digital_output_function`: the name of the digital function, as an identifier.
429/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
430///   Bracketed so that they can also be matched as optional fragments. Order is always Input first.
431///
432/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
433/// [Output]))`
434#[macro_export]
435#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
436macro_rules! for_each_gpio {
437    ($($pattern:tt => $code:tt;)*) => {
438        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
439        _for_each_inner!((0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
440        _for_each_inner!((1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])));
441        _for_each_inner!((2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input]
442        [Output]))); _for_each_inner!((3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD)
443        ([Input] [Output]))); _for_each_inner!((4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 =>
444        FSPICLK) ([Input] [Output]))); _for_each_inner!((5, GPIO5(_2 => FSPID) (_0 =>
445        MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((6, GPIO6() () ([Input]
446        [Output]))); _for_each_inner!((7, GPIO7() () ([Input] [Output])));
447        _for_each_inner!((8, GPIO8() () ([Input] [Output]))); _for_each_inner!((9,
448        GPIO9() () ([Input] [Output]))); _for_each_inner!((10, GPIO10() () ([Input]
449        [Output]))); _for_each_inner!((11, GPIO11() () ([Input] [Output])));
450        _for_each_inner!((12, GPIO12() () ([Input] [Output]))); _for_each_inner!((13,
451        GPIO13() () ([Input] [Output]))); _for_each_inner!((14, GPIO14() () ([Input]
452        [Output]))); _for_each_inner!((22, GPIO22() () ([Input] [Output])));
453        _for_each_inner!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])));
454        _for_each_inner!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2) ([Input] [Output])));
455        _for_each_inner!((25, GPIO25() (_2 => FSPICS3) ([Input] [Output])));
456        _for_each_inner!((26, GPIO26() (_2 => FSPICS4) ([Input] [Output])));
457        _for_each_inner!((27, GPIO27() (_2 => FSPICS5) ([Input] [Output])));
458        _for_each_inner!((all(0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])),
459        (1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (2, GPIO2(_0 =>
460        MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input] [Output])), (3, GPIO3(_0 => MTDI _2 =>
461        FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (4, GPIO4(_0 => MTCK _2 => FSPICLK)
462        (_2 => FSPICLK) ([Input] [Output])), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 =>
463        FSPID) ([Input] [Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() ()
464        ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input]
465        [Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11() () ([Input]
466        [Output])), (12, GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input]
467        [Output])), (14, GPIO14() () ([Input] [Output])), (22, GPIO22() () ([Input]
468        [Output])), (23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])), (24,
469        GPIO24() (_0 => U0TXD _2 => FSPICS2) ([Input] [Output])), (25, GPIO25() (_2 =>
470        FSPICS3) ([Input] [Output])), (26, GPIO26() (_2 => FSPICS4) ([Input] [Output])),
471        (27, GPIO27() (_2 => FSPICS5) ([Input] [Output]))));
472    };
473}
474/// This macro can be used to generate code for each analog function of each GPIO.
475///
476/// For an explanation on the general syntax, as well as usage of individual/repeated
477/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
478///
479/// This macro has two options for its "Individual matcher" case:
480///
481/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
482/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
483///   expanded signal case, where you need the number(s) of a signal, or the general group to which
484///   the signal belongs. For example, in case of `ADC2_CH3` the expanded form looks like
485///   `(ADC2_CH3, ADCn_CHm, 2, 3)`.
486///
487/// Macro fragments:
488///
489/// - `$signal`: the name of the signal.
490/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
491///   is `ADCn_CHm`.
492/// - `$number`: the numbers extracted from `$signal`.
493/// - `$gpio`: the name of the GPIO.
494///
495/// Example data:
496/// - `(ADC2_CH5, GPIO12)`
497/// - `((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12)`
498///
499/// The expanded syntax is only available when the signal has at least one numbered component.
500#[macro_export]
501#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
502macro_rules! for_each_analog_function {
503    ($($pattern:tt => $code:tt;)*) => {
504        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
505        _for_each_inner!((ADC1_CH0, GPIO1)); _for_each_inner!((ADC1_CH1, GPIO2));
506        _for_each_inner!((ADC1_CH2, GPIO3)); _for_each_inner!((ADC1_CH3, GPIO4));
507        _for_each_inner!((ADC1_CH4, GPIO5)); _for_each_inner!((ZCD0, GPIO10));
508        _for_each_inner!((ZCD1, GPIO11)); _for_each_inner!((XTAL_32K_P, GPIO13));
509        _for_each_inner!((XTAL_32K_N, GPIO14)); _for_each_inner!((USB_DM, GPIO26));
510        _for_each_inner!((USB_DP, GPIO27)); _for_each_inner!(((ADC1_CH0, ADCn_CHm, 1, 0),
511        GPIO1)); _for_each_inner!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
512        _for_each_inner!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
513        _for_each_inner!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
514        _for_each_inner!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5)); _for_each_inner!(((ZCD0,
515        ZCDn, 0), GPIO10)); _for_each_inner!(((ZCD1, ZCDn, 1), GPIO11));
516        _for_each_inner!((all(ADC1_CH0, GPIO1), (ADC1_CH1, GPIO2), (ADC1_CH2, GPIO3),
517        (ADC1_CH3, GPIO4), (ADC1_CH4, GPIO5), (ZCD0, GPIO10), (ZCD1, GPIO11),
518        (XTAL_32K_P, GPIO13), (XTAL_32K_N, GPIO14), (USB_DM, GPIO26), (USB_DP, GPIO27)));
519        _for_each_inner!((all_expanded((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1), ((ADC1_CH1,
520        ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3), ((ADC1_CH3,
521        ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5), ((ZCD0, ZCDn, 0),
522        GPIO10), ((ZCD1, ZCDn, 1), GPIO11)));
523    };
524}
525/// This macro can be used to generate code for each LP/RTC function of each GPIO.
526///
527/// For an explanation on the general syntax, as well as usage of individual/repeated
528/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
529///
530/// This macro has two options for its "Individual matcher" case:
531///
532/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
533/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
534///   expanded signal case, where you need the number(s) of a signal, or the general group to which
535///   the signal belongs. For example, in case of `SAR_I2C_SCL_1` the expanded form looks like
536///   `(SAR_I2C_SCL_1, SAR_I2C_SCL_n, 1)`.
537///
538/// Macro fragments:
539///
540/// - `$signal`: the name of the signal.
541/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
542///   is `ADCn_CHm`.
543/// - `$number`: the numbers extracted from `$signal`.
544/// - `$gpio`: the name of the GPIO.
545///
546/// Example data:
547/// - `(RTC_GPIO15, GPIO12)`
548/// - `((RTC_GPIO15, RTC_GPIOn, 15), GPIO12)`
549///
550/// The expanded syntax is only available when the signal has at least one numbered component.
551#[macro_export]
552#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
553macro_rules! for_each_lp_function {
554    ($($pattern:tt => $code:tt;)*) => {
555        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
556        _for_each_inner!((all)); _for_each_inner!((all_expanded));
557    };
558}
559/// Defines the `InputSignal` and `OutputSignal` enums.
560///
561/// This macro is intended to be called in esp-hal only.
562#[macro_export]
563#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
564macro_rules! define_io_mux_signals {
565    () => {
566        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
567        #[derive(Debug, PartialEq, Copy, Clone)]
568        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
569        #[doc(hidden)]
570        pub enum InputSignal {
571            EXT_ADC_START       = 0,
572            U0RXD               = 6,
573            U0CTS               = 7,
574            U0DSR               = 8,
575            U1RXD               = 9,
576            U1CTS               = 10,
577            U1DSR               = 11,
578            I2S_MCLK            = 12,
579            I2SO_BCK            = 13,
580            I2SO_WS             = 14,
581            I2SI_SD             = 15,
582            I2SI_BCK            = 16,
583            I2SI_WS             = 17,
584            USB_JTAG_TDO_BRIDGE = 19,
585            CPU_GPIO0           = 28,
586            CPU_GPIO1           = 29,
587            CPU_GPIO2           = 30,
588            CPU_GPIO3           = 31,
589            CPU_GPIO4           = 32,
590            CPU_GPIO5           = 33,
591            CPU_GPIO6           = 34,
592            CPU_GPIO7           = 35,
593            I2CEXT0_SCL         = 45,
594            I2CEXT0_SDA         = 46,
595            PARL_RX_DATA0       = 47,
596            PARL_RX_DATA1       = 48,
597            PARL_RX_DATA2       = 49,
598            PARL_RX_DATA3       = 50,
599            PARL_RX_DATA4       = 51,
600            PARL_RX_DATA5       = 52,
601            PARL_RX_DATA6       = 53,
602            PARL_RX_DATA7       = 54,
603            I2CEXT1_SCL         = 55,
604            I2CEXT1_SDA         = 56,
605            FSPICLK             = 63,
606            FSPIQ               = 64,
607            FSPID               = 65,
608            FSPIHD              = 66,
609            FSPIWP              = 67,
610            FSPICS0             = 68,
611            PARL_RX_CLK         = 69,
612            PARL_TX_CLK         = 70,
613            RMT_SIG_0           = 71,
614            RMT_SIG_1           = 72,
615            TWAI0_RX            = 73,
616            PWM0_SYNC0          = 87,
617            PWM0_SYNC1          = 88,
618            PWM0_SYNC2          = 89,
619            PWM0_F0             = 90,
620            PWM0_F1             = 91,
621            PWM0_F2             = 92,
622            PWM0_CAP0           = 93,
623            PWM0_CAP1           = 94,
624            PWM0_CAP2           = 95,
625            SIG_FUNC_97         = 97,
626            SIG_FUNC_98         = 98,
627            SIG_FUNC_99         = 99,
628            SIG_FUNC_100        = 100,
629            PCNT0_SIG_CH0       = 101,
630            PCNT0_SIG_CH1       = 102,
631            PCNT0_CTRL_CH0      = 103,
632            PCNT0_CTRL_CH1      = 104,
633            PCNT1_SIG_CH0       = 105,
634            PCNT1_SIG_CH1       = 106,
635            PCNT1_CTRL_CH0      = 107,
636            PCNT1_CTRL_CH1      = 108,
637            PCNT2_SIG_CH0       = 109,
638            PCNT2_SIG_CH1       = 110,
639            PCNT2_CTRL_CH0      = 111,
640            PCNT2_CTRL_CH1      = 112,
641            PCNT3_SIG_CH0       = 113,
642            PCNT3_SIG_CH1       = 114,
643            PCNT3_CTRL_CH0      = 115,
644            PCNT3_CTRL_CH1      = 116,
645            SPIQ                = 121,
646            SPID                = 122,
647            SPIHD               = 123,
648            SPIWP               = 124,
649            MTDI,
650            MTCK,
651            MTMS,
652        }
653        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
654        #[derive(Debug, PartialEq, Copy, Clone)]
655        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
656        #[doc(hidden)]
657        pub enum OutputSignal {
658            LEDC_LS_SIG0     = 0,
659            LEDC_LS_SIG1     = 1,
660            LEDC_LS_SIG2     = 2,
661            LEDC_LS_SIG3     = 3,
662            LEDC_LS_SIG4     = 4,
663            LEDC_LS_SIG5     = 5,
664            U0TXD            = 6,
665            U0RTS            = 7,
666            U0DTR            = 8,
667            U1TXD            = 9,
668            U1RTS            = 10,
669            U1DTR            = 11,
670            I2S_MCLK         = 12,
671            I2SO_BCK         = 13,
672            I2SO_WS          = 14,
673            I2SO_SD          = 15,
674            I2SI_BCK         = 16,
675            I2SI_WS          = 17,
676            I2SO_SD1         = 18,
677            USB_JTAG_TRST    = 19,
678            CPU_GPIO_OUT0    = 28,
679            CPU_GPIO_OUT1    = 29,
680            CPU_GPIO_OUT2    = 30,
681            CPU_GPIO_OUT3    = 31,
682            CPU_GPIO_OUT4    = 32,
683            CPU_GPIO_OUT5    = 33,
684            CPU_GPIO_OUT6    = 34,
685            CPU_GPIO_OUT7    = 35,
686            I2CEXT0_SCL      = 45,
687            I2CEXT0_SDA      = 46,
688            PARL_TX_DATA0    = 47,
689            PARL_TX_DATA1    = 48,
690            PARL_TX_DATA2    = 49,
691            PARL_TX_DATA3    = 50,
692            PARL_TX_DATA4    = 51,
693            PARL_TX_DATA5    = 52,
694            PARL_TX_DATA6    = 53,
695            PARL_TX_DATA7    = 54,
696            I2CEXT1_SCL      = 55,
697            I2CEXT1_SDA      = 56,
698            FSPICLK          = 63,
699            FSPIQ            = 64,
700            FSPID            = 65,
701            FSPIHD           = 66,
702            FSPIWP           = 67,
703            FSPICS0          = 68,
704            PARL_RX_CLK      = 69,
705            PARL_TX_CLK      = 70,
706            RMT_SIG_0        = 71,
707            RMT_SIG_1        = 72,
708            TWAI0_TX         = 73,
709            TWAI0_BUS_OFF_ON = 74,
710            TWAI0_CLKOUT     = 75,
711            TWAI0_STANDBY    = 76,
712            CTE_ANT7         = 78,
713            CTE_ANT8         = 79,
714            CTE_ANT9         = 80,
715            GPIO_SD0         = 83,
716            GPIO_SD1         = 84,
717            GPIO_SD2         = 85,
718            GPIO_SD3         = 86,
719            PWM0_0A          = 87,
720            PWM0_0B          = 88,
721            PWM0_1A          = 89,
722            PWM0_1B          = 90,
723            PWM0_2A          = 91,
724            PWM0_2B          = 92,
725            SIG_IN_FUNC97    = 97,
726            SIG_IN_FUNC98    = 98,
727            SIG_IN_FUNC99    = 99,
728            SIG_IN_FUNC100   = 100,
729            FSPICS1          = 101,
730            FSPICS2          = 102,
731            FSPICS3          = 103,
732            FSPICS4          = 104,
733            FSPICS5          = 105,
734            CTE_ANT10        = 106,
735            CTE_ANT11        = 107,
736            CTE_ANT12        = 108,
737            CTE_ANT13        = 109,
738            CTE_ANT14        = 110,
739            CTE_ANT15        = 111,
740            SPICLK           = 114,
741            SPICS0           = 115,
742            SPICS1           = 116,
743            SPIQ             = 121,
744            SPID             = 122,
745            SPIHD            = 123,
746            SPIWP            = 124,
747            CLK_OUT_OUT1     = 125,
748            CLK_OUT_OUT2     = 126,
749            CLK_OUT_OUT3     = 127,
750            GPIO             = 128,
751            MTDO,
752        }
753    };
754}
755/// Defines and implements the `io_mux_reg` function.
756///
757/// The generated function has the following signature:
758///
759/// ```rust,ignore
760/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
761///     // ...
762/// # unimplemented!()
763/// }
764/// ```
765///
766/// This macro is intended to be called in esp-hal only.
767#[macro_export]
768#[expect(clippy::crate_in_macro_def)]
769#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
770macro_rules! define_io_mux_reg {
771    () => {
772        pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
773            crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
774        }
775    };
776}