Skip to content

Commit

Permalink
Remove prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Dec 19, 2024
1 parent a3b3547 commit 2b427a4
Show file tree
Hide file tree
Showing 109 changed files with 151 additions and 170 deletions.
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
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
7 changes: 6 additions & 1 deletion examples/src/bin/debug_assist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ use core::cell::RefCell;

use critical_section::Mutex;
use esp_backtrace as _;
use esp_hal::{assist_debug::DebugAssist, prelude::*};
use esp_hal::{
assist_debug::DebugAssist,
entry,
interrupt::InterruptConfigurable,
macros::handler,
};
use esp_println::println;

static DA: Mutex<RefCell<Option<DebugAssist>>> = Mutex::new(RefCell::new(None));
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/dma_extmem2mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use aligned::{Aligned, A64};
use esp_alloc as _;
use esp_backtrace as _;
use esp_hal::{delay::Delay, dma::Mem2Mem, dma_descriptors_chunk_size, prelude::*};
use esp_hal::{delay::Delay, dma::Mem2Mem, dma_descriptors_chunk_size, entry, time::ExtU64};
use log::{error, info};
extern crate alloc;

Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/dma_mem2mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![no_main]

use esp_backtrace as _;
use esp_hal::{delay::Delay, dma::Mem2Mem, dma_buffers, prelude::*};
use esp_hal::{delay::Delay, dma::Mem2Mem, dma_buffers, entry, time::ExtU64};
use log::{error, info};

const DATA_SIZE: usize = 1024 * 10;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/embassy_multicore_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use embassy_time::{Duration, Ticker};
use esp_backtrace as _;
use esp_hal::{
cpu_control::{CpuControl, Stack},
entry,
gpio::{Level, Output},
interrupt::{software::SoftwareInterruptControl, Priority},
prelude::*,
timer::{timg::TimerGroup, AnyTimer},
Cpu,
};
Expand Down
Loading

0 comments on commit 2b427a4

Please sign in to comment.