aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorDaniel Nilsson <[email protected]>2025-11-13 14:51:00 +0100
committerDaniel Nilsson <[email protected]>2025-11-14 08:58:19 +0100
commit7e5cd16ca79cf36d2c28c7e2fe35642a27f18b72 (patch)
tree44e174917fc771dd74ec922880cb2b060198b5e5 /embassy-stm32
parent578679771eafe93ccc0e8de8fc3f97a5b991b02c (diff)
correcting channel on interval Vbat, adding Vbat resistor disable to preserve current when not sampling.
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/src/adc/v3.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs
index 78b497727..c65357aff 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 }
@@ -582,6 +582,24 @@ impl<'d, T: Instance> Adc<'d, T> {
582 Vbat {} 582 Vbat {}
583 } 583 }
584 584
585 pub fn disable_vbat(&self) {
586 cfg_if! {
587 if #[cfg(any(adc_g0, adc_u0))] {
588 T::regs().ccr().modify(|reg| {
589 reg.set_vbaten(false);
590 });
591 } else if #[cfg(any(adc_h5, adc_h7rs))] {
592 T::common_regs().ccr().modify(|reg| {
593 reg.set_vbaten(false);
594 });
595 } else {
596 T::common_regs().ccr().modify(|reg| {
597 reg.set_ch18sel(false);
598 });
599 }
600 }
601 }
602
585 /* 603 /*
586 /// Convert a raw sample from the `Temperature` to deg C 604 /// Convert a raw sample from the `Temperature` to deg C
587 pub fn to_degrees_centigrade(sample: u16) -> f32 { 605 pub fn to_degrees_centigrade(sample: u16) -> f32 {