aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorChris Storah <[email protected]>2025-07-23 12:53:34 +1000
committerChris Storah <[email protected]>2025-07-23 12:53:34 +1000
commit88e1d61654b44dc90fe26135cdbb37b3f2a296f4 (patch)
tree092a6719113d086a8effd3288b65feac6880e33f /embassy-stm32
parentbb29fdd3e2b864325bbdea53810843cc2447d3c3 (diff)
parenteb15a555196050166acdf53db02f1d0fffbfb2be (diff)
Merge branch 'obe1line-stm32c071' of github.com:obe1line/embassy into obe1line-stm32c071
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/Cargo.toml2
-rw-r--r--embassy-stm32/src/adc/adc4.rs4
-rw-r--r--embassy-stm32/src/adc/c0.rs3
-rw-r--r--embassy-stm32/src/adc/f3_v1_1.rs2
-rw-r--r--embassy-stm32/src/adc/v3.rs19
-rw-r--r--embassy-stm32/src/adc/v4.rs1
-rw-r--r--embassy-stm32/src/low_power.rs3
7 files changed, 31 insertions, 3 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 8f3a471af..38254ee40 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -57,7 +57,7 @@ embassy-hal-internal = { version = "0.3.0", path = "../embassy-hal-internal", fe
57embassy-embedded-hal = { version = "0.3.1", path = "../embassy-embedded-hal", default-features = false } 57embassy-embedded-hal = { version = "0.3.1", path = "../embassy-embedded-hal", default-features = false }
58embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } 58embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" }
59embassy-usb-driver = { version = "0.2.0", path = "../embassy-usb-driver" } 59embassy-usb-driver = { version = "0.2.0", path = "../embassy-usb-driver" }
60embassy-usb-synopsys-otg = { version = "0.2.0", path = "../embassy-usb-synopsys-otg" } 60embassy-usb-synopsys-otg = { version = "0.3.0", path = "../embassy-usb-synopsys-otg" }
61embassy-executor = { version = "0.7.0", path = "../embassy-executor", optional = true } 61embassy-executor = { version = "0.7.0", path = "../embassy-executor", optional = true }
62 62
63embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } 63embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
diff --git a/embassy-stm32/src/adc/adc4.rs b/embassy-stm32/src/adc/adc4.rs
index 98483489f..31cbdc0d7 100644
--- a/embassy-stm32/src/adc/adc4.rs
+++ b/embassy-stm32/src/adc/adc4.rs
@@ -76,12 +76,14 @@ impl<T: Instance> SealedAdcChannel<T> for Vcore {
76 } 76 }
77} 77}
78 78
79#[derive(Copy, Clone)]
79pub enum DacChannel { 80pub enum DacChannel {
80 OUT1, 81 OUT1,
81 OUT2, 82 OUT2,
82} 83}
83 84
84/// Number of samples used for averaging. 85/// Number of samples used for averaging.
86#[derive(Copy, Clone)]
85pub enum Averaging { 87pub enum Averaging {
86 Disabled, 88 Disabled,
87 Samples2, 89 Samples2,
@@ -187,7 +189,7 @@ pub struct Adc4<'d, T: Instance> {
187 adc: crate::Peri<'d, T>, 189 adc: crate::Peri<'d, T>,
188} 190}
189 191
190#[derive(Debug)] 192#[derive(Copy, Clone, Debug)]
191pub enum Adc4Error { 193pub enum Adc4Error {
192 InvalidSequence, 194 InvalidSequence,
193 DMAError, 195 DMAError,
diff --git a/embassy-stm32/src/adc/c0.rs b/embassy-stm32/src/adc/c0.rs
index 936ad7413..f5870801e 100644
--- a/embassy-stm32/src/adc/c0.rs
+++ b/embassy-stm32/src/adc/c0.rs
@@ -48,7 +48,7 @@ impl<T: Instance> SealedAdcChannel<T> for Temperature {
48 } 48 }
49} 49}
50 50
51#[derive(Debug)] 51#[derive(Copy, Clone, Debug)]
52pub enum Prescaler { 52pub enum Prescaler {
53 NotDivided, 53 NotDivided,
54 DividedBy2, 54 DividedBy2,
@@ -138,6 +138,7 @@ impl<'a> defmt::Format for Prescaler {
138/// Number of samples used for averaging. 138/// Number of samples used for averaging.
139/// TODO: Implement hardware averaging setting. 139/// TODO: Implement hardware averaging setting.
140#[allow(unused)] 140#[allow(unused)]
141#[derive(Copy, Clone)]
141pub enum Averaging { 142pub enum Averaging {
142 Disabled, 143 Disabled,
143 Samples2, 144 Samples2,
diff --git a/embassy-stm32/src/adc/f3_v1_1.rs b/embassy-stm32/src/adc/f3_v1_1.rs
index 944e971bb..84613078c 100644
--- a/embassy-stm32/src/adc/f3_v1_1.rs
+++ b/embassy-stm32/src/adc/f3_v1_1.rs
@@ -17,6 +17,7 @@ pub const VDDA_CALIB_MV: u32 = 3300;
17pub const ADC_MAX: u32 = (1 << 12) - 1; 17pub const ADC_MAX: u32 = (1 << 12) - 1;
18pub const VREF_INT: u32 = 1230; 18pub const VREF_INT: u32 = 1230;
19 19
20#[derive(Copy, Clone)]
20pub enum AdcPowerMode { 21pub enum AdcPowerMode {
21 AlwaysOn, 22 AlwaysOn,
22 DelayOff, 23 DelayOff,
@@ -24,6 +25,7 @@ pub enum AdcPowerMode {
24 DelayIdleOff, 25 DelayIdleOff,
25} 26}
26 27
28#[derive(Copy, Clone)]
27pub enum Prescaler { 29pub enum Prescaler {
28 Div1, 30 Div1,
29 Div2, 31 Div2,
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs
index 313244e19..fd74d5318 100644
--- a/embassy-stm32/src/adc/v3.rs
+++ b/embassy-stm32/src/adc/v3.rs
@@ -1,5 +1,7 @@
1use cfg_if::cfg_if; 1use cfg_if::cfg_if;
2use pac::adc::vals::Dmacfg; 2use pac::adc::vals::Dmacfg;
3#[cfg(adc_v3)]
4use pac::adc::vals::{OversamplingRatio, OversamplingShift, Rovsm, Trovs};
3 5
4use super::{ 6use super::{
5 blocking_delay_us, Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel, 7 blocking_delay_us, Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel,
@@ -470,6 +472,23 @@ impl<'d, T: Instance> Adc<'d, T> {
470 T::regs().cfgr2().modify(|reg| reg.set_ovse(enable)); 472 T::regs().cfgr2().modify(|reg| reg.set_ovse(enable));
471 } 473 }
472 474
475 #[cfg(adc_v3)]
476 pub fn enable_regular_oversampling_mode(&mut self, mode: Rovsm, trig_mode: Trovs, enable: bool) {
477 T::regs().cfgr2().modify(|reg| reg.set_trovs(trig_mode));
478 T::regs().cfgr2().modify(|reg| reg.set_rovsm(mode));
479 T::regs().cfgr2().modify(|reg| reg.set_rovse(enable));
480 }
481
482 #[cfg(adc_v3)]
483 pub fn set_oversampling_ratio(&mut self, ratio: OversamplingRatio) {
484 T::regs().cfgr2().modify(|reg| reg.set_ovsr(ratio));
485 }
486
487 #[cfg(adc_v3)]
488 pub fn set_oversampling_shift(&mut self, shift: OversamplingShift) {
489 T::regs().cfgr2().modify(|reg| reg.set_ovss(shift));
490 }
491
473 fn set_channel_sample_time(_ch: u8, sample_time: SampleTime) { 492 fn set_channel_sample_time(_ch: u8, sample_time: SampleTime) {
474 cfg_if! { 493 cfg_if! {
475 if #[cfg(any(adc_g0, adc_u0))] { 494 if #[cfg(any(adc_g0, adc_u0))] {
diff --git a/embassy-stm32/src/adc/v4.rs b/embassy-stm32/src/adc/v4.rs
index 39e0d51b9..b0871019a 100644
--- a/embassy-stm32/src/adc/v4.rs
+++ b/embassy-stm32/src/adc/v4.rs
@@ -142,6 +142,7 @@ impl Prescaler {
142} 142}
143 143
144/// Number of samples used for averaging. 144/// Number of samples used for averaging.
145#[derive(Copy, Clone)]
145pub enum Averaging { 146pub enum Averaging {
146 Disabled, 147 Disabled,
147 Samples2, 148 Samples2,
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs
index 4607eb230..d13df5a6b 100644
--- a/embassy-stm32/src/low_power.rs
+++ b/embassy-stm32/src/low_power.rs
@@ -132,7 +132,10 @@ impl Into<Lpms> for StopMode {
132 fn into(self) -> Lpms { 132 fn into(self) -> Lpms {
133 match self { 133 match self {
134 StopMode::Stop1 => Lpms::STOP1, 134 StopMode::Stop1 => Lpms::STOP1,
135 #[cfg(not(stm32wba))]
135 StopMode::Stop2 => Lpms::STOP2, 136 StopMode::Stop2 => Lpms::STOP2,
137 #[cfg(stm32wba)]
138 StopMode::Stop2 => Lpms::STOP1, // TODO: WBA has no STOP2?
136 } 139 }
137 } 140 }
138} 141}