aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-11-14 20:03:22 +0000
committerGitHub <[email protected]>2025-11-14 20:03:22 +0000
commit435267941c5e585c0de714e3251f3d28426bcdca (patch)
tree09c7bb3ae9c283af1b050e302663717cfd913829
parent6c659b613d209b2c150199f548bcdf2dc3eb0f36 (diff)
parent34b5b4eb92de4c135156c52ce3d5b59c14a5c841 (diff)
Merge pull request #4878 from Dectron-AB/adc-ch-fixes
Correcting channel numbers for internal voltage measurements etc.
-rw-r--r--embassy-stm32/CHANGELOG.md2
-rw-r--r--embassy-stm32/src/adc/v3.rs22
2 files changed, 22 insertions, 2 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md
index 8bd930e79..9153e15b9 100644
--- a/embassy-stm32/CHANGELOG.md
+++ b/embassy-stm32/CHANGELOG.md
@@ -58,6 +58,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
58- adc: reogranize and cleanup somewhat. require sample_time to be passed on conversion 58- adc: reogranize and cleanup somewhat. require sample_time to be passed on conversion
59- fix: stm32/i2c v2 slave: prevent misaligned reads, error false positives, and incorrect counts of bytes read/written 59- fix: stm32/i2c v2 slave: prevent misaligned reads, error false positives, and incorrect counts of bytes read/written
60- feat: add flash support for c0 family ([#4874](https://github.com/embassy-rs/embassy/pull/4874)) 60- feat: add flash support for c0 family ([#4874](https://github.com/embassy-rs/embassy/pull/4874))
61- fix: fixing channel numbers on vbat and vddcore for adc on adc
62- adc: adding disable to vbat
61 63
62## 0.4.0 - 2025-08-26 64## 0.4.0 - 2025-08-26
63 65
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs
index 288bd77ce..81eb1e3ee 100644
--- a/embassy-stm32/src/adc/v3.rs
+++ b/embassy-stm32/src/adc/v3.rs
@@ -65,7 +65,7 @@ impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T {
65} 65}
66#[cfg(any(adc_h5, adc_h7rs))] 66#[cfg(any(adc_h5, adc_h7rs))]
67impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T { 67impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T {
68 const CHANNEL: u8 = 2; 68 const CHANNEL: u8 = 16;
69} 69}
70#[cfg(adc_u0)] 70#[cfg(adc_u0)]
71impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T { 71impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T {
@@ -82,7 +82,7 @@ cfg_if! {
82 impl<T: Instance> super::AdcChannel<T> for VddCore {} 82 impl<T: Instance> super::AdcChannel<T> for VddCore {}
83 impl<T: Instance> super::SealedAdcChannel<T> for VddCore { 83 impl<T: Instance> super::SealedAdcChannel<T> for VddCore {
84 fn channel(&self) -> u8 { 84 fn channel(&self) -> u8 {
85 6 85 17
86 } 86 }
87 } 87 }
88 } 88 }
@@ -575,6 +575,24 @@ impl<'d, T: Instance> Adc<'d, T> {
575 Vbat {} 575 Vbat {}
576 } 576 }
577 577
578 pub fn disable_vbat(&self) {
579 cfg_if! {
580 if #[cfg(any(adc_g0, adc_u0))] {
581 T::regs().ccr().modify(|reg| {
582 reg.set_vbaten(false);
583 });
584 } else if #[cfg(any(adc_h5, adc_h7rs))] {
585 T::common_regs().ccr().modify(|reg| {
586 reg.set_vbaten(false);
587 });
588 } else {
589 T::common_regs().ccr().modify(|reg| {
590 reg.set_ch18sel(false);
591 });
592 }
593 }
594 }
595
578 /* 596 /*
579 /// Convert a raw sample from the `Temperature` to deg C 597 /// Convert a raw sample from the `Temperature` to deg C
580 pub fn to_degrees_centigrade(sample: u16) -> f32 { 598 pub fn to_degrees_centigrade(sample: u16) -> f32 {