rust-iot / rust-radio-sx127x

Rust driver for the Semtech SX127x series of Sub-GHz LoRa/ISM radio transceivers
Mozilla Public License 2.0
32 stars 16 forks source link

Type issue with stm32l1xx_hal #32

Closed niondir closed 3 years ago

niondir commented 3 years ago

I try to use the driver with the stm32l1xx_hal

I have my Pins:

    let csPin = gpiob.pb0.into_push_pull_output();
    let busyPin = gpiob.pb8.into_floating_input();
    let sdnPin = gpioa.pa2.into_push_pull_output();

But when passing it into the driver:

    let mut hal = SpiWrapper::new(spi, csPin, delay);
    hal.with_busy(busyPin.downgrade());
    hal.with_reset(sdnPin.downgrade());

with_busy and with_reset both expect the same type Output but busyPin is of type PB0 and ´sdnPin´ is of type PA2. Even the downgrade just results in PA and PB which leads to a compile error.

Is it an issue with the stm32l1xx_hal or with the SX driver? Or is there any way I can convert / wrap my types to solve the issue?

ryankurte commented 3 years ago

hmm, the type bounds should support this (it was a problem some versions ago), it's possible you're battling the type inference but that'd usually give a useful error...

have you tried using Sx127x::spi directly? you ideally shouldn't need to construct the SpiWrapper yourself.

edit: can you try running from the git version of the crate? looks like i haven't published a release of this in... some time.

niondir commented 3 years ago

Thanks, using the master did solve the type issue. Now i'm struggling with the SPI traits, see #18