I’d like to reference an object slow_uart
which was defined outside of the loop:
fn main() -> ! {
// .....
// Initializations
let slow_bdrate = <Rate<u32, 1, 1>>::Hz(120000);
let slow_uart = UartConfig::new(
slow_bdrate,
uart::DataBits::Eight,
None,
uart::StopBits::One,
);
let data: u8 = 0;
let uart_peripheral = UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS);
loop {
uart_peripheral.enable(slow_uart, clocks.peripheral_clock.freq())
.unwrap();
uart_peripheral.write_full_blocking(&data);
delay.delay_ms(100);
}
}
I’m new to Rust, but is there any other way of accesing objects outside of the loop? Compiler suggests using a Copy()
trait but seems like it is not implemented for this function. Can I reference it using a something similar to pointers in C++? What are the good practices here?
I tried moving uart_peripheral
into the loop but them I had to move all other instances of its arguments as well, which I would rather not do.
Help much appriciated