//! Template project for Rust on ESP32-C3 (`no_std`) based on [`esp-hal`](https://github.com/esp-rs/esp-hal)
//!
//! Useful resources:
//! - [The Rust on ESP Book](https://docs.esp-rs.org/book/)
//! - [Embedded Rust (no_std) on Espressif](https://docs.esp-rs.org/no_std-training/)
//! - [Matrix channel](https://matrix.to/#/#esp-rs:matrix.org)
#![no_std]
#![no_main]
use esp_backtrace as _;
use esp_hal::{clock::CpuClock, delay::Delay, gpio::{Output,Level}, main, peripherals::Peripherals};
use log::info;
#[main]
fn main() -> ! {
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);
// Set GPIO0 as an output, and set its state high initially.
let mut led = Output::new(peripherals.GPIO0, Level::High);
let delay = Delay::new();
loop {
led.toggle();
delay.delay_millis(1000);
}
}
// ISR Definition
#[handler]
fn gpio() {
// Start a Critical Section
critical_section::with(|cs| {
// Obtain access to global pin peripheral and clear interrupt
G_PIN.borrow_ref_mut(cs).as_mut().unwrap().clear_interrupt();
});
}