// Chapter 10 - The Embassy Framework
// Question 6 - Using embassy, generate a PWM with any frequency and connect it to an external pin.
// Connect the PWM pin externally to another pin creating a loopback.
// Using the other pin and a timer to create an application that measures the frequency of
// the PWM generated by the first pin.
// Wiring
// A loopback is created between pins 6 and 7. You can use either as PWM output and the other as timer input.
#![no_std]
#![no_main]
use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use esp_backtrace as _;
use esp_hal::{
timer::timg::TimerGroup,
};
use esp_println::println;
#[esp_hal_embassy::main]
async fn main(_spawner: Spawner) {
let peripherals =
esp_hal::init(esp_hal::Config::default());
// Initalize embassy executor
let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_hal_embassy::init( timg0.timer0);
loop {
Timer::after(Duration::from_millis(1_000)).await;
println!("Hello, embassy!");
}
}