From 84f5deee92ad9068a2e96945a4bd740d85d140f9 Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Sun, 21 Feb 2021 17:01:24 +0000 Subject: [PATCH 1/3] Support vddhdiv5 for saadc --- nrf-hal-common/src/saadc.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nrf-hal-common/src/saadc.rs b/nrf-hal-common/src/saadc.rs index e650b180..c69e9f9f 100644 --- a/nrf-hal-common/src/saadc.rs +++ b/nrf-hal-common/src/saadc.rs @@ -178,6 +178,8 @@ where 7 => self.0.ch[0].pselp.write(|w| w.pselp().analog_input7()), #[cfg(not(feature = "9160"))] 8 => self.0.ch[0].pselp.write(|w| w.pselp().vdd()), + #[cfg(not(feature = "9160"))] + 13 => self.0.ch[0].pselp.write(|w| w.pselp().vddhdiv5()), // This can never happen the only analog pins have already been defined // PAY CLOSE ATTENTION TO ANY CHANGES TO THIS IMPL OR THE `channel_mappings!` MACRO _ => unsafe { unreachable_unchecked() }, @@ -265,3 +267,16 @@ impl Channel for InternalVdd { #[cfg(not(feature = "9160"))] /// Channel that doesn't sample a pin, but the internal VDD voltage. pub struct InternalVdd; + +#[cfg(not(feature = "9160"))] +impl Channel for InternalVddHdiv5 { + type ID = u8; + + fn channel() -> >::ID { + 13 + } +} + +#[cfg(not(feature = "9160"))] +/// Channel that doesn't sample a pin, but the internal VDD voltage. +pub struct InternalVddHdiv5; From 9db7dfc087a5c54fb29e7c937de22d598966079b Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Sun, 21 Feb 2021 17:32:01 +0000 Subject: [PATCH 2/3] Support vddhdiv5 only on 52833 and 52840 --- nrf-hal-common/src/saadc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nrf-hal-common/src/saadc.rs b/nrf-hal-common/src/saadc.rs index c69e9f9f..3725ae5a 100644 --- a/nrf-hal-common/src/saadc.rs +++ b/nrf-hal-common/src/saadc.rs @@ -178,7 +178,7 @@ where 7 => self.0.ch[0].pselp.write(|w| w.pselp().analog_input7()), #[cfg(not(feature = "9160"))] 8 => self.0.ch[0].pselp.write(|w| w.pselp().vdd()), - #[cfg(not(feature = "9160"))] + #[cfg(any(feature = "52833", feature = "52840"))] 13 => self.0.ch[0].pselp.write(|w| w.pselp().vddhdiv5()), // This can never happen the only analog pins have already been defined // PAY CLOSE ATTENTION TO ANY CHANGES TO THIS IMPL OR THE `channel_mappings!` MACRO @@ -268,7 +268,7 @@ impl Channel for InternalVdd { /// Channel that doesn't sample a pin, but the internal VDD voltage. pub struct InternalVdd; -#[cfg(not(feature = "9160"))] +#[cfg(any(feature = "52833", feature = "52840"))] impl Channel for InternalVddHdiv5 { type ID = u8; @@ -277,6 +277,6 @@ impl Channel for InternalVddHdiv5 { } } -#[cfg(not(feature = "9160"))] +#[cfg(any(feature = "52833", feature = "52840"))] /// Channel that doesn't sample a pin, but the internal VDD voltage. pub struct InternalVddHdiv5; From 4e00bac1c778f8c41a4393e0f581528fb464e1c7 Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Fri, 26 Feb 2021 14:50:50 +0000 Subject: [PATCH 3/3] Update nrf-hal-common/src/saadc.rs Co-authored-by: Jonas Schievink --- nrf-hal-common/src/saadc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nrf-hal-common/src/saadc.rs b/nrf-hal-common/src/saadc.rs index 3725ae5a..505fa7e7 100644 --- a/nrf-hal-common/src/saadc.rs +++ b/nrf-hal-common/src/saadc.rs @@ -278,5 +278,5 @@ impl Channel for InternalVddHdiv5 { } #[cfg(any(feature = "52833", feature = "52840"))] -/// Channel that doesn't sample a pin, but the internal VDD voltage. +/// The voltage on the VDDH pin, divided by 5. pub struct InternalVddHdiv5;