0

I want to set alternate mode for AP10 of stm32f411 by rust HAl. My code looks like this:

let rx_pin = gpioa.pa10.into_alternate();

But it has multiple impl:

    = note: multiple `impl`s satisfying `stm32f4xx_hal::gpio::Pin<'A', 10>: gpio::marker::IntoAf<_>` found in the `stm32f4xx_hal` crate:
        - impl<MODE> gpio::marker::IntoAf<10> for stm32f4xx_hal::gpio::Pin<'A', 10, MODE>;
        - impl<MODE> gpio::marker::IntoAf<1> for stm32f4xx_hal::gpio::Pin<'A', 10, MODE>;
        - impl<MODE> gpio::marker::IntoAf<6> for stm32f4xx_hal::gpio::Pin<'A', 10, MODE>;
        - impl<MODE> gpio::marker::IntoAf<7> for stm32f4xx_hal::gpio::Pin<'A', 10, MODE>;

How can I fix this compile error?

Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77
tuanti1997qn
  • 57
  • 1
  • 10

1 Answers1

0

Fixex by specifying a value for generic

let rx_pin = gpioa.pa10.into_alternate::<7>();

Because the prototype of the method of into_alternate looks like this:

pub fn into_alternate<const A: u8>(self) -> Pin<P, N, Alternate<A, PushPull>>

And I need the alternate mode 7 for the pin.

This question sounds silly, but hope it will help someone still a absolute newbie crustacean (like me) in the future.

tuanti1997qn
  • 57
  • 1
  • 10