diff --git a/examples/serial-echo.rs b/examples/serial-echo.rs index 1ee5c2f7f09007c4783ca2ee4231caa2b37e08d4..451c6acb7bc0df59a74eeb75a54cda94a19ac998 100644 --- a/examples/serial-echo.rs +++ b/examples/serial-echo.rs @@ -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(); + } }