Skip to content

Commit 4352679

Browse files
authored
Merge pull request #4878 from Dectron-AB/adc-ch-fixes
Correcting channel numbers for internal voltage measurements etc.
2 parents 6c659b6 + 34b5b4e commit 4352679

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

embassy-stm32/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5858
- adc: reogranize and cleanup somewhat. require sample_time to be passed on conversion
5959
- fix: stm32/i2c v2 slave: prevent misaligned reads, error false positives, and incorrect counts of bytes read/written
6060
- 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
6163

6264
## 0.4.0 - 2025-08-26
6365

embassy-stm32/src/adc/v3.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T {
6565
}
6666
#[cfg(any(adc_h5, adc_h7rs))]
6767
impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T {
68-
const CHANNEL: u8 = 2;
68+
const CHANNEL: u8 = 16;
6969
}
7070
#[cfg(adc_u0)]
7171
impl<T: Instance> super::SealedSpecialConverter<super::Vbat> for T {
@@ -82,7 +82,7 @@ cfg_if! {
8282
impl<T: Instance> super::AdcChannel<T> for VddCore {}
8383
impl<T: Instance> super::SealedAdcChannel<T> for VddCore {
8484
fn channel(&self) -> u8 {
85-
6
85+
17
8686
}
8787
}
8888
}
@@ -575,6 +575,24 @@ impl<'d, T: Instance> Adc<'d, T> {
575575
Vbat {}
576576
}
577577

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+
578596
/*
579597
/// Convert a raw sample from the `Temperature` to deg C
580598
pub fn to_degrees_centigrade(sample: u16) -> f32 {

0 commit comments

Comments
 (0)