Add extra lifetime to opamp-using structs
This commit is contained in:
parent
2537fc6f4f
commit
6ef9e564ca
1 changed files with 20 additions and 20 deletions
|
@ -38,15 +38,15 @@ impl From<OpAmpSpeed> for crate::pac::opamp::vals::Opahsm {
|
||||||
/// OpAmp external outputs, wired to a GPIO pad.
|
/// OpAmp external outputs, wired to a GPIO pad.
|
||||||
///
|
///
|
||||||
/// This struct can also be used as an ADC input.
|
/// This struct can also be used as an ADC input.
|
||||||
pub struct OpAmpOutput<'d, T: Instance> {
|
pub struct OpAmpOutput<'a, 'd: 'a, T: Instance> {
|
||||||
_inner: &'d OpAmp<'d, T>,
|
_inner: &'a OpAmp<'d, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// OpAmp internal outputs, wired directly to ADC inputs.
|
/// OpAmp internal outputs, wired directly to ADC inputs.
|
||||||
///
|
///
|
||||||
/// This struct can be used as an ADC input.
|
/// This struct can be used as an ADC input.
|
||||||
pub struct OpAmpInternalOutput<'d, T: Instance> {
|
pub struct OpAmpInternalOutput<'a, 'd: 'a, T: Instance> {
|
||||||
_inner: &'d OpAmp<'d, T>,
|
_inner: &'a OpAmp<'d, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// OpAmp driver.
|
/// 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
|
/// directly used as an ADC input. The opamp will be disabled when the
|
||||||
/// [`OpAmpOutput`] is dropped.
|
/// [`OpAmpOutput`] is dropped.
|
||||||
pub fn buffer_ext(
|
pub fn buffer_ext(
|
||||||
&'d mut self,
|
&mut self,
|
||||||
in_pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>,
|
in_pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>,
|
||||||
out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd,
|
out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd,
|
||||||
gain: OpAmpGain,
|
gain: OpAmpGain,
|
||||||
) -> OpAmpOutput<'d, T> {
|
) -> OpAmpOutput<'_, 'd, T> {
|
||||||
into_ref!(in_pin);
|
into_ref!(in_pin);
|
||||||
into_ref!(out_pin);
|
into_ref!(out_pin);
|
||||||
in_pin.set_as_analog();
|
in_pin.set_as_analog();
|
||||||
|
@ -119,9 +119,9 @@ impl<'d, T: Instance> OpAmp<'d, T> {
|
||||||
/// [`OpAmpOutput`] is dropped.
|
/// [`OpAmpOutput`] is dropped.
|
||||||
#[cfg(opamp_g4)]
|
#[cfg(opamp_g4)]
|
||||||
pub fn buffer_dac(
|
pub fn buffer_dac(
|
||||||
&'d mut self,
|
&mut self,
|
||||||
out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd,
|
out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd,
|
||||||
) -> OpAmpOutput<'d, T> {
|
) -> OpAmpOutput<'_, 'd, T> {
|
||||||
into_ref!(out_pin);
|
into_ref!(out_pin);
|
||||||
out_pin.set_as_analog();
|
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.
|
/// The opamp output will be disabled when it is dropped.
|
||||||
#[cfg(opamp_g4)]
|
#[cfg(opamp_g4)]
|
||||||
pub fn buffer_int(
|
pub fn buffer_int(
|
||||||
&'d mut self,
|
&mut self,
|
||||||
pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>,
|
pin: impl Peripheral<P = impl NonInvertingPin<T> + crate::gpio::Pin>,
|
||||||
gain: OpAmpGain,
|
gain: OpAmpGain,
|
||||||
) -> OpAmpInternalOutput<'d, T> {
|
) -> OpAmpInternalOutput<'_, 'd, T> {
|
||||||
into_ref!(pin);
|
into_ref!(pin);
|
||||||
pin.set_as_analog();
|
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) {
|
fn drop(&mut self) {
|
||||||
T::regs().csr().modify(|w| {
|
T::regs().csr().modify(|w| {
|
||||||
w.set_opampen(false);
|
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) {
|
fn drop(&mut self) {
|
||||||
T::regs().csr().modify(|w| {
|
T::regs().csr().modify(|w| {
|
||||||
w.set_opampen(false);
|
w.set_opampen(false);
|
||||||
|
@ -224,16 +224,16 @@ macro_rules! impl_opamp_external_output {
|
||||||
($inst:ident, $adc:ident, $ch:expr) => {
|
($inst:ident, $adc:ident, $ch:expr) => {
|
||||||
foreach_adc!(
|
foreach_adc!(
|
||||||
($adc, $common_inst:ident, $adc_clock:ident) => {
|
($adc, $common_inst:ident, $adc_clock:ident) => {
|
||||||
impl<'d> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
|
impl<'a, 'd: 'a> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
|
||||||
for OpAmpOutput<'d, crate::peripherals::$inst>
|
for OpAmpOutput<'a, 'd, crate::peripherals::$inst>
|
||||||
{
|
{
|
||||||
fn channel(&self) -> u8 {
|
fn channel(&self) -> u8 {
|
||||||
$ch
|
$ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc>
|
impl<'a, 'd: 'a> crate::adc::AdcChannel<crate::peripherals::$adc>
|
||||||
for OpAmpOutput<'d, crate::peripherals::$inst>
|
for OpAmpOutput<'a, 'd, crate::peripherals::$inst>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -270,16 +270,16 @@ macro_rules! impl_opamp_internal_output {
|
||||||
($inst:ident, $adc:ident, $ch:expr) => {
|
($inst:ident, $adc:ident, $ch:expr) => {
|
||||||
foreach_adc!(
|
foreach_adc!(
|
||||||
($adc, $common_inst:ident, $adc_clock:ident) => {
|
($adc, $common_inst:ident, $adc_clock:ident) => {
|
||||||
impl<'d> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
|
impl<'a, 'd: 'a> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
|
||||||
for OpAmpInternalOutput<'d, crate::peripherals::$inst>
|
for OpAmpInternalOutput<'a, 'd, crate::peripherals::$inst>
|
||||||
{
|
{
|
||||||
fn channel(&self) -> u8 {
|
fn channel(&self) -> u8 {
|
||||||
$ch
|
$ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc>
|
impl<'a, 'd: 'a> crate::adc::AdcChannel<crate::peripherals::$adc>
|
||||||
for OpAmpInternalOutput<'d, crate::peripherals::$inst>
|
for OpAmpInternalOutput<'a, 'd, crate::peripherals::$inst>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue