start using bm1397 serial

This commit is contained in:
Georges Palauqui 2023-08-14 12:37:58 +02:00
parent 152f5b7ce7
commit c8f847a066
2 changed files with 21 additions and 2 deletions

6
.gitignore vendored
View File

@ -8,3 +8,9 @@ target/
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
build/
sdkconfig
sdkconfig.old

View File

@ -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;
}
}