aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Greig <[email protected]>2023-11-18 19:37:56 +0000
committerAdam Greig <[email protected]>2023-11-18 19:37:56 +0000
commit814e096d226b05a439095e51008da83020a24f53 (patch)
tree1286e1b5229238176ac487ec2f122a308c91ce12
parent5bc75578260f4c644cc060e6458a05d7fc0ffb41 (diff)
STM32: Don't enable opamps in new(), wait until configured.
-rw-r--r--embassy-stm32/src/opamp.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/embassy-stm32/src/opamp.rs b/embassy-stm32/src/opamp.rs
index 89db6d14d..a84010839 100644
--- a/embassy-stm32/src/opamp.rs
+++ b/embassy-stm32/src/opamp.rs
@@ -54,19 +54,12 @@ pub struct OpAmp<'d, T: Instance> {
54impl<'d, T: Instance> OpAmp<'d, T> { 54impl<'d, T: Instance> OpAmp<'d, T> {
55 /// Create a new driver instance. 55 /// Create a new driver instance.
56 /// 56 ///
57 /// Enables the OpAmp and configures the speed, but 57 /// Does not enable the opamp, but does set the speed mode on some families.
58 /// does not set any other configuration.
59 pub fn new(opamp: impl Peripheral<P = T> + 'd, #[cfg(opamp_g4)] speed: OpAmpSpeed) -> Self { 58 pub fn new(opamp: impl Peripheral<P = T> + 'd, #[cfg(opamp_g4)] speed: OpAmpSpeed) -> Self {
60 into_ref!(opamp); 59 into_ref!(opamp);
61 60
62 #[cfg(opamp_f3)]
63 T::regs().opampcsr().modify(|w| {
64 w.set_opampen(true);
65 });
66
67 #[cfg(opamp_g4)] 61 #[cfg(opamp_g4)]
68 T::regs().opamp_csr().modify(|w| { 62 T::regs().opamp_csr().modify(|w| {
69 w.set_opaen(true);
70 w.set_opahsm(speed.into()); 63 w.set_opahsm(speed.into());
71 }); 64 });
72 65
@@ -74,7 +67,7 @@ impl<'d, T: Instance> OpAmp<'d, T> {
74 } 67 }
75 68
76 /// Configure the OpAmp as a buffer for the provided input pin, 69 /// Configure the OpAmp as a buffer for the provided input pin,
77 /// outputting to the provided output pin. 70 /// outputting to the provided output pin, and enable the opamp.
78 /// 71 ///
79 /// The input pin is configured for analogue mode but not consumed, 72 /// The input pin is configured for analogue mode but not consumed,
80 /// so it may subsequently be used for ADC or comparator inputs. 73 /// so it may subsequently be used for ADC or comparator inputs.
@@ -129,7 +122,7 @@ impl<'d, T: Instance> OpAmp<'d, T> {
129 } 122 }
130 123
131 /// Configure the OpAmp as a buffer for the provided input pin, 124 /// Configure the OpAmp as a buffer for the provided input pin,
132 /// with the output only used internally. 125 /// with the output only used internally, and enable the opamp.
133 /// 126 ///
134 /// The input pin is configured for analogue mode but not consumed, 127 /// The input pin is configured for analogue mode but not consumed,
135 /// so it may be subsequently used for ADC or comparator inputs. 128 /// so it may be subsequently used for ADC or comparator inputs.