led is blicking
This commit is contained in:
@@ -8,9 +8,9 @@
|
|||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
|
use esp_hal::gpio::{Output, Level, OutputConfig};
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
use esp_hal::peripherals;
|
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
@@ -21,7 +21,6 @@ esp_bootloader_esp_idf::esp_app_desc!();
|
|||||||
|
|
||||||
#[esp_hal_embassy::main]
|
#[esp_hal_embassy::main]
|
||||||
async fn main(spawner: Spawner) {
|
async fn main(spawner: Spawner) {
|
||||||
// generator version: 0.5.0
|
|
||||||
esp_println::logger::init_logger_from_env();
|
esp_println::logger::init_logger_from_env();
|
||||||
|
|
||||||
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||||
@@ -32,8 +31,17 @@ async fn main(spawner: Spawner) {
|
|||||||
let timer0 = TimerGroup::new(peripherals.TIMG1);
|
let timer0 = TimerGroup::new(peripherals.TIMG1);
|
||||||
esp_hal_embassy::init(timer0.timer0);
|
esp_hal_embassy::init(timer0.timer0);
|
||||||
|
|
||||||
|
// Initialize GPIO4 as output (starts LOW)
|
||||||
|
let mut gpio4 = Output::new(peripherals.GPIO4, Level::Low, OutputConfig::default());
|
||||||
|
|
||||||
info!("Embassy initialized!");
|
info!("Embassy initialized!");
|
||||||
loop {
|
loop {
|
||||||
|
gpio4.set_high();
|
||||||
|
info!("GPIO4 ON");
|
||||||
|
Timer::after(Duration::from_secs(1)).await;
|
||||||
|
|
||||||
|
gpio4.set_low();
|
||||||
|
info!("GPIO4 OFF");
|
||||||
Timer::after(Duration::from_secs(1)).await;
|
Timer::after(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user