diff --git a/.gitignore b/.gitignore index 73fab07..629df60 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,9 @@ target/ # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + +build/ + +sdkconfig + +sdkconfig.old diff --git a/src/main.rs b/src/main.rs index 3f352e4..fc66123 100644 --- a/src/main.rs +++ b/src/main.rs @@ -137,7 +137,7 @@ fn main() -> ! { println!("Release BM1397 RST with gpio1 HIGH"); // will be use to init the bm1397 chain - let _bm_serial = Uart::new_with_config( + let bm_serial = Uart::new_with_config( peripherals.UART1, None, Some(TxRxPins::new_tx_rx( @@ -148,7 +148,6 @@ fn main() -> ! { &mut system.peripheral_clock_control, ); interrupt::enable(Interrupt::UART1, Priority::Priority1).unwrap(); - /* embedded-hal-async is on its way : https://github.com/esp-rs/esp-hal/pull/510 */ // will be used to control emc2101/ina260/ds44232u let i2c = I2C::new( @@ -178,6 +177,7 @@ fn main() -> ! { spawner.spawn(net_task(&stack)).ok(); spawner.spawn(task(&stack)).ok(); spawner.spawn(emc2101_task(i2c)).ok(); + spawner.spawn(bm1397_task(bm_serial)).ok(); }); } @@ -330,3 +330,16 @@ async fn emc2101_task(i2c: I2C<'static, I2C0>) { Timer::after(Duration::from_millis(1000)).await; } } + +#[embassy_executor::task] +async fn bm1397_task(mut uart: Uart<'static, UART1>) { + loop { + embedded_hal_async::serial::Write::write(&mut uart, b"Hello async write!!!\r\n") + .await + .unwrap(); + embedded_hal_async::serial::Write::flush(&mut uart) + .await + .unwrap(); + Timer::after(Duration::from_millis(1_000)).await; + } +}