#![allow(clippy::empty_loop)]
#![deny(unsafe_code)]
#![no_main]
#![no_std]
use panic_halt as _;
use cortex_m::{asm, singleton};
use cortex_m_rt::entry;
use stm32f1xx_hal::{
pac,
prelude::*,
serial::{Config, Serial},
};
#[entry]
fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let mut flash = p.FLASH.constrain();
let rcc = p.RCC.constrain();
let clocks = rcc.cfgr.freeze(&mut flash.acr);
let mut afio = p.AFIO.constrain();
let channels = p.DMA1.split();
let mut gpioa = p.GPIOA.split();
let tx = gpioa.pa9.into_alternate_push_pull(&mut gpioa.crh);
let rx = gpioa.pa10;
let serial = Serial::new(
p.USART1,
(tx, rx),
&mut afio.mapr,
Config::default(),
&clocks,
);
let rx = serial.rx.with_dma(channels.5);
let buf = singleton!(: [u8; 8] = [0; 8]).unwrap();
let t = rx.read(buf);
while !t.is_done() {
let _slice = t.peek();
asm::bkpt();
}
asm::bkpt();
loop {}
}