atsame70q21/pioa/
pio_pcmr.rs1#[doc = "Register `PIO_PCMR` reader"]
2pub struct R(crate::R<PIO_PCMR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<PIO_PCMR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<PIO_PCMR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<PIO_PCMR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `PIO_PCMR` writer"]
17pub struct W(crate::W<PIO_PCMR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<PIO_PCMR_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<PIO_PCMR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<PIO_PCMR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `PCEN` reader - Parallel Capture Mode Enable"]
38pub struct PCEN_R(crate::FieldReader<bool, bool>);
39impl PCEN_R {
40 #[inline(always)]
41 pub(crate) fn new(bits: bool) -> Self {
42 PCEN_R(crate::FieldReader::new(bits))
43 }
44}
45impl core::ops::Deref for PCEN_R {
46 type Target = crate::FieldReader<bool, bool>;
47 #[inline(always)]
48 fn deref(&self) -> &Self::Target {
49 &self.0
50 }
51}
52#[doc = "Field `PCEN` writer - Parallel Capture Mode Enable"]
53pub struct PCEN_W<'a> {
54 w: &'a mut W,
55}
56impl<'a> PCEN_W<'a> {
57 #[doc = r"Sets the field bit"]
58 #[inline(always)]
59 pub fn set_bit(self) -> &'a mut W {
60 self.bit(true)
61 }
62 #[doc = r"Clears the field bit"]
63 #[inline(always)]
64 pub fn clear_bit(self) -> &'a mut W {
65 self.bit(false)
66 }
67 #[doc = r"Writes raw bits to the field"]
68 #[inline(always)]
69 pub fn bit(self, value: bool) -> &'a mut W {
70 self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
71 self.w
72 }
73}
74#[doc = "Parallel Capture Mode Data Size\n\nValue on reset: 0"]
75#[derive(Clone, Copy, Debug, PartialEq)]
76#[repr(u8)]
77pub enum DSIZE_A {
78 #[doc = "0: The reception data in the PIO_PCRHR is a byte (8-bit)"]
79 BYTE = 0,
80 #[doc = "1: The reception data in the PIO_PCRHR is a half-word (16-bit)"]
81 HALFWORD = 1,
82 #[doc = "2: The reception data in the PIO_PCRHR is a word (32-bit)"]
83 WORD = 2,
84}
85impl From<DSIZE_A> for u8 {
86 #[inline(always)]
87 fn from(variant: DSIZE_A) -> Self {
88 variant as _
89 }
90}
91#[doc = "Field `DSIZE` reader - Parallel Capture Mode Data Size"]
92pub struct DSIZE_R(crate::FieldReader<u8, DSIZE_A>);
93impl DSIZE_R {
94 #[inline(always)]
95 pub(crate) fn new(bits: u8) -> Self {
96 DSIZE_R(crate::FieldReader::new(bits))
97 }
98 #[doc = r"Get enumerated values variant"]
99 #[inline(always)]
100 pub fn variant(&self) -> Option<DSIZE_A> {
101 match self.bits {
102 0 => Some(DSIZE_A::BYTE),
103 1 => Some(DSIZE_A::HALFWORD),
104 2 => Some(DSIZE_A::WORD),
105 _ => None,
106 }
107 }
108 #[doc = "Checks if the value of the field is `BYTE`"]
109 #[inline(always)]
110 pub fn is_byte(&self) -> bool {
111 **self == DSIZE_A::BYTE
112 }
113 #[doc = "Checks if the value of the field is `HALFWORD`"]
114 #[inline(always)]
115 pub fn is_halfword(&self) -> bool {
116 **self == DSIZE_A::HALFWORD
117 }
118 #[doc = "Checks if the value of the field is `WORD`"]
119 #[inline(always)]
120 pub fn is_word(&self) -> bool {
121 **self == DSIZE_A::WORD
122 }
123}
124impl core::ops::Deref for DSIZE_R {
125 type Target = crate::FieldReader<u8, DSIZE_A>;
126 #[inline(always)]
127 fn deref(&self) -> &Self::Target {
128 &self.0
129 }
130}
131#[doc = "Field `DSIZE` writer - Parallel Capture Mode Data Size"]
132pub struct DSIZE_W<'a> {
133 w: &'a mut W,
134}
135impl<'a> DSIZE_W<'a> {
136 #[doc = r"Writes `variant` to the field"]
137 #[inline(always)]
138 pub fn variant(self, variant: DSIZE_A) -> &'a mut W {
139 unsafe { self.bits(variant.into()) }
140 }
141 #[doc = "The reception data in the PIO_PCRHR is a byte (8-bit)"]
142 #[inline(always)]
143 pub fn byte(self) -> &'a mut W {
144 self.variant(DSIZE_A::BYTE)
145 }
146 #[doc = "The reception data in the PIO_PCRHR is a half-word (16-bit)"]
147 #[inline(always)]
148 pub fn halfword(self) -> &'a mut W {
149 self.variant(DSIZE_A::HALFWORD)
150 }
151 #[doc = "The reception data in the PIO_PCRHR is a word (32-bit)"]
152 #[inline(always)]
153 pub fn word(self) -> &'a mut W {
154 self.variant(DSIZE_A::WORD)
155 }
156 #[doc = r"Writes raw bits to the field"]
157 #[inline(always)]
158 pub unsafe fn bits(self, value: u8) -> &'a mut W {
159 self.w.bits = (self.w.bits & !(0x03 << 4)) | ((value as u32 & 0x03) << 4);
160 self.w
161 }
162}
163#[doc = "Field `ALWYS` reader - Parallel Capture Mode Always Sampling"]
164pub struct ALWYS_R(crate::FieldReader<bool, bool>);
165impl ALWYS_R {
166 #[inline(always)]
167 pub(crate) fn new(bits: bool) -> Self {
168 ALWYS_R(crate::FieldReader::new(bits))
169 }
170}
171impl core::ops::Deref for ALWYS_R {
172 type Target = crate::FieldReader<bool, bool>;
173 #[inline(always)]
174 fn deref(&self) -> &Self::Target {
175 &self.0
176 }
177}
178#[doc = "Field `ALWYS` writer - Parallel Capture Mode Always Sampling"]
179pub struct ALWYS_W<'a> {
180 w: &'a mut W,
181}
182impl<'a> ALWYS_W<'a> {
183 #[doc = r"Sets the field bit"]
184 #[inline(always)]
185 pub fn set_bit(self) -> &'a mut W {
186 self.bit(true)
187 }
188 #[doc = r"Clears the field bit"]
189 #[inline(always)]
190 pub fn clear_bit(self) -> &'a mut W {
191 self.bit(false)
192 }
193 #[doc = r"Writes raw bits to the field"]
194 #[inline(always)]
195 pub fn bit(self, value: bool) -> &'a mut W {
196 self.w.bits = (self.w.bits & !(0x01 << 9)) | ((value as u32 & 0x01) << 9);
197 self.w
198 }
199}
200#[doc = "Field `HALFS` reader - Parallel Capture Mode Half Sampling"]
201pub struct HALFS_R(crate::FieldReader<bool, bool>);
202impl HALFS_R {
203 #[inline(always)]
204 pub(crate) fn new(bits: bool) -> Self {
205 HALFS_R(crate::FieldReader::new(bits))
206 }
207}
208impl core::ops::Deref for HALFS_R {
209 type Target = crate::FieldReader<bool, bool>;
210 #[inline(always)]
211 fn deref(&self) -> &Self::Target {
212 &self.0
213 }
214}
215#[doc = "Field `HALFS` writer - Parallel Capture Mode Half Sampling"]
216pub struct HALFS_W<'a> {
217 w: &'a mut W,
218}
219impl<'a> HALFS_W<'a> {
220 #[doc = r"Sets the field bit"]
221 #[inline(always)]
222 pub fn set_bit(self) -> &'a mut W {
223 self.bit(true)
224 }
225 #[doc = r"Clears the field bit"]
226 #[inline(always)]
227 pub fn clear_bit(self) -> &'a mut W {
228 self.bit(false)
229 }
230 #[doc = r"Writes raw bits to the field"]
231 #[inline(always)]
232 pub fn bit(self, value: bool) -> &'a mut W {
233 self.w.bits = (self.w.bits & !(0x01 << 10)) | ((value as u32 & 0x01) << 10);
234 self.w
235 }
236}
237#[doc = "Field `FRSTS` reader - Parallel Capture Mode First Sample"]
238pub struct FRSTS_R(crate::FieldReader<bool, bool>);
239impl FRSTS_R {
240 #[inline(always)]
241 pub(crate) fn new(bits: bool) -> Self {
242 FRSTS_R(crate::FieldReader::new(bits))
243 }
244}
245impl core::ops::Deref for FRSTS_R {
246 type Target = crate::FieldReader<bool, bool>;
247 #[inline(always)]
248 fn deref(&self) -> &Self::Target {
249 &self.0
250 }
251}
252#[doc = "Field `FRSTS` writer - Parallel Capture Mode First Sample"]
253pub struct FRSTS_W<'a> {
254 w: &'a mut W,
255}
256impl<'a> FRSTS_W<'a> {
257 #[doc = r"Sets the field bit"]
258 #[inline(always)]
259 pub fn set_bit(self) -> &'a mut W {
260 self.bit(true)
261 }
262 #[doc = r"Clears the field bit"]
263 #[inline(always)]
264 pub fn clear_bit(self) -> &'a mut W {
265 self.bit(false)
266 }
267 #[doc = r"Writes raw bits to the field"]
268 #[inline(always)]
269 pub fn bit(self, value: bool) -> &'a mut W {
270 self.w.bits = (self.w.bits & !(0x01 << 11)) | ((value as u32 & 0x01) << 11);
271 self.w
272 }
273}
274impl R {
275 #[doc = "Bit 0 - Parallel Capture Mode Enable"]
276 #[inline(always)]
277 pub fn pcen(&self) -> PCEN_R {
278 PCEN_R::new((self.bits & 0x01) != 0)
279 }
280 #[doc = "Bits 4:5 - Parallel Capture Mode Data Size"]
281 #[inline(always)]
282 pub fn dsize(&self) -> DSIZE_R {
283 DSIZE_R::new(((self.bits >> 4) & 0x03) as u8)
284 }
285 #[doc = "Bit 9 - Parallel Capture Mode Always Sampling"]
286 #[inline(always)]
287 pub fn alwys(&self) -> ALWYS_R {
288 ALWYS_R::new(((self.bits >> 9) & 0x01) != 0)
289 }
290 #[doc = "Bit 10 - Parallel Capture Mode Half Sampling"]
291 #[inline(always)]
292 pub fn halfs(&self) -> HALFS_R {
293 HALFS_R::new(((self.bits >> 10) & 0x01) != 0)
294 }
295 #[doc = "Bit 11 - Parallel Capture Mode First Sample"]
296 #[inline(always)]
297 pub fn frsts(&self) -> FRSTS_R {
298 FRSTS_R::new(((self.bits >> 11) & 0x01) != 0)
299 }
300}
301impl W {
302 #[doc = "Bit 0 - Parallel Capture Mode Enable"]
303 #[inline(always)]
304 pub fn pcen(&mut self) -> PCEN_W {
305 PCEN_W { w: self }
306 }
307 #[doc = "Bits 4:5 - Parallel Capture Mode Data Size"]
308 #[inline(always)]
309 pub fn dsize(&mut self) -> DSIZE_W {
310 DSIZE_W { w: self }
311 }
312 #[doc = "Bit 9 - Parallel Capture Mode Always Sampling"]
313 #[inline(always)]
314 pub fn alwys(&mut self) -> ALWYS_W {
315 ALWYS_W { w: self }
316 }
317 #[doc = "Bit 10 - Parallel Capture Mode Half Sampling"]
318 #[inline(always)]
319 pub fn halfs(&mut self) -> HALFS_W {
320 HALFS_W { w: self }
321 }
322 #[doc = "Bit 11 - Parallel Capture Mode First Sample"]
323 #[inline(always)]
324 pub fn frsts(&mut self) -> FRSTS_W {
325 FRSTS_W { w: self }
326 }
327 #[doc = "Writes raw bits to the register."]
328 #[inline(always)]
329 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
330 self.0.bits(bits);
331 self
332 }
333}
334#[doc = "Parallel Capture Mode Register\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 [pio_pcmr](index.html) module"]
335pub struct PIO_PCMR_SPEC;
336impl crate::RegisterSpec for PIO_PCMR_SPEC {
337 type Ux = u32;
338}
339#[doc = "`read()` method returns [pio_pcmr::R](R) reader structure"]
340impl crate::Readable for PIO_PCMR_SPEC {
341 type Reader = R;
342}
343#[doc = "`write(|w| ..)` method takes [pio_pcmr::W](W) writer structure"]
344impl crate::Writable for PIO_PCMR_SPEC {
345 type Writer = W;
346}
347#[doc = "`reset()` method sets PIO_PCMR to value 0"]
348impl crate::Resettable for PIO_PCMR_SPEC {
349 #[inline(always)]
350 fn reset_value() -> Self::Ux {
351 0
352 }
353}