Hi there, I'm new to Rust and trying to develop a simple embedded application for the STM32F3 board. I'm still trying to figure out how to read the Rust API documentation and I think this is mostly my issue. However, to be specific, I am trying to configure a USART peripheral for serial communication to a device. Here is the snippet of code that I am trying to compile:
let peripherals = stm32f3xx_hal::stm32::Peripherals::take().unwrap();
let mut rcc = peripherals.RCC.constrain();
let mut flash = peripherals.FLASH.constrain();
let clocks = rcc.cfgr.freeze(&mut flash.acr);
let mut gpioa = peripherals.GPIOA.split(&mut rcc.ahb);
let tx = gpioa.pa9;
let rx = gpioa.pa10;
let usart1 = stm32f3xx_hal::serial::Serial::usart1(
peripherals.USART1,
(tx, rx),
115_200.bps(),
clocks,
&mut rcc.apb2,
);
I am getting these compilation errors:
error[E0277] : the trait bound stm32f3xx_hal::gpio::Pin<Gpioa, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B1>, Input>: TxPin<USART1>
is not satisfied
error[E0277] : the trait bound stm32f3xx_hal::gpio::Pin<Gpioa, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B1>, typenum::bit::B0>, Input>: RxPin<USART1>
is not satisfied
error[E0308] : mismatched types
--> hanger-buddy/src/main.rs:120:9
120 | 115_200.bps(),
| ^^^^^^^^^^^^^ expected struct Baud
, found struct BitsPerSecond
= note : expected struct **Baud**
found struct **BitsPerSecond<{integer}>**
I'm trying to understand what stm32f3xx_hal::serial::Serial::usart1(..) method is requiring for the (Tx, Rx) and the baud rate as I think the other arguments I have set correctly.
I hate to just ask for the answer as I would rather be able to read the API document for the usart1 method and be able to figure it out, so maybe if anyone can explain what I am missing and then perhaps how that was arrived at by reading the API document. Thoughts?
Thank you!
Matt