Skip to content

Commit

Permalink
fix build failure with esp-hal 0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
suapapa committed Dec 15, 2024
1 parent 81ae408 commit 85ff240
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
8 changes: 4 additions & 4 deletions ci-esp.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ fi
. $HOME/export-esp.sh

# compile
cd ../test-esp32c3; cargo build --release
cd ../test-esp32s3; cargo build --release
cd $test_dir/test-esp32c3; cargo build --release
cd $test_dir/test-esp32s3; cargo build --release

# clean up
cd ../..
# rm -r ci
cd $cwd
# rm -r $test_dir/ci
2 changes: 1 addition & 1 deletion src/templates/config.toml.esp.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runner = "espflash flash --monitor"


[env]
ESP_LOGLEVEL="INFO"
ESP_LOG="INFO"

[build]
{rustflags}
Expand Down
36 changes: 12 additions & 24 deletions src/templates/main.rs.esp.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,29 @@ use embassy_executor::Spawner;
use embassy_time::Timer;
use esp_backtrace as _;
use esp_hal::{
clock::ClockControl,
gpio::{Io, Level, Output},
peripherals::Peripherals,
prelude::*,
system::SystemControl,
timer::{timg::TimerGroup, ErasedTimer, OneShotTimer},
self,
clock::CpuClock,
gpio::{Level, Output},
timer::timg::TimerGroup,
};
use esp_hal_embassy::main;
use esp_println::println;
use static_cell::StaticCell;

#[main]
async fn main(_spawner: Spawner) {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);

let clocks = ClockControl::max(system.clock_control).freeze();

esp_println::logger::init_logger_from_env();

let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks, None);

let timer = {
static TIMER: StaticCell<[OneShotTimer<ErasedTimer>; 1]> = StaticCell::new();

TIMER.init([OneShotTimer::new(timg0.timer0.into())])
};

esp_hal_embassy::init(&clocks, timer);
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
let mut config = esp_hal::Config::default();
config.cpu_clock = CpuClock::max();
let peripherals = esp_hal::init(config);

let mut led = Output::new(io.pins.gpio17, Level::Low);
let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_hal_embassy::init(timg0.timer0);

let mut led = Output::new(peripherals.GPIO17, Level::High);
loop {
println!("Hello, World!");
led.toggle();
Timer::after_millis(1_000).await;
}
}
}

0 comments on commit 85ff240

Please sign in to comment.