Background: I'm using the Nucleo-G071RB dev board. I'm new to rust, and working through some of the examples from the embedded HAL.
I was able to get this example up and running, but ran into some difficulty when trying to change the baudrate (links are to commit at head of master at the time of this writing): https://github.com/stm32-rs/stm32g0xx-hal/blob/116ac758cc50f4e1bfb9270d41403eac462cd791/examples/uart.rs
I found the default function referenced in the example: https://github.com/stm32-rs/stm32g0xx-hal/blob/116ac758cc50f4e1bfb9270d41403eac462cd791/src/serial.rs#L112
So I tried to make something similar:
fn uart_cfg() -> serial::Config {
let baudrate = 115_200.bps();
serial::Config {
baudrate,
wordlength: serial::WordLength::DataBits8,
parity: serial::Parity::ParityNone,
stopbits: serial::StopBits::STOP1,
}
}
This gave me:
error[E0451]: field `baudrate` of struct `hal::serial::Config` is private
--> src/main.rs:22:9
|
22 | baudrate,
| ^^^^^^^^ field `baudrate` is private
(repeated errors omitted).
How do I set the baudrate on the UART periferal cleanly?