nrf52840_pac/qdec/
sampleper.rs

1#[doc = "Register `SAMPLEPER` reader"]
2pub struct R(crate::R<SAMPLEPER_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SAMPLEPER_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SAMPLEPER_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SAMPLEPER_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SAMPLEPER` writer"]
17pub struct W(crate::W<SAMPLEPER_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SAMPLEPER_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<SAMPLEPER_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SAMPLEPER_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SAMPLEPER` reader - Sample period. The SAMPLE register will be updated for every new sample"]
38pub type SAMPLEPER_R = crate::FieldReader<u8, SAMPLEPER_A>;
39#[doc = "Sample period. The SAMPLE register will be updated for every new sample\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum SAMPLEPER_A {
43    #[doc = "0: 128 us"]
44    _128US = 0,
45    #[doc = "1: 256 us"]
46    _256US = 1,
47    #[doc = "2: 512 us"]
48    _512US = 2,
49    #[doc = "3: 1024 us"]
50    _1024US = 3,
51    #[doc = "4: 2048 us"]
52    _2048US = 4,
53    #[doc = "5: 4096 us"]
54    _4096US = 5,
55    #[doc = "6: 8192 us"]
56    _8192US = 6,
57    #[doc = "7: 16384 us"]
58    _16384US = 7,
59    #[doc = "8: 32768 us"]
60    _32MS = 8,
61    #[doc = "9: 65536 us"]
62    _65MS = 9,
63    #[doc = "10: 131072 us"]
64    _131MS = 10,
65}
66impl From<SAMPLEPER_A> for u8 {
67    #[inline(always)]
68    fn from(variant: SAMPLEPER_A) -> Self {
69        variant as _
70    }
71}
72impl SAMPLEPER_R {
73    #[doc = "Get enumerated values variant"]
74    #[inline(always)]
75    pub fn variant(&self) -> Option<SAMPLEPER_A> {
76        match self.bits {
77            0 => Some(SAMPLEPER_A::_128US),
78            1 => Some(SAMPLEPER_A::_256US),
79            2 => Some(SAMPLEPER_A::_512US),
80            3 => Some(SAMPLEPER_A::_1024US),
81            4 => Some(SAMPLEPER_A::_2048US),
82            5 => Some(SAMPLEPER_A::_4096US),
83            6 => Some(SAMPLEPER_A::_8192US),
84            7 => Some(SAMPLEPER_A::_16384US),
85            8 => Some(SAMPLEPER_A::_32MS),
86            9 => Some(SAMPLEPER_A::_65MS),
87            10 => Some(SAMPLEPER_A::_131MS),
88            _ => None,
89        }
90    }
91    #[doc = "Checks if the value of the field is `_128US`"]
92    #[inline(always)]
93    pub fn is_128us(&self) -> bool {
94        *self == SAMPLEPER_A::_128US
95    }
96    #[doc = "Checks if the value of the field is `_256US`"]
97    #[inline(always)]
98    pub fn is_256us(&self) -> bool {
99        *self == SAMPLEPER_A::_256US
100    }
101    #[doc = "Checks if the value of the field is `_512US`"]
102    #[inline(always)]
103    pub fn is_512us(&self) -> bool {
104        *self == SAMPLEPER_A::_512US
105    }
106    #[doc = "Checks if the value of the field is `_1024US`"]
107    #[inline(always)]
108    pub fn is_1024us(&self) -> bool {
109        *self == SAMPLEPER_A::_1024US
110    }
111    #[doc = "Checks if the value of the field is `_2048US`"]
112    #[inline(always)]
113    pub fn is_2048us(&self) -> bool {
114        *self == SAMPLEPER_A::_2048US
115    }
116    #[doc = "Checks if the value of the field is `_4096US`"]
117    #[inline(always)]
118    pub fn is_4096us(&self) -> bool {
119        *self == SAMPLEPER_A::_4096US
120    }
121    #[doc = "Checks if the value of the field is `_8192US`"]
122    #[inline(always)]
123    pub fn is_8192us(&self) -> bool {
124        *self == SAMPLEPER_A::_8192US
125    }
126    #[doc = "Checks if the value of the field is `_16384US`"]
127    #[inline(always)]
128    pub fn is_16384us(&self) -> bool {
129        *self == SAMPLEPER_A::_16384US
130    }
131    #[doc = "Checks if the value of the field is `_32MS`"]
132    #[inline(always)]
133    pub fn is_32ms(&self) -> bool {
134        *self == SAMPLEPER_A::_32MS
135    }
136    #[doc = "Checks if the value of the field is `_65MS`"]
137    #[inline(always)]
138    pub fn is_65ms(&self) -> bool {
139        *self == SAMPLEPER_A::_65MS
140    }
141    #[doc = "Checks if the value of the field is `_131MS`"]
142    #[inline(always)]
143    pub fn is_131ms(&self) -> bool {
144        *self == SAMPLEPER_A::_131MS
145    }
146}
147#[doc = "Field `SAMPLEPER` writer - Sample period. The SAMPLE register will be updated for every new sample"]
148pub type SAMPLEPER_W<'a, const O: u8> =
149    crate::FieldWriter<'a, u32, SAMPLEPER_SPEC, u8, SAMPLEPER_A, 4, O>;
150impl<'a, const O: u8> SAMPLEPER_W<'a, O> {
151    #[doc = "128 us"]
152    #[inline(always)]
153    pub fn _128us(self) -> &'a mut W {
154        self.variant(SAMPLEPER_A::_128US)
155    }
156    #[doc = "256 us"]
157    #[inline(always)]
158    pub fn _256us(self) -> &'a mut W {
159        self.variant(SAMPLEPER_A::_256US)
160    }
161    #[doc = "512 us"]
162    #[inline(always)]
163    pub fn _512us(self) -> &'a mut W {
164        self.variant(SAMPLEPER_A::_512US)
165    }
166    #[doc = "1024 us"]
167    #[inline(always)]
168    pub fn _1024us(self) -> &'a mut W {
169        self.variant(SAMPLEPER_A::_1024US)
170    }
171    #[doc = "2048 us"]
172    #[inline(always)]
173    pub fn _2048us(self) -> &'a mut W {
174        self.variant(SAMPLEPER_A::_2048US)
175    }
176    #[doc = "4096 us"]
177    #[inline(always)]
178    pub fn _4096us(self) -> &'a mut W {
179        self.variant(SAMPLEPER_A::_4096US)
180    }
181    #[doc = "8192 us"]
182    #[inline(always)]
183    pub fn _8192us(self) -> &'a mut W {
184        self.variant(SAMPLEPER_A::_8192US)
185    }
186    #[doc = "16384 us"]
187    #[inline(always)]
188    pub fn _16384us(self) -> &'a mut W {
189        self.variant(SAMPLEPER_A::_16384US)
190    }
191    #[doc = "32768 us"]
192    #[inline(always)]
193    pub fn _32ms(self) -> &'a mut W {
194        self.variant(SAMPLEPER_A::_32MS)
195    }
196    #[doc = "65536 us"]
197    #[inline(always)]
198    pub fn _65ms(self) -> &'a mut W {
199        self.variant(SAMPLEPER_A::_65MS)
200    }
201    #[doc = "131072 us"]
202    #[inline(always)]
203    pub fn _131ms(self) -> &'a mut W {
204        self.variant(SAMPLEPER_A::_131MS)
205    }
206}
207impl R {
208    #[doc = "Bits 0:3 - Sample period. The SAMPLE register will be updated for every new sample"]
209    #[inline(always)]
210    pub fn sampleper(&self) -> SAMPLEPER_R {
211        SAMPLEPER_R::new((self.bits & 0x0f) as u8)
212    }
213}
214impl W {
215    #[doc = "Bits 0:3 - Sample period. The SAMPLE register will be updated for every new sample"]
216    #[inline(always)]
217    pub fn sampleper(&mut self) -> SAMPLEPER_W<0> {
218        SAMPLEPER_W::new(self)
219    }
220    #[doc = "Writes raw bits to the register."]
221    #[inline(always)]
222    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
223        self.0.bits(bits);
224        self
225    }
226}
227#[doc = "Sample period\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 [sampleper](index.html) module"]
228pub struct SAMPLEPER_SPEC;
229impl crate::RegisterSpec for SAMPLEPER_SPEC {
230    type Ux = u32;
231}
232#[doc = "`read()` method returns [sampleper::R](R) reader structure"]
233impl crate::Readable for SAMPLEPER_SPEC {
234    type Reader = R;
235}
236#[doc = "`write(|w| ..)` method takes [sampleper::W](W) writer structure"]
237impl crate::Writable for SAMPLEPER_SPEC {
238    type Writer = W;
239}
240#[doc = "`reset()` method sets SAMPLEPER to value 0"]
241impl crate::Resettable for SAMPLEPER_SPEC {
242    #[inline(always)]
243    fn reset_value() -> Self::Ux {
244        0
245    }
246}