2021-12-17 12:50:48 +01:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt_rtt as _; // global logger
|
|
|
|
use panic_probe as _;
|
2021-12-17 12:50:48 +01:00
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::*;
|
2021-12-17 12:50:48 +01:00
|
|
|
use embassy::executor::Spawner;
|
|
|
|
use embassy_stm32::dma::NoDma;
|
|
|
|
use embassy_stm32::usart::{Config, Uart};
|
|
|
|
use embassy_stm32::Peripherals;
|
2022-01-27 00:08:02 +01:00
|
|
|
use embassy_traits::adapter::BlockingAsync;
|
2022-01-26 22:39:06 +01:00
|
|
|
use embedded_hal_async::serial::{Read, Write};
|
2021-12-17 12:50:48 +01:00
|
|
|
|
|
|
|
#[embassy::main]
|
|
|
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
|
|
|
let config = Config::default();
|
|
|
|
let usart = Uart::new(p.UART4, p.PA1, p.PA0, NoDma, NoDma, config);
|
|
|
|
let mut usart = BlockingAsync::new(usart);
|
|
|
|
|
|
|
|
unwrap!(usart.write(b"Hello Embassy World!\r\n").await);
|
|
|
|
info!("wrote Hello, starting echo");
|
|
|
|
|
|
|
|
let mut buf = [0u8; 1];
|
|
|
|
loop {
|
|
|
|
unwrap!(usart.read(&mut buf).await);
|
|
|
|
unwrap!(usart.write(&buf).await);
|
|
|
|
}
|
|
|
|
}
|