From 5c80e052638ed83df33e6b782416cf2689d2bf4a Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 12 Mar 2019 16:44:42 +0100 Subject: [PATCH] Switch to USART2 so that serial communication actually works --- src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4e3ec28..6e3bd9f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,13 +13,13 @@ use cortex_m_semihosting::hprintln; use hal::gpio::{Edge, ExtiPin, Floating, Input}; use hal::prelude::*; use hal::serial::{self, config::Config as SerialConfig, Serial}; -use hal::stm32::{EXTI, USART1}; +use hal::stm32::{EXTI, USART2}; use heapless::consts::U8; use heapless::Vec; use rtfm::app; -type SerialTx = hal::serial::Tx; -type SerialRx = hal::serial::Rx; +type SerialTx = hal::serial::Tx; +type SerialRx = hal::serial::Rx; type UserButton = hal::gpio::gpioa::PA0>; #[app(device = hal::stm32)] @@ -52,12 +52,12 @@ const APP: () = { button.trigger_on_edge(&mut exti, Edge::RISING); // Set up the serial interface. - let tx = gpioa.pa9.into_alternate_af7(); - let rx = gpioa.pa10.into_alternate_af7(); - let config = SerialConfig::default(); + let tx = gpioa.pa2.into_alternate_af7(); + let rx = gpioa.pa3.into_alternate_af7(); + let config = SerialConfig::default().baudrate(115_200.bps()); let rcc = device.RCC.constrain(); let clocks = rcc.cfgr.freeze(); - let mut serial = Serial::usart1(device.USART1, (tx, rx), config, clocks).unwrap(); + let mut serial = Serial::usart2(device.USART2, (tx, rx), config, clocks).unwrap(); serial.listen(serial::Event::Rxne); let (serial_tx, serial_rx) = serial.split(); @@ -99,7 +99,7 @@ const APP: () = { } #[interrupt( - binds = USART1, + binds = USART2, priority = 2, resources = [buffer, led_cycle, serial_rx, serial_tx], spawn = [switch_leds]