mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 00:02:28 +00:00
Add extra lifetime to opamp-using structs
This commit is contained in:
parent
2537fc6f4f
commit
6ef9e564ca
@ -38,15 +38,15 @@ impl From<OpAmpSpeed> for crate::pac::opamp::vals::Opahsm {
|
||||
/// OpAmp external outputs, wired to a GPIO pad.
|
||||
///
|
||||
/// This struct can also be used as an ADC input.
|
||||
pub struct OpAmpOutput<'d, T: Instance> {
|
||||
_inner: &'d OpAmp<'d, T>,
|
||||
pub struct OpAmpOutput<'a, 'd: 'a, T: Instance> {
|
||||
_inner: &'a OpAmp<'d, T>,
|
||||
}
|
||||
|
||||
/// OpAmp internal outputs, wired directly to ADC inputs.
|
||||
///
|
||||
/// This struct can be used as an ADC input.
|
||||
pub struct OpAmpInternalOutput<'d, T: Instance> {
|
||||
_inner: &'d OpAmp<'d, T>,
|
||||
pub struct OpAmpInternalOutput<'a, 'd: 'a, T: Instance> {
|
||||
_inner: &'a OpAmp<'d, T>,
|
||||
}
|
||||
|
||||
/// OpAmp driver.
|
||||
@ -80,11 +80,11 @@ impl<'d, T: Instance> OpAmp<'d, T> {
|
||||
/// directly used as an ADC input. The opamp will be disabled when the
|
||||
/// [`OpAmpOutput`] is dropped.
|
||||
pub fn buffer_ext(
|
||||
&'d mut self,
|
||||
&mut self,
|
||||
in_pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>,
|
||||
out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd,
|
||||
gain: OpAmpGain,
|
||||
) -> OpAmpOutput<'d, T> {
|
||||
) -> OpAmpOutput<'_, 'd, T> {
|
||||
into_ref!(in_pin);
|
||||
into_ref!(out_pin);
|
||||
in_pin.set_as_analog();
|
||||
@ -119,9 +119,9 @@ impl<'d, T: Instance> OpAmp<'d, T> {
|
||||
/// [`OpAmpOutput`] is dropped.
|
||||
#[cfg(opamp_g4)]
|
||||
pub fn buffer_dac(
|
||||
&'d mut self,
|
||||
&mut self,
|
||||
out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd,
|
||||
) -> OpAmpOutput<'d, T> {
|
||||
) -> OpAmpOutput<'_, 'd, T> {
|
||||
into_ref!(out_pin);
|
||||
out_pin.set_as_analog();
|
||||
|
||||
@ -147,10 +147,10 @@ impl<'d, T: Instance> OpAmp<'d, T> {
|
||||
/// The opamp output will be disabled when it is dropped.
|
||||
#[cfg(opamp_g4)]
|
||||
pub fn buffer_int(
|
||||
&'d mut self,
|
||||
&mut self,
|
||||
pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>,
|
||||
gain: OpAmpGain,
|
||||
) -> OpAmpInternalOutput<'d, T> {
|
||||
) -> OpAmpInternalOutput<'_, 'd, T> {
|
||||
into_ref!(pin);
|
||||
pin.set_as_analog();
|
||||
|
||||
@ -176,7 +176,7 @@ impl<'d, T: Instance> OpAmp<'d, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> {
|
||||
impl<'a, 'd: 'a, T: Instance> Drop for OpAmpOutput<'a, 'd, T> {
|
||||
fn drop(&mut self) {
|
||||
T::regs().csr().modify(|w| {
|
||||
w.set_opampen(false);
|
||||
@ -184,7 +184,7 @@ impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> Drop for OpAmpInternalOutput<'d, T> {
|
||||
impl<'a, 'd: 'a, T: Instance> Drop for OpAmpInternalOutput<'a, 'd, T> {
|
||||
fn drop(&mut self) {
|
||||
T::regs().csr().modify(|w| {
|
||||
w.set_opampen(false);
|
||||
@ -224,16 +224,16 @@ 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::SealedAdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpOutput<'d, crate::peripherals::$inst>
|
||||
impl<'a, 'd: 'a> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpOutput<'a, 'd, crate::peripherals::$inst>
|
||||
{
|
||||
fn channel(&self) -> u8 {
|
||||
$ch
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpOutput<'d, crate::peripherals::$inst>
|
||||
impl<'a, 'd: 'a> crate::adc::AdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpOutput<'a, 'd, crate::peripherals::$inst>
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -270,16 +270,16 @@ 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::SealedAdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpInternalOutput<'d, crate::peripherals::$inst>
|
||||
impl<'a, 'd: 'a> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpInternalOutput<'a, 'd, crate::peripherals::$inst>
|
||||
{
|
||||
fn channel(&self) -> u8 {
|
||||
$ch
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpInternalOutput<'d, crate::peripherals::$inst>
|
||||
impl<'a, 'd: 'a> crate::adc::AdcChannel<crate::peripherals::$adc>
|
||||
for OpAmpInternalOutput<'a, 'd, crate::peripherals::$inst>
|
||||
{
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user