From 27425aa4f8befb79ff21f339b4a157b95c2d16af Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Fri, 1 Mar 2024 08:49:35 -0800 Subject: [PATCH 1/4] Create an `embedded-hal-02` feature and gate implementations, rename `eh1` to `embedded-hal` --- esp-hal/Cargo.toml | 20 ++++---- esp-hal/src/analog/adc/esp32.rs | 15 +++--- esp-hal/src/analog/adc/riscv.rs | 15 +++--- esp-hal/src/analog/adc/xtensa.rs | 15 +++--- esp-hal/src/delay.rs | 25 +++++++--- esp-hal/src/gpio.rs | 79 ++++++++++++++++++-------------- esp-hal/src/i2c.rs | 29 ++++++------ esp-hal/src/ledc/channel.rs | 4 +- esp-hal/src/mcpwm/operator.rs | 11 +++-- esp-hal/src/prelude.rs | 9 ---- esp-hal/src/rng.rs | 5 +- esp-hal/src/rtc_cntl/mod.rs | 21 +++++---- esp-hal/src/spi/master.rs | 58 +++++++++++++---------- esp-hal/src/spi/mod.rs | 8 ++-- esp-hal/src/timer.rs | 22 +++++---- esp-hal/src/twai/filter.rs | 6 +-- esp-hal/src/twai/mod.rs | 8 ++-- esp-hal/src/uart.rs | 34 ++++++++------ esp-hal/src/usb_serial_jtag.rs | 32 +++++++------ 19 files changed, 233 insertions(+), 183 deletions(-) diff --git a/esp-hal/Cargo.toml b/esp-hal/Cargo.toml index 5077a083295..ed2724bd890 100644 --- a/esp-hal/Cargo.toml +++ b/esp-hal/Cargo.toml @@ -27,8 +27,8 @@ embassy-sync = { version = "0.5.0", optional = true } embassy-time-driver = { version = "0.1.0", optional = true } embedded-can = { version = "0.4.1", optional = true } embedded-dma = "0.2.0" -embedded-hal = { version = "0.2.7", features = ["unproven"] } -embedded-hal-1 = { version = "1.0.0", optional = true, package = "embedded-hal" } +embedded-hal-02 = { version = "0.2.7", optional = true, features = ["unproven"], package = "embedded-hal" } +embedded-hal = { version = "1.0.0", optional = true } embedded-hal-async = { version = "1.0.0", optional = true } embedded-hal-nb = { version = "1.0.0", optional = true } embedded-io = { version = "0.6.1", optional = true } @@ -74,7 +74,7 @@ esp-metadata = { version = "0.1.0", path = "../esp-metadata" } serde = { version = "1.0.197", features = ["derive"] } [features] -default = ["rt", "vectored"] +default = ["embedded-hal-02", "rt", "vectored"] riscv = ["dep:riscv", "critical-section/restore-state-u8", "esp-riscv-rt?/zero-bss"] xtensa = ["dep:xtensa-lx", "critical-section/restore-state-u32"] @@ -151,8 +151,8 @@ rv-init-rtc-data = ["esp-riscv-rt?/init-rtc-fast-data", "esp-riscv-rt?/init-rtc- ## Enable support for asynchronous operation, with interfaces provided by ## `embedded-hal-async` and `embedded-io-async`. async = [ + "embedded-hal", "embedded-hal-async", - "eh1", "embassy-sync", "embassy-futures", "embedded-io", @@ -164,13 +164,15 @@ defmt = [ "embassy-executor?/defmt", "embassy-futures?/defmt", "embassy-sync?/defmt", - "embedded-hal-1?/defmt-03", + "embedded-hal?/defmt-03", "embedded-io/defmt-03", "embedded-io-async?/defmt-03", ] +## Implement the traits defined in the `0.2.x` release of `embedded-hal`. +embedded-hal-02 = ["dep:embedded-hal-02"] ## Implement the traits defined in the `1.0.0` releases of `embedded-hal` and ## `embedded-hal-nb` for the relevant peripherals. -eh1 = ["embedded-hal-1", "embedded-hal-nb", "embedded-can"] +embedded-hal = ["dep:embedded-hal", "dep:embedded-hal-nb", "dep:embedded-can"] ## Implement the traits defined in `embedded-io` for certain peripherals. embedded-io = ["dep:embedded-io"] ## Implement the `ufmt_write::uWrite` trait for certain peripherals. @@ -211,11 +213,11 @@ psram-80mhz = [] #! ### Octal RAM Feature Flags ## Use externally connected Octal RAM (2MB). -opsram-2m = [] +opsram-2m = [] ## Use externally connected Octal RAM (4MB). -opsram-4m = [] +opsram-4m = [] ## Use externally connected Octal RAM (8MB). -opsram-8m = [] +opsram-8m = [] ## Use externally connected Octal RAM (16MB). opsram-16m = [] diff --git a/esp-hal/src/analog/adc/esp32.rs b/esp-hal/src/analog/adc/esp32.rs index 56d01119b44..9f6f5f6d920 100644 --- a/esp-hal/src/analog/adc/esp32.rs +++ b/esp-hal/src/analog/adc/esp32.rs @@ -21,9 +21,10 @@ pub struct AdcPin { _phantom: PhantomData, } -impl embedded_hal::adc::Channel for AdcPin +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::adc::Channel for AdcPin where - PIN: embedded_hal::adc::Channel, + PIN: embedded_hal_02::adc::Channel, { type ID = u8; @@ -346,15 +347,16 @@ impl<'d, ADC1> ADC<'d, ADC1> { } } -impl<'d, ADCI, PIN> embedded_hal::adc::OneShot> for ADC<'d, ADCI> +#[cfg(feature = "embedded-hal-02")] +impl<'d, ADCI, PIN> embedded_hal_02::adc::OneShot> for ADC<'d, ADCI> where - PIN: embedded_hal::adc::Channel, + PIN: embedded_hal_02::adc::Channel, ADCI: RegisterAccess, { type Error = (); fn read(&mut self, _pin: &mut AdcPin) -> nb::Result { - use embedded_hal::adc::Channel; + use embedded_hal_02::adc::Channel; if self.attenuations[AdcPin::::channel() as usize].is_none() { panic!( @@ -405,7 +407,8 @@ macro_rules! impl_adc_interface { const CHANNEL: u8 = $channel; } - impl embedded_hal::adc::Channel<$adc> for crate::gpio::$pin { + #[cfg(feature = "embedded-hal-02")] + impl embedded_hal_02::adc::Channel<$adc> for crate::gpio::$pin { type ID = u8; fn channel() -> u8 { $channel } diff --git a/esp-hal/src/analog/adc/riscv.rs b/esp-hal/src/analog/adc/riscv.rs index 7aa260b4f29..5686731900d 100644 --- a/esp-hal/src/analog/adc/riscv.rs +++ b/esp-hal/src/analog/adc/riscv.rs @@ -117,9 +117,10 @@ pub struct AdcPin { _phantom: PhantomData, } -impl embedded_hal::adc::Channel for AdcPin +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::adc::Channel for AdcPin where - PIN: embedded_hal::adc::Channel, + PIN: embedded_hal_02::adc::Channel, { type ID = u8; @@ -548,17 +549,18 @@ impl AdcCalEfuse for crate::peripherals::ADC2 { } } -impl<'d, ADCI, PIN, CS> embedded_hal::adc::OneShot> +#[cfg(feature = "embedded-hal-02")] +impl<'d, ADCI, PIN, CS> embedded_hal_02::adc::OneShot> for ADC<'d, ADCI> where - PIN: embedded_hal::adc::Channel, + PIN: embedded_hal_02::adc::Channel, ADCI: RegisterAccess, CS: AdcCalScheme, { type Error = (); fn read(&mut self, pin: &mut AdcPin) -> nb::Result { - use embedded_hal::adc::Channel; + use embedded_hal_02::adc::Channel; if self.attenuations[AdcPin::::channel() as usize].is_none() { panic!( @@ -639,7 +641,8 @@ macro_rules! impl_adc_interface { const CHANNEL: u8 = $channel; } - impl embedded_hal::adc::Channel<$adc> for crate::gpio::$pin { + #[cfg(feature = "embedded-hal-02")] + impl embedded_hal_02::adc::Channel<$adc> for crate::gpio::$pin { type ID = u8; fn channel() -> u8 { $channel } diff --git a/esp-hal/src/analog/adc/xtensa.rs b/esp-hal/src/analog/adc/xtensa.rs index 3d2df240d53..096fd1ac52f 100644 --- a/esp-hal/src/analog/adc/xtensa.rs +++ b/esp-hal/src/analog/adc/xtensa.rs @@ -86,9 +86,10 @@ pub struct AdcPin { _phantom: PhantomData, } -impl embedded_hal::adc::Channel for AdcPin +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::adc::Channel for AdcPin where - PIN: embedded_hal::adc::Channel, + PIN: embedded_hal_02::adc::Channel, { type ID = u8; @@ -637,17 +638,18 @@ impl AdcCalEfuse for crate::peripherals::ADC2 { } } -impl<'d, ADCI, PIN, CS> embedded_hal::adc::OneShot> +#[cfg(feature = "embedded-hal-02")] +impl<'d, ADCI, PIN, CS> embedded_hal_02::adc::OneShot> for ADC<'d, ADCI> where - PIN: embedded_hal::adc::Channel, + PIN: embedded_hal_02::adc::Channel, ADCI: RegisterAccess, CS: AdcCalScheme, { type Error = (); fn read(&mut self, pin: &mut AdcPin) -> nb::Result { - use embedded_hal::adc::Channel; + use embedded_hal_02::adc::Channel; if self.attenuations[AdcPin::::channel() as usize].is_none() { panic!( @@ -706,7 +708,8 @@ macro_rules! impl_adc_interface { const CHANNEL: u8 = $channel; } - impl embedded_hal::adc::Channel<$adc> for crate::gpio::$pin { + #[cfg(feature = "embedded-hal-02")] + impl embedded_hal_02::adc::Channel<$adc> for crate::gpio::$pin { type ID = u8; fn channel() -> u8 { $channel } diff --git a/esp-hal/src/delay.rs b/esp-hal/src/delay.rs index ebbd7a464f4..6b77ebf0d73 100644 --- a/esp-hal/src/delay.rs +++ b/esp-hal/src/delay.rs @@ -18,9 +18,9 @@ //! delay.delay_ms(1000 as u32); //! ``` //! -//! [DelayMs]: embedded_hal::blocking::delay::DelayMs -//! [DelayUs]: embedded_hal::blocking::delay::DelayUs -//! [embedded-hal]: https://docs.rs/embedded-hal/latest/embedded_hal/ +//! [DelayMs]: embedded_hal_02::blocking::delay::DelayMs +//! [DelayUs]: embedded_hal_02::blocking::delay::DelayUs +//! [embedded-hal]: https://docs.rs/embedded-hal/0.2.7/embedded_hal/index.html use fugit::HertzU64; @@ -33,7 +33,17 @@ pub struct Delay { freq: HertzU64, } -impl embedded_hal::blocking::delay::DelayMs for Delay +impl Delay { + /// Delay for the specified number of milliseconds + pub fn delay_millis(&self, ms: u32) { + for _ in 0..ms { + self.delay_micros(1000u32); + } + } +} + +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::delay::DelayMs for Delay where T: Into, { @@ -44,7 +54,8 @@ where } } -impl embedded_hal::blocking::delay::DelayUs for Delay +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::delay::DelayUs for Delay where T: Into, { @@ -53,8 +64,8 @@ where } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::delay::DelayNs for Delay { +#[cfg(feature = "embedded-hal")] +impl embedded_hal::delay::DelayNs for Delay { fn delay_ns(&mut self, ns: u32) { self.delay_nanos(ns); } diff --git a/esp-hal/src/gpio.rs b/esp-hal/src/gpio.rs index 04ee1e6b346..41c04026562 100644 --- a/esp-hal/src/gpio.rs +++ b/esp-hal/src/gpio.rs @@ -541,7 +541,9 @@ pub struct GpioPin { _mode: PhantomData, } -impl embedded_hal::digital::v2::InputPin for GpioPin, GPIONUM> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::InputPin + for GpioPin, GPIONUM> where Self: GpioProperties, { @@ -554,7 +556,9 @@ where } } -impl embedded_hal::digital::v2::InputPin for GpioPin, GPIONUM> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::InputPin + for GpioPin, GPIONUM> where Self: GpioProperties, { @@ -567,16 +571,16 @@ where } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::ErrorType for GpioPin, GPIONUM> +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::ErrorType for GpioPin, GPIONUM> where Self: GpioProperties, { type Error = Infallible; } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::InputPin for GpioPin, GPIONUM> +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::InputPin for GpioPin, GPIONUM> where Self: GpioProperties, { @@ -588,8 +592,8 @@ where } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::InputPin for GpioPin, GPIONUM> +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::InputPin for GpioPin, GPIONUM> where Self: GpioProperties, ::PinType: IsOutputPin, @@ -865,7 +869,8 @@ where } } -impl embedded_hal::digital::v2::OutputPin +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::OutputPin for GpioPin, GPIONUM> where Self: GpioProperties, @@ -882,7 +887,8 @@ where } } -impl embedded_hal::digital::v2::StatefulOutputPin +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::StatefulOutputPin for GpioPin, GPIONUM> where Self: GpioProperties, @@ -896,7 +902,8 @@ where } } -impl embedded_hal::digital::v2::ToggleableOutputPin +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::ToggleableOutputPin for GpioPin, GPIONUM> where Self: GpioProperties, @@ -904,7 +911,7 @@ where { type Error = Infallible; fn toggle(&mut self) -> Result<(), Self::Error> { - use embedded_hal::digital::v2::{OutputPin as _, StatefulOutputPin as _}; + use embedded_hal_02::digital::v2::{OutputPin as _, StatefulOutputPin as _}; if self.is_set_high()? { Ok(self.set_low()?) } else { @@ -913,8 +920,8 @@ where } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::ErrorType for GpioPin, GPIONUM> +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::ErrorType for GpioPin, GPIONUM> where Self: GpioProperties, ::PinType: IsOutputPin, @@ -922,8 +929,8 @@ where type Error = Infallible; } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::OutputPin for GpioPin, GPIONUM> +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::OutputPin for GpioPin, GPIONUM> where Self: GpioProperties, ::PinType: IsOutputPin, @@ -938,8 +945,8 @@ where } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::StatefulOutputPin +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::StatefulOutputPin for GpioPin, GPIONUM> where Self: GpioProperties, @@ -1719,7 +1726,8 @@ where } } -impl embedded_hal::digital::v2::InputPin for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::InputPin for AnyPin, TYPE> { type Error = core::convert::Infallible; fn is_high(&self) -> Result { @@ -1733,13 +1741,13 @@ impl embedded_hal::digital::v2::InputPin for AnyPin, TYP } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::ErrorType for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::ErrorType for AnyPin, TYPE> { type Error = Infallible; } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::InputPin for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::InputPin for AnyPin, TYPE> { fn is_high(&mut self) -> Result { let inner = &mut self.inner; handle_gpio_input!(inner, target, { target.is_high() }) @@ -1751,7 +1759,8 @@ impl embedded_hal_1::digital::InputPin for AnyPin, TYPE> } } -impl embedded_hal::digital::v2::OutputPin for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::OutputPin for AnyPin, TYPE> { type Error = Infallible; fn set_low(&mut self) -> Result<(), Self::Error> { @@ -1765,7 +1774,8 @@ impl embedded_hal::digital::v2::OutputPin for AnyPin, T } } -impl embedded_hal::digital::v2::StatefulOutputPin for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::StatefulOutputPin for AnyPin, TYPE> { fn is_set_high(&self) -> Result { let inner = &self.inner; handle_gpio_output!(inner, target, { target.is_set_high() }) @@ -1777,7 +1787,8 @@ impl embedded_hal::digital::v2::StatefulOutputPin for AnyPin embedded_hal::digital::v2::ToggleableOutputPin for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::digital::v2::ToggleableOutputPin for AnyPin, TYPE> { type Error = Infallible; fn toggle(&mut self) -> Result<(), Self::Error> { @@ -1786,13 +1797,13 @@ impl embedded_hal::digital::v2::ToggleableOutputPin for AnyPin embedded_hal_1::digital::ErrorType for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::ErrorType for AnyPin, TYPE> { type Error = Infallible; } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::OutputPin for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::OutputPin for AnyPin, TYPE> { fn set_low(&mut self) -> Result<(), Self::Error> { let inner = &mut self.inner; handle_gpio_output!(inner, target, { target.set_low() }) @@ -1804,8 +1815,8 @@ impl embedded_hal_1::digital::OutputPin for AnyPin, TYP } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::digital::StatefulOutputPin for AnyPin, TYPE> { +#[cfg(feature = "embedded-hal")] +impl embedded_hal::digital::StatefulOutputPin for AnyPin, TYPE> { fn is_set_high(&mut self) -> Result { let inner = &mut self.inner; handle_gpio_output!(inner, target, { target.is_set_high() }) @@ -3139,7 +3150,7 @@ mod asynch { impl<'a, P> PinFuture<'a, P> where - P: crate::gpio::Pin + embedded_hal_1::digital::ErrorType, + P: crate::gpio::Pin + embedded_hal::digital::ErrorType, { pub fn new(pin: &'a mut P, event: Event) -> Self { pin.listen(event); @@ -3149,7 +3160,7 @@ mod asynch { impl<'a, P> core::future::Future for PinFuture<'a, P> where - P: crate::gpio::Pin + embedded_hal_1::digital::ErrorType, + P: crate::gpio::Pin + embedded_hal::digital::ErrorType, { type Output = Result<(), P::Error>; diff --git a/esp-hal/src/i2c.rs b/esp-hal/src/i2c.rs index 22d512c2024..6af5ab12ad2 100644 --- a/esp-hal/src/i2c.rs +++ b/esp-hal/src/i2c.rs @@ -62,10 +62,10 @@ pub enum Error { CommandNrExceeded, } -#[cfg(feature = "eh1")] -impl embedded_hal_1::i2c::Error for Error { - fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { - use embedded_hal_1::i2c::ErrorKind; +#[cfg(feature = "embedded-hal")] +impl embedded_hal::i2c::Error for Error { + fn kind(&self) -> embedded_hal::i2c::ErrorKind { + use embedded_hal::i2c::ErrorKind; match self { Self::ExceedingFifo => ErrorKind::Overrun, @@ -187,7 +187,8 @@ pub struct I2C<'d, T> { peripheral: PeripheralRef<'d, T>, } -impl embedded_hal::blocking::i2c::Read for I2C<'_, T> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::i2c::Read for I2C<'_, T> where T: Instance, { @@ -198,7 +199,8 @@ where } } -impl embedded_hal::blocking::i2c::Write for I2C<'_, T> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::i2c::Write for I2C<'_, T> where T: Instance, { @@ -209,7 +211,8 @@ where } } -impl embedded_hal::blocking::i2c::WriteRead for I2C<'_, T> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::i2c::WriteRead for I2C<'_, T> where T: Instance, { @@ -225,13 +228,13 @@ where } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::i2c::ErrorType for I2C<'_, T> { +#[cfg(feature = "embedded-hal")] +impl embedded_hal::i2c::ErrorType for I2C<'_, T> { type Error = Error; } -#[cfg(feature = "eh1")] -impl embedded_hal_1::i2c::I2c for I2C<'_, T> +#[cfg(feature = "embedded-hal")] +impl embedded_hal::i2c::I2c for I2C<'_, T> where T: Instance, { @@ -255,7 +258,7 @@ where fn transaction<'a>( &mut self, _address: u8, - _operations: &mut [embedded_hal_1::i2c::Operation<'a>], + _operations: &mut [embedded_hal::i2c::Operation<'a>], ) -> Result<(), Self::Error> { todo!() } @@ -337,7 +340,7 @@ mod asynch { use cfg_if::cfg_if; use embassy_futures::select::select; use embassy_sync::waitqueue::AtomicWaker; - use embedded_hal_1::i2c::Operation; + use embedded_hal::i2c::Operation; use procmacros::interrupt; use super::*; diff --git a/esp-hal/src/ledc/channel.rs b/esp-hal/src/ledc/channel.rs index da5f1d31a72..717a3148374 100644 --- a/esp-hal/src/ledc/channel.rs +++ b/esp-hal/src/ledc/channel.rs @@ -285,9 +285,9 @@ where } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] mod ehal1 { - use embedded_hal_1::pwm::{self, ErrorKind, ErrorType, SetDutyCycle}; + use embedded_hal::pwm::{self, ErrorKind, ErrorType, SetDutyCycle}; use super::{Channel, ChannelHW, ChannelIFace, Error}; use crate::{gpio::OutputPin, ledc::timer::TimerSpeed}; diff --git a/esp-hal/src/mcpwm/operator.rs b/esp-hal/src/mcpwm/operator.rs index bf7a5336d3a..b87084a2bde 100644 --- a/esp-hal/src/mcpwm/operator.rs +++ b/esp-hal/src/mcpwm/operator.rs @@ -638,7 +638,8 @@ impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> } } -impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> embedded_hal::PwmPin +#[cfg(feature = "embedded-hal-02")] +impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> embedded_hal_02::PwmPin for PwmPin<'d, Pin, PWM, OP, IS_A> { type Duty = u16; @@ -672,17 +673,17 @@ impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> emb } /// Implement no error type for the PwmPin because the method are infallible -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> - embedded_hal_1::pwm::ErrorType for PwmPin<'d, Pin, PWM, OP, IS_A> + embedded_hal::pwm::ErrorType for PwmPin<'d, Pin, PWM, OP, IS_A> { type Error = core::convert::Infallible; } /// Implement the trait SetDutyCycle for PwmPin -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> - embedded_hal_1::pwm::SetDutyCycle for PwmPin<'d, Pin, PWM, OP, IS_A> + embedded_hal::pwm::SetDutyCycle for PwmPin<'d, Pin, PWM, OP, IS_A> { /// Get the max duty of the PwmPin fn max_duty_cycle(&self) -> u16 { diff --git a/esp-hal/src/prelude.rs b/esp-hal/src/prelude.rs index 359a78b9cdf..17111942448 100644 --- a/esp-hal/src/prelude.rs +++ b/esp-hal/src/prelude.rs @@ -10,15 +10,6 @@ pub use embedded_dma::{ WriteBuffer as _embedded_dma_WriteBuffer, WriteTarget as _embedded_dma_WriteTarget, }; -pub use embedded_hal::{ - digital::v2::{ - InputPin as _embedded_hal_digital_v2_InputPin, - OutputPin as _embedded_hal_digital_v2_OutputPin, - StatefulOutputPin as _embedded_hal_digital_v2_StatefulOutputPin, - ToggleableOutputPin as _embedded_hal_digital_v2_ToggleableOutputPin, - }, - prelude::*, -}; pub use fugit::{ ExtU32 as _fugit_ExtU32, ExtU64 as _fugit_ExtU64, diff --git a/esp-hal/src/rng.rs b/esp-hal/src/rng.rs index 92757001c69..d3ee9cfc426 100644 --- a/esp-hal/src/rng.rs +++ b/esp-hal/src/rng.rs @@ -16,7 +16,7 @@ //! method, which returns a 32-bit unsigned integer. //! //! Additionally, this driver implements the -//! [Read](embedded_hal::blocking::rng::Read) trait from the `embedded_hal` +//! [Read](embedded_hal_02::blocking::rng::Read) trait from the `embedded_hal` //! crate, allowing you to generate random bytes by calling the `read` method. // //! # Important Note @@ -95,7 +95,8 @@ impl Rng { } } -impl embedded_hal::blocking::rng::Read for Rng { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::rng::Read for Rng { type Error = Infallible; fn read(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error> { diff --git a/esp-hal/src/rtc_cntl/mod.rs b/esp-hal/src/rtc_cntl/mod.rs index a749e30e110..10555ba7f8d 100644 --- a/esp-hal/src/rtc_cntl/mod.rs +++ b/esp-hal/src/rtc_cntl/mod.rs @@ -69,7 +69,6 @@ //! } //! ``` -use embedded_hal::watchdog::{Watchdog, WatchdogDisable, WatchdogEnable}; #[cfg(not(any(esp32c6, esp32h2)))] use fugit::HertzU32; use fugit::MicrosDurationU64; @@ -307,9 +306,7 @@ impl<'d> Rtc<'d> { } config.apply(); - - use embedded_hal::blocking::delay::DelayMs; - delay.delay_ms(100u32); + delay.delay_millis(100u32); config.start_sleep(wakeup_triggers); config.finish_sleep(); @@ -871,13 +868,15 @@ impl Rwdt { } } -impl WatchdogDisable for Rwdt { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::watchdog::WatchdogDisable for Rwdt { fn disable(&mut self) { self.disable(); } } -impl WatchdogEnable for Rwdt { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::watchdog::WatchdogEnable for Rwdt { type Time = MicrosDurationU64; fn start(&mut self, period: T) @@ -888,7 +887,8 @@ impl WatchdogEnable for Rwdt { } } -impl Watchdog for Rwdt { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::watchdog::Watchdog for Rwdt { fn feed(&mut self) { self.feed(); } @@ -949,8 +949,11 @@ impl Default for Swd { } } -#[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3))] -impl WatchdogDisable for Swd { +#[cfg(all( + any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3), + feature = "embedded-hal-02" +))] +impl embedded_hal_02::watchdog::WatchdogDisable for Swd { fn disable(&mut self) { self.disable(); } diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index ea929afb5d9..9941a72a2fb 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -29,11 +29,11 @@ //! If all you want to do is to communicate to a single device, and you initiate //! transactions yourself, there are a number of ways to achieve this: //! -//! - Use the [`FullDuplex`](embedded_hal::spi::FullDuplex) trait to read/write -//! single bytes at a time, -//! - Use the [`SpiBus`](embedded_hal_1::spi::SpiBus) trait (requires the "eh1" -//! feature) and its associated functions to initiate transactions with -//! simultaneous reads and writes, or +//! - Use the [`FullDuplex`](embedded_hal_02::spi::FullDuplex) trait to +//! read/write single bytes at a time, +//! - Use the [`SpiBus`](embedded_hal::spi::SpiBus) trait (requires the +//! "embedded-hal" feature) and its associated functions to initiate +//! transactions with simultaneous reads and writes, or //! - Use the `ExclusiveDevice` struct from [`embedded-hal-bus`] or `SpiDevice` //! from [`embassy-embedded-hal`]. //! @@ -716,7 +716,8 @@ where } } -impl embedded_hal::spi::FullDuplex for Spi<'_, T, M> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::spi::FullDuplex for Spi<'_, T, M> where T: Instance, M: IsFullDuplex, @@ -732,7 +733,8 @@ where } } -impl embedded_hal::blocking::spi::Transfer for Spi<'_, T, M> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::spi::Transfer for Spi<'_, T, M> where T: Instance, M: IsFullDuplex, @@ -744,7 +746,8 @@ where } } -impl embedded_hal::blocking::spi::Write for Spi<'_, T, M> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::blocking::spi::Write for Spi<'_, T, M> where T: Instance, M: IsFullDuplex, @@ -1214,7 +1217,8 @@ pub mod dma { } } - impl<'d, T, C, M> embedded_hal::blocking::spi::Transfer for SpiDma<'d, T, C, M> + #[cfg(feature = "embedded-hal-02")] + impl<'d, T, C, M> embedded_hal_02::blocking::spi::Transfer for SpiDma<'d, T, C, M> where T: InstanceDma, C::Rx<'d>>, C: ChannelTypes, @@ -1229,7 +1233,8 @@ pub mod dma { } } - impl<'d, T, C, M> embedded_hal::blocking::spi::Write for SpiDma<'d, T, C, M> + #[cfg(feature = "embedded-hal-02")] + impl<'d, T, C, M> embedded_hal_02::blocking::spi::Write for SpiDma<'d, T, C, M> where T: InstanceDma, C::Rx<'d>>, C: ChannelTypes, @@ -1245,8 +1250,9 @@ pub mod dma { } } - impl, const SIZE: usize> - embedded_hal::blocking::spi::Transfer for FlashSafeDma + #[cfg(feature = "embedded-hal-02")] + impl, const SIZE: usize> + embedded_hal_02::blocking::spi::Transfer for FlashSafeDma { type Error = T::Error; @@ -1255,8 +1261,9 @@ pub mod dma { } } - impl, const SIZE: usize> - embedded_hal::blocking::spi::Write for FlashSafeDma + #[cfg(feature = "embedded-hal-02")] + impl, const SIZE: usize> + embedded_hal_02::blocking::spi::Write for FlashSafeDma { type Error = T::Error; @@ -1274,23 +1281,24 @@ pub mod dma { } } - impl, const SIZE: usize> embedded_hal::spi::FullDuplex - for FlashSafeDma + #[cfg(feature = "embedded-hal-02")] + impl, const SIZE: usize> + embedded_hal_02::spi::FullDuplex for FlashSafeDma where - Self: embedded_hal::blocking::spi::Transfer, - Self: embedded_hal::blocking::spi::Write, + Self: embedded_hal_02::blocking::spi::Transfer, + Self: embedded_hal_02::blocking::spi::Write, { type Error = T::Error; fn read(&mut self) -> nb::Result { - use embedded_hal::blocking::spi::Transfer; + use embedded_hal_02::blocking::spi::Transfer; let mut buf = [0; 1]; self.transfer(&mut buf)?; Ok(buf[0]) } fn send(&mut self, word: u8) -> nb::Result<(), Self::Error> { - use embedded_hal::blocking::spi::Write; + use embedded_hal_02::blocking::spi::Write; self.write(&[word])?; Ok(()) } @@ -1454,9 +1462,9 @@ pub mod dma { } } - #[cfg(feature = "eh1")] + #[cfg(feature = "embedded-hal")] mod ehal1 { - use embedded_hal_1::spi::{ErrorType, SpiBus}; + use embedded_hal::spi::{ErrorType, SpiBus}; use super::*; @@ -1560,14 +1568,14 @@ pub mod dma { } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] mod ehal1 { - use embedded_hal_1::spi::SpiBus; + use embedded_hal::spi::SpiBus; use embedded_hal_nb::spi::FullDuplex; use super::*; - impl embedded_hal_1::spi::ErrorType for Spi<'_, T, M> { + impl embedded_hal::spi::ErrorType for Spi<'_, T, M> { type Error = super::Error; } diff --git a/esp-hal/src/spi/mod.rs b/esp-hal/src/spi/mod.rs index 8b6b2e7ff64..ae9fd6eb47b 100644 --- a/esp-hal/src/spi/mod.rs +++ b/esp-hal/src/spi/mod.rs @@ -27,10 +27,10 @@ impl From for Error { } } -#[cfg(feature = "eh1")] -impl embedded_hal_1::spi::Error for Error { - fn kind(&self) -> embedded_hal_1::spi::ErrorKind { - embedded_hal_1::spi::ErrorKind::Other +#[cfg(feature = "embedded-hal")] +impl embedded_hal::spi::Error for Error { + fn kind(&self) -> embedded_hal::spi::ErrorKind { + embedded_hal::spi::ErrorKind::Other } } diff --git a/esp-hal/src/timer.rs b/esp-hal/src/timer.rs index e4e293674c0..ee8a10e9cae 100644 --- a/esp-hal/src/timer.rs +++ b/esp-hal/src/timer.rs @@ -39,10 +39,6 @@ use core::{ ops::{Deref, DerefMut}, }; -use embedded_hal::{ - timer::{Cancel, CountDown, Periodic}, - watchdog::{Watchdog, WatchdogDisable, WatchdogEnable}, -}; use fugit::{HertzU32, MicrosDurationU64}; use void::Void; @@ -650,7 +646,8 @@ where (1_000_000 * micros / period as u64) as u64 } -impl CountDown for Timer +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::timer::CountDown for Timer where T: Instance, { @@ -693,7 +690,8 @@ where } } -impl Cancel for Timer +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::timer::Cancel for Timer where T: Instance, { @@ -712,7 +710,8 @@ where } } -impl Periodic for Timer where T: Instance {} +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::timer::Periodic for Timer where T: Instance {} /// Watchdog timer pub struct Wdt { @@ -844,7 +843,8 @@ where } } -impl WatchdogDisable for Wdt +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::watchdog::WatchdogDisable for Wdt where TG: TimerGroupInstance, { @@ -853,7 +853,8 @@ where } } -impl WatchdogEnable for Wdt +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::watchdog::WatchdogEnable for Wdt where TG: TimerGroupInstance, { @@ -868,7 +869,8 @@ where } } -impl Watchdog for Wdt +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::watchdog::Watchdog for Wdt where TG: TimerGroupInstance, { diff --git a/esp-hal/src/twai/filter.rs b/esp-hal/src/twai/filter.rs index 887c731bbb4..964775846ad 100644 --- a/esp-hal/src/twai/filter.rs +++ b/esp-hal/src/twai/filter.rs @@ -3,10 +3,10 @@ //! These are acceptance filters that limit which packets are received by the //! TWAI peripheral. -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] use embedded_can::{ExtendedId, StandardId}; -#[cfg(not(feature = "eh1"))] -use embedded_hal::can::{ExtendedId, StandardId}; +#[cfg(not(feature = "embedded-hal"))] // FIXME +use embedded_hal_02::can::{ExtendedId, StandardId}; #[derive(Debug, PartialEq, Eq)] pub enum FilterType { diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs index 07efe330c79..de2188d5d2b 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -75,10 +75,10 @@ //! } //! ``` -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] use embedded_can::{nb::Can, Error, ErrorKind, ExtendedId, Frame, Id, StandardId}; -#[cfg(not(feature = "eh1"))] -use embedded_hal::can::{Can, Error, ErrorKind, ExtendedId, Frame, Id, StandardId}; +#[cfg(not(feature = "embedded-hal"))] // FIXME +use embedded_hal_02::can::{Can, Error, ErrorKind, ExtendedId, Frame, Id, StandardId}; use fugit::HertzU32; use self::filter::{Filter, FilterType}; @@ -92,7 +92,7 @@ use crate::{ pub mod filter; -/// Structure backing the embedded_hal::can::Frame/embedded_can::Frame trait. +/// Structure backing the embedded_hal_02::can::Frame/embedded_can::Frame trait. #[derive(Clone, Copy, Debug)] pub struct EspTwaiFrame { id: Id, diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index b0a01a05b73..5e407e3784b 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -65,7 +65,7 @@ pub enum Error { RxFifoOvf, } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Error for Error { fn kind(&self) -> embedded_hal_nb::serial::ErrorKind { embedded_hal_nb::serial::ErrorKind::Other @@ -730,17 +730,17 @@ where .write(|w| w.rxfifo_full_int_clr().set_bit()); } - #[cfg(feature = "eh1")] + #[cfg(feature = "embedded-hal")] fn write_byte(&mut self, word: u8) -> nb::Result<(), Error> { self.tx.write_byte(word) } - #[cfg(feature = "eh1")] + #[cfg(feature = "embedded-hal")] fn flush_tx(&self) -> nb::Result<(), Error> { self.tx.flush_tx() } - #[cfg(feature = "eh1")] + #[cfg(feature = "embedded-hal")] fn read_byte(&mut self) -> nb::Result { self.rx.read_byte() } @@ -1230,7 +1230,8 @@ where } } -impl embedded_hal::serial::Write for Uart<'_, T> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Write for Uart<'_, T> where T: Instance, { @@ -1245,7 +1246,8 @@ where } } -impl embedded_hal::serial::Write for UartTx<'_, T> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Write for UartTx<'_, T> where T: Instance, { @@ -1260,7 +1262,8 @@ where } } -impl embedded_hal::serial::Read for Uart<'_, T> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Read for Uart<'_, T> where T: Instance, { @@ -1271,7 +1274,8 @@ where } } -impl embedded_hal::serial::Read for UartRx<'_, T> +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Read for UartRx<'_, T> where T: Instance, { @@ -1282,22 +1286,22 @@ where } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::ErrorType for Uart<'_, T> { type Error = Error; } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::ErrorType for UartTx<'_, T> { type Error = Error; } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::ErrorType for UartRx<'_, T> { type Error = Error; } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Read for Uart<'_, T> where T: Instance, @@ -1307,7 +1311,7 @@ where } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Read for UartRx<'_, T> where T: Instance, @@ -1317,7 +1321,7 @@ where } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Write for Uart<'_, T> where T: Instance, @@ -1331,7 +1335,7 @@ where } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Write for UartTx<'_, T> where T: Instance, diff --git a/esp-hal/src/usb_serial_jtag.rs b/esp-hal/src/usb_serial_jtag.rs index e0df0b1de60..decee9818f1 100644 --- a/esp-hal/src/usb_serial_jtag.rs +++ b/esp-hal/src/usb_serial_jtag.rs @@ -364,15 +364,17 @@ impl ufmt_write::uWrite for UsbSerialJtagTx<'_> { } } -impl embedded_hal::serial::Read for UsbSerialJtag<'_> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Read for UsbSerialJtag<'_> { type Error = Error; fn read(&mut self) -> nb::Result { - embedded_hal::serial::Read::read(&mut self.rx) + embedded_hal_02::serial::Read::read(&mut self.rx) } } -impl embedded_hal::serial::Read for UsbSerialJtagRx<'_> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Read for UsbSerialJtagRx<'_> { type Error = Error; fn read(&mut self) -> nb::Result { @@ -380,19 +382,21 @@ impl embedded_hal::serial::Read for UsbSerialJtagRx<'_> { } } -impl embedded_hal::serial::Write for UsbSerialJtag<'_> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Write for UsbSerialJtag<'_> { type Error = Error; fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { - embedded_hal::serial::Write::write(&mut self.tx, word) + embedded_hal_02::serial::Write::write(&mut self.tx, word) } fn flush(&mut self) -> nb::Result<(), Self::Error> { - embedded_hal::serial::Write::flush(&mut self.tx) + embedded_hal_02::serial::Write::flush(&mut self.tx) } } -impl embedded_hal::serial::Write for UsbSerialJtagTx<'_> { +#[cfg(feature = "embedded-hal-02")] +impl embedded_hal_02::serial::Write for UsbSerialJtagTx<'_> { type Error = Error; fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { @@ -404,36 +408,36 @@ impl embedded_hal::serial::Write for UsbSerialJtagTx<'_> { } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::ErrorType for UsbSerialJtag<'_> { type Error = Error; } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagTx<'_> { type Error = Error; } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagRx<'_> { type Error = Error; } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Read for UsbSerialJtag<'_> { fn read(&mut self) -> nb::Result { embedded_hal_nb::serial::Read::read(&mut self.rx) } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Read for UsbSerialJtagRx<'_> { fn read(&mut self) -> nb::Result { self.read_byte() } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_> { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { embedded_hal_nb::serial::Write::write(&mut self.tx, word) @@ -444,7 +448,7 @@ impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_> { } } -#[cfg(feature = "eh1")] +#[cfg(feature = "embedded-hal")] impl embedded_hal_nb::serial::Write for UsbSerialJtagTx<'_> { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { self.write_byte_nb(word) From 8de0a457a114231a241b2559a84e65f05e9ffde6 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Tue, 12 Mar 2024 10:08:50 -0700 Subject: [PATCH 2/4] Use native `Delay` APIs in examples where applicable --- examples/Cargo.toml | 5 +++-- examples/src/bin/adc.rs | 4 ++-- examples/src/bin/adc_cal.rs | 4 ++-- examples/src/bin/advanced_serial.rs | 4 ++-- examples/src/bin/blinky.rs | 4 ++-- examples/src/bin/blinky_erased_pins.rs | 4 ++-- examples/src/bin/dac.rs | 4 ++-- examples/src/bin/gpio_interrupt.rs | 4 ++-- examples/src/bin/hello_rgb.rs | 4 ++-- examples/src/bin/lcd_i8080.rs | 16 ++++++++-------- examples/src/bin/parl_io_rx.rs | 4 ++-- examples/src/bin/parl_io_tx.rs | 4 ++-- examples/src/bin/qspi_flash.rs | 12 ++++++------ examples/src/bin/rmt_rx.rs | 8 ++++---- examples/src/bin/rmt_tx.rs | 4 ++-- examples/src/bin/rtc_time.rs | 4 ++-- examples/src/bin/sleep_timer.rs | 2 +- examples/src/bin/sleep_timer_ext0.rs | 6 +++--- examples/src/bin/sleep_timer_ext1.rs | 6 +++--- examples/src/bin/sleep_timer_lpio.rs | 2 +- examples/src/bin/sleep_timer_rtcio.rs | 6 +++--- examples/src/bin/software_interrupts.rs | 4 ++-- examples/src/bin/spi_eh1_device_loopback.rs | 12 ++++++------ examples/src/bin/spi_eh1_loopback.rs | 12 ++++++------ .../bin/spi_halfduplex_read_manufacturer_id.rs | 8 ++++---- examples/src/bin/spi_loopback.rs | 4 ++-- examples/src/bin/spi_loopback_dma.rs | 6 +++--- examples/src/bin/spi_slave_dma.rs | 6 +++--- examples/src/bin/systimer.rs | 4 ++-- 29 files changed, 84 insertions(+), 83 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 7f9d7075b92..92b1d2187bf 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -17,7 +17,7 @@ embassy-time = "0.3.0" embassy-time-driver = { version = "0.1.0", optional = true } embedded-graphics = "0.8.1" embedded-hal = "1.0.0" -embedded-hal-02 = { version = "0.2.7", package = "embedded-hal" } +embedded-hal-02 = { version = "0.2.7", package = "embedded-hal", features = ["unproven"] } embedded-hal-async = "1.0.0" embedded-hal-bus = "0.1.0" embedded-io-async = "0.6.1" @@ -52,7 +52,8 @@ esp32s3 = ["esp-hal/esp32s3", "esp-backtrace/esp32s3", "esp-println/esp32s3", "e async = ["esp-hal/async"] -eh1 = ["esp-hal/eh1"] +embedded-hal-02 = ["esp-hal/embedded-hal-02"] +embedded-hal = ["esp-hal/embedded-hal"] embassy = ["esp-hal/embassy"] diff --git a/examples/src/bin/adc.rs b/examples/src/bin/adc.rs index 19422d24a3a..40f85856ac5 100644 --- a/examples/src/bin/adc.rs +++ b/examples/src/bin/adc.rs @@ -42,11 +42,11 @@ fn main() -> ! { let mut adc1_pin = adc1_config.enable_pin(analog_pin, Attenuation::Attenuation11dB); let mut adc1 = ADC::::new(peripherals.ADC1, adc1_config); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { let pin_value: u16 = nb::block!(adc1.read(&mut adc1_pin)).unwrap(); println!("ADC reading = {}", pin_value); - delay.delay_ms(1500u32); + delay.delay_millis(1500u32); } } diff --git a/examples/src/bin/adc_cal.rs b/examples/src/bin/adc_cal.rs index 6ec67745cf1..b40705b8dc7 100644 --- a/examples/src/bin/adc_cal.rs +++ b/examples/src/bin/adc_cal.rs @@ -48,11 +48,11 @@ fn main() -> ! { adc1_config.enable_pin_with_cal::<_, AdcCal>(analog_pin, Attenuation::Attenuation11dB); let mut adc1 = ADC::::new(peripherals.ADC1, adc1_config); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { let pin_mv = nb::block!(adc1.read(&mut adc1_pin)).unwrap(); println!("PIN2 ADC reading = {pin_mv} mV"); - delay.delay_ms(1500u32); + delay.delay_millis(1500u32); } } diff --git a/examples/src/bin/advanced_serial.rs b/examples/src/bin/advanced_serial.rs index 82958dab31d..59e7003c733 100644 --- a/examples/src/bin/advanced_serial.rs +++ b/examples/src/bin/advanced_serial.rs @@ -49,7 +49,7 @@ fn main() -> ! { let mut serial1 = Uart::new_with_config(peripherals.UART1, config, Some(pins), &clocks); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); println!("Start"); loop { @@ -61,6 +61,6 @@ fn main() -> ! { Err(err) => println!("Error {:?}", err), } - delay.delay_ms(250u32); + delay.delay_millis(250u32); } } diff --git a/examples/src/bin/blinky.rs b/examples/src/bin/blinky.rs index 072267b9bad..3046683b01e 100644 --- a/examples/src/bin/blinky.rs +++ b/examples/src/bin/blinky.rs @@ -24,10 +24,10 @@ fn main() -> ! { // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { led.toggle().unwrap(); - delay.delay_ms(500u32); + delay.delay_millis(500u32); } } diff --git a/examples/src/bin/blinky_erased_pins.rs b/examples/src/bin/blinky_erased_pins.rs index 0a58e2f285c..5a6b286c89b 100644 --- a/examples/src/bin/blinky_erased_pins.rs +++ b/examples/src/bin/blinky_erased_pins.rs @@ -40,11 +40,11 @@ fn main() -> ! { // Initialize the `Delay` peripheral, and use it to toggle the LED state // in a loop: - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { toggle_pins(&mut pins, &button); - delay.delay_ms(500u32); + delay.delay_millis(500u32); } } diff --git a/examples/src/bin/dac.rs b/examples/src/bin/dac.rs index 5f9831c8cbf..8020f6eddd3 100644 --- a/examples/src/bin/dac.rs +++ b/examples/src/bin/dac.rs @@ -43,7 +43,7 @@ fn main() -> ! { let mut dac1 = DAC1::new(peripherals.DAC1, dac1_pin); let mut dac2 = DAC2::new(peripherals.DAC2, dac2_pin); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let mut voltage_dac1: u8 = 200; let mut voltage_dac2: u8 = 255; @@ -54,6 +54,6 @@ fn main() -> ! { voltage_dac2 = voltage_dac2.wrapping_sub(1); dac2.write(voltage_dac2); - delay.delay_ms(50u32); + delay.delay_millis(50u32); } } diff --git a/examples/src/bin/gpio_interrupt.rs b/examples/src/bin/gpio_interrupt.rs index e2555e2528f..2f83e5fc177 100644 --- a/examples/src/bin/gpio_interrupt.rs +++ b/examples/src/bin/gpio_interrupt.rs @@ -54,11 +54,11 @@ fn main() -> ! { // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { led.toggle().unwrap(); - delay.delay_ms(500u32); + delay.delay_millis(500u32); } } diff --git a/examples/src/bin/hello_rgb.rs b/examples/src/bin/hello_rgb.rs index 9eed238cde1..dd3d041be84 100644 --- a/examples/src/bin/hello_rgb.rs +++ b/examples/src/bin/hello_rgb.rs @@ -67,7 +67,7 @@ fn main() -> ! { // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let mut color = Hsv { hue: 0, @@ -88,7 +88,7 @@ fn main() -> ! { // that the output it's not too bright. led.write(brightness(gamma(data.iter().cloned()), 10)) .unwrap(); - delay.delay_ms(20u8); + delay.delay_millis(20); } } } diff --git a/examples/src/bin/lcd_i8080.rs b/examples/src/bin/lcd_i8080.rs index a93d7f8d0c1..6a00adaf3d8 100644 --- a/examples/src/bin/lcd_i8080.rs +++ b/examples/src/bin/lcd_i8080.rs @@ -64,7 +64,7 @@ fn main() -> ! { DmaPriority::Priority0, ); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let mut backlight = lcd_backlight.into_push_pull_output(); let mut reset = lcd_reset.into_push_pull_output(); @@ -96,9 +96,9 @@ fn main() -> ! { // https://github.com/lovyan03/LovyanGFX/blob/302169a6f23e9a2a6451f03311c366d182193831/src/lgfx/v1/panel/Panel_ST7796.hpp#L28 reset.set_low().unwrap(); - delay.delay_us(8_000u32); + delay.delay_micros(8_000u32); reset.set_high().unwrap(); - delay.delay_us(64_000u32); + delay.delay_micros(64_000u32); // const CMD_FRMCTR1: u8 = 0xB1; // const CMD_FRMCTR2: u8 = 0xB2; @@ -149,7 +149,7 @@ fn main() -> ! { i8080.send(CMD_PWCTR3, 0, &[0xA7]).unwrap(); // Power control 3 //Source driving current level=low, Gamma driving current // level=High i8080.send(CMD_VMCTR, 0, &[0x18]).unwrap(); // VCOM Control //VCOM=0.9 - delay.delay_us(120_000u32); + delay.delay_micros(120_000u32); i8080 .send( CMD_GMCTRP1, @@ -170,13 +170,13 @@ fn main() -> ! { ], ) .unwrap(); - delay.delay_us(120_000u32); + delay.delay_micros(120_000u32); i8080.send(CMD_CSCON, 0, &[0x3C]).unwrap(); // Command Set control // Disable extension command 2 partI i8080.send(CMD_CSCON, 0, &[0x69]).unwrap(); // Command Set control // Disable // extension command 2 partII i8080.send(0x11, 0, &[]).unwrap(); // ExitSleepMode - delay.delay_us(130_000u32); + delay.delay_micros(130_000u32); i8080.send(0x38, 0, &[]).unwrap(); // ExitIdleMode i8080.send(0x29, 0, &[]).unwrap(); // SetDisplayOn @@ -239,10 +239,10 @@ fn main() -> ! { transfer.wait().unwrap(); } - delay.delay_ms(1_000u32); + delay.delay_millis(1_000u32); } loop { - delay.delay_ms(1_000u32); + delay.delay_millis(1_000u32); } } diff --git a/examples/src/bin/parl_io_rx.rs b/examples/src/bin/parl_io_rx.rs index c2646a55e64..d8b50991474 100644 --- a/examples/src/bin/parl_io_rx.rs +++ b/examples/src/bin/parl_io_rx.rs @@ -57,13 +57,13 @@ fn main() -> ! { let mut buffer = rx_buffer; buffer.fill(0u8); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { let transfer = parl_io_rx.read_dma(&mut buffer).unwrap(); transfer.wait().unwrap(); println!("Received: {:02x?} ...", &buffer[..30]); - delay.delay_ms(500u32); + delay.delay_millis(500u32); } } diff --git a/examples/src/bin/parl_io_tx.rs b/examples/src/bin/parl_io_tx.rs index 220c26fa2d0..c58ee21a99a 100644 --- a/examples/src/bin/parl_io_tx.rs +++ b/examples/src/bin/parl_io_tx.rs @@ -80,13 +80,13 @@ fn main() -> ! { buffer[i] = (i % 255) as u8; } - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { let transfer = parl_io_tx.write_dma(&buffer).unwrap(); transfer.wait().unwrap(); println!("Transferred {} bytes", buffer.len()); - delay.delay_ms(500u32); + delay.delay_millis(500u32); } } diff --git a/examples/src/bin/qspi_flash.rs b/examples/src/bin/qspi_flash.rs index 7842547d341..e4a20ab11ab 100644 --- a/examples/src/bin/qspi_flash.rs +++ b/examples/src/bin/qspi_flash.rs @@ -93,7 +93,7 @@ fn main() -> ! { DmaPriority::Priority0, )); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); // DMA buffer require a static life-time let (zero_buf, _, _, _) = dma_buffers!(0); @@ -111,7 +111,7 @@ fn main() -> ! { ) .unwrap(); transfer.wait().unwrap(); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // erase sector let transfer = spi @@ -124,7 +124,7 @@ fn main() -> ! { ) .unwrap(); transfer.wait().unwrap(); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // write enable let transfer = spi @@ -137,7 +137,7 @@ fn main() -> ! { ) .unwrap(); transfer.wait().unwrap(); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // write data / program page send.fill(b'!'); @@ -152,7 +152,7 @@ fn main() -> ! { ) .unwrap(); transfer.wait().unwrap(); - delay.delay_ms(250u32); + delay.delay_millis(250u32); loop { // quad fast read @@ -181,6 +181,6 @@ fn main() -> ! { } println!(); - delay.delay_ms(250u32); + delay.delay_millis(250u32); } } diff --git a/examples/src/bin/rmt_rx.rs b/examples/src/bin/rmt_rx.rs index 6dc47e92a8d..220e394c0e9 100644 --- a/examples/src/bin/rmt_rx.rs +++ b/examples/src/bin/rmt_rx.rs @@ -54,7 +54,7 @@ fn main() -> ! { } } - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let mut data = [PulseCode { level1: true, @@ -74,9 +74,9 @@ fn main() -> ! { // simulate input for i in 0u32..5u32 { out.set_high().unwrap(); - delay.delay_us(i * 10 + 20); + delay.delay_micros(i * 10 + 20); out.set_low().unwrap(); - delay.delay_us(i * 20 + 20); + delay.delay_micros(i * 20 + 20); } match transaction.wait() { @@ -125,6 +125,6 @@ fn main() -> ! { } } - delay.delay_ms(1500u32); + delay.delay_millis(1500u32); } } diff --git a/examples/src/bin/rmt_tx.rs b/examples/src/bin/rmt_tx.rs index 56943975cd6..4f7a7cd0340 100644 --- a/examples/src/bin/rmt_tx.rs +++ b/examples/src/bin/rmt_tx.rs @@ -42,7 +42,7 @@ fn main() -> ! { let mut channel = rmt.channel0.configure(io.pins.gpio4, tx_config).unwrap(); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let mut data = [PulseCode { level1: true, @@ -62,6 +62,6 @@ fn main() -> ! { loop { let transaction = channel.transmit(&data); channel = transaction.wait().unwrap(); - delay.delay_ms(500u32); + delay.delay_millis(500u32); } } diff --git a/examples/src/bin/rtc_time.rs b/examples/src/bin/rtc_time.rs index d0e5cfd01ca..21c99441fe3 100644 --- a/examples/src/bin/rtc_time.rs +++ b/examples/src/bin/rtc_time.rs @@ -21,10 +21,10 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let rtc = Rtc::new(peripherals.LPWR); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { esp_println::println!("rtc time in milliseconds is {}", rtc.get_time_ms()); - delay.delay_ms(1000u32); + delay.delay_millis(1000u32); } } diff --git a/examples/src/bin/sleep_timer.rs b/examples/src/bin/sleep_timer.rs index d910114cc90..35fbb005280 100644 --- a/examples/src/bin/sleep_timer.rs +++ b/examples/src/bin/sleep_timer.rs @@ -36,6 +36,6 @@ fn main() -> ! { let timer = TimerWakeupSource::new(Duration::from_secs(5)); println!("sleeping!"); - delay.delay_ms(100u32); + delay.delay_millis(100u32); rtc.sleep_deep(&[&timer], &mut delay); } diff --git a/examples/src/bin/sleep_timer_ext0.rs b/examples/src/bin/sleep_timer_ext0.rs index c6711ea2d2a..60761dbce1f 100644 --- a/examples/src/bin/sleep_timer_ext0.rs +++ b/examples/src/bin/sleep_timer_ext0.rs @@ -43,11 +43,11 @@ fn main() -> ! { let wake_reason = get_wakeup_cause(); println!("wake reason: {:?}", wake_reason); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let timer = TimerWakeupSource::new(Duration::from_secs(30)); let ext0 = Ext0WakeupSource::new(&mut ext0_pin, WakeupLevel::High); println!("sleeping!"); - delay.delay_ms(100u32); - rtc.sleep_deep(&[&timer, &ext0], &mut delay); + delay.delay_millis(100u32); + rtc.sleep_deep(&[&timer, &ext0], &delay); } diff --git a/examples/src/bin/sleep_timer_ext1.rs b/examples/src/bin/sleep_timer_ext1.rs index 2140228bcd4..1ae1ec97a36 100644 --- a/examples/src/bin/sleep_timer_ext1.rs +++ b/examples/src/bin/sleep_timer_ext1.rs @@ -44,12 +44,12 @@ fn main() -> ! { let wake_reason = get_wakeup_cause(); println!("wake reason: {:?}", wake_reason); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let timer = TimerWakeupSource::new(Duration::from_secs(30)); let mut wakeup_pins: [&mut dyn RTCPin; 2] = [&mut pin_0, &mut pin_2]; let ext1 = Ext1WakeupSource::new(&mut wakeup_pins, WakeupLevel::High); println!("sleeping!"); - delay.delay_ms(100u32); - rtc.sleep_deep(&[&timer, &ext1], &mut delay); + delay.delay_millis(100u32); + rtc.sleep_deep(&[&timer, &ext1], &delay); } diff --git a/examples/src/bin/sleep_timer_lpio.rs b/examples/src/bin/sleep_timer_lpio.rs index 5e9f83a3393..5046cf28cab 100644 --- a/examples/src/bin/sleep_timer_lpio.rs +++ b/examples/src/bin/sleep_timer_lpio.rs @@ -54,6 +54,6 @@ fn main() -> ! { let rtcio = Ext1WakeupSource::new(wakeup_pins); println!("sleeping!"); - delay.delay_ms(100u32); + delay.delay_millis(100u32); rtc.sleep_deep(&[&timer, &rtcio], &mut delay); } diff --git a/examples/src/bin/sleep_timer_rtcio.rs b/examples/src/bin/sleep_timer_rtcio.rs index 22acd751e3d..9ca7b23f679 100644 --- a/examples/src/bin/sleep_timer_rtcio.rs +++ b/examples/src/bin/sleep_timer_rtcio.rs @@ -43,7 +43,7 @@ fn main() -> ! { let wake_reason = get_wakeup_cause(); println!("wake reason: {:?}", wake_reason); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let timer = TimerWakeupSource::new(Duration::from_secs(10)); #[cfg(feature = "esp32c3")] @@ -58,6 +58,6 @@ fn main() -> ! { let rtcio = RtcioWakeupSource::new(wakeup_pins); println!("sleeping!"); - delay.delay_ms(100u32); - rtc.sleep_deep(&[&timer, &rtcio], &mut delay); + delay.delay_millis(100u32); + rtc.sleep_deep(&[&timer, &rtcio], &delay); } diff --git a/examples/src/bin/software_interrupts.rs b/examples/src/bin/software_interrupts.rs index 71f0fc16a60..0daae4d734c 100644 --- a/examples/src/bin/software_interrupts.rs +++ b/examples/src/bin/software_interrupts.rs @@ -38,11 +38,11 @@ fn main() -> ! { interrupt::enable(Interrupt::FROM_CPU_INTR2, Priority::Priority3).unwrap(); interrupt::enable(Interrupt::FROM_CPU_INTR3, Priority::Priority3).unwrap(); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); let mut counter = 0; loop { - delay.delay_ms(500u32); + delay.delay_millis(500u32); match counter { 0 => critical_section::with(|cs| { SWINT diff --git a/examples/src/bin/spi_eh1_device_loopback.rs b/examples/src/bin/spi_eh1_device_loopback.rs index 27ccbfc1fa9..81b2402bb70 100644 --- a/examples/src/bin/spi_eh1_device_loopback.rs +++ b/examples/src/bin/spi_eh1_device_loopback.rs @@ -24,7 +24,7 @@ //! data. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 -//% FEATURES: eh1 +//% FEATURES: embedded-hal #![no_std] #![no_main] @@ -79,7 +79,7 @@ fn main() -> ! { } } - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); println!("=== SPI example with embedded-hal-1 traits ==="); loop { @@ -93,7 +93,7 @@ fn main() -> ! { spi_device_2.transfer(&mut read[..], &write[..]).unwrap(); spi_device_3.transfer(&mut read[..], &write[..]).unwrap(); println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // --- Asymmetric transfer (Read more than we write) --- print!("Starting asymetric transfer (read > write)..."); @@ -111,7 +111,7 @@ fn main() -> ! { .transfer(&mut read[0..2], &write[..]) .expect("Asymmetric transfer failed"); println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // --- Symmetric transfer with huge buffer --- // Only your RAM is the limit! @@ -133,7 +133,7 @@ fn main() -> ! { .transfer(&mut read[..], &write[..]) .expect("Huge transfer failed"); println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // --- Symmetric transfer with huge buffer in-place (No additional allocation // needed) --- @@ -156,6 +156,6 @@ fn main() -> ! { .transfer_in_place(&mut write[..]) .expect("Huge transfer failed"); println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); } } diff --git a/examples/src/bin/spi_eh1_loopback.rs b/examples/src/bin/spi_eh1_loopback.rs index 75f654f0577..45e23f855ca 100644 --- a/examples/src/bin/spi_eh1_loopback.rs +++ b/examples/src/bin/spi_eh1_loopback.rs @@ -14,7 +14,7 @@ //! data. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 -//% FEATURES: eh1 +//% FEATURES: embedded-hal #![no_std] #![no_main] @@ -50,7 +50,7 @@ fn main() -> ! { Some(cs), ); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); println!("=== SPI example with embedded-hal-1 traits ==="); loop { @@ -62,7 +62,7 @@ fn main() -> ! { SpiBus::transfer(&mut spi, &mut read[..], &write[..]).expect("Symmetric transfer failed"); assert_eq!(write, read); println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // --- Asymmetric transfer (Read more than we write) --- print!("Starting asymetric transfer (read > write)..."); @@ -73,7 +73,7 @@ fn main() -> ! { assert_eq!(write[0], read[0]); assert_eq!(read[2], 0x00u8); println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // --- Symmetric transfer with huge buffer --- // Only your RAM is the limit! @@ -87,7 +87,7 @@ fn main() -> ! { SpiBus::transfer(&mut spi, &mut read[..], &write[..]).expect("Huge transfer failed"); assert_eq!(write, read); println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // --- Symmetric transfer with huge buffer in-place (No additional allocation // needed) --- @@ -102,6 +102,6 @@ fn main() -> ! { assert_eq!(write[byte], byte as u8); } println!(" SUCCESS"); - delay.delay_ms(250u32); + delay.delay_millis(250u32); } } diff --git a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs index d462fd19e2a..e2c4241a949 100644 --- a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs +++ b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs @@ -77,7 +77,7 @@ fn main() -> ! { Some(cs), ); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { // READ MANUFACTURER ID FROM FLASH CHIP @@ -91,7 +91,7 @@ fn main() -> ! { ) .unwrap(); println!("Single {:x?}", data); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // READ MANUFACTURER ID FROM FLASH CHIP let mut data = [0u8; 2]; @@ -104,7 +104,7 @@ fn main() -> ! { ) .unwrap(); println!("Dual {:x?}", data); - delay.delay_ms(250u32); + delay.delay_millis(250u32); // READ MANUFACTURER ID FROM FLASH CHIP let mut data = [0u8; 2]; @@ -117,6 +117,6 @@ fn main() -> ! { ) .unwrap(); println!("Quad {:x?}", data); - delay.delay_ms(1500u32); + delay.delay_millis(1500u32); } } diff --git a/examples/src/bin/spi_loopback.rs b/examples/src/bin/spi_loopback.rs index bb307972b91..337e1e33ac2 100644 --- a/examples/src/bin/spi_loopback.rs +++ b/examples/src/bin/spi_loopback.rs @@ -48,13 +48,13 @@ fn main() -> ! { Some(cs), ); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { let mut data = [0xde, 0xca, 0xfb, 0xad]; spi.transfer(&mut data).unwrap(); println!("{:x?}", data); - delay.delay_ms(250u32); + delay.delay_millis(250u32); } } diff --git a/examples/src/bin/spi_loopback_dma.rs b/examples/src/bin/spi_loopback_dma.rs index b2cc5612253..cf61ea88a6d 100644 --- a/examples/src/bin/spi_loopback_dma.rs +++ b/examples/src/bin/spi_loopback_dma.rs @@ -64,7 +64,7 @@ fn main() -> ! { DmaPriority::Priority0, )); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); // DMA buffer require a static life-time let mut send = tx_buffer; @@ -86,7 +86,7 @@ fn main() -> ! { // Check is_done until the transfer is almost done (32000 bytes at 100kHz is // 2.56 seconds), then move to wait(). while !transfer.is_done() && n < 10 { - delay.delay_ms(250u32); + delay.delay_millis(250u32); n += 1; } @@ -97,6 +97,6 @@ fn main() -> ! { &receive[receive.len() - 10..] ); - delay.delay_ms(250u32); + delay.delay_millis(250u32); } } diff --git a/examples/src/bin/spi_slave_dma.rs b/examples/src/bin/spi_slave_dma.rs index 1100db9edc4..9ba851e6f61 100644 --- a/examples/src/bin/spi_slave_dma.rs +++ b/examples/src/bin/spi_slave_dma.rs @@ -83,7 +83,7 @@ fn main() -> ! { DmaPriority::Priority0, )); - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); // DMA buffer require a static life-time let master_send = &mut [0u8; 32000]; @@ -149,7 +149,7 @@ fn main() -> ! { &master_receive[master_receive.len() - 10..] ); - delay.delay_ms(250u32); + delay.delay_millis(250u32); slave_receive.fill(0xff); let transfer = spi.dma_read(&mut slave_receive).unwrap(); @@ -177,7 +177,7 @@ fn main() -> ! { &slave_receive[slave_receive.len() - 10..], ); - delay.delay_ms(250u32); + delay.delay_millis(250u32); let transfer = spi.dma_write(&mut slave_send).unwrap(); master_receive.fill(0); diff --git a/examples/src/bin/systimer.rs b/examples/src/bin/systimer.rs index df41d819dcc..c3f0cefc190 100644 --- a/examples/src/bin/systimer.rs +++ b/examples/src/bin/systimer.rs @@ -59,10 +59,10 @@ fn main() -> ! { // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. - let mut delay = Delay::new(&clocks); + let delay = Delay::new(&clocks); loop { - delay.delay_ms(500u32); + delay.delay_millis(500u32); } } From c5e2d8a96713c2829a2a6e1b597986188c7b176e Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Tue, 12 Mar 2024 10:17:09 -0700 Subject: [PATCH 3/4] Fix example imports, be explicit about about `embedded-hal-02` feature requirements --- examples/src/bin/adc.rs | 2 ++ examples/src/bin/adc_cal.rs | 2 ++ examples/src/bin/advanced_serial.rs | 2 ++ examples/src/bin/blinky.rs | 2 ++ examples/src/bin/blinky_erased_pins.rs | 2 ++ examples/src/bin/clock_monitor.rs | 2 ++ examples/src/bin/crc.rs | 2 ++ examples/src/bin/ecc.rs | 2 ++ examples/src/bin/embassy_multicore.rs | 3 ++- examples/src/bin/embassy_multicore_interrupt.rs | 3 ++- examples/src/bin/embassy_rmt_rx.rs | 3 ++- examples/src/bin/etm_gpio.rs | 2 ++ examples/src/bin/gpio_interrupt.rs | 2 ++ examples/src/bin/hello_world.rs | 2 ++ examples/src/bin/hmac.rs | 2 ++ examples/src/bin/i2c_bmp180_calibration_data.rs | 2 ++ examples/src/bin/i2c_display.rs | 2 ++ examples/src/bin/lcd_i8080.rs | 2 ++ examples/src/bin/lp_core_uart.rs | 2 ++ examples/src/bin/multicore.rs | 2 ++ examples/src/bin/psram.rs | 7 +------ examples/src/bin/ram.rs | 2 ++ examples/src/bin/rmt_rx.rs | 2 ++ examples/src/bin/rng.rs | 2 ++ examples/src/bin/rtc_watchdog.rs | 2 ++ examples/src/bin/serial_interrupts.rs | 2 ++ examples/src/bin/sleep_timer_ext0.rs | 4 ++-- examples/src/bin/sleep_timer_ext1.rs | 4 ++-- examples/src/bin/sleep_timer_rtcio.rs | 4 ++-- examples/src/bin/spi_loopback.rs | 2 ++ examples/src/bin/spi_slave_dma.rs | 2 ++ examples/src/bin/timer_interrupt.rs | 2 ++ examples/src/bin/twai.rs | 10 +++++----- examples/src/bin/usb_serial_jtag.rs | 2 ++ examples/src/bin/watchdog.rs | 5 +++++ 35 files changed, 75 insertions(+), 20 deletions(-) diff --git a/examples/src/bin/adc.rs b/examples/src/bin/adc.rs index 40f85856ac5..fbc45cd20b0 100644 --- a/examples/src/bin/adc.rs +++ b/examples/src/bin/adc.rs @@ -5,10 +5,12 @@ //! maximum and minimum raw values read. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::adc::OneShot; use esp_backtrace as _; use esp_hal::{ analog::adc::{AdcConfig, Attenuation, ADC}, diff --git a/examples/src/bin/adc_cal.rs b/examples/src/bin/adc_cal.rs index b40705b8dc7..9c87e59f5e3 100644 --- a/examples/src/bin/adc_cal.rs +++ b/examples/src/bin/adc_cal.rs @@ -3,10 +3,12 @@ //! 3V3 to see the maximum and minimum raw values read. //% CHIPS: esp32c2 esp32c3 esp32c6 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::adc::OneShot; use esp_backtrace as _; use esp_hal::{ analog::adc::{AdcConfig, Attenuation, ADC}, diff --git a/examples/src/bin/advanced_serial.rs b/examples/src/bin/advanced_serial.rs index 59e7003c733..5ab2ac58c04 100644 --- a/examples/src/bin/advanced_serial.rs +++ b/examples/src/bin/advanced_serial.rs @@ -8,10 +8,12 @@ //! - RX => GPIO5 //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::serial::{Read, Write}; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/blinky.rs b/examples/src/bin/blinky.rs index 3046683b01e..8612e63cb5b 100644 --- a/examples/src/bin/blinky.rs +++ b/examples/src/bin/blinky.rs @@ -3,10 +3,12 @@ //! This assumes that a LED is connected to the pin assigned to `led`. (GPIO0) //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::digital::v2::{OutputPin, ToggleableOutputPin}; use esp_backtrace as _; use esp_hal::{clock::ClockControl, delay::Delay, gpio::IO, peripherals::Peripherals, prelude::*}; diff --git a/examples/src/bin/blinky_erased_pins.rs b/examples/src/bin/blinky_erased_pins.rs index 5a6b286c89b..faf665f7896 100644 --- a/examples/src/bin/blinky_erased_pins.rs +++ b/examples/src/bin/blinky_erased_pins.rs @@ -6,10 +6,12 @@ //! Additionally demonstrates passing GPIO to a function in a generic way. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::digital::v2::{InputPin, ToggleableOutputPin}; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/clock_monitor.rs b/examples/src/bin/clock_monitor.rs index 0b1f3cfc5f2..ef69190e6c2 100644 --- a/examples/src/bin/clock_monitor.rs +++ b/examples/src/bin/clock_monitor.rs @@ -3,6 +3,7 @@ //! clock cycles within a given number of RTC_SLOW_CLK cycles. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -10,6 +11,7 @@ use core::cell::RefCell; use critical_section::Mutex; +use embedded_hal_02::watchdog::WatchdogEnable; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/crc.rs b/examples/src/bin/crc.rs index 33eecc9cb52..f9d35211945 100644 --- a/examples/src/bin/crc.rs +++ b/examples/src/bin/crc.rs @@ -1,12 +1,14 @@ //! This shows example usage of the CRC functions in ROM //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] use core::fmt::Write; +use embedded_hal_02::timer::CountDown; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/ecc.rs b/examples/src/bin/ecc.rs index 32c0f0f86df..58b9627c21b 100644 --- a/examples/src/bin/ecc.rs +++ b/examples/src/bin/ecc.rs @@ -2,6 +2,7 @@ //! hardware-accelerated and pure software ECC. //% CHIPS: esp32c2 esp32c6 esp32h2 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -15,6 +16,7 @@ use crypto_bigint::{ U256, }; use elliptic_curve::sec1::ToEncodedPoint; +use embedded_hal_02::blocking::rng::Read; use esp_backtrace as _; use esp_hal::{ ecc::{Ecc, EllipticCurve, Error, WorkMode}, diff --git a/examples/src/bin/embassy_multicore.rs b/examples/src/bin/embassy_multicore.rs index 45354e7f123..d9234c66baf 100644 --- a/examples/src/bin/embassy_multicore.rs +++ b/examples/src/bin/embassy_multicore.rs @@ -4,7 +4,7 @@ //! signal set by the task running on the other core. //% CHIPS: esp32 esp32s3 -//% FEATURES: embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers +//% FEATURES: embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers embedded-hal-02 #![no_std] #![no_main] @@ -13,6 +13,7 @@ use embassy_executor::Spawner; use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal}; use embassy_time::{Duration, Ticker}; +use embedded_hal_02::digital::v2::OutputPin; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/embassy_multicore_interrupt.rs b/examples/src/bin/embassy_multicore_interrupt.rs index c139e6ef9af..93760e7699d 100644 --- a/examples/src/bin/embassy_multicore_interrupt.rs +++ b/examples/src/bin/embassy_multicore_interrupt.rs @@ -4,7 +4,7 @@ //! signal set by the task running on the other core. //% CHIPS: esp32 esp32s3 -//% FEATURES: embassy embassy-executor-interrupt embassy-time-timg0 embassy-generic-timers +//% FEATURES: embassy embassy-executor-interrupt embassy-time-timg0 embassy-generic-timers embedded-hal-02 #![no_std] #![no_main] @@ -12,6 +12,7 @@ use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal}; use embassy_time::{Duration, Ticker}; +use embedded_hal_02::digital::v2::OutputPin; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/embassy_rmt_rx.rs b/examples/src/bin/embassy_rmt_rx.rs index 3b22c1ea1ec..96a3caadc39 100644 --- a/examples/src/bin/embassy_rmt_rx.rs +++ b/examples/src/bin/embassy_rmt_rx.rs @@ -2,7 +2,7 @@ //! Connect GPIO5 to GPIO4 //% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 -//% FEATURES: async embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers +//% FEATURES: async embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers embedded-hal-02 #![no_std] #![no_main] @@ -10,6 +10,7 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; +use embedded_hal_02::digital::v2::ToggleableOutputPin; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/etm_gpio.rs b/examples/src/bin/etm_gpio.rs index 900ad1c3239..18840882948 100644 --- a/examples/src/bin/etm_gpio.rs +++ b/examples/src/bin/etm_gpio.rs @@ -1,10 +1,12 @@ //! Control LED on GPIO1 by the BOOT-BUTTON via ETM //% CHIPS: esp32c6 esp32h2 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::digital::v2::OutputPin; use esp_backtrace as _; use esp_hal::{ etm::Etm, diff --git a/examples/src/bin/gpio_interrupt.rs b/examples/src/bin/gpio_interrupt.rs index 2f83e5fc177..50ba5496a0a 100644 --- a/examples/src/bin/gpio_interrupt.rs +++ b/examples/src/bin/gpio_interrupt.rs @@ -4,6 +4,7 @@ //! It also blinks an LED like the blinky example. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -11,6 +12,7 @@ use core::cell::RefCell; use critical_section::Mutex; +use embedded_hal_02::digital::v2::{OutputPin, ToggleableOutputPin}; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/hello_world.rs b/examples/src/bin/hello_world.rs index 0daaa76853d..da503d77ace 100644 --- a/examples/src/bin/hello_world.rs +++ b/examples/src/bin/hello_world.rs @@ -4,12 +4,14 @@ //! option. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] use core::fmt::Write; +use embedded_hal_02::timer::CountDown; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/hmac.rs b/examples/src/bin/hmac.rs index 45bafa0c1c3..0e7c6d8bf35 100644 --- a/examples/src/bin/hmac.rs +++ b/examples/src/bin/hmac.rs @@ -53,10 +53,12 @@ //! ``` //% CHIPS: esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::blocking::rng::Read; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/i2c_bmp180_calibration_data.rs b/examples/src/bin/i2c_bmp180_calibration_data.rs index cfd6c25ee9e..344daa14b65 100644 --- a/examples/src/bin/i2c_bmp180_calibration_data.rs +++ b/examples/src/bin/i2c_bmp180_calibration_data.rs @@ -7,10 +7,12 @@ //! - SCL => GPIO5 //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::blocking::i2c::WriteRead; use esp_backtrace as _; use esp_hal::{clock::ClockControl, gpio::IO, i2c::I2C, peripherals::Peripherals, prelude::*}; use esp_println::println; diff --git a/examples/src/bin/i2c_display.rs b/examples/src/bin/i2c_display.rs index 402b1dfb50f..2f10d05561b 100644 --- a/examples/src/bin/i2c_display.rs +++ b/examples/src/bin/i2c_display.rs @@ -8,6 +8,7 @@ //! - SCL => GPIO2 //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -21,6 +22,7 @@ use embedded_graphics::{ prelude::*, text::{Alignment, Text}, }; +use embedded_hal_02::timer::CountDown; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/lcd_i8080.rs b/examples/src/bin/lcd_i8080.rs index 6a00adaf3d8..278e4652efb 100644 --- a/examples/src/bin/lcd_i8080.rs +++ b/examples/src/bin/lcd_i8080.rs @@ -18,10 +18,12 @@ //! D7 GPIO15 //% CHIPS: esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::digital::v2::OutputPin; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/lp_core_uart.rs b/examples/src/bin/lp_core_uart.rs index e53ff192994..8834cd7f755 100644 --- a/examples/src/bin/lp_core_uart.rs +++ b/examples/src/bin/lp_core_uart.rs @@ -6,10 +6,12 @@ //! Make sure to first compile the `esp-lp-hal/examples/uart.rs` example //% CHIPS: esp32c6 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::serial::Read; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/multicore.rs b/examples/src/bin/multicore.rs index dc506beb1a8..4f5f87590ce 100644 --- a/examples/src/bin/multicore.rs +++ b/examples/src/bin/multicore.rs @@ -4,6 +4,7 @@ //! second core. //% CHIPS: esp32 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -11,6 +12,7 @@ use core::cell::RefCell; use critical_section::Mutex; +use embedded_hal_02::timer::CountDown; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/psram.rs b/examples/src/bin/psram.rs index cc369fad867..c7ba179c306 100644 --- a/examples/src/bin/psram.rs +++ b/examples/src/bin/psram.rs @@ -13,12 +13,7 @@ extern crate alloc; use alloc::{string::String, vec::Vec}; use esp_backtrace as _; -use esp_hal::{ - clock::{ClockControl, CpuClock}, - peripherals::Peripherals, - prelude::*, - psram, -}; +use esp_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, psram}; use esp_println::println; #[global_allocator] diff --git a/examples/src/bin/ram.rs b/examples/src/bin/ram.rs index 41f251b7819..1307510d48a 100644 --- a/examples/src/bin/ram.rs +++ b/examples/src/bin/ram.rs @@ -12,10 +12,12 @@ //! We can also run code from RTC memory. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::timer::CountDown; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/rmt_rx.rs b/examples/src/bin/rmt_rx.rs index 220e394c0e9..04bd3e9a5e1 100644 --- a/examples/src/bin/rmt_rx.rs +++ b/examples/src/bin/rmt_rx.rs @@ -2,10 +2,12 @@ //! Connect GPIO5 to GPIO4 //% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::digital::v2::OutputPin; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/rng.rs b/examples/src/bin/rng.rs index 0d86ae70a4f..4dbb0f80c64 100644 --- a/examples/src/bin/rng.rs +++ b/examples/src/bin/rng.rs @@ -1,10 +1,12 @@ //! Demonstrates the use of the hardware Random Number Generator (RNG) //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::blocking::rng::Read; use esp_backtrace as _; use esp_hal::{peripherals::Peripherals, prelude::*, rng::Rng}; use esp_println::println; diff --git a/examples/src/bin/rtc_watchdog.rs b/examples/src/bin/rtc_watchdog.rs index 0927d00046d..320ff60c0a0 100644 --- a/examples/src/bin/rtc_watchdog.rs +++ b/examples/src/bin/rtc_watchdog.rs @@ -5,6 +5,7 @@ //! to reset both the main system and the RTC. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -12,6 +13,7 @@ use core::cell::RefCell; use critical_section::Mutex; +use embedded_hal_02::watchdog::WatchdogEnable; use esp_backtrace as _; use esp_hal::{ interrupt::{self, Priority}, diff --git a/examples/src/bin/serial_interrupts.rs b/examples/src/bin/serial_interrupts.rs index 0a73757c62d..1f847420dbc 100644 --- a/examples/src/bin/serial_interrupts.rs +++ b/examples/src/bin/serial_interrupts.rs @@ -3,6 +3,7 @@ //! espflash won't work) //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -10,6 +11,7 @@ use core::{cell::RefCell, fmt::Write}; use critical_section::Mutex; +use embedded_hal_02::{serial::Read, timer::CountDown}; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/sleep_timer_ext0.rs b/examples/src/bin/sleep_timer_ext0.rs index 60761dbce1f..a5442aecd56 100644 --- a/examples/src/bin/sleep_timer_ext0.rs +++ b/examples/src/bin/sleep_timer_ext0.rs @@ -43,11 +43,11 @@ fn main() -> ! { let wake_reason = get_wakeup_cause(); println!("wake reason: {:?}", wake_reason); - let delay = Delay::new(&clocks); + let mut delay = Delay::new(&clocks); let timer = TimerWakeupSource::new(Duration::from_secs(30)); let ext0 = Ext0WakeupSource::new(&mut ext0_pin, WakeupLevel::High); println!("sleeping!"); delay.delay_millis(100u32); - rtc.sleep_deep(&[&timer, &ext0], &delay); + rtc.sleep_deep(&[&timer, &ext0], &mut delay); } diff --git a/examples/src/bin/sleep_timer_ext1.rs b/examples/src/bin/sleep_timer_ext1.rs index 1ae1ec97a36..f0e8ad253c1 100644 --- a/examples/src/bin/sleep_timer_ext1.rs +++ b/examples/src/bin/sleep_timer_ext1.rs @@ -44,12 +44,12 @@ fn main() -> ! { let wake_reason = get_wakeup_cause(); println!("wake reason: {:?}", wake_reason); - let delay = Delay::new(&clocks); + let mut delay = Delay::new(&clocks); let timer = TimerWakeupSource::new(Duration::from_secs(30)); let mut wakeup_pins: [&mut dyn RTCPin; 2] = [&mut pin_0, &mut pin_2]; let ext1 = Ext1WakeupSource::new(&mut wakeup_pins, WakeupLevel::High); println!("sleeping!"); delay.delay_millis(100u32); - rtc.sleep_deep(&[&timer, &ext1], &delay); + rtc.sleep_deep(&[&timer, &ext1], &mut delay); } diff --git a/examples/src/bin/sleep_timer_rtcio.rs b/examples/src/bin/sleep_timer_rtcio.rs index 9ca7b23f679..c989337bebd 100644 --- a/examples/src/bin/sleep_timer_rtcio.rs +++ b/examples/src/bin/sleep_timer_rtcio.rs @@ -43,7 +43,7 @@ fn main() -> ! { let wake_reason = get_wakeup_cause(); println!("wake reason: {:?}", wake_reason); - let delay = Delay::new(&clocks); + let mut delay = Delay::new(&clocks); let timer = TimerWakeupSource::new(Duration::from_secs(10)); #[cfg(feature = "esp32c3")] @@ -59,5 +59,5 @@ fn main() -> ! { let rtcio = RtcioWakeupSource::new(wakeup_pins); println!("sleeping!"); delay.delay_millis(100u32); - rtc.sleep_deep(&[&timer, &rtcio], &delay); + rtc.sleep_deep(&[&timer, &rtcio], &mut delay); } diff --git a/examples/src/bin/spi_loopback.rs b/examples/src/bin/spi_loopback.rs index 337e1e33ac2..084c528cfb2 100644 --- a/examples/src/bin/spi_loopback.rs +++ b/examples/src/bin/spi_loopback.rs @@ -14,10 +14,12 @@ //! data. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::blocking::spi::Transfer; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/spi_slave_dma.rs b/examples/src/bin/spi_slave_dma.rs index 9ba851e6f61..8d9228a8648 100644 --- a/examples/src/bin/spi_slave_dma.rs +++ b/examples/src/bin/spi_slave_dma.rs @@ -24,10 +24,12 @@ //! so no immediate neighbor is available. //% CHIPS: esp32c2 esp32c3 esp32c6 esp32h2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::digital::v2::{InputPin, OutputPin}; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/timer_interrupt.rs b/examples/src/bin/timer_interrupt.rs index 62e4194f94a..5e97e0cdbac 100644 --- a/examples/src/bin/timer_interrupt.rs +++ b/examples/src/bin/timer_interrupt.rs @@ -3,6 +3,7 @@ //! There is TIMG0 which contains a general purpose timer and a watchdog timer. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -10,6 +11,7 @@ use core::cell::RefCell; use critical_section::Mutex; +use embedded_hal_02::timer::CountDown; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/twai.rs b/examples/src/bin/twai.rs index 0ca79a7299a..1808998e812 100644 --- a/examples/src/bin/twai.rs +++ b/examples/src/bin/twai.rs @@ -18,14 +18,14 @@ const IS_FIRST_SENDER: bool = true; -// Run this example with the eh1 feature enabled to use embedded-can instead of +// Run this example with the embedded-hal feature enabled to use embedded-can instead of // embedded-hal-0.2.7. embedded-can was split off from embedded-hal before it's -// upgrade to 1.0.0. cargo run --example twai --features eh1 --release -#[cfg(feature = "eh1")] +// upgrade to 1.0.0. cargo run --example twai --features embedded-hal --release +#[cfg(feature = "embedded-hal")] use embedded_can::{nb::Can, Frame, StandardId}; -// Run this example without the eh1 flag to use the embedded-hal 0.2.7 CAN traits. +// Run this example without the embedded-hal flag to use the embedded-hal 0.2.7 CAN traits. // cargo run --example twai --release -#[cfg(not(feature = "eh1"))] +#[cfg(not(feature = "embedded-hal"))] use embedded_hal_02::can::{Can, Frame, StandardId}; use esp_backtrace as _; use esp_hal::{ diff --git a/examples/src/bin/usb_serial_jtag.rs b/examples/src/bin/usb_serial_jtag.rs index 1e884febf99..ebde03f4ddc 100644 --- a/examples/src/bin/usb_serial_jtag.rs +++ b/examples/src/bin/usb_serial_jtag.rs @@ -4,6 +4,7 @@ //! Most dev-kits use a USB-UART-bridge - in that case you won't see any output. //% CHIPS: esp32c3 esp32c6 esp32h2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] @@ -11,6 +12,7 @@ use core::{cell::RefCell, fmt::Write}; use critical_section::Mutex; +use embedded_hal_02::timer::CountDown; use esp_backtrace as _; use esp_hal::{ clock::ClockControl, diff --git a/examples/src/bin/watchdog.rs b/examples/src/bin/watchdog.rs index 12f07e707e7..b55bc786233 100644 --- a/examples/src/bin/watchdog.rs +++ b/examples/src/bin/watchdog.rs @@ -4,10 +4,15 @@ //! `wdt.feed()` the watchdog will reset the system. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: embedded-hal-02 #![no_std] #![no_main] +use embedded_hal_02::{ + timer::CountDown, + watchdog::{Watchdog, WatchdogEnable}, +}; use esp_backtrace as _; use esp_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup}; use esp_println::println; From 0eb1a8491c7396fbd50a13a48d29a9888443614a Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Tue, 12 Mar 2024 10:49:56 -0700 Subject: [PATCH 4/4] Update `CHANGELOG.md` --- esp-hal/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 24f0b800884..cf5ee74c4df 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Prefer mutable references over moving for DMA transactions (#1238) - Support runtime interrupt binding, adapt GPIO driver (#1231) +- Renamed `eh1` feature to `embedded-hal`, feature-gated `embedded-hal@0.2.x` trait implementations (#1273) ### Removed