diff --git a/embassy-stm32/src/adc/f1.rs b/embassy-stm32/src/adc/f1.rs index 80eaecc14..3822d5032 100644 --- a/embassy-stm32/src/adc/f1.rs +++ b/embassy-stm32/src/adc/f1.rs @@ -5,7 +5,7 @@ use core::task::Poll; use embassy_hal_internal::into_ref; use super::blocking_delay_us; -use crate::adc::{Adc, AdcPin, Instance, SampleTime}; +use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; use crate::time::Hertz; use crate::{interrupt, Peripheral}; @@ -32,16 +32,16 @@ impl interrupt::typelevel::Handler for InterruptHandl } pub struct Vref; -impl AdcPin for Vref {} -impl super::SealedAdcPin for Vref { +impl AdcChannel for Vref {} +impl super::SealedAdcChannel for Vref { fn channel(&self) -> u8 { 17 } } pub struct Temperature; -impl AdcPin for Temperature {} -impl super::SealedAdcPin for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { 16 } @@ -135,8 +135,8 @@ impl<'d, T: Instance> Adc<'d, T> { T::regs().dr().read().0 as u16 } - pub async fn read(&mut self, pin: &mut impl AdcPin) -> u16 { - Self::set_channel_sample_time(pin.channel(), self.sample_time); + pub async fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { + Self::set_channel_sample_time(channel.channel(), self.sample_time); T::regs().cr1().modify(|reg| { reg.set_scan(false); reg.set_discen(false); @@ -151,7 +151,7 @@ impl<'d, T: Instance> Adc<'d, T> { }); // Configure the channel to sample - T::regs().sqr3().write(|reg| reg.set_sq(0, pin.channel())); + T::regs().sqr3().write(|reg| reg.set_sq(0, channel.channel())); self.convert().await } diff --git a/embassy-stm32/src/adc/f3.rs b/embassy-stm32/src/adc/f3.rs index c22a3fe4a..3f076d64b 100644 --- a/embassy-stm32/src/adc/f3.rs +++ b/embassy-stm32/src/adc/f3.rs @@ -5,7 +5,7 @@ use core::task::Poll; use embassy_hal_internal::into_ref; use super::blocking_delay_us; -use crate::adc::{Adc, AdcPin, Instance, SampleTime}; +use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; use crate::interrupt::typelevel::Interrupt; use crate::time::Hertz; use crate::{interrupt, Peripheral}; @@ -32,8 +32,8 @@ impl interrupt::typelevel::Handler for InterruptHandl } pub struct Vref; -impl AdcPin for Vref {} -impl super::SealedAdcPin for Vref { +impl AdcChannel for Vref {} +impl super::SealedAdcChannel for Vref { fn channel(&self) -> u8 { 18 } @@ -47,8 +47,8 @@ impl Vref { } pub struct Temperature; -impl AdcPin for Temperature {} -impl super::SealedAdcPin for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { 16 } @@ -154,11 +154,11 @@ impl<'d, T: Instance> Adc<'d, T> { T::regs().dr().read().rdata() } - pub async fn read(&mut self, pin: &mut impl AdcPin) -> u16 { - Self::set_channel_sample_time(pin.channel(), self.sample_time); + pub async fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { + Self::set_channel_sample_time(channel.channel(), self.sample_time); // Configure the channel to sample - T::regs().sqr1().write(|w| w.set_sq(0, pin.channel())); + T::regs().sqr1().write(|w| w.set_sq(0, channel.channel())); self.convert().await } diff --git a/embassy-stm32/src/adc/f3_v1_1.rs b/embassy-stm32/src/adc/f3_v1_1.rs index 672ace04f..106956989 100644 --- a/embassy-stm32/src/adc/f3_v1_1.rs +++ b/embassy-stm32/src/adc/f3_v1_1.rs @@ -7,7 +7,7 @@ use embassy_hal_internal::into_ref; use embassy_time::Instant; use super::Resolution; -use crate::adc::{Adc, AdcPin, Instance, SampleTime}; +use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; use crate::interrupt::typelevel::Interrupt; use crate::time::Hertz; use crate::{interrupt, Peripheral}; @@ -64,8 +64,8 @@ fn update_vref(op: i8) { } pub struct Vref(core::marker::PhantomData); -impl AdcPin for Vref {} -impl super::SealedAdcPin for Vref { +impl AdcChannel for Vref {} +impl super::SealedAdcChannel for Vref { fn channel(&self) -> u8 { 17 } @@ -123,8 +123,8 @@ impl Drop for Vref { } pub struct Temperature(core::marker::PhantomData); -impl AdcPin for Temperature {} -impl super::SealedAdcPin for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { 16 } @@ -271,8 +271,8 @@ impl<'d, T: Instance> Adc<'d, T> { } } - pub async fn read(&mut self, pin: &mut impl AdcPin) -> u16 { - self.set_sample_sequence(&[pin.channel()]).await; + pub async fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { + self.set_sample_sequence(&[channel.channel()]).await; self.convert().await } @@ -283,18 +283,18 @@ impl<'d, T: Instance> Adc<'d, T> { } } - pub async fn set_sample_time(&mut self, pin: &mut impl AdcPin, sample_time: SampleTime) { - if Self::get_channel_sample_time(pin.channel()) != sample_time { + pub async fn set_sample_time(&mut self, channel: &mut impl AdcChannel, sample_time: SampleTime) { + if Self::get_channel_sample_time(channel.channel()) != sample_time { self.stop_adc().await; unsafe { - Self::set_channel_sample_time(pin.channel(), sample_time); + Self::set_channel_sample_time(channel.channel(), sample_time); } self.start_adc().await; } } - pub fn get_sample_time(&self, pin: &impl AdcPin) -> SampleTime { - Self::get_channel_sample_time(pin.channel()) + pub fn get_sample_time(&self, channel: &impl AdcChannel) -> SampleTime { + Self::get_channel_sample_time(channel.channel()) } /// Sets the channel sample time diff --git a/embassy-stm32/src/adc/g4.rs b/embassy-stm32/src/adc/g4.rs index 221cc2a40..ce7f5db70 100644 --- a/embassy-stm32/src/adc/g4.rs +++ b/embassy-stm32/src/adc/g4.rs @@ -2,7 +2,7 @@ use pac::adc::vals::{Adcaldif, Difsel, Exten}; use pac::adccommon::vals::Presc; -use super::{blocking_delay_us, Adc, AdcPin, Instance, InternalChannel, Resolution, SampleTime}; +use super::{blocking_delay_us, Adc, AdcChannel, Instance, Resolution, SampleTime}; use crate::time::Hertz; use crate::{pac, Peripheral}; @@ -33,8 +33,8 @@ const VBAT_CHANNEL: u8 = 17; // NOTE: Vrefint/Temperature/Vbat are not available on all ADCs, this currently cannot be modeled with stm32-data, so these are available from the software on all ADCs /// Internal voltage reference channel. pub struct VrefInt; -impl InternalChannel for VrefInt {} -impl super::SealedInternalChannel for VrefInt { +impl AdcChannel for VrefInt {} +impl super::SealedAdcChannel for VrefInt { fn channel(&self) -> u8 { VREF_CHANNEL } @@ -42,8 +42,8 @@ impl super::SealedInternalChannel for VrefInt { /// Internal temperature channel. pub struct Temperature; -impl InternalChannel for Temperature {} -impl super::SealedInternalChannel for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { TEMP_CHANNEL } @@ -51,8 +51,8 @@ impl super::SealedInternalChannel for Temperature { /// Internal battery voltage channel. pub struct Vbat; -impl InternalChannel for Vbat {} -impl super::SealedInternalChannel for Vbat { +impl AdcChannel for Vbat {} +impl super::SealedAdcChannel for Vbat { fn channel(&self) -> u8 { VBAT_CHANNEL } @@ -258,18 +258,9 @@ impl<'d, T: Instance> Adc<'d, T> { } /// Read an ADC pin. - pub fn read

(&mut self, pin: &mut P) -> u16 - where - P: AdcPin, - P: crate::gpio::Pin, - { - pin.set_as_analog(); + pub fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { + channel.setup(); - self.read_channel(pin.channel()) - } - - /// Read an ADC internal channel. - pub fn read_internal(&mut self, channel: &mut impl InternalChannel) -> u16 { self.read_channel(channel.channel()) } diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index c753d046c..040ee9c53 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs @@ -15,6 +15,8 @@ #[cfg_attr(adc_g4, path = "g4.rs")] mod _version; +use core::marker::PhantomData; + #[allow(unused)] #[cfg(not(adc_f3_v2))] pub use _version::*; @@ -58,19 +60,14 @@ trait SealedInstance { fn state() -> &'static State; } -pub(crate) trait SealedAdcPin { - #[cfg(any(adc_v1, adc_l0, adc_v2))] - fn set_as_analog(&mut self) {} +pub(crate) trait SealedAdcChannel { + #[cfg(any(adc_v1, adc_l0, adc_v2, adc_g4, adc_v4))] + fn setup(&mut self) {} #[allow(unused)] fn channel(&self) -> u8; } -trait SealedInternalChannel { - #[allow(unused)] - fn channel(&self) -> u8; -} - /// Performs a busy-wait delay for a specified number of microseconds. #[allow(unused)] pub(crate) fn blocking_delay_us(us: u32) { @@ -124,12 +121,36 @@ pub trait Instance: SealedInstance + crate::Peripheral

+ crate::rcc::R type Interrupt: crate::interrupt::typelevel::Interrupt; } -/// ADC pin. +/// ADC channel. #[allow(private_bounds)] -pub trait AdcPin: SealedAdcPin {} -/// ADC internal channel. -#[allow(private_bounds)] -pub trait InternalChannel: SealedInternalChannel {} +pub trait AdcChannel: SealedAdcChannel + Sized { + #[allow(unused_mut)] + fn degrade_adc(mut self) -> AnyAdcChannel { + #[cfg(any(adc_v1, adc_l0, adc_v2, adc_g4, adc_v4))] + self.setup(); + + AnyAdcChannel { + channel: self.channel(), + _phantom: PhantomData, + } + } +} + +/// A type-erased channel for a given ADC instance. +/// +/// This is useful in scenarios where you need the ADC channels to have the same type, such as +/// storing them in an array. +pub struct AnyAdcChannel { + channel: u8, + _phantom: PhantomData, +} + +impl AdcChannel for AnyAdcChannel {} +impl SealedAdcChannel for AnyAdcChannel { + fn channel(&self) -> u8 { + self.channel + } +} foreach_adc!( ($inst:ident, $common_inst:ident, $clock:ident) => { @@ -158,11 +179,10 @@ foreach_adc!( macro_rules! impl_adc_pin { ($inst:ident, $pin:ident, $ch:expr) => { - impl crate::adc::AdcPin for crate::peripherals::$pin {} - - impl crate::adc::SealedAdcPin for crate::peripherals::$pin { - #[cfg(any(adc_v1, adc_l0, adc_v2))] - fn set_as_analog(&mut self) { + impl crate::adc::AdcChannel for crate::peripherals::$pin {} + impl crate::adc::SealedAdcChannel for crate::peripherals::$pin { + #[cfg(any(adc_v1, adc_l0, adc_v2, adc_g4, adc_v4))] + fn setup(&mut self) { ::set_as_analog(self); } diff --git a/embassy-stm32/src/adc/v1.rs b/embassy-stm32/src/adc/v1.rs index f17522076..090790c39 100644 --- a/embassy-stm32/src/adc/v1.rs +++ b/embassy-stm32/src/adc/v1.rs @@ -7,7 +7,7 @@ use embassy_hal_internal::into_ref; use stm32_metapac::adc::vals::Ckmode; use super::blocking_delay_us; -use crate::adc::{Adc, AdcPin, Instance, Resolution, SampleTime}; +use crate::adc::{Adc, AdcChannel, Instance, Resolution, SampleTime}; use crate::interrupt::typelevel::Interrupt; use crate::peripherals::ADC1; use crate::{interrupt, Peripheral}; @@ -36,26 +36,26 @@ impl interrupt::typelevel::Handler for InterruptHandl pub struct Vbat; #[cfg(not(adc_l0))] -impl AdcPin for Vbat {} +impl AdcChannel for Vbat {} #[cfg(not(adc_l0))] -impl super::SealedAdcPin for Vbat { +impl super::SealedAdcChannel for Vbat { fn channel(&self) -> u8 { 18 } } pub struct Vref; -impl AdcPin for Vref {} -impl super::SealedAdcPin for Vref { +impl AdcChannel for Vref {} +impl super::SealedAdcChannel for Vref { fn channel(&self) -> u8 { 17 } } pub struct Temperature; -impl AdcPin for Temperature {} -impl super::SealedAdcPin for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { 16 } @@ -155,12 +155,12 @@ impl<'d, T: Instance> Adc<'d, T> { T::regs().cfgr2().modify(|reg| reg.set_ckmode(ckmode)); } - pub async fn read(&mut self, pin: &mut impl AdcPin) -> u16 { - let channel = pin.channel(); - pin.set_as_analog(); + pub async fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { + let ch_num = channel.channel(); + channel.setup(); // A.7.5 Single conversion sequence code example - Software trigger - T::regs().chselr().write(|reg| reg.set_chselx(channel as usize, true)); + T::regs().chselr().write(|reg| reg.set_chselx(ch_num as usize, true)); self.convert().await } diff --git a/embassy-stm32/src/adc/v2.rs b/embassy-stm32/src/adc/v2.rs index 7771cf768..033108195 100644 --- a/embassy-stm32/src/adc/v2.rs +++ b/embassy-stm32/src/adc/v2.rs @@ -1,7 +1,7 @@ use embassy_hal_internal::into_ref; use super::blocking_delay_us; -use crate::adc::{Adc, AdcPin, Instance, Resolution, SampleTime}; +use crate::adc::{Adc, AdcChannel, Instance, Resolution, SampleTime}; use crate::peripherals::ADC1; use crate::time::Hertz; use crate::Peripheral; @@ -12,8 +12,8 @@ pub const VREF_DEFAULT_MV: u32 = 3300; pub const VREF_CALIB_MV: u32 = 3300; pub struct VrefInt; -impl AdcPin for VrefInt {} -impl super::SealedAdcPin for VrefInt { +impl AdcChannel for VrefInt {} +impl super::SealedAdcChannel for VrefInt { fn channel(&self) -> u8 { 17 } @@ -27,8 +27,8 @@ impl VrefInt { } pub struct Temperature; -impl AdcPin for Temperature {} -impl super::SealedAdcPin for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { cfg_if::cfg_if! { if #[cfg(any(stm32f2, stm32f40, stm32f41))] { @@ -48,8 +48,8 @@ impl Temperature { } pub struct Vbat; -impl AdcPin for Vbat {} -impl super::SealedAdcPin for Vbat { +impl AdcChannel for Vbat {} +impl super::SealedAdcChannel for Vbat { fn channel(&self) -> u8 { 18 } @@ -175,11 +175,11 @@ where T::regs().dr().read().0 as u16 } - pub fn read(&mut self, pin: &mut impl AdcPin) -> u16 { - pin.set_as_analog(); + pub fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { + channel.setup(); // Configure ADC - let channel = pin.channel(); + let channel = channel.channel(); // Select channel T::regs().sqr3().write(|reg| reg.set_sq(0, channel)); diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs index dc418297e..be857f4dd 100644 --- a/embassy-stm32/src/adc/v3.rs +++ b/embassy-stm32/src/adc/v3.rs @@ -2,7 +2,7 @@ use cfg_if::cfg_if; use embassy_hal_internal::into_ref; use super::blocking_delay_us; -use crate::adc::{Adc, AdcPin, Instance, Resolution, SampleTime}; +use crate::adc::{Adc, AdcChannel, Instance, Resolution, SampleTime}; use crate::Peripheral; /// Default VREF voltage used for sample conversion to millivolts. @@ -11,8 +11,8 @@ pub const VREF_DEFAULT_MV: u32 = 3300; pub const VREF_CALIB_MV: u32 = 3000; pub struct VrefInt; -impl AdcPin for VrefInt {} -impl super::SealedAdcPin for VrefInt { +impl AdcChannel for VrefInt {} +impl super::SealedAdcChannel for VrefInt { fn channel(&self) -> u8 { cfg_if! { if #[cfg(adc_g0)] { @@ -30,8 +30,8 @@ impl super::SealedAdcPin for VrefInt { } pub struct Temperature; -impl AdcPin for Temperature {} -impl super::SealedAdcPin for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { cfg_if! { if #[cfg(adc_g0)] { @@ -49,8 +49,8 @@ impl super::SealedAdcPin for Temperature { } pub struct Vbat; -impl AdcPin for Vbat {} -impl super::SealedAdcPin for Vbat { +impl AdcChannel for Vbat {} +impl super::SealedAdcChannel for Vbat { fn channel(&self) -> u8 { cfg_if! { if #[cfg(adc_g0)] { @@ -70,8 +70,8 @@ impl super::SealedAdcPin for Vbat { cfg_if! { if #[cfg(adc_h5)] { pub struct VddCore; - impl AdcPin for VddCore {} - impl super::SealedAdcPin for VddCore { + impl AdcChannel for VddCore {} + impl super::SealedAdcChannel for VddCore { fn channel(&self) -> u8 { 6 } @@ -82,8 +82,8 @@ cfg_if! { cfg_if! { if #[cfg(adc_u0)] { pub struct DacOut; - impl AdcPin for DacOut {} - impl super::SealedAdcPin for DacOut { + impl AdcChannel for DacOut {} + impl super::SealedAdcChannel for DacOut { fn channel(&self) -> u8 { 19 } @@ -220,7 +220,7 @@ impl<'d, T: Instance> Adc<'d, T> { T::regs().dr().read().0 as u16 } - pub fn read(&mut self, pin: &mut impl AdcPin) -> u16 { + pub fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { // Make sure bits are off while T::regs().cr().read().addis() { // spin @@ -241,18 +241,18 @@ impl<'d, T: Instance> Adc<'d, T> { // RM0492, RM0481, etc. // "This option bit must be set to 1 when ADCx_INP0 or ADCx_INN1 channel is selected." #[cfg(adc_h5)] - if pin.channel() == 0 { + if channel.channel() == 0 { T::regs().or().modify(|reg| reg.set_op0(true)); } // Configure channel - Self::set_channel_sample_time(pin.channel(), self.sample_time); + Self::set_channel_sample_time(channel.channel(), self.sample_time); // Select channel #[cfg(not(any(adc_g0, adc_u0)))] - T::regs().sqr1().write(|reg| reg.set_sq(0, pin.channel())); + T::regs().sqr1().write(|reg| reg.set_sq(0, channel.channel())); #[cfg(any(adc_g0, adc_u0))] - T::regs().chselr().write(|reg| reg.set_chsel(1 << pin.channel())); + T::regs().chselr().write(|reg| reg.set_chsel(1 << channel.channel())); // Some models are affected by an erratum: // If we perform conversions slower than 1 kHz, the first read ADC value can be @@ -270,7 +270,7 @@ impl<'d, T: Instance> Adc<'d, T> { // RM0492, RM0481, etc. // "This option bit must be set to 1 when ADCx_INP0 or ADCx_INN1 channel is selected." #[cfg(adc_h5)] - if pin.channel() == 0 { + if channel.channel() == 0 { T::regs().or().modify(|reg| reg.set_op0(false)); } diff --git a/embassy-stm32/src/adc/v4.rs b/embassy-stm32/src/adc/v4.rs index ca87b41ee..f564114c2 100644 --- a/embassy-stm32/src/adc/v4.rs +++ b/embassy-stm32/src/adc/v4.rs @@ -2,7 +2,7 @@ use pac::adc::vals::{Adcaldif, Boost, Difsel, Exten, Pcsel}; use pac::adccommon::vals::Presc; -use super::{blocking_delay_us, Adc, AdcPin, Instance, InternalChannel, Resolution, SampleTime}; +use super::{blocking_delay_us, Adc, AdcChannel, Instance, Resolution, SampleTime}; use crate::time::Hertz; use crate::{pac, Peripheral}; @@ -33,8 +33,8 @@ const VBAT_CHANNEL: u8 = 17; // NOTE: Vrefint/Temperature/Vbat are not available on all ADCs, this currently cannot be modeled with stm32-data, so these are available from the software on all ADCs /// Internal voltage reference channel. pub struct VrefInt; -impl InternalChannel for VrefInt {} -impl super::SealedInternalChannel for VrefInt { +impl AdcChannel for VrefInt {} +impl super::SealedAdcChannel for VrefInt { fn channel(&self) -> u8 { VREF_CHANNEL } @@ -42,8 +42,8 @@ impl super::SealedInternalChannel for VrefInt { /// Internal temperature channel. pub struct Temperature; -impl InternalChannel for Temperature {} -impl super::SealedInternalChannel for Temperature { +impl AdcChannel for Temperature {} +impl super::SealedAdcChannel for Temperature { fn channel(&self) -> u8 { TEMP_CHANNEL } @@ -51,8 +51,8 @@ impl super::SealedInternalChannel for Temperature { /// Internal battery voltage channel. pub struct Vbat; -impl InternalChannel for Vbat {} -impl super::SealedInternalChannel for Vbat { +impl AdcChannel for Vbat {} +impl super::SealedAdcChannel for Vbat { fn channel(&self) -> u8 { VBAT_CHANNEL } @@ -271,19 +271,10 @@ impl<'d, T: Instance> Adc<'d, T> { T::regs().dr().read().0 as u16 } - /// Read an ADC pin. - pub fn read

(&mut self, pin: &mut P) -> u16 - where - P: AdcPin, - P: crate::gpio::Pin, - { - pin.set_as_analog(); + /// Read an ADC channel. + pub fn read(&mut self, channel: &mut impl AdcChannel) -> u16 { + channel.setup(); - self.read_channel(pin.channel()) - } - - /// Read an ADC internal channel. - pub fn read_internal(&mut self, channel: &mut impl InternalChannel) -> u16 { self.read_channel(channel.channel()) } diff --git a/embassy-stm32/src/opamp.rs b/embassy-stm32/src/opamp.rs index a3b4352c0..487902959 100644 --- a/embassy-stm32/src/opamp.rs +++ b/embassy-stm32/src/opamp.rs @@ -198,7 +198,7 @@ macro_rules! impl_opamp_external_output { ($inst:ident, $adc:ident, $ch:expr) => { foreach_adc!( ($adc, $common_inst:ident, $adc_clock:ident) => { - impl<'d> crate::adc::SealedAdcPin + impl<'d> crate::adc::SealedAdcChannel for OpAmpOutput<'d, crate::peripherals::$inst> { fn channel(&self) -> u8 { @@ -206,7 +206,7 @@ macro_rules! impl_opamp_external_output { } } - impl<'d> crate::adc::AdcPin + impl<'d> crate::adc::AdcChannel for OpAmpOutput<'d, crate::peripherals::$inst> { } @@ -244,7 +244,7 @@ macro_rules! impl_opamp_internal_output { ($inst:ident, $adc:ident, $ch:expr) => { foreach_adc!( ($adc, $common_inst:ident, $adc_clock:ident) => { - impl<'d> crate::adc::SealedAdcPin + impl<'d> crate::adc::SealedAdcChannel for OpAmpInternalOutput<'d, crate::peripherals::$inst> { fn channel(&self) -> u8 { @@ -252,7 +252,7 @@ macro_rules! impl_opamp_internal_output { } } - impl<'d> crate::adc::AdcPin + impl<'d> crate::adc::AdcChannel for OpAmpInternalOutput<'d, crate::peripherals::$inst> { } diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index 0009103d1..e9a857a74 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs @@ -51,7 +51,7 @@ async fn main(_spawner: Spawner) { let mut vrefint_channel = adc.enable_vrefint(); loop { - let vrefint = adc.read_internal(&mut vrefint_channel); + let vrefint = adc.read(&mut vrefint_channel); info!("vrefint: {}", vrefint); let measured = adc.read(&mut p.PC0); info!("measured: {}", measured);