#![deny(unsafe_code)]
#![no_main]
#![no_std]
use panic_halt as _;
use cortex_m::asm;
use stm32f1xx_hal::{
prelude::*,
pac,
serial::Serial,
};
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let mut flash = p.FLASH.constrain();
let mut rcc = p.RCC.constrain();
let clocks = rcc.cfgr.freeze(&mut flash.acr);
let mut afio = p.AFIO.constrain(&mut rcc.apb2);
let channels = p.DMA1.split(&mut rcc.ahb);
let mut gpioa = p.GPIOA.split(&mut rcc.apb2);
let tx = gpioa.pa9.into_alternate_push_pull(&mut gpioa.crh);
let rx = gpioa.pa10;
let serial = Serial::usart1(
p.USART1,
(tx, rx),
&mut afio.mapr,
9_600.bps(),
clocks,
&mut rcc.apb2,
);
let tx = serial.split().0.with_dma(channels.4);
let (_, tx) = tx.write(b"The quick brown fox").wait();
asm::bkpt();
let (_, tx) = tx.write(b" jumps").wait();
asm::bkpt();
tx.write(b" over the lazy dog.").wait();
asm::bkpt();
loop {}
}