aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-05-30 12:23:53 +0000
committerGitHub <[email protected]>2024-05-30 12:23:53 +0000
commitd21e9caa801511a7959543e058a22d83871bb3fe (patch)
treee8f75ca09d9e2beac5e7593101a35d4184aa50f3
parentb378ec4558306a7d10572301b7e078c055bc47ac (diff)
parent28f5f0babaa6348c08985f599353e34b48c887fb (diff)
Merge pull request #3021 from mat-kie/follower-opamp
Make OpAmp usable in follower configuration for internal DAC channel
-rw-r--r--embassy-stm32/src/opamp.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/embassy-stm32/src/opamp.rs b/embassy-stm32/src/opamp.rs
index 487902959..ca94a573d 100644
--- a/embassy-stm32/src/opamp.rs
+++ b/embassy-stm32/src/opamp.rs
@@ -110,6 +110,32 @@ impl<'d, T: Instance> OpAmp<'d, T> {
110 110
111 OpAmpOutput { _inner: self } 111 OpAmpOutput { _inner: self }
112 } 112 }
113 /// Configure the OpAmp as a buffer for the DAC it is connected to,
114 /// outputting to the provided output pin, and enable the opamp.
115 ///
116 /// The output pin is held within the returned [`OpAmpOutput`] struct,
117 /// preventing it being used elsewhere. The `OpAmpOutput` can then be
118 /// directly used as an ADC input. The opamp will be disabled when the
119 /// [`OpAmpOutput`] is dropped.
120 #[cfg(opamp_g4)]
121 pub fn buffer_dac(
122 &'d mut self,
123 out_pin: impl Peripheral<P = impl OutputPin<T> + crate::gpio::Pin> + 'd,
124 ) -> OpAmpOutput<'d, T> {
125 into_ref!(out_pin);
126 out_pin.set_as_analog();
127
128 T::regs().csr().modify(|w| {
129 use crate::pac::opamp::vals::*;
130
131 w.set_vm_sel(VmSel::OUTPUT);
132 w.set_vp_sel(VpSel::DAC3_CH1);
133 w.set_opaintoen(Opaintoen::OUTPUTPIN);
134 w.set_opampen(true);
135 });
136
137 OpAmpOutput { _inner: self }
138 }
113 139
114 /// Configure the OpAmp as a buffer for the provided input pin, 140 /// Configure the OpAmp as a buffer for the provided input pin,
115 /// with the output only used internally, and enable the opamp. 141 /// with the output only used internally, and enable the opamp.