nrf51_pac/qdec/
reportper.rs

1#[doc = "Register `REPORTPER` reader"]
2pub struct R(crate::R<REPORTPER_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<REPORTPER_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<REPORTPER_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<REPORTPER_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `REPORTPER` writer"]
17pub struct W(crate::W<REPORTPER_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<REPORTPER_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<REPORTPER_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<REPORTPER_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `REPORTPER` reader - Number of samples to generate an EVENT_REPORTRDY."]
38pub type REPORTPER_R = crate::FieldReader<u8, REPORTPER_A>;
39#[doc = "Number of samples to generate an EVENT_REPORTRDY.\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum REPORTPER_A {
43    #[doc = "0: 10 samples per report."]
44    _10SMPL = 0,
45    #[doc = "1: 40 samples per report."]
46    _40SMPL = 1,
47    #[doc = "2: 80 samples per report."]
48    _80SMPL = 2,
49    #[doc = "3: 120 samples per report."]
50    _120SMPL = 3,
51    #[doc = "4: 160 samples per report."]
52    _160SMPL = 4,
53    #[doc = "5: 200 samples per report."]
54    _200SMPL = 5,
55    #[doc = "6: 240 samples per report."]
56    _240SMPL = 6,
57    #[doc = "7: 280 samples per report."]
58    _280SMPL = 7,
59}
60impl From<REPORTPER_A> for u8 {
61    #[inline(always)]
62    fn from(variant: REPORTPER_A) -> Self {
63        variant as _
64    }
65}
66impl REPORTPER_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> REPORTPER_A {
70        match self.bits {
71            0 => REPORTPER_A::_10SMPL,
72            1 => REPORTPER_A::_40SMPL,
73            2 => REPORTPER_A::_80SMPL,
74            3 => REPORTPER_A::_120SMPL,
75            4 => REPORTPER_A::_160SMPL,
76            5 => REPORTPER_A::_200SMPL,
77            6 => REPORTPER_A::_240SMPL,
78            7 => REPORTPER_A::_280SMPL,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `_10SMPL`"]
83    #[inline(always)]
84    pub fn is_10smpl(&self) -> bool {
85        *self == REPORTPER_A::_10SMPL
86    }
87    #[doc = "Checks if the value of the field is `_40SMPL`"]
88    #[inline(always)]
89    pub fn is_40smpl(&self) -> bool {
90        *self == REPORTPER_A::_40SMPL
91    }
92    #[doc = "Checks if the value of the field is `_80SMPL`"]
93    #[inline(always)]
94    pub fn is_80smpl(&self) -> bool {
95        *self == REPORTPER_A::_80SMPL
96    }
97    #[doc = "Checks if the value of the field is `_120SMPL`"]
98    #[inline(always)]
99    pub fn is_120smpl(&self) -> bool {
100        *self == REPORTPER_A::_120SMPL
101    }
102    #[doc = "Checks if the value of the field is `_160SMPL`"]
103    #[inline(always)]
104    pub fn is_160smpl(&self) -> bool {
105        *self == REPORTPER_A::_160SMPL
106    }
107    #[doc = "Checks if the value of the field is `_200SMPL`"]
108    #[inline(always)]
109    pub fn is_200smpl(&self) -> bool {
110        *self == REPORTPER_A::_200SMPL
111    }
112    #[doc = "Checks if the value of the field is `_240SMPL`"]
113    #[inline(always)]
114    pub fn is_240smpl(&self) -> bool {
115        *self == REPORTPER_A::_240SMPL
116    }
117    #[doc = "Checks if the value of the field is `_280SMPL`"]
118    #[inline(always)]
119    pub fn is_280smpl(&self) -> bool {
120        *self == REPORTPER_A::_280SMPL
121    }
122}
123#[doc = "Field `REPORTPER` writer - Number of samples to generate an EVENT_REPORTRDY."]
124pub type REPORTPER_W<'a, const O: u8> =
125    crate::FieldWriterSafe<'a, u32, REPORTPER_SPEC, u8, REPORTPER_A, 3, O>;
126impl<'a, const O: u8> REPORTPER_W<'a, O> {
127    #[doc = "10 samples per report."]
128    #[inline(always)]
129    pub fn _10smpl(self) -> &'a mut W {
130        self.variant(REPORTPER_A::_10SMPL)
131    }
132    #[doc = "40 samples per report."]
133    #[inline(always)]
134    pub fn _40smpl(self) -> &'a mut W {
135        self.variant(REPORTPER_A::_40SMPL)
136    }
137    #[doc = "80 samples per report."]
138    #[inline(always)]
139    pub fn _80smpl(self) -> &'a mut W {
140        self.variant(REPORTPER_A::_80SMPL)
141    }
142    #[doc = "120 samples per report."]
143    #[inline(always)]
144    pub fn _120smpl(self) -> &'a mut W {
145        self.variant(REPORTPER_A::_120SMPL)
146    }
147    #[doc = "160 samples per report."]
148    #[inline(always)]
149    pub fn _160smpl(self) -> &'a mut W {
150        self.variant(REPORTPER_A::_160SMPL)
151    }
152    #[doc = "200 samples per report."]
153    #[inline(always)]
154    pub fn _200smpl(self) -> &'a mut W {
155        self.variant(REPORTPER_A::_200SMPL)
156    }
157    #[doc = "240 samples per report."]
158    #[inline(always)]
159    pub fn _240smpl(self) -> &'a mut W {
160        self.variant(REPORTPER_A::_240SMPL)
161    }
162    #[doc = "280 samples per report."]
163    #[inline(always)]
164    pub fn _280smpl(self) -> &'a mut W {
165        self.variant(REPORTPER_A::_280SMPL)
166    }
167}
168impl R {
169    #[doc = "Bits 0:2 - Number of samples to generate an EVENT_REPORTRDY."]
170    #[inline(always)]
171    pub fn reportper(&self) -> REPORTPER_R {
172        REPORTPER_R::new((self.bits & 7) as u8)
173    }
174}
175impl W {
176    #[doc = "Bits 0:2 - Number of samples to generate an EVENT_REPORTRDY."]
177    #[inline(always)]
178    pub fn reportper(&mut self) -> REPORTPER_W<0> {
179        REPORTPER_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 = "Number of samples to generate an EVENT_REPORTRDY.\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 [reportper](index.html) module"]
189pub struct REPORTPER_SPEC;
190impl crate::RegisterSpec for REPORTPER_SPEC {
191    type Ux = u32;
192}
193#[doc = "`read()` method returns [reportper::R](R) reader structure"]
194impl crate::Readable for REPORTPER_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [reportper::W](W) writer structure"]
198impl crate::Writable for REPORTPER_SPEC {
199    type Writer = W;
200}
201#[doc = "`reset()` method sets REPORTPER to value 0"]
202impl crate::Resettable for REPORTPER_SPEC {
203    #[inline(always)]
204    fn reset_value() -> Self::Ux {
205        0
206    }
207}