esp_hal/soc/esp32c3/
peripherals.rs

1//! # Peripheral Instances
2//!
3//! This module creates singleton instances for each of the various peripherals,
4//! and re-exports them to allow users to access and use them in their
5//! applications.
6//!
7//! Should be noted that that the module also re-exports the [Interrupt] enum
8//! from the PAC, allowing users to handle interrupts associated with these
9//! peripherals.
10
11pub(crate) use esp32c3 as pac;
12// We need to export this for users to use
13#[doc(hidden)]
14pub use pac::Interrupt;
15
16// Note that certain are marked with `virtual` in the invocation of the
17// `peripherals!` macro below. Basically, this indicates there's no physical
18// peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're
19// creating "virtual peripherals" for them.
20crate::peripherals! {
21    peripherals: [
22        I2C0 <= I2C0,
23        SPI2 <= SPI2 (SPI2),
24        UART0 <= UART0,
25        UART1 <= UART1,
26    ],
27    unstable_peripherals: [
28        ADC1 <= virtual,
29        ADC2 <= virtual,
30        AES <= AES,
31        APB_CTRL <= APB_CTRL,
32        APB_SARADC <= APB_SARADC,
33        ASSIST_DEBUG <= ASSIST_DEBUG,
34        BB <= BB,
35        BT <= virtual,
36        DMA <= DMA,
37        DS <= DS,
38        EFUSE <= EFUSE,
39        EXTMEM <= EXTMEM,
40        FE <= FE,
41        FE2 <= FE2,
42        GPIO <= GPIO,
43        GPIO_SD <= GPIO_SD,
44        HMAC <= HMAC,
45        I2C_ANA_MST <= I2C_ANA_MST,
46        I2S0 <= I2S0 (I2S0),
47        INTERRUPT_CORE0 <= INTERRUPT_CORE0,
48        IO_MUX <= IO_MUX,
49        LEDC <= LEDC,
50        LPWR <= RTC_CNTL,
51        NRX <= NRX,
52        RADIO_CLK <= virtual,
53        RMT <= RMT,
54        RNG <= RNG,
55        RSA <= RSA,
56        SENSITIVE <= SENSITIVE,
57        SHA <= SHA,
58        SPI0 <= SPI0,
59        SPI1 <= SPI1,
60        SYSTEM <= SYSTEM,
61        SYSTIMER <= SYSTIMER,
62        SW_INTERRUPT <= virtual,
63        TIMG0 <= TIMG0,
64        TIMG1 <= TIMG1,
65        TSENS <= virtual,
66        TWAI0 <= TWAI0,
67        UHCI0 <= UHCI0,
68        UHCI1 <= UHCI1,
69        USB_DEVICE <= USB_DEVICE,
70        WIFI <= virtual,
71        XTS_AES <= XTS_AES,
72    ],
73    pins: [
74        (0, [Input, Output, Analog, RtcIo])
75        (1, [Input, Output, Analog, RtcIo])
76        (2, [Input, Output, Analog, RtcIo] (2 => FSPIQ) (2 => FSPIQ))
77        (3, [Input, Output, Analog, RtcIo])
78        (4, [Input, Output, Analog, RtcIo] (2 => FSPIHD) (0 => USB_JTAG_TMS 2 => FSPIHD))
79        (5, [Input, Output, Analog, RtcIo] (2 => FSPIWP) (0 => USB_JTAG_TDI 2 => FSPIWP))
80        (6, [Input, Output] (2 => FSPICLK) (0 => USB_JTAG_TCK 2 => FSPICLK_MUX))
81        (7, [Input, Output] (2 => FSPID) (0 => USB_JTAG_TDO 2 => FSPID))
82        (8, [Input, Output])
83        (9, [Input, Output])
84        (10, [Input, Output] (2 => FSPICS0) (2 => FSPICS0))
85        (11, [Input, Output])
86        (12, [Input, Output] (0 => SPIHD) (0 => SPIHD))
87        (13, [Input, Output] (0 => SPIWP) (0 => SPIWP))
88        (14, [Input, Output] () (0 => SPICS0))
89        (15, [Input, Output] () (0 => SPICLK_MUX))
90        (16, [Input, Output] (0 => SPID) (0 => SPID))
91        (17, [Input, Output] (0 => SPIQ) (0 => SPIQ))
92        (18, [Input, Output])
93        (19, [Input, Output])
94        (20, [Input, Output] (0 => U0RXD) ())
95        (21, [Input, Output] () (0 => U0TXD))
96    ],
97    dma_channels: [
98        DMA_CH0: DmaChannel0,
99        DMA_CH1: DmaChannel1,
100        DMA_CH2: DmaChannel2,
101    ]
102}