async hard interrupt working compiled and tested

This commit is contained in:
Priec
2025-10-15 19:46:03 +02:00
parent e6e22818e4
commit 02971bd9e1
3 changed files with 47 additions and 37 deletions

View File

@@ -7,7 +7,8 @@
)]
use embassy_executor::Spawner;
use embassy_sync::signal::Signal;
use embassy_time::{Duration, Timer};
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_time::Duration;
use esp_backtrace as _;
use esp_hal::{
clock::CpuClock,
@@ -27,7 +28,7 @@ use log::info;
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();
static SIGNAL: Signal<()> = Signal::new();
static SIGNAL: Signal<CriticalSectionRawMutex, ()> = Signal::new();
static TIMER0: Mutex<RefCell<Option<esp_hal::timer::timg::Timer<'static>>>> = Mutex::new(RefCell::new(None));
#[esp_hal_embassy::main]
@@ -38,6 +39,8 @@ async fn main(spawner: Spawner) {
let peripherals = esp_hal::init(config);
esp_alloc::heap_allocator!(size: 64 * 1024);
let timer_group0 = TimerGroup::new(peripherals.TIMG0);
esp_hal_embassy::init(timer_group0.timer0);
let timer_group1 = TimerGroup::new(peripherals.TIMG1);
let timer0 = timer_group1.timer0;
@@ -62,13 +65,12 @@ async fn main(spawner: Spawner) {
.unwrap();
// Initialize GPIO4 as output (starts LOW)
let mut gpio4 = Output::new(peripherals.GPIO4, Level::Low, OutputConfig::default());
let gpio4 = Output::new(peripherals.GPIO4, Level::Low, OutputConfig::default());
spawner.spawn(led_task(gpio4)).unwrap();
info!("Embassy initialized!");
loop {
embassy_time::Timer::after(Duration::from_secs(5)).await;
info!("x");
}