From 273162b29e9c24fa8f42e499f80959240c3e5264 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Mon, 26 Sep 2022 12:12:51 -0700 Subject: [PATCH 1/6] Add the peripheral module plus some helper macros in preparation --- esp-hal-common/src/lib.rs | 58 ++++++- esp-hal-common/src/peripheral.rs | 186 ++++++++++++++++++++++ esp-hal-common/src/{serial.rs => uart.rs} | 0 3 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 esp-hal-common/src/peripheral.rs rename esp-hal-common/src/{serial.rs => uart.rs} (100%) diff --git a/esp-hal-common/src/lib.rs b/esp-hal-common/src/lib.rs index 53971c79d9e..4fa994618db 100644 --- a/esp-hal-common/src/lib.rs +++ b/esp-hal-common/src/lib.rs @@ -43,7 +43,7 @@ pub use self::{ interrupt::*, rng::Rng, rtc_cntl::{Rtc, Rwdt}, - serial::Serial, + uart::Serial, spi::Spi, timer::Timer, }; @@ -63,14 +63,15 @@ pub mod ledc; pub mod mcpwm; #[cfg(usb_otg)] pub mod otg_fs; +pub mod peripheral; pub mod prelude; #[cfg(rmt)] pub mod pulse_control; pub mod rng; pub mod rom; pub mod rtc_cntl; -pub mod serial; pub mod sha; +pub mod uart; pub mod spi; pub mod system; #[cfg(systimer)] @@ -236,3 +237,56 @@ mod critical_section_impl { } } } + +#[macro_export] +#[allow(unused_macros)] +macro_rules! into_ref { + ($($name:ident),*) => { + $( + let $name = $name.into_ref(); + )* + } +} + +#[allow(unused_macros)] +macro_rules! impl_peripheral_trait { + ($type:ident) => { + unsafe impl Send for $type {} + + impl $crate::peripheral::sealed::Sealed for $type {} + + impl $crate::peripheral::Peripheral for $type { + type P = $type; + + #[inline] + unsafe fn clone_unchecked(&mut self) -> Self::P { + $type { ..*self } + } + } + }; +} + +#[allow(unused_macros)] +macro_rules! impl_peripheral { + ($type:ident) => { + pub struct $type(::core::marker::PhantomData<*const ()>); + + impl $type { + /// # Safety + /// + /// Care should be taken not to instnatiate this peripheral instance, if it + /// is already instantiated and used elsewhere + #[inline(always)] + pub unsafe fn new() -> Self { + $type(::core::marker::PhantomData) + } + } + + $crate::impl_peripheral_trait!($type); + }; +} + +#[allow(unused_imports)] +pub(crate) use impl_peripheral; +#[allow(unused_imports)] +pub(crate) use impl_peripheral_trait; diff --git a/esp-hal-common/src/peripheral.rs b/esp-hal-common/src/peripheral.rs new file mode 100644 index 00000000000..167a7477b02 --- /dev/null +++ b/esp-hal-common/src/peripheral.rs @@ -0,0 +1,186 @@ +use core::{ + marker::PhantomData, + ops::{Deref, DerefMut}, +}; + +/// An exclusive reference to a peripheral. +/// +/// This is functionally the same as a `&'a mut T`. The reason for having a +/// dedicated struct is memory efficiency: +/// +/// Peripheral singletons are typically either zero-sized (for concrete +/// peripehrals like `PA9` or `Spi4`) or very small (for example `AnyPin` which +/// is 1 byte). However `&mut T` is always 4 bytes for 32-bit targets, even if T +/// is zero-sized. PeripheralRef stores a copy of `T` instead, so it's the same +/// size. +/// +/// but it is the size of `T` not the size +/// of a pointer. This is useful if T is a zero sized type. +pub struct PeripheralRef<'a, T> { + inner: T, + _lifetime: PhantomData<&'a mut T>, +} + +impl<'a, T> PeripheralRef<'a, T> { + #[inline] + pub fn new(inner: T) -> Self { + Self { + inner, + _lifetime: PhantomData, + } + } + + /// Unsafely clone (duplicate) a peripheral singleton. + /// + /// # Safety + /// + /// This returns an owned clone of the peripheral. You must manually ensure + /// only one copy of the peripheral is in use at a time. For example, don't + /// create two SPI drivers on `SPI1`, because they will "fight" each other. + /// + /// You should strongly prefer using `reborrow()` instead. It returns a + /// `PeripheralRef` that borrows `self`, which allows the borrow checker + /// to enforce this at compile time. + pub unsafe fn clone_unchecked(&mut self) -> PeripheralRef<'a, T> + where + T: Peripheral

, + { + PeripheralRef::new(self.inner.clone_unchecked()) + } + + /// Reborrow into a "child" PeripheralRef. + /// + /// `self` will stay borrowed until the child PeripheralRef is dropped. + pub fn reborrow(&mut self) -> PeripheralRef<'_, T> + where + T: Peripheral

, + { + // safety: we're returning the clone inside a new PeripheralRef that borrows + // self, so user code can't use both at the same time. + PeripheralRef::new(unsafe { self.inner.clone_unchecked() }) + } + + /// Map the inner peripheral using `Into`. + /// + /// This converts from `PeripheralRef<'a, T>` to `PeripheralRef<'a, U>`, + /// using an `Into` impl to convert from `T` to `U`. + /// + /// For example, this can be useful to degrade GPIO pins: converting from + /// PeripheralRef<'a, PB11>` to `PeripheralRef<'a, AnyPin>`. + #[inline] + pub fn map_into(self) -> PeripheralRef<'a, U> + where + T: Into, + { + PeripheralRef { + inner: self.inner.into(), + _lifetime: PhantomData, + } + } +} + +impl<'a, T> Deref for PeripheralRef<'a, T> { + type Target = T; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl<'a, T> DerefMut for PeripheralRef<'a, T> { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} + +/// Trait for any type that can be used as a peripheral of type `P`. +/// +/// This is used in driver constructors, to allow passing either owned +/// peripherals (e.g. `TWISPI0`), or borrowed peripherals (e.g. `&mut TWISPI0`). +/// +/// For example, if you have a driver with a constructor like this: +/// +/// ```ignore +/// impl<'d, T: Instance> Twim<'d, T> { +/// pub fn new( +/// twim: impl Peripheral

+ 'd, +/// irq: impl Peripheral

+ 'd, +/// sda: impl Peripheral

+ 'd, +/// scl: impl Peripheral

+ 'd, +/// config: Config, +/// ) -> Self { .. } +/// } +/// ``` +/// +/// You may call it with owned peripherals, which yields an instance that can +/// live forever (`'static`): +/// +/// ```ignore +/// let mut twi: Twim<'static, ...> = Twim::new(p.TWISPI0, irq, p.P0_03, p.P0_04, config); +/// ``` +/// +/// Or you may call it with borrowed peripherals, which yields an instance that +/// can only live for as long as the borrows last: +/// +/// ```ignore +/// let mut twi: Twim<'_, ...> = Twim::new(&mut p.TWISPI0, &mut irq, &mut p.P0_03, &mut p.P0_04, config); +/// ``` +/// +/// # Implementation details, for HAL authors +/// +/// When writing a HAL, the intended way to use this trait is to take `impl +/// Peripheral

` in the HAL's public API (such as driver constructors), +/// calling `.into_ref()` to obtain a `PeripheralRef`, and storing that in the +/// driver struct. +/// +/// `.into_ref()` on an owned `T` yields a `PeripheralRef<'static, T>`. +/// `.into_ref()` on an `&'a mut T` yields a `PeripheralRef<'a, T>`. +pub trait Peripheral: Sized + sealed::Sealed { + /// Peripheral singleton type + type P; + + /// Unsafely clone (duplicate) a peripheral singleton. + /// + /// # Safety + /// + /// This returns an owned clone of the peripheral. You must manually ensure + /// only one copy of the peripheral is in use at a time. For example, don't + /// create two SPI drivers on `SPI1`, because they will "fight" each other. + /// + /// You should strongly prefer using `into_ref()` instead. It returns a + /// `PeripheralRef`, which allows the borrow checker to enforce this at + /// compile time. + unsafe fn clone_unchecked(&mut self) -> Self::P; + + /// Convert a value into a `PeripheralRef`. + /// + /// When called on an owned `T`, yields a `PeripheralRef<'static, T>`. + /// When called on an `&'a mut T`, yields a `PeripheralRef<'a, T>`. + #[inline] + fn into_ref<'a>(mut self) -> PeripheralRef<'a, Self::P> + where + Self: 'a, + { + PeripheralRef::new(unsafe { self.clone_unchecked() }) + } +} + +impl sealed::Sealed for T {} + +impl Peripheral for T +where + T::Target: Peripheral, +{ + type P = ::P; + + #[inline] + unsafe fn clone_unchecked(&mut self) -> Self::P { + self.deref_mut().clone_unchecked() + } +} + +pub(crate) mod sealed { + pub trait Sealed {} +} diff --git a/esp-hal-common/src/serial.rs b/esp-hal-common/src/uart.rs similarity index 100% rename from esp-hal-common/src/serial.rs rename to esp-hal-common/src/uart.rs From 080f4aef66b4b88f478f0c8f0961f559555abed4 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Fri, 11 Nov 2022 17:42:00 +0000 Subject: [PATCH 2/6] peripheral macro * Add peripheral generation macro --- esp-hal-common/src/lib.rs | 73 ++------ esp-hal-common/src/peripheral.rs | 156 ++++++++++++++++-- esp-hal-common/src/peripherals/esp32.rs | 59 +++++++ esp-hal-common/src/peripherals/esp32c2.rs | 41 +++++ esp-hal-common/src/peripherals/esp32c3.rs | 52 ++++++ esp-hal-common/src/peripherals/esp32s2.rs | 56 +++++++ esp-hal-common/src/peripherals/esp32s3.rs | 67 ++++++++ esp-hal-common/src/uart.rs | 41 +++-- esp-hal-procmacros/src/lib.rs | 2 +- esp32-hal/examples/adc.rs | 2 +- esp32-hal/examples/advanced_serial.rs | 8 +- esp32-hal/examples/blinky.rs | 2 +- esp32-hal/examples/clock_monitor.rs | 4 +- esp32-hal/examples/dac.rs | 2 +- esp32-hal/examples/gpio_interrupt.rs | 4 +- esp32-hal/examples/hello_rgb.rs | 2 +- esp32-hal/examples/hello_world.rs | 6 +- esp32-hal/examples/i2c_display.rs | 2 +- esp32-hal/examples/ledc.rs | 2 +- esp32-hal/examples/multicore.rs | 2 +- esp32-hal/examples/pulse_control.rs | 2 +- esp32-hal/examples/ram.rs | 2 +- esp32-hal/examples/read_efuse.rs | 2 +- esp32-hal/examples/rtc_watchdog.rs | 4 +- esp32-hal/examples/serial_interrupts.rs | 12 +- esp32-hal/examples/spi_eh1_device_loopback.rs | 2 +- esp32-hal/examples/spi_eh1_loopback.rs | 2 +- esp32-hal/examples/spi_loopback.rs | 2 +- esp32-hal/examples/spi_loopback_dma.rs | 2 +- esp32-hal/examples/timer_interrupt.rs | 10 +- esp32-hal/examples/watchdog.rs | 2 +- esp32-hal/src/lib.rs | 8 +- esp32c2-hal/examples/adc.rs | 2 +- esp32c2-hal/examples/advanced_serial.rs | 8 +- esp32c2-hal/examples/blinky.rs | 2 +- esp32c2-hal/examples/clock_monitor.rs | 4 +- esp32c2-hal/examples/gpio_interrupt.rs | 4 +- esp32c2-hal/examples/hello_world.rs | 6 +- esp32c2-hal/examples/i2c_display.rs | 2 +- esp32c2-hal/examples/ledc.rs | 2 +- esp32c2-hal/examples/read_efuse.rs | 2 +- esp32c2-hal/examples/rtc_watchdog.rs | 4 +- esp32c2-hal/examples/serial_interrupts.rs | 12 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32c2-hal/examples/spi_eh1_loopback.rs | 2 +- esp32c2-hal/examples/spi_loopback.rs | 2 +- esp32c2-hal/examples/spi_loopback_dma.rs | 2 +- esp32c2-hal/examples/systimer.rs | 8 +- esp32c2-hal/examples/timer_interrupt.rs | 4 +- esp32c2-hal/examples/watchdog.rs | 2 +- esp32c2-hal/src/lib.rs | 8 +- esp32c3-hal/examples/adc.rs | 2 +- esp32c3-hal/examples/advanced_serial.rs | 8 +- esp32c3-hal/examples/blinky.rs | 2 +- esp32c3-hal/examples/clock_monitor.rs | 4 +- esp32c3-hal/examples/gpio_interrupt.rs | 4 +- esp32c3-hal/examples/hello_rgb.rs | 2 +- esp32c3-hal/examples/hello_world.rs | 16 +- esp32c3-hal/examples/i2c_display.rs | 2 +- esp32c3-hal/examples/ledc.rs | 2 +- esp32c3-hal/examples/pulse_control.rs | 2 +- esp32c3-hal/examples/ram.rs | 2 +- esp32c3-hal/examples/read_efuse.rs | 2 +- esp32c3-hal/examples/rtc_watchdog.rs | 4 +- esp32c3-hal/examples/serial_interrupts.rs | 12 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32c3-hal/examples/spi_eh1_loopback.rs | 2 +- esp32c3-hal/examples/spi_loopback.rs | 2 +- esp32c3-hal/examples/spi_loopback_dma.rs | 2 +- esp32c3-hal/examples/systimer.rs | 8 +- esp32c3-hal/examples/timer_interrupt.rs | 6 +- esp32c3-hal/examples/usb_serial_jtag.rs | 3 +- esp32c3-hal/examples/watchdog.rs | 2 +- esp32c3-hal/src/lib.rs | 8 +- esp32s2-hal/examples/adc.rs | 2 +- esp32s2-hal/examples/advanced_serial.rs | 8 +- esp32s2-hal/examples/blinky.rs | 2 +- esp32s2-hal/examples/clock_monitor.rs | 4 +- esp32s2-hal/examples/dac.rs | 2 +- esp32s2-hal/examples/gpio_interrupt.rs | 4 +- esp32s2-hal/examples/hello_rgb.rs | 2 +- esp32s2-hal/examples/hello_world.rs | 6 +- esp32s2-hal/examples/i2c_display.rs | 2 +- esp32s2-hal/examples/ledc.rs | 2 +- esp32s2-hal/examples/pulse_control.rs | 2 +- esp32s2-hal/examples/ram.rs | 2 +- esp32s2-hal/examples/read_efuse.rs | 2 +- esp32s2-hal/examples/rtc_watchdog.rs | 4 +- esp32s2-hal/examples/serial_interrupts.rs | 12 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32s2-hal/examples/spi_eh1_loopback.rs | 2 +- esp32s2-hal/examples/spi_loopback.rs | 2 +- esp32s2-hal/examples/spi_loopback_dma.rs | 2 +- esp32s2-hal/examples/systimer.rs | 8 +- esp32s2-hal/examples/timer_interrupt.rs | 10 +- esp32s2-hal/examples/usb_serial.rs | 2 +- esp32s2-hal/examples/watchdog.rs | 2 +- esp32s2-hal/src/lib.rs | 8 +- esp32s3-hal/examples/adc.rs | 2 +- esp32s3-hal/examples/advanced_serial.rs | 8 +- esp32s3-hal/examples/blinky.rs | 2 +- esp32s3-hal/examples/clock_monitor.rs | 4 +- esp32s3-hal/examples/gpio_interrupt.rs | 4 +- esp32s3-hal/examples/hello_rgb.rs | 2 +- esp32s3-hal/examples/hello_world.rs | 6 +- esp32s3-hal/examples/i2c_display.rs | 8 +- esp32s3-hal/examples/ledc.rs | 2 +- esp32s3-hal/examples/multicore.rs | 2 +- esp32s3-hal/examples/pulse_control.rs | 2 +- esp32s3-hal/examples/ram.rs | 2 +- esp32s3-hal/examples/read_efuse.rs | 2 +- esp32s3-hal/examples/rtc_watchdog.rs | 4 +- esp32s3-hal/examples/serial_interrupts.rs | 12 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32s3-hal/examples/spi_eh1_loopback.rs | 2 +- esp32s3-hal/examples/spi_loopback.rs | 2 +- esp32s3-hal/examples/spi_loopback_dma.rs | 2 +- esp32s3-hal/examples/systimer.rs | 8 +- esp32s3-hal/examples/timer_interrupt.rs | 10 +- esp32s3-hal/examples/usb_serial.rs | 2 +- esp32s3-hal/examples/usb_serial_jtag.rs | 3 +- esp32s3-hal/examples/watchdog.rs | 2 +- esp32s3-hal/src/lib.rs | 8 +- 123 files changed, 691 insertions(+), 316 deletions(-) create mode 100644 esp-hal-common/src/peripherals/esp32.rs create mode 100644 esp-hal-common/src/peripherals/esp32c2.rs create mode 100644 esp-hal-common/src/peripherals/esp32c3.rs create mode 100644 esp-hal-common/src/peripherals/esp32s2.rs create mode 100644 esp-hal-common/src/peripherals/esp32s3.rs diff --git a/esp-hal-common/src/lib.rs b/esp-hal-common/src/lib.rs index 4fa994618db..1335a111aff 100644 --- a/esp-hal-common/src/lib.rs +++ b/esp-hal-common/src/lib.rs @@ -22,15 +22,23 @@ #![cfg_attr(xtensa, feature(asm_experimental_arch))] #[cfg(esp32)] -pub use esp32 as pac; +pub(crate) use esp32 as pac; #[cfg(esp32c2)] -pub use esp32c2 as pac; +pub(crate) use esp32c2 as pac; #[cfg(esp32c3)] -pub use esp32c3 as pac; +pub(crate) use esp32c3 as pac; #[cfg(esp32s2)] -pub use esp32s2 as pac; +pub(crate) use esp32s2 as pac; #[cfg(esp32s3)] -pub use esp32s3 as pac; +pub(crate) use esp32s3 as pac; + +#[cfg_attr(esp32, path = "peripherals/esp32.rs")] +#[cfg_attr(esp32c3, path = "peripherals/esp32c3.rs")] +#[cfg_attr(esp32c2, path = "peripherals/esp32c2.rs")] +#[cfg_attr(esp32s2, path = "peripherals/esp32s2.rs")] +#[cfg_attr(esp32s3, path = "peripherals/esp32s3.rs")] +pub mod peripherals; + pub use procmacros as macros; #[cfg(rmt)] @@ -43,7 +51,7 @@ pub use self::{ interrupt::*, rng::Rng, rtc_cntl::{Rtc, Rwdt}, - uart::Serial, + uart::Uart, spi::Spi, timer::Timer, }; @@ -237,56 +245,3 @@ mod critical_section_impl { } } } - -#[macro_export] -#[allow(unused_macros)] -macro_rules! into_ref { - ($($name:ident),*) => { - $( - let $name = $name.into_ref(); - )* - } -} - -#[allow(unused_macros)] -macro_rules! impl_peripheral_trait { - ($type:ident) => { - unsafe impl Send for $type {} - - impl $crate::peripheral::sealed::Sealed for $type {} - - impl $crate::peripheral::Peripheral for $type { - type P = $type; - - #[inline] - unsafe fn clone_unchecked(&mut self) -> Self::P { - $type { ..*self } - } - } - }; -} - -#[allow(unused_macros)] -macro_rules! impl_peripheral { - ($type:ident) => { - pub struct $type(::core::marker::PhantomData<*const ()>); - - impl $type { - /// # Safety - /// - /// Care should be taken not to instnatiate this peripheral instance, if it - /// is already instantiated and used elsewhere - #[inline(always)] - pub unsafe fn new() -> Self { - $type(::core::marker::PhantomData) - } - } - - $crate::impl_peripheral_trait!($type); - }; -} - -#[allow(unused_imports)] -pub(crate) use impl_peripheral; -#[allow(unused_imports)] -pub(crate) use impl_peripheral_trait; diff --git a/esp-hal-common/src/peripheral.rs b/esp-hal-common/src/peripheral.rs index 167a7477b02..41a364856fb 100644 --- a/esp-hal-common/src/peripheral.rs +++ b/esp-hal-common/src/peripheral.rs @@ -169,18 +169,152 @@ pub trait Peripheral: Sized + sealed::Sealed { impl sealed::Sealed for T {} -impl Peripheral for T -where - T::Target: Peripheral, -{ - type P = ::P; +pub(crate) mod sealed { + pub trait Sealed {} +} - #[inline] - unsafe fn clone_unchecked(&mut self) -> Self::P { - self.deref_mut().clone_unchecked() +mod peripheral_macros { + #[macro_export] + macro_rules! peripherals { + ($($(#[$cfg:meta])? $name:ident),*$(,)?) => { + #[allow(non_snake_case)] + pub struct Peripherals { + $( + $(#[$cfg])? + pub $name: peripherals::$name, + )* + } + + impl Peripherals { + // /// Returns all the peripherals *once* + // #[inline] + // pub fn take() -> Self { + + // #[no_mangle] + // static mut _ESP_HAL_DEVICE_PERIPHERALS: bool = false; + + // critical_section::with(|_| unsafe { + // if _ESP_HAL_DEVICE_PERIPHERALS { + // panic!("init called more than once!") + // } + // _ESP_HAL_DEVICE_PERIPHERALS = true; + // Self::steal() + // }) + // } + + pub fn take() -> Option { + #[no_mangle] + static mut _ESP_HAL_DEVICE_PERIPHERALS: bool = false; + critical_section::with(|_| unsafe { + if _ESP_HAL_DEVICE_PERIPHERALS { + return None; + } + _ESP_HAL_DEVICE_PERIPHERALS = true; + Some(Peripherals::steal()) + }) + } + } + + impl Peripherals { + /// Unsafely create an instance of this peripheral out of thin air. + /// + /// # Safety + /// + /// You must ensure that you're only using one instance of this type at a time. + #[inline] + pub unsafe fn steal() -> Self { + Self { + $( + $(#[$cfg])? + // $name: peripherals::$name::steal(), // FIXME add this back once we have removed pac::Peripherals completely + $name: unsafe { core::mem::zeroed() }, // this is well defined for zero sized types: https://github.com/rust-lang/unsafe-code-guidelines/issues/250 + )* + } + } + } + + // expose the new structs + $( + pub use peripherals::$name; + )* + } } -} -pub(crate) mod sealed { - pub trait Sealed {} + #[macro_export] + macro_rules! create_peripherals { + ($($(#[$cfg:meta])? $name:ident),*$(,)?) => { + $( + $(#[$cfg])? + #[derive(Debug)] + #[allow(non_camel_case_types)] + pub struct $name { _inner: () } + + $(#[$cfg])? + impl $name { + /// Unsafely create an instance of this peripheral out of thin air. + /// + /// # Safety + /// + /// You must ensure that you're only using one instance of this type at a time. + #[inline] + pub unsafe fn steal() -> Self { + Self { _inner: () } + } + + #[doc = r"Pointer to the register block"] + pub const PTR: *const ::Target = super::pac::$name::PTR; + + #[doc = r"Return the pointer to the register block"] + #[inline(always)] + pub const fn ptr() -> *const ::Target { + super::pac::$name::PTR + } + } + + impl core::ops::Deref for $name { + type Target = ::Target; + + fn deref(&self) -> &Self::Target { + unsafe { &*Self::PTR } + } + } + + impl core::ops::DerefMut for $name { + + fn deref_mut(&mut self) -> &mut Self::Target { + unsafe { &mut *(Self::PTR as *mut _) } + } + } + + impl crate::peripheral::Peripheral for $name { + type P = $name; + + #[inline] + unsafe fn clone_unchecked(&mut self) -> Self::P { + Self::steal() + } + } + + impl crate::peripheral::Peripheral for &mut $name { + type P = $name; + + #[inline] + unsafe fn clone_unchecked(&mut self) -> Self::P { + $name::steal() + } + } + + + )* + } + } + + #[macro_export] + macro_rules! into_ref { + ($($name:ident),*) => { + $( + let $name = $name.into_ref(); + )* + } +} } diff --git a/esp-hal-common/src/peripherals/esp32.rs b/esp-hal-common/src/peripherals/esp32.rs new file mode 100644 index 00000000000..4ac0c1a17c1 --- /dev/null +++ b/esp-hal-common/src/peripherals/esp32.rs @@ -0,0 +1,59 @@ + +use crate::pac; + +pub use pac::Interrupt; // We need to export this for users to use + +crate::peripherals! { + AES, + APB_CTRL, + BB, + DPORT, + EFUSE, + FLASH_ENCRYPTION, + FRC_TIMER, + GPIO, + GPIO_SD, + HINF, + I2C0, + I2C1, + I2S0, + I2S1, + IO_MUX, + LEDC, + PWM0, + PWM1, + NRX, + PCNT, + RMT, + RNG, + RSA, + RTC_CNTL, + RTCIO, + RTC_I2C, + SDMMC, + SENS, + SHA, + SLC, + SLCHOST, + SPI0, + SPI1, + SPI2, + SPI3, + TIMG0, + TIMG1, + TWAI, + UART0, + UART1, + UART2, + UHCI0, + UHCI1, +} + +mod peripherals { + pub use super::pac::*; + + crate::create_peripherals! { + UART0, + UART1, + } +} diff --git a/esp-hal-common/src/peripherals/esp32c2.rs b/esp-hal-common/src/peripherals/esp32c2.rs new file mode 100644 index 00000000000..efde9bbbcb8 --- /dev/null +++ b/esp-hal-common/src/peripherals/esp32c2.rs @@ -0,0 +1,41 @@ + +use crate::pac; + +pub use pac::Interrupt; // We need to export this for users to use + +crate::peripherals! { + APB_CTRL, + APB_SARADC, + ASSIST_DEBUG, + DMA, + ECC, + EFUSE, + EXTMEM, + GPIO, + I2C0, + INTERRUPT_CORE0, + IO_MUX, + LEDC, + RNG, + RTC_CNTL, + SENSITIVE, + SHA, + SPI0, + SPI1, + SPI2, + SYSTEM, + SYSTIMER, + TIMG0, + UART0, + UART1, + XTS_AES, +} + +mod peripherals { + pub use super::pac::*; + + crate::create_peripherals! { + UART0, + UART1, + } +} diff --git a/esp-hal-common/src/peripherals/esp32c3.rs b/esp-hal-common/src/peripherals/esp32c3.rs new file mode 100644 index 00000000000..5ec07bd663d --- /dev/null +++ b/esp-hal-common/src/peripherals/esp32c3.rs @@ -0,0 +1,52 @@ + +use crate::pac; + +pub use pac::Interrupt; // We need to export this for users to use + +crate::peripherals! { + AES, + APB_CTRL, + APB_SARADC, + ASSIST_DEBUG, + DMA, + DS, + EFUSE, + EXTMEM, + GPIO, + GPIOSD, + HMAC, + I2C0, + I2S, + INTERRUPT_CORE0, + IO_MUX, + LEDC, + RMT, + RNG, + RSA, + RTC_CNTL, + SENSITIVE, + SHA, + SPI0, + SPI1, + SPI2, + SYSTEM, + SYSTIMER, + TIMG0, + TIMG1, + TWAI, + UART0, + UART1, + UHCI0, + UHCI1, + USB_DEVICE, + XTS_AES, +} + +mod peripherals { + pub use super::pac::*; + + crate::create_peripherals! { + UART0, + UART1, + } +} diff --git a/esp-hal-common/src/peripherals/esp32s2.rs b/esp-hal-common/src/peripherals/esp32s2.rs new file mode 100644 index 00000000000..7bccc792218 --- /dev/null +++ b/esp-hal-common/src/peripherals/esp32s2.rs @@ -0,0 +1,56 @@ +pub use pac::Interrupt; + +use crate::pac; // We need to export this for users to use + +crate::peripherals! { + AES, + APB_SARADC, + DEDICATED_GPIO, + DS, + EFUSE, + EXTMEM, + GPIO, + GPIO_SD, + HMAC, + I2C0, + I2C1, + I2S, + INTERRUPT, + IO_MUX, + LEDC, + PCNT, + PMS, + RMT, + RNG, + RSA, + RTCIO, + RTC_CNTL, + RTC_I2C, + SENS, + SHA, + SPI0, + SPI1, + SPI2, + SPI3, + SPI4, + SYSTEM, + SYSTIMER, + TIMG0, + TIMG1, + TWAI, + UART0, + UART1, + UHCI0, + USB0, + USB_WRAP, + XTS_AES, +} + +mod peripherals { + pub use super::pac::*; + + crate::create_peripherals! { + UART0, + UART1, + } +} diff --git a/esp-hal-common/src/peripherals/esp32s3.rs b/esp-hal-common/src/peripherals/esp32s3.rs new file mode 100644 index 00000000000..8edfe1f417c --- /dev/null +++ b/esp-hal-common/src/peripherals/esp32s3.rs @@ -0,0 +1,67 @@ +pub use pac::Interrupt; + +use crate::pac; // We need to export this for users to use + +crate::peripherals! { + AES, + APB_CTRL, + APB_SARADC, + DEBUG_ASSIST, + DMA, + DS, + EFUSE, + EXTMEM, + GPIO, + GPIOSD, + HMAC, + I2C0, + I2C1, + I2S0, + I2S1, + INTERRUPT_CORE0, + INTERRUPT_CORE1, + IO_MUX, + LCD_CAM, + LEDC, + PCNT, + PERI_BACKUP, + PWM0, + PWM1, + RMT, + RNG, + RSA, + RTC_CNTL, + RTC_I2C, + RTCIO, + SENS, + SENSITIVE, + SHA, + SPI0, + SPI1, + SPI2, + SPI3, + SYSTEM, + SYSTIMER, + TIMG0, + TIMG1, + TWAI, + UART0, + UART1, + UART2, + UHCI0, + UHCI1, + USB0, + USB_DEVICE, + USB_WRAP, + WCL, + XTS_AES, +} + +mod peripherals { + pub use super::pac::*; + + crate::create_peripherals! { + UART0, + UART1, + } +} diff --git a/esp-hal-common/src/uart.rs b/esp-hal-common/src/uart.rs index bd38f8c1df6..1542b962300 100644 --- a/esp-hal-common/src/uart.rs +++ b/esp-hal-common/src/uart.rs @@ -5,14 +5,14 @@ use self::config::Config; use crate::pac::UART2; use crate::{ clock::Clocks, - pac::{ - uart0::{fifo::FIFO_SPEC, RegisterBlock}, + peripherals::{ UART0, UART1, }, + pac::uart0::{fifo::FIFO_SPEC, RegisterBlock}, types::{InputSignal, OutputSignal}, InputPin, - OutputPin, + OutputPin, peripheral::{Peripheral, PeripheralRef}, }; const UART_FIFO_SIZE: u16 = 128; @@ -233,17 +233,17 @@ impl embedded_hal_1::serial::Error for Error { } /// UART driver -pub struct Serial { - uart: T, +pub struct Uart<'d, T> { + uart: PeripheralRef<'d, T>, } -impl Serial +impl<'d, T> Uart<'d, T> where T: Instance, { /// Create a new UART instance with defaults pub fn new_with_config

( - uart: T, + uart: impl Peripheral

+ 'd, config: Option, mut pins: Option

, clocks: &Clocks, @@ -251,7 +251,8 @@ where where P: UartPins, { - let mut serial = Serial { uart }; + crate::into_ref!(uart); + let mut serial = Uart { uart }; serial.uart.disable_rx_interrupts(); serial.uart.disable_tx_interrupts(); @@ -275,19 +276,15 @@ where } /// Create a new UART instance with defaults - pub fn new(uart: T) -> Self { - let mut serial = Serial { uart }; + pub fn new(uart: impl Peripheral

+ 'd) -> Self { + crate::into_ref!(uart); + let mut serial = Uart { uart }; serial.uart.disable_rx_interrupts(); serial.uart.disable_tx_interrupts(); serial } - /// Return the raw interface to the underlying UART instance - pub fn free(self) -> T { - self.uart - } - /// Writes bytes pub fn write_bytes(&mut self, data: &[u8]) -> Result<(), Error> { data.iter() @@ -767,7 +764,7 @@ impl Instance for UART2 { } #[cfg(feature = "ufmt")] -impl ufmt_write::uWrite for Serial +impl ufmt_write::uWrite for Uart<'_, T> where T: Instance, { @@ -785,7 +782,7 @@ where } } -impl core::fmt::Write for Serial +impl core::fmt::Write for Uart<'_, T> where T: Instance, { @@ -795,7 +792,7 @@ where } } -impl embedded_hal::serial::Write for Serial +impl embedded_hal::serial::Write for Uart<'_, T> where T: Instance, { @@ -810,7 +807,7 @@ where } } -impl embedded_hal::serial::Read for Serial +impl embedded_hal::serial::Read for Uart<'_, T> where T: Instance, { @@ -822,12 +819,12 @@ where } #[cfg(feature = "eh1")] -impl embedded_hal_1::serial::ErrorType for Serial { +impl embedded_hal_1::serial::ErrorType for Uart<'_, T> { type Error = Error; } #[cfg(feature = "eh1")] -impl embedded_hal_nb::serial::Read for Serial +impl embedded_hal_nb::serial::Read for Uart<'_, T> where T: Instance, { @@ -837,7 +834,7 @@ where } #[cfg(feature = "eh1")] -impl embedded_hal_nb::serial::Write for Serial +impl embedded_hal_nb::serial::Write for Uart<'_, T> where T: Instance, { diff --git a/esp-hal-procmacros/src/lib.rs b/esp-hal-procmacros/src/lib.rs index e4e8d2f0061..68ba571aeac 100644 --- a/esp-hal-procmacros/src/lib.rs +++ b/esp-hal-procmacros/src/lib.rs @@ -199,7 +199,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream { f.block.stmts.extend(std::iter::once( syn::parse2(quote! {{ // Check that this interrupt actually exists - self::pac::Interrupt::#ident_s; + crate::peripherals::Interrupt::#ident_s; }}) .unwrap(), )); diff --git a/esp32-hal/examples/adc.rs b/esp32-hal/examples/adc.rs index 31534be1ff4..ddf5b2e7059 100644 --- a/esp32-hal/examples/adc.rs +++ b/esp32-hal/examples/adc.rs @@ -9,7 +9,7 @@ use esp32_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC2}, clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32-hal/examples/advanced_serial.rs b/esp32-hal/examples/advanced_serial.rs index 199b0dc6144..75fbded9a97 100644 --- a/esp32-hal/examples/advanced_serial.rs +++ b/esp32-hal/examples/advanced_serial.rs @@ -9,16 +9,16 @@ use esp32_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, - serial::{ + uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, timer::TimerGroup, Delay, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use esp_println::println; @@ -52,7 +52,7 @@ fn main() -> ! { io.pins.gpio17.into_floating_input(), ); - let mut serial1 = Serial::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); + let mut serial1 = Uart::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); let mut delay = Delay::new(&clocks); diff --git a/esp32-hal/examples/blinky.rs b/esp32-hal/examples/blinky.rs index fdec5ff3028..d1a6b668feb 100644 --- a/esp32-hal/examples/blinky.rs +++ b/esp32-hal/examples/blinky.rs @@ -8,7 +8,7 @@ use esp32_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32-hal/examples/clock_monitor.rs b/esp32-hal/examples/clock_monitor.rs index 35ae9527015..eb6d6f51520 100644 --- a/esp32-hal/examples/clock_monitor.rs +++ b/esp32-hal/examples/clock_monitor.rs @@ -11,7 +11,7 @@ use critical_section::Mutex; use esp32_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, }; @@ -40,7 +40,7 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); critical_section::with(|cs| RTC.borrow_ref_mut(cs).replace(rtc)); diff --git a/esp32-hal/examples/dac.rs b/esp32-hal/examples/dac.rs index 5eaec3be8be..5fa4a18a278 100644 --- a/esp32-hal/examples/dac.rs +++ b/esp32-hal/examples/dac.rs @@ -9,7 +9,7 @@ use esp32_hal::{ clock::ClockControl, dac, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32-hal/examples/gpio_interrupt.rs b/esp32-hal/examples/gpio_interrupt.rs index 4cb400a0d0e..90c8d0d2b53 100644 --- a/esp32-hal/examples/gpio_interrupt.rs +++ b/esp32-hal/examples/gpio_interrupt.rs @@ -14,7 +14,7 @@ use esp32_hal::{ gpio::{Gpio0, IO, Event, Input, PullDown,}, interrupt, macros::ram, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, timer::TimerGroup, Delay, @@ -48,7 +48,7 @@ fn main() -> ! { critical_section::with(|cs| BUTTON.borrow_ref_mut(cs).replace(button)); - interrupt::enable(pac::Interrupt::GPIO, interrupt::Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::GPIO, interrupt::Priority::Priority2).unwrap(); led.set_high().unwrap(); diff --git a/esp32-hal/examples/hello_rgb.rs b/esp32-hal/examples/hello_rgb.rs index 3d3a9d82d0d..e239db6a9fa 100644 --- a/esp32-hal/examples/hello_rgb.rs +++ b/esp32-hal/examples/hello_rgb.rs @@ -36,7 +36,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = pac::Peripherals::take().unwrap(); + let peripherals = peripherals::Peripherals::take().unwrap(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/hello_world.rs b/esp32-hal/examples/hello_world.rs index 6925b2b00d1..d7e4393a074 100644 --- a/esp32-hal/examples/hello_world.rs +++ b/esp32-hal/examples/hello_world.rs @@ -8,11 +8,11 @@ use core::fmt::Write; use esp32_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; @@ -27,7 +27,7 @@ fn main() -> ! { let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks); let mut timer0 = timer_group0.timer0; let mut wdt = timer_group0.wdt; - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); let mut rtc = Rtc::new(peripherals.RTC_CNTL); // Disable MWDT and RWDT (Watchdog) flash boot protection diff --git a/esp32-hal/examples/i2c_display.rs b/esp32-hal/examples/i2c_display.rs index abb151bad1c..2587f3ec322 100644 --- a/esp32-hal/examples/i2c_display.rs +++ b/esp32-hal/examples/i2c_display.rs @@ -23,7 +23,7 @@ use esp32_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/examples/ledc.rs b/esp32-hal/examples/ledc.rs index d0db9f41598..7a7c76d0e06 100644 --- a/esp32-hal/examples/ledc.rs +++ b/esp32-hal/examples/ledc.rs @@ -15,7 +15,7 @@ use esp32_hal::{ HighSpeed, LEDC, }, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/examples/multicore.rs b/esp32-hal/examples/multicore.rs index baa1f08c757..654509daf24 100644 --- a/esp32-hal/examples/multicore.rs +++ b/esp32-hal/examples/multicore.rs @@ -10,7 +10,7 @@ use core::cell::RefCell; use critical_section::Mutex; use esp32_hal::{ clock::ClockControl, - pac::{Peripherals, TIMG1}, + peripherals::{Peripherals, TIMG1}, prelude::*, timer::{Timer, Timer0, TimerGroup}, CpuControl, diff --git a/esp32-hal/examples/pulse_control.rs b/esp32-hal/examples/pulse_control.rs index 08613d7b634..c8ccda20c8f 100644 --- a/esp32-hal/examples/pulse_control.rs +++ b/esp32-hal/examples/pulse_control.rs @@ -8,7 +8,7 @@ use esp32_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, pulse_control::{ConfiguredChannel, OutputChannel, PulseCode, RepeatMode}, timer::TimerGroup, diff --git a/esp32-hal/examples/ram.rs b/esp32-hal/examples/ram.rs index 0ca5793e92e..a5b3253fd6f 100644 --- a/esp32-hal/examples/ram.rs +++ b/esp32-hal/examples/ram.rs @@ -11,7 +11,7 @@ use esp32_hal::{ clock::ClockControl, macros::ram, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, }; diff --git a/esp32-hal/examples/read_efuse.rs b/esp32-hal/examples/read_efuse.rs index ea855d85214..a640c5152d3 100644 --- a/esp32-hal/examples/read_efuse.rs +++ b/esp32-hal/examples/read_efuse.rs @@ -7,7 +7,7 @@ use esp32_hal::{ clock::ClockControl, efuse::Efuse, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/examples/rtc_watchdog.rs b/esp32-hal/examples/rtc_watchdog.rs index 81ef52f2811..17b23d0556e 100644 --- a/esp32-hal/examples/rtc_watchdog.rs +++ b/esp32-hal/examples/rtc_watchdog.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, Rwdt, @@ -38,7 +38,7 @@ fn main() -> ! { critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); loop {} } diff --git a/esp32-hal/examples/serial_interrupts.rs b/esp32-hal/examples/serial_interrupts.rs index c8c5b9a3a34..18144f9b149 100644 --- a/esp32-hal/examples/serial_interrupts.rs +++ b/esp32-hal/examples/serial_interrupts.rs @@ -11,18 +11,18 @@ use critical_section::Mutex; use esp32_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, UART0}, + peripherals::{self, Peripherals, UART0}, prelude::*, - serial::config::AtCmdConfig, + uart::config::AtCmdConfig, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; use xtensa_lx_rt::entry; -static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); +static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { @@ -38,7 +38,7 @@ fn main() -> ! { let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks); let mut wdt1 = timer_group1.wdt; - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); let mut rtc = Rtc::new(peripherals.RTC_CNTL); // Disable MWDT and RWDT (Watchdog) flash boot protection @@ -51,7 +51,7 @@ fn main() -> ! { serial0.listen_at_cmd(); serial0.listen_rx_fifo_full(); - interrupt::enable(pac::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); timer0.start(1u64.secs()); diff --git a/esp32-hal/examples/spi_eh1_device_loopback.rs b/esp32-hal/examples/spi_eh1_device_loopback.rs index cf41e5b521a..d095640279c 100644 --- a/esp32-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32-hal/examples/spi_eh1_device_loopback.rs @@ -22,7 +22,7 @@ use embedded_hal_1::spi::SpiDevice; use esp32_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiBusController, SpiMode}, timer::TimerGroup, diff --git a/esp32-hal/examples/spi_eh1_loopback.rs b/esp32-hal/examples/spi_eh1_loopback.rs index 53925de6e6c..32c30e9ace2 100644 --- a/esp32-hal/examples/spi_eh1_loopback.rs +++ b/esp32-hal/examples/spi_eh1_loopback.rs @@ -20,7 +20,7 @@ use embedded_hal_1::spi::SpiBus; use esp32_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32-hal/examples/spi_loopback.rs b/esp32-hal/examples/spi_loopback.rs index ea585d4ba34..60ca0986377 100644 --- a/esp32-hal/examples/spi_loopback.rs +++ b/esp32-hal/examples/spi_loopback.rs @@ -19,7 +19,7 @@ use esp32_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32-hal/examples/spi_loopback_dma.rs b/esp32-hal/examples/spi_loopback_dma.rs index 241fbb1db1b..12aebf614fc 100644 --- a/esp32-hal/examples/spi_loopback_dma.rs +++ b/esp32-hal/examples/spi_loopback_dma.rs @@ -20,7 +20,7 @@ use esp32_hal::{ clock::ClockControl, dma::{DmaPriority}, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, pdma::Dma, prelude::*, spi::{Spi, SpiMode}, diff --git a/esp32-hal/examples/timer_interrupt.rs b/esp32-hal/examples/timer_interrupt.rs index ecf9df04714..c57217f4db1 100644 --- a/esp32-hal/examples/timer_interrupt.rs +++ b/esp32-hal/examples/timer_interrupt.rs @@ -12,7 +12,7 @@ use esp32_hal::{ clock::ClockControl, interrupt, interrupt::Priority, - pac::{self, Peripherals, TIMG0, TIMG1}, + peripherals::{self, Peripherals, TIMG0, TIMG1}, prelude::*, timer::{Timer, Timer0, Timer1, TimerGroup}, Rtc, @@ -49,10 +49,10 @@ fn main() -> ! { wdt1.disable(); rtc.rwdt.disable(); - interrupt::enable(pac::Interrupt::TG0_T0_LEVEL, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::TG0_T1_LEVEL, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::TG1_T0_LEVEL, Priority::Priority3).unwrap(); - interrupt::enable(pac::Interrupt::TG1_T1_LEVEL, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T0_LEVEL, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T1_LEVEL, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::TG1_T0_LEVEL, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::TG1_T1_LEVEL, Priority::Priority3).unwrap(); timer00.start(500u64.millis()); timer00.listen(); timer01.start(2500u64.millis()); diff --git a/esp32-hal/examples/watchdog.rs b/esp32-hal/examples/watchdog.rs index 4e30605dfc3..35098ac7612 100644 --- a/esp32-hal/examples/watchdog.rs +++ b/esp32-hal/examples/watchdog.rs @@ -5,7 +5,7 @@ #![no_std] #![no_main] -use esp32_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32-hal/src/lib.rs b/esp32-hal/src/lib.rs index f513c4e3716..fe0060ce04d 100644 --- a/esp32-hal/src/lib.rs +++ b/esp32-hal/src/lib.rs @@ -17,10 +17,10 @@ pub use esp_hal_common::{ ledc, macros, mcpwm, - pac, + peripherals, prelude, pulse_control, - serial, + uart, spi, system, timer, @@ -31,8 +31,8 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - Serial, sha + Uart, }; pub use self::gpio::IO; @@ -46,7 +46,7 @@ pub mod analog { } #[no_mangle] -extern "C" fn EspDefaultHandler(_level: u32, _interrupt: pac::Interrupt) {} +extern "C" fn EspDefaultHandler(_level: u32, _interrupt: peripherals::Interrupt) {} #[no_mangle] extern "C" fn DefaultHandler() {} diff --git a/esp32c2-hal/examples/adc.rs b/esp32c2-hal/examples/adc.rs index 58581aa8a47..fb010b013f4 100644 --- a/esp32c2-hal/examples/adc.rs +++ b/esp32c2-hal/examples/adc.rs @@ -9,7 +9,7 @@ use esp32c2_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC1}, clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32c2-hal/examples/advanced_serial.rs b/esp32c2-hal/examples/advanced_serial.rs index 0a5cacf98e1..eacafa23123 100644 --- a/esp32c2-hal/examples/advanced_serial.rs +++ b/esp32c2-hal/examples/advanced_serial.rs @@ -8,15 +8,15 @@ use esp32c2_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, - serial::{ + uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, timer::TimerGroup, Rtc, - Serial, + Uart, IO, }; use esp_backtrace as _; @@ -53,7 +53,7 @@ fn main() -> ! { io.pins.gpio2.into_floating_input(), ); - let mut serial1 = Serial::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); + let mut serial1 = Uart::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); timer0.start(250u64.millis()); diff --git a/esp32c2-hal/examples/blinky.rs b/esp32c2-hal/examples/blinky.rs index 649843f9e83..812d3eb8d21 100644 --- a/esp32c2-hal/examples/blinky.rs +++ b/esp32c2-hal/examples/blinky.rs @@ -8,7 +8,7 @@ use esp32c2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32c2-hal/examples/clock_monitor.rs b/esp32c2-hal/examples/clock_monitor.rs index a1f209b5a11..c8e58f4ef11 100644 --- a/esp32c2-hal/examples/clock_monitor.rs +++ b/esp32c2-hal/examples/clock_monitor.rs @@ -11,7 +11,7 @@ use critical_section::Mutex; use esp32c2_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, }; @@ -41,7 +41,7 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); critical_section::with(|cs| { RTC.borrow_ref_mut(cs).replace(rtc); diff --git a/esp32c2-hal/examples/gpio_interrupt.rs b/esp32c2-hal/examples/gpio_interrupt.rs index bf26880202c..295864a394b 100644 --- a/esp32c2-hal/examples/gpio_interrupt.rs +++ b/esp32c2-hal/examples/gpio_interrupt.rs @@ -13,7 +13,7 @@ use esp32c2_hal::{ clock::ClockControl, gpio::{Gpio9, IO, Event, Input, PullDown}, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, timer::TimerGroup, Delay, @@ -50,7 +50,7 @@ fn main() -> ! { critical_section::with(|cs| BUTTON.borrow_ref_mut(cs).replace(button)); - interrupt::enable(pac::Interrupt::GPIO, interrupt::Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::GPIO, interrupt::Priority::Priority3).unwrap(); unsafe { riscv::interrupt::enable(); diff --git a/esp32c2-hal/examples/hello_world.rs b/esp32c2-hal/examples/hello_world.rs index 853991ed1fc..c9db5a06dff 100644 --- a/esp32c2-hal/examples/hello_world.rs +++ b/esp32c2-hal/examples/hello_world.rs @@ -8,11 +8,11 @@ use core::fmt::Write; use esp32c2_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; @@ -25,7 +25,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks); let mut timer0 = timer_group0.timer0; let mut wdt0 = timer_group0.wdt; diff --git a/esp32c2-hal/examples/i2c_display.rs b/esp32c2-hal/examples/i2c_display.rs index ce302ca7a08..e366093d9ca 100644 --- a/esp32c2-hal/examples/i2c_display.rs +++ b/esp32c2-hal/examples/i2c_display.rs @@ -23,7 +23,7 @@ use esp32c2_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c2-hal/examples/ledc.rs b/esp32c2-hal/examples/ledc.rs index 0bce2e3d71d..ffa138b1095 100644 --- a/esp32c2-hal/examples/ledc.rs +++ b/esp32c2-hal/examples/ledc.rs @@ -16,7 +16,7 @@ use esp32c2_hal::{ LowSpeed, LEDC, }, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c2-hal/examples/read_efuse.rs b/esp32c2-hal/examples/read_efuse.rs index 6f3fa669f7b..72ff31afb84 100644 --- a/esp32c2-hal/examples/read_efuse.rs +++ b/esp32c2-hal/examples/read_efuse.rs @@ -7,7 +7,7 @@ use esp32c2_hal::{ clock::ClockControl, efuse::Efuse, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c2-hal/examples/rtc_watchdog.rs b/esp32c2-hal/examples/rtc_watchdog.rs index 5b65a897d98..fc783e5d4a6 100644 --- a/esp32c2-hal/examples/rtc_watchdog.rs +++ b/esp32c2-hal/examples/rtc_watchdog.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32c2_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, Rwdt, @@ -37,7 +37,7 @@ fn main() -> ! { rtc.rwdt.start(2000u64.millis()); rtc.rwdt.listen(); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); diff --git a/esp32c2-hal/examples/serial_interrupts.rs b/esp32c2-hal/examples/serial_interrupts.rs index 064a28a4e78..8ab9c5f7190 100644 --- a/esp32c2-hal/examples/serial_interrupts.rs +++ b/esp32c2-hal/examples/serial_interrupts.rs @@ -11,19 +11,19 @@ use critical_section::Mutex; use esp32c2_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, UART0}, + peripherals::{self, Peripherals, UART0}, prelude::*, - serial::config::AtCmdConfig, + uart::config::AtCmdConfig, timer::TimerGroup, Cpu, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; use riscv_rt::entry; -static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); +static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { @@ -32,7 +32,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks); let mut timer0 = timer_group0.timer0; let mut wdt0 = timer_group0.wdt; @@ -51,7 +51,7 @@ fn main() -> ! { critical_section::with(|cs| SERIAL.borrow_ref_mut(cs).replace(serial0)); - interrupt::enable(pac::Interrupt::UART0, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority1).unwrap(); interrupt::set_kind( Cpu::ProCpu, interrupt::CpuInterrupt::Interrupt1, // Interrupt 1 handles priority one interrupts diff --git a/esp32c2-hal/examples/spi_eh1_device_loopback.rs b/esp32c2-hal/examples/spi_eh1_device_loopback.rs index 9ef83c06fb6..b69209a5729 100644 --- a/esp32c2-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32c2-hal/examples/spi_eh1_device_loopback.rs @@ -22,7 +22,7 @@ use embedded_hal_1::spi::SpiDevice; use esp32c2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiBusController, SpiMode}, timer::TimerGroup, diff --git a/esp32c2-hal/examples/spi_eh1_loopback.rs b/esp32c2-hal/examples/spi_eh1_loopback.rs index f65b0082573..0cc1fcf270b 100644 --- a/esp32c2-hal/examples/spi_eh1_loopback.rs +++ b/esp32c2-hal/examples/spi_eh1_loopback.rs @@ -20,7 +20,7 @@ use embedded_hal_1::spi::SpiBus; use esp32c2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32c2-hal/examples/spi_loopback.rs b/esp32c2-hal/examples/spi_loopback.rs index 0346e7be0b4..8e030380476 100644 --- a/esp32c2-hal/examples/spi_loopback.rs +++ b/esp32c2-hal/examples/spi_loopback.rs @@ -19,7 +19,7 @@ use esp32c2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32c2-hal/examples/spi_loopback_dma.rs b/esp32c2-hal/examples/spi_loopback_dma.rs index fecc9977d79..350706e3dd6 100644 --- a/esp32c2-hal/examples/spi_loopback_dma.rs +++ b/esp32c2-hal/examples/spi_loopback_dma.rs @@ -21,7 +21,7 @@ use esp32c2_hal::{ dma::{DmaPriority}, gdma::Gdma, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32c2-hal/examples/systimer.rs b/esp32c2-hal/examples/systimer.rs index 9c2e19486de..5b3b0f92c6c 100644 --- a/esp32c2-hal/examples/systimer.rs +++ b/esp32c2-hal/examples/systimer.rs @@ -11,7 +11,7 @@ use esp32c2_hal::{ clock::ClockControl, interrupt, interrupt::Priority, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, systimer::{Alarm, Periodic, SystemTimer, Target}, timer::TimerGroup, @@ -63,9 +63,9 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET2, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority2).unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/esp32c2-hal/examples/timer_interrupt.rs b/esp32c2-hal/examples/timer_interrupt.rs index 815ceb49f96..184fff682cf 100644 --- a/esp32c2-hal/examples/timer_interrupt.rs +++ b/esp32c2-hal/examples/timer_interrupt.rs @@ -10,7 +10,7 @@ use critical_section::Mutex; use esp32c2_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, TIMG0}, + peripherals::{self, Peripherals, TIMG0}, prelude::*, timer::{Timer, Timer0, TimerGroup}, Rtc, @@ -37,7 +37,7 @@ fn main() -> ! { rtc.rwdt.disable(); wdt0.disable(); - interrupt::enable(pac::Interrupt::TG0_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); timer0.start(500u64.millis()); timer0.listen(); diff --git a/esp32c2-hal/examples/watchdog.rs b/esp32c2-hal/examples/watchdog.rs index 4f62b7e951a..076f6640aed 100644 --- a/esp32c2-hal/examples/watchdog.rs +++ b/esp32c2-hal/examples/watchdog.rs @@ -5,7 +5,7 @@ #![no_std] #![no_main] -use esp32c2_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32c2_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32c2-hal/src/lib.rs b/esp32c2-hal/src/lib.rs index ca89ac9dab6..10812dc26b4 100644 --- a/esp32c2-hal/src/lib.rs +++ b/esp32c2-hal/src/lib.rs @@ -16,9 +16,9 @@ pub use esp_hal_common::{ interrupt, ledc, macros, - pac, + peripherals, prelude, - serial, + uart, spi, system, systimer, @@ -28,8 +28,8 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - Serial, sha, + Uart, }; pub use self::gpio::IO; @@ -295,4 +295,4 @@ pub fn mp_hook() -> bool { } #[no_mangle] -extern "C" fn EspDefaultHandler(_interrupt: pac::Interrupt) {} +extern "C" fn EspDefaultHandler(_interrupt: peripherals::Interrupt) {} diff --git a/esp32c3-hal/examples/adc.rs b/esp32c3-hal/examples/adc.rs index 6e3d93bb0d0..5cefa56fb91 100644 --- a/esp32c3-hal/examples/adc.rs +++ b/esp32c3-hal/examples/adc.rs @@ -9,7 +9,7 @@ use esp32c3_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC1}, clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32c3-hal/examples/advanced_serial.rs b/esp32c3-hal/examples/advanced_serial.rs index 5021d0cec53..a1da81a2d83 100644 --- a/esp32c3-hal/examples/advanced_serial.rs +++ b/esp32c3-hal/examples/advanced_serial.rs @@ -8,15 +8,15 @@ use esp32c3_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, - serial::{ + uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, timer::TimerGroup, Rtc, - Serial, + Uart, IO, }; use esp_backtrace as _; @@ -56,7 +56,7 @@ fn main() -> ! { io.pins.gpio2.into_floating_input(), ); - let mut serial1 = Serial::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); + let mut serial1 = Uart::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); timer0.start(250u64.millis()); diff --git a/esp32c3-hal/examples/blinky.rs b/esp32c3-hal/examples/blinky.rs index 6d71b197156..4facaf224e6 100644 --- a/esp32c3-hal/examples/blinky.rs +++ b/esp32c3-hal/examples/blinky.rs @@ -8,7 +8,7 @@ use esp32c3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32c3-hal/examples/clock_monitor.rs b/esp32c3-hal/examples/clock_monitor.rs index 925b050ccaf..a7d5c104936 100644 --- a/esp32c3-hal/examples/clock_monitor.rs +++ b/esp32c3-hal/examples/clock_monitor.rs @@ -11,7 +11,7 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, }; @@ -41,7 +41,7 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); critical_section::with(|cs| { RTC.borrow_ref_mut(cs).replace(rtc); diff --git a/esp32c3-hal/examples/gpio_interrupt.rs b/esp32c3-hal/examples/gpio_interrupt.rs index 12d3bd2f4c8..032628b2008 100644 --- a/esp32c3-hal/examples/gpio_interrupt.rs +++ b/esp32c3-hal/examples/gpio_interrupt.rs @@ -13,7 +13,7 @@ use esp32c3_hal::{ clock::ClockControl, gpio::{Gpio9, IO, Event, Input, PullDown}, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, timer::TimerGroup, Delay, @@ -53,7 +53,7 @@ fn main() -> ! { critical_section::with(|cs| BUTTON.borrow_ref_mut(cs).replace(button)); - interrupt::enable(pac::Interrupt::GPIO, interrupt::Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::GPIO, interrupt::Priority::Priority3).unwrap(); unsafe { riscv::interrupt::enable(); diff --git a/esp32c3-hal/examples/hello_rgb.rs b/esp32c3-hal/examples/hello_rgb.rs index f58453000d8..ea051772ada 100644 --- a/esp32c3-hal/examples/hello_rgb.rs +++ b/esp32c3-hal/examples/hello_rgb.rs @@ -35,7 +35,7 @@ use smart_leds::{ #[entry] fn main() -> ! { - let peripherals = pac::Peripherals::take().unwrap(); + let peripherals = peripherals::Peripherals::take().unwrap(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/hello_world.rs b/esp32c3-hal/examples/hello_world.rs index 70f5ca5eafd..0c63224b23d 100644 --- a/esp32c3-hal/examples/hello_world.rs +++ b/esp32c3-hal/examples/hello_world.rs @@ -1,4 +1,4 @@ -//! This shows how to write text to serial0. +//! This shows how to write text to uart0. //! You can see the output with `espflash` if you provide the `--monitor` option #![no_std] @@ -8,11 +8,11 @@ use core::fmt::Write; use esp32c3_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; @@ -25,12 +25,18 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let mut serial0 = Serial::new(peripherals.UART0); + let mut uart = peripherals.UART0; let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks); let mut timer0 = timer_group0.timer0; let mut wdt0 = timer_group0.wdt; let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks); let mut wdt1 = timer_group1.wdt; + + let mut uart0 = Uart::new(&mut uart); + writeln!(uart0, "Test 1").unwrap(); + drop(uart0); // this ends the mutable borrow of uart, its now available in the peripheral struct again + let mut uart0 = Uart::new(uart); // construct via move this time + writeln!(uart0, "Test 2").unwrap(); // Disable watchdog timers rtc.swd.disable(); @@ -41,7 +47,7 @@ fn main() -> ! { timer0.start(1u64.secs()); loop { - writeln!(serial0, "Hello world!").unwrap(); + writeln!(uart0, "Hello world!").unwrap(); block!(timer0.wait()).unwrap(); } } diff --git a/esp32c3-hal/examples/i2c_display.rs b/esp32c3-hal/examples/i2c_display.rs index e4eb904abe9..72c1bb151ff 100644 --- a/esp32c3-hal/examples/i2c_display.rs +++ b/esp32c3-hal/examples/i2c_display.rs @@ -23,7 +23,7 @@ use esp32c3_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/ledc.rs b/esp32c3-hal/examples/ledc.rs index 75c0092b192..7bb7edde823 100644 --- a/esp32c3-hal/examples/ledc.rs +++ b/esp32c3-hal/examples/ledc.rs @@ -16,7 +16,7 @@ use esp32c3_hal::{ LowSpeed, LEDC, }, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/pulse_control.rs b/esp32c3-hal/examples/pulse_control.rs index 5287f21b706..f20ae72467e 100644 --- a/esp32c3-hal/examples/pulse_control.rs +++ b/esp32c3-hal/examples/pulse_control.rs @@ -8,7 +8,7 @@ use esp32c3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, pulse_control::{ClockSource, ConfiguredChannel, OutputChannel, PulseCode, RepeatMode}, timer::TimerGroup, diff --git a/esp32c3-hal/examples/ram.rs b/esp32c3-hal/examples/ram.rs index 6c66c67179a..c3bd79dceb2 100644 --- a/esp32c3-hal/examples/ram.rs +++ b/esp32c3-hal/examples/ram.rs @@ -11,7 +11,7 @@ use esp32c3_hal::{ clock::ClockControl, macros::ram, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, }; diff --git a/esp32c3-hal/examples/read_efuse.rs b/esp32c3-hal/examples/read_efuse.rs index 93646665026..8db604e3339 100644 --- a/esp32c3-hal/examples/read_efuse.rs +++ b/esp32c3-hal/examples/read_efuse.rs @@ -7,7 +7,7 @@ use esp32c3_hal::{ clock::ClockControl, efuse::Efuse, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/rtc_watchdog.rs b/esp32c3-hal/examples/rtc_watchdog.rs index a956396ad35..8a0a14b2df9 100644 --- a/esp32c3-hal/examples/rtc_watchdog.rs +++ b/esp32c3-hal/examples/rtc_watchdog.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, Rwdt, @@ -37,7 +37,7 @@ fn main() -> ! { rtc.rwdt.start(2000u64.millis()); rtc.rwdt.listen(); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); diff --git a/esp32c3-hal/examples/serial_interrupts.rs b/esp32c3-hal/examples/serial_interrupts.rs index e785a64388e..2af2c412041 100644 --- a/esp32c3-hal/examples/serial_interrupts.rs +++ b/esp32c3-hal/examples/serial_interrupts.rs @@ -11,19 +11,19 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, UART0}, + peripherals::{self, Peripherals, UART0}, prelude::*, - serial::config::AtCmdConfig, + uart::config::AtCmdConfig, timer::TimerGroup, Cpu, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; use riscv_rt::entry; -static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); +static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { @@ -32,7 +32,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks); let mut timer0 = timer_group0.timer0; let mut wdt0 = timer_group0.wdt; @@ -54,7 +54,7 @@ fn main() -> ! { critical_section::with(|cs| SERIAL.borrow_ref_mut(cs).replace(serial0)); - interrupt::enable(pac::Interrupt::UART0, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority1).unwrap(); interrupt::set_kind( Cpu::ProCpu, interrupt::CpuInterrupt::Interrupt1, // Interrupt 1 handles priority one interrupts diff --git a/esp32c3-hal/examples/spi_eh1_device_loopback.rs b/esp32c3-hal/examples/spi_eh1_device_loopback.rs index a014cd8eb97..80a985f6d7a 100644 --- a/esp32c3-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32c3-hal/examples/spi_eh1_device_loopback.rs @@ -22,7 +22,7 @@ use embedded_hal_1::spi::SpiDevice; use esp32c3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiBusController, SpiMode}, timer::TimerGroup, diff --git a/esp32c3-hal/examples/spi_eh1_loopback.rs b/esp32c3-hal/examples/spi_eh1_loopback.rs index b74005f7896..6934f54ed01 100644 --- a/esp32c3-hal/examples/spi_eh1_loopback.rs +++ b/esp32c3-hal/examples/spi_eh1_loopback.rs @@ -20,7 +20,7 @@ use embedded_hal_1::spi::SpiBus; use esp32c3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32c3-hal/examples/spi_loopback.rs b/esp32c3-hal/examples/spi_loopback.rs index 4e53274d21a..5ba34756ffd 100644 --- a/esp32c3-hal/examples/spi_loopback.rs +++ b/esp32c3-hal/examples/spi_loopback.rs @@ -19,7 +19,7 @@ use esp32c3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32c3-hal/examples/spi_loopback_dma.rs b/esp32c3-hal/examples/spi_loopback_dma.rs index ee1bf7a5995..d639c9bea37 100644 --- a/esp32c3-hal/examples/spi_loopback_dma.rs +++ b/esp32c3-hal/examples/spi_loopback_dma.rs @@ -21,7 +21,7 @@ use esp32c3_hal::{ dma::{DmaPriority}, gdma::Gdma, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32c3-hal/examples/systimer.rs b/esp32c3-hal/examples/systimer.rs index f3b09b94f60..265d288cf51 100644 --- a/esp32c3-hal/examples/systimer.rs +++ b/esp32c3-hal/examples/systimer.rs @@ -11,7 +11,7 @@ use esp32c3_hal::{ clock::ClockControl, interrupt, interrupt::Priority, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, systimer::{Alarm, Periodic, SystemTimer, Target}, timer::TimerGroup, @@ -63,9 +63,9 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET2, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority2).unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/esp32c3-hal/examples/timer_interrupt.rs b/esp32c3-hal/examples/timer_interrupt.rs index 096eed2da41..a0fce312189 100644 --- a/esp32c3-hal/examples/timer_interrupt.rs +++ b/esp32c3-hal/examples/timer_interrupt.rs @@ -11,7 +11,7 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, TIMG0, TIMG1}, + peripherals::{self, Peripherals, TIMG0, TIMG1}, prelude::*, timer::{Timer, Timer0, TimerGroup}, Rtc, @@ -43,11 +43,11 @@ fn main() -> ! { wdt0.disable(); wdt1.disable(); - interrupt::enable(pac::Interrupt::TG0_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); timer0.start(500u64.millis()); timer0.listen(); - interrupt::enable(pac::Interrupt::TG1_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::TG1_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); timer1.start(1u64.secs()); timer1.listen(); diff --git a/esp32c3-hal/examples/usb_serial_jtag.rs b/esp32c3-hal/examples/usb_serial_jtag.rs index 39e736befe6..a9e94966e6d 100644 --- a/esp32c3-hal/examples/usb_serial_jtag.rs +++ b/esp32c3-hal/examples/usb_serial_jtag.rs @@ -12,7 +12,8 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, USB_DEVICE}, + pac::{self, USB_DEVICE}, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Cpu, diff --git a/esp32c3-hal/examples/watchdog.rs b/esp32c3-hal/examples/watchdog.rs index a792ecd49d1..9fac5c05af5 100644 --- a/esp32c3-hal/examples/watchdog.rs +++ b/esp32c3-hal/examples/watchdog.rs @@ -5,7 +5,7 @@ #![no_std] #![no_main] -use esp32c3_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32c3_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32c3-hal/src/lib.rs b/esp32c3-hal/src/lib.rs index 2d139095707..944982044b2 100644 --- a/esp32c3-hal/src/lib.rs +++ b/esp32c3-hal/src/lib.rs @@ -18,14 +18,14 @@ pub use esp_hal_common::{ interrupt, ledc, macros, - pac, + peripherals, prelude, pulse_control, - serial, spi, system, systimer, timer, + uart, utils, Cpu, Delay, @@ -33,7 +33,7 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - Serial, + Uart, UsbSerialJtag, sha }; @@ -444,4 +444,4 @@ pub fn mp_hook() -> bool { } #[no_mangle] -extern "C" fn EspDefaultHandler(_interrupt: pac::Interrupt) {} +extern "C" fn EspDefaultHandler(_interrupt: peripherals::Interrupt) {} diff --git a/esp32s2-hal/examples/adc.rs b/esp32s2-hal/examples/adc.rs index 37588c9abf9..d1133e448d5 100644 --- a/esp32s2-hal/examples/adc.rs +++ b/esp32s2-hal/examples/adc.rs @@ -9,7 +9,7 @@ use esp32s2_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC1}, clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32s2-hal/examples/advanced_serial.rs b/esp32s2-hal/examples/advanced_serial.rs index e10dd124590..6bab01ec8e8 100644 --- a/esp32s2-hal/examples/advanced_serial.rs +++ b/esp32s2-hal/examples/advanced_serial.rs @@ -9,16 +9,16 @@ use esp32s2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, - serial::{ + uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, timer::TimerGroup, Delay, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use xtensa_atomic_emulation_trap as _; @@ -53,7 +53,7 @@ fn main() -> ! { io.pins.gpio2.into_floating_input(), ); - let mut serial1 = Serial::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); + let mut serial1 = Uart::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); let mut delay = Delay::new(&clocks); diff --git a/esp32s2-hal/examples/blinky.rs b/esp32s2-hal/examples/blinky.rs index 5fda08184bf..938d579771d 100644 --- a/esp32s2-hal/examples/blinky.rs +++ b/esp32s2-hal/examples/blinky.rs @@ -8,7 +8,7 @@ use esp32s2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32s2-hal/examples/clock_monitor.rs b/esp32s2-hal/examples/clock_monitor.rs index 3e5f414f006..38cacd94436 100644 --- a/esp32s2-hal/examples/clock_monitor.rs +++ b/esp32s2-hal/examples/clock_monitor.rs @@ -11,7 +11,7 @@ use critical_section::Mutex; use esp32s2_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, }; @@ -42,7 +42,7 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); critical_section::with(|cs| RTC.borrow_ref_mut(cs).replace(rtc)); diff --git a/esp32s2-hal/examples/dac.rs b/esp32s2-hal/examples/dac.rs index 6ffc31e274b..307f4550d85 100644 --- a/esp32s2-hal/examples/dac.rs +++ b/esp32s2-hal/examples/dac.rs @@ -9,7 +9,7 @@ use esp32s2_hal::{ clock::ClockControl, dac, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32s2-hal/examples/gpio_interrupt.rs b/esp32s2-hal/examples/gpio_interrupt.rs index b8b46793c87..f28dfd5f8b3 100644 --- a/esp32s2-hal/examples/gpio_interrupt.rs +++ b/esp32s2-hal/examples/gpio_interrupt.rs @@ -14,7 +14,7 @@ use esp32s2_hal::{ gpio::{Gpio0, IO, Event, Input, PullDown}, interrupt, macros::ram, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, timer::TimerGroup, Delay, @@ -49,7 +49,7 @@ fn main() -> ! { critical_section::with(|cs| BUTTON.borrow_ref_mut(cs).replace(button)); - interrupt::enable(pac::Interrupt::GPIO, interrupt::Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::GPIO, interrupt::Priority::Priority2).unwrap(); led.set_high().unwrap(); diff --git a/esp32s2-hal/examples/hello_rgb.rs b/esp32s2-hal/examples/hello_rgb.rs index 02e3bea8929..a51e516428e 100644 --- a/esp32s2-hal/examples/hello_rgb.rs +++ b/esp32s2-hal/examples/hello_rgb.rs @@ -13,7 +13,7 @@ use esp32s2_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, utils::{smartLedAdapter, SmartLedsAdapter}, diff --git a/esp32s2-hal/examples/hello_world.rs b/esp32s2-hal/examples/hello_world.rs index 0de84b69751..f440ac987d5 100644 --- a/esp32s2-hal/examples/hello_world.rs +++ b/esp32s2-hal/examples/hello_world.rs @@ -8,11 +8,11 @@ use core::fmt::Write; use esp32s2_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use xtensa_atomic_emulation_trap as _; @@ -29,7 +29,7 @@ fn main() -> ! { let mut timer0 = timer_group0.timer0; let mut wdt = timer_group0.wdt; let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); // Disable MWDT and RWDT (Watchdog) flash boot protection wdt.disable(); diff --git a/esp32s2-hal/examples/i2c_display.rs b/esp32s2-hal/examples/i2c_display.rs index feed528c26d..f1d6e819d5d 100644 --- a/esp32s2-hal/examples/i2c_display.rs +++ b/esp32s2-hal/examples/i2c_display.rs @@ -23,7 +23,7 @@ use esp32s2_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/examples/ledc.rs b/esp32s2-hal/examples/ledc.rs index 6e35107386a..039e79fa510 100644 --- a/esp32s2-hal/examples/ledc.rs +++ b/esp32s2-hal/examples/ledc.rs @@ -16,7 +16,7 @@ use esp32s2_hal::{ LowSpeed, LEDC, }, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/examples/pulse_control.rs b/esp32s2-hal/examples/pulse_control.rs index 977c394ed34..1e8bcae9617 100644 --- a/esp32s2-hal/examples/pulse_control.rs +++ b/esp32s2-hal/examples/pulse_control.rs @@ -8,7 +8,7 @@ use esp32s2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, pulse_control::{ConfiguredChannel, OutputChannel, PulseCode, RepeatMode}, timer::TimerGroup, diff --git a/esp32s2-hal/examples/ram.rs b/esp32s2-hal/examples/ram.rs index 4fdc19e99f9..287716a20c5 100644 --- a/esp32s2-hal/examples/ram.rs +++ b/esp32s2-hal/examples/ram.rs @@ -11,7 +11,7 @@ use esp32s2_hal::{ clock::ClockControl, macros::ram, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, }; diff --git a/esp32s2-hal/examples/read_efuse.rs b/esp32s2-hal/examples/read_efuse.rs index edd8af52f85..6e6c7f40a22 100644 --- a/esp32s2-hal/examples/read_efuse.rs +++ b/esp32s2-hal/examples/read_efuse.rs @@ -7,7 +7,7 @@ use esp32s2_hal::{ clock::ClockControl, efuse::Efuse, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/examples/rtc_watchdog.rs b/esp32s2-hal/examples/rtc_watchdog.rs index 163feb10e4f..eb716087649 100644 --- a/esp32s2-hal/examples/rtc_watchdog.rs +++ b/esp32s2-hal/examples/rtc_watchdog.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32s2_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, Rwdt, @@ -39,7 +39,7 @@ fn main() -> ! { critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); loop {} } diff --git a/esp32s2-hal/examples/serial_interrupts.rs b/esp32s2-hal/examples/serial_interrupts.rs index 0f402546e2a..f932451009d 100644 --- a/esp32s2-hal/examples/serial_interrupts.rs +++ b/esp32s2-hal/examples/serial_interrupts.rs @@ -11,19 +11,19 @@ use critical_section::Mutex; use esp32s2_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, UART0}, + peripherals::{self, Peripherals, UART0}, prelude::*, - serial::config::AtCmdConfig, + uart::config::AtCmdConfig, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use xtensa_atomic_emulation_trap as _; use nb::block; use xtensa_lx_rt::entry; -static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); +static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { @@ -39,7 +39,7 @@ fn main() -> ! { let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks); let mut wdt1 = timer_group1.wdt; - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); let mut rtc = Rtc::new(peripherals.RTC_CNTL); // Disable MWDT and RWDT (Watchdog) flash boot protection @@ -52,7 +52,7 @@ fn main() -> ! { serial0.listen_at_cmd(); serial0.listen_rx_fifo_full(); - interrupt::enable(pac::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); timer0.start(1u64.secs()); diff --git a/esp32s2-hal/examples/spi_eh1_device_loopback.rs b/esp32s2-hal/examples/spi_eh1_device_loopback.rs index a0d7c09a930..4c3cb49614a 100644 --- a/esp32s2-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32s2-hal/examples/spi_eh1_device_loopback.rs @@ -22,7 +22,7 @@ use embedded_hal_1::spi::SpiDevice; use esp32s2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiBusController, SpiMode}, timer::TimerGroup, diff --git a/esp32s2-hal/examples/spi_eh1_loopback.rs b/esp32s2-hal/examples/spi_eh1_loopback.rs index 64dc7f2dd6b..63a6eee346e 100644 --- a/esp32s2-hal/examples/spi_eh1_loopback.rs +++ b/esp32s2-hal/examples/spi_eh1_loopback.rs @@ -20,7 +20,7 @@ use embedded_hal_1::spi::SpiBus; use esp32s2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32s2-hal/examples/spi_loopback.rs b/esp32s2-hal/examples/spi_loopback.rs index 8360cff637a..a38219d1541 100644 --- a/esp32s2-hal/examples/spi_loopback.rs +++ b/esp32s2-hal/examples/spi_loopback.rs @@ -19,7 +19,7 @@ use esp32s2_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32s2-hal/examples/spi_loopback_dma.rs b/esp32s2-hal/examples/spi_loopback_dma.rs index a8a72cc0996..7068e0cc7de 100644 --- a/esp32s2-hal/examples/spi_loopback_dma.rs +++ b/esp32s2-hal/examples/spi_loopback_dma.rs @@ -20,7 +20,7 @@ use esp32s2_hal::{ clock::ClockControl, dma::{DmaPriority}, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, pdma::Dma, prelude::*, spi::{Spi, SpiMode}, diff --git a/esp32s2-hal/examples/systimer.rs b/esp32s2-hal/examples/systimer.rs index e54c467b145..8150232d8de 100644 --- a/esp32s2-hal/examples/systimer.rs +++ b/esp32s2-hal/examples/systimer.rs @@ -11,7 +11,7 @@ use esp32s2_hal::{ clock::ClockControl, interrupt, interrupt::Priority, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, systimer::{Alarm, Periodic, SystemTimer, Target}, timer::TimerGroup, @@ -63,9 +63,9 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET1, Priority::Priority3).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET2, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority3).unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/esp32s2-hal/examples/timer_interrupt.rs b/esp32s2-hal/examples/timer_interrupt.rs index 3e227ae6bf1..a8c4b996dd9 100644 --- a/esp32s2-hal/examples/timer_interrupt.rs +++ b/esp32s2-hal/examples/timer_interrupt.rs @@ -12,7 +12,7 @@ use esp32s2_hal::{ clock::ClockControl, interrupt, interrupt::Priority, - pac::{self, Peripherals, TIMG0, TIMG1}, + peripherals::{self, Peripherals, TIMG0, TIMG1}, prelude::*, timer::{Timer, Timer0, Timer1, TimerGroup}, Rtc, @@ -51,10 +51,10 @@ fn main() -> ! { wdt1.disable(); rtc.rwdt.disable(); - interrupt::enable(pac::Interrupt::TG0_T0_LEVEL, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::TG0_T1_LEVEL, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::TG1_T0_LEVEL, Priority::Priority3).unwrap(); - interrupt::enable(pac::Interrupt::TG1_T1_LEVEL, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T0_LEVEL, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T1_LEVEL, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::TG1_T0_LEVEL, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::TG1_T1_LEVEL, Priority::Priority3).unwrap(); timer00.start(500u64.millis()); timer00.listen(); timer01.start(2500u64.millis()); diff --git a/esp32s2-hal/examples/usb_serial.rs b/esp32s2-hal/examples/usb_serial.rs index 70dd0c19d50..8d9f0d26145 100644 --- a/esp32s2-hal/examples/usb_serial.rs +++ b/esp32s2-hal/examples/usb_serial.rs @@ -8,7 +8,7 @@ use esp32s2_hal::{ clock::{ClockControl, CpuClock}, otg_fs::{UsbBus, USB}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/examples/watchdog.rs b/esp32s2-hal/examples/watchdog.rs index bc0204b2740..4152540a293 100644 --- a/esp32s2-hal/examples/watchdog.rs +++ b/esp32s2-hal/examples/watchdog.rs @@ -5,7 +5,7 @@ #![no_std] #![no_main] -use esp32s2_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32s2_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; use esp_backtrace as _; use esp_println::println; use xtensa_atomic_emulation_trap as _; diff --git a/esp32s2-hal/src/lib.rs b/esp32s2-hal/src/lib.rs index e4f001b95d8..31ed4886e22 100644 --- a/esp32s2-hal/src/lib.rs +++ b/esp32s2-hal/src/lib.rs @@ -16,10 +16,10 @@ pub use esp_hal_common::{ ledc, macros, otg_fs, - pac, prelude, pulse_control, - serial, + peripherals, + uart, spi, system, systimer, @@ -31,8 +31,8 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - Serial, sha + Uart, }; #[cfg(feature = "embassy")] @@ -46,7 +46,7 @@ pub mod analog { } #[no_mangle] -extern "C" fn EspDefaultHandler(_level: u32, _interrupt: pac::Interrupt) {} +extern "C" fn EspDefaultHandler(_level: u32, _interrupt: peripherals::Interrupt) {} #[no_mangle] extern "C" fn DefaultHandler() {} diff --git a/esp32s3-hal/examples/adc.rs b/esp32s3-hal/examples/adc.rs index 60e710e6f1d..4b4203e5113 100644 --- a/esp32s3-hal/examples/adc.rs +++ b/esp32s3-hal/examples/adc.rs @@ -9,7 +9,7 @@ use esp32s3_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC1}, clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32s3-hal/examples/advanced_serial.rs b/esp32s3-hal/examples/advanced_serial.rs index 30f4eeec4c2..d5e63b67f59 100644 --- a/esp32s3-hal/examples/advanced_serial.rs +++ b/esp32s3-hal/examples/advanced_serial.rs @@ -9,16 +9,16 @@ use esp32s3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, - serial::{ + uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, timer::TimerGroup, Delay, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use esp_println::println; @@ -52,7 +52,7 @@ fn main() -> ! { io.pins.gpio2.into_floating_input(), ); - let mut serial1 = Serial::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); + let mut serial1 = Uart::new_with_config(peripherals.UART1, Some(config), Some(pins), &clocks); let mut delay = Delay::new(&clocks); diff --git a/esp32s3-hal/examples/blinky.rs b/esp32s3-hal/examples/blinky.rs index 33d51a856bd..2030346474d 100644 --- a/esp32s3-hal/examples/blinky.rs +++ b/esp32s3-hal/examples/blinky.rs @@ -8,7 +8,7 @@ use esp32s3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Delay, diff --git a/esp32s3-hal/examples/clock_monitor.rs b/esp32s3-hal/examples/clock_monitor.rs index d101a002070..b3c4d797230 100644 --- a/esp32s3-hal/examples/clock_monitor.rs +++ b/esp32s3-hal/examples/clock_monitor.rs @@ -11,7 +11,7 @@ use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, }; @@ -41,7 +41,7 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); critical_section::with(|cs| RTC.borrow_ref_mut(cs).replace(rtc)); diff --git a/esp32s3-hal/examples/gpio_interrupt.rs b/esp32s3-hal/examples/gpio_interrupt.rs index a562464726b..c0dd33fd5a0 100644 --- a/esp32s3-hal/examples/gpio_interrupt.rs +++ b/esp32s3-hal/examples/gpio_interrupt.rs @@ -14,7 +14,7 @@ use esp32s3_hal::{ gpio::{Gpio0, IO, Event, Input, PullDown}, interrupt, macros::ram, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, timer::TimerGroup, Delay, @@ -48,7 +48,7 @@ fn main() -> ! { critical_section::with(|cs| BUTTON.borrow_ref_mut(cs).replace(button)); - interrupt::enable(pac::Interrupt::GPIO, interrupt::Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::GPIO, interrupt::Priority::Priority2).unwrap(); led.set_high().unwrap(); diff --git a/esp32s3-hal/examples/hello_rgb.rs b/esp32s3-hal/examples/hello_rgb.rs index e7c9c9728f2..833811df08d 100644 --- a/esp32s3-hal/examples/hello_rgb.rs +++ b/esp32s3-hal/examples/hello_rgb.rs @@ -13,7 +13,7 @@ use esp32s3_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, pulse_control::ClockSource, timer::TimerGroup, diff --git a/esp32s3-hal/examples/hello_world.rs b/esp32s3-hal/examples/hello_world.rs index 9ab714e9d11..a73199b3af0 100644 --- a/esp32s3-hal/examples/hello_world.rs +++ b/esp32s3-hal/examples/hello_world.rs @@ -8,11 +8,11 @@ use core::fmt::Write; use esp32s3_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; @@ -28,7 +28,7 @@ fn main() -> ! { let mut timer0 = timer_group0.timer0; let mut wdt = timer_group0.wdt; let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); // Disable MWDT and RWDT (Watchdog) flash boot protection wdt.disable(); diff --git a/esp32s3-hal/examples/i2c_display.rs b/esp32s3-hal/examples/i2c_display.rs index 43719179431..089d9b8c2a4 100644 --- a/esp32s3-hal/examples/i2c_display.rs +++ b/esp32s3-hal/examples/i2c_display.rs @@ -20,7 +20,13 @@ use embedded_graphics::{ text::{Alignment, Text}, }; use esp32s3_hal::{ - clock::ClockControl, gpio::IO, i2c::I2C, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc, + clock::ClockControl, + gpio::IO, + i2c::I2C, + peripherals::Peripherals, + prelude::*, + timer::TimerGroup, + Rtc, }; use esp_backtrace as _; use nb::block; diff --git a/esp32s3-hal/examples/ledc.rs b/esp32s3-hal/examples/ledc.rs index 412686101b7..951191d7a08 100644 --- a/esp32s3-hal/examples/ledc.rs +++ b/esp32s3-hal/examples/ledc.rs @@ -16,7 +16,7 @@ use esp32s3_hal::{ LowSpeed, LEDC, }, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/multicore.rs b/esp32s3-hal/examples/multicore.rs index 804c6cc89b6..775781c4990 100644 --- a/esp32s3-hal/examples/multicore.rs +++ b/esp32s3-hal/examples/multicore.rs @@ -10,7 +10,7 @@ use core::cell::RefCell; use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, - pac::{Peripherals, TIMG1}, + peripherals::{Peripherals, TIMG1}, prelude::*, timer::{Timer, Timer0, TimerGroup}, CpuControl, diff --git a/esp32s3-hal/examples/pulse_control.rs b/esp32s3-hal/examples/pulse_control.rs index 0288541ea44..99fe00ee3af 100644 --- a/esp32s3-hal/examples/pulse_control.rs +++ b/esp32s3-hal/examples/pulse_control.rs @@ -8,7 +8,7 @@ use esp32s3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, pulse_control::{ClockSource, ConfiguredChannel, OutputChannel, PulseCode, RepeatMode}, timer::TimerGroup, diff --git a/esp32s3-hal/examples/ram.rs b/esp32s3-hal/examples/ram.rs index 2dd277b9531..aa21f25f813 100644 --- a/esp32s3-hal/examples/ram.rs +++ b/esp32s3-hal/examples/ram.rs @@ -11,7 +11,7 @@ use esp32s3_hal::{ clock::ClockControl, macros::ram, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, }; diff --git a/esp32s3-hal/examples/read_efuse.rs b/esp32s3-hal/examples/read_efuse.rs index c5672d6034a..b03b32f0057 100644 --- a/esp32s3-hal/examples/read_efuse.rs +++ b/esp32s3-hal/examples/read_efuse.rs @@ -7,7 +7,7 @@ use esp32s3_hal::{ clock::ClockControl, efuse::Efuse, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/rtc_watchdog.rs b/esp32s3-hal/examples/rtc_watchdog.rs index 23495d2aa89..a03104e2d82 100644 --- a/esp32s3-hal/examples/rtc_watchdog.rs +++ b/esp32s3-hal/examples/rtc_watchdog.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, Rtc, Rwdt, @@ -38,7 +38,7 @@ fn main() -> ! { critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); - interrupt::enable(pac::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); loop {} } diff --git a/esp32s3-hal/examples/serial_interrupts.rs b/esp32s3-hal/examples/serial_interrupts.rs index ce57e8d1485..32567bb9686 100644 --- a/esp32s3-hal/examples/serial_interrupts.rs +++ b/esp32s3-hal/examples/serial_interrupts.rs @@ -11,18 +11,18 @@ use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, UART0}, + peripherals::{self, Peripherals, UART0}, prelude::*, - serial::config::AtCmdConfig, + uart::config::AtCmdConfig, timer::TimerGroup, Rtc, - Serial, + Uart, }; use esp_backtrace as _; use nb::block; use xtensa_lx_rt::entry; -static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); +static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { @@ -38,7 +38,7 @@ fn main() -> ! { let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks); let mut wdt1 = timer_group1.wdt; - let mut serial0 = Serial::new(peripherals.UART0); + let mut serial0 = Uart::new(peripherals.UART0); let mut rtc = Rtc::new(peripherals.RTC_CNTL); // Disable MWDT and RWDT (Watchdog) flash boot protection @@ -51,7 +51,7 @@ fn main() -> ! { serial0.listen_at_cmd(); serial0.listen_rx_fifo_full(); - interrupt::enable(pac::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); timer0.start(1u64.secs()); diff --git a/esp32s3-hal/examples/spi_eh1_device_loopback.rs b/esp32s3-hal/examples/spi_eh1_device_loopback.rs index 297e334dfc5..f5154d9826e 100644 --- a/esp32s3-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32s3-hal/examples/spi_eh1_device_loopback.rs @@ -22,7 +22,7 @@ use embedded_hal_1::spi::SpiDevice; use esp32s3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiBusController, SpiMode}, timer::TimerGroup, diff --git a/esp32s3-hal/examples/spi_eh1_loopback.rs b/esp32s3-hal/examples/spi_eh1_loopback.rs index d483538022c..522a1b1fd9c 100644 --- a/esp32s3-hal/examples/spi_eh1_loopback.rs +++ b/esp32s3-hal/examples/spi_eh1_loopback.rs @@ -20,7 +20,7 @@ use embedded_hal_1::spi::SpiBus; use esp32s3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32s3-hal/examples/spi_loopback.rs b/esp32s3-hal/examples/spi_loopback.rs index 7e7503e13bc..eb424e505b3 100644 --- a/esp32s3-hal/examples/spi_loopback.rs +++ b/esp32s3-hal/examples/spi_loopback.rs @@ -19,7 +19,7 @@ use esp32s3_hal::{ clock::ClockControl, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32s3-hal/examples/spi_loopback_dma.rs b/esp32s3-hal/examples/spi_loopback_dma.rs index 94a3dd96338..fd20925e43e 100644 --- a/esp32s3-hal/examples/spi_loopback_dma.rs +++ b/esp32s3-hal/examples/spi_loopback_dma.rs @@ -21,7 +21,7 @@ use esp32s3_hal::{ dma::{DmaPriority}, gdma::Gdma, gpio::IO, - pac::Peripherals, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32s3-hal/examples/systimer.rs b/esp32s3-hal/examples/systimer.rs index 8c360983e6c..7f71376957d 100644 --- a/esp32s3-hal/examples/systimer.rs +++ b/esp32s3-hal/examples/systimer.rs @@ -11,7 +11,7 @@ use esp32s3_hal::{ clock::ClockControl, interrupt, interrupt::Priority, - pac::{self, Peripherals}, + peripherals::{self, Peripherals}, prelude::*, systimer::{Alarm, Periodic, SystemTimer, Target}, timer::TimerGroup, @@ -62,9 +62,9 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::SYSTIMER_TARGET2, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority3).unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/esp32s3-hal/examples/timer_interrupt.rs b/esp32s3-hal/examples/timer_interrupt.rs index 9a99bf6bd7e..faaefa7f32c 100644 --- a/esp32s3-hal/examples/timer_interrupt.rs +++ b/esp32s3-hal/examples/timer_interrupt.rs @@ -12,7 +12,7 @@ use esp32s3_hal::{ clock::ClockControl, interrupt, interrupt::Priority, - pac::{self, Peripherals, TIMG0, TIMG1}, + peripherals::{self, Peripherals, TIMG0, TIMG1}, prelude::*, timer::{Timer, Timer0, Timer1, TimerGroup}, Rtc, @@ -50,10 +50,10 @@ fn main() -> ! { wdt1.disable(); rtc.rwdt.disable(); - interrupt::enable(pac::Interrupt::TG0_T0_LEVEL, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::TG0_T1_LEVEL, Priority::Priority2).unwrap(); - interrupt::enable(pac::Interrupt::TG1_T0_LEVEL, Priority::Priority3).unwrap(); - interrupt::enable(pac::Interrupt::TG1_T1_LEVEL, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T0_LEVEL, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::TG0_T1_LEVEL, Priority::Priority2).unwrap(); + interrupt::enable(peripherals::Interrupt::TG1_T0_LEVEL, Priority::Priority3).unwrap(); + interrupt::enable(peripherals::Interrupt::TG1_T1_LEVEL, Priority::Priority3).unwrap(); timer00.start(500u64.millis()); timer00.listen(); timer01.start(2500u64.millis()); diff --git a/esp32s3-hal/examples/usb_serial.rs b/esp32s3-hal/examples/usb_serial.rs index e2f9f8d9a6b..553a87ea10f 100644 --- a/esp32s3-hal/examples/usb_serial.rs +++ b/esp32s3-hal/examples/usb_serial.rs @@ -8,7 +8,7 @@ use esp32s3_hal::{ clock::{ClockControl, CpuClock}, otg_fs::{UsbBus, USB}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/usb_serial_jtag.rs b/esp32s3-hal/examples/usb_serial_jtag.rs index 82ebb6280e6..7f6f973b755 100644 --- a/esp32s3-hal/examples/usb_serial_jtag.rs +++ b/esp32s3-hal/examples/usb_serial_jtag.rs @@ -13,7 +13,8 @@ use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, interrupt, - pac::{self, Peripherals, USB_DEVICE}, + pac::{self, USB_DEVICE}, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/watchdog.rs b/esp32s3-hal/examples/watchdog.rs index f1bb092abd0..ae1aa998fb4 100644 --- a/esp32s3-hal/examples/watchdog.rs +++ b/esp32s3-hal/examples/watchdog.rs @@ -5,7 +5,7 @@ #![no_std] #![no_main] -use esp32s3_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32s3_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32s3-hal/src/lib.rs b/esp32s3-hal/src/lib.rs index 4d584488e43..85ce924d616 100644 --- a/esp32s3-hal/src/lib.rs +++ b/esp32s3-hal/src/lib.rs @@ -18,22 +18,22 @@ pub use esp_hal_common::{ macros, mcpwm, otg_fs, - pac, prelude, pulse_control, - serial, + uart, spi, system, systimer, timer, utils, + peripherals, Cpu, Delay, PulseControl, Rng, Rtc, Rwdt, - Serial, + Uart, UsbSerialJtag, sha }; @@ -49,7 +49,7 @@ pub mod analog { } #[no_mangle] -extern "C" fn EspDefaultHandler(_level: u32, _interrupt: pac::Interrupt) {} +extern "C" fn EspDefaultHandler(_level: u32, _interrupt: peripherals::Interrupt) {} #[no_mangle] extern "C" fn DefaultHandler() {} From 3b515b7baa48e7d57ae78e889e54347052484b6b Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Mon, 12 Dec 2022 11:14:05 +0100 Subject: [PATCH 3/6] Fixes after rebase --- esp-hal-common/src/prelude.rs | 4 ++-- esp-hal-common/src/pulse_control.rs | 2 +- esp32-hal/examples/embassy_hello_world.rs | 2 +- esp32-hal/examples/hello_rgb.rs | 2 +- esp32-hal/examples/i2c_bmp180_calibration_data.rs | 2 +- esp32-hal/examples/i2s_read.rs | 2 +- esp32-hal/examples/i2s_sound.rs | 2 +- esp32-hal/examples/mcpwm.rs | 2 +- esp32-hal/examples/sha.rs | 2 +- esp32-hal/src/lib.rs | 2 +- esp32c2-hal/examples/embassy_hello_world.rs | 2 +- esp32c2-hal/examples/i2c_bmp180_calibration_data.rs | 2 +- esp32c2-hal/examples/sha.rs | 2 +- esp32c3-hal/examples/embassy_hello_world.rs | 2 +- esp32c3-hal/examples/hello_rgb.rs | 2 +- esp32c3-hal/examples/i2c_bmp180_calibration_data.rs | 2 +- esp32c3-hal/examples/i2s_read.rs | 2 +- esp32c3-hal/examples/i2s_sound.rs | 2 +- esp32c3-hal/examples/sha.rs | 2 +- esp32c3-hal/examples/usb_serial_jtag.rs | 4 ++-- esp32c3-hal/src/lib.rs | 2 +- esp32s2-hal/examples/embassy_hello_world.rs | 2 +- esp32s2-hal/examples/i2c_bmp180_calibration_data.rs | 2 +- esp32s2-hal/examples/i2s_read.rs | 2 +- esp32s2-hal/examples/i2s_sound.rs | 2 +- esp32s2-hal/examples/sha.rs | 2 +- esp32s2-hal/src/lib.rs | 2 +- esp32s3-hal/examples/embassy_hello_world.rs | 2 +- esp32s3-hal/examples/i2c_bmp180_calibration_data.rs | 2 +- esp32s3-hal/examples/i2s_read.rs | 2 +- esp32s3-hal/examples/i2s_sound.rs | 2 +- esp32s3-hal/examples/mcpwm.rs | 2 +- esp32s3-hal/examples/sha.rs | 2 +- esp32s3-hal/examples/usb_serial_jtag.rs | 4 ++-- esp32s3-hal/src/lib.rs | 12 ++++++------ 35 files changed, 43 insertions(+), 43 deletions(-) diff --git a/esp-hal-common/src/prelude.rs b/esp-hal-common/src/prelude.rs index aefd61d1aed..13370e1ff8e 100644 --- a/esp-hal-common/src/prelude.rs +++ b/esp-hal-common/src/prelude.rs @@ -54,7 +54,7 @@ pub use crate::{ }, }, macros::*, - serial::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins}, + uart::{Instance as _esp_hal_uart_Instance, UartPins as _esp_hal_uart_UartPins}, spi::{ dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2, Instance as _esp_hal_spi_Instance, @@ -132,7 +132,7 @@ pub mod eh1 { }, }, macros::*, - serial::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins}, + uart::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins}, spi::{ dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2, Instance as _esp_hal_spi_Instance, diff --git a/esp-hal-common/src/pulse_control.rs b/esp-hal-common/src/pulse_control.rs index e0a2e94ebc2..926bfdccd47 100644 --- a/esp-hal-common/src/pulse_control.rs +++ b/esp-hal-common/src/pulse_control.rs @@ -36,7 +36,7 @@ //! //! ### Example (for ESP32-C3) //! ``` -//! let mut peripherals = pac::Peripherals::take().unwrap(); +//! let mut peripherals = peripherals::Peripherals::take().unwrap(); //! //! // Configure RMT peripheral globally //! let pulse = PulseControl::new( diff --git a/esp32-hal/examples/embassy_hello_world.rs b/esp32-hal/examples/embassy_hello_world.rs index 2fedcc9e4ae..c3eb1feaf6b 100644 --- a/esp32-hal/examples/embassy_hello_world.rs +++ b/esp32-hal/examples/embassy_hello_world.rs @@ -9,7 +9,7 @@ use esp32_hal::{ clock::ClockControl, prelude::*, timer::TimerGroup, - Rtc, embassy, pac::Peripherals, + Rtc, embassy, peripherals::Peripherals, }; use esp_backtrace as _; use static_cell::StaticCell; diff --git a/esp32-hal/examples/hello_rgb.rs b/esp32-hal/examples/hello_rgb.rs index e239db6a9fa..9e5f7eafa4e 100644 --- a/esp32-hal/examples/hello_rgb.rs +++ b/esp32-hal/examples/hello_rgb.rs @@ -15,7 +15,7 @@ use esp32_hal::{ clock::ClockControl, - pac, + peripherals, prelude::*, timer::TimerGroup, utils::{smartLedAdapter, SmartLedsAdapter}, diff --git a/esp32-hal/examples/i2c_bmp180_calibration_data.rs b/esp32-hal/examples/i2c_bmp180_calibration_data.rs index a7face9009a..5371c184b18 100644 --- a/esp32-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32-hal/examples/i2c_bmp180_calibration_data.rs @@ -13,7 +13,7 @@ use esp32_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/examples/i2s_read.rs b/esp32-hal/examples/i2s_read.rs index a553528883c..cf2ddc444b1 100644 --- a/esp32-hal/examples/i2s_read.rs +++ b/esp32-hal/examples/i2s_read.rs @@ -18,7 +18,7 @@ use esp32_hal::{ dma::{DmaPriority}, pdma::Dma, i2s::{DataFormat, I2s, NoMclk, Standard, I2s0New, PinsBclkWsDin, I2sReadDma}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/examples/i2s_sound.rs b/esp32-hal/examples/i2s_sound.rs index 118a6b42792..45654bcf642 100644 --- a/esp32-hal/examples/i2s_sound.rs +++ b/esp32-hal/examples/i2s_sound.rs @@ -34,7 +34,7 @@ use esp32_hal::{ dma::DmaPriority, pdma::Dma, i2s::{DataFormat, I2s, I2sWriteDma, NoMclk, PinsBclkWsDout, Standard, I2s0New}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/examples/mcpwm.rs b/esp32-hal/examples/mcpwm.rs index 1bc4caf1857..c8ef1a0dff5 100644 --- a/esp32-hal/examples/mcpwm.rs +++ b/esp32-hal/examples/mcpwm.rs @@ -13,7 +13,7 @@ use esp32_hal::{ operator::PwmPinConfig, timer::PwmWorkingMode, }, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/examples/sha.rs b/esp32-hal/examples/sha.rs index 79a1abc9503..c71b9513992 100644 --- a/esp32-hal/examples/sha.rs +++ b/esp32-hal/examples/sha.rs @@ -6,7 +6,7 @@ use esp32_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32-hal/src/lib.rs b/esp32-hal/src/lib.rs index fe0060ce04d..7b5e667f965 100644 --- a/esp32-hal/src/lib.rs +++ b/esp32-hal/src/lib.rs @@ -31,7 +31,7 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - sha + sha, Uart, }; diff --git a/esp32c2-hal/examples/embassy_hello_world.rs b/esp32c2-hal/examples/embassy_hello_world.rs index 2801037885b..4072f499285 100644 --- a/esp32c2-hal/examples/embassy_hello_world.rs +++ b/esp32c2-hal/examples/embassy_hello_world.rs @@ -7,7 +7,7 @@ use embassy_time::{Duration, Timer}; use esp32c2_hal::{ clock::ClockControl, embassy, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs b/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs index 6fab21ca1ef..a121d92f848 100644 --- a/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs @@ -13,7 +13,7 @@ use esp32c2_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c2-hal/examples/sha.rs b/esp32c2-hal/examples/sha.rs index 07234e64cd5..32fa5cd029b 100644 --- a/esp32c2-hal/examples/sha.rs +++ b/esp32c2-hal/examples/sha.rs @@ -6,7 +6,7 @@ use esp32c2_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/embassy_hello_world.rs b/esp32c3-hal/examples/embassy_hello_world.rs index f974e23bb40..771050fca0c 100644 --- a/esp32c3-hal/examples/embassy_hello_world.rs +++ b/esp32c3-hal/examples/embassy_hello_world.rs @@ -9,7 +9,7 @@ use esp32c3_hal::{ clock::ClockControl, prelude::*, timer::TimerGroup, - Rtc, embassy, pac::Peripherals, + Rtc, embassy, peripherals::Peripherals, }; use esp_backtrace as _; use static_cell::StaticCell; diff --git a/esp32c3-hal/examples/hello_rgb.rs b/esp32c3-hal/examples/hello_rgb.rs index ea051772ada..361785e9f76 100644 --- a/esp32c3-hal/examples/hello_rgb.rs +++ b/esp32c3-hal/examples/hello_rgb.rs @@ -13,7 +13,7 @@ use esp32c3_hal::{ clock::ClockControl, - pac, + peripherals, prelude::*, pulse_control::ClockSource, timer::TimerGroup, diff --git a/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs b/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs index 18469146525..fe78c9958f7 100644 --- a/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs @@ -13,7 +13,7 @@ use esp32c3_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/i2s_read.rs b/esp32c3-hal/examples/i2s_read.rs index ded6e994361..c09c1a01915 100644 --- a/esp32c3-hal/examples/i2s_read.rs +++ b/esp32c3-hal/examples/i2s_read.rs @@ -19,7 +19,7 @@ use esp32c3_hal::{ dma::DmaPriority, gdma::Gdma, i2s::{DataFormat, I2s, I2sReadDma, MclkPin, PinsBclkWsDin, Standard, I2s0New}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/i2s_sound.rs b/esp32c3-hal/examples/i2s_sound.rs index 8b084506940..67a17c4f95b 100644 --- a/esp32c3-hal/examples/i2s_sound.rs +++ b/esp32c3-hal/examples/i2s_sound.rs @@ -35,7 +35,7 @@ use esp32c3_hal::{ dma::DmaPriority, gdma::Gdma, i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/sha.rs b/esp32c3-hal/examples/sha.rs index 27eca891b85..8c5b165828a 100644 --- a/esp32c3-hal/examples/sha.rs +++ b/esp32c3-hal/examples/sha.rs @@ -6,7 +6,7 @@ use esp32c3_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32c3-hal/examples/usb_serial_jtag.rs b/esp32c3-hal/examples/usb_serial_jtag.rs index a9e94966e6d..3bf8ea53e9d 100644 --- a/esp32c3-hal/examples/usb_serial_jtag.rs +++ b/esp32c3-hal/examples/usb_serial_jtag.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, interrupt, - pac::{self, USB_DEVICE}, + peripherals::{self, USB_DEVICE}, peripherals::Peripherals, prelude::*, timer::TimerGroup, @@ -55,7 +55,7 @@ fn main() -> ! { critical_section::with(|cs| USB_SERIAL.borrow_ref_mut(cs).replace(usb_serial)); interrupt::enable( - pac::Interrupt::USB_SERIAL_JTAG, + peripherals::Interrupt::USB_SERIAL_JTAG, interrupt::Priority::Priority1, ) .unwrap(); diff --git a/esp32c3-hal/src/lib.rs b/esp32c3-hal/src/lib.rs index 944982044b2..57e8177552c 100644 --- a/esp32c3-hal/src/lib.rs +++ b/esp32c3-hal/src/lib.rs @@ -407,7 +407,7 @@ unsafe fn configure_mmu() { 0, ); - let peripherals = pac::Peripherals::steal(); + let peripherals = peripherals::Peripherals::steal(); peripherals.EXTMEM.icache_ctrl1.modify(|_, w| { w.icache_shut_ibus() .clear_bit() diff --git a/esp32s2-hal/examples/embassy_hello_world.rs b/esp32s2-hal/examples/embassy_hello_world.rs index b013a98f0fd..61a0304ed1d 100644 --- a/esp32s2-hal/examples/embassy_hello_world.rs +++ b/esp32s2-hal/examples/embassy_hello_world.rs @@ -9,7 +9,7 @@ use esp32s2_hal::{ clock::ClockControl, prelude::*, timer::TimerGroup, - Rtc, embassy, pac::Peripherals, + Rtc, embassy, peripherals::Peripherals, }; use esp_backtrace as _; use xtensa_atomic_emulation_trap as _; diff --git a/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs b/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs index ea5355c5f4c..15fbfb01f83 100644 --- a/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs @@ -13,7 +13,7 @@ use esp32s2_hal::{ clock::ClockControl, gpio::IO, i2c::I2C, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/examples/i2s_read.rs b/esp32s2-hal/examples/i2s_read.rs index ccc6ca78b40..5cfb85cf6a7 100644 --- a/esp32s2-hal/examples/i2s_read.rs +++ b/esp32s2-hal/examples/i2s_read.rs @@ -18,7 +18,7 @@ use esp32s2_hal::{ dma::{DmaPriority}, pdma::Dma, i2s::{DataFormat, I2s, NoMclk, Standard, I2s0New, PinsBclkWsDin, I2sReadDma}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/examples/i2s_sound.rs b/esp32s2-hal/examples/i2s_sound.rs index 21cb3216e03..1b7ef15912d 100644 --- a/esp32s2-hal/examples/i2s_sound.rs +++ b/esp32s2-hal/examples/i2s_sound.rs @@ -35,7 +35,7 @@ use esp32s2_hal::{ dma::DmaPriority, pdma::Dma, i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/examples/sha.rs b/esp32s2-hal/examples/sha.rs index 1e16b0f4842..63feac4dc1f 100644 --- a/esp32s2-hal/examples/sha.rs +++ b/esp32s2-hal/examples/sha.rs @@ -6,7 +6,7 @@ use esp32s2_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s2-hal/src/lib.rs b/esp32s2-hal/src/lib.rs index 31ed4886e22..ac2ef6cddfb 100644 --- a/esp32s2-hal/src/lib.rs +++ b/esp32s2-hal/src/lib.rs @@ -31,7 +31,7 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - sha + sha, Uart, }; diff --git a/esp32s3-hal/examples/embassy_hello_world.rs b/esp32s3-hal/examples/embassy_hello_world.rs index f707a86a5cd..0fed5c5f1fe 100644 --- a/esp32s3-hal/examples/embassy_hello_world.rs +++ b/esp32s3-hal/examples/embassy_hello_world.rs @@ -9,7 +9,7 @@ use esp32s3_hal::{ clock::ClockControl, prelude::*, timer::TimerGroup, - Rtc, embassy, pac::Peripherals, + Rtc, embassy, peripherals::Peripherals, }; use esp_backtrace as _; use static_cell::StaticCell; diff --git a/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs b/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs index 5eb692c56a8..0f63a6e2a1f 100644 --- a/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs @@ -10,7 +10,7 @@ #![no_main] use esp32s3_hal::{ - clock::ClockControl, gpio::IO, i2c::I2C, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc, + clock::ClockControl, gpio::IO, i2c::I2C, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, }; use esp_backtrace as _; use esp_println::println; diff --git a/esp32s3-hal/examples/i2s_read.rs b/esp32s3-hal/examples/i2s_read.rs index 73dc48c219a..1cf43636100 100644 --- a/esp32s3-hal/examples/i2s_read.rs +++ b/esp32s3-hal/examples/i2s_read.rs @@ -19,7 +19,7 @@ use esp32s3_hal::{ dma::DmaPriority, gdma::Gdma, i2s::{DataFormat, I2s, I2sReadDma, MclkPin, PinsBclkWsDin, Standard, I2s0New}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/i2s_sound.rs b/esp32s3-hal/examples/i2s_sound.rs index 6f790ddc780..911fc121ff3 100644 --- a/esp32s3-hal/examples/i2s_sound.rs +++ b/esp32s3-hal/examples/i2s_sound.rs @@ -35,7 +35,7 @@ use esp32s3_hal::{ dma::DmaPriority, gdma::Gdma, i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New}, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/mcpwm.rs b/esp32s3-hal/examples/mcpwm.rs index 43e62c6b5c1..8a772b6ff66 100644 --- a/esp32s3-hal/examples/mcpwm.rs +++ b/esp32s3-hal/examples/mcpwm.rs @@ -13,7 +13,7 @@ use esp32s3_hal::{ operator::PwmPinConfig, timer::PwmWorkingMode, }, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/sha.rs b/esp32s3-hal/examples/sha.rs index b47b11f515b..7ccda2975da 100644 --- a/esp32s3-hal/examples/sha.rs +++ b/esp32s3-hal/examples/sha.rs @@ -6,7 +6,7 @@ use esp32s3_hal::{ clock::ClockControl, - pac::Peripherals, + peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, diff --git a/esp32s3-hal/examples/usb_serial_jtag.rs b/esp32s3-hal/examples/usb_serial_jtag.rs index 7f6f973b755..f7e754c3052 100644 --- a/esp32s3-hal/examples/usb_serial_jtag.rs +++ b/esp32s3-hal/examples/usb_serial_jtag.rs @@ -13,7 +13,7 @@ use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, interrupt, - pac::{self, USB_DEVICE}, + peripherals::{self, USB_DEVICE}, peripherals::Peripherals, prelude::*, timer::TimerGroup, @@ -50,7 +50,7 @@ fn main() -> ! { critical_section::with(|cs| USB_SERIAL.borrow_ref_mut(cs).replace(usb_serial)); - interrupt::enable(pac::Interrupt::USB_DEVICE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::USB_DEVICE, interrupt::Priority::Priority1).unwrap(); loop { critical_section::with(|cs| { diff --git a/esp32s3-hal/src/lib.rs b/esp32s3-hal/src/lib.rs index 85ce924d616..e3b5e472372 100644 --- a/esp32s3-hal/src/lib.rs +++ b/esp32s3-hal/src/lib.rs @@ -142,24 +142,24 @@ pub unsafe fn startup_direct_boot() -> ! { // do some configurations for compatability with the 2nd stage bootloader // this is a workaround and ideally we should deal with these settings in other // places - (&*crate::pac::TIMG0::PTR) + (&*crate::peripherals::TIMG0::PTR) .int_ena_timers .modify(|_, w| w.t0_int_ena().set_bit().t1_int_ena().set_bit()); - (&*crate::pac::TIMG1::PTR) + (&*crate::peripherals::TIMG1::PTR) .int_ena_timers .modify(|_, w| w.t0_int_ena().set_bit().t1_int_ena().set_bit()); - (&*crate::pac::RTC_CNTL::PTR) + (&*crate::peripherals::RTC_CNTL::PTR) .swd_wprotect .write(|w| w.bits(0x8f1d312a)); - (&*crate::pac::RTC_CNTL::PTR) + (&*crate::peripherals::RTC_CNTL::PTR) .swd_conf .modify(|_, w| w.swd_disable().set_bit()); - (&*crate::pac::RTC_CNTL::PTR) + (&*crate::peripherals::RTC_CNTL::PTR) .swd_wprotect .write(|w| w.bits(0)); - (&*crate::pac::SYSTEM::PTR) + (&*crate::peripherals::SYSTEM::PTR) .sysclk_conf .modify(|_, w| w.soc_clk_sel().bits(1)); From b2020b01717ffc96621db6916b962a174861e58a Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Mon, 12 Dec 2022 14:35:47 +0100 Subject: [PATCH 4/6] Update the signature of Peripherals::take --- esp-hal-common/src/peripheral.rs | 26 +++++-------------- esp-hal-common/src/pulse_control.rs | 2 +- esp-hal-common/src/system.rs | 2 +- esp32-hal/examples/adc.rs | 2 +- esp32-hal/examples/advanced_serial.rs | 2 +- esp32-hal/examples/blinky.rs | 2 +- esp32-hal/examples/clock_monitor.rs | 2 +- esp32-hal/examples/dac.rs | 2 +- esp32-hal/examples/embassy_hello_world.rs | 2 +- esp32-hal/examples/gpio_interrupt.rs | 2 +- esp32-hal/examples/hello_rgb.rs | 2 +- esp32-hal/examples/hello_world.rs | 2 +- .../examples/i2c_bmp180_calibration_data.rs | 2 +- esp32-hal/examples/i2c_display.rs | 2 +- esp32-hal/examples/i2s_read.rs | 2 +- esp32-hal/examples/i2s_sound.rs | 2 +- esp32-hal/examples/ledc.rs | 2 +- esp32-hal/examples/mcpwm.rs | 2 +- esp32-hal/examples/multicore.rs | 2 +- esp32-hal/examples/pulse_control.rs | 2 +- esp32-hal/examples/ram.rs | 2 +- esp32-hal/examples/read_efuse.rs | 2 +- esp32-hal/examples/rtc_watchdog.rs | 2 +- esp32-hal/examples/serial_interrupts.rs | 2 +- esp32-hal/examples/sha.rs | 2 +- esp32-hal/examples/spi_eh1_device_loopback.rs | 2 +- esp32-hal/examples/spi_eh1_loopback.rs | 2 +- esp32-hal/examples/spi_loopback.rs | 2 +- esp32-hal/examples/spi_loopback_dma.rs | 2 +- esp32-hal/examples/timer_interrupt.rs | 2 +- esp32-hal/examples/watchdog.rs | 2 +- esp32c2-hal/examples/adc.rs | 2 +- esp32c2-hal/examples/advanced_serial.rs | 2 +- esp32c2-hal/examples/blinky.rs | 2 +- esp32c2-hal/examples/clock_monitor.rs | 2 +- esp32c2-hal/examples/embassy_hello_world.rs | 2 +- esp32c2-hal/examples/gpio_interrupt.rs | 2 +- esp32c2-hal/examples/hello_world.rs | 2 +- .../examples/i2c_bmp180_calibration_data.rs | 2 +- esp32c2-hal/examples/i2c_display.rs | 2 +- esp32c2-hal/examples/ledc.rs | 2 +- esp32c2-hal/examples/read_efuse.rs | 2 +- esp32c2-hal/examples/rtc_watchdog.rs | 2 +- esp32c2-hal/examples/serial_interrupts.rs | 2 +- esp32c2-hal/examples/sha.rs | 2 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32c2-hal/examples/spi_eh1_loopback.rs | 2 +- esp32c2-hal/examples/spi_loopback.rs | 2 +- esp32c2-hal/examples/spi_loopback_dma.rs | 2 +- esp32c2-hal/examples/systimer.rs | 2 +- esp32c2-hal/examples/timer_interrupt.rs | 2 +- esp32c2-hal/examples/watchdog.rs | 2 +- esp32c3-hal/examples/adc.rs | 2 +- esp32c3-hal/examples/advanced_serial.rs | 2 +- esp32c3-hal/examples/blinky.rs | 2 +- esp32c3-hal/examples/clock_monitor.rs | 2 +- esp32c3-hal/examples/embassy_hello_world.rs | 2 +- esp32c3-hal/examples/gpio_interrupt.rs | 2 +- esp32c3-hal/examples/hello_rgb.rs | 2 +- esp32c3-hal/examples/hello_world.rs | 2 +- .../examples/i2c_bmp180_calibration_data.rs | 2 +- esp32c3-hal/examples/i2c_display.rs | 2 +- esp32c3-hal/examples/i2s_read.rs | 2 +- esp32c3-hal/examples/i2s_sound.rs | 2 +- esp32c3-hal/examples/ledc.rs | 2 +- esp32c3-hal/examples/pulse_control.rs | 2 +- esp32c3-hal/examples/ram.rs | 2 +- esp32c3-hal/examples/read_efuse.rs | 2 +- esp32c3-hal/examples/rtc_watchdog.rs | 2 +- esp32c3-hal/examples/serial_interrupts.rs | 2 +- esp32c3-hal/examples/sha.rs | 2 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32c3-hal/examples/spi_eh1_loopback.rs | 2 +- esp32c3-hal/examples/spi_loopback.rs | 2 +- esp32c3-hal/examples/spi_loopback_dma.rs | 2 +- esp32c3-hal/examples/systimer.rs | 2 +- esp32c3-hal/examples/timer_interrupt.rs | 2 +- esp32c3-hal/examples/usb_serial_jtag.rs | 2 +- esp32c3-hal/examples/watchdog.rs | 2 +- esp32s2-hal/examples/adc.rs | 2 +- esp32s2-hal/examples/advanced_serial.rs | 2 +- esp32s2-hal/examples/blinky.rs | 2 +- esp32s2-hal/examples/clock_monitor.rs | 2 +- esp32s2-hal/examples/dac.rs | 2 +- esp32s2-hal/examples/embassy_hello_world.rs | 2 +- esp32s2-hal/examples/gpio_interrupt.rs | 2 +- esp32s2-hal/examples/hello_rgb.rs | 2 +- esp32s2-hal/examples/hello_world.rs | 2 +- .../examples/i2c_bmp180_calibration_data.rs | 2 +- esp32s2-hal/examples/i2c_display.rs | 2 +- esp32s2-hal/examples/i2s_read.rs | 2 +- esp32s2-hal/examples/i2s_sound.rs | 2 +- esp32s2-hal/examples/ledc.rs | 2 +- esp32s2-hal/examples/pulse_control.rs | 2 +- esp32s2-hal/examples/ram.rs | 2 +- esp32s2-hal/examples/read_efuse.rs | 2 +- esp32s2-hal/examples/rtc_watchdog.rs | 2 +- esp32s2-hal/examples/serial_interrupts.rs | 2 +- esp32s2-hal/examples/sha.rs | 2 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32s2-hal/examples/spi_eh1_loopback.rs | 2 +- esp32s2-hal/examples/spi_loopback.rs | 2 +- esp32s2-hal/examples/spi_loopback_dma.rs | 2 +- esp32s2-hal/examples/systimer.rs | 2 +- esp32s2-hal/examples/timer_interrupt.rs | 2 +- esp32s2-hal/examples/usb_serial.rs | 2 +- esp32s2-hal/examples/watchdog.rs | 2 +- esp32s3-hal/examples/adc.rs | 2 +- esp32s3-hal/examples/advanced_serial.rs | 2 +- esp32s3-hal/examples/blinky.rs | 2 +- esp32s3-hal/examples/clock_monitor.rs | 2 +- esp32s3-hal/examples/embassy_hello_world.rs | 2 +- esp32s3-hal/examples/gpio_interrupt.rs | 2 +- esp32s3-hal/examples/hello_rgb.rs | 2 +- esp32s3-hal/examples/hello_world.rs | 2 +- .../examples/i2c_bmp180_calibration_data.rs | 2 +- esp32s3-hal/examples/i2c_display.rs | 2 +- esp32s3-hal/examples/i2s_read.rs | 2 +- esp32s3-hal/examples/i2s_sound.rs | 2 +- esp32s3-hal/examples/ledc.rs | 2 +- esp32s3-hal/examples/mcpwm.rs | 2 +- esp32s3-hal/examples/multicore.rs | 2 +- esp32s3-hal/examples/pulse_control.rs | 2 +- esp32s3-hal/examples/ram.rs | 2 +- esp32s3-hal/examples/read_efuse.rs | 2 +- esp32s3-hal/examples/rtc_watchdog.rs | 2 +- esp32s3-hal/examples/serial_interrupts.rs | 2 +- esp32s3-hal/examples/sha.rs | 2 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32s3-hal/examples/spi_eh1_loopback.rs | 2 +- esp32s3-hal/examples/spi_loopback.rs | 2 +- esp32s3-hal/examples/spi_loopback_dma.rs | 2 +- esp32s3-hal/examples/systimer.rs | 2 +- esp32s3-hal/examples/timer_interrupt.rs | 2 +- esp32s3-hal/examples/usb_serial.rs | 2 +- esp32s3-hal/examples/usb_serial_jtag.rs | 2 +- esp32s3-hal/examples/watchdog.rs | 2 +- 137 files changed, 143 insertions(+), 155 deletions(-) diff --git a/esp-hal-common/src/peripheral.rs b/esp-hal-common/src/peripheral.rs index 41a364856fb..52cb5c46979 100644 --- a/esp-hal-common/src/peripheral.rs +++ b/esp-hal-common/src/peripheral.rs @@ -186,31 +186,19 @@ mod peripheral_macros { } impl Peripherals { - // /// Returns all the peripherals *once* - // #[inline] - // pub fn take() -> Self { - - // #[no_mangle] - // static mut _ESP_HAL_DEVICE_PERIPHERALS: bool = false; - - // critical_section::with(|_| unsafe { - // if _ESP_HAL_DEVICE_PERIPHERALS { - // panic!("init called more than once!") - // } - // _ESP_HAL_DEVICE_PERIPHERALS = true; - // Self::steal() - // }) - // } - - pub fn take() -> Option { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Self { + #[no_mangle] static mut _ESP_HAL_DEVICE_PERIPHERALS: bool = false; + critical_section::with(|_| unsafe { if _ESP_HAL_DEVICE_PERIPHERALS { - return None; + panic!("init called more than once!") } _ESP_HAL_DEVICE_PERIPHERALS = true; - Some(Peripherals::steal()) + Self::steal() }) } } diff --git a/esp-hal-common/src/pulse_control.rs b/esp-hal-common/src/pulse_control.rs index 926bfdccd47..c36bfc769e0 100644 --- a/esp-hal-common/src/pulse_control.rs +++ b/esp-hal-common/src/pulse_control.rs @@ -36,7 +36,7 @@ //! //! ### Example (for ESP32-C3) //! ``` -//! let mut peripherals = peripherals::Peripherals::take().unwrap(); +//! let mut peripherals = peripherals::Peripherals::take(); //! //! // Configure RMT peripheral globally //! let pulse = PulseControl::new( diff --git a/esp-hal-common/src/system.rs b/esp-hal-common/src/system.rs index 4d72c5bbe53..7dce0525459 100644 --- a/esp-hal-common/src/system.rs +++ b/esp-hal-common/src/system.rs @@ -4,7 +4,7 @@ //! //! Example //! ```no_run -//! let peripherals = Peripherals::take().unwrap(); +//! let peripherals = Peripherals::take(); //! let system = peripherals.SYSTEM.split(); //! let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); //! ``` diff --git a/esp32-hal/examples/adc.rs b/esp32-hal/examples/adc.rs index ddf5b2e7059..3d30252bfef 100644 --- a/esp32-hal/examples/adc.rs +++ b/esp32-hal/examples/adc.rs @@ -21,7 +21,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/advanced_serial.rs b/esp32-hal/examples/advanced_serial.rs index 75fbded9a97..b95f3bff423 100644 --- a/esp32-hal/examples/advanced_serial.rs +++ b/esp32-hal/examples/advanced_serial.rs @@ -27,7 +27,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/blinky.rs b/esp32-hal/examples/blinky.rs index d1a6b668feb..6f772da019f 100644 --- a/esp32-hal/examples/blinky.rs +++ b/esp32-hal/examples/blinky.rs @@ -19,7 +19,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/clock_monitor.rs b/esp32-hal/examples/clock_monitor.rs index eb6d6f51520..f0afe7b8bab 100644 --- a/esp32-hal/examples/clock_monitor.rs +++ b/esp32-hal/examples/clock_monitor.rs @@ -22,7 +22,7 @@ static RTC: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/dac.rs b/esp32-hal/examples/dac.rs index 5fa4a18a278..e2a6465e08a 100644 --- a/esp32-hal/examples/dac.rs +++ b/esp32-hal/examples/dac.rs @@ -20,7 +20,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/embassy_hello_world.rs b/esp32-hal/examples/embassy_hello_world.rs index c3eb1feaf6b..ca7cb15a260 100644 --- a/esp32-hal/examples/embassy_hello_world.rs +++ b/esp32-hal/examples/embassy_hello_world.rs @@ -35,7 +35,7 @@ static EXECUTOR: StaticCell = StaticCell::new(); #[xtensa_lx_rt::entry] fn main() -> ! { esp_println::println!("Init!"); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/gpio_interrupt.rs b/esp32-hal/examples/gpio_interrupt.rs index 90c8d0d2b53..be2b3b38dce 100644 --- a/esp32-hal/examples/gpio_interrupt.rs +++ b/esp32-hal/examples/gpio_interrupt.rs @@ -27,7 +27,7 @@ static BUTTON: Mutex>>>> = Mutex::new(RefCe #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/hello_rgb.rs b/esp32-hal/examples/hello_rgb.rs index 9e5f7eafa4e..2bb5c336094 100644 --- a/esp32-hal/examples/hello_rgb.rs +++ b/esp32-hal/examples/hello_rgb.rs @@ -36,7 +36,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = peripherals::Peripherals::take().unwrap(); + let peripherals = peripherals::Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/hello_world.rs b/esp32-hal/examples/hello_world.rs index d7e4393a074..74a162eb3b2 100644 --- a/esp32-hal/examples/hello_world.rs +++ b/esp32-hal/examples/hello_world.rs @@ -20,7 +20,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/i2c_bmp180_calibration_data.rs b/esp32-hal/examples/i2c_bmp180_calibration_data.rs index 5371c184b18..e25a47b3d46 100644 --- a/esp32-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32-hal/examples/i2c_bmp180_calibration_data.rs @@ -24,7 +24,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/i2c_display.rs b/esp32-hal/examples/i2c_display.rs index 2587f3ec322..34c7bfb09a0 100644 --- a/esp32-hal/examples/i2c_display.rs +++ b/esp32-hal/examples/i2c_display.rs @@ -35,7 +35,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/i2s_read.rs b/esp32-hal/examples/i2s_read.rs index cf2ddc444b1..50dee73eb69 100644 --- a/esp32-hal/examples/i2s_read.rs +++ b/esp32-hal/examples/i2s_read.rs @@ -30,7 +30,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/i2s_sound.rs b/esp32-hal/examples/i2s_sound.rs index 45654bcf642..ad016008587 100644 --- a/esp32-hal/examples/i2s_sound.rs +++ b/esp32-hal/examples/i2s_sound.rs @@ -53,7 +53,7 @@ const SINE: [i16; 64] = [ #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/ledc.rs b/esp32-hal/examples/ledc.rs index 7a7c76d0e06..6c5b2c82ad7 100644 --- a/esp32-hal/examples/ledc.rs +++ b/esp32-hal/examples/ledc.rs @@ -25,7 +25,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/mcpwm.rs b/esp32-hal/examples/mcpwm.rs index c8ef1a0dff5..777671d8503 100644 --- a/esp32-hal/examples/mcpwm.rs +++ b/esp32-hal/examples/mcpwm.rs @@ -23,7 +23,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/multicore.rs b/esp32-hal/examples/multicore.rs index 654509daf24..358c71cb4a3 100644 --- a/esp32-hal/examples/multicore.rs +++ b/esp32-hal/examples/multicore.rs @@ -23,7 +23,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/pulse_control.rs b/esp32-hal/examples/pulse_control.rs index c8ccda20c8f..7fc6ac6e775 100644 --- a/esp32-hal/examples/pulse_control.rs +++ b/esp32-hal/examples/pulse_control.rs @@ -20,7 +20,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/ram.rs b/esp32-hal/examples/ram.rs index a5b3253fd6f..b52e3a629f0 100644 --- a/esp32-hal/examples/ram.rs +++ b/esp32-hal/examples/ram.rs @@ -31,7 +31,7 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/read_efuse.rs b/esp32-hal/examples/read_efuse.rs index a640c5152d3..c0eedee86cc 100644 --- a/esp32-hal/examples/read_efuse.rs +++ b/esp32-hal/examples/read_efuse.rs @@ -18,7 +18,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/rtc_watchdog.rs b/esp32-hal/examples/rtc_watchdog.rs index 17b23d0556e..4f411f09e3d 100644 --- a/esp32-hal/examples/rtc_watchdog.rs +++ b/esp32-hal/examples/rtc_watchdog.rs @@ -24,7 +24,7 @@ static RWDT: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/serial_interrupts.rs b/esp32-hal/examples/serial_interrupts.rs index 18144f9b149..1a071306a5f 100644 --- a/esp32-hal/examples/serial_interrupts.rs +++ b/esp32-hal/examples/serial_interrupts.rs @@ -26,7 +26,7 @@ static SERIAL: Mutex>>> = Mutex::new(RefCell::new(Non #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/sha.rs b/esp32-hal/examples/sha.rs index c71b9513992..9c2c074e619 100644 --- a/esp32-hal/examples/sha.rs +++ b/esp32-hal/examples/sha.rs @@ -20,7 +20,7 @@ use sha2::{Sha512, Digest}; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/spi_eh1_device_loopback.rs b/esp32-hal/examples/spi_eh1_device_loopback.rs index d095640279c..bd9eb7dc753 100644 --- a/esp32-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32-hal/examples/spi_eh1_device_loopback.rs @@ -35,7 +35,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/spi_eh1_loopback.rs b/esp32-hal/examples/spi_eh1_loopback.rs index 32c30e9ace2..9aab98eee92 100644 --- a/esp32-hal/examples/spi_eh1_loopback.rs +++ b/esp32-hal/examples/spi_eh1_loopback.rs @@ -33,7 +33,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/spi_loopback.rs b/esp32-hal/examples/spi_loopback.rs index 60ca0986377..d8583508897 100644 --- a/esp32-hal/examples/spi_loopback.rs +++ b/esp32-hal/examples/spi_loopback.rs @@ -32,7 +32,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/spi_loopback_dma.rs b/esp32-hal/examples/spi_loopback_dma.rs index 12aebf614fc..b02380a4db1 100644 --- a/esp32-hal/examples/spi_loopback_dma.rs +++ b/esp32-hal/examples/spi_loopback_dma.rs @@ -34,7 +34,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/timer_interrupt.rs b/esp32-hal/examples/timer_interrupt.rs index c57217f4db1..7b52ce559ad 100644 --- a/esp32-hal/examples/timer_interrupt.rs +++ b/esp32-hal/examples/timer_interrupt.rs @@ -27,7 +27,7 @@ static TIMER11: Mutex>>>> = Mutex::new(RefCel #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32-hal/examples/watchdog.rs b/esp32-hal/examples/watchdog.rs index 35098ac7612..732410a0afd 100644 --- a/esp32-hal/examples/watchdog.rs +++ b/esp32-hal/examples/watchdog.rs @@ -13,7 +13,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/adc.rs b/esp32c2-hal/examples/adc.rs index fb010b013f4..720de63c603 100644 --- a/esp32c2-hal/examples/adc.rs +++ b/esp32c2-hal/examples/adc.rs @@ -21,7 +21,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/advanced_serial.rs b/esp32c2-hal/examples/advanced_serial.rs index eacafa23123..4cd7592a3e9 100644 --- a/esp32c2-hal/examples/advanced_serial.rs +++ b/esp32c2-hal/examples/advanced_serial.rs @@ -26,7 +26,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/blinky.rs b/esp32c2-hal/examples/blinky.rs index 812d3eb8d21..dcef2bbf972 100644 --- a/esp32c2-hal/examples/blinky.rs +++ b/esp32c2-hal/examples/blinky.rs @@ -19,7 +19,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/clock_monitor.rs b/esp32c2-hal/examples/clock_monitor.rs index c8e58f4ef11..003f19eff4e 100644 --- a/esp32c2-hal/examples/clock_monitor.rs +++ b/esp32c2-hal/examples/clock_monitor.rs @@ -22,7 +22,7 @@ static RTC: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/embassy_hello_world.rs b/esp32c2-hal/examples/embassy_hello_world.rs index 4072f499285..6d4bab00372 100644 --- a/esp32c2-hal/examples/embassy_hello_world.rs +++ b/esp32c2-hal/examples/embassy_hello_world.rs @@ -36,7 +36,7 @@ static EXECUTOR: StaticCell = StaticCell::new(); #[riscv_rt::entry] fn main() -> ! { esp_println::println!("Init!"); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/gpio_interrupt.rs b/esp32c2-hal/examples/gpio_interrupt.rs index 295864a394b..1e0034ab176 100644 --- a/esp32c2-hal/examples/gpio_interrupt.rs +++ b/esp32c2-hal/examples/gpio_interrupt.rs @@ -26,7 +26,7 @@ static BUTTON: Mutex>>>> = Mutex::new(RefCe #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/hello_world.rs b/esp32c2-hal/examples/hello_world.rs index c9db5a06dff..13cef0f88b1 100644 --- a/esp32c2-hal/examples/hello_world.rs +++ b/esp32c2-hal/examples/hello_world.rs @@ -20,7 +20,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs b/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs index a121d92f848..768fed737f5 100644 --- a/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32c2-hal/examples/i2c_bmp180_calibration_data.rs @@ -24,7 +24,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/i2c_display.rs b/esp32c2-hal/examples/i2c_display.rs index e366093d9ca..fc9b4f2ee73 100644 --- a/esp32c2-hal/examples/i2c_display.rs +++ b/esp32c2-hal/examples/i2c_display.rs @@ -35,7 +35,7 @@ use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306}; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/ledc.rs b/esp32c2-hal/examples/ledc.rs index ffa138b1095..e16e69708d5 100644 --- a/esp32c2-hal/examples/ledc.rs +++ b/esp32c2-hal/examples/ledc.rs @@ -26,7 +26,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/read_efuse.rs b/esp32c2-hal/examples/read_efuse.rs index 72ff31afb84..b7bfe930b51 100644 --- a/esp32c2-hal/examples/read_efuse.rs +++ b/esp32c2-hal/examples/read_efuse.rs @@ -18,7 +18,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/rtc_watchdog.rs b/esp32c2-hal/examples/rtc_watchdog.rs index fc783e5d4a6..e532a1a09c7 100644 --- a/esp32c2-hal/examples/rtc_watchdog.rs +++ b/esp32c2-hal/examples/rtc_watchdog.rs @@ -24,7 +24,7 @@ static RWDT: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/serial_interrupts.rs b/esp32c2-hal/examples/serial_interrupts.rs index 8ab9c5f7190..8ee9b05c6af 100644 --- a/esp32c2-hal/examples/serial_interrupts.rs +++ b/esp32c2-hal/examples/serial_interrupts.rs @@ -27,7 +27,7 @@ static SERIAL: Mutex>>> = Mutex::new(RefCell::new(Non #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/sha.rs b/esp32c2-hal/examples/sha.rs index 32fa5cd029b..4f82c0e96de 100644 --- a/esp32c2-hal/examples/sha.rs +++ b/esp32c2-hal/examples/sha.rs @@ -20,7 +20,7 @@ use sha2::{Sha256, Digest}; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/spi_eh1_device_loopback.rs b/esp32c2-hal/examples/spi_eh1_device_loopback.rs index b69209a5729..1e20bb33a98 100644 --- a/esp32c2-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32c2-hal/examples/spi_eh1_device_loopback.rs @@ -35,7 +35,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/spi_eh1_loopback.rs b/esp32c2-hal/examples/spi_eh1_loopback.rs index 0cc1fcf270b..b04447f6ee6 100644 --- a/esp32c2-hal/examples/spi_eh1_loopback.rs +++ b/esp32c2-hal/examples/spi_eh1_loopback.rs @@ -33,7 +33,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/spi_loopback.rs b/esp32c2-hal/examples/spi_loopback.rs index 8e030380476..5c6af7637b1 100644 --- a/esp32c2-hal/examples/spi_loopback.rs +++ b/esp32c2-hal/examples/spi_loopback.rs @@ -32,7 +32,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/spi_loopback_dma.rs b/esp32c2-hal/examples/spi_loopback_dma.rs index 350706e3dd6..6334a60088d 100644 --- a/esp32c2-hal/examples/spi_loopback_dma.rs +++ b/esp32c2-hal/examples/spi_loopback_dma.rs @@ -34,7 +34,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/systimer.rs b/esp32c2-hal/examples/systimer.rs index 5b3b0f92c6c..cc894452bc2 100644 --- a/esp32c2-hal/examples/systimer.rs +++ b/esp32c2-hal/examples/systimer.rs @@ -28,7 +28,7 @@ static ALARM2: Mutex>>> = Mutex::new(RefCell::ne #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/timer_interrupt.rs b/esp32c2-hal/examples/timer_interrupt.rs index 184fff682cf..5ec24a420a4 100644 --- a/esp32c2-hal/examples/timer_interrupt.rs +++ b/esp32c2-hal/examples/timer_interrupt.rs @@ -22,7 +22,7 @@ static TIMER0: Mutex>>>> = Mutex::new(RefCell #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c2-hal/examples/watchdog.rs b/esp32c2-hal/examples/watchdog.rs index 076f6640aed..d603f679d5d 100644 --- a/esp32c2-hal/examples/watchdog.rs +++ b/esp32c2-hal/examples/watchdog.rs @@ -13,7 +13,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/adc.rs b/esp32c3-hal/examples/adc.rs index 5cefa56fb91..22684762eb7 100644 --- a/esp32c3-hal/examples/adc.rs +++ b/esp32c3-hal/examples/adc.rs @@ -21,7 +21,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/advanced_serial.rs b/esp32c3-hal/examples/advanced_serial.rs index a1da81a2d83..503e541c5f1 100644 --- a/esp32c3-hal/examples/advanced_serial.rs +++ b/esp32c3-hal/examples/advanced_serial.rs @@ -26,7 +26,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/blinky.rs b/esp32c3-hal/examples/blinky.rs index 4facaf224e6..551944ec5aa 100644 --- a/esp32c3-hal/examples/blinky.rs +++ b/esp32c3-hal/examples/blinky.rs @@ -19,7 +19,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/clock_monitor.rs b/esp32c3-hal/examples/clock_monitor.rs index a7d5c104936..6547c033636 100644 --- a/esp32c3-hal/examples/clock_monitor.rs +++ b/esp32c3-hal/examples/clock_monitor.rs @@ -22,7 +22,7 @@ static RTC: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/embassy_hello_world.rs b/esp32c3-hal/examples/embassy_hello_world.rs index 771050fca0c..086b92f4be2 100644 --- a/esp32c3-hal/examples/embassy_hello_world.rs +++ b/esp32c3-hal/examples/embassy_hello_world.rs @@ -35,7 +35,7 @@ static EXECUTOR: StaticCell = StaticCell::new(); #[riscv_rt::entry] fn main() -> ! { esp_println::println!("Init!"); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/gpio_interrupt.rs b/esp32c3-hal/examples/gpio_interrupt.rs index 032628b2008..483b6f5d276 100644 --- a/esp32c3-hal/examples/gpio_interrupt.rs +++ b/esp32c3-hal/examples/gpio_interrupt.rs @@ -26,7 +26,7 @@ static BUTTON: Mutex>>>> = Mutex::new(RefCe #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/hello_rgb.rs b/esp32c3-hal/examples/hello_rgb.rs index 361785e9f76..b1654cb63ae 100644 --- a/esp32c3-hal/examples/hello_rgb.rs +++ b/esp32c3-hal/examples/hello_rgb.rs @@ -35,7 +35,7 @@ use smart_leds::{ #[entry] fn main() -> ! { - let peripherals = peripherals::Peripherals::take().unwrap(); + let peripherals = peripherals::Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/hello_world.rs b/esp32c3-hal/examples/hello_world.rs index 0c63224b23d..944ec3f3443 100644 --- a/esp32c3-hal/examples/hello_world.rs +++ b/esp32c3-hal/examples/hello_world.rs @@ -20,7 +20,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs b/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs index fe78c9958f7..4a6adb0e911 100644 --- a/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32c3-hal/examples/i2c_bmp180_calibration_data.rs @@ -24,7 +24,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/i2c_display.rs b/esp32c3-hal/examples/i2c_display.rs index 72c1bb151ff..0cff1436455 100644 --- a/esp32c3-hal/examples/i2c_display.rs +++ b/esp32c3-hal/examples/i2c_display.rs @@ -35,7 +35,7 @@ use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306}; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/i2s_read.rs b/esp32c3-hal/examples/i2s_read.rs index c09c1a01915..40fb9a72052 100644 --- a/esp32c3-hal/examples/i2s_read.rs +++ b/esp32c3-hal/examples/i2s_read.rs @@ -31,7 +31,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/i2s_sound.rs b/esp32c3-hal/examples/i2s_sound.rs index 67a17c4f95b..f6ac33a0e6c 100644 --- a/esp32c3-hal/examples/i2s_sound.rs +++ b/esp32c3-hal/examples/i2s_sound.rs @@ -54,7 +54,7 @@ const SINE: [i16; 64] = [ #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/ledc.rs b/esp32c3-hal/examples/ledc.rs index 7bb7edde823..7be93e456c6 100644 --- a/esp32c3-hal/examples/ledc.rs +++ b/esp32c3-hal/examples/ledc.rs @@ -26,7 +26,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/pulse_control.rs b/esp32c3-hal/examples/pulse_control.rs index f20ae72467e..40cdc856a8c 100644 --- a/esp32c3-hal/examples/pulse_control.rs +++ b/esp32c3-hal/examples/pulse_control.rs @@ -20,7 +20,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/ram.rs b/esp32c3-hal/examples/ram.rs index c3bd79dceb2..8e4b31518ed 100644 --- a/esp32c3-hal/examples/ram.rs +++ b/esp32c3-hal/examples/ram.rs @@ -31,7 +31,7 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/read_efuse.rs b/esp32c3-hal/examples/read_efuse.rs index 8db604e3339..9ffb6b351b0 100644 --- a/esp32c3-hal/examples/read_efuse.rs +++ b/esp32c3-hal/examples/read_efuse.rs @@ -18,7 +18,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/rtc_watchdog.rs b/esp32c3-hal/examples/rtc_watchdog.rs index 8a0a14b2df9..8224d193a98 100644 --- a/esp32c3-hal/examples/rtc_watchdog.rs +++ b/esp32c3-hal/examples/rtc_watchdog.rs @@ -24,7 +24,7 @@ static RWDT: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/serial_interrupts.rs b/esp32c3-hal/examples/serial_interrupts.rs index 2af2c412041..9ef9749a245 100644 --- a/esp32c3-hal/examples/serial_interrupts.rs +++ b/esp32c3-hal/examples/serial_interrupts.rs @@ -27,7 +27,7 @@ static SERIAL: Mutex>>> = Mutex::new(RefCell::new(Non #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/sha.rs b/esp32c3-hal/examples/sha.rs index 8c5b165828a..db925f555b0 100644 --- a/esp32c3-hal/examples/sha.rs +++ b/esp32c3-hal/examples/sha.rs @@ -20,7 +20,7 @@ use sha2::{Sha256, Digest}; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/spi_eh1_device_loopback.rs b/esp32c3-hal/examples/spi_eh1_device_loopback.rs index 80a985f6d7a..21bb1bd362f 100644 --- a/esp32c3-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32c3-hal/examples/spi_eh1_device_loopback.rs @@ -35,7 +35,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/spi_eh1_loopback.rs b/esp32c3-hal/examples/spi_eh1_loopback.rs index 6934f54ed01..94081fee6fb 100644 --- a/esp32c3-hal/examples/spi_eh1_loopback.rs +++ b/esp32c3-hal/examples/spi_eh1_loopback.rs @@ -33,7 +33,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/spi_loopback.rs b/esp32c3-hal/examples/spi_loopback.rs index 5ba34756ffd..0dcf27992a6 100644 --- a/esp32c3-hal/examples/spi_loopback.rs +++ b/esp32c3-hal/examples/spi_loopback.rs @@ -32,7 +32,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/spi_loopback_dma.rs b/esp32c3-hal/examples/spi_loopback_dma.rs index d639c9bea37..20c5cf2a4d8 100644 --- a/esp32c3-hal/examples/spi_loopback_dma.rs +++ b/esp32c3-hal/examples/spi_loopback_dma.rs @@ -34,7 +34,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/systimer.rs b/esp32c3-hal/examples/systimer.rs index 265d288cf51..0beef103562 100644 --- a/esp32c3-hal/examples/systimer.rs +++ b/esp32c3-hal/examples/systimer.rs @@ -28,7 +28,7 @@ static ALARM2: Mutex>>> = Mutex::new(RefCell::ne #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/timer_interrupt.rs b/esp32c3-hal/examples/timer_interrupt.rs index a0fce312189..9fe9e6f5530 100644 --- a/esp32c3-hal/examples/timer_interrupt.rs +++ b/esp32c3-hal/examples/timer_interrupt.rs @@ -24,7 +24,7 @@ static TIMER1: Mutex>>>> = Mutex::new(RefCell #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/usb_serial_jtag.rs b/esp32c3-hal/examples/usb_serial_jtag.rs index 3bf8ea53e9d..c8654d5706d 100644 --- a/esp32c3-hal/examples/usb_serial_jtag.rs +++ b/esp32c3-hal/examples/usb_serial_jtag.rs @@ -29,7 +29,7 @@ static USB_SERIAL: Mutex>>> = #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32c3-hal/examples/watchdog.rs b/esp32c3-hal/examples/watchdog.rs index 9fac5c05af5..519d1d3ee30 100644 --- a/esp32c3-hal/examples/watchdog.rs +++ b/esp32c3-hal/examples/watchdog.rs @@ -13,7 +13,7 @@ use riscv_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/adc.rs b/esp32s2-hal/examples/adc.rs index d1133e448d5..808ce9eaa19 100644 --- a/esp32s2-hal/examples/adc.rs +++ b/esp32s2-hal/examples/adc.rs @@ -22,7 +22,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/advanced_serial.rs b/esp32s2-hal/examples/advanced_serial.rs index 6bab01ec8e8..8bff4bb6f94 100644 --- a/esp32s2-hal/examples/advanced_serial.rs +++ b/esp32s2-hal/examples/advanced_serial.rs @@ -28,7 +28,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/blinky.rs b/esp32s2-hal/examples/blinky.rs index 938d579771d..f7371fa71e5 100644 --- a/esp32s2-hal/examples/blinky.rs +++ b/esp32s2-hal/examples/blinky.rs @@ -20,7 +20,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/clock_monitor.rs b/esp32s2-hal/examples/clock_monitor.rs index 38cacd94436..6f2b6a378a5 100644 --- a/esp32s2-hal/examples/clock_monitor.rs +++ b/esp32s2-hal/examples/clock_monitor.rs @@ -24,7 +24,7 @@ static RTC: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/dac.rs b/esp32s2-hal/examples/dac.rs index 307f4550d85..4276df18dd8 100644 --- a/esp32s2-hal/examples/dac.rs +++ b/esp32s2-hal/examples/dac.rs @@ -21,7 +21,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/embassy_hello_world.rs b/esp32s2-hal/examples/embassy_hello_world.rs index 61a0304ed1d..df332cbaa78 100644 --- a/esp32s2-hal/examples/embassy_hello_world.rs +++ b/esp32s2-hal/examples/embassy_hello_world.rs @@ -36,7 +36,7 @@ static EXECUTOR: StaticCell = StaticCell::new(); #[xtensa_lx_rt::entry] fn main() -> ! { esp_println::println!("Init!"); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/gpio_interrupt.rs b/esp32s2-hal/examples/gpio_interrupt.rs index f28dfd5f8b3..14f5a2b74df 100644 --- a/esp32s2-hal/examples/gpio_interrupt.rs +++ b/esp32s2-hal/examples/gpio_interrupt.rs @@ -28,7 +28,7 @@ static BUTTON: Mutex>>>> = Mutex::new(RefCe #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/hello_rgb.rs b/esp32s2-hal/examples/hello_rgb.rs index a51e516428e..1463e10b2a8 100644 --- a/esp32s2-hal/examples/hello_rgb.rs +++ b/esp32s2-hal/examples/hello_rgb.rs @@ -35,7 +35,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/hello_world.rs b/esp32s2-hal/examples/hello_world.rs index f440ac987d5..bd0b708e177 100644 --- a/esp32s2-hal/examples/hello_world.rs +++ b/esp32s2-hal/examples/hello_world.rs @@ -21,7 +21,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs b/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs index 15fbfb01f83..e6ad37fce44 100644 --- a/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32s2-hal/examples/i2c_bmp180_calibration_data.rs @@ -24,7 +24,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/i2c_display.rs b/esp32s2-hal/examples/i2c_display.rs index f1d6e819d5d..01bd307f6ea 100644 --- a/esp32s2-hal/examples/i2c_display.rs +++ b/esp32s2-hal/examples/i2c_display.rs @@ -36,7 +36,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/i2s_read.rs b/esp32s2-hal/examples/i2s_read.rs index 5cfb85cf6a7..c85b3b5c540 100644 --- a/esp32s2-hal/examples/i2s_read.rs +++ b/esp32s2-hal/examples/i2s_read.rs @@ -30,7 +30,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/i2s_sound.rs b/esp32s2-hal/examples/i2s_sound.rs index 1b7ef15912d..f5054b9f698 100644 --- a/esp32s2-hal/examples/i2s_sound.rs +++ b/esp32s2-hal/examples/i2s_sound.rs @@ -54,7 +54,7 @@ const SINE: [i16; 64] = [ #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/ledc.rs b/esp32s2-hal/examples/ledc.rs index 039e79fa510..2ed52e48576 100644 --- a/esp32s2-hal/examples/ledc.rs +++ b/esp32s2-hal/examples/ledc.rs @@ -28,7 +28,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/pulse_control.rs b/esp32s2-hal/examples/pulse_control.rs index 1e8bcae9617..693f7da0100 100644 --- a/esp32s2-hal/examples/pulse_control.rs +++ b/esp32s2-hal/examples/pulse_control.rs @@ -21,7 +21,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/ram.rs b/esp32s2-hal/examples/ram.rs index 287716a20c5..ad269855c6c 100644 --- a/esp32s2-hal/examples/ram.rs +++ b/esp32s2-hal/examples/ram.rs @@ -32,7 +32,7 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/read_efuse.rs b/esp32s2-hal/examples/read_efuse.rs index 6e6c7f40a22..07034c681e2 100644 --- a/esp32s2-hal/examples/read_efuse.rs +++ b/esp32s2-hal/examples/read_efuse.rs @@ -19,7 +19,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/rtc_watchdog.rs b/esp32s2-hal/examples/rtc_watchdog.rs index eb716087649..9561c32dc26 100644 --- a/esp32s2-hal/examples/rtc_watchdog.rs +++ b/esp32s2-hal/examples/rtc_watchdog.rs @@ -25,7 +25,7 @@ static RWDT: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/serial_interrupts.rs b/esp32s2-hal/examples/serial_interrupts.rs index f932451009d..72f93873143 100644 --- a/esp32s2-hal/examples/serial_interrupts.rs +++ b/esp32s2-hal/examples/serial_interrupts.rs @@ -27,7 +27,7 @@ static SERIAL: Mutex>>> = Mutex::new(RefCell::new(Non #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/sha.rs b/esp32s2-hal/examples/sha.rs index 63feac4dc1f..746bb43c8db 100644 --- a/esp32s2-hal/examples/sha.rs +++ b/esp32s2-hal/examples/sha.rs @@ -20,7 +20,7 @@ use sha2::{Sha512, Digest}; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/spi_eh1_device_loopback.rs b/esp32s2-hal/examples/spi_eh1_device_loopback.rs index 4c3cb49614a..2e75be4cea3 100644 --- a/esp32s2-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32s2-hal/examples/spi_eh1_device_loopback.rs @@ -36,7 +36,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/spi_eh1_loopback.rs b/esp32s2-hal/examples/spi_eh1_loopback.rs index 63a6eee346e..03ec71cde3b 100644 --- a/esp32s2-hal/examples/spi_eh1_loopback.rs +++ b/esp32s2-hal/examples/spi_eh1_loopback.rs @@ -34,7 +34,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/spi_loopback.rs b/esp32s2-hal/examples/spi_loopback.rs index a38219d1541..bfb9bbbb749 100644 --- a/esp32s2-hal/examples/spi_loopback.rs +++ b/esp32s2-hal/examples/spi_loopback.rs @@ -33,7 +33,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/spi_loopback_dma.rs b/esp32s2-hal/examples/spi_loopback_dma.rs index 7068e0cc7de..98cba99e8b7 100644 --- a/esp32s2-hal/examples/spi_loopback_dma.rs +++ b/esp32s2-hal/examples/spi_loopback_dma.rs @@ -35,7 +35,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/systimer.rs b/esp32s2-hal/examples/systimer.rs index 8150232d8de..f8914741327 100644 --- a/esp32s2-hal/examples/systimer.rs +++ b/esp32s2-hal/examples/systimer.rs @@ -29,7 +29,7 @@ static ALARM2: Mutex>>> = Mutex::new(RefCell::ne #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/timer_interrupt.rs b/esp32s2-hal/examples/timer_interrupt.rs index a8c4b996dd9..b2739a8a29a 100644 --- a/esp32s2-hal/examples/timer_interrupt.rs +++ b/esp32s2-hal/examples/timer_interrupt.rs @@ -29,7 +29,7 @@ static TIMER11: Mutex>>>> = Mutex::new(RefCel #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s2-hal/examples/usb_serial.rs b/esp32s2-hal/examples/usb_serial.rs index 8d9f0d26145..e2b127f28ea 100644 --- a/esp32s2-hal/examples/usb_serial.rs +++ b/esp32s2-hal/examples/usb_serial.rs @@ -22,7 +22,7 @@ static mut EP_MEMORY: [u32; 1024] = [0; 1024]; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze(); diff --git a/esp32s2-hal/examples/watchdog.rs b/esp32s2-hal/examples/watchdog.rs index 4152540a293..3356b26acd9 100644 --- a/esp32s2-hal/examples/watchdog.rs +++ b/esp32s2-hal/examples/watchdog.rs @@ -14,7 +14,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/adc.rs b/esp32s3-hal/examples/adc.rs index 4b4203e5113..826ec5eae01 100644 --- a/esp32s3-hal/examples/adc.rs +++ b/esp32s3-hal/examples/adc.rs @@ -21,7 +21,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/advanced_serial.rs b/esp32s3-hal/examples/advanced_serial.rs index d5e63b67f59..af83d82581b 100644 --- a/esp32s3-hal/examples/advanced_serial.rs +++ b/esp32s3-hal/examples/advanced_serial.rs @@ -27,7 +27,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/blinky.rs b/esp32s3-hal/examples/blinky.rs index 2030346474d..8338c70d421 100644 --- a/esp32s3-hal/examples/blinky.rs +++ b/esp32s3-hal/examples/blinky.rs @@ -19,7 +19,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/clock_monitor.rs b/esp32s3-hal/examples/clock_monitor.rs index b3c4d797230..bcf5ff161cd 100644 --- a/esp32s3-hal/examples/clock_monitor.rs +++ b/esp32s3-hal/examples/clock_monitor.rs @@ -23,7 +23,7 @@ static RTC: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/embassy_hello_world.rs b/esp32s3-hal/examples/embassy_hello_world.rs index 0fed5c5f1fe..e73e31e5cc8 100644 --- a/esp32s3-hal/examples/embassy_hello_world.rs +++ b/esp32s3-hal/examples/embassy_hello_world.rs @@ -35,7 +35,7 @@ static EXECUTOR: StaticCell = StaticCell::new(); #[xtensa_lx_rt::entry] fn main() -> ! { esp_println::println!("Init!"); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/gpio_interrupt.rs b/esp32s3-hal/examples/gpio_interrupt.rs index c0dd33fd5a0..66790c8afd0 100644 --- a/esp32s3-hal/examples/gpio_interrupt.rs +++ b/esp32s3-hal/examples/gpio_interrupt.rs @@ -27,7 +27,7 @@ static BUTTON: Mutex>>>> = Mutex::new(RefCe #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/hello_rgb.rs b/esp32s3-hal/examples/hello_rgb.rs index 833811df08d..5d5c71d1632 100644 --- a/esp32s3-hal/examples/hello_rgb.rs +++ b/esp32s3-hal/examples/hello_rgb.rs @@ -35,7 +35,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/hello_world.rs b/esp32s3-hal/examples/hello_world.rs index a73199b3af0..433cd748742 100644 --- a/esp32s3-hal/examples/hello_world.rs +++ b/esp32s3-hal/examples/hello_world.rs @@ -20,7 +20,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs b/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs index 0f63a6e2a1f..e27593a2b10 100644 --- a/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs @@ -18,7 +18,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/i2c_display.rs b/esp32s3-hal/examples/i2c_display.rs index 089d9b8c2a4..b61c213ae9a 100644 --- a/esp32s3-hal/examples/i2c_display.rs +++ b/esp32s3-hal/examples/i2c_display.rs @@ -35,7 +35,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/i2s_read.rs b/esp32s3-hal/examples/i2s_read.rs index 1cf43636100..5bb2ddacf35 100644 --- a/esp32s3-hal/examples/i2s_read.rs +++ b/esp32s3-hal/examples/i2s_read.rs @@ -31,7 +31,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/i2s_sound.rs b/esp32s3-hal/examples/i2s_sound.rs index 911fc121ff3..fdce932d69d 100644 --- a/esp32s3-hal/examples/i2s_sound.rs +++ b/esp32s3-hal/examples/i2s_sound.rs @@ -54,7 +54,7 @@ const SINE: [i16; 64] = [ #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/ledc.rs b/esp32s3-hal/examples/ledc.rs index 951191d7a08..ae5cca47ac8 100644 --- a/esp32s3-hal/examples/ledc.rs +++ b/esp32s3-hal/examples/ledc.rs @@ -26,7 +26,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/mcpwm.rs b/esp32s3-hal/examples/mcpwm.rs index 8a772b6ff66..97151dcb243 100644 --- a/esp32s3-hal/examples/mcpwm.rs +++ b/esp32s3-hal/examples/mcpwm.rs @@ -23,7 +23,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/multicore.rs b/esp32s3-hal/examples/multicore.rs index 775781c4990..d586f101c71 100644 --- a/esp32s3-hal/examples/multicore.rs +++ b/esp32s3-hal/examples/multicore.rs @@ -23,7 +23,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/pulse_control.rs b/esp32s3-hal/examples/pulse_control.rs index 99fe00ee3af..83ba6a02ada 100644 --- a/esp32s3-hal/examples/pulse_control.rs +++ b/esp32s3-hal/examples/pulse_control.rs @@ -20,7 +20,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/ram.rs b/esp32s3-hal/examples/ram.rs index aa21f25f813..a85231e937a 100644 --- a/esp32s3-hal/examples/ram.rs +++ b/esp32s3-hal/examples/ram.rs @@ -31,7 +31,7 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/read_efuse.rs b/esp32s3-hal/examples/read_efuse.rs index b03b32f0057..9ac89f563f9 100644 --- a/esp32s3-hal/examples/read_efuse.rs +++ b/esp32s3-hal/examples/read_efuse.rs @@ -18,7 +18,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/rtc_watchdog.rs b/esp32s3-hal/examples/rtc_watchdog.rs index a03104e2d82..16bcfbd3695 100644 --- a/esp32s3-hal/examples/rtc_watchdog.rs +++ b/esp32s3-hal/examples/rtc_watchdog.rs @@ -24,7 +24,7 @@ static RWDT: Mutex>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/serial_interrupts.rs b/esp32s3-hal/examples/serial_interrupts.rs index 32567bb9686..98f0c466877 100644 --- a/esp32s3-hal/examples/serial_interrupts.rs +++ b/esp32s3-hal/examples/serial_interrupts.rs @@ -26,7 +26,7 @@ static SERIAL: Mutex>>> = Mutex::new(RefCell::new(Non #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/sha.rs b/esp32s3-hal/examples/sha.rs index 7ccda2975da..0e213397b9f 100644 --- a/esp32s3-hal/examples/sha.rs +++ b/esp32s3-hal/examples/sha.rs @@ -20,7 +20,7 @@ use sha2::{Sha512, Digest}; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/spi_eh1_device_loopback.rs b/esp32s3-hal/examples/spi_eh1_device_loopback.rs index f5154d9826e..154a4adf65b 100644 --- a/esp32s3-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32s3-hal/examples/spi_eh1_device_loopback.rs @@ -35,7 +35,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/spi_eh1_loopback.rs b/esp32s3-hal/examples/spi_eh1_loopback.rs index 522a1b1fd9c..ae85a037f80 100644 --- a/esp32s3-hal/examples/spi_eh1_loopback.rs +++ b/esp32s3-hal/examples/spi_eh1_loopback.rs @@ -33,7 +33,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/spi_loopback.rs b/esp32s3-hal/examples/spi_loopback.rs index eb424e505b3..c1c2ca2ef0f 100644 --- a/esp32s3-hal/examples/spi_loopback.rs +++ b/esp32s3-hal/examples/spi_loopback.rs @@ -32,7 +32,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/spi_loopback_dma.rs b/esp32s3-hal/examples/spi_loopback_dma.rs index fd20925e43e..3a14b446e99 100644 --- a/esp32s3-hal/examples/spi_loopback_dma.rs +++ b/esp32s3-hal/examples/spi_loopback_dma.rs @@ -34,7 +34,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/systimer.rs b/esp32s3-hal/examples/systimer.rs index 7f71376957d..60152414804 100644 --- a/esp32s3-hal/examples/systimer.rs +++ b/esp32s3-hal/examples/systimer.rs @@ -28,7 +28,7 @@ static ALARM2: Mutex>>> = Mutex::new(RefCell::ne #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/timer_interrupt.rs b/esp32s3-hal/examples/timer_interrupt.rs index faaefa7f32c..ab8405f1f5b 100644 --- a/esp32s3-hal/examples/timer_interrupt.rs +++ b/esp32s3-hal/examples/timer_interrupt.rs @@ -28,7 +28,7 @@ static TIMER11: Mutex>>>> = Mutex::new(RefCel #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/usb_serial.rs b/esp32s3-hal/examples/usb_serial.rs index 553a87ea10f..2df9d099fa6 100644 --- a/esp32s3-hal/examples/usb_serial.rs +++ b/esp32s3-hal/examples/usb_serial.rs @@ -22,7 +22,7 @@ static mut EP_MEMORY: [u32; 1024] = [0; 1024]; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze(); diff --git a/esp32s3-hal/examples/usb_serial_jtag.rs b/esp32s3-hal/examples/usb_serial_jtag.rs index f7e754c3052..9675f839e30 100644 --- a/esp32s3-hal/examples/usb_serial_jtag.rs +++ b/esp32s3-hal/examples/usb_serial_jtag.rs @@ -29,7 +29,7 @@ static USB_SERIAL: Mutex>>> = #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); diff --git a/esp32s3-hal/examples/watchdog.rs b/esp32s3-hal/examples/watchdog.rs index ae1aa998fb4..3da0c50713f 100644 --- a/esp32s3-hal/examples/watchdog.rs +++ b/esp32s3-hal/examples/watchdog.rs @@ -13,7 +13,7 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); From 7d0a2e0ad977176e93073d11df3ef860f76b7b53 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Mon, 12 Dec 2022 14:56:24 +0100 Subject: [PATCH 5/6] syncronise hello world example --- esp32c3-hal/examples/hello_world.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/esp32c3-hal/examples/hello_world.rs b/esp32c3-hal/examples/hello_world.rs index 944ec3f3443..95d9701aa24 100644 --- a/esp32c3-hal/examples/hello_world.rs +++ b/esp32c3-hal/examples/hello_world.rs @@ -25,18 +25,12 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc = Rtc::new(peripherals.RTC_CNTL); - let mut uart = peripherals.UART0; + let mut uart0 = Uart::new(peripherals.UART0); let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks); let mut timer0 = timer_group0.timer0; let mut wdt0 = timer_group0.wdt; let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks); let mut wdt1 = timer_group1.wdt; - - let mut uart0 = Uart::new(&mut uart); - writeln!(uart0, "Test 1").unwrap(); - drop(uart0); // this ends the mutable borrow of uart, its now available in the peripheral struct again - let mut uart0 = Uart::new(uart); // construct via move this time - writeln!(uart0, "Test 2").unwrap(); // Disable watchdog timers rtc.swd.disable(); From e14eb1500e6b23e3183617f36a0e21db173ffecb Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Mon, 12 Dec 2022 15:24:22 +0100 Subject: [PATCH 6/6] fmt the entire repo --- esp-hal-common/build.rs | 9 ++- .../src/embassy/time_driver_systimer.rs | 8 ++- .../src/embassy/time_driver_timg.rs | 8 ++- esp-hal-common/src/interrupt/xtensa.rs | 4 +- esp-hal-common/src/lib.rs | 4 +- esp-hal-common/src/peripherals/esp32.rs | 5 +- esp-hal-common/src/peripherals/esp32c2.rs | 5 +- esp-hal-common/src/peripherals/esp32c3.rs | 5 +- esp-hal-common/src/prelude.rs | 4 +- esp-hal-common/src/systimer.rs | 12 +--- esp-hal-common/src/uart.rs | 8 +-- esp32-hal/examples/advanced_serial.rs | 2 +- esp32-hal/examples/clock_monitor.rs | 6 +- esp32-hal/examples/embassy_hello_world.rs | 8 +-- esp32-hal/examples/gpio_interrupt.rs | 2 +- esp32-hal/examples/i2s_read.rs | 8 +-- esp32-hal/examples/i2s_sound.rs | 2 +- esp32-hal/examples/mcpwm.rs | 16 +++--- esp32-hal/examples/rtc_watchdog.rs | 6 +- esp32-hal/examples/serial_interrupts.rs | 8 ++- esp32-hal/examples/sha.rs | 39 +++++++------ esp32-hal/examples/spi_loopback_dma.rs | 4 +- esp32-hal/examples/watchdog.rs | 8 ++- esp32-hal/src/lib.rs | 9 ++- esp32c2-hal/examples/advanced_serial.rs | 2 +- esp32c2-hal/examples/clock_monitor.rs | 6 +- esp32c2-hal/examples/embassy_hello_world.rs | 5 +- esp32c2-hal/examples/gpio_interrupt.rs | 2 +- esp32c2-hal/examples/rtc_watchdog.rs | 6 +- esp32c2-hal/examples/serial_interrupts.rs | 8 ++- esp32c2-hal/examples/sha.rs | 55 ++++++++++--------- esp32c2-hal/examples/spi_loopback_dma.rs | 2 +- esp32c2-hal/examples/systimer.rs | 18 +++++- esp32c2-hal/examples/timer_interrupt.rs | 6 +- esp32c2-hal/examples/watchdog.rs | 8 ++- esp32c2-hal/src/lib.rs | 4 +- esp32c3-hal/examples/advanced_serial.rs | 2 +- esp32c3-hal/examples/clock_monitor.rs | 6 +- esp32c3-hal/examples/embassy_hello_world.rs | 12 ++-- esp32c3-hal/examples/gpio_interrupt.rs | 2 +- esp32c3-hal/examples/i2s_read.rs | 6 +- esp32c3-hal/examples/i2s_sound.rs | 2 +- esp32c3-hal/examples/rtc_watchdog.rs | 6 +- esp32c3-hal/examples/serial_interrupts.rs | 8 ++- esp32c3-hal/examples/sha.rs | 55 ++++++++++--------- esp32c3-hal/examples/spi_loopback_dma.rs | 2 +- esp32c3-hal/examples/systimer.rs | 18 +++++- esp32c3-hal/examples/timer_interrupt.rs | 12 +++- esp32c3-hal/examples/usb_serial_jtag.rs | 3 +- esp32c3-hal/examples/watchdog.rs | 8 ++- esp32c3-hal/src/lib.rs | 8 +-- esp32s2-hal/examples/adc.rs | 11 ++-- esp32s2-hal/examples/advanced_serial.rs | 13 +++-- esp32s2-hal/examples/blinky.rs | 9 ++- esp32s2-hal/examples/clock_monitor.rs | 17 ++++-- esp32s2-hal/examples/dac.rs | 9 ++- esp32s2-hal/examples/embassy_hello_world.rs | 16 ++++-- esp32s2-hal/examples/gpio_interrupt.rs | 11 ++-- esp32s2-hal/examples/hello_rgb.rs | 11 ++-- esp32s2-hal/examples/hello_world.rs | 9 ++- esp32s2-hal/examples/i2c_display.rs | 11 ++-- esp32s2-hal/examples/i2s_read.rs | 8 +-- esp32s2-hal/examples/i2s_sound.rs | 2 +- esp32s2-hal/examples/ledc.rs | 11 ++-- esp32s2-hal/examples/pulse_control.rs | 7 ++- esp32s2-hal/examples/ram.rs | 9 ++- esp32s2-hal/examples/read_efuse.rs | 9 ++- esp32s2-hal/examples/rtc_watchdog.rs | 13 ++++- esp32s2-hal/examples/serial_interrupts.rs | 19 +++++-- esp32s2-hal/examples/sha.rs | 39 +++++++------ .../examples/spi_eh1_device_loopback.rs | 7 ++- esp32s2-hal/examples/spi_eh1_loopback.rs | 7 ++- esp32s2-hal/examples/spi_loopback.rs | 7 ++- esp32s2-hal/examples/spi_loopback_dma.rs | 15 +++-- esp32s2-hal/examples/systimer.rs | 25 +++++++-- esp32s2-hal/examples/timer_interrupt.rs | 9 ++- esp32s2-hal/examples/watchdog.rs | 17 ++++-- esp32s2-hal/src/lib.rs | 13 ++--- esp32s3-hal/examples/advanced_serial.rs | 2 +- esp32s3-hal/examples/clock_monitor.rs | 6 +- esp32s3-hal/examples/embassy_hello_world.rs | 12 ++-- esp32s3-hal/examples/gpio_interrupt.rs | 2 +- .../examples/i2c_bmp180_calibration_data.rs | 8 ++- esp32s3-hal/examples/i2s_read.rs | 2 +- esp32s3-hal/examples/i2s_sound.rs | 2 +- esp32s3-hal/examples/mcpwm.rs | 16 +++--- esp32s3-hal/examples/rtc_watchdog.rs | 6 +- esp32s3-hal/examples/serial_interrupts.rs | 8 ++- esp32s3-hal/examples/sha.rs | 39 +++++++------ esp32s3-hal/examples/spi_loopback_dma.rs | 2 +- esp32s3-hal/examples/systimer.rs | 18 +++++- esp32s3-hal/examples/usb_serial_jtag.rs | 9 ++- esp32s3-hal/examples/watchdog.rs | 8 ++- esp32s3-hal/src/lib.rs | 11 ++-- 94 files changed, 601 insertions(+), 346 deletions(-) diff --git a/esp-hal-common/build.rs b/esp-hal-common/build.rs index 7037f198f50..0cceb015962 100644 --- a/esp-hal-common/build.rs +++ b/esp-hal-common/build.rs @@ -55,7 +55,14 @@ fn main() { "uart2", ] } else if esp32c2 { - vec!["esp32c2", "riscv", "single_core", "gdma", "systimer", "timg0"] + vec![ + "esp32c2", + "riscv", + "single_core", + "gdma", + "systimer", + "timg0", + ] } else if esp32c3 { vec![ "esp32c3", diff --git a/esp-hal-common/src/embassy/time_driver_systimer.rs b/esp-hal-common/src/embassy/time_driver_systimer.rs index fbc01d0b0ec..56c528196c5 100644 --- a/esp-hal-common/src/embassy/time_driver_systimer.rs +++ b/esp-hal-common/src/embassy/time_driver_systimer.rs @@ -75,7 +75,11 @@ impl EmbassyTimer { } } - pub(crate) fn set_alarm(&self, alarm: embassy_time::driver::AlarmHandle, timestamp: u64) -> bool { + pub(crate) fn set_alarm( + &self, + alarm: embassy_time::driver::AlarmHandle, + timestamp: u64, + ) -> bool { critical_section::with(|cs| { let now = Self::now(); let alarm_state = unsafe { self.alarms.borrow(cs).get_unchecked(alarm.id() as usize) }; @@ -108,7 +112,7 @@ impl EmbassyTimer { } fn disable_interrupt(&self, id: u8) { - match id { + match id { 0 => self.alarm0.interrupt_enable(false), 1 => self.alarm1.interrupt_enable(false), 2 => self.alarm2.interrupt_enable(false), diff --git a/esp-hal-common/src/embassy/time_driver_timg.rs b/esp-hal-common/src/embassy/time_driver_timg.rs index 4695b455da5..5462e62b9b7 100644 --- a/esp-hal-common/src/embassy/time_driver_timg.rs +++ b/esp-hal-common/src/embassy/time_driver_timg.rs @@ -68,7 +68,11 @@ impl EmbassyTimer { } } - pub(crate) fn set_alarm(&self, alarm: embassy_time::driver::AlarmHandle, timestamp: u64) -> bool { + pub(crate) fn set_alarm( + &self, + alarm: embassy_time::driver::AlarmHandle, + timestamp: u64, + ) -> bool { critical_section::with(|cs| { let now = Self::now(); let alarm_state = unsafe { self.alarms.borrow(cs).get_unchecked(alarm.id() as usize) }; @@ -87,7 +91,7 @@ impl EmbassyTimer { tg.set_auto_reload(false); tg.set_counter_active(true); tg.set_alarm_active(true); - + true }) } diff --git a/esp-hal-common/src/interrupt/xtensa.rs b/esp-hal-common/src/interrupt/xtensa.rs index 063cd88a379..cd7e013b7d0 100644 --- a/esp-hal-common/src/interrupt/xtensa.rs +++ b/esp-hal-common/src/interrupt/xtensa.rs @@ -340,7 +340,9 @@ mod vectored { const CPU_INTERRUPT_EDGE: u32 = 0b_0111_0000_0100_0000_0000_1100_1000_0000; #[inline] - fn cpu_interrupt_nr_to_cpu_interrupt_handler(number: u32) -> Option { + fn cpu_interrupt_nr_to_cpu_interrupt_handler( + number: u32, + ) -> Option { use xtensa_lx_rt::*; // we're fortunate that all esp variants use the same CPU interrupt layout Some(match number { diff --git a/esp-hal-common/src/lib.rs b/esp-hal-common/src/lib.rs index 1335a111aff..614beea78e6 100644 --- a/esp-hal-common/src/lib.rs +++ b/esp-hal-common/src/lib.rs @@ -51,9 +51,9 @@ pub use self::{ interrupt::*, rng::Rng, rtc_cntl::{Rtc, Rwdt}, - uart::Uart, spi::Spi, timer::Timer, + uart::Uart, }; pub mod analog; @@ -79,12 +79,12 @@ pub mod rng; pub mod rom; pub mod rtc_cntl; pub mod sha; -pub mod uart; pub mod spi; pub mod system; #[cfg(systimer)] pub mod systimer; pub mod timer; +pub mod uart; #[cfg(usb_serial_jtag)] pub mod usb_serial_jtag; #[cfg(rmt)] diff --git a/esp-hal-common/src/peripherals/esp32.rs b/esp-hal-common/src/peripherals/esp32.rs index 4ac0c1a17c1..a785fa76fce 100644 --- a/esp-hal-common/src/peripherals/esp32.rs +++ b/esp-hal-common/src/peripherals/esp32.rs @@ -1,7 +1,6 @@ +pub use pac::Interrupt; -use crate::pac; - -pub use pac::Interrupt; // We need to export this for users to use +use crate::pac; // We need to export this for users to use crate::peripherals! { AES, diff --git a/esp-hal-common/src/peripherals/esp32c2.rs b/esp-hal-common/src/peripherals/esp32c2.rs index efde9bbbcb8..0ccff88a24a 100644 --- a/esp-hal-common/src/peripherals/esp32c2.rs +++ b/esp-hal-common/src/peripherals/esp32c2.rs @@ -1,7 +1,6 @@ +pub use pac::Interrupt; -use crate::pac; - -pub use pac::Interrupt; // We need to export this for users to use +use crate::pac; // We need to export this for users to use crate::peripherals! { APB_CTRL, diff --git a/esp-hal-common/src/peripherals/esp32c3.rs b/esp-hal-common/src/peripherals/esp32c3.rs index 5ec07bd663d..ed6181fc895 100644 --- a/esp-hal-common/src/peripherals/esp32c3.rs +++ b/esp-hal-common/src/peripherals/esp32c3.rs @@ -1,7 +1,6 @@ +pub use pac::Interrupt; -use crate::pac; - -pub use pac::Interrupt; // We need to export this for users to use +use crate::pac; // We need to export this for users to use crate::peripherals! { AES, diff --git a/esp-hal-common/src/prelude.rs b/esp-hal-common/src/prelude.rs index 13370e1ff8e..93b82971ac7 100644 --- a/esp-hal-common/src/prelude.rs +++ b/esp-hal-common/src/prelude.rs @@ -54,7 +54,6 @@ pub use crate::{ }, }, macros::*, - uart::{Instance as _esp_hal_uart_Instance, UartPins as _esp_hal_uart_UartPins}, spi::{ dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2, Instance as _esp_hal_spi_Instance, @@ -65,6 +64,7 @@ pub use crate::{ Instance as _esp_hal_timer_Instance, TimerGroupInstance as _esp_hal_timer_TimerGroupInstance, }, + uart::{Instance as _esp_hal_uart_Instance, UartPins as _esp_hal_uart_UartPins}, }; /// All traits required for using the 1.0.0-alpha.x release of embedded-hal @@ -132,7 +132,6 @@ pub mod eh1 { }, }, macros::*, - uart::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins}, spi::{ dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2, Instance as _esp_hal_spi_Instance, @@ -143,5 +142,6 @@ pub mod eh1 { Instance as _esp_hal_timer_Instance, TimerGroupInstance as _esp_hal_timer_TimerGroupInstance, }, + uart::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins}, }; } diff --git a/esp-hal-common/src/systimer.rs b/esp-hal-common/src/systimer.rs index a7c8962db90..b1ad9d01dc1 100644 --- a/esp-hal-common/src/systimer.rs +++ b/esp-hal-common/src/systimer.rs @@ -86,15 +86,9 @@ impl Alarm { pub fn interrupt_enable(&self, val: bool) { let systimer = unsafe { &*SYSTIMER::ptr() }; match CHANNEL { - 0 => systimer - .int_ena - .modify(|_, w| w.target0_int_ena().bit(val)), - 1 => systimer - .int_ena - .modify(|_, w| w.target1_int_ena().bit(val)), - 2 => systimer - .int_ena - .modify(|_, w| w.target2_int_ena().bit(val)), + 0 => systimer.int_ena.modify(|_, w| w.target0_int_ena().bit(val)), + 1 => systimer.int_ena.modify(|_, w| w.target1_int_ena().bit(val)), + 2 => systimer.int_ena.modify(|_, w| w.target2_int_ena().bit(val)), _ => unreachable!(), } } diff --git a/esp-hal-common/src/uart.rs b/esp-hal-common/src/uart.rs index 1542b962300..7e90580710c 100644 --- a/esp-hal-common/src/uart.rs +++ b/esp-hal-common/src/uart.rs @@ -5,14 +5,12 @@ use self::config::Config; use crate::pac::UART2; use crate::{ clock::Clocks, - peripherals::{ - UART0, - UART1, - }, pac::uart0::{fifo::FIFO_SPEC, RegisterBlock}, + peripheral::{Peripheral, PeripheralRef}, + peripherals::{UART0, UART1}, types::{InputSignal, OutputSignal}, InputPin, - OutputPin, peripheral::{Peripheral, PeripheralRef}, + OutputPin, }; const UART_FIFO_SIZE: u16 = 128; diff --git a/esp32-hal/examples/advanced_serial.rs b/esp32-hal/examples/advanced_serial.rs index b95f3bff423..c162fcf8330 100644 --- a/esp32-hal/examples/advanced_serial.rs +++ b/esp32-hal/examples/advanced_serial.rs @@ -11,11 +11,11 @@ use esp32_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, + timer::TimerGroup, uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, - timer::TimerGroup, Delay, Rtc, Uart, diff --git a/esp32-hal/examples/clock_monitor.rs b/esp32-hal/examples/clock_monitor.rs index f0afe7b8bab..ce0038ef3f9 100644 --- a/esp32-hal/examples/clock_monitor.rs +++ b/esp32-hal/examples/clock_monitor.rs @@ -40,7 +40,11 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); critical_section::with(|cs| RTC.borrow_ref_mut(cs).replace(rtc)); diff --git a/esp32-hal/examples/embassy_hello_world.rs b/esp32-hal/examples/embassy_hello_world.rs index ca7cb15a260..dba91257752 100644 --- a/esp32-hal/examples/embassy_hello_world.rs +++ b/esp32-hal/examples/embassy_hello_world.rs @@ -4,12 +4,13 @@ use embassy_executor::Executor; use embassy_time::{Duration, Timer}; - use esp32_hal::{ clock::ClockControl, + embassy, + peripherals::Peripherals, prelude::*, timer::TimerGroup, - Rtc, embassy, peripherals::Peripherals, + Rtc, }; use esp_backtrace as _; use static_cell::StaticCell; @@ -53,10 +54,9 @@ fn main() -> ! { #[cfg(feature = "embassy-time-timg0")] embassy::init(&clocks, timer_group0.timer0); - let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { spawner.spawn(run1()).ok(); spawner.spawn(run2()).ok(); }); -} \ No newline at end of file +} diff --git a/esp32-hal/examples/gpio_interrupt.rs b/esp32-hal/examples/gpio_interrupt.rs index be2b3b38dce..a76405f33b5 100644 --- a/esp32-hal/examples/gpio_interrupt.rs +++ b/esp32-hal/examples/gpio_interrupt.rs @@ -11,7 +11,7 @@ use core::{borrow::BorrowMut, cell::RefCell}; use critical_section::Mutex; use esp32_hal::{ clock::ClockControl, - gpio::{Gpio0, IO, Event, Input, PullDown,}, + gpio::{Event, Gpio0, Input, PullDown, IO}, interrupt, macros::ram, peripherals::{self, Peripherals}, diff --git a/esp32-hal/examples/i2s_read.rs b/esp32-hal/examples/i2s_read.rs index 50dee73eb69..2f7d0996582 100644 --- a/esp32-hal/examples/i2s_read.rs +++ b/esp32-hal/examples/i2s_read.rs @@ -1,5 +1,5 @@ //! This shows how to continously receive data via I2S -//! +//! //! Pins used //! BCLK GPIO12 //! WS GPIO13 @@ -7,7 +7,7 @@ //! //! Without an additional I2S source device you can connect 3V3 or GND to DIN to //! read 0 or 0xFF or connect DIN to WS to read two different values -//! +//! //! You can also inspect the MCLK, BCLK and WS with a logic analyzer #![no_std] @@ -15,9 +15,9 @@ use esp32_hal::{ clock::ClockControl, - dma::{DmaPriority}, + dma::DmaPriority, + i2s::{DataFormat, I2s, I2s0New, I2sReadDma, NoMclk, PinsBclkWsDin, Standard}, pdma::Dma, - i2s::{DataFormat, I2s, NoMclk, Standard, I2s0New, PinsBclkWsDin, I2sReadDma}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32-hal/examples/i2s_sound.rs b/esp32-hal/examples/i2s_sound.rs index ad016008587..7ecec89eb84 100644 --- a/esp32-hal/examples/i2s_sound.rs +++ b/esp32-hal/examples/i2s_sound.rs @@ -32,8 +32,8 @@ use esp32_hal::{ clock::ClockControl, dma::DmaPriority, + i2s::{DataFormat, I2s, I2s0New, I2sWriteDma, NoMclk, PinsBclkWsDout, Standard}, pdma::Dma, - i2s::{DataFormat, I2s, I2sWriteDma, NoMclk, PinsBclkWsDout, Standard, I2s0New}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32-hal/examples/mcpwm.rs b/esp32-hal/examples/mcpwm.rs index 777671d8503..0c355e08cc6 100644 --- a/esp32-hal/examples/mcpwm.rs +++ b/esp32-hal/examples/mcpwm.rs @@ -1,4 +1,5 @@ -//! Uses timer0 and operator0 of the MCPWM0 peripheral to output a 50% duty signal at 20 kHz. +//! Uses timer0 and operator0 of the MCPWM0 peripheral to output a 50% duty +//! signal at 20 kHz. //! //! The signal will be output to the pin assigned to `pin`. (GPIO4) @@ -8,11 +9,7 @@ use esp32_hal::{ clock::ClockControl, gpio::IO, - mcpwm::{ - {MCPWM, PeripheralClockConfig}, - operator::PwmPinConfig, - timer::PwmWorkingMode, - }, + mcpwm::{operator::PwmPinConfig, timer::PwmWorkingMode, PeripheralClockConfig, MCPWM}, peripherals::Peripherals, prelude::*, timer::TimerGroup, @@ -53,8 +50,11 @@ fn main() -> ! { .operator0 .with_pin_a(pin, PwmPinConfig::UP_ACTIVE_HIGH); - // start timer with timestamp values in the range of 0..=99 and a frequency of 20 kHz - let timer_clock_cfg = clock_cfg.timer_clock_with_frequency(99, PwmWorkingMode::Increase, 20u32.kHz()).unwrap(); + // start timer with timestamp values in the range of 0..=99 and a frequency of + // 20 kHz + let timer_clock_cfg = clock_cfg + .timer_clock_with_frequency(99, PwmWorkingMode::Increase, 20u32.kHz()) + .unwrap(); mcpwm.timer0.start(timer_clock_cfg); // pin will be high 50% of the time diff --git a/esp32-hal/examples/rtc_watchdog.rs b/esp32-hal/examples/rtc_watchdog.rs index 4f411f09e3d..9054cee0c14 100644 --- a/esp32-hal/examples/rtc_watchdog.rs +++ b/esp32-hal/examples/rtc_watchdog.rs @@ -38,7 +38,11 @@ fn main() -> ! { critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); loop {} } diff --git a/esp32-hal/examples/serial_interrupts.rs b/esp32-hal/examples/serial_interrupts.rs index 1a071306a5f..c7ed2353ef2 100644 --- a/esp32-hal/examples/serial_interrupts.rs +++ b/esp32-hal/examples/serial_interrupts.rs @@ -13,8 +13,8 @@ use esp32_hal::{ interrupt, peripherals::{self, Peripherals, UART0}, prelude::*, - uart::config::AtCmdConfig, timer::TimerGroup, + uart::config::AtCmdConfig, Rtc, Uart, }; @@ -51,7 +51,11 @@ fn main() -> ! { serial0.listen_at_cmd(); serial0.listen_rx_fifo_full(); - interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::UART0, + interrupt::Priority::Priority2, + ) + .unwrap(); timer0.start(1u64.secs()); diff --git a/esp32-hal/examples/sha.rs b/esp32-hal/examples/sha.rs index 9c2c074e619..474910f156b 100644 --- a/esp32-hal/examples/sha.rs +++ b/esp32-hal/examples/sha.rs @@ -1,5 +1,5 @@ -//! Demonstrates the use of the SHA peripheral and compares the speed of hardware-accelerated and pure software hashing. -//! +//! Demonstrates the use of the SHA peripheral and compares the speed of +//! hardware-accelerated and pure software hashing. #![no_std] #![no_main] @@ -8,15 +8,15 @@ use esp32_hal::{ clock::ClockControl, peripherals::Peripherals, prelude::*, + sha::{Sha, ShaMode}, timer::TimerGroup, Rtc, - sha::{Sha, ShaMode}, }; -use nb::block; use esp_backtrace as _; use esp_println::println; +use nb::block; +use sha2::{Digest, Sha512}; use xtensa_lx_rt::entry; -use sha2::{Sha512, Digest}; #[entry] fn main() -> ! { @@ -32,30 +32,34 @@ fn main() -> ! { wdt.disable(); rtc.rwdt.disable(); - let source_data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".as_bytes(); let mut remaining = source_data.clone(); let mut hasher = Sha::new(peripherals.SHA, ShaMode::SHA512); - // Short hashes can be created by decreasing the output buffer to the desired length + // Short hashes can be created by decreasing the output buffer to the desired + // length let mut output = [0u8; 64]; let pre_calc = xtensa_lx::timer::get_cycle_count(); - // The hardware implementation takes a subslice of the input, and returns the unprocessed parts - // The unprocessed parts can be input in the next iteration, you can always add more data until - // finish() is called. After finish() is called update()'s will contribute to a new hash which + // The hardware implementation takes a subslice of the input, and returns the + // unprocessed parts The unprocessed parts can be input in the next + // iteration, you can always add more data until finish() is called. After + // finish() is called update()'s will contribute to a new hash which // can be extracted again with finish(). - + while remaining.len() > 0 { - // Can add println to view progress, however println takes a few orders of magnitude longer than - // the Sha function itself so not useful for comparing processing time - // println!("Remaining len: {}", remaining.len()); + // Can add println to view progress, however println takes a few orders of + // magnitude longer than the Sha function itself so not useful for + // comparing processing time println!("Remaining len: {}", + // remaining.len()); - // All the HW Sha functions are infallible so unwrap is fine to use if you use block! + // All the HW Sha functions are infallible so unwrap is fine to use if you use + // block! remaining = block!(hasher.update(remaining)).unwrap(); } - // Finish can be called as many times as desired to get mutliple copies of the output. + // Finish can be called as many times as desired to get mutliple copies of the + // output. block!(hasher.finish(output.as_mut_slice())).unwrap(); let post_calc = xtensa_lx::timer::get_cycle_count(); @@ -64,7 +68,6 @@ fn main() -> ! { println!("SHA512 Hash output {:02x?}", output); let _usha = hasher.free(); - let pre_calc = xtensa_lx::timer::get_cycle_count(); let mut hasher = Sha512::new(); hasher.update(source_data); @@ -74,7 +77,7 @@ fn main() -> ! { println!("Took {} cycles", soft_time); println!("SHA512 Hash output {:02x?}", soft_result); - println!("HW SHA is {}x faster", soft_time/hw_time); + println!("HW SHA is {}x faster", soft_time / hw_time); loop {} } diff --git a/esp32-hal/examples/spi_loopback_dma.rs b/esp32-hal/examples/spi_loopback_dma.rs index b02380a4db1..dea517e4f92 100644 --- a/esp32-hal/examples/spi_loopback_dma.rs +++ b/esp32-hal/examples/spi_loopback_dma.rs @@ -18,10 +18,10 @@ use esp32_hal::{ clock::ClockControl, - dma::{DmaPriority}, + dma::DmaPriority, gpio::IO, - peripherals::Peripherals, pdma::Dma, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, diff --git a/esp32-hal/examples/watchdog.rs b/esp32-hal/examples/watchdog.rs index 732410a0afd..675e10a03e3 100644 --- a/esp32-hal/examples/watchdog.rs +++ b/esp32-hal/examples/watchdog.rs @@ -5,7 +5,13 @@ #![no_std] #![no_main] -use esp32_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32_hal::{ + clock::ClockControl, + peripherals::Peripherals, + prelude::*, + timer::TimerGroup, + Rtc, +}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32-hal/src/lib.rs b/esp32-hal/src/lib.rs index 7b5e667f965..a213b5a1813 100644 --- a/esp32-hal/src/lib.rs +++ b/esp32-hal/src/lib.rs @@ -1,6 +1,8 @@ #![no_std] pub use embedded_hal as ehal; +#[cfg(feature = "embassy")] +pub use esp_hal_common::embassy; #[doc(inline)] pub use esp_hal_common::{ analog::adc::implementation as adc, @@ -20,10 +22,11 @@ pub use esp_hal_common::{ peripherals, prelude, pulse_control, - uart, + sha, spi, system, timer, + uart, utils, Cpu, Delay, @@ -31,15 +34,11 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - sha, Uart, }; pub use self::gpio::IO; -#[cfg(feature = "embassy")] -pub use esp_hal_common::embassy; - /// Common module for analog functions pub mod analog { pub use esp_hal_common::analog::{AvailableAnalog, SensExt}; diff --git a/esp32c2-hal/examples/advanced_serial.rs b/esp32c2-hal/examples/advanced_serial.rs index 4cd7592a3e9..5f2d11750b2 100644 --- a/esp32c2-hal/examples/advanced_serial.rs +++ b/esp32c2-hal/examples/advanced_serial.rs @@ -10,11 +10,11 @@ use esp32c2_hal::{ clock::ClockControl, peripherals::Peripherals, prelude::*, + timer::TimerGroup, uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, - timer::TimerGroup, Rtc, Uart, IO, diff --git a/esp32c2-hal/examples/clock_monitor.rs b/esp32c2-hal/examples/clock_monitor.rs index 003f19eff4e..3eebc387bf6 100644 --- a/esp32c2-hal/examples/clock_monitor.rs +++ b/esp32c2-hal/examples/clock_monitor.rs @@ -41,7 +41,11 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); critical_section::with(|cs| { RTC.borrow_ref_mut(cs).replace(rtc); diff --git a/esp32c2-hal/examples/embassy_hello_world.rs b/esp32c2-hal/examples/embassy_hello_world.rs index 6d4bab00372..ff827ee9557 100644 --- a/esp32c2-hal/examples/embassy_hello_world.rs +++ b/esp32c2-hal/examples/embassy_hello_world.rs @@ -50,7 +50,10 @@ fn main() -> ! { wdt0.disable(); #[cfg(feature = "embassy-time-systick")] - embassy::init(&clocks, esp32c2_hal::systimer::SystemTimer::new(peripherals.SYSTIMER)); + embassy::init( + &clocks, + esp32c2_hal::systimer::SystemTimer::new(peripherals.SYSTIMER), + ); #[cfg(feature = "embassy-time-timg0")] embassy::init(&clocks, timer_group0.timer0); diff --git a/esp32c2-hal/examples/gpio_interrupt.rs b/esp32c2-hal/examples/gpio_interrupt.rs index 1e0034ab176..0ef960a4b4f 100644 --- a/esp32c2-hal/examples/gpio_interrupt.rs +++ b/esp32c2-hal/examples/gpio_interrupt.rs @@ -11,7 +11,7 @@ use core::cell::RefCell; use critical_section::Mutex; use esp32c2_hal::{ clock::ClockControl, - gpio::{Gpio9, IO, Event, Input, PullDown}, + gpio::{Event, Gpio9, Input, PullDown, IO}, interrupt, peripherals::{self, Peripherals}, prelude::*, diff --git a/esp32c2-hal/examples/rtc_watchdog.rs b/esp32c2-hal/examples/rtc_watchdog.rs index e532a1a09c7..45af22c1473 100644 --- a/esp32c2-hal/examples/rtc_watchdog.rs +++ b/esp32c2-hal/examples/rtc_watchdog.rs @@ -37,7 +37,11 @@ fn main() -> ! { rtc.rwdt.start(2000u64.millis()); rtc.rwdt.listen(); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); diff --git a/esp32c2-hal/examples/serial_interrupts.rs b/esp32c2-hal/examples/serial_interrupts.rs index 8ee9b05c6af..cc6e71cd359 100644 --- a/esp32c2-hal/examples/serial_interrupts.rs +++ b/esp32c2-hal/examples/serial_interrupts.rs @@ -13,8 +13,8 @@ use esp32c2_hal::{ interrupt, peripherals::{self, Peripherals, UART0}, prelude::*, - uart::config::AtCmdConfig, timer::TimerGroup, + uart::config::AtCmdConfig, Cpu, Rtc, Uart, @@ -51,7 +51,11 @@ fn main() -> ! { critical_section::with(|cs| SERIAL.borrow_ref_mut(cs).replace(serial0)); - interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::UART0, + interrupt::Priority::Priority1, + ) + .unwrap(); interrupt::set_kind( Cpu::ProCpu, interrupt::CpuInterrupt::Interrupt1, // Interrupt 1 handles priority one interrupts diff --git a/esp32c2-hal/examples/sha.rs b/esp32c2-hal/examples/sha.rs index 4f82c0e96de..290770886a9 100644 --- a/esp32c2-hal/examples/sha.rs +++ b/esp32c2-hal/examples/sha.rs @@ -1,5 +1,5 @@ -//! Demonstrates the use of the SHA peripheral and compares the speed of hardware-accelerated and pure software hashing. -//! +//! Demonstrates the use of the SHA peripheral and compares the speed of +//! hardware-accelerated and pure software hashing. #![no_std] #![no_main] @@ -8,15 +8,15 @@ use esp32c2_hal::{ clock::ClockControl, peripherals::Peripherals, prelude::*, + sha::{Sha, ShaMode}, timer::TimerGroup, Rtc, - sha::{Sha, ShaMode}, }; -use nb::block; use esp_backtrace as _; use esp_println::println; +use nb::block; use riscv_rt::entry; -use sha2::{Sha256, Digest}; +use sha2::{Digest, Sha256}; #[entry] fn main() -> ! { @@ -32,48 +32,51 @@ fn main() -> ! { wdt.disable(); rtc.rwdt.disable(); - let source_data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".as_bytes(); let mut remaining = source_data.clone(); let mut hasher = Sha::new(peripherals.SHA, ShaMode::SHA256); - // Short hashes can be created by decreasing the output buffer to the desired length + // Short hashes can be created by decreasing the output buffer to the desired + // length let mut output = [0u8; 32]; - //let pre_calc = xtensa_lx::timer::get_cycle_count(); - // The hardware implementation takes a subslice of the input, and returns the unprocessed parts - // The unprocessed parts can be input in the next iteration, you can always add more data until - // finish() is called. After finish() is called update()'s will contribute to a new hash which + // let pre_calc = xtensa_lx::timer::get_cycle_count(); + // The hardware implementation takes a subslice of the input, and returns the + // unprocessed parts The unprocessed parts can be input in the next + // iteration, you can always add more data until finish() is called. After + // finish() is called update()'s will contribute to a new hash which // can be extracted again with finish(). - + while remaining.len() > 0 { - // Can add println to view progress, however println takes a few orders of magnitude longer than - // the Sha function itself so not useful for comparing processing time - // println!("Remaining len: {}", remaining.len()); + // Can add println to view progress, however println takes a few orders of + // magnitude longer than the Sha function itself so not useful for + // comparing processing time println!("Remaining len: {}", + // remaining.len()); - // All the HW Sha functions are infallible so unwrap is fine to use if you use block! + // All the HW Sha functions are infallible so unwrap is fine to use if you use + // block! remaining = block!(hasher.update(remaining)).unwrap(); } - // Finish can be called as many times as desired to get mutliple copies of the output. + // Finish can be called as many times as desired to get mutliple copies of the + // output. block!(hasher.finish(output.as_mut_slice())).unwrap(); - //let post_calc = xtensa_lx::timer::get_cycle_count(); - //let hw_time = post_calc - pre_calc; - //println!("Took {} cycles", hw_time); + // let post_calc = xtensa_lx::timer::get_cycle_count(); + // let hw_time = post_calc - pre_calc; + // println!("Took {} cycles", hw_time); println!("SHA256 Hash output {:02x?}", output); let _usha = hasher.free(); - - //let pre_calc = xtensa_lx::timer::get_cycle_count(); + // let pre_calc = xtensa_lx::timer::get_cycle_count(); let mut hasher = Sha256::new(); hasher.update(source_data); let soft_result = hasher.finalize(); - //let post_calc = xtensa_lx::timer::get_cycle_count(); - //let soft_time = post_calc - pre_calc; - //println!("Took {} cycles", soft_time); + // let post_calc = xtensa_lx::timer::get_cycle_count(); + // let soft_time = post_calc - pre_calc; + // println!("Took {} cycles", soft_time); println!("SHA256 Hash output {:02x?}", soft_result); - //println!("HW SHA is {}x faster", soft_time/hw_time); + // println!("HW SHA is {}x faster", soft_time/hw_time); loop {} } diff --git a/esp32c2-hal/examples/spi_loopback_dma.rs b/esp32c2-hal/examples/spi_loopback_dma.rs index 6334a60088d..f4090918752 100644 --- a/esp32c2-hal/examples/spi_loopback_dma.rs +++ b/esp32c2-hal/examples/spi_loopback_dma.rs @@ -18,7 +18,7 @@ use esp32c2_hal::{ clock::ClockControl, - dma::{DmaPriority}, + dma::DmaPriority, gdma::Gdma, gpio::IO, peripherals::Peripherals, diff --git a/esp32c2-hal/examples/systimer.rs b/esp32c2-hal/examples/systimer.rs index cc894452bc2..3e98e2b4662 100644 --- a/esp32c2-hal/examples/systimer.rs +++ b/esp32c2-hal/examples/systimer.rs @@ -63,9 +63,21 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET0, + Priority::Priority1, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET1, + Priority::Priority2, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET2, + Priority::Priority2, + ) + .unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/esp32c2-hal/examples/timer_interrupt.rs b/esp32c2-hal/examples/timer_interrupt.rs index 5ec24a420a4..b7b51d5ba46 100644 --- a/esp32c2-hal/examples/timer_interrupt.rs +++ b/esp32c2-hal/examples/timer_interrupt.rs @@ -37,7 +37,11 @@ fn main() -> ! { rtc.rwdt.disable(); wdt0.disable(); - interrupt::enable(peripherals::Interrupt::TG0_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::TG0_T0_LEVEL, + interrupt::Priority::Priority1, + ) + .unwrap(); timer0.start(500u64.millis()); timer0.listen(); diff --git a/esp32c2-hal/examples/watchdog.rs b/esp32c2-hal/examples/watchdog.rs index d603f679d5d..bdc8d838080 100644 --- a/esp32c2-hal/examples/watchdog.rs +++ b/esp32c2-hal/examples/watchdog.rs @@ -5,7 +5,13 @@ #![no_std] #![no_main] -use esp32c2_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32c2_hal::{ + clock::ClockControl, + peripherals::Peripherals, + prelude::*, + timer::TimerGroup, + Rtc, +}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32c2-hal/src/lib.rs b/esp32c2-hal/src/lib.rs index 10812dc26b4..8579ced6641 100644 --- a/esp32c2-hal/src/lib.rs +++ b/esp32c2-hal/src/lib.rs @@ -18,17 +18,17 @@ pub use esp_hal_common::{ macros, peripherals, prelude, - uart, + sha, spi, system, systimer, timer, + uart, Cpu, Delay, Rng, Rtc, Rwdt, - sha, Uart, }; diff --git a/esp32c3-hal/examples/advanced_serial.rs b/esp32c3-hal/examples/advanced_serial.rs index 503e541c5f1..bcc4c43f5c0 100644 --- a/esp32c3-hal/examples/advanced_serial.rs +++ b/esp32c3-hal/examples/advanced_serial.rs @@ -10,11 +10,11 @@ use esp32c3_hal::{ clock::ClockControl, peripherals::Peripherals, prelude::*, + timer::TimerGroup, uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, - timer::TimerGroup, Rtc, Uart, IO, diff --git a/esp32c3-hal/examples/clock_monitor.rs b/esp32c3-hal/examples/clock_monitor.rs index 6547c033636..777beee0af2 100644 --- a/esp32c3-hal/examples/clock_monitor.rs +++ b/esp32c3-hal/examples/clock_monitor.rs @@ -41,7 +41,11 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); critical_section::with(|cs| { RTC.borrow_ref_mut(cs).replace(rtc); diff --git a/esp32c3-hal/examples/embassy_hello_world.rs b/esp32c3-hal/examples/embassy_hello_world.rs index 086b92f4be2..8c22abef033 100644 --- a/esp32c3-hal/examples/embassy_hello_world.rs +++ b/esp32c3-hal/examples/embassy_hello_world.rs @@ -4,12 +4,13 @@ use embassy_executor::Executor; use embassy_time::{Duration, Timer}; - use esp32c3_hal::{ clock::ClockControl, + embassy, + peripherals::Peripherals, prelude::*, timer::TimerGroup, - Rtc, embassy, peripherals::Peripherals, + Rtc, }; use esp_backtrace as _; use static_cell::StaticCell; @@ -52,7 +53,10 @@ fn main() -> ! { wdt1.disable(); #[cfg(feature = "embassy-time-systick")] - embassy::init(&clocks, esp32c3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER)); + embassy::init( + &clocks, + esp32c3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER), + ); #[cfg(feature = "embassy-time-timg0")] embassy::init(&clocks, timer_group0.timer0); @@ -62,4 +66,4 @@ fn main() -> ! { spawner.spawn(run1()).ok(); spawner.spawn(run2()).ok(); }); -} \ No newline at end of file +} diff --git a/esp32c3-hal/examples/gpio_interrupt.rs b/esp32c3-hal/examples/gpio_interrupt.rs index 483b6f5d276..a69e8ce308d 100644 --- a/esp32c3-hal/examples/gpio_interrupt.rs +++ b/esp32c3-hal/examples/gpio_interrupt.rs @@ -11,7 +11,7 @@ use core::cell::RefCell; use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, - gpio::{Gpio9, IO, Event, Input, PullDown}, + gpio::{Event, Gpio9, Input, PullDown, IO}, interrupt, peripherals::{self, Peripherals}, prelude::*, diff --git a/esp32c3-hal/examples/i2s_read.rs b/esp32c3-hal/examples/i2s_read.rs index 40fb9a72052..06fd660769a 100644 --- a/esp32c3-hal/examples/i2s_read.rs +++ b/esp32c3-hal/examples/i2s_read.rs @@ -1,5 +1,5 @@ //! This shows how to continously receive data via I2S -//! +//! //! Pins used //! MCLK GPIO4 //! BCLK GPIO1 @@ -8,7 +8,7 @@ //! //! Without an additional I2S source device you can connect 3V3 or GND to DIN to //! read 0 or 0xFF or connect DIN to WS to read two different values -//! +//! //! You can also inspect the MCLK, BCLK and WS with a logic analyzer #![no_std] @@ -18,7 +18,7 @@ use esp32c3_hal::{ clock::ClockControl, dma::DmaPriority, gdma::Gdma, - i2s::{DataFormat, I2s, I2sReadDma, MclkPin, PinsBclkWsDin, Standard, I2s0New}, + i2s::{DataFormat, I2s, I2s0New, I2sReadDma, MclkPin, PinsBclkWsDin, Standard}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32c3-hal/examples/i2s_sound.rs b/esp32c3-hal/examples/i2s_sound.rs index f6ac33a0e6c..8393d5d49ce 100644 --- a/esp32c3-hal/examples/i2s_sound.rs +++ b/esp32c3-hal/examples/i2s_sound.rs @@ -34,7 +34,7 @@ use esp32c3_hal::{ clock::ClockControl, dma::DmaPriority, gdma::Gdma, - i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New}, + i2s::{DataFormat, I2s, I2s0New, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32c3-hal/examples/rtc_watchdog.rs b/esp32c3-hal/examples/rtc_watchdog.rs index 8224d193a98..035a977e5a4 100644 --- a/esp32c3-hal/examples/rtc_watchdog.rs +++ b/esp32c3-hal/examples/rtc_watchdog.rs @@ -37,7 +37,11 @@ fn main() -> ! { rtc.rwdt.start(2000u64.millis()); rtc.rwdt.listen(); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); diff --git a/esp32c3-hal/examples/serial_interrupts.rs b/esp32c3-hal/examples/serial_interrupts.rs index 9ef9749a245..a020c167536 100644 --- a/esp32c3-hal/examples/serial_interrupts.rs +++ b/esp32c3-hal/examples/serial_interrupts.rs @@ -13,8 +13,8 @@ use esp32c3_hal::{ interrupt, peripherals::{self, Peripherals, UART0}, prelude::*, - uart::config::AtCmdConfig, timer::TimerGroup, + uart::config::AtCmdConfig, Cpu, Rtc, Uart, @@ -54,7 +54,11 @@ fn main() -> ! { critical_section::with(|cs| SERIAL.borrow_ref_mut(cs).replace(serial0)); - interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::UART0, + interrupt::Priority::Priority1, + ) + .unwrap(); interrupt::set_kind( Cpu::ProCpu, interrupt::CpuInterrupt::Interrupt1, // Interrupt 1 handles priority one interrupts diff --git a/esp32c3-hal/examples/sha.rs b/esp32c3-hal/examples/sha.rs index db925f555b0..88d8e6eddd5 100644 --- a/esp32c3-hal/examples/sha.rs +++ b/esp32c3-hal/examples/sha.rs @@ -1,5 +1,5 @@ -//! Demonstrates the use of the SHA peripheral and compares the speed of hardware-accelerated and pure software hashing. -//! +//! Demonstrates the use of the SHA peripheral and compares the speed of +//! hardware-accelerated and pure software hashing. #![no_std] #![no_main] @@ -8,15 +8,15 @@ use esp32c3_hal::{ clock::ClockControl, peripherals::Peripherals, prelude::*, + sha::{Sha, ShaMode}, timer::TimerGroup, Rtc, - sha::{Sha, ShaMode}, }; -use nb::block; use esp_backtrace as _; use esp_println::println; +use nb::block; use riscv_rt::entry; -use sha2::{Sha256, Digest}; +use sha2::{Digest, Sha256}; #[entry] fn main() -> ! { @@ -32,48 +32,51 @@ fn main() -> ! { wdt.disable(); rtc.rwdt.disable(); - let source_data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".as_bytes(); let mut remaining = source_data.clone(); let mut hasher = Sha::new(peripherals.SHA, ShaMode::SHA256); - // Short hashes can be created by decreasing the output buffer to the desired length + // Short hashes can be created by decreasing the output buffer to the desired + // length let mut output = [0u8; 32]; - //let pre_calc = xtensa_lx::timer::get_cycle_count(); - // The hardware implementation takes a subslice of the input, and returns the unprocessed parts - // The unprocessed parts can be input in the next iteration, you can always add more data until - // finish() is called. After finish() is called update()'s will contribute to a new hash which + // let pre_calc = xtensa_lx::timer::get_cycle_count(); + // The hardware implementation takes a subslice of the input, and returns the + // unprocessed parts The unprocessed parts can be input in the next + // iteration, you can always add more data until finish() is called. After + // finish() is called update()'s will contribute to a new hash which // can be extracted again with finish(). - + while remaining.len() > 0 { - // Can add println to view progress, however println takes a few orders of magnitude longer than - // the Sha function itself so not useful for comparing processing time - // println!("Remaining len: {}", remaining.len()); + // Can add println to view progress, however println takes a few orders of + // magnitude longer than the Sha function itself so not useful for + // comparing processing time println!("Remaining len: {}", + // remaining.len()); - // All the HW Sha functions are infallible so unwrap is fine to use if you use block! + // All the HW Sha functions are infallible so unwrap is fine to use if you use + // block! remaining = block!(hasher.update(remaining)).unwrap(); } - // Finish can be called as many times as desired to get mutliple copies of the output. + // Finish can be called as many times as desired to get mutliple copies of the + // output. block!(hasher.finish(output.as_mut_slice())).unwrap(); - //let post_calc = xtensa_lx::timer::get_cycle_count(); - //let hw_time = post_calc - pre_calc; - //println!("Took {} cycles", hw_time); + // let post_calc = xtensa_lx::timer::get_cycle_count(); + // let hw_time = post_calc - pre_calc; + // println!("Took {} cycles", hw_time); println!("SHA256 Hash output {:02x?}", output); let _usha = hasher.free(); - - //let pre_calc = xtensa_lx::timer::get_cycle_count(); + // let pre_calc = xtensa_lx::timer::get_cycle_count(); let mut hasher = Sha256::new(); hasher.update(source_data); let soft_result = hasher.finalize(); - //let post_calc = xtensa_lx::timer::get_cycle_count(); - //let soft_time = post_calc - pre_calc; - //println!("Took {} cycles", soft_time); + // let post_calc = xtensa_lx::timer::get_cycle_count(); + // let soft_time = post_calc - pre_calc; + // println!("Took {} cycles", soft_time); println!("SHA256 Hash output {:02x?}", soft_result); - //println!("HW SHA is {}x faster", soft_time/hw_time); + // println!("HW SHA is {}x faster", soft_time/hw_time); loop {} } diff --git a/esp32c3-hal/examples/spi_loopback_dma.rs b/esp32c3-hal/examples/spi_loopback_dma.rs index 20c5cf2a4d8..5385c82aeea 100644 --- a/esp32c3-hal/examples/spi_loopback_dma.rs +++ b/esp32c3-hal/examples/spi_loopback_dma.rs @@ -18,7 +18,7 @@ use esp32c3_hal::{ clock::ClockControl, - dma::{DmaPriority}, + dma::DmaPriority, gdma::Gdma, gpio::IO, peripherals::Peripherals, diff --git a/esp32c3-hal/examples/systimer.rs b/esp32c3-hal/examples/systimer.rs index 0beef103562..fa8c0fdc3ec 100644 --- a/esp32c3-hal/examples/systimer.rs +++ b/esp32c3-hal/examples/systimer.rs @@ -63,9 +63,21 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET0, + Priority::Priority1, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET1, + Priority::Priority2, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET2, + Priority::Priority2, + ) + .unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/esp32c3-hal/examples/timer_interrupt.rs b/esp32c3-hal/examples/timer_interrupt.rs index 9fe9e6f5530..ccad344f33d 100644 --- a/esp32c3-hal/examples/timer_interrupt.rs +++ b/esp32c3-hal/examples/timer_interrupt.rs @@ -43,11 +43,19 @@ fn main() -> ! { wdt0.disable(); wdt1.disable(); - interrupt::enable(peripherals::Interrupt::TG0_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::TG0_T0_LEVEL, + interrupt::Priority::Priority1, + ) + .unwrap(); timer0.start(500u64.millis()); timer0.listen(); - interrupt::enable(peripherals::Interrupt::TG1_T0_LEVEL, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::TG1_T0_LEVEL, + interrupt::Priority::Priority1, + ) + .unwrap(); timer1.start(1u64.secs()); timer1.listen(); diff --git a/esp32c3-hal/examples/usb_serial_jtag.rs b/esp32c3-hal/examples/usb_serial_jtag.rs index c8654d5706d..35c08a561ca 100644 --- a/esp32c3-hal/examples/usb_serial_jtag.rs +++ b/esp32c3-hal/examples/usb_serial_jtag.rs @@ -12,8 +12,7 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, interrupt, - peripherals::{self, USB_DEVICE}, - peripherals::Peripherals, + peripherals::{self, Peripherals, USB_DEVICE}, prelude::*, timer::TimerGroup, Cpu, diff --git a/esp32c3-hal/examples/watchdog.rs b/esp32c3-hal/examples/watchdog.rs index 519d1d3ee30..1eb0ce58dfa 100644 --- a/esp32c3-hal/examples/watchdog.rs +++ b/esp32c3-hal/examples/watchdog.rs @@ -5,7 +5,13 @@ #![no_std] #![no_main] -use esp32c3_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32c3_hal::{ + clock::ClockControl, + peripherals::Peripherals, + prelude::*, + timer::TimerGroup, + Rtc, +}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32c3-hal/src/lib.rs b/esp32c3-hal/src/lib.rs index 57e8177552c..5601e49c036 100644 --- a/esp32c3-hal/src/lib.rs +++ b/esp32c3-hal/src/lib.rs @@ -5,6 +5,8 @@ use core::arch::{asm, global_asm}; use core::mem::size_of; pub use embedded_hal as ehal; +#[cfg(feature = "embassy")] +pub use esp_hal_common::embassy; #[doc(inline)] pub use esp_hal_common::{ analog::adc::implementation as adc, @@ -21,6 +23,7 @@ pub use esp_hal_common::{ peripherals, prelude, pulse_control, + sha, spi, system, systimer, @@ -35,12 +38,7 @@ pub use esp_hal_common::{ Rwdt, Uart, UsbSerialJtag, - sha }; - -#[cfg(feature = "embassy")] -pub use esp_hal_common::embassy; - #[cfg(feature = "direct-boot")] use riscv_rt::pre_init; diff --git a/esp32s2-hal/examples/adc.rs b/esp32s2-hal/examples/adc.rs index 808ce9eaa19..50c539fa0f4 100644 --- a/esp32s2-hal/examples/adc.rs +++ b/esp32s2-hal/examples/adc.rs @@ -16,8 +16,8 @@ use esp32s2_hal::{ Rtc, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use esp_println::println; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -57,15 +57,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/advanced_serial.rs b/esp32s2-hal/examples/advanced_serial.rs index 8bff4bb6f94..36ac70fc3ef 100644 --- a/esp32s2-hal/examples/advanced_serial.rs +++ b/esp32s2-hal/examples/advanced_serial.rs @@ -11,19 +11,19 @@ use esp32s2_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, + timer::TimerGroup, uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, - timer::TimerGroup, Delay, Rtc, Uart, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use esp_println::println; use nb::block; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -72,15 +72,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/blinky.rs b/esp32s2-hal/examples/blinky.rs index f7371fa71e5..393c5c8a48e 100644 --- a/esp32s2-hal/examples/blinky.rs +++ b/esp32s2-hal/examples/blinky.rs @@ -49,15 +49,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/clock_monitor.rs b/esp32s2-hal/examples/clock_monitor.rs index 6f2b6a378a5..cbf7a74318b 100644 --- a/esp32s2-hal/examples/clock_monitor.rs +++ b/esp32s2-hal/examples/clock_monitor.rs @@ -16,8 +16,8 @@ use esp32s2_hal::{ Rtc, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use esp_println::println; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; static RTC: Mutex>> = Mutex::new(RefCell::new(None)); @@ -42,7 +42,11 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); critical_section::with(|cs| RTC.borrow_ref_mut(cs).replace(rtc)); @@ -66,15 +70,18 @@ fn RTC_CORE() { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/dac.rs b/esp32s2-hal/examples/dac.rs index 4276df18dd8..e0d5b9a6cf9 100644 --- a/esp32s2-hal/examples/dac.rs +++ b/esp32s2-hal/examples/dac.rs @@ -58,15 +58,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/embassy_hello_world.rs b/esp32s2-hal/examples/embassy_hello_world.rs index df332cbaa78..fb31b350b69 100644 --- a/esp32s2-hal/examples/embassy_hello_world.rs +++ b/esp32s2-hal/examples/embassy_hello_world.rs @@ -4,16 +4,17 @@ use embassy_executor::Executor; use embassy_time::{Duration, Timer}; - use esp32s2_hal::{ clock::ClockControl, + embassy, + peripherals::Peripherals, prelude::*, timer::TimerGroup, - Rtc, embassy, peripherals::Peripherals, + Rtc, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use static_cell::StaticCell; +use xtensa_atomic_emulation_trap as _; #[embassy_executor::task] async fn run1() { @@ -62,15 +63,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/gpio_interrupt.rs b/esp32s2-hal/examples/gpio_interrupt.rs index 14f5a2b74df..7e2285a2fab 100644 --- a/esp32s2-hal/examples/gpio_interrupt.rs +++ b/esp32s2-hal/examples/gpio_interrupt.rs @@ -11,7 +11,7 @@ use core::cell::RefCell; use critical_section::Mutex; use esp32s2_hal::{ clock::ClockControl, - gpio::{Gpio0, IO, Event, Input, PullDown}, + gpio::{Event, Gpio0, Input, PullDown, IO}, interrupt, macros::ram, peripherals::{self, Peripherals}, @@ -80,15 +80,18 @@ fn GPIO() { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/hello_rgb.rs b/esp32s2-hal/examples/hello_rgb.rs index 1463e10b2a8..af1f740150b 100644 --- a/esp32s2-hal/examples/hello_rgb.rs +++ b/esp32s2-hal/examples/hello_rgb.rs @@ -24,13 +24,13 @@ use esp32s2_hal::{ }; #[allow(unused_imports)] use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use smart_leds::{ brightness, gamma, hsv::{hsv2rgb, Hsv}, SmartLedsWrite, }; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -84,15 +84,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/hello_world.rs b/esp32s2-hal/examples/hello_world.rs index bd0b708e177..952abc7d860 100644 --- a/esp32s2-hal/examples/hello_world.rs +++ b/esp32s2-hal/examples/hello_world.rs @@ -15,8 +15,8 @@ use esp32s2_hal::{ Uart, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use nb::block; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -44,11 +44,14 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/i2c_display.rs b/esp32s2-hal/examples/i2c_display.rs index 01bd307f6ea..fcb23e55268 100644 --- a/esp32s2-hal/examples/i2c_display.rs +++ b/esp32s2-hal/examples/i2c_display.rs @@ -29,9 +29,9 @@ use esp32s2_hal::{ Rtc, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use nb::block; use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306}; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -131,15 +131,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/i2s_read.rs b/esp32s2-hal/examples/i2s_read.rs index c85b3b5c540..c08db6d1123 100644 --- a/esp32s2-hal/examples/i2s_read.rs +++ b/esp32s2-hal/examples/i2s_read.rs @@ -1,5 +1,5 @@ //! This shows how to continously receive data via I2S -//! +//! //! Pins used //! BCLK GPIO1 //! WS GPIO2 @@ -7,7 +7,7 @@ //! //! Without an additional I2S source device you can connect 3V3 or GND to DIN to //! read 0 or 0xFF or connect DIN to WS to read two different values -//! +//! //! You can also inspect the MCLK, BCLK and WS with a logic analyzer #![no_std] @@ -15,9 +15,9 @@ use esp32s2_hal::{ clock::ClockControl, - dma::{DmaPriority}, + dma::DmaPriority, + i2s::{DataFormat, I2s, I2s0New, I2sReadDma, NoMclk, PinsBclkWsDin, Standard}, pdma::Dma, - i2s::{DataFormat, I2s, NoMclk, Standard, I2s0New, PinsBclkWsDin, I2sReadDma}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32s2-hal/examples/i2s_sound.rs b/esp32s2-hal/examples/i2s_sound.rs index f5054b9f698..94d94df487b 100644 --- a/esp32s2-hal/examples/i2s_sound.rs +++ b/esp32s2-hal/examples/i2s_sound.rs @@ -33,8 +33,8 @@ use esp32s2_hal::{ clock::ClockControl, dma::DmaPriority, + i2s::{DataFormat, I2s, I2s0New, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard}, pdma::Dma, - i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32s2-hal/examples/ledc.rs b/esp32s2-hal/examples/ledc.rs index 2ed52e48576..fb47e49128a 100644 --- a/esp32s2-hal/examples/ledc.rs +++ b/esp32s2-hal/examples/ledc.rs @@ -22,8 +22,8 @@ use esp32s2_hal::{ Rtc, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use esp_println; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -73,15 +73,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/pulse_control.rs b/esp32s2-hal/examples/pulse_control.rs index 693f7da0100..cccede5e6bc 100644 --- a/esp32s2-hal/examples/pulse_control.rs +++ b/esp32s2-hal/examples/pulse_control.rs @@ -78,11 +78,14 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/ram.rs b/esp32s2-hal/examples/ram.rs index ad269855c6c..255a22c2d98 100644 --- a/esp32s2-hal/examples/ram.rs +++ b/esp32s2-hal/examples/ram.rs @@ -17,8 +17,8 @@ use esp32s2_hal::{ }; use esp_backtrace as _; use esp_println::println; -use xtensa_atomic_emulation_trap as _; use nb::block; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[ram(rtc_fast)] @@ -99,11 +99,14 @@ fn function_in_rtc_ram() -> u32 { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/read_efuse.rs b/esp32s2-hal/examples/read_efuse.rs index 07034c681e2..50a609dd474 100644 --- a/esp32s2-hal/examples/read_efuse.rs +++ b/esp32s2-hal/examples/read_efuse.rs @@ -37,15 +37,18 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/rtc_watchdog.rs b/esp32s2-hal/examples/rtc_watchdog.rs index 9561c32dc26..dd01123233b 100644 --- a/esp32s2-hal/examples/rtc_watchdog.rs +++ b/esp32s2-hal/examples/rtc_watchdog.rs @@ -39,7 +39,11 @@ fn main() -> ! { critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); loop {} } @@ -59,11 +63,14 @@ fn RTC_CORE() { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/serial_interrupts.rs b/esp32s2-hal/examples/serial_interrupts.rs index 72f93873143..283247bff09 100644 --- a/esp32s2-hal/examples/serial_interrupts.rs +++ b/esp32s2-hal/examples/serial_interrupts.rs @@ -13,14 +13,14 @@ use esp32s2_hal::{ interrupt, peripherals::{self, Peripherals, UART0}, prelude::*, - uart::config::AtCmdConfig, timer::TimerGroup, + uart::config::AtCmdConfig, Rtc, Uart, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use nb::block; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; static SERIAL: Mutex>>> = Mutex::new(RefCell::new(None)); @@ -52,7 +52,11 @@ fn main() -> ! { serial0.listen_at_cmd(); serial0.listen_rx_fifo_full(); - interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::UART0, + interrupt::Priority::Priority2, + ) + .unwrap(); timer0.start(1u64.secs()); @@ -95,15 +99,18 @@ fn UART0() { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/sha.rs b/esp32s2-hal/examples/sha.rs index 746bb43c8db..c9d53c25980 100644 --- a/esp32s2-hal/examples/sha.rs +++ b/esp32s2-hal/examples/sha.rs @@ -1,5 +1,5 @@ -//! Demonstrates the use of the SHA peripheral and compares the speed of hardware-accelerated and pure software hashing. -//! +//! Demonstrates the use of the SHA peripheral and compares the speed of +//! hardware-accelerated and pure software hashing. #![no_std] #![no_main] @@ -8,15 +8,15 @@ use esp32s2_hal::{ clock::ClockControl, peripherals::Peripherals, prelude::*, + sha::{Sha, ShaMode}, timer::TimerGroup, Rtc, - sha::{Sha, ShaMode}, }; -use nb::block; use esp_backtrace as _; use esp_println::println; +use nb::block; +use sha2::{Digest, Sha512}; use xtensa_lx_rt::entry; -use sha2::{Sha512, Digest}; #[entry] fn main() -> ! { @@ -32,30 +32,34 @@ fn main() -> ! { wdt.disable(); rtc.rwdt.disable(); - let source_data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".as_bytes(); let mut remaining = source_data.clone(); let mut hasher = Sha::new(peripherals.SHA, ShaMode::SHA512); - // Short hashes can be created by decreasing the output buffer to the desired length + // Short hashes can be created by decreasing the output buffer to the desired + // length let mut output = [0u8; 64]; let pre_calc = xtensa_lx::timer::get_cycle_count(); - // The hardware implementation takes a subslice of the input, and returns the unprocessed parts - // The unprocessed parts can be input in the next iteration, you can always add more data until - // finish() is called. After finish() is called update()'s will contribute to a new hash which + // The hardware implementation takes a subslice of the input, and returns the + // unprocessed parts The unprocessed parts can be input in the next + // iteration, you can always add more data until finish() is called. After + // finish() is called update()'s will contribute to a new hash which // can be extracted again with finish(). - + while remaining.len() > 0 { - // Can add println to view progress, however println takes a few orders of magnitude longer than - // the Sha function itself so not useful for comparing processing time - // println!("Remaining len: {}", remaining.len()); + // Can add println to view progress, however println takes a few orders of + // magnitude longer than the Sha function itself so not useful for + // comparing processing time println!("Remaining len: {}", + // remaining.len()); - // All the HW Sha functions are infallible so unwrap is fine to use if you use block! + // All the HW Sha functions are infallible so unwrap is fine to use if you use + // block! remaining = block!(hasher.update(remaining)).unwrap(); } - // Finish can be called as many times as desired to get mutliple copies of the output. + // Finish can be called as many times as desired to get mutliple copies of the + // output. block!(hasher.finish(output.as_mut_slice())).unwrap(); let post_calc = xtensa_lx::timer::get_cycle_count(); let hw_time = post_calc - pre_calc; @@ -63,7 +67,6 @@ fn main() -> ! { println!("SHA512 Hash output {:02x?}", output); let _usha = hasher.free(); - let pre_calc = xtensa_lx::timer::get_cycle_count(); let mut hasher = Sha512::new(); hasher.update(source_data); @@ -73,7 +76,7 @@ fn main() -> ! { println!("Took {} cycles", soft_time); println!("SHA512 Hash output {:02x?}", soft_result); - println!("HW SHA is {}x faster", soft_time/hw_time); + println!("HW SHA is {}x faster", soft_time / hw_time); loop {} } diff --git a/esp32s2-hal/examples/spi_eh1_device_loopback.rs b/esp32s2-hal/examples/spi_eh1_device_loopback.rs index 2e75be4cea3..f515967fac5 100644 --- a/esp32s2-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32s2-hal/examples/spi_eh1_device_loopback.rs @@ -150,11 +150,14 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/spi_eh1_loopback.rs b/esp32s2-hal/examples/spi_eh1_loopback.rs index 03ec71cde3b..3592fc78592 100644 --- a/esp32s2-hal/examples/spi_eh1_loopback.rs +++ b/esp32s2-hal/examples/spi_eh1_loopback.rs @@ -122,11 +122,14 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/spi_loopback.rs b/esp32s2-hal/examples/spi_loopback.rs index bfb9bbbb749..ff4769516b7 100644 --- a/esp32s2-hal/examples/spi_loopback.rs +++ b/esp32s2-hal/examples/spi_loopback.rs @@ -76,11 +76,14 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/spi_loopback_dma.rs b/esp32s2-hal/examples/spi_loopback_dma.rs index 98cba99e8b7..35ccfbe7647 100644 --- a/esp32s2-hal/examples/spi_loopback_dma.rs +++ b/esp32s2-hal/examples/spi_loopback_dma.rs @@ -18,10 +18,10 @@ use esp32s2_hal::{ clock::ClockControl, - dma::{DmaPriority}, + dma::DmaPriority, gpio::IO, - peripherals::Peripherals, pdma::Dma, + peripherals::Peripherals, prelude::*, spi::{Spi, SpiMode}, timer::TimerGroup, @@ -29,8 +29,8 @@ use esp32s2_hal::{ Rtc, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; use esp_println::println; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -120,15 +120,18 @@ fn buffer2() -> &'static mut [u8; 32000] { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/systimer.rs b/esp32s2-hal/examples/systimer.rs index f8914741327..3f4fe809ae6 100644 --- a/esp32s2-hal/examples/systimer.rs +++ b/esp32s2-hal/examples/systimer.rs @@ -63,9 +63,21 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority3).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority3).unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET0, + Priority::Priority1, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET1, + Priority::Priority3, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET2, + Priority::Priority3, + ) + .unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. @@ -113,11 +125,14 @@ fn SYSTIMER_TARGET2() { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/examples/timer_interrupt.rs b/esp32s2-hal/examples/timer_interrupt.rs index b2739a8a29a..42acbaf5bdf 100644 --- a/esp32s2-hal/examples/timer_interrupt.rs +++ b/esp32s2-hal/examples/timer_interrupt.rs @@ -131,15 +131,18 @@ fn TG1_T1_LEVEL() { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { println!("0x{:x}", addr) } } -} \ No newline at end of file +} diff --git a/esp32s2-hal/examples/watchdog.rs b/esp32s2-hal/examples/watchdog.rs index 3356b26acd9..9fd4d2f55bd 100644 --- a/esp32s2-hal/examples/watchdog.rs +++ b/esp32s2-hal/examples/watchdog.rs @@ -5,11 +5,17 @@ #![no_std] #![no_main] -use esp32s2_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32s2_hal::{ + clock::ClockControl, + peripherals::Peripherals, + prelude::*, + timer::TimerGroup, + Rtc, +}; use esp_backtrace as _; use esp_println::println; -use xtensa_atomic_emulation_trap as _; use nb::block; +use xtensa_atomic_emulation_trap as _; use xtensa_lx_rt::entry; #[entry] @@ -36,11 +42,14 @@ fn main() -> ! { } #[xtensa_lx_rt::exception] -fn exception(cause: xtensa_lx_rt::exception::ExceptionCause, frame: xtensa_lx_rt::exception::Context) { +fn exception( + cause: xtensa_lx_rt::exception::ExceptionCause, + frame: xtensa_lx_rt::exception::Context, +) { use esp_println::*; println!("\n\nException occured {:?} {:x?}", cause, frame); - + let backtrace = esp_backtrace::arch::backtrace(); for b in backtrace.iter() { if let Some(addr) = b { diff --git a/esp32s2-hal/src/lib.rs b/esp32s2-hal/src/lib.rs index ac2ef6cddfb..1c9f481fb53 100644 --- a/esp32s2-hal/src/lib.rs +++ b/esp32s2-hal/src/lib.rs @@ -1,6 +1,8 @@ #![no_std] pub use embedded_hal as ehal; +#[cfg(feature = "embassy")] +pub use esp_hal_common::embassy; #[doc(inline)] pub use esp_hal_common::{ analog::adc::implementation as adc, @@ -10,20 +12,21 @@ pub use esp_hal_common::{ dma::pdma, efuse, gpio, - i2s, i2c::{self, I2C}, + i2s, interrupt, ledc, macros, otg_fs, + peripherals, prelude, pulse_control, - peripherals, - uart, + sha, spi, system, systimer, timer, + uart, utils, Cpu, Delay, @@ -31,13 +34,9 @@ pub use esp_hal_common::{ Rng, Rtc, Rwdt, - sha, Uart, }; -#[cfg(feature = "embassy")] -pub use esp_hal_common::embassy; - pub use self::gpio::IO; /// Common module for analog functions diff --git a/esp32s3-hal/examples/advanced_serial.rs b/esp32s3-hal/examples/advanced_serial.rs index af83d82581b..fd86b44c593 100644 --- a/esp32s3-hal/examples/advanced_serial.rs +++ b/esp32s3-hal/examples/advanced_serial.rs @@ -11,11 +11,11 @@ use esp32s3_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, + timer::TimerGroup, uart::{ config::{Config, DataBits, Parity, StopBits}, TxRxPins, }, - timer::TimerGroup, Delay, Rtc, Uart, diff --git a/esp32s3-hal/examples/clock_monitor.rs b/esp32s3-hal/examples/clock_monitor.rs index bcf5ff161cd..06c3016bfd3 100644 --- a/esp32s3-hal/examples/clock_monitor.rs +++ b/esp32s3-hal/examples/clock_monitor.rs @@ -41,7 +41,11 @@ fn main() -> ! { clocks.xtal_clock.to_MHz() ); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); critical_section::with(|cs| RTC.borrow_ref_mut(cs).replace(rtc)); diff --git a/esp32s3-hal/examples/embassy_hello_world.rs b/esp32s3-hal/examples/embassy_hello_world.rs index e73e31e5cc8..7d02ef2201b 100644 --- a/esp32s3-hal/examples/embassy_hello_world.rs +++ b/esp32s3-hal/examples/embassy_hello_world.rs @@ -4,12 +4,13 @@ use embassy_executor::Executor; use embassy_time::{Duration, Timer}; - use esp32s3_hal::{ clock::ClockControl, + embassy, + peripherals::Peripherals, prelude::*, timer::TimerGroup, - Rtc, embassy, peripherals::Peripherals, + Rtc, }; use esp_backtrace as _; use static_cell::StaticCell; @@ -52,7 +53,10 @@ fn main() -> ! { wdt1.disable(); #[cfg(feature = "embassy-time-systick")] - embassy::init(&clocks, esp32s3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER)); + embassy::init( + &clocks, + esp32s3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER), + ); #[cfg(feature = "embassy-time-timg0")] embassy::init(&clocks, timer_group0.timer0); @@ -62,4 +66,4 @@ fn main() -> ! { spawner.spawn(run1()).ok(); spawner.spawn(run2()).ok(); }); -} \ No newline at end of file +} diff --git a/esp32s3-hal/examples/gpio_interrupt.rs b/esp32s3-hal/examples/gpio_interrupt.rs index 66790c8afd0..215829cd1f1 100644 --- a/esp32s3-hal/examples/gpio_interrupt.rs +++ b/esp32s3-hal/examples/gpio_interrupt.rs @@ -11,7 +11,7 @@ use core::cell::RefCell; use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, - gpio::{Gpio0, IO, Event, Input, PullDown}, + gpio::{Event, Gpio0, Input, PullDown, IO}, interrupt, macros::ram, peripherals::{self, Peripherals}, diff --git a/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs b/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs index e27593a2b10..301a5a43dd2 100644 --- a/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs +++ b/esp32s3-hal/examples/i2c_bmp180_calibration_data.rs @@ -10,7 +10,13 @@ #![no_main] use esp32s3_hal::{ - clock::ClockControl, gpio::IO, i2c::I2C, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, + clock::ClockControl, + gpio::IO, + i2c::I2C, + peripherals::Peripherals, + prelude::*, + timer::TimerGroup, + Rtc, }; use esp_backtrace as _; use esp_println::println; diff --git a/esp32s3-hal/examples/i2s_read.rs b/esp32s3-hal/examples/i2s_read.rs index 5bb2ddacf35..b711769ffbc 100644 --- a/esp32s3-hal/examples/i2s_read.rs +++ b/esp32s3-hal/examples/i2s_read.rs @@ -18,7 +18,7 @@ use esp32s3_hal::{ clock::ClockControl, dma::DmaPriority, gdma::Gdma, - i2s::{DataFormat, I2s, I2sReadDma, MclkPin, PinsBclkWsDin, Standard, I2s0New}, + i2s::{DataFormat, I2s, I2s0New, I2sReadDma, MclkPin, PinsBclkWsDin, Standard}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32s3-hal/examples/i2s_sound.rs b/esp32s3-hal/examples/i2s_sound.rs index fdce932d69d..a24e1c2e273 100644 --- a/esp32s3-hal/examples/i2s_sound.rs +++ b/esp32s3-hal/examples/i2s_sound.rs @@ -34,7 +34,7 @@ use esp32s3_hal::{ clock::ClockControl, dma::DmaPriority, gdma::Gdma, - i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New}, + i2s::{DataFormat, I2s, I2s0New, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard}, peripherals::Peripherals, prelude::*, timer::TimerGroup, diff --git a/esp32s3-hal/examples/mcpwm.rs b/esp32s3-hal/examples/mcpwm.rs index 97151dcb243..56a20832397 100644 --- a/esp32s3-hal/examples/mcpwm.rs +++ b/esp32s3-hal/examples/mcpwm.rs @@ -1,4 +1,5 @@ -//! Uses timer0 and operator0 of the MCPWM0 peripheral to output a 50% duty signal at 20 kHz. +//! Uses timer0 and operator0 of the MCPWM0 peripheral to output a 50% duty +//! signal at 20 kHz. //! //! The signal will be output to the pin assigned to `pin`. (GPIO4) @@ -8,11 +9,7 @@ use esp32s3_hal::{ clock::ClockControl, gpio::IO, - mcpwm::{ - {MCPWM, PeripheralClockConfig}, - operator::PwmPinConfig, - timer::PwmWorkingMode, - }, + mcpwm::{operator::PwmPinConfig, timer::PwmWorkingMode, PeripheralClockConfig, MCPWM}, peripherals::Peripherals, prelude::*, timer::TimerGroup, @@ -53,8 +50,11 @@ fn main() -> ! { .operator0 .with_pin_a(pin, PwmPinConfig::UP_ACTIVE_HIGH); - // start timer with timestamp values in the range of 0..=99 and a frequency of 20 kHz - let timer_clock_cfg = clock_cfg.timer_clock_with_frequency(99, PwmWorkingMode::Increase, 20u32.kHz()).unwrap(); + // start timer with timestamp values in the range of 0..=99 and a frequency of + // 20 kHz + let timer_clock_cfg = clock_cfg + .timer_clock_with_frequency(99, PwmWorkingMode::Increase, 20u32.kHz()) + .unwrap(); mcpwm.timer0.start(timer_clock_cfg); // pin will be high 50% of the time diff --git a/esp32s3-hal/examples/rtc_watchdog.rs b/esp32s3-hal/examples/rtc_watchdog.rs index 16bcfbd3695..c588f8981e6 100644 --- a/esp32s3-hal/examples/rtc_watchdog.rs +++ b/esp32s3-hal/examples/rtc_watchdog.rs @@ -38,7 +38,11 @@ fn main() -> ! { critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt)); - interrupt::enable(peripherals::Interrupt::RTC_CORE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::RTC_CORE, + interrupt::Priority::Priority1, + ) + .unwrap(); loop {} } diff --git a/esp32s3-hal/examples/serial_interrupts.rs b/esp32s3-hal/examples/serial_interrupts.rs index 98f0c466877..3fdce12703d 100644 --- a/esp32s3-hal/examples/serial_interrupts.rs +++ b/esp32s3-hal/examples/serial_interrupts.rs @@ -13,8 +13,8 @@ use esp32s3_hal::{ interrupt, peripherals::{self, Peripherals, UART0}, prelude::*, - uart::config::AtCmdConfig, timer::TimerGroup, + uart::config::AtCmdConfig, Rtc, Uart, }; @@ -51,7 +51,11 @@ fn main() -> ! { serial0.listen_at_cmd(); serial0.listen_rx_fifo_full(); - interrupt::enable(peripherals::Interrupt::UART0, interrupt::Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::UART0, + interrupt::Priority::Priority2, + ) + .unwrap(); timer0.start(1u64.secs()); diff --git a/esp32s3-hal/examples/sha.rs b/esp32s3-hal/examples/sha.rs index 0e213397b9f..bd81f660e79 100644 --- a/esp32s3-hal/examples/sha.rs +++ b/esp32s3-hal/examples/sha.rs @@ -1,5 +1,5 @@ -//! Demonstrates the use of the SHA peripheral and compares the speed of hardware-accelerated and pure software hashing. -//! +//! Demonstrates the use of the SHA peripheral and compares the speed of +//! hardware-accelerated and pure software hashing. #![no_std] #![no_main] @@ -8,15 +8,15 @@ use esp32s3_hal::{ clock::ClockControl, peripherals::Peripherals, prelude::*, + sha::{Sha, ShaMode}, timer::TimerGroup, Rtc, - sha::{Sha, ShaMode}, }; -use nb::block; use esp_backtrace as _; use esp_println::println; +use nb::block; +use sha2::{Digest, Sha512}; use xtensa_lx_rt::entry; -use sha2::{Sha512, Digest}; #[entry] fn main() -> ! { @@ -32,30 +32,34 @@ fn main() -> ! { wdt.disable(); rtc.rwdt.disable(); - let source_data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".as_bytes(); let mut remaining = source_data.clone(); let mut hasher = Sha::new(peripherals.SHA, ShaMode::SHA512); - // Short hashes can be created by decreasing the output buffer to the desired length + // Short hashes can be created by decreasing the output buffer to the desired + // length let mut output = [0u8; 64]; let pre_calc = xtensa_lx::timer::get_cycle_count(); - // The hardware implementation takes a subslice of the input, and returns the unprocessed parts - // The unprocessed parts can be input in the next iteration, you can always add more data until - // finish() is called. After finish() is called update()'s will contribute to a new hash which + // The hardware implementation takes a subslice of the input, and returns the + // unprocessed parts The unprocessed parts can be input in the next + // iteration, you can always add more data until finish() is called. After + // finish() is called update()'s will contribute to a new hash which // can be extracted again with finish(). - + while remaining.len() > 0 { - // Can add println to view progress, however println takes a few orders of magnitude longer than - // the Sha function itself so not useful for comparing processing time - // println!("Remaining len: {}", remaining.len()); + // Can add println to view progress, however println takes a few orders of + // magnitude longer than the Sha function itself so not useful for + // comparing processing time println!("Remaining len: {}", + // remaining.len()); - // All the HW Sha functions are infallible so unwrap is fine to use if you use block! + // All the HW Sha functions are infallible so unwrap is fine to use if you use + // block! remaining = block!(hasher.update(remaining)).unwrap(); } - // Finish can be called as many times as desired to get mutliple copies of the output. + // Finish can be called as many times as desired to get mutliple copies of the + // output. block!(hasher.finish(output.as_mut_slice())).unwrap(); let post_calc = xtensa_lx::timer::get_cycle_count(); let hw_time = post_calc - pre_calc; @@ -63,7 +67,6 @@ fn main() -> ! { println!("SHA512 Hash output {:02x?}", output); let _usha = hasher.free(); - let pre_calc = xtensa_lx::timer::get_cycle_count(); let mut hasher = Sha512::new(); hasher.update(source_data); @@ -73,7 +76,7 @@ fn main() -> ! { println!("Took {} cycles", soft_time); println!("SHA512 Hash output {:02x?}", soft_result); - println!("HW SHA is {}x faster", soft_time/hw_time); + println!("HW SHA is {}x faster", soft_time / hw_time); loop {} } diff --git a/esp32s3-hal/examples/spi_loopback_dma.rs b/esp32s3-hal/examples/spi_loopback_dma.rs index 3a14b446e99..92b3ebaebfd 100644 --- a/esp32s3-hal/examples/spi_loopback_dma.rs +++ b/esp32s3-hal/examples/spi_loopback_dma.rs @@ -18,7 +18,7 @@ use esp32s3_hal::{ clock::ClockControl, - dma::{DmaPriority}, + dma::DmaPriority, gdma::Gdma, gpio::IO, peripherals::Peripherals, diff --git a/esp32s3-hal/examples/systimer.rs b/esp32s3-hal/examples/systimer.rs index 60152414804..c6c63175ac4 100644 --- a/esp32s3-hal/examples/systimer.rs +++ b/esp32s3-hal/examples/systimer.rs @@ -62,9 +62,21 @@ fn main() -> ! { ALARM2.borrow_ref_mut(cs).replace(alarm2); }); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET0, Priority::Priority1).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET1, Priority::Priority2).unwrap(); - interrupt::enable(peripherals::Interrupt::SYSTIMER_TARGET2, Priority::Priority3).unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET0, + Priority::Priority1, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET1, + Priority::Priority2, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::SYSTIMER_TARGET2, + Priority::Priority3, + ) + .unwrap(); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/esp32s3-hal/examples/usb_serial_jtag.rs b/esp32s3-hal/examples/usb_serial_jtag.rs index 9675f839e30..6cc0f48ede1 100644 --- a/esp32s3-hal/examples/usb_serial_jtag.rs +++ b/esp32s3-hal/examples/usb_serial_jtag.rs @@ -13,8 +13,7 @@ use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, interrupt, - peripherals::{self, USB_DEVICE}, - peripherals::Peripherals, + peripherals::{self, Peripherals, USB_DEVICE}, prelude::*, timer::TimerGroup, Rtc, @@ -50,7 +49,11 @@ fn main() -> ! { critical_section::with(|cs| USB_SERIAL.borrow_ref_mut(cs).replace(usb_serial)); - interrupt::enable(peripherals::Interrupt::USB_DEVICE, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::USB_DEVICE, + interrupt::Priority::Priority1, + ) + .unwrap(); loop { critical_section::with(|cs| { diff --git a/esp32s3-hal/examples/watchdog.rs b/esp32s3-hal/examples/watchdog.rs index 3da0c50713f..7c6fc4fcfea 100644 --- a/esp32s3-hal/examples/watchdog.rs +++ b/esp32s3-hal/examples/watchdog.rs @@ -5,7 +5,13 @@ #![no_std] #![no_main] -use esp32s3_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc}; +use esp32s3_hal::{ + clock::ClockControl, + peripherals::Peripherals, + prelude::*, + timer::TimerGroup, + Rtc, +}; use esp_backtrace as _; use esp_println::println; use nb::block; diff --git a/esp32s3-hal/src/lib.rs b/esp32s3-hal/src/lib.rs index e3b5e472372..1025c82d5b4 100644 --- a/esp32s3-hal/src/lib.rs +++ b/esp32s3-hal/src/lib.rs @@ -3,6 +3,8 @@ #![cfg_attr(feature = "direct-boot", feature(asm_experimental_arch))] pub use embedded_hal as ehal; +#[cfg(feature = "embassy")] +pub use esp_hal_common::embassy; #[doc(inline)] pub use esp_hal_common::{ analog::adc::implementation as adc, @@ -18,15 +20,16 @@ pub use esp_hal_common::{ macros, mcpwm, otg_fs, + peripherals, prelude, pulse_control, - uart, + sha, spi, system, systimer, timer, + uart, utils, - peripherals, Cpu, Delay, PulseControl, @@ -35,12 +38,8 @@ pub use esp_hal_common::{ Rwdt, Uart, UsbSerialJtag, - sha }; -#[cfg(feature = "embassy")] -pub use esp_hal_common::embassy; - pub use self::gpio::IO; /// Common module for analog functions