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

* RISC-V: Make atomic emulation opt-in * Update embassy-executor, embassy-sync * Don't automatically enable portable-atomic * Update changelog * Fix warnings
49 lines
1.3 KiB
Rust
49 lines
1.3 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_executor::Spawner;
|
|
use embassy_time::{Duration, Timer};
|
|
use esp32c3_hal::{clock::ClockControl, embassy, peripherals::Peripherals, prelude::*};
|
|
use esp_backtrace as _;
|
|
|
|
#[embassy_executor::task]
|
|
async fn run() {
|
|
loop {
|
|
esp_println::println!("Hello world from embassy using esp-hal-async!");
|
|
Timer::after(Duration::from_millis(1_000)).await;
|
|
}
|
|
}
|
|
|
|
#[main]
|
|
async fn main(spawner: Spawner) -> ! {
|
|
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-systick")]
|
|
embassy::init(
|
|
&clocks,
|
|
esp32c3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER),
|
|
);
|
|
|
|
#[cfg(feature = "embassy-time-timg0")]
|
|
embassy::init(
|
|
&clocks,
|
|
esp32c3_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks).timer0,
|
|
);
|
|
|
|
spawner.spawn(run()).ok();
|
|
|
|
loop {
|
|
esp_println::println!("Bing!");
|
|
Timer::after(Duration::from_millis(5_000)).await;
|
|
}
|
|
}
|