aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/adc/mod.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/adc/mod.rs
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/adc/mod.rs')
-rw-r--r--embassy-stm32/src/adc/mod.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs
index 31a08b6eb..321db7431 100644
--- a/embassy-stm32/src/adc/mod.rs
+++ b/embassy-stm32/src/adc/mod.rs
@@ -22,6 +22,7 @@ use core::marker::PhantomData;
22#[allow(unused)] 22#[allow(unused)]
23#[cfg(not(any(adc_f3_v2)))] 23#[cfg(not(any(adc_f3_v2)))]
24pub use _version::*; 24pub use _version::*;
25use embassy_hal_internal::{impl_peripheral, PeripheralType};
25#[cfg(any(adc_f1, adc_f3, adc_v1, adc_l0, adc_f3_v1_1))] 26#[cfg(any(adc_f1, adc_f3, adc_v1, adc_l0, adc_f3_v1_1))]
26use embassy_sync::waitqueue::AtomicWaker; 27use embassy_sync::waitqueue::AtomicWaker;
27 28
@@ -42,7 +43,7 @@ dma_trait!(RxDma4, adc4::Instance);
42/// Analog to Digital driver. 43/// Analog to Digital driver.
43pub struct Adc<'d, T: Instance> { 44pub struct Adc<'d, T: Instance> {
44 #[allow(unused)] 45 #[allow(unused)]
45 adc: crate::PeripheralRef<'d, T>, 46 adc: crate::Peri<'d, T>,
46 #[cfg(not(any(adc_f3_v2, adc_f3_v1_1)))] 47 #[cfg(not(any(adc_f3_v2, adc_f3_v1_1)))]
47 sample_time: SampleTime, 48 sample_time: SampleTime,
48} 49}
@@ -111,7 +112,7 @@ pub(crate) fn blocking_delay_us(us: u32) {
111 adc_c0 112 adc_c0
112)))] 113)))]
113#[allow(private_bounds)] 114#[allow(private_bounds)]
114pub trait Instance: SealedInstance + crate::Peripheral<P = Self> { 115pub trait Instance: SealedInstance + crate::PeripheralType {
115 type Interrupt: crate::interrupt::typelevel::Interrupt; 116 type Interrupt: crate::interrupt::typelevel::Interrupt;
116} 117}
117/// ADC instance. 118/// ADC instance.
@@ -132,7 +133,7 @@ pub trait Instance: SealedInstance + crate::Peripheral<P = Self> {
132 adc_c0 133 adc_c0
133))] 134))]
134#[allow(private_bounds)] 135#[allow(private_bounds)]
135pub trait Instance: SealedInstance + crate::Peripheral<P = Self> + crate::rcc::RccPeripheral { 136pub trait Instance: SealedInstance + crate::PeripheralType + crate::rcc::RccPeripheral {
136 type Interrupt: crate::interrupt::typelevel::Interrupt; 137 type Interrupt: crate::interrupt::typelevel::Interrupt;
137} 138}
138 139
@@ -159,7 +160,7 @@ pub struct AnyAdcChannel<T> {
159 channel: u8, 160 channel: u8,
160 _phantom: PhantomData<T>, 161 _phantom: PhantomData<T>,
161} 162}
162 163impl_peripheral!(AnyAdcChannel<T: Instance>);
163impl<T: Instance> AdcChannel<T> for AnyAdcChannel<T> {} 164impl<T: Instance> AdcChannel<T> for AnyAdcChannel<T> {}
164impl<T: Instance> SealedAdcChannel<T> for AnyAdcChannel<T> { 165impl<T: Instance> SealedAdcChannel<T> for AnyAdcChannel<T> {
165 fn channel(&self) -> u8 { 166 fn channel(&self) -> u8 {
@@ -233,11 +234,11 @@ foreach_adc!(
233 234
234macro_rules! impl_adc_pin { 235macro_rules! impl_adc_pin {
235 ($inst:ident, $pin:ident, $ch:expr) => { 236 ($inst:ident, $pin:ident, $ch:expr) => {
236 impl crate::adc::AdcChannel<peripherals::$inst> for crate::peripherals::$pin {} 237 impl crate::adc::AdcChannel<peripherals::$inst> for crate::Peri<'_, crate::peripherals::$pin> {}
237 impl crate::adc::SealedAdcChannel<peripherals::$inst> for crate::peripherals::$pin { 238 impl crate::adc::SealedAdcChannel<peripherals::$inst> for crate::Peri<'_, crate::peripherals::$pin> {
238 #[cfg(any(adc_v1, adc_c0, adc_l0, adc_v2, adc_g4, adc_v4, adc_u5))] 239 #[cfg(any(adc_v1, adc_c0, adc_l0, adc_v2, adc_g4, adc_v4, adc_u5))]
239 fn setup(&mut self) { 240 fn setup(&mut self) {
240 <Self as crate::gpio::SealedPin>::set_as_analog(self); 241 <crate::peripherals::$pin as crate::gpio::SealedPin>::set_as_analog(self);
241 } 242 }
242 243
243 fn channel(&self) -> u8 { 244 fn channel(&self) -> u8 {