aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-07-20 14:21:40 +0000
committerGitHub <[email protected]>2023-07-20 14:21:40 +0000
commit4d1d125f4157084668a949f9bc24e4417628f9fe (patch)
treef9012cc261feca20f170152b2cfabf41b79633e9
parent3382ca1a5429504c56c360e99ec09f4f641948a2 (diff)
parenta3d4ae85b021b888a78ef2214a7ecae0a49741c4 (diff)
Merge pull request #1673 from pennae/rp-disable-adc
rp: disable adc hardware on Adc drop
-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 {