Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prelude #2845

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions esp-hal-embassy/src/time_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use core::cell::Cell;
use embassy_time_driver::{AlarmHandle, Driver};
use esp_hal::{
interrupt::{InterruptHandler, Priority},
prelude::*,
sync::Locked,
time::now,
time::{now, ExtU64},
timer::{AnyTimer, OneShotTimer},
Blocking,
};
Expand Down
4 changes: 4 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `gpio::{Level, Pull, AlternateFunction, RtcFunction}` now implement `Hash` (#2842)
- `gpio::{GpioPin, AnyPin, Io, Output, OutputOpenDrain, Input, Flex}` now implement `Debug`, `defmt::Format` (#2842)

- The `ExtU64` and `RateExtU32` traits have been added to `esp_hal::time` (#2845)

### Changed

- Bump MSRV to 1.83 (#2615)
Expand Down Expand Up @@ -104,6 +106,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed `Camera::set_` functions (#2610)
- `DmaTxBuf::{compute_chunk_size, compute_descriptor_count, new_with_block_size}` (#2543)

- The `prelude` module has been removed (#2845)

## [0.22.0] - 2024-11-20

### Added
Expand Down
19 changes: 19 additions & 0 deletions esp-hal/MIGRATING-0.22.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,22 @@ To avoid abbreviations and contractions (as per the esp-hal guidelines), some er
- Error::InvalidZeroLength
+ Error::ZeroLengthInvalid
```

## The crate prelude has been removed

The reexports that were previously part of the prelude are available through other paths:

- `nb` is no longer re-exported. Please import the `nb` crate if you need it.
- `ExtU64` and `RateExtU32` have been moved to `esp_hal::time`
- `Clock` and `CpuClock`: `esp_hal::clock::{Clock, CpuClock}`
- The following traits need to be individually imported when needed:
- `esp_hal::analog::dac::Instance`
- `esp_hal::gpio::Pin`
- `esp_hal::ledc::channel::ChannelHW`
- `esp_hal::ledc::channel::ChannelIFace`
- `esp_hal::ledc::timer::TimerHW`
- `esp_hal::ledc::timer::TimerIFace`
- `esp_hal::timer::timg::TimerGroupInstance`
- `esp_hal::timer::Timer`
- `esp_hal::interrupt::InterruptConfigurable`
- The `entry` macro can be imported as `esp_hal::entry`, while other macros are found under `esp_hal::macros`
2 changes: 2 additions & 0 deletions esp-hal/src/clock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
//! ### Initialize With Different Clock Frequencies
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! use esp_hal::clock::CpuClock;
//!
//! // Initialize with the highest possible frequency for this chip
//! let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
//! let peripherals = esp_hal::init(config);
Expand Down
2 changes: 2 additions & 0 deletions esp-hal/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
//! ### Custom initialization
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! use esp_hal::clock::CpuClock;
//!
//! let config =
//! esp_hal::Config::default().with_cpu_clock(CpuClock::max()).
//! with_watchdog(esp_hal::config::WatchdogConfig::default().
Expand Down
1 change: 0 additions & 1 deletion esp-hal/src/i2s/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
//! # use esp_hal::dma_buffers;
//! # use esp_hal::delay::Delay;
//! # use esp_hal::i2s::parallel::{I2sParallel, TxEightBits};
//! # use esp_hal::prelude::*;
//!
//! const BUFFER_SIZE: usize = 256;
//!
Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@
//! # loop {}
//! # }
//! use esp_hal::{
//! clock::CpuClock,
//! delay::Delay,
//! entry,
//! gpio::{Io, Level, Output},
//! prelude::*,
//! };
//!
//! #[entry]
Expand Down Expand Up @@ -178,7 +179,6 @@ pub mod i2c;
#[cfg(any(dport, interrupt_core0, interrupt_core1))]
pub mod interrupt;
pub mod peripheral;
pub mod prelude;
#[cfg(any(hmac, sha))]
mod reg_access;
#[cfg(any(spi0, spi1, spi2, spi3))]
Expand Down
3 changes: 1 addition & 2 deletions esp-hal/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ macro_rules! before_snippet {
() => {
r#"
# #![no_std]
# use esp_hal::prelude::*;
# use procmacros::handler;
# use esp_hal::interrupt;
# use esp_hal::{interrupt::{self, InterruptConfigurable}, time::{RateExtU32 as _, ExtU64 as _}};
# macro_rules! println {
# ($($tt:tt)*) => { };
# }
Expand Down
1 change: 0 additions & 1 deletion esp-hal/src/mcpwm/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ impl<PWM: PwmPeripheral, const OP: u8, const IS_A: bool> embedded_hal::pwm::SetD
///
/// ```rust, no_run
#[doc = crate::before_snippet!()]
/// # use esp_hal::{mcpwm, prelude::*};
/// # use esp_hal::mcpwm::{McPwm, PeripheralClockConfig};
/// # use esp_hal::mcpwm::operator::{DeadTimeCfg, PwmPinConfig, PWMStream};
/// // active high complementary using PWMA input
Expand Down
40 changes: 0 additions & 40 deletions esp-hal/src/prelude.rs

This file was deleted.

2 changes: 0 additions & 2 deletions esp-hal/src/rmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
#![doc = crate::before_snippet!()]
//! # use esp_hal::rmt::{PulseCode, Rmt, TxChannel, TxChannelConfig, TxChannelCreator};
//! # use esp_hal::delay::Delay;
//! # use esp_hal::prelude::*;
//!
//! // Configure frequency based on chip type
#![cfg_attr(esp32h2, doc = "let freq = 32.MHz();")]
Expand Down Expand Up @@ -117,7 +116,6 @@
#![doc = crate::before_snippet!()]
//! # use esp_hal::rmt::{PulseCode, Rmt, RxChannel, RxChannelConfig, RxChannelCreator};
//! # use esp_hal::delay::Delay;
//! # use esp_hal::prelude::*;
//! # use esp_hal::gpio::{Level, Output};
//!
//! const WIDTH: usize = 80;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
//!
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use esp_hal::{prelude::*, rng::Rng};
//! # use esp_hal::rng::Rng;
//!
//! let mut rng = Rng::new(peripherals.RNG);
//!
Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/rtc_cntl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use core::time::Duration;
//! # use esp_hal::{delay::Delay, prelude::*, rtc_cntl::Rtc};
//! # use esp_hal::{delay::Delay, rtc_cntl::Rtc};
//!
//! let rtc = Rtc::new(peripherals.LPWR);
//! let delay = Delay::new();
Expand Down Expand Up @@ -90,7 +90,7 @@
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use core::time::Duration;
//! # use esp_hal::{delay::Delay, prelude::*, rtc_cntl::Rtc};
//! # use esp_hal::{delay::Delay, rtc_cntl::Rtc};
//!
//! let rtc = Rtc::new(peripherals.LPWR);
//! let delay = Delay::new();
Expand Down
5 changes: 0 additions & 5 deletions esp-hal/src/rtc_cntl/sleep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub enum WakeupLevel {
#[doc = crate::before_snippet!()]
/// # use core::time::Duration;
/// # use esp_hal::delay::Delay;
/// # use esp_hal::prelude::*;
/// # use esp_hal::rtc_cntl::{reset_reason, sleep::TimerWakeupSource, wakeup_cause, Rtc, SocResetReason};
/// # use esp_hal::Cpu;
///
Expand Down Expand Up @@ -104,7 +103,6 @@ pub enum Error {
#[doc = crate::before_snippet!()]
/// # use core::time::Duration;
/// # use esp_hal::delay::Delay;
/// # use esp_hal::prelude::*;
/// # use esp_hal::rtc_cntl::{reset_reason, sleep::{Ext0WakeupSource, TimerWakeupSource, WakeupLevel}, wakeup_cause, Rtc, SocResetReason};
/// # use esp_hal::Cpu;
/// # use esp_hal::gpio::{Input, Pull};
Expand Down Expand Up @@ -155,7 +153,6 @@ impl<'a, P: RtcIoWakeupPinType> Ext0WakeupSource<'a, P> {
#[doc = crate::before_snippet!()]
/// # use core::time::Duration;
/// # use esp_hal::delay::Delay;
/// # use esp_hal::prelude::*;
/// # use esp_hal::rtc_cntl::{reset_reason, sleep::{Ext1WakeupSource, TimerWakeupSource, WakeupLevel}, wakeup_cause, Rtc, SocResetReason};
/// # use esp_hal::Cpu;
/// # use esp_hal::gpio::{Input, Pull, RtcPin};
Expand Down Expand Up @@ -210,7 +207,6 @@ impl<'a, 'b> Ext1WakeupSource<'a, 'b> {
#[doc = crate::before_snippet!()]
/// # use core::time::Duration;
/// # use esp_hal::delay::Delay;
/// # use esp_hal::prelude::*;
/// # use esp_hal::rtc_cntl::{reset_reason, sleep::{Ext1WakeupSource, TimerWakeupSource, WakeupLevel}, wakeup_cause, Rtc, SocResetReason};
/// # use esp_hal::Cpu;
/// # use esp_hal::gpio::{Input, Pull, RtcPinWithResistors};
Expand Down Expand Up @@ -268,7 +264,6 @@ impl<'a, 'b> Ext1WakeupSource<'a, 'b> {
/// # use core::time::Duration;
/// # use esp_hal::delay::Delay;
/// # use esp_hal::gpio::{self, Input, Pull};
/// # use esp_hal::prelude::*;
/// # use esp_hal::rtc_cntl::{reset_reason, sleep::{RtcioWakeupSource, TimerWakeupSource, WakeupLevel}, wakeup_cause, Rtc, SocResetReason};
/// # use esp_hal::Cpu;
/// # use esp_hal::peripheral::Peripheral;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/soc/esp32/psram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! # extern crate alloc;
//! # use alloc::{string::String, vec::Vec};
//! # use esp_alloc as _;
//! # use esp_hal::{psram, prelude::*};
//! # use esp_hal::psram;
//!
//! // Initialize PSRAM and add it as a heap memory region
//! fn init_psram_heap(start: *mut u8, size: usize) {
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/soc/esp32s2/psram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! # extern crate alloc;
//! # use alloc::{string::String, vec::Vec};
//! # use esp_alloc as _;
//! # use esp_hal::{psram, prelude::*};
//! # use esp_hal::psram;
//!
//! // Initialize PSRAM and add it as a heap memory region
//! fn init_psram_heap(start: *mut u8, size: usize) {
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/soc/esp32s3/psram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! # extern crate alloc;
//! # use alloc::{string::String, vec::Vec};
//! # use esp_alloc as _;
//! # use esp_hal::{psram, prelude::*};
//! # use esp_hal::psram;
//!
//! // Initialize PSRAM and add it as a heap memory region
//! fn init_psram_heap(start: *mut u8, size: usize) {
Expand Down
3 changes: 1 addition & 2 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ use crate::{
clock::Clocks,
dma::{DmaChannelFor, DmaEligible, DmaRxBuffer, DmaTxBuffer, Rx, Tx},
gpio::{interconnect::PeripheralOutput, InputSignal, NoPin, OutputSignal},
interrupt::InterruptHandler,
interrupt::{InterruptConfigurable, InterruptHandler},
peripheral::{Peripheral, PeripheralRef},
peripherals::spi2::RegisterBlock,
prelude::InterruptConfigurable,
private,
private::Sealed,
spi::AnySpi,
Expand Down
2 changes: 2 additions & 0 deletions esp-hal/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! The `time` module offers a way to get the system now.

pub use fugit::{ExtU64, RateExtU32};

/// Represents a duration of time.
///
/// The resolution is 1 microsecond, represented as a 64-bit unsigned integer.
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/timer/systimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl Alarm {

static mut HANDLERS: [Option<extern "C" fn()>; 3] = [None, None, None];

#[crate::prelude::ram]
#[crate::macros::ram]
unsafe extern "C" fn _handle_interrupt<const CH: u8>() {
if unsafe { &*SYSTIMER::PTR }
.int_raw()
Expand Down
8 changes: 5 additions & 3 deletions esp-hal/src/timer/timg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
//!
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use esp_hal::timer::timg::TimerGroup;
//! use esp_hal::timer::timg::TimerGroup;
//! use esp_hal::timer::Timer;
//!
//! let timg0 = TimerGroup::new(peripherals.TIMG0);
//! let timer0 = timg0.timer0;
Expand All @@ -49,8 +50,9 @@
//! ### Watchdog Timer
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use esp_hal::timer::timg::TimerGroup;
//! # use esp_hal::timer::timg::MwdtStage;
//! use esp_hal::timer::timg::TimerGroup;
//! use esp_hal::timer::timg::MwdtStage;
//! use esp_hal::timer::Timer;
//!
//! let timg0 = TimerGroup::new(peripherals.TIMG0);
//! let mut wdt = timg0.wdt;
Expand Down
8 changes: 6 additions & 2 deletions esp-hal/src/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ use core::marker::PhantomData;

use crate::{
gpio::TouchPin,
interrupt::InterruptConfigurable,
peripheral::{Peripheral, PeripheralRef},
peripherals::{RTC_CNTL, SENS, TOUCH},
prelude::*,
private::{Internal, Sealed},
rtc_cntl::Rtc,
Async,
Expand Down Expand Up @@ -528,7 +528,11 @@ mod asynch {
};

use super::*;
use crate::{asynch::AtomicWaker, macros::ram, prelude::handler, Async};
use crate::{
asynch::AtomicWaker,
macros::{handler, ram},
Async,
};

const NUM_TOUCH_PINS: usize = 10;

Expand Down
1 change: 0 additions & 1 deletion esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
#![doc = crate::before_snippet!()]
//! # use esp_hal::delay::Delay;
//! # use esp_hal::uart::{AtCmdConfig, Config, Uart, UartInterrupt};
//! # use esp_hal::prelude::*;
//! let delay = Delay::new();
//!
//! // Default pins for UART/Serial communication
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/usb_serial_jtag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
//! ### How to output text using USB Serial/JTAG.
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use esp_hal::{delay::Delay, prelude::*, usb_serial_jtag::UsbSerialJtag, Blocking};
//! # use esp_hal::{delay::Delay, usb_serial_jtag::UsbSerialJtag, Blocking};
//!
//! let delay = Delay::new();
//!
Expand Down
2 changes: 1 addition & 1 deletion esp-ieee802154/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use core::{cell::RefCell, ptr::addr_of};
use critical_section::Mutex;
use esp_hal::{
interrupt::Priority,
macros::handler,
peripherals::RADIO_CLK,
prelude::handler,
system::{RadioClockController, RadioPeripherals},
};
use esp_wifi_sys::include::{
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::phy_init_data::PHY_INIT_DATA_DEFAULT;
use crate::{
binary::include::*,
hal::{
prelude::ram,
macros::ram,
system::{RadioClockController, RadioPeripherals},
},
};
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32s2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::phy_init_data::PHY_INIT_DATA_DEFAULT;
use crate::{
binary::include::*,
hal::{
prelude::ram,
macros::ram,
system::{RadioClockController, RadioPeripherals},
},
};
Expand Down
Loading
Loading