* Runtime ISR binding for TIMG/SYSTIMER * CHANGELOG.md * Implement `set_interrupt_handler` only for blocking * Adapt HIL test
49 lines
1.2 KiB
Rust
49 lines
1.2 KiB
Rust
//! embassy hello world
|
|
//!
|
|
//! This is an example of running the embassy executor with multiple tasks
|
|
//! concurrently.
|
|
|
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
|
//% FEATURES: embassy embassy-time-timg0 embassy-executor-thread embassy-generic-timers
|
|
|
|
#![no_std]
|
|
#![no_main]
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
use embassy_executor::Spawner;
|
|
use embassy_time::{Duration, Timer};
|
|
use esp_backtrace as _;
|
|
use esp_hal::{
|
|
clock::ClockControl,
|
|
embassy::{self},
|
|
peripherals::Peripherals,
|
|
prelude::*,
|
|
timer::TimerGroup,
|
|
};
|
|
|
|
#[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();
|
|
|
|
let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
|
|
embassy::init(&clocks, timg0);
|
|
|
|
spawner.spawn(run()).ok();
|
|
|
|
loop {
|
|
esp_println::println!("Bing!");
|
|
Timer::after(Duration::from_millis(5_000)).await;
|
|
}
|
|
}
|