diff --git a/esp-hal/src/analog/adc/esp32.rs b/esp-hal/src/analog/adc/esp32.rs index 9f6f5f6d920..d7e90177a4b 100644 --- a/esp-hal/src/analog/adc/esp32.rs +++ b/esp-hal/src/analog/adc/esp32.rs @@ -249,7 +249,9 @@ impl RegisterAccess for ADC2 { /// Analog-to-Digital Converter peripheral driver. pub struct ADC<'d, ADC> { _adc: PeripheralRef<'d, ADC>, + #[allow(dead_code)] // FIXME attenuations: [Option; 10], + #[allow(dead_code)] // FIXME active_channel: Option, } @@ -418,6 +420,7 @@ macro_rules! impl_adc_interface { } mod adc_implementation { + #[cfg(feature = "embedded-hal-02")] use crate::peripherals::{ADC1, ADC2}; impl_adc_interface! { diff --git a/esp-hal/src/analog/adc/riscv.rs b/esp-hal/src/analog/adc/riscv.rs index 406b24a4471..599062ac010 100644 --- a/esp-hal/src/analog/adc/riscv.rs +++ b/esp-hal/src/analog/adc/riscv.rs @@ -486,7 +486,9 @@ impl CalibrationAccess for crate::peripherals::ADC2 { /// Analog-to-Digital Converter peripheral driver. pub struct ADC<'d, ADCI> { _adc: PeripheralRef<'d, ADCI>, + #[allow(dead_code)] // FIXME attenuations: [Option; NUM_ATTENS], + #[allow(dead_code)] // FIXME active_channel: Option, } @@ -648,6 +650,7 @@ macro_rules! impl_adc_interface { #[cfg(esp32c2)] mod adc_implementation { + #[cfg(feature = "embedded-hal-02")] use crate::peripherals::ADC1; impl_adc_interface! { @@ -663,6 +666,7 @@ mod adc_implementation { #[cfg(esp32c3)] mod adc_implementation { + #[cfg(feature = "embedded-hal-02")] use crate::peripherals::{ADC1, ADC2}; impl_adc_interface! { @@ -684,6 +688,7 @@ mod adc_implementation { #[cfg(esp32c6)] mod adc_implementation { + #[cfg(feature = "embedded-hal-02")] use crate::peripherals::ADC1; impl_adc_interface! { @@ -701,6 +706,7 @@ mod adc_implementation { #[cfg(esp32h2)] mod adc_implementation { + #[cfg(feature = "embedded-hal-02")] use crate::peripherals::ADC1; impl_adc_interface! { diff --git a/esp-hal/src/analog/adc/xtensa.rs b/esp-hal/src/analog/adc/xtensa.rs index 096fd1ac52f..c3ccb9b9655 100644 --- a/esp-hal/src/analog/adc/xtensa.rs +++ b/esp-hal/src/analog/adc/xtensa.rs @@ -524,7 +524,9 @@ impl CalibrationAccess for crate::peripherals::ADC2 { /// Analog-to-Digital Converter peripheral driver. pub struct ADC<'d, ADC> { _adc: PeripheralRef<'d, ADC>, + #[allow(dead_code)] // FIXME attenuations: [Option; 10], + #[allow(dead_code)] // FIXME active_channel: Option, } @@ -719,6 +721,7 @@ macro_rules! impl_adc_interface { } mod adc_implementation { + #[cfg(feature = "embedded-hal-02")] use crate::peripherals::{ADC1, ADC2}; impl_adc_interface! { diff --git a/esp-hal/src/i2c.rs b/esp-hal/src/i2c.rs index 6af5ab12ad2..43a8e5b259d 100644 --- a/esp-hal/src/i2c.rs +++ b/esp-hal/src/i2c.rs @@ -255,10 +255,10 @@ where self.peripheral.master_write_read(address, bytes, buffer) } - fn transaction<'a>( + fn transaction( &mut self, _address: u8, - _operations: &mut [embedded_hal::i2c::Operation<'a>], + _operations: &mut [embedded_hal::i2c::Operation<'_>], ) -> Result<(), Self::Error> { todo!() } diff --git a/esp-hal/src/rng.rs b/esp-hal/src/rng.rs index d3ee9cfc426..8ea996f4a7b 100644 --- a/esp-hal/src/rng.rs +++ b/esp-hal/src/rng.rs @@ -63,7 +63,9 @@ //! rng.read(&mut buffer).unwrap(); //! ``` -use core::{convert::Infallible, marker::PhantomData}; +#[cfg(feature = "embedded-hal-02")] +use core::convert::Infallible; +use core::marker::PhantomData; use crate::{peripheral::Peripheral, peripherals::RNG}; diff --git a/esp-hal/src/rtc_cntl/mod.rs b/esp-hal/src/rtc_cntl/mod.rs index b72a9387ab2..c813c0ed296 100644 --- a/esp-hal/src/rtc_cntl/mod.rs +++ b/esp-hal/src/rtc_cntl/mod.rs @@ -805,7 +805,7 @@ impl Rwdt { self.set_write_protection(true); } - fn set_timeout(&mut self, timeout: MicrosDurationU64) { + pub fn set_timeout(&mut self, timeout: MicrosDurationU64) { #[cfg(not(any(esp32c6, esp32h2)))] let rtc_cntl = unsafe { &*LPWR::PTR }; #[cfg(any(esp32c6, esp32h2))] diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 9941a72a2fb..6bf8beab8d1 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -1532,29 +1532,27 @@ pub mod dma { } fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - Ok( - if !crate::soc::is_valid_ram_address(&words[0] as *const _ as u32) { - for chunk in words.chunks(SIZE) { - self.buffer[..chunk.len()].copy_from_slice(chunk); - self.inner.write(&self.buffer[..chunk.len()])?; - } - } else { - self.inner.write(words)?; - }, - ) + if !crate::soc::is_valid_ram_address(&words[0] as *const _ as u32) { + for chunk in words.chunks(SIZE) { + self.buffer[..chunk.len()].copy_from_slice(chunk); + self.inner.write(&self.buffer[..chunk.len()])?; + } + } else { + self.inner.write(words)?; + } + Ok(()) } fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { - Ok( - if !crate::soc::is_valid_ram_address(&write[0] as *const _ as u32) { - for (read, write) in read.chunks_mut(SIZE).zip(write.chunks(SIZE)) { - self.buffer[..write.len()].copy_from_slice(write); - self.inner.transfer(read, &self.buffer[..write.len()])?; - } - } else { - self.inner.transfer(read, write)?; - }, - ) + if !crate::soc::is_valid_ram_address(&write[0] as *const _ as u32) { + for (read, write) in read.chunks_mut(SIZE).zip(write.chunks(SIZE)) { + self.buffer[..write.len()].copy_from_slice(write); + self.inner.transfer(read, &self.buffer[..write.len()])?; + } + } else { + self.inner.transfer(read, write)?; + } + Ok(()) } fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { @@ -1608,9 +1606,9 @@ mod ehal1 { fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { // Optimizations - if read.len() == 0 { + if read.is_empty() { SpiBus::write(self, write)?; - } else if write.len() == 0 { + } else if write.is_empty() { SpiBus::read(self, read)?; } diff --git a/esp-hal/src/timer.rs b/esp-hal/src/timer.rs index ad97998c5c9..a2a492779b3 100644 --- a/esp-hal/src/timer.rs +++ b/esp-hal/src/timer.rs @@ -40,6 +40,7 @@ use core::{ }; use fugit::{HertzU32, MicrosDurationU64}; +#[cfg(feature = "embedded-hal-02")] use void::Void; #[cfg(timg1)] @@ -221,6 +222,7 @@ where /// General-purpose Timer driver pub struct Timer { timg: T, + #[allow(dead_code)] // FIXME apb_clk_freq: HertzU32, } @@ -638,6 +640,7 @@ where } } +#[allow(dead_code)] // FIXME fn timeout_to_ticks(timeout: T, clock: F, divider: u32) -> u64 where T: Into, @@ -781,7 +784,7 @@ where .write(|w| unsafe { w.wdt_wkey().bits(0u32) }); } - fn feed(&mut self) { + pub fn feed(&mut self) { let reg_block = unsafe { &*TG::register_block() }; reg_block @@ -795,7 +798,7 @@ where .write(|w| unsafe { w.wdt_wkey().bits(0u32) }); } - fn set_timeout(&mut self, timeout: MicrosDurationU64) { + pub fn set_timeout(&mut self, timeout: MicrosDurationU64) { let timeout_raw = (timeout.to_nanos() * 10 / 125) as u32; let reg_block = unsafe { &*TG::register_block() };