Prefix peripheral cfg symbols with chip_has_* (#3628)

* Prefix peri cfg with `soc_has_`

* Clean up ETM
This commit is contained in:
Dániel Buga 2025-06-16 10:13:28 +02:00 committed by GitHub
parent 3e6b85bf30
commit c29c436be5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 297 additions and 272 deletions

View File

@ -726,28 +726,28 @@ cfg_if::cfg_if! {
crate::dma::impl_dma_eligible! { crate::dma::impl_dma_eligible! {
AnyGdmaChannel { AnyGdmaChannel {
#[cfg(spi2)] #[cfg(soc_has_spi2)]
SPI2 => Spi2, SPI2 => Spi2,
#[cfg(spi3)] #[cfg(soc_has_spi3)]
SPI3 => Spi3, SPI3 => Spi3,
#[cfg(uhci0)] #[cfg(soc_has_uhci0)]
UHCI0 => Uhci0, UHCI0 => Uhci0,
#[cfg(i2s0)] #[cfg(soc_has_i2s0)]
I2S0 => I2s0, I2S0 => I2s0,
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
I2S1 => I2s1, I2S1 => I2s1,
#[cfg(esp32s3)] #[cfg(esp32s3)]
LCD_CAM => LcdCam, LCD_CAM => LcdCam,
#[cfg(all(gdma, aes))] #[cfg(all(gdma, soc_has_aes))]
AES => Aes, AES => Aes,
#[cfg(all(gdma, sha))] #[cfg(all(gdma, soc_has_sha))]
SHA => Sha, SHA => Sha,
#[cfg(any(esp32c3, esp32c6, esp32h2, esp32s3))] #[cfg(any(esp32c3, esp32c6, esp32h2, esp32s3))]
@ -759,7 +759,7 @@ crate::dma::impl_dma_eligible! {
#[cfg(esp32s3)] #[cfg(esp32s3)]
RMT => Rmt, RMT => Rmt,
#[cfg(parl_io)] #[cfg(soc_has_parl_io)]
PARL_IO => ParlIo, PARL_IO => ParlIo,
#[cfg(any(esp32c2, esp32c6, esp32h2))] #[cfg(any(esp32c2, esp32c6, esp32h2))]

View File

@ -2952,7 +2952,7 @@ pub(crate) mod asynch {
} }
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
pub struct DmaTxDoneChFuture<'a, CH> pub struct DmaTxDoneChFuture<'a, CH>
where where
CH: DmaTxChannel, CH: DmaTxChannel,
@ -2961,7 +2961,7 @@ pub(crate) mod asynch {
_a: (), _a: (),
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
impl<'a, CH> DmaTxDoneChFuture<'a, CH> impl<'a, CH> DmaTxDoneChFuture<'a, CH>
where where
CH: DmaTxChannel, CH: DmaTxChannel,
@ -2971,7 +2971,7 @@ pub(crate) mod asynch {
} }
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
impl<CH> core::future::Future for DmaTxDoneChFuture<'_, CH> impl<CH> core::future::Future for DmaTxDoneChFuture<'_, CH>
where where
CH: DmaTxChannel, CH: DmaTxChannel,
@ -3005,7 +3005,7 @@ pub(crate) mod asynch {
} }
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
impl<CH> Drop for DmaTxDoneChFuture<'_, CH> impl<CH> Drop for DmaTxDoneChFuture<'_, CH>
where where
CH: DmaTxChannel, CH: DmaTxChannel,
@ -3016,7 +3016,7 @@ pub(crate) mod asynch {
} }
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
pub struct DmaRxDoneChFuture<'a, CH> pub struct DmaRxDoneChFuture<'a, CH>
where where
CH: DmaRxChannel, CH: DmaRxChannel,
@ -3025,7 +3025,7 @@ pub(crate) mod asynch {
_a: (), _a: (),
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
impl<'a, CH> DmaRxDoneChFuture<'a, CH> impl<'a, CH> DmaRxDoneChFuture<'a, CH>
where where
CH: DmaRxChannel, CH: DmaRxChannel,
@ -3035,7 +3035,7 @@ pub(crate) mod asynch {
} }
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
impl<CH> core::future::Future for DmaRxDoneChFuture<'_, CH> impl<CH> core::future::Future for DmaRxDoneChFuture<'_, CH>
where where
CH: DmaRxChannel, CH: DmaRxChannel,
@ -3073,7 +3073,7 @@ pub(crate) mod asynch {
} }
} }
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
impl<CH> Drop for DmaRxDoneChFuture<'_, CH> impl<CH> Drop for DmaRxDoneChFuture<'_, CH>
where where
CH: DmaRxChannel, CH: DmaRxChannel,

View File

@ -385,8 +385,9 @@ impl InterruptAccess<DmaRxInterrupt> for AnyI2sDmaRxChannel<'_> {
crate::any_peripheral! { crate::any_peripheral! {
/// An I2S-compatible type-erased DMA channel. /// An I2S-compatible type-erased DMA channel.
pub peripheral AnyI2sDmaChannel<'d> { pub peripheral AnyI2sDmaChannel<'d> {
#[cfg(soc_has_i2s0)]
I2s0(super::DMA_I2S0<'d>), I2s0(super::DMA_I2S0<'d>),
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
I2s1(super::DMA_I2S1<'d>), I2s1(super::DMA_I2S1<'d>),
} }
} }
@ -408,8 +409,9 @@ impl PdmaChannel for AnyI2sDmaChannel<'_> {
delegate::delegate! { delegate::delegate! {
to match &self.0 { to match &self.0 {
#[cfg(soc_has_i2s0)]
AnyI2sDmaChannelInner::I2s0(channel) => channel, AnyI2sDmaChannelInner::I2s0(channel) => channel,
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
AnyI2sDmaChannelInner::I2s1(channel) => channel, AnyI2sDmaChannelInner::I2s1(channel) => channel,
} { } {
fn register_block(&self) -> &I2sRegisterBlock; fn register_block(&self) -> &I2sRegisterBlock;

View File

@ -136,17 +136,21 @@ macro_rules! impl_pdma_channel {
impl_pdma_channel!(AnySpi, SpiRegisterBlock, DMA_SPI2, SPI2_DMA, [Spi2]); impl_pdma_channel!(AnySpi, SpiRegisterBlock, DMA_SPI2, SPI2_DMA, [Spi2]);
impl_pdma_channel!(AnySpi, SpiRegisterBlock, DMA_SPI3, SPI3_DMA, [Spi3]); impl_pdma_channel!(AnySpi, SpiRegisterBlock, DMA_SPI3, SPI3_DMA, [Spi3]);
#[cfg(soc_has_i2s0)]
impl_pdma_channel!(AnyI2s, I2sRegisterBlock, DMA_I2S0, I2S0, [I2s0]); impl_pdma_channel!(AnyI2s, I2sRegisterBlock, DMA_I2S0, I2S0, [I2s0]);
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
impl_pdma_channel!(AnyI2s, I2sRegisterBlock, DMA_I2S1, I2S1, [I2s1]); impl_pdma_channel!(AnyI2s, I2sRegisterBlock, DMA_I2S1, I2S1, [I2s1]);
// Specific peripherals use specific channels. Note that this may be overly // Specific peripherals use specific channels. Note that this may be overly
// restrictive (ESP32 allows configuring 2 SPI DMA channels between 3 different // restrictive (ESP32 allows configuring 2 SPI DMA channels between 3 different
// peripherals), but for the current set of restrictions this is sufficient. // peripherals), but for the current set of restrictions this is sufficient.
#[cfg(soc_has_spi2)]
crate::dma::impl_dma_eligible!([DMA_SPI2] SPI2 => Spi2); crate::dma::impl_dma_eligible!([DMA_SPI2] SPI2 => Spi2);
#[cfg(soc_has_spi3)]
crate::dma::impl_dma_eligible!([DMA_SPI3] SPI3 => Spi3); crate::dma::impl_dma_eligible!([DMA_SPI3] SPI3 => Spi3);
#[cfg(soc_has_i2s0)]
crate::dma::impl_dma_eligible!([DMA_I2S0] I2S0 => I2s0); crate::dma::impl_dma_eligible!([DMA_I2S0] I2S0 => I2s0);
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
crate::dma::impl_dma_eligible!([DMA_I2S1] I2S1 => I2s1); crate::dma::impl_dma_eligible!([DMA_I2S1] I2S1 => I2s1);
#[cfg(esp32s2)] #[cfg(esp32s2)]
use crate::peripherals::DMA_CRYPTO; use crate::peripherals::DMA_CRYPTO;

View File

@ -5,7 +5,7 @@
//! Each pin can be used as a general-purpose I/O, or be connected to one or //! Each pin can be used as a general-purpose I/O, or be connected to one or
//! more internal peripheral signals. //! more internal peripheral signals.
#![cfg_attr( #![cfg_attr(
soc_etm, soc_has_etm,
doc = "The GPIO pins also provide tasks and events via the ETM interconnect system. For more information, see the [etm] module." doc = "The GPIO pins also provide tasks and events via the ETM interconnect system. For more information, see the [etm] module."
)] )]
#![doc = ""] #![doc = ""]
@ -54,13 +54,13 @@
crate::unstable_module! { crate::unstable_module! {
pub mod interconnect; pub mod interconnect;
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
pub mod etm; pub mod etm;
#[cfg(lp_io)] #[cfg(soc_has_lp_io)]
pub mod lp_io; pub mod lp_io;
#[cfg(all(rtc_io, not(esp32)))] #[cfg(all(soc_has_rtc_io, not(esp32)))]
pub mod rtc_io; pub mod rtc_io;
} }
@ -76,7 +76,7 @@ pub use placeholder::NoPin;
use portable_atomic::AtomicU32; use portable_atomic::AtomicU32;
use strum::EnumCount; use strum::EnumCount;
#[cfg(any(lp_io, rtc_cntl))] #[cfg(any(soc_has_lp_io, soc_has_rtc_cntl))]
use crate::peripherals::{handle_rtcio, handle_rtcio_with_resistors}; use crate::peripherals::{handle_rtcio, handle_rtcio_with_resistors};
pub use crate::soc::gpio::*; pub use crate::soc::gpio::*;
use crate::{ use crate::{
@ -354,7 +354,7 @@ pub trait RtcPin: Pin {
/// Trait implemented by RTC pins which supporting internal pull-up / pull-down /// Trait implemented by RTC pins which supporting internal pull-up / pull-down
/// resistors. /// resistors.
#[instability::unstable] #[instability::unstable]
#[cfg(any(lp_io, rtc_cntl))] #[cfg(any(soc_has_lp_io, soc_has_rtc_cntl))]
pub trait RtcPinWithResistors: RtcPin { pub trait RtcPinWithResistors: RtcPin {
/// Enable/disable the internal pull-up resistor /// Enable/disable the internal pull-up resistor
#[doc(hidden)] #[doc(hidden)]
@ -588,7 +588,7 @@ pub struct AnyPin<'lt> {
/// Workaround to make D+ and D- work on the ESP32-C3 and ESP32-S3, which by /// Workaround to make D+ and D- work on the ESP32-C3 and ESP32-S3, which by
/// default are assigned to the `USB_SERIAL_JTAG` peripheral. /// default are assigned to the `USB_SERIAL_JTAG` peripheral.
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
fn disable_usb_pads(gpionum: u8) { fn disable_usb_pads(gpionum: u8) {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(esp32c3)] { if #[cfg(esp32c3)] {
@ -937,7 +937,7 @@ macro_rules! gpio {
pub(crate) use handle_gpio_input; pub(crate) use handle_gpio_input;
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(any(lp_io, rtc_cntl))] { if #[cfg(any(soc_has_lp_io, soc_has_rtc_cntl))] {
#[doc(hidden)] #[doc(hidden)]
macro_rules! handle_rtcio { macro_rules! handle_rtcio {
($this:expr, $inner:ident, $code:tt) => { ($this:expr, $inner:ident, $code:tt) => {
@ -1792,7 +1792,7 @@ impl<'lt> AnyPin<'lt> {
/// - Before converting it into signals /// - Before converting it into signals
/// - Before using it as an input or output /// - Before using it as an input or output
pub(crate) fn init_gpio(&self) { pub(crate) fn init_gpio(&self) {
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
disable_usb_pads(self.number()); disable_usb_pads(self.number());
self.set_output_enable(false); self.set_output_enable(false);
@ -2079,7 +2079,7 @@ impl Pin for AnyPin<'_> {
impl InputPin for AnyPin<'_> {} impl InputPin for AnyPin<'_> {}
impl OutputPin for AnyPin<'_> {} impl OutputPin for AnyPin<'_> {}
#[cfg(any(lp_io, rtc_cntl))] #[cfg(any(soc_has_lp_io, soc_has_rtc_cntl))]
impl RtcPin for AnyPin<'_> { impl RtcPin for AnyPin<'_> {
#[cfg(xtensa)] #[cfg(xtensa)]
#[allow(unused_braces, reason = "False positive")] #[allow(unused_braces, reason = "False positive")]
@ -2109,7 +2109,7 @@ impl RtcPin for AnyPin<'_> {
} }
} }
#[cfg(any(lp_io, rtc_cntl))] #[cfg(any(soc_has_lp_io, soc_has_rtc_cntl))]
impl RtcPinWithResistors for AnyPin<'_> { impl RtcPinWithResistors for AnyPin<'_> {
fn rtcio_pullup(&self, enable: bool) { fn rtcio_pullup(&self, enable: bool) {
handle_rtcio_with_resistors!(self, target, { handle_rtcio_with_resistors!(self, target, {

View File

@ -10,7 +10,7 @@
pub mod master; pub mod master;
#[cfg(lp_i2c0)] #[cfg(soc_has_lp_i2c0)]
crate::unstable_module! { crate::unstable_module! {
pub mod lp_i2c; pub mod lp_i2c;
} }

View File

@ -669,8 +669,9 @@ where
/// A peripheral singleton compatible with the I2S master driver. /// A peripheral singleton compatible with the I2S master driver.
pub trait Instance: RegisterAccessPrivate + super::IntoAnyI2s {} pub trait Instance: RegisterAccessPrivate + super::IntoAnyI2s {}
#[cfg(soc_has_i2s0)]
impl Instance for crate::peripherals::I2S0<'_> {} impl Instance for crate::peripherals::I2S0<'_> {}
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
impl Instance for crate::peripherals::I2S1<'_> {} impl Instance for crate::peripherals::I2S1<'_> {}
impl Instance for AnyI2s<'_> {} impl Instance for AnyI2s<'_> {}
@ -678,7 +679,7 @@ mod private {
use enumset::EnumSet; use enumset::EnumSet;
use super::*; use super::*;
#[cfg(not(i2s1))] #[cfg(not(soc_has_i2s1))]
use crate::pac::i2s0::RegisterBlock; use crate::pac::i2s0::RegisterBlock;
use crate::{ use crate::{
DriverMode, DriverMode,
@ -696,7 +697,7 @@ mod private {
}; };
// on ESP32-S3 I2S1 doesn't support all features - use that to avoid using those features // on ESP32-S3 I2S1 doesn't support all features - use that to avoid using those features
// by accident // by accident
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
use crate::{pac::i2s1::RegisterBlock, peripherals::I2S1}; use crate::{pac::i2s1::RegisterBlock, peripherals::I2S1};
pub struct TxCreator<'d, Dm> pub struct TxCreator<'d, Dm>
@ -1608,7 +1609,7 @@ mod private {
} }
} }
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
impl RegBlock for I2S1<'_> { impl RegBlock for I2S1<'_> {
fn regs(&self) -> &RegisterBlock { fn regs(&self) -> &RegisterBlock {
unsafe { &*I2S1::PTR.cast::<RegisterBlock>() } unsafe { &*I2S1::PTR.cast::<RegisterBlock>() }
@ -1619,7 +1620,7 @@ mod private {
} }
} }
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
impl RegisterAccessPrivate for I2S1<'_> { impl RegisterAccessPrivate for I2S1<'_> {
fn set_interrupt_handler(&self, handler: InterruptHandler) { fn set_interrupt_handler(&self, handler: InterruptHandler) {
for core in crate::system::Cpu::other() { for core in crate::system::Cpu::other() {
@ -1633,7 +1634,7 @@ mod private {
} }
} }
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
impl Signals for crate::peripherals::I2S1<'_> { impl Signals for crate::peripherals::I2S1<'_> {
fn mclk_signal(&self) -> OutputSignal { fn mclk_signal(&self) -> OutputSignal {
cfg_if::cfg_if! { cfg_if::cfg_if! {
@ -1685,16 +1686,18 @@ mod private {
impl RegBlock for super::AnyI2s<'_> { impl RegBlock for super::AnyI2s<'_> {
fn regs(&self) -> &RegisterBlock { fn regs(&self) -> &RegisterBlock {
match &self.0 { match &self.0 {
#[cfg(soc_has_i2s0)]
AnyI2sInner::I2s0(i2s) => RegBlock::regs(i2s), AnyI2sInner::I2s0(i2s) => RegBlock::regs(i2s),
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
AnyI2sInner::I2s1(i2s) => RegBlock::regs(i2s), AnyI2sInner::I2s1(i2s) => RegBlock::regs(i2s),
} }
} }
delegate::delegate! { delegate::delegate! {
to match &self.0 { to match &self.0 {
#[cfg(soc_has_i2s0)]
AnyI2sInner::I2s0(i2s) => i2s, AnyI2sInner::I2s0(i2s) => i2s,
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
AnyI2sInner::I2s1(i2s) => i2s, AnyI2sInner::I2s1(i2s) => i2s,
} { } {
fn peripheral(&self) -> crate::system::Peripheral; fn peripheral(&self) -> crate::system::Peripheral;
@ -1705,8 +1708,9 @@ mod private {
impl RegisterAccessPrivate for super::AnyI2s<'_> { impl RegisterAccessPrivate for super::AnyI2s<'_> {
delegate::delegate! { delegate::delegate! {
to match &self.0 { to match &self.0 {
#[cfg(soc_has_i2s0)]
AnyI2sInner::I2s0(i2s) => i2s, AnyI2sInner::I2s0(i2s) => i2s,
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
AnyI2sInner::I2s1(i2s) => i2s, AnyI2sInner::I2s1(i2s) => i2s,
} { } {
fn set_interrupt_handler(&self, handler: InterruptHandler); fn set_interrupt_handler(&self, handler: InterruptHandler);
@ -1717,8 +1721,9 @@ mod private {
impl Signals for super::AnyI2s<'_> { impl Signals for super::AnyI2s<'_> {
delegate::delegate! { delegate::delegate! {
to match &self.0 { to match &self.0 {
#[cfg(soc_has_i2s0)]
AnyI2sInner::I2s0(i2s) => i2s, AnyI2sInner::I2s0(i2s) => i2s,
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
AnyI2sInner::I2s1(i2s) => i2s, AnyI2sInner::I2s1(i2s) => i2s,
} { } {
fn mclk_signal(&self) -> OutputSignal; fn mclk_signal(&self) -> OutputSignal;

View File

@ -10,9 +10,9 @@ pub mod parallel;
crate::any_peripheral! { crate::any_peripheral! {
/// Any I2S peripheral. /// Any I2S peripheral.
pub peripheral AnyI2s<'d> { pub peripheral AnyI2s<'d> {
#[cfg(i2s0)] #[cfg(soc_has_i2s0)]
I2s0(crate::peripherals::I2S0<'d>), I2s0(crate::peripherals::I2S0<'d>),
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
I2s1(crate::peripherals::I2S1<'d>), I2s1(crate::peripherals::I2S1<'d>),
} }
} }
@ -25,8 +25,9 @@ impl<'d> DmaEligible for AnyI2s<'d> {
fn dma_peripheral(&self) -> crate::dma::DmaPeripheral { fn dma_peripheral(&self) -> crate::dma::DmaPeripheral {
match &self.0 { match &self.0 {
#[cfg(soc_has_i2s0)]
AnyI2sInner::I2s0(_) => crate::dma::DmaPeripheral::I2s0, AnyI2sInner::I2s0(_) => crate::dma::DmaPeripheral::I2s0,
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
AnyI2sInner::I2s1(_) => crate::dma::DmaPeripheral::I2s1, AnyI2sInner::I2s1(_) => crate::dma::DmaPeripheral::I2s1,
} }
} }

View File

@ -793,6 +793,6 @@ impl PrivateInstance for AnyI2s<'_> {
pub trait Instance: PrivateInstance + super::IntoAnyI2s {} pub trait Instance: PrivateInstance + super::IntoAnyI2s {}
impl Instance for I2S0<'_> {} impl Instance for I2S0<'_> {}
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
impl Instance for I2S1<'_> {} impl Instance for I2S1<'_> {}
impl Instance for AnyI2s<'_> {} impl Instance for AnyI2s<'_> {}

View File

@ -208,7 +208,7 @@ pub use esp_riscv_rt::{self, riscv};
#[cfg_attr(not(feature = "unstable"), doc(hidden))] #[cfg_attr(not(feature = "unstable"), doc(hidden))]
pub use xtensa_lx_rt::{self, xtensa_lx}; pub use xtensa_lx_rt::{self, xtensa_lx};
#[cfg(efuse)] #[cfg(soc_has_efuse)]
#[instability::unstable] #[instability::unstable]
#[cfg_attr(not(feature = "unstable"), allow(unused))] #[cfg_attr(not(feature = "unstable"), allow(unused))]
pub use self::soc::efuse; pub use self::soc::efuse;
@ -226,20 +226,20 @@ pub use self::soc::psram;
#[cfg_attr(not(feature = "unstable"), allow(unused))] #[cfg_attr(not(feature = "unstable"), allow(unused))]
pub use self::soc::ulp_core; pub use self::soc::ulp_core;
#[cfg(any(dport, hp_sys, pcr, system))] #[cfg(any(soc_has_dport, soc_has_hp_sys, soc_has_pcr, soc_has_system))]
pub mod clock; pub mod clock;
#[cfg(gpio)] #[cfg(soc_has_gpio)]
pub mod gpio; pub mod gpio;
#[cfg(any(i2c0, i2c1))] #[cfg(any(soc_has_i2c0, soc_has_i2c1))]
pub mod i2c; pub mod i2c;
pub mod peripheral; pub mod peripheral;
#[cfg(all(feature = "unstable", any(hmac, sha)))] #[cfg(all(feature = "unstable", any(soc_has_hmac, soc_has_sha)))]
mod reg_access; mod reg_access;
#[cfg(any(spi0, spi1, spi2, spi3))] #[cfg(any(soc_has_spi0, soc_has_spi1, soc_has_spi2, soc_has_spi3))]
pub mod spi; pub mod spi;
pub mod system; pub mod system;
pub mod time; pub mod time;
#[cfg(any(uart0, uart1, uart2))] #[cfg(any(soc_has_uart0, soc_has_uart1, soc_has_uart2))]
pub mod uart; pub mod uart;
mod macros; mod macros;
@ -300,7 +300,7 @@ unstable_module! {
pub mod asynch; pub mod asynch;
pub mod config; pub mod config;
pub mod debugger; pub mod debugger;
#[cfg(any(dport, interrupt_core0, interrupt_core1))] #[cfg(any(soc_has_dport, soc_has_interrupt_core0, soc_has_interrupt_core1))]
pub mod interrupt; pub mod interrupt;
pub mod rom; pub mod rom;
#[doc(hidden)] #[doc(hidden)]
@ -310,55 +310,55 @@ unstable_module! {
pub mod analog; pub mod analog;
#[cfg(any(systimer, timergroup))] #[cfg(any(systimer, timergroup))]
pub mod timer; pub mod timer;
#[cfg(any(lp_clkrst, rtc_cntl))] #[cfg(any(soc_has_lp_clkrst, soc_has_rtc_cntl))]
pub mod rtc_cntl; pub mod rtc_cntl;
#[cfg(any(gdma, pdma))] #[cfg(any(gdma, pdma))]
pub mod dma; pub mod dma;
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
pub mod etm; pub mod etm;
#[cfg(usb0)] #[cfg(soc_has_usb0)]
pub mod otg_fs; pub mod otg_fs;
} }
unstable_driver! { unstable_driver! {
#[cfg(aes)] #[cfg(soc_has_aes)]
pub mod aes; pub mod aes;
#[cfg(assist_debug)] #[cfg(soc_has_assist_debug)]
pub mod assist_debug; pub mod assist_debug;
pub mod delay; pub mod delay;
#[cfg(ecc)] #[cfg(soc_has_ecc)]
pub mod ecc; pub mod ecc;
#[cfg(hmac)] #[cfg(soc_has_hmac)]
pub mod hmac; pub mod hmac;
#[cfg(any(i2s0, i2s1))] #[cfg(any(soc_has_i2s0, soc_has_i2s1))]
pub mod i2s; pub mod i2s;
#[cfg(lcd_cam)] #[cfg(soc_has_lcd_cam)]
pub mod lcd_cam; pub mod lcd_cam;
#[cfg(ledc)] #[cfg(soc_has_ledc)]
pub mod ledc; pub mod ledc;
#[cfg(any(mcpwm0, mcpwm1))] #[cfg(any(soc_has_mcpwm0, soc_has_mcpwm1))]
pub mod mcpwm; pub mod mcpwm;
#[cfg(parl_io)] #[cfg(soc_has_parl_io)]
pub mod parl_io; pub mod parl_io;
#[cfg(pcnt)] #[cfg(soc_has_pcnt)]
pub mod pcnt; pub mod pcnt;
#[cfg(rmt)] #[cfg(soc_has_rmt)]
pub mod rmt; pub mod rmt;
#[cfg(rng)] #[cfg(soc_has_rng)]
pub mod rng; pub mod rng;
#[cfg(rsa)] #[cfg(soc_has_rsa)]
pub mod rsa; pub mod rsa;
#[cfg(sha)] #[cfg(soc_has_sha)]
pub mod sha; pub mod sha;
#[cfg(touch)] #[cfg(touch)]
pub mod touch; pub mod touch;
#[cfg(trace0)] #[cfg(soc_has_trace0)]
pub mod trace; pub mod trace;
#[cfg(tsens)] #[cfg(tsens)]
pub mod tsens; pub mod tsens;
#[cfg(any(twai0, twai1))] #[cfg(any(soc_has_twai0, soc_has_twai1))]
pub mod twai; pub mod twai;
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
pub mod usb_serial_jtag; pub mod usb_serial_jtag;
} }

View File

@ -317,7 +317,7 @@ pub trait PwmPeripheral: crate::private::Sealed {
fn peripheral() -> system::Peripheral; fn peripheral() -> system::Peripheral;
} }
#[cfg(mcpwm0)] #[cfg(soc_has_mcpwm0)]
impl PwmPeripheral for crate::peripherals::MCPWM0<'_> { impl PwmPeripheral for crate::peripherals::MCPWM0<'_> {
fn block() -> *const RegisterBlock { fn block() -> *const RegisterBlock {
Self::regs() Self::regs()
@ -340,7 +340,7 @@ impl PwmPeripheral for crate::peripherals::MCPWM0<'_> {
} }
} }
#[cfg(mcpwm1)] #[cfg(soc_has_mcpwm1)]
impl PwmPeripheral for crate::peripherals::MCPWM1<'_> { impl PwmPeripheral for crate::peripherals::MCPWM1<'_> {
fn block() -> *const RegisterBlock { fn block() -> *const RegisterBlock {
Self::regs() Self::regs()

View File

@ -1702,7 +1702,7 @@ mod chip_specific {
return Err(Error::UnreachableTargetFrequency); return Err(Error::UnreachableTargetFrequency);
}; };
#[cfg(not(pcr))] #[cfg(not(soc_has_pcr))]
{ {
RMT::regs().sys_conf().modify(|_, w| unsafe { RMT::regs().sys_conf().modify(|_, w| unsafe {
w.clk_en().clear_bit(); w.clk_en().clear_bit();
@ -1714,7 +1714,7 @@ mod chip_specific {
}); });
} }
#[cfg(pcr)] #[cfg(soc_has_pcr)]
{ {
use crate::peripherals::PCR; use crate::peripherals::PCR;
PCR::regs().rmt_sclk_conf().modify(|_, w| unsafe { PCR::regs().rmt_sclk_conf().modify(|_, w| unsafe {

View File

@ -1025,7 +1025,7 @@ impl RtcSleepConfig {
// misc_modules_sleep_prepare // misc_modules_sleep_prepare
// TODO: IDF-7370 // TODO: IDF-7370
#[cfg(not(pmu))] #[cfg(not(soc_has_pmu))]
if !(self.deep && wakeup_triggers.touch) { if !(self.deep && wakeup_triggers.touch) {
let saradc = &*esp32c6::APB_SARADC::ptr(); let saradc = &*esp32c6::APB_SARADC::ptr();
saradc saradc

View File

@ -495,7 +495,7 @@ bitfield::bitfield! {
pub bt, set_bt: 10; pub bt, set_bt: 10;
} }
#[cfg(pmu)] #[cfg(soc_has_pmu)]
bitfield::bitfield! { bitfield::bitfield! {
/// Represents the wakeup triggers. /// Represents the wakeup triggers.
#[derive(Default, Clone, Copy)] #[derive(Default, Clone, Copy)]

View File

@ -589,8 +589,9 @@ pub trait Instance: crate::private::Sealed + IntoAnySpi {
#[allow(private_bounds)] #[allow(private_bounds)]
pub trait InstanceDma: Instance + DmaEligible {} pub trait InstanceDma: Instance + DmaEligible {}
#[cfg(soc_has_spi2)]
impl InstanceDma for crate::peripherals::SPI2<'_> {} impl InstanceDma for crate::peripherals::SPI2<'_> {}
#[cfg(spi3)] #[cfg(soc_has_spi3)]
impl InstanceDma for crate::peripherals::SPI3<'_> {} impl InstanceDma for crate::peripherals::SPI3<'_> {}
/// Peripheral data describing a particular SPI instance. /// Peripheral data describing a particular SPI instance.
@ -836,7 +837,9 @@ impl<'d> DmaEligible for AnySpi<'d> {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(esp32)] { if #[cfg(esp32)] {
#[cfg(spi_master_spi2)]
spi_instance!(2, HSPICLK, HSPID, HSPIQ, HSPICS0); spi_instance!(2, HSPICLK, HSPID, HSPIQ, HSPICS0);
#[cfg(spi_master_spi3)]
spi_instance!(3, VSPICLK, VSPID, VSPIQ, VSPICS0); spi_instance!(3, VSPICLK, VSPID, VSPIQ, VSPICS0);
} else { } else {
#[cfg(spi_master_spi2)] #[cfg(spi_master_spi2)]

View File

@ -19,34 +19,34 @@ use crate::peripherals::SYSTEM;
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Peripheral { pub enum Peripheral {
/// SPI2 peripheral. /// SPI2 peripheral.
#[cfg(spi2)] #[cfg(soc_has_spi2)]
Spi2, Spi2,
/// SPI3 peripheral. /// SPI3 peripheral.
#[cfg(spi3)] #[cfg(soc_has_spi3)]
Spi3, Spi3,
/// External I2C0 peripheral. /// External I2C0 peripheral.
#[cfg(i2c0)] #[cfg(soc_has_i2c0)]
I2cExt0, I2cExt0,
/// External I2C1 peripheral. /// External I2C1 peripheral.
#[cfg(i2c1)] #[cfg(soc_has_i2c1)]
I2cExt1, I2cExt1,
/// RMT peripheral (Remote Control). /// RMT peripheral (Remote Control).
#[cfg(rmt)] #[cfg(soc_has_rmt)]
Rmt, Rmt,
/// LEDC peripheral (LED PWM Controller). /// LEDC peripheral (LED PWM Controller).
#[cfg(ledc)] #[cfg(soc_has_ledc)]
Ledc, Ledc,
/// MCPWM0 peripheral (Motor Control PWM 0). /// MCPWM0 peripheral (Motor Control PWM 0).
#[cfg(mcpwm0)] #[cfg(soc_has_mcpwm0)]
Mcpwm0, Mcpwm0,
/// MCPWM1 peripheral (Motor Control PWM 1). /// MCPWM1 peripheral (Motor Control PWM 1).
#[cfg(mcpwm1)] #[cfg(soc_has_mcpwm1)]
Mcpwm1, Mcpwm1,
/// PCNT peripheral (Pulse Counter). /// PCNT peripheral (Pulse Counter).
#[cfg(pcnt)] #[cfg(soc_has_pcnt)]
Pcnt, Pcnt,
/// APB SAR ADC peripheral. /// APB SAR ADC peripheral.
#[cfg(apb_saradc)] #[cfg(soc_has_apb_saradc)]
ApbSarAdc, ApbSarAdc,
/// General DMA (GDMA) peripheral. /// General DMA (GDMA) peripheral.
#[cfg(gdma)] #[cfg(gdma)]
@ -55,67 +55,67 @@ pub enum Peripheral {
#[cfg(pdma)] #[cfg(pdma)]
Dma, Dma,
/// I2S0 peripheral (Inter-IC Sound). /// I2S0 peripheral (Inter-IC Sound).
#[cfg(i2s0)] #[cfg(soc_has_i2s0)]
I2s0, I2s0,
/// I2S1 peripheral (Inter-IC Sound). /// I2S1 peripheral (Inter-IC Sound).
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
I2s1, I2s1,
/// USB0 peripheral. /// USB0 peripheral.
#[cfg(usb0)] #[cfg(soc_has_usb0)]
Usb, Usb,
/// AES peripheral (Advanced Encryption Standard). /// AES peripheral (Advanced Encryption Standard).
#[cfg(aes)] #[cfg(soc_has_aes)]
Aes, Aes,
/// TWAI0 peripheral. /// TWAI0 peripheral.
#[cfg(twai0)] #[cfg(soc_has_twai0)]
Twai0, Twai0,
/// TWAI1 peripheral. /// TWAI1 peripheral.
#[cfg(twai1)] #[cfg(soc_has_twai1)]
Twai1, Twai1,
/// Timer Group 0 peripheral. /// Timer Group 0 peripheral.
#[cfg(timg0)] #[cfg(soc_has_timg0)]
Timg0, Timg0,
/// Timer Group 1 peripheral. /// Timer Group 1 peripheral.
#[cfg(timg1)] #[cfg(soc_has_timg1)]
Timg1, Timg1,
/// SHA peripheral (Secure Hash Algorithm). /// SHA peripheral (Secure Hash Algorithm).
#[cfg(sha)] #[cfg(soc_has_sha)]
Sha, Sha,
/// USB Device peripheral. /// USB Device peripheral.
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
UsbDevice, UsbDevice,
/// UART0 peripheral. /// UART0 peripheral.
#[cfg(uart0)] #[cfg(soc_has_uart0)]
Uart0, Uart0,
/// UART1 peripheral. /// UART1 peripheral.
#[cfg(uart1)] #[cfg(soc_has_uart1)]
Uart1, Uart1,
/// UART2 peripheral. /// UART2 peripheral.
#[cfg(uart2)] #[cfg(soc_has_uart2)]
Uart2, Uart2,
/// RSA peripheral (Rivest-Shamir-Adleman encryption). /// RSA peripheral (Rivest-Shamir-Adleman encryption).
#[cfg(rsa)] #[cfg(soc_has_rsa)]
Rsa, Rsa,
/// Parallel IO peripheral. /// Parallel IO peripheral.
#[cfg(parl_io)] #[cfg(soc_has_parl_io)]
ParlIo, ParlIo,
/// HMAC peripheral (Hash-based Message Authentication Code). /// HMAC peripheral (Hash-based Message Authentication Code).
#[cfg(hmac)] #[cfg(soc_has_hmac)]
Hmac, Hmac,
/// ECC peripheral (Elliptic Curve Cryptography). /// ECC peripheral (Elliptic Curve Cryptography).
#[cfg(ecc)] #[cfg(soc_has_ecc)]
Ecc, Ecc,
/// SOC ETM peripheral (Event Task Manager). /// SOC ETM peripheral (Event Task Manager).
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
Etm, Etm,
/// TRACE0 peripheral (Debug trace). /// TRACE0 peripheral (Debug trace).
#[cfg(trace0)] #[cfg(soc_has_trace0)]
Trace0, Trace0,
/// LCD Camera peripheral. /// LCD Camera peripheral.
#[cfg(lcd_cam)] #[cfg(soc_has_lcd_cam)]
LcdCam, LcdCam,
/// Systimer peripheral. /// Systimer peripheral.
#[cfg(systimer)] #[cfg(soc_has_systimer)]
Systimer, Systimer,
/// Temperature sensor peripheral. /// Temperature sensor peripheral.
#[cfg(tsens)] #[cfg(tsens)]
@ -125,11 +125,11 @@ pub enum Peripheral {
impl Peripheral { impl Peripheral {
const KEEP_ENABLED: &[Peripheral] = &[ const KEEP_ENABLED: &[Peripheral] = &[
Peripheral::Uart0, Peripheral::Uart0,
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
Peripheral::UsbDevice, Peripheral::UsbDevice,
#[cfg(systimer)] #[cfg(soc_has_systimer)]
Peripheral::Systimer, Peripheral::Systimer,
#[cfg(timg0)] #[cfg(soc_has_timg0)]
Peripheral::Timg0, Peripheral::Timg0,
#[cfg(esp32c6)] // used by some wifi calibration steps. #[cfg(esp32c6)] // used by some wifi calibration steps.
// TODO: We should probably automatically enable this when needed. // TODO: We should probably automatically enable this when needed.
@ -139,71 +139,71 @@ impl Peripheral {
const COUNT: usize = Self::ALL.len(); const COUNT: usize = Self::ALL.len();
const ALL: &[Self] = &[ const ALL: &[Self] = &[
#[cfg(spi2)] #[cfg(soc_has_spi2)]
Self::Spi2, Self::Spi2,
#[cfg(spi3)] #[cfg(soc_has_spi3)]
Self::Spi3, Self::Spi3,
#[cfg(i2c0)] #[cfg(soc_has_i2c0)]
Self::I2cExt0, Self::I2cExt0,
#[cfg(i2c1)] #[cfg(soc_has_i2c1)]
Self::I2cExt1, Self::I2cExt1,
#[cfg(rmt)] #[cfg(soc_has_rmt)]
Self::Rmt, Self::Rmt,
#[cfg(ledc)] #[cfg(soc_has_ledc)]
Self::Ledc, Self::Ledc,
#[cfg(mcpwm0)] #[cfg(soc_has_mcpwm0)]
Self::Mcpwm0, Self::Mcpwm0,
#[cfg(mcpwm1)] #[cfg(soc_has_mcpwm1)]
Self::Mcpwm1, Self::Mcpwm1,
#[cfg(pcnt)] #[cfg(soc_has_pcnt)]
Self::Pcnt, Self::Pcnt,
#[cfg(apb_saradc)] #[cfg(soc_has_apb_saradc)]
Self::ApbSarAdc, Self::ApbSarAdc,
#[cfg(gdma)] #[cfg(gdma)]
Self::Gdma, Self::Gdma,
#[cfg(pdma)] #[cfg(pdma)]
Self::Dma, Self::Dma,
#[cfg(i2s0)] #[cfg(soc_has_i2s0)]
Self::I2s0, Self::I2s0,
#[cfg(i2s1)] #[cfg(soc_has_i2s1)]
Self::I2s1, Self::I2s1,
#[cfg(usb0)] #[cfg(soc_has_usb0)]
Self::Usb, Self::Usb,
#[cfg(aes)] #[cfg(soc_has_aes)]
Self::Aes, Self::Aes,
#[cfg(twai0)] #[cfg(soc_has_twai0)]
Self::Twai0, Self::Twai0,
#[cfg(twai1)] #[cfg(soc_has_twai1)]
Self::Twai1, Self::Twai1,
#[cfg(timg0)] #[cfg(soc_has_timg0)]
Self::Timg0, Self::Timg0,
#[cfg(timg1)] #[cfg(soc_has_timg1)]
Self::Timg1, Self::Timg1,
#[cfg(sha)] #[cfg(soc_has_sha)]
Self::Sha, Self::Sha,
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
Self::UsbDevice, Self::UsbDevice,
#[cfg(uart0)] #[cfg(soc_has_uart0)]
Self::Uart0, Self::Uart0,
#[cfg(uart1)] #[cfg(soc_has_uart1)]
Self::Uart1, Self::Uart1,
#[cfg(uart2)] #[cfg(soc_has_uart2)]
Self::Uart2, Self::Uart2,
#[cfg(rsa)] #[cfg(soc_has_rsa)]
Self::Rsa, Self::Rsa,
#[cfg(parl_io)] #[cfg(soc_has_parl_io)]
Self::ParlIo, Self::ParlIo,
#[cfg(hmac)] #[cfg(soc_has_hmac)]
Self::Hmac, Self::Hmac,
#[cfg(ecc)] #[cfg(soc_has_ecc)]
Self::Ecc, Self::Ecc,
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
Self::Etm, Self::Etm,
#[cfg(trace0)] #[cfg(soc_has_trace0)]
Self::Trace0, Self::Trace0,
#[cfg(lcd_cam)] #[cfg(soc_has_lcd_cam)]
Self::LcdCam, Self::LcdCam,
#[cfg(systimer)] #[cfg(soc_has_systimer)]
Self::Systimer, Self::Systimer,
#[cfg(tsens)] #[cfg(tsens)]
Self::Tsens, Self::Tsens,
@ -329,47 +329,47 @@ impl PeripheralClockControl {
let perip_clk_en1 = &system.perip_clk_en1(); let perip_clk_en1 = &system.perip_clk_en1();
match peripheral { match peripheral {
#[cfg(spi2)] #[cfg(soc_has_spi2)]
Peripheral::Spi2 => { Peripheral::Spi2 => {
perip_clk_en0.modify(|_, w| w.spi2_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.spi2_clk_en().bit(enable));
} }
#[cfg(spi3)] #[cfg(soc_has_spi3)]
Peripheral::Spi3 => { Peripheral::Spi3 => {
perip_clk_en0.modify(|_, w| w.spi3_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.spi3_clk_en().bit(enable));
} }
#[cfg(all(i2c0, esp32))] #[cfg(all(soc_has_i2c0, esp32))]
Peripheral::I2cExt0 => { Peripheral::I2cExt0 => {
perip_clk_en0.modify(|_, w| w.i2c0_ext0_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.i2c0_ext0_clk_en().bit(enable));
} }
#[cfg(all(i2c0, not(esp32)))] #[cfg(all(soc_has_i2c0, not(esp32)))]
Peripheral::I2cExt0 => { Peripheral::I2cExt0 => {
perip_clk_en0.modify(|_, w| w.i2c_ext0_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
} }
#[cfg(i2c1)] #[cfg(soc_has_i2c1)]
Peripheral::I2cExt1 => { Peripheral::I2cExt1 => {
perip_clk_en0.modify(|_, w| w.i2c_ext1_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.i2c_ext1_clk_en().bit(enable));
} }
#[cfg(rmt)] #[cfg(soc_has_rmt)]
Peripheral::Rmt => { Peripheral::Rmt => {
perip_clk_en0.modify(|_, w| w.rmt_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.rmt_clk_en().bit(enable));
} }
#[cfg(ledc)] #[cfg(soc_has_ledc)]
Peripheral::Ledc => { Peripheral::Ledc => {
perip_clk_en0.modify(|_, w| w.ledc_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.ledc_clk_en().bit(enable));
} }
#[cfg(mcpwm0)] #[cfg(soc_has_mcpwm0)]
Peripheral::Mcpwm0 => { Peripheral::Mcpwm0 => {
perip_clk_en0.modify(|_, w| w.pwm0_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.pwm0_clk_en().bit(enable));
} }
#[cfg(mcpwm1)] #[cfg(soc_has_mcpwm1)]
Peripheral::Mcpwm1 => { Peripheral::Mcpwm1 => {
perip_clk_en0.modify(|_, w| w.pwm1_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.pwm1_clk_en().bit(enable));
} }
#[cfg(pcnt)] #[cfg(soc_has_pcnt)]
Peripheral::Pcnt => { Peripheral::Pcnt => {
perip_clk_en0.modify(|_, w| w.pcnt_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.pcnt_clk_en().bit(enable));
} }
#[cfg(apb_saradc)] #[cfg(soc_has_apb_saradc)]
Peripheral::ApbSarAdc => { Peripheral::ApbSarAdc => {
perip_clk_en0.modify(|_, w| w.apb_saradc_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.apb_saradc_clk_en().bit(enable));
} }
@ -400,11 +400,11 @@ impl PeripheralClockControl {
Peripheral::I2s1 => { Peripheral::I2s1 => {
perip_clk_en0.modify(|_, w| w.i2s1_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.i2s1_clk_en().bit(enable));
} }
#[cfg(usb0)] #[cfg(soc_has_usb0)]
Peripheral::Usb => { Peripheral::Usb => {
perip_clk_en0.modify(|_, w| w.usb_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.usb_clk_en().bit(enable));
} }
#[cfg(twai0)] #[cfg(soc_has_twai0)]
Peripheral::Twai0 => { Peripheral::Twai0 => {
perip_clk_en0.modify(|_, w| w.twai_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.twai_clk_en().bit(enable));
} }
@ -416,19 +416,19 @@ impl PeripheralClockControl {
Peripheral::Aes => { Peripheral::Aes => {
perip_clk_en1.modify(|_, w| w.crypto_aes_clk_en().bit(enable)); perip_clk_en1.modify(|_, w| w.crypto_aes_clk_en().bit(enable));
} }
#[cfg(timg0)] #[cfg(soc_has_timg0)]
Peripheral::Timg0 => { Peripheral::Timg0 => {
#[cfg(any(esp32c3, esp32s2, esp32s3))] #[cfg(any(esp32c3, esp32s2, esp32s3))]
perip_clk_en0.modify(|_, w| w.timers_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.timers_clk_en().bit(enable));
perip_clk_en0.modify(|_, w| w.timergroup_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.timergroup_clk_en().bit(enable));
} }
#[cfg(timg1)] #[cfg(soc_has_timg1)]
Peripheral::Timg1 => { Peripheral::Timg1 => {
#[cfg(any(esp32c3, esp32s2, esp32s3))] #[cfg(any(esp32c3, esp32s2, esp32s3))]
perip_clk_en0.modify(|_, w| w.timers_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.timers_clk_en().bit(enable));
perip_clk_en0.modify(|_, w| w.timergroup1_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.timergroup1_clk_en().bit(enable));
} }
#[cfg(sha)] #[cfg(soc_has_sha)]
Peripheral::Sha => { Peripheral::Sha => {
#[cfg(not(esp32))] #[cfg(not(esp32))]
perip_clk_en1.modify(|_, w| w.crypto_sha_clk_en().bit(enable)); perip_clk_en1.modify(|_, w| w.crypto_sha_clk_en().bit(enable));
@ -441,19 +441,19 @@ impl PeripheralClockControl {
Peripheral::UsbDevice => { Peripheral::UsbDevice => {
perip_clk_en1.modify(|_, w| w.usb_device_clk_en().bit(enable)); perip_clk_en1.modify(|_, w| w.usb_device_clk_en().bit(enable));
} }
#[cfg(uart0)] #[cfg(soc_has_uart0)]
Peripheral::Uart0 => { Peripheral::Uart0 => {
perip_clk_en0.modify(|_, w| w.uart_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.uart_clk_en().bit(enable));
} }
#[cfg(uart1)] #[cfg(soc_has_uart1)]
Peripheral::Uart1 => { Peripheral::Uart1 => {
perip_clk_en0.modify(|_, w| w.uart1_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.uart1_clk_en().bit(enable));
} }
#[cfg(all(uart2, esp32s3))] #[cfg(all(soc_has_uart2, esp32s3))]
Peripheral::Uart2 => { Peripheral::Uart2 => {
perip_clk_en1.modify(|_, w| w.uart2_clk_en().set_bit()); perip_clk_en1.modify(|_, w| w.uart2_clk_en().set_bit());
} }
#[cfg(all(uart2, esp32))] #[cfg(all(soc_has_uart2, esp32))]
Peripheral::Uart2 => { Peripheral::Uart2 => {
perip_clk_en0.modify(|_, w| w.uart2_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.uart2_clk_en().bit(enable));
} }
@ -468,19 +468,19 @@ impl PeripheralClockControl {
.rsa_pd_ctrl() .rsa_pd_ctrl()
.modify(|_, w| w.rsa_mem_pd().bit(!enable)); .modify(|_, w| w.rsa_mem_pd().bit(!enable));
} }
#[cfg(hmac)] #[cfg(soc_has_hmac)]
Peripheral::Hmac => { Peripheral::Hmac => {
perip_clk_en1.modify(|_, w| w.crypto_hmac_clk_en().bit(enable)); perip_clk_en1.modify(|_, w| w.crypto_hmac_clk_en().bit(enable));
} }
#[cfg(ecc)] #[cfg(soc_has_ecc)]
Peripheral::Ecc => { Peripheral::Ecc => {
perip_clk_en1.modify(|_, w| w.crypto_ecc_clk_en().bit(enable)); perip_clk_en1.modify(|_, w| w.crypto_ecc_clk_en().bit(enable));
} }
#[cfg(lcd_cam)] #[cfg(soc_has_lcd_cam)]
Peripheral::LcdCam => { Peripheral::LcdCam => {
perip_clk_en1.modify(|_, w| w.lcd_cam_clk_en().bit(enable)); perip_clk_en1.modify(|_, w| w.lcd_cam_clk_en().bit(enable));
} }
#[cfg(systimer)] #[cfg(soc_has_systimer)]
Peripheral::Systimer => { Peripheral::Systimer => {
perip_clk_en0.modify(|_, w| w.systimer_clk_en().bit(enable)); perip_clk_en0.modify(|_, w| w.systimer_clk_en().bit(enable));
} }
@ -505,57 +505,57 @@ impl PeripheralClockControl {
let perip_rst_en1 = system.perip_rst_en1(); let perip_rst_en1 = system.perip_rst_en1();
critical_section::with(|_cs| match peripheral { critical_section::with(|_cs| match peripheral {
#[cfg(spi2)] #[cfg(soc_has_spi2)]
Peripheral::Spi2 => { Peripheral::Spi2 => {
perip_rst_en0.modify(|_, w| w.spi2_rst().set_bit()); perip_rst_en0.modify(|_, w| w.spi2_rst().set_bit());
perip_rst_en0.modify(|_, w| w.spi2_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.spi2_rst().clear_bit());
} }
#[cfg(spi3)] #[cfg(soc_has_spi3)]
Peripheral::Spi3 => { Peripheral::Spi3 => {
perip_rst_en0.modify(|_, w| w.spi3_rst().set_bit()); perip_rst_en0.modify(|_, w| w.spi3_rst().set_bit());
perip_rst_en0.modify(|_, w| w.spi3_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.spi3_rst().clear_bit());
} }
#[cfg(all(i2c0, esp32))] #[cfg(all(soc_has_i2c0, esp32))]
Peripheral::I2cExt0 => { Peripheral::I2cExt0 => {
perip_rst_en0.modify(|_, w| w.i2c0_ext0_rst().set_bit()); perip_rst_en0.modify(|_, w| w.i2c0_ext0_rst().set_bit());
perip_rst_en0.modify(|_, w| w.i2c0_ext0_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.i2c0_ext0_rst().clear_bit());
} }
#[cfg(all(i2c0, not(esp32)))] #[cfg(all(soc_has_i2c0, not(esp32)))]
Peripheral::I2cExt0 => { Peripheral::I2cExt0 => {
perip_rst_en0.modify(|_, w| w.i2c_ext0_rst().set_bit()); perip_rst_en0.modify(|_, w| w.i2c_ext0_rst().set_bit());
perip_rst_en0.modify(|_, w| w.i2c_ext0_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.i2c_ext0_rst().clear_bit());
} }
#[cfg(i2c1)] #[cfg(soc_has_i2c1)]
Peripheral::I2cExt1 => { Peripheral::I2cExt1 => {
perip_rst_en0.modify(|_, w| w.i2c_ext1_rst().set_bit()); perip_rst_en0.modify(|_, w| w.i2c_ext1_rst().set_bit());
perip_rst_en0.modify(|_, w| w.i2c_ext1_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.i2c_ext1_rst().clear_bit());
} }
#[cfg(rmt)] #[cfg(soc_has_rmt)]
Peripheral::Rmt => { Peripheral::Rmt => {
perip_rst_en0.modify(|_, w| w.rmt_rst().set_bit()); perip_rst_en0.modify(|_, w| w.rmt_rst().set_bit());
perip_rst_en0.modify(|_, w| w.rmt_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.rmt_rst().clear_bit());
} }
#[cfg(ledc)] #[cfg(soc_has_ledc)]
Peripheral::Ledc => { Peripheral::Ledc => {
perip_rst_en0.modify(|_, w| w.ledc_rst().set_bit()); perip_rst_en0.modify(|_, w| w.ledc_rst().set_bit());
perip_rst_en0.modify(|_, w| w.ledc_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.ledc_rst().clear_bit());
} }
#[cfg(mcpwm0)] #[cfg(soc_has_mcpwm0)]
Peripheral::Mcpwm0 => { Peripheral::Mcpwm0 => {
perip_rst_en0.modify(|_, w| w.pwm0_rst().set_bit()); perip_rst_en0.modify(|_, w| w.pwm0_rst().set_bit());
perip_rst_en0.modify(|_, w| w.pwm0_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.pwm0_rst().clear_bit());
} }
#[cfg(mcpwm1)] #[cfg(soc_has_mcpwm1)]
Peripheral::Mcpwm1 => { Peripheral::Mcpwm1 => {
perip_rst_en0.modify(|_, w| w.pwm1_rst().set_bit()); perip_rst_en0.modify(|_, w| w.pwm1_rst().set_bit());
perip_rst_en0.modify(|_, w| w.pwm1_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.pwm1_rst().clear_bit());
} }
#[cfg(pcnt)] #[cfg(soc_has_pcnt)]
Peripheral::Pcnt => { Peripheral::Pcnt => {
perip_rst_en0.modify(|_, w| w.pcnt_rst().set_bit()); perip_rst_en0.modify(|_, w| w.pcnt_rst().set_bit());
perip_rst_en0.modify(|_, w| w.pcnt_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.pcnt_rst().clear_bit());
} }
#[cfg(apb_saradc)] #[cfg(soc_has_apb_saradc)]
Peripheral::ApbSarAdc => { Peripheral::ApbSarAdc => {
perip_rst_en0.modify(|_, w| w.apb_saradc_rst().set_bit()); perip_rst_en0.modify(|_, w| w.apb_saradc_rst().set_bit());
perip_rst_en0.modify(|_, w| w.apb_saradc_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.apb_saradc_rst().clear_bit());
@ -595,12 +595,12 @@ impl PeripheralClockControl {
perip_rst_en0.modify(|_, w| w.i2s1_rst().set_bit()); perip_rst_en0.modify(|_, w| w.i2s1_rst().set_bit());
perip_rst_en0.modify(|_, w| w.i2s1_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.i2s1_rst().clear_bit());
} }
#[cfg(usb0)] #[cfg(soc_has_usb0)]
Peripheral::Usb => { Peripheral::Usb => {
perip_rst_en0.modify(|_, w| w.usb_rst().set_bit()); perip_rst_en0.modify(|_, w| w.usb_rst().set_bit());
perip_rst_en0.modify(|_, w| w.usb_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.usb_rst().clear_bit());
} }
#[cfg(twai0)] #[cfg(soc_has_twai0)]
Peripheral::Twai0 => { Peripheral::Twai0 => {
perip_rst_en0.modify(|_, w| w.twai_rst().set_bit()); perip_rst_en0.modify(|_, w| w.twai_rst().set_bit());
perip_rst_en0.modify(|_, w| w.twai_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.twai_rst().clear_bit());
@ -615,7 +615,7 @@ impl PeripheralClockControl {
perip_rst_en1.modify(|_, w| w.crypto_aes_rst().set_bit()); perip_rst_en1.modify(|_, w| w.crypto_aes_rst().set_bit());
perip_rst_en1.modify(|_, w| w.crypto_aes_rst().clear_bit()); perip_rst_en1.modify(|_, w| w.crypto_aes_rst().clear_bit());
} }
#[cfg(timg0)] #[cfg(soc_has_timg0)]
Peripheral::Timg0 => { Peripheral::Timg0 => {
#[cfg(any(esp32c3, esp32s2, esp32s3))] #[cfg(any(esp32c3, esp32s2, esp32s3))]
perip_rst_en0.modify(|_, w| w.timers_rst().set_bit()); perip_rst_en0.modify(|_, w| w.timers_rst().set_bit());
@ -624,7 +624,7 @@ impl PeripheralClockControl {
perip_rst_en0.modify(|_, w| w.timers_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.timers_rst().clear_bit());
perip_rst_en0.modify(|_, w| w.timergroup_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.timergroup_rst().clear_bit());
} }
#[cfg(timg1)] #[cfg(soc_has_timg1)]
Peripheral::Timg1 => { Peripheral::Timg1 => {
#[cfg(any(esp32c3, esp32s2, esp32s3))] #[cfg(any(esp32c3, esp32s2, esp32s3))]
perip_rst_en0.modify(|_, w| w.timers_rst().set_bit()); perip_rst_en0.modify(|_, w| w.timers_rst().set_bit());
@ -633,7 +633,7 @@ impl PeripheralClockControl {
perip_rst_en0.modify(|_, w| w.timers_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.timers_rst().clear_bit());
perip_rst_en0.modify(|_, w| w.timergroup1_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.timergroup1_rst().clear_bit());
} }
#[cfg(sha)] #[cfg(soc_has_sha)]
Peripheral::Sha => { Peripheral::Sha => {
#[cfg(not(esp32))] #[cfg(not(esp32))]
perip_rst_en1.modify(|_, w| w.crypto_sha_rst().set_bit()); perip_rst_en1.modify(|_, w| w.crypto_sha_rst().set_bit());
@ -650,22 +650,22 @@ impl PeripheralClockControl {
perip_rst_en1.modify(|_, w| w.usb_device_rst().set_bit()); perip_rst_en1.modify(|_, w| w.usb_device_rst().set_bit());
perip_rst_en1.modify(|_, w| w.usb_device_rst().clear_bit()); perip_rst_en1.modify(|_, w| w.usb_device_rst().clear_bit());
} }
#[cfg(uart0)] #[cfg(soc_has_uart0)]
Peripheral::Uart0 => { Peripheral::Uart0 => {
perip_rst_en0.modify(|_, w| w.uart_rst().set_bit()); perip_rst_en0.modify(|_, w| w.uart_rst().set_bit());
perip_rst_en0.modify(|_, w| w.uart_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.uart_rst().clear_bit());
} }
#[cfg(uart1)] #[cfg(soc_has_uart1)]
Peripheral::Uart1 => { Peripheral::Uart1 => {
perip_rst_en0.modify(|_, w| w.uart1_rst().set_bit()); perip_rst_en0.modify(|_, w| w.uart1_rst().set_bit());
perip_rst_en0.modify(|_, w| w.uart1_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.uart1_rst().clear_bit());
} }
#[cfg(all(uart2, esp32s3))] #[cfg(all(soc_has_uart2, esp32s3))]
Peripheral::Uart2 => { Peripheral::Uart2 => {
perip_rst_en1.modify(|_, w| w.uart2_rst().set_bit()); perip_rst_en1.modify(|_, w| w.uart2_rst().set_bit());
perip_rst_en1.modify(|_, w| w.uart2_rst().clear_bit()); perip_rst_en1.modify(|_, w| w.uart2_rst().clear_bit());
} }
#[cfg(all(uart2, esp32))] #[cfg(all(soc_has_uart2, esp32))]
Peripheral::Uart2 => { Peripheral::Uart2 => {
perip_rst_en0.modify(|_, w| w.uart2_rst().set_bit()); perip_rst_en0.modify(|_, w| w.uart2_rst().set_bit());
perip_rst_en0.modify(|_, w| w.uart2_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.uart2_rst().clear_bit());
@ -680,22 +680,22 @@ impl PeripheralClockControl {
perip_rst_en1.modify(|_, w| w.crypto_rsa_rst().set_bit()); perip_rst_en1.modify(|_, w| w.crypto_rsa_rst().set_bit());
perip_rst_en1.modify(|_, w| w.crypto_rsa_rst().clear_bit()); perip_rst_en1.modify(|_, w| w.crypto_rsa_rst().clear_bit());
} }
#[cfg(hmac)] #[cfg(soc_has_hmac)]
Peripheral::Hmac => { Peripheral::Hmac => {
perip_rst_en1.modify(|_, w| w.crypto_hmac_rst().set_bit()); perip_rst_en1.modify(|_, w| w.crypto_hmac_rst().set_bit());
perip_rst_en1.modify(|_, w| w.crypto_hmac_rst().clear_bit()); perip_rst_en1.modify(|_, w| w.crypto_hmac_rst().clear_bit());
} }
#[cfg(ecc)] #[cfg(soc_has_ecc)]
Peripheral::Ecc => { Peripheral::Ecc => {
perip_rst_en1.modify(|_, w| w.crypto_ecc_rst().set_bit()); perip_rst_en1.modify(|_, w| w.crypto_ecc_rst().set_bit());
perip_rst_en1.modify(|_, w| w.crypto_ecc_rst().clear_bit()); perip_rst_en1.modify(|_, w| w.crypto_ecc_rst().clear_bit());
} }
#[cfg(lcd_cam)] #[cfg(soc_has_lcd_cam)]
Peripheral::LcdCam => { Peripheral::LcdCam => {
perip_rst_en1.modify(|_, w| w.lcd_cam_rst().set_bit()); perip_rst_en1.modify(|_, w| w.lcd_cam_rst().set_bit());
perip_rst_en1.modify(|_, w| w.lcd_cam_rst().clear_bit()); perip_rst_en1.modify(|_, w| w.lcd_cam_rst().clear_bit());
} }
#[cfg(systimer)] #[cfg(soc_has_systimer)]
Peripheral::Systimer => { Peripheral::Systimer => {
perip_rst_en0.modify(|_, w| w.systimer_rst().set_bit()); perip_rst_en0.modify(|_, w| w.systimer_rst().set_bit());
perip_rst_en0.modify(|_, w| w.systimer_rst().clear_bit()); perip_rst_en0.modify(|_, w| w.systimer_rst().clear_bit());
@ -721,43 +721,43 @@ impl PeripheralClockControl {
let system = SYSTEM::regs(); let system = SYSTEM::regs();
match peripheral { match peripheral {
#[cfg(spi2)] #[cfg(soc_has_spi2)]
Peripheral::Spi2 => { Peripheral::Spi2 => {
system system
.spi2_conf() .spi2_conf()
.modify(|_, w| w.spi2_clk_en().bit(enable)); .modify(|_, w| w.spi2_clk_en().bit(enable));
} }
#[cfg(i2c0)] #[cfg(soc_has_i2c0)]
Peripheral::I2cExt0 => { Peripheral::I2cExt0 => {
system system
.i2c0_conf() .i2c0_conf()
.modify(|_, w| w.i2c0_clk_en().bit(enable)); .modify(|_, w| w.i2c0_clk_en().bit(enable));
} }
#[cfg(i2c1)] #[cfg(soc_has_i2c1)]
Peripheral::I2cExt1 => { Peripheral::I2cExt1 => {
system system
.i2c1_conf() .i2c1_conf()
.modify(|_, w| w.i2c1_clk_en().bit(enable)); .modify(|_, w| w.i2c1_clk_en().bit(enable));
} }
#[cfg(rmt)] #[cfg(soc_has_rmt)]
Peripheral::Rmt => { Peripheral::Rmt => {
system.rmt_conf().modify(|_, w| w.rmt_clk_en().bit(enable)); system.rmt_conf().modify(|_, w| w.rmt_clk_en().bit(enable));
} }
#[cfg(ledc)] #[cfg(soc_has_ledc)]
Peripheral::Ledc => { Peripheral::Ledc => {
system system
.ledc_conf() .ledc_conf()
.modify(|_, w| w.ledc_clk_en().bit(enable)); .modify(|_, w| w.ledc_clk_en().bit(enable));
} }
#[cfg(mcpwm0)] #[cfg(soc_has_mcpwm0)]
Peripheral::Mcpwm0 => { Peripheral::Mcpwm0 => {
system.pwm_conf().modify(|_, w| w.pwm_clk_en().bit(enable)); system.pwm_conf().modify(|_, w| w.pwm_clk_en().bit(enable));
} }
#[cfg(mcpwm1)] #[cfg(soc_has_mcpwm1)]
Peripheral::Mcpwm1 => { Peripheral::Mcpwm1 => {
system.pwm_conf.modify(|_, w| w.pwm_clk_en().bit(enable)); system.pwm_conf.modify(|_, w| w.pwm_clk_en().bit(enable));
} }
#[cfg(apb_saradc)] #[cfg(soc_has_apb_saradc)]
Peripheral::ApbSarAdc => { Peripheral::ApbSarAdc => {
system system
.saradc_conf() .saradc_conf()
@ -769,11 +769,11 @@ impl PeripheralClockControl {
.gdma_conf() .gdma_conf()
.modify(|_, w| w.gdma_clk_en().bit(enable)); .modify(|_, w| w.gdma_clk_en().bit(enable));
} }
#[cfg(i2s0)] #[cfg(soc_has_i2s0)]
Peripheral::I2s0 => { Peripheral::I2s0 => {
system.i2s_conf().modify(|_, w| w.i2s_clk_en().bit(enable)); system.i2s_conf().modify(|_, w| w.i2s_clk_en().bit(enable));
} }
#[cfg(twai0)] #[cfg(soc_has_twai0)]
Peripheral::Twai0 => { Peripheral::Twai0 => {
system system
.twai0_conf() .twai0_conf()
@ -789,86 +789,86 @@ impl PeripheralClockControl {
}); });
} }
} }
#[cfg(twai1)] #[cfg(soc_has_twai1)]
Peripheral::Twai1 => { Peripheral::Twai1 => {
system system
.twai1_conf() .twai1_conf()
.modify(|_, w| w.twai1_clk_en().bit(enable)); .modify(|_, w| w.twai1_clk_en().bit(enable));
} }
#[cfg(aes)] #[cfg(soc_has_aes)]
Peripheral::Aes => { Peripheral::Aes => {
system.aes_conf().modify(|_, w| w.aes_clk_en().bit(enable)); system.aes_conf().modify(|_, w| w.aes_clk_en().bit(enable));
} }
#[cfg(pcnt)] #[cfg(soc_has_pcnt)]
Peripheral::Pcnt => { Peripheral::Pcnt => {
system system
.pcnt_conf() .pcnt_conf()
.modify(|_, w| w.pcnt_clk_en().bit(enable)); .modify(|_, w| w.pcnt_clk_en().bit(enable));
} }
#[cfg(timg0)] #[cfg(soc_has_timg0)]
Peripheral::Timg0 => { Peripheral::Timg0 => {
system system
.timergroup0_timer_clk_conf() .timergroup0_timer_clk_conf()
.modify(|_, w| w.tg0_timer_clk_en().bit(enable)); .modify(|_, w| w.tg0_timer_clk_en().bit(enable));
} }
#[cfg(timg1)] #[cfg(soc_has_timg1)]
Peripheral::Timg1 => { Peripheral::Timg1 => {
system system
.timergroup1_timer_clk_conf() .timergroup1_timer_clk_conf()
.modify(|_, w| w.tg1_timer_clk_en().bit(enable)); .modify(|_, w| w.tg1_timer_clk_en().bit(enable));
} }
#[cfg(sha)] #[cfg(soc_has_sha)]
Peripheral::Sha => { Peripheral::Sha => {
system.sha_conf().modify(|_, w| w.sha_clk_en().bit(enable)); system.sha_conf().modify(|_, w| w.sha_clk_en().bit(enable));
} }
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
Peripheral::UsbDevice => { Peripheral::UsbDevice => {
system system
.usb_device_conf() .usb_device_conf()
.modify(|_, w| w.usb_device_clk_en().bit(enable)); .modify(|_, w| w.usb_device_clk_en().bit(enable));
} }
#[cfg(uart0)] #[cfg(soc_has_uart0)]
Peripheral::Uart0 => { Peripheral::Uart0 => {
system.uart(0).conf().modify(|_, w| w.clk_en().bit(enable)); system.uart(0).conf().modify(|_, w| w.clk_en().bit(enable));
} }
#[cfg(uart1)] #[cfg(soc_has_uart1)]
Peripheral::Uart1 => { Peripheral::Uart1 => {
system.uart(1).conf().modify(|_, w| w.clk_en().bit(enable)); system.uart(1).conf().modify(|_, w| w.clk_en().bit(enable));
} }
#[cfg(rsa)] #[cfg(soc_has_rsa)]
Peripheral::Rsa => { Peripheral::Rsa => {
system.rsa_conf().modify(|_, w| w.rsa_clk_en().bit(enable)); system.rsa_conf().modify(|_, w| w.rsa_clk_en().bit(enable));
system system
.rsa_pd_ctrl() .rsa_pd_ctrl()
.modify(|_, w| w.rsa_mem_pd().clear_bit()); .modify(|_, w| w.rsa_mem_pd().clear_bit());
} }
#[cfg(parl_io)] #[cfg(soc_has_parl_io)]
Peripheral::ParlIo => { Peripheral::ParlIo => {
system system
.parl_io_conf() .parl_io_conf()
.modify(|_, w| w.parl_clk_en().bit(enable)); .modify(|_, w| w.parl_clk_en().bit(enable));
} }
#[cfg(hmac)] #[cfg(soc_has_hmac)]
Peripheral::Hmac => { Peripheral::Hmac => {
system system
.hmac_conf() .hmac_conf()
.modify(|_, w| w.hmac_clk_en().bit(enable)); .modify(|_, w| w.hmac_clk_en().bit(enable));
} }
#[cfg(ecc)] #[cfg(soc_has_ecc)]
Peripheral::Ecc => { Peripheral::Ecc => {
system.ecc_conf().modify(|_, w| w.ecc_clk_en().bit(enable)); system.ecc_conf().modify(|_, w| w.ecc_clk_en().bit(enable));
} }
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
Peripheral::Etm => { Peripheral::Etm => {
system.etm_conf().modify(|_, w| w.etm_clk_en().bit(enable)); system.etm_conf().modify(|_, w| w.etm_clk_en().bit(enable));
} }
#[cfg(trace0)] #[cfg(soc_has_trace0)]
Peripheral::Trace0 => { Peripheral::Trace0 => {
system system
.trace_conf() .trace_conf()
.modify(|_, w| w.trace_clk_en().bit(enable)); .modify(|_, w| w.trace_clk_en().bit(enable));
} }
#[cfg(systimer)] #[cfg(soc_has_systimer)]
Peripheral::Systimer => { Peripheral::Systimer => {
system system
.systimer_conf() .systimer_conf()
@ -894,14 +894,14 @@ impl PeripheralClockControl {
let system = SYSTEM::regs(); let system = SYSTEM::regs();
match peripheral { match peripheral {
#[cfg(spi2)] #[cfg(soc_has_spi2)]
Peripheral::Spi2 => { Peripheral::Spi2 => {
system.spi2_conf().modify(|_, w| w.spi2_rst_en().set_bit()); system.spi2_conf().modify(|_, w| w.spi2_rst_en().set_bit());
system system
.spi2_conf() .spi2_conf()
.modify(|_, w| w.spi2_rst_en().clear_bit()); .modify(|_, w| w.spi2_rst_en().clear_bit());
} }
#[cfg(i2c0)] #[cfg(soc_has_i2c0)]
Peripheral::I2cExt0 => { Peripheral::I2cExt0 => {
#[cfg(any(esp32c6, esp32h2))] #[cfg(any(esp32c6, esp32h2))]
{ {
@ -911,7 +911,7 @@ impl PeripheralClockControl {
.modify(|_, w| w.i2c0_rst_en().clear_bit()); .modify(|_, w| w.i2c0_rst_en().clear_bit());
} }
} }
#[cfg(i2c1)] #[cfg(soc_has_i2c1)]
Peripheral::I2cExt1 => { Peripheral::I2cExt1 => {
#[cfg(esp32h2)] #[cfg(esp32h2)]
{ {
@ -921,29 +921,29 @@ impl PeripheralClockControl {
.modify(|_, w| w.i2c1_rst_en().clear_bit()); .modify(|_, w| w.i2c1_rst_en().clear_bit());
} }
} }
#[cfg(rmt)] #[cfg(soc_has_rmt)]
Peripheral::Rmt => { Peripheral::Rmt => {
system.rmt_conf().modify(|_, w| w.rmt_rst_en().set_bit()); system.rmt_conf().modify(|_, w| w.rmt_rst_en().set_bit());
system.rmt_conf().modify(|_, w| w.rmt_rst_en().clear_bit()); system.rmt_conf().modify(|_, w| w.rmt_rst_en().clear_bit());
} }
#[cfg(ledc)] #[cfg(soc_has_ledc)]
Peripheral::Ledc => { Peripheral::Ledc => {
system.ledc_conf().modify(|_, w| w.ledc_rst_en().set_bit()); system.ledc_conf().modify(|_, w| w.ledc_rst_en().set_bit());
system system
.ledc_conf() .ledc_conf()
.modify(|_, w| w.ledc_rst_en().clear_bit()); .modify(|_, w| w.ledc_rst_en().clear_bit());
} }
#[cfg(mcpwm0)] #[cfg(soc_has_mcpwm0)]
Peripheral::Mcpwm0 => { Peripheral::Mcpwm0 => {
system.pwm_conf().modify(|_, w| w.pwm_rst_en().set_bit()); system.pwm_conf().modify(|_, w| w.pwm_rst_en().set_bit());
system.pwm_conf().modify(|_, w| w.pwm_rst_en().clear_bit()); system.pwm_conf().modify(|_, w| w.pwm_rst_en().clear_bit());
} }
#[cfg(mcpwm1)] #[cfg(soc_has_mcpwm1)]
Peripheral::Mcpwm1 => { Peripheral::Mcpwm1 => {
system.pwm_conf.modify(|_, w| w.pwm_rst_en().set_bit()); system.pwm_conf.modify(|_, w| w.pwm_rst_en().set_bit());
system.pwm_conf.modify(|_, w| w.pwm_rst_en().clear_bit()); system.pwm_conf.modify(|_, w| w.pwm_rst_en().clear_bit());
} }
#[cfg(apb_saradc)] #[cfg(soc_has_apb_saradc)]
Peripheral::ApbSarAdc => { Peripheral::ApbSarAdc => {
system system
.saradc_conf() .saradc_conf()
@ -959,12 +959,12 @@ impl PeripheralClockControl {
.gdma_conf() .gdma_conf()
.modify(|_, w| w.gdma_rst_en().clear_bit()); .modify(|_, w| w.gdma_rst_en().clear_bit());
} }
#[cfg(i2s0)] #[cfg(soc_has_i2s0)]
Peripheral::I2s0 => { Peripheral::I2s0 => {
system.i2s_conf().modify(|_, w| w.i2s_rst_en().set_bit()); system.i2s_conf().modify(|_, w| w.i2s_rst_en().set_bit());
system.i2s_conf().modify(|_, w| w.i2s_rst_en().clear_bit()); system.i2s_conf().modify(|_, w| w.i2s_rst_en().clear_bit());
} }
#[cfg(twai0)] #[cfg(soc_has_twai0)]
Peripheral::Twai0 => { Peripheral::Twai0 => {
system system
.twai0_conf() .twai0_conf()
@ -973,7 +973,7 @@ impl PeripheralClockControl {
.twai0_conf() .twai0_conf()
.modify(|_, w| w.twai0_rst_en().clear_bit()); .modify(|_, w| w.twai0_rst_en().clear_bit());
} }
#[cfg(twai1)] #[cfg(soc_has_twai1)]
Peripheral::Twai1 => { Peripheral::Twai1 => {
system system
.twai1_conf() .twai1_conf()
@ -982,32 +982,32 @@ impl PeripheralClockControl {
.twai1_conf() .twai1_conf()
.modify(|_, w| w.twai1_rst_en().clear_bit()); .modify(|_, w| w.twai1_rst_en().clear_bit());
} }
#[cfg(aes)] #[cfg(soc_has_aes)]
Peripheral::Aes => { Peripheral::Aes => {
system.aes_conf().modify(|_, w| w.aes_rst_en().set_bit()); system.aes_conf().modify(|_, w| w.aes_rst_en().set_bit());
system.aes_conf().modify(|_, w| w.aes_rst_en().clear_bit()); system.aes_conf().modify(|_, w| w.aes_rst_en().clear_bit());
} }
#[cfg(pcnt)] #[cfg(soc_has_pcnt)]
Peripheral::Pcnt => { Peripheral::Pcnt => {
system.pcnt_conf().modify(|_, w| w.pcnt_rst_en().set_bit()); system.pcnt_conf().modify(|_, w| w.pcnt_rst_en().set_bit());
system system
.pcnt_conf() .pcnt_conf()
.modify(|_, w| w.pcnt_rst_en().clear_bit()); .modify(|_, w| w.pcnt_rst_en().clear_bit());
} }
#[cfg(timg0)] #[cfg(soc_has_timg0)]
Peripheral::Timg0 => { Peripheral::Timg0 => {
// no reset? // no reset?
} }
#[cfg(timg1)] #[cfg(soc_has_timg1)]
Peripheral::Timg1 => { Peripheral::Timg1 => {
// no reset? // no reset?
} }
#[cfg(sha)] #[cfg(soc_has_sha)]
Peripheral::Sha => { Peripheral::Sha => {
system.sha_conf().modify(|_, w| w.sha_rst_en().set_bit()); system.sha_conf().modify(|_, w| w.sha_rst_en().set_bit());
system.sha_conf().modify(|_, w| w.sha_rst_en().clear_bit()); system.sha_conf().modify(|_, w| w.sha_rst_en().clear_bit());
} }
#[cfg(usb_device)] #[cfg(soc_has_usb_device)]
Peripheral::UsbDevice => { Peripheral::UsbDevice => {
system system
.usb_device_conf() .usb_device_conf()
@ -1016,22 +1016,22 @@ impl PeripheralClockControl {
.usb_device_conf() .usb_device_conf()
.modify(|_, w| w.usb_device_rst_en().clear_bit()); .modify(|_, w| w.usb_device_rst_en().clear_bit());
} }
#[cfg(uart0)] #[cfg(soc_has_uart0)]
Peripheral::Uart0 => { Peripheral::Uart0 => {
system.uart(0).conf().modify(|_, w| w.rst_en().set_bit()); system.uart(0).conf().modify(|_, w| w.rst_en().set_bit());
system.uart(0).conf().modify(|_, w| w.rst_en().clear_bit()); system.uart(0).conf().modify(|_, w| w.rst_en().clear_bit());
} }
#[cfg(uart1)] #[cfg(soc_has_uart1)]
Peripheral::Uart1 => { Peripheral::Uart1 => {
system.uart(1).conf().modify(|_, w| w.rst_en().set_bit()); system.uart(1).conf().modify(|_, w| w.rst_en().set_bit());
system.uart(1).conf().modify(|_, w| w.rst_en().clear_bit()); system.uart(1).conf().modify(|_, w| w.rst_en().clear_bit());
} }
#[cfg(rsa)] #[cfg(soc_has_rsa)]
Peripheral::Rsa => { Peripheral::Rsa => {
system.rsa_conf().modify(|_, w| w.rsa_rst_en().set_bit()); system.rsa_conf().modify(|_, w| w.rsa_rst_en().set_bit());
system.rsa_conf().modify(|_, w| w.rsa_rst_en().clear_bit()); system.rsa_conf().modify(|_, w| w.rsa_rst_en().clear_bit());
} }
#[cfg(parl_io)] #[cfg(soc_has_parl_io)]
Peripheral::ParlIo => { Peripheral::ParlIo => {
system system
.parl_io_conf() .parl_io_conf()
@ -1040,24 +1040,24 @@ impl PeripheralClockControl {
.parl_io_conf() .parl_io_conf()
.modify(|_, w| w.parl_rst_en().clear_bit()); .modify(|_, w| w.parl_rst_en().clear_bit());
} }
#[cfg(hmac)] #[cfg(soc_has_hmac)]
Peripheral::Hmac => { Peripheral::Hmac => {
system.hmac_conf().modify(|_, w| w.hmac_rst_en().set_bit()); system.hmac_conf().modify(|_, w| w.hmac_rst_en().set_bit());
system system
.hmac_conf() .hmac_conf()
.modify(|_, w| w.hmac_rst_en().clear_bit()); .modify(|_, w| w.hmac_rst_en().clear_bit());
} }
#[cfg(ecc)] #[cfg(soc_has_ecc)]
Peripheral::Ecc => { Peripheral::Ecc => {
system.ecc_conf().modify(|_, w| w.ecc_rst_en().set_bit()); system.ecc_conf().modify(|_, w| w.ecc_rst_en().set_bit());
system.ecc_conf().modify(|_, w| w.ecc_rst_en().clear_bit()); system.ecc_conf().modify(|_, w| w.ecc_rst_en().clear_bit());
} }
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
Peripheral::Etm => { Peripheral::Etm => {
system.etm_conf().modify(|_, w| w.etm_rst_en().set_bit()); system.etm_conf().modify(|_, w| w.etm_rst_en().set_bit());
system.etm_conf().modify(|_, w| w.etm_rst_en().clear_bit()); system.etm_conf().modify(|_, w| w.etm_rst_en().clear_bit());
} }
#[cfg(trace0)] #[cfg(soc_has_trace0)]
Peripheral::Trace0 => { Peripheral::Trace0 => {
system system
.trace_conf() .trace_conf()
@ -1066,7 +1066,7 @@ impl PeripheralClockControl {
.trace_conf() .trace_conf()
.modify(|_, w| w.trace_rst_en().clear_bit()); .modify(|_, w| w.trace_rst_en().clear_bit());
} }
#[cfg(systimer)] #[cfg(soc_has_systimer)]
Peripheral::Systimer => { Peripheral::Systimer => {
system system
.systimer_conf() .systimer_conf()

View File

@ -99,7 +99,7 @@ impl<'d> SystemTimer<'d> {
// Don't reset Systimer as it will break `time::Instant::now`, only enable it // Don't reset Systimer as it will break `time::Instant::now`, only enable it
PeripheralClockControl::enable(PeripheralEnable::Systimer); PeripheralClockControl::enable(PeripheralEnable::Systimer);
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
etm::enable_etm(); etm::enable_etm();
Self { Self {
@ -661,7 +661,7 @@ mod asynch {
} }
} }
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
pub mod etm { pub mod etm {
//! # Event Task Matrix Function //! # Event Task Matrix Function
//! //!

View File

@ -895,7 +895,7 @@ mod asynch {
} }
/// Event Task Matrix /// Event Task Matrix
#[cfg(soc_etm)] #[cfg(soc_has_etm)]
pub mod etm { pub mod etm {
use super::*; use super::*;
use crate::etm::{EtmEvent, EtmTask}; use crate::etm::{EtmEvent, EtmTask};

View File

@ -1530,7 +1530,7 @@ impl PrivateInstance for crate::peripherals::TWAI0<'_> {
} }
} }
#[cfg(twai1)] #[cfg(soc_has_twai1)]
impl PrivateInstance for crate::peripherals::TWAI1<'_> { impl PrivateInstance for crate::peripherals::TWAI1<'_> {
fn number(&self) -> usize { fn number(&self) -> usize {
1 1
@ -1570,9 +1570,9 @@ impl PrivateInstance for crate::peripherals::TWAI1<'_> {
crate::any_peripheral! { crate::any_peripheral! {
/// Any TWAI peripheral. /// Any TWAI peripheral.
pub peripheral AnyTwai<'d> { pub peripheral AnyTwai<'d> {
#[cfg(twai0)] #[cfg(soc_has_twai0)]
Twai0(crate::peripherals::TWAI0<'d>), Twai0(crate::peripherals::TWAI0<'d>),
#[cfg(twai1)] #[cfg(soc_has_twai1)]
Twai1(crate::peripherals::TWAI1<'d>), Twai1(crate::peripherals::TWAI1<'d>),
} }
} }
@ -1580,9 +1580,9 @@ crate::any_peripheral! {
impl PrivateInstance for AnyTwai<'_> { impl PrivateInstance for AnyTwai<'_> {
delegate::delegate! { delegate::delegate! {
to match &self.0 { to match &self.0 {
#[cfg(twai0)] #[cfg(soc_has_twai0)]
AnyTwaiInner::Twai0(twai) => twai, AnyTwaiInner::Twai0(twai) => twai,
#[cfg(twai1)] #[cfg(soc_has_twai1)]
AnyTwaiInner::Twai1(twai) => twai, AnyTwaiInner::Twai1(twai) => twai,
} { } {
fn number(&self) -> usize; fn number(&self) -> usize;
@ -1600,8 +1600,9 @@ impl PrivateInstance for AnyTwai<'_> {
/// A peripheral singleton compatible with the TWAI driver. /// A peripheral singleton compatible with the TWAI driver.
pub trait Instance: PrivateInstance + IntoAnyTwai {} pub trait Instance: PrivateInstance + IntoAnyTwai {}
#[cfg(soc_has_twai0)]
impl Instance for crate::peripherals::TWAI0<'_> {} impl Instance for crate::peripherals::TWAI0<'_> {}
#[cfg(twai1)] #[cfg(soc_has_twai1)]
impl Instance for crate::peripherals::TWAI1<'_> {} impl Instance for crate::peripherals::TWAI1<'_> {}
impl Instance for AnyTwai<'_> {} impl Instance for AnyTwai<'_> {}
@ -1616,8 +1617,9 @@ mod asynch {
use procmacros::handler; use procmacros::handler;
use super::*; use super::*;
#[cfg(soc_has_twai0)]
use crate::peripherals::TWAI0; use crate::peripherals::TWAI0;
#[cfg(twai1)] #[cfg(soc_has_twai1)]
use crate::peripherals::TWAI1; use crate::peripherals::TWAI1;
pub struct TwaiAsyncState { pub struct TwaiAsyncState {
@ -1828,13 +1830,14 @@ mod asynch {
} }
} }
#[cfg(soc_has_twai0)]
#[handler] #[handler]
pub(super) fn twai0() { pub(super) fn twai0() {
let twai = unsafe { TWAI0::steal() }; let twai = unsafe { TWAI0::steal() };
handle_interrupt(twai.register_block(), twai.async_state()); handle_interrupt(twai.register_block(), twai.async_state());
} }
#[cfg(twai1)] #[cfg(soc_has_twai1)]
#[handler] #[handler]
pub(super) fn twai1() { pub(super) fn twai1() {
let twai = unsafe { TWAI1::steal() }; let twai = unsafe { TWAI1::steal() };

View File

@ -3,7 +3,7 @@
//! ## Overview //! ## Overview
//! //!
//! The UART is a hardware peripheral which handles communication using serial //! The UART is a hardware peripheral which handles communication using serial
//! communication interfaces, such as RS232 and RS485. This peripheral provides //! communication interfaces, such as RS232 and RS485. This peripheral provides!
//! a cheap and ubiquitous method for full- and half-duplex communication //! a cheap and ubiquitous method for full- and half-duplex communication
//! between devices. //! between devices.
//! //!
@ -149,14 +149,14 @@ impl embedded_io::Error for TxError {
#[instability::unstable] #[instability::unstable]
pub enum ClockSource { pub enum ClockSource {
/// APB_CLK clock source /// APB_CLK clock source
#[cfg_attr(not(any(esp32c6, esp32h2, lp_uart)), default)] #[cfg_attr(not(any(esp32c6, esp32h2, soc_has_lp_uart)), default)]
Apb, Apb,
/// RC_FAST_CLK clock source (17.5 MHz) /// RC_FAST_CLK clock source (17.5 MHz)
#[cfg(not(any(esp32, esp32s2)))] #[cfg(not(any(esp32, esp32s2)))]
RcFast, RcFast,
/// XTAL_CLK clock source /// XTAL_CLK clock source
#[cfg(not(any(esp32, esp32s2)))] #[cfg(not(any(esp32, esp32s2)))]
#[cfg_attr(any(esp32c6, esp32h2, lp_uart), default)] #[cfg_attr(any(esp32c6, esp32h2, soc_has_lp_uart), default)]
Xtal, Xtal,
/// REF_TICK clock source (derived from XTAL or RC_FAST, 1MHz) /// REF_TICK clock source (derived from XTAL or RC_FAST, 1MHz)
#[cfg(any(esp32, esp32s2))] #[cfg(any(esp32, esp32s2))]
@ -2201,7 +2201,7 @@ pub(super) fn intr_handler(uart: &Info, state: &State) {
} }
/// Low-power UART /// Low-power UART
#[cfg(lp_uart)] #[cfg(soc_has_lp_uart)]
#[instability::unstable] #[instability::unstable]
pub mod lp_uart { pub mod lp_uart {
use crate::{ use crate::{
@ -3257,19 +3257,21 @@ macro_rules! impl_instance {
}; };
} }
#[cfg(soc_has_uart0)]
impl_instance!(UART0, Uart0, U0TXD, U0RXD, U0CTS, U0RTS); impl_instance!(UART0, Uart0, U0TXD, U0RXD, U0CTS, U0RTS);
#[cfg(soc_has_uart1)]
impl_instance!(UART1, Uart1, U1TXD, U1RXD, U1CTS, U1RTS); impl_instance!(UART1, Uart1, U1TXD, U1RXD, U1CTS, U1RTS);
#[cfg(uart2)] #[cfg(soc_has_uart2)]
impl_instance!(UART2, Uart2, U2TXD, U2RXD, U2CTS, U2RTS); impl_instance!(UART2, Uart2, U2TXD, U2RXD, U2CTS, U2RTS);
crate::any_peripheral! { crate::any_peripheral! {
/// Any UART peripheral. /// Any UART peripheral.
pub peripheral AnyUart<'d> { pub peripheral AnyUart<'d> {
#[cfg(uart0)] #[cfg(soc_has_uart0)]
Uart0(crate::peripherals::UART0<'d>), Uart0(crate::peripherals::UART0<'d>),
#[cfg(uart1)] #[cfg(soc_has_uart1)]
Uart1(crate::peripherals::UART1<'d>), Uart1(crate::peripherals::UART1<'d>),
#[cfg(uart2)] #[cfg(soc_has_uart2)]
Uart2(crate::peripherals::UART2<'d>), Uart2(crate::peripherals::UART2<'d>),
} }
} }
@ -3278,11 +3280,11 @@ impl Instance for AnyUart<'_> {
#[inline] #[inline]
fn parts(&self) -> (&'static Info, &'static State) { fn parts(&self) -> (&'static Info, &'static State) {
match &self.0 { match &self.0 {
#[cfg(uart0)] #[cfg(soc_has_uart0)]
AnyUartInner::Uart0(uart) => uart.parts(), AnyUartInner::Uart0(uart) => uart.parts(),
#[cfg(uart1)] #[cfg(soc_has_uart1)]
AnyUartInner::Uart1(uart) => uart.parts(), AnyUartInner::Uart1(uart) => uart.parts(),
#[cfg(uart2)] #[cfg(soc_has_uart2)]
AnyUartInner::Uart2(uart) => uart.parts(), AnyUartInner::Uart2(uart) => uart.parts(),
} }
} }

View File

@ -60,7 +60,7 @@ peripherals = [
"rsa", "rsa",
"sha", "sha",
"slchost", "slchost",
"soc_etm", "etm",
"spi0", "spi0",
"spi1", "spi1",
"spi2", "spi2",

View File

@ -53,7 +53,7 @@ peripherals = [
"rng", "rng",
"rsa", "rsa",
"sha", "sha",
"soc_etm", "etm",
"spi0", "spi0",
"spi1", "spi1",
"spi2", "spi2",

View File

@ -457,7 +457,7 @@ driver_configs![
EtmProperties { EtmProperties {
driver: etm, driver: etm,
name: "ETM", name: "ETM",
peripherals: &["soc_etm"], peripherals: &["etm"],
properties: {} properties: {}
}, },
GpioProperties { GpioProperties {
@ -820,7 +820,12 @@ impl Config {
}, },
] ]
.into_iter() .into_iter()
.chain(self.device.peripherals.iter().cloned()) .chain(
self.device
.peripherals
.iter()
.map(|p| format!("soc_has_{p}")),
)
.chain(self.device.symbols.iter().cloned()) .chain(self.device.symbols.iter().cloned())
.chain( .chain(
self.device self.device