26 lines
718 B
Rust
26 lines
718 B
Rust
#![no_std]
|
|
#![no_main]
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
use defmt::*;
|
|
use embassy_executor::Spawner;
|
|
use embassy_stm32::interrupt;
|
|
use embassy_stm32::usart::{Config, Uart};
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
#[embassy_executor::main]
|
|
async fn main(_spawner: Spawner) {
|
|
let p = embassy_stm32::init(Default::default());
|
|
let irq = interrupt::take!(USART1);
|
|
let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, irq, p.DMA1_CH2, p.DMA1_CH3, Config::default());
|
|
|
|
usart.write(b"Hello Embassy World!\r\n").await.unwrap();
|
|
info!("wrote Hello, starting echo");
|
|
|
|
let mut buf = [0; 1];
|
|
loop {
|
|
usart.read(&mut buf[..]).await.unwrap();
|
|
usart.write(&buf[..]).await.unwrap();
|
|
}
|
|
}
|