diff options
| author | Dion Dokter <[email protected]> | 2024-07-25 12:22:55 +0200 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2024-07-25 12:22:55 +0200 |
| commit | 6ef9e564cad088c246af97f408c5b34dc47301b5 (patch) | |
| tree | 803b82861d6fd39b753d47c6906abd95c2e85495 | |
| parent | 2537fc6f4fcbdaa0fcea45a37382d61f59cc5767 (diff) | |
Add extra lifetime to opamp-using structs
| -rw-r--r-- | embassy-stm32/src/opamp.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/embassy-stm32/src/opamp.rs b/embassy-stm32/src/opamp.rs index ca94a573d..f3f8368f8 100644 --- a/embassy-stm32/src/opamp.rs +++ b/embassy-stm32/src/opamp.rs | |||
| @@ -38,15 +38,15 @@ impl From<OpAmpSpeed> for crate::pac::opamp::vals::Opahsm { | |||
| 38 | /// OpAmp external outputs, wired to a GPIO pad. | 38 | /// OpAmp external outputs, wired to a GPIO pad. |
| 39 | /// | 39 | /// |
| 40 | /// This struct can also be used as an ADC input. | 40 | /// This struct can also be used as an ADC input. |
| 41 | pub struct OpAmpOutput<'d, T: Instance> { | 41 | pub struct OpAmpOutput<'a, 'd: 'a, T: Instance> { |
| 42 | _inner: &'d OpAmp<'d, T>, | 42 | _inner: &'a OpAmp<'d, T>, |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | /// OpAmp internal outputs, wired directly to ADC inputs. | 45 | /// OpAmp internal outputs, wired directly to ADC inputs. |
| 46 | /// | 46 | /// |
| 47 | /// This struct can be used as an ADC input. | 47 | /// This struct can be used as an ADC input. |
| 48 | pub struct OpAmpInternalOutput<'d, T: Instance> { | 48 | pub struct OpAmpInternalOutput<'a, 'd: 'a, T: Instance> { |
| 49 | _inner: &'d OpAmp<'d, T>, | 49 | _inner: &'a OpAmp<'d, T>, |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | /// OpAmp driver. | 52 | /// OpAmp driver. |
| @@ -80,11 +80,11 @@ impl<'d, T: Instance> OpAmp<'d, T> { | |||
| 80 | /// directly used as an ADC input. The opamp will be disabled when the | 80 | /// directly used as an ADC input. The opamp will be disabled when the |
| 81 | /// [`OpAmpOutput`] is dropped. | 81 | /// [`OpAmpOutput`] is dropped. |
| 82 | pub fn buffer_ext( | 82 | pub fn buffer_ext( |
| 83 | &'d mut self, | 83 | &mut self, |
| 84 | in_pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>, | 84 | in_pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>, |
| 85 | out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd, | 85 | out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd, |
| 86 | gain: OpAmpGain, | 86 | gain: OpAmpGain, |
| 87 | ) -> OpAmpOutput<'d, T> { | 87 | ) -> OpAmpOutput<'_, 'd, T> { |
| 88 | into_ref!(in_pin); | 88 | into_ref!(in_pin); |
| 89 | into_ref!(out_pin); | 89 | into_ref!(out_pin); |
| 90 | in_pin.set_as_analog(); | 90 | in_pin.set_as_analog(); |
| @@ -119,9 +119,9 @@ impl<'d, T: Instance> OpAmp<'d, T> { | |||
| 119 | /// [`OpAmpOutput`] is dropped. | 119 | /// [`OpAmpOutput`] is dropped. |
| 120 | #[cfg(opamp_g4)] | 120 | #[cfg(opamp_g4)] |
| 121 | pub fn buffer_dac( | 121 | pub fn buffer_dac( |
| 122 | &'d mut self, | 122 | &mut self, |
| 123 | out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd, | 123 | out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd, |
| 124 | ) -> OpAmpOutput<'d, T> { | 124 | ) -> OpAmpOutput<'_, 'd, T> { |
| 125 | into_ref!(out_pin); | 125 | into_ref!(out_pin); |
| 126 | out_pin.set_as_analog(); | 126 | out_pin.set_as_analog(); |
| 127 | 127 | ||
| @@ -147,10 +147,10 @@ impl<'d, T: Instance> OpAmp<'d, T> { | |||
| 147 | /// The opamp output will be disabled when it is dropped. | 147 | /// The opamp output will be disabled when it is dropped. |
| 148 | #[cfg(opamp_g4)] | 148 | #[cfg(opamp_g4)] |
| 149 | pub fn buffer_int( | 149 | pub fn buffer_int( |
| 150 | &'d mut self, | 150 | &mut self, |
| 151 | pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>, | 151 | pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>, |
| 152 | gain: OpAmpGain, | 152 | gain: OpAmpGain, |
| 153 | ) -> OpAmpInternalOutput<'d, T> { | 153 | ) -> OpAmpInternalOutput<'_, 'd, T> { |
| 154 | into_ref!(pin); | 154 | into_ref!(pin); |
| 155 | pin.set_as_analog(); | 155 | pin.set_as_analog(); |
| 156 | 156 | ||
| @@ -176,7 +176,7 @@ impl<'d, T: Instance> OpAmp<'d, T> { | |||
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> { | 179 | impl<'a, 'd: 'a, T: Instance> Drop for OpAmpOutput<'a, 'd, T> { |
| 180 | fn drop(&mut self) { | 180 | fn drop(&mut self) { |
| 181 | T::regs().csr().modify(|w| { | 181 | T::regs().csr().modify(|w| { |
| 182 | w.set_opampen(false); | 182 | w.set_opampen(false); |
| @@ -184,7 +184,7 @@ impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> { | |||
| 184 | } | 184 | } |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | impl<'d, T: Instance> Drop for OpAmpInternalOutput<'d, T> { | 187 | impl<'a, 'd: 'a, T: Instance> Drop for OpAmpInternalOutput<'a, 'd, T> { |
| 188 | fn drop(&mut self) { | 188 | fn drop(&mut self) { |
| 189 | T::regs().csr().modify(|w| { | 189 | T::regs().csr().modify(|w| { |
| 190 | w.set_opampen(false); | 190 | w.set_opampen(false); |
| @@ -224,16 +224,16 @@ macro_rules! impl_opamp_external_output { | |||
| 224 | ($inst:ident, $adc:ident, $ch:expr) => { | 224 | ($inst:ident, $adc:ident, $ch:expr) => { |
| 225 | foreach_adc!( | 225 | foreach_adc!( |
| 226 | ($adc, $common_inst:ident, $adc_clock:ident) => { | 226 | ($adc, $common_inst:ident, $adc_clock:ident) => { |
| 227 | impl<'d> crate::adc::SealedAdcChannel<crate::peripherals::$adc> | 227 | impl<'a, 'd: 'a> crate::adc::SealedAdcChannel<crate::peripherals::$adc> |
| 228 | for OpAmpOutput<'d, crate::peripherals::$inst> | 228 | for OpAmpOutput<'a, 'd, crate::peripherals::$inst> |
| 229 | { | 229 | { |
| 230 | fn channel(&self) -> u8 { | 230 | fn channel(&self) -> u8 { |
| 231 | $ch | 231 | $ch |
| 232 | } | 232 | } |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc> | 235 | impl<'a, 'd: 'a> crate::adc::AdcChannel<crate::peripherals::$adc> |
| 236 | for OpAmpOutput<'d, crate::peripherals::$inst> | 236 | for OpAmpOutput<'a, 'd, crate::peripherals::$inst> |
| 237 | { | 237 | { |
| 238 | } | 238 | } |
| 239 | }; | 239 | }; |
| @@ -270,16 +270,16 @@ macro_rules! impl_opamp_internal_output { | |||
| 270 | ($inst:ident, $adc:ident, $ch:expr) => { | 270 | ($inst:ident, $adc:ident, $ch:expr) => { |
| 271 | foreach_adc!( | 271 | foreach_adc!( |
| 272 | ($adc, $common_inst:ident, $adc_clock:ident) => { | 272 | ($adc, $common_inst:ident, $adc_clock:ident) => { |
| 273 | impl<'d> crate::adc::SealedAdcChannel<crate::peripherals::$adc> | 273 | impl<'a, 'd: 'a> crate::adc::SealedAdcChannel<crate::peripherals::$adc> |
| 274 | for OpAmpInternalOutput<'d, crate::peripherals::$inst> | 274 | for OpAmpInternalOutput<'a, 'd, crate::peripherals::$inst> |
| 275 | { | 275 | { |
| 276 | fn channel(&self) -> u8 { | 276 | fn channel(&self) -> u8 { |
| 277 | $ch | 277 | $ch |
| 278 | } | 278 | } |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc> | 281 | impl<'a, 'd: 'a> crate::adc::AdcChannel<crate::peripherals::$adc> |
| 282 | for OpAmpInternalOutput<'d, crate::peripherals::$inst> | 282 | for OpAmpInternalOutput<'a, 'd, crate::peripherals::$inst> |
| 283 | { | 283 | { |
| 284 | } | 284 | } |
| 285 | }; | 285 | }; |
