nrf52840_pac/comp/
extrefsel.rs

1#[doc = "Register `EXTREFSEL` reader"]
2pub struct R(crate::R<EXTREFSEL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EXTREFSEL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EXTREFSEL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EXTREFSEL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EXTREFSEL` writer"]
17pub struct W(crate::W<EXTREFSEL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EXTREFSEL_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<EXTREFSEL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EXTREFSEL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EXTREFSEL` reader - External analog reference select"]
38pub type EXTREFSEL_R = crate::FieldReader<u8, EXTREFSEL_A>;
39#[doc = "External analog reference select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum EXTREFSEL_A {
43    #[doc = "0: Use AIN0 as external analog reference"]
44    ANALOG_REFERENCE0 = 0,
45    #[doc = "1: Use AIN1 as external analog reference"]
46    ANALOG_REFERENCE1 = 1,
47    #[doc = "2: Use AIN2 as external analog reference"]
48    ANALOG_REFERENCE2 = 2,
49    #[doc = "3: Use AIN3 as external analog reference"]
50    ANALOG_REFERENCE3 = 3,
51    #[doc = "4: Use AIN4 as external analog reference"]
52    ANALOG_REFERENCE4 = 4,
53    #[doc = "5: Use AIN5 as external analog reference"]
54    ANALOG_REFERENCE5 = 5,
55    #[doc = "6: Use AIN6 as external analog reference"]
56    ANALOG_REFERENCE6 = 6,
57    #[doc = "7: Use AIN7 as external analog reference"]
58    ANALOG_REFERENCE7 = 7,
59}
60impl From<EXTREFSEL_A> for u8 {
61    #[inline(always)]
62    fn from(variant: EXTREFSEL_A) -> Self {
63        variant as _
64    }
65}
66impl EXTREFSEL_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> EXTREFSEL_A {
70        match self.bits {
71            0 => EXTREFSEL_A::ANALOG_REFERENCE0,
72            1 => EXTREFSEL_A::ANALOG_REFERENCE1,
73            2 => EXTREFSEL_A::ANALOG_REFERENCE2,
74            3 => EXTREFSEL_A::ANALOG_REFERENCE3,
75            4 => EXTREFSEL_A::ANALOG_REFERENCE4,
76            5 => EXTREFSEL_A::ANALOG_REFERENCE5,
77            6 => EXTREFSEL_A::ANALOG_REFERENCE6,
78            7 => EXTREFSEL_A::ANALOG_REFERENCE7,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE0`"]
83    #[inline(always)]
84    pub fn is_analog_reference0(&self) -> bool {
85        *self == EXTREFSEL_A::ANALOG_REFERENCE0
86    }
87    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE1`"]
88    #[inline(always)]
89    pub fn is_analog_reference1(&self) -> bool {
90        *self == EXTREFSEL_A::ANALOG_REFERENCE1
91    }
92    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE2`"]
93    #[inline(always)]
94    pub fn is_analog_reference2(&self) -> bool {
95        *self == EXTREFSEL_A::ANALOG_REFERENCE2
96    }
97    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE3`"]
98    #[inline(always)]
99    pub fn is_analog_reference3(&self) -> bool {
100        *self == EXTREFSEL_A::ANALOG_REFERENCE3
101    }
102    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE4`"]
103    #[inline(always)]
104    pub fn is_analog_reference4(&self) -> bool {
105        *self == EXTREFSEL_A::ANALOG_REFERENCE4
106    }
107    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE5`"]
108    #[inline(always)]
109    pub fn is_analog_reference5(&self) -> bool {
110        *self == EXTREFSEL_A::ANALOG_REFERENCE5
111    }
112    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE6`"]
113    #[inline(always)]
114    pub fn is_analog_reference6(&self) -> bool {
115        *self == EXTREFSEL_A::ANALOG_REFERENCE6
116    }
117    #[doc = "Checks if the value of the field is `ANALOG_REFERENCE7`"]
118    #[inline(always)]
119    pub fn is_analog_reference7(&self) -> bool {
120        *self == EXTREFSEL_A::ANALOG_REFERENCE7
121    }
122}
123#[doc = "Field `EXTREFSEL` writer - External analog reference select"]
124pub type EXTREFSEL_W<'a, const O: u8> =
125    crate::FieldWriterSafe<'a, u32, EXTREFSEL_SPEC, u8, EXTREFSEL_A, 3, O>;
126impl<'a, const O: u8> EXTREFSEL_W<'a, O> {
127    #[doc = "Use AIN0 as external analog reference"]
128    #[inline(always)]
129    pub fn analog_reference0(self) -> &'a mut W {
130        self.variant(EXTREFSEL_A::ANALOG_REFERENCE0)
131    }
132    #[doc = "Use AIN1 as external analog reference"]
133    #[inline(always)]
134    pub fn analog_reference1(self) -> &'a mut W {
135        self.variant(EXTREFSEL_A::ANALOG_REFERENCE1)
136    }
137    #[doc = "Use AIN2 as external analog reference"]
138    #[inline(always)]
139    pub fn analog_reference2(self) -> &'a mut W {
140        self.variant(EXTREFSEL_A::ANALOG_REFERENCE2)
141    }
142    #[doc = "Use AIN3 as external analog reference"]
143    #[inline(always)]
144    pub fn analog_reference3(self) -> &'a mut W {
145        self.variant(EXTREFSEL_A::ANALOG_REFERENCE3)
146    }
147    #[doc = "Use AIN4 as external analog reference"]
148    #[inline(always)]
149    pub fn analog_reference4(self) -> &'a mut W {
150        self.variant(EXTREFSEL_A::ANALOG_REFERENCE4)
151    }
152    #[doc = "Use AIN5 as external analog reference"]
153    #[inline(always)]
154    pub fn analog_reference5(self) -> &'a mut W {
155        self.variant(EXTREFSEL_A::ANALOG_REFERENCE5)
156    }
157    #[doc = "Use AIN6 as external analog reference"]
158    #[inline(always)]
159    pub fn analog_reference6(self) -> &'a mut W {
160        self.variant(EXTREFSEL_A::ANALOG_REFERENCE6)
161    }
162    #[doc = "Use AIN7 as external analog reference"]
163    #[inline(always)]
164    pub fn analog_reference7(self) -> &'a mut W {
165        self.variant(EXTREFSEL_A::ANALOG_REFERENCE7)
166    }
167}
168impl R {
169    #[doc = "Bits 0:2 - External analog reference select"]
170    #[inline(always)]
171    pub fn extrefsel(&self) -> EXTREFSEL_R {
172        EXTREFSEL_R::new((self.bits & 7) as u8)
173    }
174}
175impl W {
176    #[doc = "Bits 0:2 - External analog reference select"]
177    #[inline(always)]
178    pub fn extrefsel(&mut self) -> EXTREFSEL_W<0> {
179        EXTREFSEL_W::new(self)
180    }
181    #[doc = "Writes raw bits to the register."]
182    #[inline(always)]
183    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
184        self.0.bits(bits);
185        self
186    }
187}
188#[doc = "External reference select\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 [extrefsel](index.html) module"]
189pub struct EXTREFSEL_SPEC;
190impl crate::RegisterSpec for EXTREFSEL_SPEC {
191    type Ux = u32;
192}
193#[doc = "`read()` method returns [extrefsel::R](R) reader structure"]
194impl crate::Readable for EXTREFSEL_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [extrefsel::W](W) writer structure"]
198impl crate::Writable for EXTREFSEL_SPEC {
199    type Writer = W;
200}
201#[doc = "`reset()` method sets EXTREFSEL to value 0"]
202impl crate::Resettable for EXTREFSEL_SPEC {
203    #[inline(always)]
204    fn reset_value() -> Self::Ux {
205        0
206    }
207}