aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-01-10 18:06:47 +0100
committerDario Nieuwenhuis <[email protected]>2024-01-10 18:06:47 +0100
commit3bc6e414f7b1d4b4d138c7e90f7f9e85a7ca2885 (patch)
tree4e0881c6724c428a8bb5272196a30e82d124b01e
parent38a927175bce522dbf43ab67c60465ce19b46828 (diff)
stm32: update metapac.
-rw-r--r--embassy-stm32/Cargo.toml4
-rw-r--r--embassy-stm32/src/opamp.rs59
-rw-r--r--embassy-stm32/src/sai/mod.rs9
3 files changed, 22 insertions, 50 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 2e5bf0e24..a798a8c5f 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -57,7 +57,7 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
57rand_core = "0.6.3" 57rand_core = "0.6.3"
58sdio-host = "0.5.0" 58sdio-host = "0.5.0"
59critical-section = "1.1" 59critical-section = "1.1"
60stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-d5096244fa0b7992454a894a2aeaa369ae674222" } 60stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-656ecf6714fa34fdfb3b3e2f2cd034bffed3f303" }
61vcell = "0.1.3" 61vcell = "0.1.3"
62bxcan = "0.7.0" 62bxcan = "0.7.0"
63nb = "1.0.0" 63nb = "1.0.0"
@@ -75,7 +75,7 @@ critical-section = { version = "1.1", features = ["std"] }
75[build-dependencies] 75[build-dependencies]
76proc-macro2 = "1.0.36" 76proc-macro2 = "1.0.36"
77quote = "1.0.15" 77quote = "1.0.15"
78stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-d5096244fa0b7992454a894a2aeaa369ae674222", default-features = false, features = ["metadata"]} 78stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-656ecf6714fa34fdfb3b3e2f2cd034bffed3f303", default-features = false, features = ["metadata"]}
79 79
80 80
81[features] 81[features]
diff --git a/embassy-stm32/src/opamp.rs b/embassy-stm32/src/opamp.rs
index df8a78bcc..ae8b3cacc 100644
--- a/embassy-stm32/src/opamp.rs
+++ b/embassy-stm32/src/opamp.rs
@@ -3,6 +3,7 @@
3 3
4use embassy_hal_internal::{into_ref, PeripheralRef}; 4use embassy_hal_internal::{into_ref, PeripheralRef};
5 5
6use crate::pac::opamp::vals::*;
6use crate::Peripheral; 7use crate::Peripheral;
7 8
8/// Gain 9/// Gain
@@ -25,11 +26,11 @@ pub enum OpAmpSpeed {
25} 26}
26 27
27#[cfg(opamp_g4)] 28#[cfg(opamp_g4)]
28impl From<OpAmpSpeed> for crate::pac::opamp::vals::OpampCsrOpahsm { 29impl From<OpAmpSpeed> for crate::pac::opamp::vals::Opahsm {
29 fn from(v: OpAmpSpeed) -> Self { 30 fn from(v: OpAmpSpeed) -> Self {
30 match v { 31 match v {
31 OpAmpSpeed::Normal => crate::pac::opamp::vals::OpampCsrOpahsm::NORMAL, 32 OpAmpSpeed::Normal => crate::pac::opamp::vals::Opahsm::NORMAL,
32 OpAmpSpeed::HighSpeed => crate::pac::opamp::vals::OpampCsrOpahsm::HIGHSPEED, 33 OpAmpSpeed::HighSpeed => crate::pac::opamp::vals::Opahsm::HIGHSPEED,
33 } 34 }
34 } 35 }
35} 36}
@@ -61,7 +62,7 @@ impl<'d, T: Instance> OpAmp<'d, T> {
61 into_ref!(opamp); 62 into_ref!(opamp);
62 63
63 #[cfg(opamp_g4)] 64 #[cfg(opamp_g4)]
64 T::regs().opamp_csr().modify(|w| { 65 T::regs().csr().modify(|w| {
65 w.set_opahsm(speed.into()); 66 w.set_opahsm(speed.into());
66 }); 67 });
67 68
@@ -97,25 +98,15 @@ impl<'d, T: Instance> OpAmp<'d, T> {
97 OpAmpGain::Mul16 => (0b10, 0b11), 98 OpAmpGain::Mul16 => (0b10, 0b11),
98 }; 99 };
99 100
100 #[cfg(opamp_f3)] 101 T::regs().csr().modify(|w| {
101 T::regs().opampcsr().modify(|w| { 102 w.set_vp_sel(VpSel::from_bits(in_pin.channel()));
102 w.set_vp_sel(in_pin.channel()); 103 w.set_vm_sel(VmSel::from_bits(vm_sel));
103 w.set_vm_sel(vm_sel); 104 w.set_pga_gain(PgaGain::from_bits(pga_gain));
104 w.set_pga_gain(pga_gain); 105 #[cfg(opamp_g4)]
106 w.set_opaintoen(Opaintoen::OUTPUTPIN);
105 w.set_opampen(true); 107 w.set_opampen(true);
106 }); 108 });
107 109
108 #[cfg(opamp_g4)]
109 T::regs().opamp_csr().modify(|w| {
110 use crate::pac::opamp::vals::*;
111
112 w.set_vp_sel(OpampCsrVpSel::from_bits(in_pin.channel()));
113 w.set_vm_sel(OpampCsrVmSel::from_bits(vm_sel));
114 w.set_pga_gain(OpampCsrPgaGain::from_bits(pga_gain));
115 w.set_opaintoen(OpampCsrOpaintoen::OUTPUTPIN);
116 w.set_opaen(true);
117 });
118
119 OpAmpOutput { _inner: self } 110 OpAmpOutput { _inner: self }
120 } 111 }
121 112
@@ -144,13 +135,13 @@ impl<'d, T: Instance> OpAmp<'d, T> {
144 OpAmpGain::Mul16 => (0b10, 0b11), 135 OpAmpGain::Mul16 => (0b10, 0b11),
145 }; 136 };
146 137
147 T::regs().opamp_csr().modify(|w| { 138 T::regs().csr().modify(|w| {
148 use crate::pac::opamp::vals::*; 139 use crate::pac::opamp::vals::*;
149 w.set_vp_sel(OpampCsrVpSel::from_bits(pin.channel())); 140 w.set_vp_sel(VpSel::from_bits(pin.channel()));
150 w.set_vm_sel(OpampCsrVmSel::from_bits(vm_sel)); 141 w.set_vm_sel(VmSel::from_bits(vm_sel));
151 w.set_pga_gain(OpampCsrPgaGain::from_bits(pga_gain)); 142 w.set_pga_gain(PgaGain::from_bits(pga_gain));
152 w.set_opaintoen(OpampCsrOpaintoen::ADCCHANNEL); 143 w.set_opaintoen(Opaintoen::ADCCHANNEL);
153 w.set_opaen(true); 144 w.set_opampen(true);
154 }); 145 });
155 146
156 OpAmpInternalOutput { _inner: self } 147 OpAmpInternalOutput { _inner: self }
@@ -159,29 +150,17 @@ impl<'d, T: Instance> OpAmp<'d, T> {
159 150
160impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> { 151impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> {
161 fn drop(&mut self) { 152 fn drop(&mut self) {
162 #[cfg(opamp_f3)] 153 T::regs().csr().modify(|w| {
163 T::regs().opampcsr().modify(|w| {
164 w.set_opampen(false); 154 w.set_opampen(false);
165 }); 155 });
166
167 #[cfg(opamp_g4)]
168 T::regs().opamp_csr().modify(|w| {
169 w.set_opaen(false);
170 });
171 } 156 }
172} 157}
173 158
174impl<'d, T: Instance> Drop for OpAmpInternalOutput<'d, T> { 159impl<'d, T: Instance> Drop for OpAmpInternalOutput<'d, T> {
175 fn drop(&mut self) { 160 fn drop(&mut self) {
176 #[cfg(opamp_f3)] 161 T::regs().csr().modify(|w| {
177 T::regs().opampcsr().modify(|w| {
178 w.set_opampen(false); 162 w.set_opampen(false);
179 }); 163 });
180
181 #[cfg(opamp_g4)]
182 T::regs().opamp_csr().modify(|w| {
183 w.set_opaen(false);
184 });
185 } 164 }
186} 165}
187 166
diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs
index ef8802184..5e647612c 100644
--- a/embassy-stm32/src/sai/mod.rs
+++ b/embassy-stm32/src/sai/mod.rs
@@ -846,14 +846,7 @@ impl<'d, T: Instance, C: Channel, W: word::Word> Sai<'d, T, C, W> {
846 pub fn flush(&mut self) { 846 pub fn flush(&mut self) {
847 let ch = T::REGS.ch(self.sub_block as usize); 847 let ch = T::REGS.ch(self.sub_block as usize);
848 ch.cr1().modify(|w| w.set_saien(false)); 848 ch.cr1().modify(|w| w.set_saien(false));
849 #[cfg(any(sai_v1, sai_v2))] 849 ch.cr2().modify(|w| w.set_fflush(true));
850 {
851 ch.cr2().modify(|w| w.set_fflush(vals::Fflush::FLUSH));
852 }
853 #[cfg(any(sai_v3, sai_v4))]
854 {
855 ch.cr2().modify(|w| w.set_fflush(true));
856 }
857 ch.cr1().modify(|w| w.set_saien(true)); 850 ch.cr1().modify(|w| w.set_saien(true));
858 } 851 }
859 852