mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 14:44:42 +00:00

* No longer publicly expose the `PeripheralClockControl` struct * Update examples as needed to get things building again * Update CHANGELOG.md * Address review feedback, fix a warning * Use a critical section for all devices other than the ESP32-C6/H2, as they modify multiple registers * Rebase and update `etm` driver to fix build errors
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
//! embassy hello world
|
|
//!
|
|
//! This is an example of running the embassy executor with multiple tasks
|
|
//! concurrently.
|
|
|
|
#![no_std]
|
|
#![no_main]
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
use embassy_time::{Duration, Timer};
|
|
use esp32s2_hal::{
|
|
clock::ClockControl,
|
|
embassy::{self, executor::Executor},
|
|
peripherals::Peripherals,
|
|
prelude::*,
|
|
};
|
|
use esp_backtrace as _;
|
|
use static_cell::make_static;
|
|
use xtensa_atomic_emulation_trap as _;
|
|
|
|
#[embassy_executor::task]
|
|
async fn run1() {
|
|
loop {
|
|
esp_println::println!("Hello world from embassy using esp-hal-async!");
|
|
Timer::after(Duration::from_millis(1_000)).await;
|
|
}
|
|
}
|
|
|
|
#[embassy_executor::task]
|
|
async fn run2() {
|
|
loop {
|
|
esp_println::println!("Bing!");
|
|
Timer::after(Duration::from_millis(5_000)).await;
|
|
}
|
|
}
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
esp_println::println!("Init!");
|
|
let peripherals = Peripherals::take();
|
|
let system = peripherals.SYSTEM.split();
|
|
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
|
|
|
|
#[cfg(feature = "embassy-time-timg0")]
|
|
{
|
|
let timer_group0 = esp32s2_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
|
|
embassy::init(&clocks, timer_group0.timer0);
|
|
}
|
|
|
|
let executor = make_static!(Executor::new());
|
|
executor.run(|spawner| {
|
|
spawner.spawn(run1()).ok();
|
|
spawner.spawn(run2()).ok();
|
|
});
|
|
}
|