nrf52811_pac/saadc/ch/
pseln.rs

1#[doc = "Register `PSELN` reader"]
2pub struct R(crate::R<PSELN_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PSELN_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PSELN_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PSELN_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PSELN` writer"]
17pub struct W(crate::W<PSELN_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PSELN_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<PSELN_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PSELN_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `PSELN` reader - Analog negative input, enables differential channel"]
38pub type PSELN_R = crate::FieldReader<u8, PSELN_A>;
39#[doc = "Analog negative input, enables differential channel\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum PSELN_A {
43    #[doc = "0: Not connected"]
44    NC = 0,
45    #[doc = "1: AIN0"]
46    ANALOG_INPUT0 = 1,
47    #[doc = "2: AIN1"]
48    ANALOG_INPUT1 = 2,
49    #[doc = "3: AIN2"]
50    ANALOG_INPUT2 = 3,
51    #[doc = "4: AIN3"]
52    ANALOG_INPUT3 = 4,
53    #[doc = "5: AIN4"]
54    ANALOG_INPUT4 = 5,
55    #[doc = "6: AIN5"]
56    ANALOG_INPUT5 = 6,
57    #[doc = "7: AIN6"]
58    ANALOG_INPUT6 = 7,
59    #[doc = "8: AIN7"]
60    ANALOG_INPUT7 = 8,
61    #[doc = "9: VDD"]
62    VDD = 9,
63}
64impl From<PSELN_A> for u8 {
65    #[inline(always)]
66    fn from(variant: PSELN_A) -> Self {
67        variant as _
68    }
69}
70impl PSELN_R {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> Option<PSELN_A> {
74        match self.bits {
75            0 => Some(PSELN_A::NC),
76            1 => Some(PSELN_A::ANALOG_INPUT0),
77            2 => Some(PSELN_A::ANALOG_INPUT1),
78            3 => Some(PSELN_A::ANALOG_INPUT2),
79            4 => Some(PSELN_A::ANALOG_INPUT3),
80            5 => Some(PSELN_A::ANALOG_INPUT4),
81            6 => Some(PSELN_A::ANALOG_INPUT5),
82            7 => Some(PSELN_A::ANALOG_INPUT6),
83            8 => Some(PSELN_A::ANALOG_INPUT7),
84            9 => Some(PSELN_A::VDD),
85            _ => None,
86        }
87    }
88    #[doc = "Checks if the value of the field is `NC`"]
89    #[inline(always)]
90    pub fn is_nc(&self) -> bool {
91        *self == PSELN_A::NC
92    }
93    #[doc = "Checks if the value of the field is `ANALOG_INPUT0`"]
94    #[inline(always)]
95    pub fn is_analog_input0(&self) -> bool {
96        *self == PSELN_A::ANALOG_INPUT0
97    }
98    #[doc = "Checks if the value of the field is `ANALOG_INPUT1`"]
99    #[inline(always)]
100    pub fn is_analog_input1(&self) -> bool {
101        *self == PSELN_A::ANALOG_INPUT1
102    }
103    #[doc = "Checks if the value of the field is `ANALOG_INPUT2`"]
104    #[inline(always)]
105    pub fn is_analog_input2(&self) -> bool {
106        *self == PSELN_A::ANALOG_INPUT2
107    }
108    #[doc = "Checks if the value of the field is `ANALOG_INPUT3`"]
109    #[inline(always)]
110    pub fn is_analog_input3(&self) -> bool {
111        *self == PSELN_A::ANALOG_INPUT3
112    }
113    #[doc = "Checks if the value of the field is `ANALOG_INPUT4`"]
114    #[inline(always)]
115    pub fn is_analog_input4(&self) -> bool {
116        *self == PSELN_A::ANALOG_INPUT4
117    }
118    #[doc = "Checks if the value of the field is `ANALOG_INPUT5`"]
119    #[inline(always)]
120    pub fn is_analog_input5(&self) -> bool {
121        *self == PSELN_A::ANALOG_INPUT5
122    }
123    #[doc = "Checks if the value of the field is `ANALOG_INPUT6`"]
124    #[inline(always)]
125    pub fn is_analog_input6(&self) -> bool {
126        *self == PSELN_A::ANALOG_INPUT6
127    }
128    #[doc = "Checks if the value of the field is `ANALOG_INPUT7`"]
129    #[inline(always)]
130    pub fn is_analog_input7(&self) -> bool {
131        *self == PSELN_A::ANALOG_INPUT7
132    }
133    #[doc = "Checks if the value of the field is `VDD`"]
134    #[inline(always)]
135    pub fn is_vdd(&self) -> bool {
136        *self == PSELN_A::VDD
137    }
138}
139#[doc = "Field `PSELN` writer - Analog negative input, enables differential channel"]
140pub type PSELN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PSELN_SPEC, u8, PSELN_A, 5, O>;
141impl<'a, const O: u8> PSELN_W<'a, O> {
142    #[doc = "Not connected"]
143    #[inline(always)]
144    pub fn nc(self) -> &'a mut W {
145        self.variant(PSELN_A::NC)
146    }
147    #[doc = "AIN0"]
148    #[inline(always)]
149    pub fn analog_input0(self) -> &'a mut W {
150        self.variant(PSELN_A::ANALOG_INPUT0)
151    }
152    #[doc = "AIN1"]
153    #[inline(always)]
154    pub fn analog_input1(self) -> &'a mut W {
155        self.variant(PSELN_A::ANALOG_INPUT1)
156    }
157    #[doc = "AIN2"]
158    #[inline(always)]
159    pub fn analog_input2(self) -> &'a mut W {
160        self.variant(PSELN_A::ANALOG_INPUT2)
161    }
162    #[doc = "AIN3"]
163    #[inline(always)]
164    pub fn analog_input3(self) -> &'a mut W {
165        self.variant(PSELN_A::ANALOG_INPUT3)
166    }
167    #[doc = "AIN4"]
168    #[inline(always)]
169    pub fn analog_input4(self) -> &'a mut W {
170        self.variant(PSELN_A::ANALOG_INPUT4)
171    }
172    #[doc = "AIN5"]
173    #[inline(always)]
174    pub fn analog_input5(self) -> &'a mut W {
175        self.variant(PSELN_A::ANALOG_INPUT5)
176    }
177    #[doc = "AIN6"]
178    #[inline(always)]
179    pub fn analog_input6(self) -> &'a mut W {
180        self.variant(PSELN_A::ANALOG_INPUT6)
181    }
182    #[doc = "AIN7"]
183    #[inline(always)]
184    pub fn analog_input7(self) -> &'a mut W {
185        self.variant(PSELN_A::ANALOG_INPUT7)
186    }
187    #[doc = "VDD"]
188    #[inline(always)]
189    pub fn vdd(self) -> &'a mut W {
190        self.variant(PSELN_A::VDD)
191    }
192}
193impl R {
194    #[doc = "Bits 0:4 - Analog negative input, enables differential channel"]
195    #[inline(always)]
196    pub fn pseln(&self) -> PSELN_R {
197        PSELN_R::new((self.bits & 0x1f) as u8)
198    }
199}
200impl W {
201    #[doc = "Bits 0:4 - Analog negative input, enables differential channel"]
202    #[inline(always)]
203    pub fn pseln(&mut self) -> PSELN_W<0> {
204        PSELN_W::new(self)
205    }
206    #[doc = "Writes raw bits to the register."]
207    #[inline(always)]
208    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
209        self.0.bits(bits);
210        self
211    }
212}
213#[doc = "Description cluster: Input negative pin selection for CH\\[n\\]\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pseln](index.html) module"]
214pub struct PSELN_SPEC;
215impl crate::RegisterSpec for PSELN_SPEC {
216    type Ux = u32;
217}
218#[doc = "`read()` method returns [pseln::R](R) reader structure"]
219impl crate::Readable for PSELN_SPEC {
220    type Reader = R;
221}
222#[doc = "`write(|w| ..)` method takes [pseln::W](W) writer structure"]
223impl crate::Writable for PSELN_SPEC {
224    type Writer = W;
225}
226#[doc = "`reset()` method sets PSELN to value 0"]
227impl crate::Resettable for PSELN_SPEC {
228    #[inline(always)]
229    fn reset_value() -> Self::Ux {
230        0
231    }
232}