nrf51_pac/lpcomp/
refsel.rs

1#[doc = "Register `REFSEL` reader"]
2pub struct R(crate::R<REFSEL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<REFSEL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<REFSEL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<REFSEL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `REFSEL` writer"]
17pub struct W(crate::W<REFSEL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<REFSEL_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<REFSEL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<REFSEL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `REFSEL` reader - Reference select."]
38pub type REFSEL_R = crate::FieldReader<u8, REFSEL_A>;
39#[doc = "Reference select.\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum REFSEL_A {
43    #[doc = "0: Use supply with a 1/8 prescaler as reference."]
44    SUPPLY_ONE_EIGHTH_PRESCALING = 0,
45    #[doc = "1: Use supply with a 2/8 prescaler as reference."]
46    SUPPLY_TWO_EIGHTHS_PRESCALING = 1,
47    #[doc = "2: Use supply with a 3/8 prescaler as reference."]
48    SUPPLY_THREE_EIGHTHS_PRESCALING = 2,
49    #[doc = "3: Use supply with a 4/8 prescaler as reference."]
50    SUPPLY_FOUR_EIGHTHS_PRESCALING = 3,
51    #[doc = "4: Use supply with a 5/8 prescaler as reference."]
52    SUPPLY_FIVE_EIGHTHS_PRESCALING = 4,
53    #[doc = "5: Use supply with a 6/8 prescaler as reference."]
54    SUPPLY_SIX_EIGHTHS_PRESCALING = 5,
55    #[doc = "6: Use supply with a 7/8 prescaler as reference."]
56    SUPPLY_SEVEN_EIGHTHS_PRESCALING = 6,
57    #[doc = "7: Use external analog reference as reference."]
58    AREF = 7,
59}
60impl From<REFSEL_A> for u8 {
61    #[inline(always)]
62    fn from(variant: REFSEL_A) -> Self {
63        variant as _
64    }
65}
66impl REFSEL_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> REFSEL_A {
70        match self.bits {
71            0 => REFSEL_A::SUPPLY_ONE_EIGHTH_PRESCALING,
72            1 => REFSEL_A::SUPPLY_TWO_EIGHTHS_PRESCALING,
73            2 => REFSEL_A::SUPPLY_THREE_EIGHTHS_PRESCALING,
74            3 => REFSEL_A::SUPPLY_FOUR_EIGHTHS_PRESCALING,
75            4 => REFSEL_A::SUPPLY_FIVE_EIGHTHS_PRESCALING,
76            5 => REFSEL_A::SUPPLY_SIX_EIGHTHS_PRESCALING,
77            6 => REFSEL_A::SUPPLY_SEVEN_EIGHTHS_PRESCALING,
78            7 => REFSEL_A::AREF,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `SUPPLY_ONE_EIGHTH_PRESCALING`"]
83    #[inline(always)]
84    pub fn is_supply_one_eighth_prescaling(&self) -> bool {
85        *self == REFSEL_A::SUPPLY_ONE_EIGHTH_PRESCALING
86    }
87    #[doc = "Checks if the value of the field is `SUPPLY_TWO_EIGHTHS_PRESCALING`"]
88    #[inline(always)]
89    pub fn is_supply_two_eighths_prescaling(&self) -> bool {
90        *self == REFSEL_A::SUPPLY_TWO_EIGHTHS_PRESCALING
91    }
92    #[doc = "Checks if the value of the field is `SUPPLY_THREE_EIGHTHS_PRESCALING`"]
93    #[inline(always)]
94    pub fn is_supply_three_eighths_prescaling(&self) -> bool {
95        *self == REFSEL_A::SUPPLY_THREE_EIGHTHS_PRESCALING
96    }
97    #[doc = "Checks if the value of the field is `SUPPLY_FOUR_EIGHTHS_PRESCALING`"]
98    #[inline(always)]
99    pub fn is_supply_four_eighths_prescaling(&self) -> bool {
100        *self == REFSEL_A::SUPPLY_FOUR_EIGHTHS_PRESCALING
101    }
102    #[doc = "Checks if the value of the field is `SUPPLY_FIVE_EIGHTHS_PRESCALING`"]
103    #[inline(always)]
104    pub fn is_supply_five_eighths_prescaling(&self) -> bool {
105        *self == REFSEL_A::SUPPLY_FIVE_EIGHTHS_PRESCALING
106    }
107    #[doc = "Checks if the value of the field is `SUPPLY_SIX_EIGHTHS_PRESCALING`"]
108    #[inline(always)]
109    pub fn is_supply_six_eighths_prescaling(&self) -> bool {
110        *self == REFSEL_A::SUPPLY_SIX_EIGHTHS_PRESCALING
111    }
112    #[doc = "Checks if the value of the field is `SUPPLY_SEVEN_EIGHTHS_PRESCALING`"]
113    #[inline(always)]
114    pub fn is_supply_seven_eighths_prescaling(&self) -> bool {
115        *self == REFSEL_A::SUPPLY_SEVEN_EIGHTHS_PRESCALING
116    }
117    #[doc = "Checks if the value of the field is `AREF`"]
118    #[inline(always)]
119    pub fn is_aref(&self) -> bool {
120        *self == REFSEL_A::AREF
121    }
122}
123#[doc = "Field `REFSEL` writer - Reference select."]
124pub type REFSEL_W<'a, const O: u8> =
125    crate::FieldWriterSafe<'a, u32, REFSEL_SPEC, u8, REFSEL_A, 3, O>;
126impl<'a, const O: u8> REFSEL_W<'a, O> {
127    #[doc = "Use supply with a 1/8 prescaler as reference."]
128    #[inline(always)]
129    pub fn supply_one_eighth_prescaling(self) -> &'a mut W {
130        self.variant(REFSEL_A::SUPPLY_ONE_EIGHTH_PRESCALING)
131    }
132    #[doc = "Use supply with a 2/8 prescaler as reference."]
133    #[inline(always)]
134    pub fn supply_two_eighths_prescaling(self) -> &'a mut W {
135        self.variant(REFSEL_A::SUPPLY_TWO_EIGHTHS_PRESCALING)
136    }
137    #[doc = "Use supply with a 3/8 prescaler as reference."]
138    #[inline(always)]
139    pub fn supply_three_eighths_prescaling(self) -> &'a mut W {
140        self.variant(REFSEL_A::SUPPLY_THREE_EIGHTHS_PRESCALING)
141    }
142    #[doc = "Use supply with a 4/8 prescaler as reference."]
143    #[inline(always)]
144    pub fn supply_four_eighths_prescaling(self) -> &'a mut W {
145        self.variant(REFSEL_A::SUPPLY_FOUR_EIGHTHS_PRESCALING)
146    }
147    #[doc = "Use supply with a 5/8 prescaler as reference."]
148    #[inline(always)]
149    pub fn supply_five_eighths_prescaling(self) -> &'a mut W {
150        self.variant(REFSEL_A::SUPPLY_FIVE_EIGHTHS_PRESCALING)
151    }
152    #[doc = "Use supply with a 6/8 prescaler as reference."]
153    #[inline(always)]
154    pub fn supply_six_eighths_prescaling(self) -> &'a mut W {
155        self.variant(REFSEL_A::SUPPLY_SIX_EIGHTHS_PRESCALING)
156    }
157    #[doc = "Use supply with a 7/8 prescaler as reference."]
158    #[inline(always)]
159    pub fn supply_seven_eighths_prescaling(self) -> &'a mut W {
160        self.variant(REFSEL_A::SUPPLY_SEVEN_EIGHTHS_PRESCALING)
161    }
162    #[doc = "Use external analog reference as reference."]
163    #[inline(always)]
164    pub fn aref(self) -> &'a mut W {
165        self.variant(REFSEL_A::AREF)
166    }
167}
168impl R {
169    #[doc = "Bits 0:2 - Reference select."]
170    #[inline(always)]
171    pub fn refsel(&self) -> REFSEL_R {
172        REFSEL_R::new((self.bits & 7) as u8)
173    }
174}
175impl W {
176    #[doc = "Bits 0:2 - Reference select."]
177    #[inline(always)]
178    pub fn refsel(&mut self) -> REFSEL_W<0> {
179        REFSEL_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 = "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 [refsel](index.html) module"]
189pub struct REFSEL_SPEC;
190impl crate::RegisterSpec for REFSEL_SPEC {
191    type Ux = u32;
192}
193#[doc = "`read()` method returns [refsel::R](R) reader structure"]
194impl crate::Readable for REFSEL_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [refsel::W](W) writer structure"]
198impl crate::Writable for REFSEL_SPEC {
199    type Writer = W;
200}
201#[doc = "`reset()` method sets REFSEL to value 0"]
202impl crate::Resettable for REFSEL_SPEC {
203    #[inline(always)]
204    fn reset_value() -> Self::Ux {
205        0
206    }
207}