] as ChannelTypes>::set_isr(super::asynch::interrupt::[< interrupt_handler_i2s $num >]);
Channel {
tx: ChannelTx::new(tx_impl, burst_mode),
@@ -854,7 +814,7 @@ impl PeripheralMarker for I2s1DmaSuitablePeripheral {}
impl I2sPeripheral for I2s1DmaSuitablePeripheral {}
impl I2s1Peripheral for I2s1DmaSuitablePeripheral {}
-#[cfg(esp32)]
+#[cfg(i2s1)]
ImplI2sChannel!(1, "I2S1");
/// DMA Peripheral
@@ -885,7 +845,7 @@ impl<'d> Dma<'d> {
spi2channel: Spi2DmaChannelCreator {},
spi3channel: Spi3DmaChannelCreator {},
i2s0channel: I2s0DmaChannelCreator {},
- #[cfg(esp32)]
+ #[cfg(i2s1)]
i2s1channel: I2s1DmaChannelCreator {},
}
}
diff --git a/esp-hal/src/gpio/mod.rs b/esp-hal/src/gpio/mod.rs
index 9168914dd..df03c5d67 100644
--- a/esp-hal/src/gpio/mod.rs
+++ b/esp-hal/src/gpio/mod.rs
@@ -91,12 +91,13 @@ pub mod rtc_io;
/// Convenience constant for `Option::None` pin
-static USER_INTERRUPT_HANDLER: CFnPtr = CFnPtr::NULL;
+static USER_INTERRUPT_HANDLER: CFnPtr = CFnPtr::new();
struct CFnPtr(AtomicPtr<()>);
impl CFnPtr {
- #[allow(clippy::declare_interior_mutable_const)]
- pub const NULL: Self = Self(AtomicPtr::new(core::ptr::null_mut()));
+ pub const fn new() -> Self {
+ Self(AtomicPtr::new(core::ptr::null_mut()))
+ }
pub fn store(&self, f: extern "C" fn()) {
self.0.store(f as *mut (), Ordering::Relaxed);
@@ -2488,9 +2489,8 @@ mod asynch {
use super::*;
- #[allow(clippy::declare_interior_mutable_const)]
- const NEW_AW: AtomicWaker = AtomicWaker::new();
- pub(super) static PIN_WAKERS: [AtomicWaker; NUM_PINS] = [NEW_AW; NUM_PINS];
+ pub(super) static PIN_WAKERS: [AtomicWaker; NUM_PINS] =
+ [const { AtomicWaker::new() }; NUM_PINS];
impl<'d, P> Flex<'d, P>
where
diff --git a/esp-hal/src/i2c.rs b/esp-hal/src/i2c.rs
index 647ad5432..2b157e92b 100644
--- a/esp-hal/src/i2c.rs
+++ b/esp-hal/src/i2c.rs
@@ -533,23 +533,14 @@ mod asynch {
task::{Context, Poll},
};
- use cfg_if::cfg_if;
use embassy_sync::waitqueue::AtomicWaker;
use embedded_hal::i2c::Operation;
use procmacros::handler;
use super::*;
- cfg_if! {
- if #[cfg(all(i2c0, i2c1))] {
- const NUM_I2C: usize = 2;
- } else if #[cfg(i2c0)] {
- const NUM_I2C: usize = 1;
- }
- }
- #[allow(clippy::declare_interior_mutable_const)]
- const INIT: AtomicWaker = AtomicWaker::new();
- static WAKERS: [AtomicWaker; NUM_I2C] = [INIT; NUM_I2C];
+ const NUM_I2C: usize = 1 + cfg!(i2c1) as usize;
+ static WAKERS: [AtomicWaker; NUM_I2C] = [const { AtomicWaker::new() }; NUM_I2C];
#[cfg_attr(esp32, allow(dead_code))]
pub(crate) enum Event {
diff --git a/esp-hal/src/i2s.rs b/esp-hal/src/i2s.rs
index 6693f5e5f..c7d212356 100644
--- a/esp-hal/src/i2s.rs
+++ b/esp-hal/src/i2s.rs
@@ -84,7 +84,7 @@ use core::marker::PhantomData;
use enumset::{EnumSet, EnumSetType};
use private::*;
-#[cfg(any(esp32, esp32s3))]
+#[cfg(i2s1)]
use crate::dma::I2s1Peripheral;
use crate::{
dma::{
@@ -469,7 +469,7 @@ where
/// Construct a new I2S peripheral driver instance for the second I2S
/// peripheral
#[allow(clippy::too_many_arguments)]
- #[cfg(any(esp32s3, esp32))]
+ #[cfg(i2s1)]
pub fn new_i2s1(
i2s: impl Peripheral + 'd,
standard: Standard,
diff --git a/esp-hal/src/peripheral.rs b/esp-hal/src/peripheral.rs
index 63cc578cf..5f11fdafc 100644
--- a/esp-hal/src/peripheral.rs
+++ b/esp-hal/src/peripheral.rs
@@ -188,11 +188,10 @@ mod peripheral_macros {
$crate::create_peripheral!($(#[$cfg])? $name <= $from_pac);
)*
-
$crate::impl_dma_eligible!(SPI2,Spi2);
#[cfg(any(pdma, esp32s3))]
$crate::impl_dma_eligible!(SPI3,Spi3);
- #[cfg(any(esp32c6, esp32h2))]
+ #[cfg(any(esp32c2, esp32c6, esp32h2))]
$crate::impl_dma_eligible!(MEM2MEM1,Mem2Mem1);
#[cfg(any(esp32c3, esp32c6, esp32h2, esp32s3))]
$crate::impl_dma_eligible!(UHCI0,Uhci0);
diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs
index fcd765c07..102b573ec 100644
--- a/esp-hal/src/rmt.rs
+++ b/esp-hal/src/rmt.rs
@@ -1124,9 +1124,7 @@ pub mod asynch {
#[cfg(not(any(esp32, esp32s3)))]
const NUM_CHANNELS: usize = 4;
- #[allow(clippy::declare_interior_mutable_const)]
- const INIT: AtomicWaker = AtomicWaker::new();
- static WAKER: [AtomicWaker; NUM_CHANNELS] = [INIT; NUM_CHANNELS];
+ static WAKER: [AtomicWaker; NUM_CHANNELS] = [const { AtomicWaker::new() }; NUM_CHANNELS];
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub(crate) struct RmtTxFuture
diff --git a/esp-hal/src/timer/systimer.rs b/esp-hal/src/timer/systimer.rs
index ed5f01fbb..6c2740434 100644
--- a/esp-hal/src/timer/systimer.rs
+++ b/esp-hal/src/timer/systimer.rs
@@ -1025,9 +1025,7 @@ mod asynch {
const NUM_ALARMS: usize = 3;
- #[allow(clippy::declare_interior_mutable_const)]
- const INIT: AtomicWaker = AtomicWaker::new();
- static WAKERS: [AtomicWaker; NUM_ALARMS] = [INIT; NUM_ALARMS];
+ static WAKERS: [AtomicWaker; NUM_ALARMS] = [const { AtomicWaker::new() }; NUM_ALARMS];
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub(crate) struct AlarmFuture<'a, COMP: Comparator, UNIT: Unit> {
diff --git a/esp-hal/src/touch.rs b/esp-hal/src/touch.rs
index 3005d2e29..be397dc10 100644
--- a/esp-hal/src/touch.rs
+++ b/esp-hal/src/touch.rs
@@ -536,9 +536,8 @@ mod asynch {
const NUM_TOUCH_PINS: usize = 10;
- #[allow(clippy::declare_interior_mutable_const)]
- const NEW_AW: AtomicWaker = AtomicWaker::new();
- static TOUCH_WAKERS: [AtomicWaker; NUM_TOUCH_PINS] = [NEW_AW; NUM_TOUCH_PINS];
+ static TOUCH_WAKERS: [AtomicWaker; NUM_TOUCH_PINS] =
+ [const { AtomicWaker::new() }; NUM_TOUCH_PINS];
// Helper variable to store which pins need handling.
static TOUCHED_PINS: AtomicU16 = AtomicU16::new(0);
diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs
index c01737382..f0e06ecda 100644
--- a/esp-hal/src/twai/mod.rs
+++ b/esp-hal/src/twai/mod.rs
@@ -1671,9 +1671,8 @@ mod asynch {
}
const NUM_TWAI: usize = 1 + cfg!(twai1) as usize;
- #[allow(clippy::declare_interior_mutable_const)]
- const NEW_STATE: TwaiAsyncState = TwaiAsyncState::new();
- pub(crate) static TWAI_STATE: [TwaiAsyncState; NUM_TWAI] = [NEW_STATE; NUM_TWAI];
+ pub(crate) static TWAI_STATE: [TwaiAsyncState; NUM_TWAI] =
+ [const { TwaiAsyncState::new() }; NUM_TWAI];
impl Twai<'_, T, crate::Async>
where
diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs
index 8461e561d..35134be4e 100644
--- a/esp-hal/src/uart.rs
+++ b/esp-hal/src/uart.rs
@@ -1849,7 +1849,6 @@ where
mod asynch {
use core::task::Poll;
- use cfg_if::cfg_if;
use embassy_sync::waitqueue::AtomicWaker;
use enumset::{EnumSet, EnumSetType};
use procmacros::handler;
@@ -1857,20 +1856,10 @@ mod asynch {
use super::*;
use crate::Async;
- cfg_if! {
- if #[cfg(all(uart0, uart1, uart2))] {
- const NUM_UART: usize = 3;
- } else if #[cfg(all(uart0, uart1))] {
- const NUM_UART: usize = 2;
- } else if #[cfg(uart0)] {
- const NUM_UART: usize = 1;
- }
- }
+ const NUM_UART: usize = 1 + cfg!(uart1) as usize + cfg!(uart2) as usize;
- #[allow(clippy::declare_interior_mutable_const)]
- const INIT: AtomicWaker = AtomicWaker::new();
- static TX_WAKERS: [AtomicWaker; NUM_UART] = [INIT; NUM_UART];
- static RX_WAKERS: [AtomicWaker; NUM_UART] = [INIT; NUM_UART];
+ static TX_WAKERS: [AtomicWaker; NUM_UART] = [const { AtomicWaker::new() }; NUM_UART];
+ static RX_WAKERS: [AtomicWaker; NUM_UART] = [const { AtomicWaker::new() }; NUM_UART];
#[derive(EnumSetType, Debug)]
pub(crate) enum TxEvent {
diff --git a/hil-test/tests/dma_macros.rs b/hil-test/tests/dma_macros.rs
index f07073034..e3c9502ef 100644
--- a/hil-test/tests/dma_macros.rs
+++ b/hil-test/tests/dma_macros.rs
@@ -1,6 +1,6 @@
-//! DMA Mem2Mem Tests
+//! DMA macro tests
-//% CHIPS: esp32s3 esp32c2 esp32c3 esp32c6 esp32h2
+//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
#![no_std]
#![no_main]
diff --git a/hil-test/tests/dma_mem2mem.rs b/hil-test/tests/dma_mem2mem.rs
index 86d46037b..656e89bfb 100644
--- a/hil-test/tests/dma_mem2mem.rs
+++ b/hil-test/tests/dma_mem2mem.rs
@@ -1,12 +1,12 @@
//! DMA Mem2Mem Tests
-//% CHIPS: esp32s3 esp32c2 esp32c3 esp32c6 esp32h2
+//% CHIPS: esp32c2 esp32c3 esp32c6 esp32h2 esp32s3
#![no_std]
#![no_main]
use esp_hal::{
- dma::{Channel, Dma, DmaChannel0, DmaError, DmaPriority, Mem2Mem},
+ dma::{Channel, Dma, DmaError, DmaPriority, Mem2Mem},
dma_buffers,
dma_buffers_chunk_size,
dma_descriptors,
@@ -17,13 +17,15 @@ use hil_test as _;
const DATA_SIZE: usize = 1024 * 10;
cfg_if::cfg_if! {
- if #[cfg(any(feature = "esp32c2", feature = "esp32c3", feature = "esp32s3"))] {
- type DmaPeripheralType = esp_hal::peripherals::SPI2;
- } else {
+ if #[cfg(any(esp32c2, esp32c6, esp32h2))] {
type DmaPeripheralType = esp_hal::peripherals::MEM2MEM1;
+ } else {
+ type DmaPeripheralType = esp_hal::peripherals::SPI2;
}
}
+use esp_hal::dma::DmaChannel0;
+
struct Context {
channel: Channel<'static, DmaChannel0, Blocking>,
dma_peripheral: DmaPeripheralType,
@@ -41,18 +43,18 @@ mod tests {
let peripherals = esp_hal::init(esp_hal::Config::default());
let dma = Dma::new(peripherals.DMA);
- let channel = dma.channel0.configure(false, DmaPriority::Priority0);
+ let dma_channel = dma.channel0;
cfg_if::cfg_if! {
- if #[cfg(any(feature = "esp32c2", feature = "esp32c3", feature = "esp32s3"))] {
- let dma_peripheral = peripherals.SPI2;
- } else {
+ if #[cfg(any(esp32c2, esp32c6, esp32h2))] {
let dma_peripheral = peripherals.MEM2MEM1;
+ } else {
+ let dma_peripheral = peripherals.SPI2;
}
}
Context {
- channel,
+ channel: dma_channel.configure(false, DmaPriority::Priority0),
dma_peripheral,
}
}
diff --git a/hil-test/tests/spi_half_duplex_read.rs b/hil-test/tests/spi_half_duplex_read.rs
index 90413adcb..22fbc6848 100644
--- a/hil-test/tests/spi_half_duplex_read.rs
+++ b/hil-test/tests/spi_half_duplex_read.rs
@@ -22,10 +22,7 @@ use esp_hal::{
use hil_test as _;
cfg_if::cfg_if! {
- if #[cfg(any(
- feature = "esp32",
- feature = "esp32s2",
- ))] {
+ if #[cfg(any(esp32, esp32s2))] {
use esp_hal::dma::Spi2DmaChannel as DmaChannel0;
} else {
use esp_hal::dma::DmaChannel0;