diff --git a/rp2040-hal/src/adc.rs b/rp2040-hal/src/adc.rs index 9fe20a5b8..30c9fd457 100644 --- a/rp2040-hal/src/adc.rs +++ b/rp2040-hal/src/adc.rs @@ -848,66 +848,60 @@ impl dma::EndlessReadTarget for DmaReadTarget {} /// See [`AdcFifoBuilder::round_robin`], for usage example. pub struct RoundRobin(u8); -impl From for RoundRobin { - fn from(pin: PIN) -> Self { +impl From<&PIN> for RoundRobin { + fn from(pin: &PIN) -> Self { Self(1 << pin.channel()) } } -// impl> From for RoundRobin { -// fn from(_: PIN) -> Self { -// Self(1 << PIN::channel()) -// } -// } - -impl From<(&mut A, &mut B)> for RoundRobin +impl From<(&A, &B)> for RoundRobin where - A: Channel, - B: Channel, + A: AdcChannel, + B: AdcChannel, { - fn from(_: (&mut A, &mut B)) -> Self { - Self(1 << A::channel() | 1 << B::channel()) + fn from(pins: (&A, &B)) -> Self { + Self(1 << pins.0.channel() | 1 << pins.1.channel()) } } -impl From<(&mut A, &mut B, &mut C)> for RoundRobin +impl From<(&A, &B, &C)> for RoundRobin where - A: Channel, - B: Channel, - C: Channel, + A: AdcChannel, + B: AdcChannel, + C: AdcChannel, { - fn from(_: (&mut A, &mut B, &mut C)) -> Self { - Self(1 << A::channel() | 1 << B::channel() | 1 << C::channel()) + fn from(pins: (&A, &B, &C)) -> Self { + Self(1 << pins.0.channel() | 1 << pins.1.channel() | 1 << pins.2.channel()) } } -impl From<(&mut A, &mut B, &mut C, &mut D)> for RoundRobin +impl From<(&A, &B, &C, &D)> for RoundRobin where - A: Channel, - B: Channel, - C: Channel, - D: Channel, + A: AdcChannel, + B: AdcChannel, + C: AdcChannel, + D: AdcChannel, { - fn from(_: (&mut A, &mut B, &mut C, &mut D)) -> Self { - Self(1 << A::channel() | 1 << B::channel() | 1 << C::channel() | 1 << D::channel()) + fn from(pins: (&A, &B, &C, &D)) -> Self { + Self(1 << pins.0.channel() | 1 << pins.1.channel() | 1 << pins.2.channel() | 1 << pins.3.channel()) } } -impl From<(&mut A, &mut B, &mut C, &mut D, &mut E)> for RoundRobin +impl From<(&A, &B, &C, &D, &E)> for RoundRobin where - A: Channel, - B: Channel, - C: Channel, - D: Channel, - E: Channel, + A: AdcChannel, + B: AdcChannel, + C: AdcChannel, + D: AdcChannel, + E: AdcChannel, { - fn from(_: (&mut A, &mut B, &mut C, &mut D, &mut E)) -> Self { + fn from(pins: (&A, &B, &C, &D, &E)) -> Self { Self( - 1 << A::channel() - | 1 << B::channel() - | 1 << C::channel() - | 1 << D::channel() - | 1 << E::channel(), + 1 << pins.0.channel() + | 1 << pins.1.channel() + | 1 << pins.2.channel() + | 1 << pins.3.channel() + | 1 << pins.4.channel(), ) } }