You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if i am doing this the right way. But I want to store the reference to IO in my function to either a struct, or static so that I can use it from other modules to access the gpio pins. When I try to assign it it complains that the method does not implement copy....
If i comment out the i2c code it works, but I assume ill have a similar issue in the future....
Edit: the same happens with peripherals if I try to store that too.
Error:
use of partially moved value: `io`
partial move occurs because `io.pins.gpio2` has type `GpioPin<esp_hal::gpio::Unknown, 2>`, which does not implement the `Copy` trait
minimal example:
use esp_hal::gpio::IO;
pub struct System {
pub io: IO,
}
impl System {
pub fn init() -> Self {
let peripherals = Peripherals::take();
let system = peripherals.SYSTEM.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let myio = IO::new(peripherals.GPIO, peripherals.IO_MUX);
// Initialize and configure I2C0
let mut i2c0 = I2C::new_async(
peripherals.I2C0,
myio.pins.gpio3,
myio.pins.gpio2,
100u32.kHz(),
&clocks,
);
Self {
io: myio, // <-- error here **
}
}
}
The text was updated successfully, but these errors were encountered:
Hey @Gibbz! Rust is stopping you from moving a value in which some of its sub fields have been moved. To combat this you should also move the pins you want for later and store those in the struct instead :).
I'm not sure if i am doing this the right way. But I want to store the reference to IO in my function to either a struct, or static so that I can use it from other modules to access the gpio pins. When I try to assign it it complains that the method does not implement copy....
If i comment out the i2c code it works, but I assume ill have a similar issue in the future....
Edit: the same happens with peripherals if I try to store that too.
Error:
minimal example:
The text was updated successfully, but these errors were encountered: