nrf51_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."]
38pub type SAMPLEPER_R = crate::FieldReader<u8, SAMPLEPER_A>;
39#[doc = "Sample period.\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum SAMPLEPER_A {
43    #[doc = "0: 128us sample period."]
44    _128US = 0,
45    #[doc = "1: 256us sample period."]
46    _256US = 1,
47    #[doc = "2: 512us sample period."]
48    _512US = 2,
49    #[doc = "3: 1024us sample period."]
50    _1024US = 3,
51    #[doc = "4: 2048us sample period."]
52    _2048US = 4,
53    #[doc = "5: 4096us sample period."]
54    _4096US = 5,
55    #[doc = "6: 8192us sample period."]
56    _8192US = 6,
57    #[doc = "7: 16384us sample period."]
58    _16384US = 7,
59}
60impl From<SAMPLEPER_A> for u8 {
61    #[inline(always)]
62    fn from(variant: SAMPLEPER_A) -> Self {
63        variant as _
64    }
65}
66impl SAMPLEPER_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> SAMPLEPER_A {
70        match self.bits {
71            0 => SAMPLEPER_A::_128US,
72            1 => SAMPLEPER_A::_256US,
73            2 => SAMPLEPER_A::_512US,
74            3 => SAMPLEPER_A::_1024US,
75            4 => SAMPLEPER_A::_2048US,
76            5 => SAMPLEPER_A::_4096US,
77            6 => SAMPLEPER_A::_8192US,
78            7 => SAMPLEPER_A::_16384US,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `_128US`"]
83    #[inline(always)]
84    pub fn is_128us(&self) -> bool {
85        *self == SAMPLEPER_A::_128US
86    }
87    #[doc = "Checks if the value of the field is `_256US`"]
88    #[inline(always)]
89    pub fn is_256us(&self) -> bool {
90        *self == SAMPLEPER_A::_256US
91    }
92    #[doc = "Checks if the value of the field is `_512US`"]
93    #[inline(always)]
94    pub fn is_512us(&self) -> bool {
95        *self == SAMPLEPER_A::_512US
96    }
97    #[doc = "Checks if the value of the field is `_1024US`"]
98    #[inline(always)]
99    pub fn is_1024us(&self) -> bool {
100        *self == SAMPLEPER_A::_1024US
101    }
102    #[doc = "Checks if the value of the field is `_2048US`"]
103    #[inline(always)]
104    pub fn is_2048us(&self) -> bool {
105        *self == SAMPLEPER_A::_2048US
106    }
107    #[doc = "Checks if the value of the field is `_4096US`"]
108    #[inline(always)]
109    pub fn is_4096us(&self) -> bool {
110        *self == SAMPLEPER_A::_4096US
111    }
112    #[doc = "Checks if the value of the field is `_8192US`"]
113    #[inline(always)]
114    pub fn is_8192us(&self) -> bool {
115        *self == SAMPLEPER_A::_8192US
116    }
117    #[doc = "Checks if the value of the field is `_16384US`"]
118    #[inline(always)]
119    pub fn is_16384us(&self) -> bool {
120        *self == SAMPLEPER_A::_16384US
121    }
122}
123#[doc = "Field `SAMPLEPER` writer - Sample period."]
124pub type SAMPLEPER_W<'a, const O: u8> =
125    crate::FieldWriterSafe<'a, u32, SAMPLEPER_SPEC, u8, SAMPLEPER_A, 3, O>;
126impl<'a, const O: u8> SAMPLEPER_W<'a, O> {
127    #[doc = "128us sample period."]
128    #[inline(always)]
129    pub fn _128us(self) -> &'a mut W {
130        self.variant(SAMPLEPER_A::_128US)
131    }
132    #[doc = "256us sample period."]
133    #[inline(always)]
134    pub fn _256us(self) -> &'a mut W {
135        self.variant(SAMPLEPER_A::_256US)
136    }
137    #[doc = "512us sample period."]
138    #[inline(always)]
139    pub fn _512us(self) -> &'a mut W {
140        self.variant(SAMPLEPER_A::_512US)
141    }
142    #[doc = "1024us sample period."]
143    #[inline(always)]
144    pub fn _1024us(self) -> &'a mut W {
145        self.variant(SAMPLEPER_A::_1024US)
146    }
147    #[doc = "2048us sample period."]
148    #[inline(always)]
149    pub fn _2048us(self) -> &'a mut W {
150        self.variant(SAMPLEPER_A::_2048US)
151    }
152    #[doc = "4096us sample period."]
153    #[inline(always)]
154    pub fn _4096us(self) -> &'a mut W {
155        self.variant(SAMPLEPER_A::_4096US)
156    }
157    #[doc = "8192us sample period."]
158    #[inline(always)]
159    pub fn _8192us(self) -> &'a mut W {
160        self.variant(SAMPLEPER_A::_8192US)
161    }
162    #[doc = "16384us sample period."]
163    #[inline(always)]
164    pub fn _16384us(self) -> &'a mut W {
165        self.variant(SAMPLEPER_A::_16384US)
166    }
167}
168impl R {
169    #[doc = "Bits 0:2 - Sample period."]
170    #[inline(always)]
171    pub fn sampleper(&self) -> SAMPLEPER_R {
172        SAMPLEPER_R::new((self.bits & 7) as u8)
173    }
174}
175impl W {
176    #[doc = "Bits 0:2 - Sample period."]
177    #[inline(always)]
178    pub fn sampleper(&mut self) -> SAMPLEPER_W<0> {
179        SAMPLEPER_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 = "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"]
189pub struct SAMPLEPER_SPEC;
190impl crate::RegisterSpec for SAMPLEPER_SPEC {
191    type Ux = u32;
192}
193#[doc = "`read()` method returns [sampleper::R](R) reader structure"]
194impl crate::Readable for SAMPLEPER_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [sampleper::W](W) writer structure"]
198impl crate::Writable for SAMPLEPER_SPEC {
199    type Writer = W;
200}
201#[doc = "`reset()` method sets SAMPLEPER to value 0"]
202impl crate::Resettable for SAMPLEPER_SPEC {
203    #[inline(always)]
204    fn reset_value() -> Self::Ux {
205        0
206    }
207}