Skip to content
Snippets Groups Projects
Commit 3cf74dd0 authored by Per Lindgren's avatar Per Lindgren
Browse files

serial works (HCI wrong value)

parent f0036d77
No related branches found
No related tags found
No related merge requests found
......@@ -16,22 +16,23 @@ use f4::serial::Serial;
use f4::stm32f4x;
fn main() {
// let p = stm32f30x::Peripherals::take().unwrap();
let p = stm32f4x::Peripherals::take().unwrap();
// let mut flash = p.FLASH.constrain();
// let mut rcc = p.RCC.constrain();
// let mut gpioa = p.GPIOA.split(&mut rcc.ahb);
let mut flash = p.FLASH.constrain();
let mut rcc = p.RCC.constrain();
let mut gpioa = p.GPIOA.split(&mut rcc.ahb1);
// let clocks = rcc.cfgr.freeze(&mut flash.acr);
let clocks = rcc.cfgr.freeze(&mut flash.acr);
// let tx = gpioa.pa9.into_af7(&mut gpioa.moder, &mut gpioa.afrh);
// let rx = gpioa.pa10.into_af7(&mut gpioa.moder, &mut gpioa.afrh);
let tx = gpioa.pa2.into_af7(&mut gpioa.moder, &mut gpioa.afrl);
let rx = gpioa.pa3.into_af7(&mut gpioa.moder, &mut gpioa.afrl);
// let serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), clocks, &mut rcc.apb2);
// let (mut tx, mut rx) = serial.split();
//let serial = Serial::usart2(p.USART2, (tx, rx), 115_200.bps(), clocks, &mut rcc.apb1);
let serial = Serial::usart2(p.USART2, (tx, rx), 57_600.bps(), clocks, &mut rcc.apb1);
let (mut tx, mut rx) = serial.split();
// loop {
// let byte = block!(rx.read()).unwrap();
// block!(tx.write(byte)).ok();
// }
loop {
let byte = block!(rx.read()).unwrap();
block!(tx.write(byte)).ok();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment