aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-07-20 15:48:59 +0200
committerpennae <[email protected]>2023-07-20 15:48:59 +0200
commita3d4ae85b021b888a78ef2214a7ecae0a49741c4 (patch)
treef9012cc261feca20f170152b2cfabf41b79633e9 /embassy-rp
parent3382ca1a5429504c56c360e99ec09f4f641948a2 (diff)
rp: disable adc hardware on Adc drop
the adc constantly pulls a small but significant amount of current while the hardware is enabled. this can have quite an effect on sleeping devices that also use the adc.
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/src/adc.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs
index dfa1b877a..95780c068 100644
--- a/embassy-rp/src/adc.rs
+++ b/embassy-rp/src/adc.rs
@@ -81,6 +81,16 @@ pub struct Adc<'d, M: Mode> {
81 phantom: PhantomData<(&'d ADC, M)>, 81 phantom: PhantomData<(&'d ADC, M)>,
82} 82}
83 83
84impl<'d, M: Mode> Drop for Adc<'d, M> {
85 fn drop(&mut self) {
86 let r = Self::regs();
87 // disable ADC. leaving it enabled comes with a ~150µA static
88 // current draw. the temperature sensor has already been disabled
89 // by the temperature-reading methods, so we don't need to touch that.
90 r.cs().write(|w| w.set_en(false));
91 }
92}
93
84impl<'d, M: Mode> Adc<'d, M> { 94impl<'d, M: Mode> Adc<'d, M> {
85 #[inline] 95 #[inline]
86 fn regs() -> pac::adc::Adc { 96 fn regs() -> pac::adc::Adc {