diff options
| author | Lachezar Lechev <[email protected]> | 2023-02-28 09:22:38 +0200 |
|---|---|---|
| committer | Lachezar Lechev <[email protected]> | 2023-02-28 09:22:38 +0200 |
| commit | 5cb0c8cc01583137ccb8b6a64a452b52316b626f (patch) | |
| tree | d40ae4a86d23c61341a6aa57ea2377b4f9f4a0cc | |
| parent | 28b695e7c9b134cafcdfb5897d26b00e396c7776 (diff) | |
fix: rp - disable Pull-down/up resistors for ADC read
Signed-off-by: Lachezar Lechev <[email protected]>
| -rw-r--r-- | embassy-rp/src/adc.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs index 025c6f917..145ba9c59 100644 --- a/embassy-rp/src/adc.rs +++ b/embassy-rp/src/adc.rs | |||
| @@ -7,6 +7,7 @@ use embassy_hal_common::into_ref; | |||
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 8 | use embedded_hal_02::adc::{Channel, OneShot}; | 8 | use embedded_hal_02::adc::{Channel, OneShot}; |
| 9 | 9 | ||
| 10 | use crate::gpio::Pin; | ||
| 10 | use crate::interrupt::{self, InterruptExt}; | 11 | use crate::interrupt::{self, InterruptExt}; |
| 11 | use crate::peripherals::ADC; | 12 | use crate::peripherals::ADC; |
| 12 | use crate::{pac, peripherals, Peripheral}; | 13 | use crate::{pac, peripherals, Peripheral}; |
| @@ -90,9 +91,17 @@ impl<'d> Adc<'d> { | |||
| 90 | } | 91 | } |
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | pub async fn read<PIN: Channel<Adc<'d>, ID = u8>>(&mut self, _pin: &mut PIN) -> u16 { | 94 | pub async fn read<PIN: Channel<Adc<'d>, ID = u8> + Pin>(&mut self, pin: &mut PIN) -> u16 { |
| 94 | let r = Self::regs(); | 95 | let r = Self::regs(); |
| 95 | unsafe { | 96 | unsafe { |
| 97 | // disable pull-down and pull-up resistors | ||
| 98 | // pull-down resistors are enabled by default | ||
| 99 | pin.pad_ctrl().modify(|w| { | ||
| 100 | w.set_ie(true); | ||
| 101 | let (pu, pd) = (false, false); | ||
| 102 | w.set_pue(pu); | ||
| 103 | w.set_pde(pd); | ||
| 104 | }); | ||
| 96 | r.cs().modify(|w| { | 105 | r.cs().modify(|w| { |
| 97 | w.set_ainsel(PIN::channel()); | 106 | w.set_ainsel(PIN::channel()); |
| 98 | w.set_start_once(true) | 107 | w.set_start_once(true) |
