diff --git a/examples/ch32v003/src/bin/embassy_blinky.rs b/examples/ch32v003/src/bin/embassy_blinky.rs index 91b708e..0943e13 100644 --- a/examples/ch32v003/src/bin/embassy_blinky.rs +++ b/examples/ch32v003/src/bin/embassy_blinky.rs @@ -4,12 +4,21 @@ use ch32_hal as hal; use embassy_executor::Spawner; -use embassy_time::{Instant, Timer}; -use embedded_hal::delay::DelayNs; -use hal::delay::Delay; -use hal::gpio::{Level, Output}; +use embassy_time::Timer; +use hal::gpio::{AnyPin, Level, Output, Pin}; use hal::println; -use qingke::riscv; + +#[embassy_executor::task(pool_size = 2)] +async fn blink(pin: AnyPin, interval_ms: u64) { + let mut led = Output::new(pin, Level::Low, Default::default()); + + loop { + led.set_high(); + Timer::after_millis(interval_ms).await; + led.set_low(); + Timer::after_millis(interval_ms).await; + } +} #[embassy_executor::main(entry = "qingke_rt::entry")] async fn main(spawner: Spawner) -> ! { @@ -19,12 +28,17 @@ async fn main(spawner: Spawner) -> ! { let p = hal::init(config); hal::embassy::init(); - let mut led = Output::new(p.PC4, Level::Low, Default::default()); + println!("CHIP signature => {}", hal::signature::chip_id().name()); + println!("Clocks {:?}", hal::rcc::clocks()); - loop { - led.toggle(); + // let mut led = Output::new(p.PC4, Level::Low, Default::default()); - Timer::after_millis(100).await; + spawner.spawn(blink(p.PC4.degrade(), 110)).unwrap(); + spawner.spawn(blink(p.PA2.degrade(), 270)).unwrap(); + + loop { + Timer::after_millis(1000).await; + println!("tick"); } }