Merge pull request #1673 from pennae/rp-disable-adc
rp: disable adc hardware on Adc drop
This commit is contained in:
		@@ -81,6 +81,16 @@ pub struct Adc<'d, M: Mode> {
 | 
				
			|||||||
    phantom: PhantomData<(&'d ADC, M)>,
 | 
					    phantom: PhantomData<(&'d ADC, M)>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl<'d, M: Mode> Drop for Adc<'d, M> {
 | 
				
			||||||
 | 
					    fn drop(&mut self) {
 | 
				
			||||||
 | 
					        let r = Self::regs();
 | 
				
			||||||
 | 
					        // disable ADC. leaving it enabled comes with a ~150µA static
 | 
				
			||||||
 | 
					        // current draw. the temperature sensor has already been disabled
 | 
				
			||||||
 | 
					        // by the temperature-reading methods, so we don't need to touch that.
 | 
				
			||||||
 | 
					        r.cs().write(|w| w.set_en(false));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<'d, M: Mode> Adc<'d, M> {
 | 
					impl<'d, M: Mode> Adc<'d, M> {
 | 
				
			||||||
    #[inline]
 | 
					    #[inline]
 | 
				
			||||||
    fn regs() -> pac::adc::Adc {
 | 
					    fn regs() -> pac::adc::Adc {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user