//! Template project for Rust on ESP32 (`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::
{
    delay::Delay,
    gpio::{Io, Level, Output},
    prelude::*,
};




#[entry]
fn main() -> ! 
{
    // Take Peripherals
    let peripherals = esp_hal::init(esp_hal::Config::default());

    // Create Delay handle
    // A delay instance needs to be created, this is done with Delay::new()
    let delay = Delay::new();

    // Instantiate and Create Handle for IO
    let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

    // Create Output Pin
    let mut led_pin = Output::new(io.pins.gpio1, Level::Low);


    loop 
    {
        // Turn on LED
        led_pin.set_high();

        // Wait for 1 second
        delay.delay_millis(1000_u32);

        // Turn off LED
        led_pin.set_low();

        // Wait for 1 second
        delay.delay_millis(1000_u32);
    }
}