Skip to content

Commit

Permalink
Clean up example imports (#1027)
Browse files Browse the repository at this point in the history
* Don't import directly from `esp-hal-common` in examples

* Do no alias the HAL packages in examples
  • Loading branch information
jessebraham authored Dec 14, 2023
1 parent 58baecc commit 82c579e
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 116 deletions.
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use esp32_hal::{
clock::ClockControl,
cpu_control::{CpuControl, Stack},
embassy::{self, executor::Executor},
get_core,
gpio::{GpioPin, Output, PushPull, IO},
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
};
use esp_backtrace as _;
use esp_hal_common::get_core;
use esp_println::println;
use static_cell::make_static;

Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_multicore_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ use esp32_hal::{
self,
executor::{FromCpu1, FromCpu2, InterruptExecutor},
},
get_core,
gpio::{GpioPin, Output, PushPull, IO},
interrupt::Priority,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
};
use esp_backtrace as _;
use esp_hal_common::get_core;
use esp_println::println;
use static_cell::make_static;

Expand Down
9 changes: 4 additions & 5 deletions esp32-hal/examples/embassy_multiprio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

use embassy_executor::Spawner;
use embassy_time::{Duration, Instant, Ticker, Timer};
use esp32_hal as hal;
use esp_backtrace as _;
use esp_println::println;
use hal::{
use esp32_hal::{
clock::ClockControl,
embassy::{
self,
Expand All @@ -30,6 +27,8 @@ use hal::{
peripherals::Peripherals,
prelude::*,
};
use esp_backtrace as _;
use esp_println::println;

static INT_EXECUTOR_0: InterruptExecutor<FromCpu1> = InterruptExecutor::new();

Expand Down Expand Up @@ -82,7 +81,7 @@ async fn main(low_prio_spawner: Spawner) {

#[cfg(feature = "embassy-time-timg0")]
{
let timer_group0 = hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
let timer_group0 = esp32_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);
}

Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_rmt_rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ use embassy_time::{Duration, Timer};
use esp32_hal::{
clock::ClockControl,
embassy::{self},
gpio::{Gpio15, Output, PushPull},
peripherals::Peripherals,
prelude::*,
rmt::{asynch::RxChannelAsync, PulseCode, RxChannelConfig, RxChannelCreator},
Rmt,
IO,
};
use esp_backtrace as _;
use esp_hal_common::gpio::{Gpio15, Output, PushPull};
use esp_println::{print, println};

const WIDTH: usize = 80;
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use esp32_hal::{
interrupt,
peripherals::{Interrupt, Peripherals, UART0},
prelude::*,
uart::{config::AtCmdConfig, UartRx, UartTx},
Uart,
};
use esp_backtrace as _;
use esp_hal_common::uart::{config::AtCmdConfig, UartRx, UartTx};
use static_cell::make_static;

// rx_fifo_full_threshold
Expand Down
10 changes: 5 additions & 5 deletions esp32-hal/examples/sleep_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

use core::time::Duration;

use esp32_hal as hal;
use esp_backtrace as _;
use esp_println::println;
use hal::{
use esp32_hal::{
clock::ClockControl,
entry,
peripherals::Peripherals,
prelude::*,
rtc_cntl::{get_reset_reason, get_wakeup_cause, sleep::TimerWakeupSource, SocResetReason},
Cpu,
Delay,
Rtc,
};
use esp_backtrace as _;
use esp_println::println;

#[entry]
fn main() -> ! {
Expand All @@ -27,7 +27,7 @@ fn main() -> ! {
let mut rtc = Rtc::new(peripherals.RTC_CNTL);

println!("up and runnning!");
let reason = get_reset_reason(hal::Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
println!("reset reason: {:?}", reason);
let wake_reason = get_wakeup_cause();
println!("wake reason: {:?}", wake_reason);
Expand Down
10 changes: 5 additions & 5 deletions esp32-hal/examples/sleep_timer_ext0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

use core::time::Duration;

use esp32_hal as hal;
use esp_backtrace as _;
use esp_println::println;
use hal::{
use esp32_hal::{
clock::ClockControl,
entry,
peripherals::Peripherals,
Expand All @@ -19,10 +16,13 @@ use hal::{
sleep::{Ext0WakeupSource, TimerWakeupSource, WakeupLevel},
SocResetReason,
},
Cpu,
Delay,
Rtc,
IO,
};
use esp_backtrace as _;
use esp_println::println;

#[entry]
fn main() -> ! {
Expand All @@ -36,7 +36,7 @@ fn main() -> ! {
let mut ext0_pin = io.pins.gpio27;

println!("up and runnning!");
let reason = get_reset_reason(hal::Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
println!("reset reason: {:?}", reason);
let wake_reason = get_wakeup_cause();
println!("wake reason: {:?}", wake_reason);
Expand Down
14 changes: 7 additions & 7 deletions esp32-hal/examples/sleep_timer_ext1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

use core::time::Duration;

use esp32_hal as hal;
use esp_backtrace as _;
use esp_println::println;
use hal::{
use esp32_hal::{
clock::ClockControl,
entry,
gpio::{RTCPin, IO},
peripherals::Peripherals,
prelude::*,
rtc_cntl::{
Expand All @@ -19,10 +17,12 @@ use hal::{
sleep::{Ext1WakeupSource, TimerWakeupSource, WakeupLevel},
SocResetReason,
},
Cpu,
Delay,
Rtc,
IO,
};
use esp_backtrace as _;
use esp_println::println;

#[entry]
fn main() -> ! {
Expand All @@ -37,15 +37,15 @@ fn main() -> ! {
let mut pin32 = io.pins.gpio32;

println!("up and runnning!");
let reason = get_reset_reason(hal::Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
println!("reset reason: {:?}", reason);
let wake_reason = get_wakeup_cause();
println!("wake reason: {:?}", wake_reason);

let mut delay = Delay::new(&clocks);

let timer = TimerWakeupSource::new(Duration::from_secs(30));
let mut wakeup_pins: [&mut dyn hal::gpio::RTCPin; 2] = [&mut pin27, &mut pin32];
let mut wakeup_pins: [&mut dyn RTCPin; 2] = [&mut pin27, &mut pin32];
let ext1 = Ext1WakeupSource::new(&mut wakeup_pins, WakeupLevel::High);
println!("sleeping!");
delay.delay_ms(100u32);
Expand Down
11 changes: 5 additions & 6 deletions esp32c2-hal/examples/embassy_multiprio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

use embassy_executor::Spawner;
use embassy_time::{Duration, Instant, Ticker, Timer};
use esp32c2_hal as hal;
use esp_backtrace as _;
use esp_println::println;
use hal::{
use esp32c2_hal::{
clock::ClockControl,
embassy::{
self,
Expand All @@ -30,6 +27,8 @@ use hal::{
peripherals::Peripherals,
prelude::*,
};
use esp_backtrace as _;
use esp_println::println;

static INT_EXECUTOR_0: InterruptExecutor<FromCpu1> = InterruptExecutor::new();

Expand Down Expand Up @@ -83,12 +82,12 @@ async fn main(low_prio_spawner: Spawner) {
#[cfg(feature = "embassy-time-systick")]
embassy::init(
&clocks,
hal::systimer::SystemTimer::new(peripherals.SYSTIMER),
esp32c2_hal::systimer::SystemTimer::new(peripherals.SYSTIMER),
);

#[cfg(feature = "embassy-time-timg0")]
{
let timer_group0 = hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
let timer_group0 = esp32c2_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);
}

Expand Down
2 changes: 1 addition & 1 deletion esp32c2-hal/examples/embassy_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use esp32c2_hal::{
interrupt,
peripherals::{Interrupt, Peripherals, UART0},
prelude::*,
uart::{config::AtCmdConfig, UartRx, UartTx},
Uart,
};
use esp_backtrace as _;
use esp_hal_common::uart::{config::AtCmdConfig, UartRx, UartTx};
use static_cell::make_static;

// rx_fifo_full_threshold
Expand Down
11 changes: 5 additions & 6 deletions esp32c3-hal/examples/embassy_multiprio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

use embassy_executor::Spawner;
use embassy_time::{Duration, Instant, Ticker, Timer};
use esp32c3_hal as hal;
use esp_backtrace as _;
use esp_println::println;
use hal::{
use esp32c3_hal::{
clock::ClockControl,
embassy::{
self,
Expand All @@ -30,6 +27,8 @@ use hal::{
peripherals::Peripherals,
prelude::*,
};
use esp_backtrace as _;
use esp_println::println;

static INT_EXECUTOR_0: InterruptExecutor<FromCpu1> = InterruptExecutor::new();

Expand Down Expand Up @@ -83,12 +82,12 @@ async fn main(low_prio_spawner: Spawner) {
#[cfg(feature = "embassy-time-systick")]
embassy::init(
&clocks,
hal::systimer::SystemTimer::new(peripherals.SYSTIMER),
esp32c3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER),
);

#[cfg(feature = "embassy-time-timg0")]
{
let timer_group0 = hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
let timer_group0 = esp32c3_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);
}

Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/embassy_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use esp32c3_hal::{
interrupt,
peripherals::{Interrupt, Peripherals, UART0},
prelude::*,
uart::{config::AtCmdConfig, UartRx, UartTx},
Uart,
};
use esp_backtrace as _;
use esp_hal_common::uart::{config::AtCmdConfig, UartRx, UartTx};
use static_cell::make_static;

// rx_fifo_full_threshold
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/rmt_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use esp32c3_hal::{
peripherals::Peripherals,
prelude::*,
rmt::{PulseCode, TxChannel, TxChannelConfig, TxChannelCreator},
Delay,
Rmt,
};
use esp_backtrace as _;
use esp_hal_common::Delay;

#[entry]
fn main() -> ! {
Expand Down
10 changes: 5 additions & 5 deletions esp32c3-hal/examples/sleep_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

use core::time::Duration;

use esp32c3_hal as hal;
use esp_backtrace as _;
use esp_println::println;
use hal::{
use esp32c3_hal::{
clock::ClockControl,
entry,
peripherals::Peripherals,
prelude::*,
rtc_cntl::{get_reset_reason, get_wakeup_cause, sleep::TimerWakeupSource, SocResetReason},
Cpu,
Delay,
Rtc,
};
use esp_backtrace as _;
use esp_println::println;

#[entry]
fn main() -> ! {
Expand All @@ -27,7 +27,7 @@ fn main() -> ! {
let mut rtc = Rtc::new(peripherals.RTC_CNTL);

println!("up and runnning!");
let reason = get_reset_reason(hal::Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
println!("reset reason: {:?}", reason);
let wake_reason = get_wakeup_cause();
println!("wake reason: {:?}", wake_reason);
Expand Down
14 changes: 7 additions & 7 deletions esp32c3-hal/examples/sleep_timer_rtcio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

use core::time::Duration;

use esp32c3_hal as hal;
use esp_backtrace as _;
use esp_hal_common::{gpio::RTCPinWithResistors, rtc_cntl::sleep::RtcioWakeupSource};
use esp_println::println;
use hal::{
use esp32c3_hal::{
clock::ClockControl,
entry,
gpio::RTCPinWithResistors,
peripherals::Peripherals,
prelude::*,
rtc_cntl::{
get_reset_reason,
get_wakeup_cause,
sleep::{TimerWakeupSource, WakeupLevel},
sleep::{RtcioWakeupSource, TimerWakeupSource, WakeupLevel},
SocResetReason,
},
Cpu,
Delay,
Rtc,
IO,
};
use esp_backtrace as _;
use esp_println::println;

#[entry]
fn main() -> ! {
Expand All @@ -39,7 +39,7 @@ fn main() -> ! {
let mut pin3 = io.pins.gpio3;

println!("up and runnning!");
let reason = get_reset_reason(hal::Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn);
println!("reset reason: {:?}", reason);
let wake_reason = get_wakeup_cause();
println!("wake reason: {:?}", wake_reason);
Expand Down
Loading

0 comments on commit 82c579e

Please sign in to comment.