Hi ,
So, I have a 'spi' object defined like this
let mut spi = Spi::new(
dp.SPI1,
SpiDevice::One,
spi_cfg,
BaudRate::Div16,
);
intellisense says that the object is of type "Spi < SPI1 >"
I now want to pass that object to a function, but having trouble with the type.
Reading and trying and experimenting .... gave me this
fn ws28xx_writeled<T>(spi: &mut Spi<T>, color: u32) {
let mut spidata: [u8;24] = [0;24];
ws28xx_calc24(&mut spidata, color);
spi.write(&mut spidata);
}
But I get:
error[E0599]: the method `write` exists for mutable reference `&mut Spi<T>`, but its trait bounds were not satisfied
--> src/main.rs:55:9
|
55 | spi.write(&mut spidata);
| ^^^^^ method cannot be called on `&mut Spi<T>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`<T as Deref>::Target = stm32_hal2::pac::spi1::RegisterBlock`
`T: Deref`
Am I on the right track?
/Troels