mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-01 06:11:03 +00:00
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use esp32c3_hal::{gpio::IO, pac::Peripherals, prelude::*, Delay, RtcCntl, Timer};
|
|
use panic_halt as _;
|
|
use riscv_rt::entry;
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
let peripherals = Peripherals::take().unwrap();
|
|
|
|
// Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT,
|
|
// the RTC WDT, and the TIMG WDTs.
|
|
let rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
|
|
let mut timer0 = Timer::new(peripherals.TIMG0);
|
|
let mut timer1 = Timer::new(peripherals.TIMG1);
|
|
|
|
rtc_cntl.set_super_wdt_enable(false);
|
|
rtc_cntl.set_wdt_enable(false);
|
|
timer0.disable();
|
|
timer1.disable();
|
|
|
|
// Set GPIO5 as an output, and set its state high initially.
|
|
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
|
|
let mut led = io.pins.gpio5.into_push_pull_output();
|
|
|
|
led.set_high().unwrap();
|
|
|
|
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
|
// loop.
|
|
let mut delay = Delay::new(peripherals.SYSTIMER);
|
|
|
|
loop {
|
|
led.toggle().unwrap();
|
|
delay.delay_ms(500u32);
|
|
}
|
|
}
|