You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

43 lines
872 B

#![no_main]
#![no_std]
extern crate cortex_m;
extern crate cortex_m_rt;
extern crate panic_halt;
extern crate stm32f0xx_hal as hal;
use hal::prelude::*;
use hal::stm32;
#[macro_use(block)]
extern crate nb;
use hal::serial::Serial;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
if let Some(p) = stm32::Peripherals::take() {
let gpioa = p.GPIOA.split();
let mut rcc = p.RCC.constrain();
let clocks = rcc.cfgr.sysclk(48.mhz()).freeze();
let tx = gpioa.pa9.into_alternate_af1();
let rx = gpioa.pa10.into_alternate_af1();
let serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), clocks);
let (mut tx, mut rx) = serial.split();
loop {
let received = block!(rx.read()).unwrap();
block!(tx.write(received)).ok();
}
}
loop {
continue;
}
}