mcxa_pac/gpio0/
ptor.rs

1#[doc = "Register `PTOR` reader"]
2pub type R = crate::R<PtorSpec>;
3#[doc = "Register `PTOR` writer"]
4pub type W = crate::W<PtorSpec>;
5#[doc = "Port Toggle Output\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Ptto {
9    #[doc = "0: No change"]
10    Ptto0 = 0,
11    #[doc = "1: Set to the inverse of its current logic state"]
12    Ptto1 = 1,
13}
14impl From<Ptto> for bool {
15    #[inline(always)]
16    fn from(variant: Ptto) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `PTTO(0-31)` reader - Port Toggle Output"]
21pub type PttoR = crate::BitReader<Ptto>;
22impl PttoR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Ptto {
26        match self.bits {
27            false => Ptto::Ptto0,
28            true => Ptto::Ptto1,
29        }
30    }
31    #[doc = "No change"]
32    #[inline(always)]
33    pub fn is_ptto0(&self) -> bool {
34        *self == Ptto::Ptto0
35    }
36    #[doc = "Set to the inverse of its current logic state"]
37    #[inline(always)]
38    pub fn is_ptto1(&self) -> bool {
39        *self == Ptto::Ptto1
40    }
41}
42#[doc = "Field `PTTO(0-31)` writer - Port Toggle Output"]
43pub type PttoW<'a, REG> = crate::BitWriter<'a, REG, Ptto>;
44impl<'a, REG> PttoW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "No change"]
49    #[inline(always)]
50    pub fn ptto0(self) -> &'a mut crate::W<REG> {
51        self.variant(Ptto::Ptto0)
52    }
53    #[doc = "Set to the inverse of its current logic state"]
54    #[inline(always)]
55    pub fn ptto1(self) -> &'a mut crate::W<REG> {
56        self.variant(Ptto::Ptto1)
57    }
58}
59impl R {
60    #[doc = "Port Toggle Output"]
61    #[doc = ""]
62    #[doc = "<div class=\"warning\">`n` is number of field in register. `n == 0` corresponds to `PTTO0` field.</div>"]
63    #[inline(always)]
64    pub fn ptto(&self, n: u8) -> PttoR {
65        #[allow(clippy::no_effect)]
66        [(); 32][n as usize];
67        PttoR::new(((self.bits >> n) & 1) != 0)
68    }
69    #[doc = "Iterator for array of:"]
70    #[doc = "Port Toggle Output"]
71    #[inline(always)]
72    pub fn ptto_iter(&self) -> impl Iterator<Item = PttoR> + '_ {
73        (0..32).map(move |n| PttoR::new(((self.bits >> n) & 1) != 0))
74    }
75    #[doc = "Bit 0 - Port Toggle Output"]
76    #[inline(always)]
77    pub fn ptto0(&self) -> PttoR {
78        PttoR::new((self.bits & 1) != 0)
79    }
80    #[doc = "Bit 1 - Port Toggle Output"]
81    #[inline(always)]
82    pub fn ptto1(&self) -> PttoR {
83        PttoR::new(((self.bits >> 1) & 1) != 0)
84    }
85    #[doc = "Bit 2 - Port Toggle Output"]
86    #[inline(always)]
87    pub fn ptto2(&self) -> PttoR {
88        PttoR::new(((self.bits >> 2) & 1) != 0)
89    }
90    #[doc = "Bit 3 - Port Toggle Output"]
91    #[inline(always)]
92    pub fn ptto3(&self) -> PttoR {
93        PttoR::new(((self.bits >> 3) & 1) != 0)
94    }
95    #[doc = "Bit 4 - Port Toggle Output"]
96    #[inline(always)]
97    pub fn ptto4(&self) -> PttoR {
98        PttoR::new(((self.bits >> 4) & 1) != 0)
99    }
100    #[doc = "Bit 5 - Port Toggle Output"]
101    #[inline(always)]
102    pub fn ptto5(&self) -> PttoR {
103        PttoR::new(((self.bits >> 5) & 1) != 0)
104    }
105    #[doc = "Bit 6 - Port Toggle Output"]
106    #[inline(always)]
107    pub fn ptto6(&self) -> PttoR {
108        PttoR::new(((self.bits >> 6) & 1) != 0)
109    }
110    #[doc = "Bit 7 - Port Toggle Output"]
111    #[inline(always)]
112    pub fn ptto7(&self) -> PttoR {
113        PttoR::new(((self.bits >> 7) & 1) != 0)
114    }
115    #[doc = "Bit 8 - Port Toggle Output"]
116    #[inline(always)]
117    pub fn ptto8(&self) -> PttoR {
118        PttoR::new(((self.bits >> 8) & 1) != 0)
119    }
120    #[doc = "Bit 9 - Port Toggle Output"]
121    #[inline(always)]
122    pub fn ptto9(&self) -> PttoR {
123        PttoR::new(((self.bits >> 9) & 1) != 0)
124    }
125    #[doc = "Bit 10 - Port Toggle Output"]
126    #[inline(always)]
127    pub fn ptto10(&self) -> PttoR {
128        PttoR::new(((self.bits >> 10) & 1) != 0)
129    }
130    #[doc = "Bit 11 - Port Toggle Output"]
131    #[inline(always)]
132    pub fn ptto11(&self) -> PttoR {
133        PttoR::new(((self.bits >> 11) & 1) != 0)
134    }
135    #[doc = "Bit 12 - Port Toggle Output"]
136    #[inline(always)]
137    pub fn ptto12(&self) -> PttoR {
138        PttoR::new(((self.bits >> 12) & 1) != 0)
139    }
140    #[doc = "Bit 13 - Port Toggle Output"]
141    #[inline(always)]
142    pub fn ptto13(&self) -> PttoR {
143        PttoR::new(((self.bits >> 13) & 1) != 0)
144    }
145    #[doc = "Bit 14 - Port Toggle Output"]
146    #[inline(always)]
147    pub fn ptto14(&self) -> PttoR {
148        PttoR::new(((self.bits >> 14) & 1) != 0)
149    }
150    #[doc = "Bit 15 - Port Toggle Output"]
151    #[inline(always)]
152    pub fn ptto15(&self) -> PttoR {
153        PttoR::new(((self.bits >> 15) & 1) != 0)
154    }
155    #[doc = "Bit 16 - Port Toggle Output"]
156    #[inline(always)]
157    pub fn ptto16(&self) -> PttoR {
158        PttoR::new(((self.bits >> 16) & 1) != 0)
159    }
160    #[doc = "Bit 17 - Port Toggle Output"]
161    #[inline(always)]
162    pub fn ptto17(&self) -> PttoR {
163        PttoR::new(((self.bits >> 17) & 1) != 0)
164    }
165    #[doc = "Bit 18 - Port Toggle Output"]
166    #[inline(always)]
167    pub fn ptto18(&self) -> PttoR {
168        PttoR::new(((self.bits >> 18) & 1) != 0)
169    }
170    #[doc = "Bit 19 - Port Toggle Output"]
171    #[inline(always)]
172    pub fn ptto19(&self) -> PttoR {
173        PttoR::new(((self.bits >> 19) & 1) != 0)
174    }
175    #[doc = "Bit 20 - Port Toggle Output"]
176    #[inline(always)]
177    pub fn ptto20(&self) -> PttoR {
178        PttoR::new(((self.bits >> 20) & 1) != 0)
179    }
180    #[doc = "Bit 21 - Port Toggle Output"]
181    #[inline(always)]
182    pub fn ptto21(&self) -> PttoR {
183        PttoR::new(((self.bits >> 21) & 1) != 0)
184    }
185    #[doc = "Bit 22 - Port Toggle Output"]
186    #[inline(always)]
187    pub fn ptto22(&self) -> PttoR {
188        PttoR::new(((self.bits >> 22) & 1) != 0)
189    }
190    #[doc = "Bit 23 - Port Toggle Output"]
191    #[inline(always)]
192    pub fn ptto23(&self) -> PttoR {
193        PttoR::new(((self.bits >> 23) & 1) != 0)
194    }
195    #[doc = "Bit 24 - Port Toggle Output"]
196    #[inline(always)]
197    pub fn ptto24(&self) -> PttoR {
198        PttoR::new(((self.bits >> 24) & 1) != 0)
199    }
200    #[doc = "Bit 25 - Port Toggle Output"]
201    #[inline(always)]
202    pub fn ptto25(&self) -> PttoR {
203        PttoR::new(((self.bits >> 25) & 1) != 0)
204    }
205    #[doc = "Bit 26 - Port Toggle Output"]
206    #[inline(always)]
207    pub fn ptto26(&self) -> PttoR {
208        PttoR::new(((self.bits >> 26) & 1) != 0)
209    }
210    #[doc = "Bit 27 - Port Toggle Output"]
211    #[inline(always)]
212    pub fn ptto27(&self) -> PttoR {
213        PttoR::new(((self.bits >> 27) & 1) != 0)
214    }
215    #[doc = "Bit 28 - Port Toggle Output"]
216    #[inline(always)]
217    pub fn ptto28(&self) -> PttoR {
218        PttoR::new(((self.bits >> 28) & 1) != 0)
219    }
220    #[doc = "Bit 29 - Port Toggle Output"]
221    #[inline(always)]
222    pub fn ptto29(&self) -> PttoR {
223        PttoR::new(((self.bits >> 29) & 1) != 0)
224    }
225    #[doc = "Bit 30 - Port Toggle Output"]
226    #[inline(always)]
227    pub fn ptto30(&self) -> PttoR {
228        PttoR::new(((self.bits >> 30) & 1) != 0)
229    }
230    #[doc = "Bit 31 - Port Toggle Output"]
231    #[inline(always)]
232    pub fn ptto31(&self) -> PttoR {
233        PttoR::new(((self.bits >> 31) & 1) != 0)
234    }
235}
236#[cfg(feature = "debug")]
237impl core::fmt::Debug for R {
238    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
239        f.debug_struct("PTOR")
240            .field("ptto0", &self.ptto0())
241            .field("ptto1", &self.ptto1())
242            .field("ptto2", &self.ptto2())
243            .field("ptto3", &self.ptto3())
244            .field("ptto4", &self.ptto4())
245            .field("ptto5", &self.ptto5())
246            .field("ptto6", &self.ptto6())
247            .field("ptto7", &self.ptto7())
248            .field("ptto8", &self.ptto8())
249            .field("ptto9", &self.ptto9())
250            .field("ptto10", &self.ptto10())
251            .field("ptto11", &self.ptto11())
252            .field("ptto12", &self.ptto12())
253            .field("ptto13", &self.ptto13())
254            .field("ptto14", &self.ptto14())
255            .field("ptto15", &self.ptto15())
256            .field("ptto16", &self.ptto16())
257            .field("ptto17", &self.ptto17())
258            .field("ptto18", &self.ptto18())
259            .field("ptto19", &self.ptto19())
260            .field("ptto20", &self.ptto20())
261            .field("ptto21", &self.ptto21())
262            .field("ptto22", &self.ptto22())
263            .field("ptto23", &self.ptto23())
264            .field("ptto24", &self.ptto24())
265            .field("ptto25", &self.ptto25())
266            .field("ptto26", &self.ptto26())
267            .field("ptto27", &self.ptto27())
268            .field("ptto28", &self.ptto28())
269            .field("ptto29", &self.ptto29())
270            .field("ptto30", &self.ptto30())
271            .field("ptto31", &self.ptto31())
272            .finish()
273    }
274}
275impl W {
276    #[doc = "Port Toggle Output"]
277    #[doc = ""]
278    #[doc = "<div class=\"warning\">`n` is number of field in register. `n == 0` corresponds to `PTTO0` field.</div>"]
279    #[inline(always)]
280    pub fn ptto(&mut self, n: u8) -> PttoW<'_, PtorSpec> {
281        #[allow(clippy::no_effect)]
282        [(); 32][n as usize];
283        PttoW::new(self, n)
284    }
285    #[doc = "Bit 0 - Port Toggle Output"]
286    #[inline(always)]
287    pub fn ptto0(&mut self) -> PttoW<'_, PtorSpec> {
288        PttoW::new(self, 0)
289    }
290    #[doc = "Bit 1 - Port Toggle Output"]
291    #[inline(always)]
292    pub fn ptto1(&mut self) -> PttoW<'_, PtorSpec> {
293        PttoW::new(self, 1)
294    }
295    #[doc = "Bit 2 - Port Toggle Output"]
296    #[inline(always)]
297    pub fn ptto2(&mut self) -> PttoW<'_, PtorSpec> {
298        PttoW::new(self, 2)
299    }
300    #[doc = "Bit 3 - Port Toggle Output"]
301    #[inline(always)]
302    pub fn ptto3(&mut self) -> PttoW<'_, PtorSpec> {
303        PttoW::new(self, 3)
304    }
305    #[doc = "Bit 4 - Port Toggle Output"]
306    #[inline(always)]
307    pub fn ptto4(&mut self) -> PttoW<'_, PtorSpec> {
308        PttoW::new(self, 4)
309    }
310    #[doc = "Bit 5 - Port Toggle Output"]
311    #[inline(always)]
312    pub fn ptto5(&mut self) -> PttoW<'_, PtorSpec> {
313        PttoW::new(self, 5)
314    }
315    #[doc = "Bit 6 - Port Toggle Output"]
316    #[inline(always)]
317    pub fn ptto6(&mut self) -> PttoW<'_, PtorSpec> {
318        PttoW::new(self, 6)
319    }
320    #[doc = "Bit 7 - Port Toggle Output"]
321    #[inline(always)]
322    pub fn ptto7(&mut self) -> PttoW<'_, PtorSpec> {
323        PttoW::new(self, 7)
324    }
325    #[doc = "Bit 8 - Port Toggle Output"]
326    #[inline(always)]
327    pub fn ptto8(&mut self) -> PttoW<'_, PtorSpec> {
328        PttoW::new(self, 8)
329    }
330    #[doc = "Bit 9 - Port Toggle Output"]
331    #[inline(always)]
332    pub fn ptto9(&mut self) -> PttoW<'_, PtorSpec> {
333        PttoW::new(self, 9)
334    }
335    #[doc = "Bit 10 - Port Toggle Output"]
336    #[inline(always)]
337    pub fn ptto10(&mut self) -> PttoW<'_, PtorSpec> {
338        PttoW::new(self, 10)
339    }
340    #[doc = "Bit 11 - Port Toggle Output"]
341    #[inline(always)]
342    pub fn ptto11(&mut self) -> PttoW<'_, PtorSpec> {
343        PttoW::new(self, 11)
344    }
345    #[doc = "Bit 12 - Port Toggle Output"]
346    #[inline(always)]
347    pub fn ptto12(&mut self) -> PttoW<'_, PtorSpec> {
348        PttoW::new(self, 12)
349    }
350    #[doc = "Bit 13 - Port Toggle Output"]
351    #[inline(always)]
352    pub fn ptto13(&mut self) -> PttoW<'_, PtorSpec> {
353        PttoW::new(self, 13)
354    }
355    #[doc = "Bit 14 - Port Toggle Output"]
356    #[inline(always)]
357    pub fn ptto14(&mut self) -> PttoW<'_, PtorSpec> {
358        PttoW::new(self, 14)
359    }
360    #[doc = "Bit 15 - Port Toggle Output"]
361    #[inline(always)]
362    pub fn ptto15(&mut self) -> PttoW<'_, PtorSpec> {
363        PttoW::new(self, 15)
364    }
365    #[doc = "Bit 16 - Port Toggle Output"]
366    #[inline(always)]
367    pub fn ptto16(&mut self) -> PttoW<'_, PtorSpec> {
368        PttoW::new(self, 16)
369    }
370    #[doc = "Bit 17 - Port Toggle Output"]
371    #[inline(always)]
372    pub fn ptto17(&mut self) -> PttoW<'_, PtorSpec> {
373        PttoW::new(self, 17)
374    }
375    #[doc = "Bit 18 - Port Toggle Output"]
376    #[inline(always)]
377    pub fn ptto18(&mut self) -> PttoW<'_, PtorSpec> {
378        PttoW::new(self, 18)
379    }
380    #[doc = "Bit 19 - Port Toggle Output"]
381    #[inline(always)]
382    pub fn ptto19(&mut self) -> PttoW<'_, PtorSpec> {
383        PttoW::new(self, 19)
384    }
385    #[doc = "Bit 20 - Port Toggle Output"]
386    #[inline(always)]
387    pub fn ptto20(&mut self) -> PttoW<'_, PtorSpec> {
388        PttoW::new(self, 20)
389    }
390    #[doc = "Bit 21 - Port Toggle Output"]
391    #[inline(always)]
392    pub fn ptto21(&mut self) -> PttoW<'_, PtorSpec> {
393        PttoW::new(self, 21)
394    }
395    #[doc = "Bit 22 - Port Toggle Output"]
396    #[inline(always)]
397    pub fn ptto22(&mut self) -> PttoW<'_, PtorSpec> {
398        PttoW::new(self, 22)
399    }
400    #[doc = "Bit 23 - Port Toggle Output"]
401    #[inline(always)]
402    pub fn ptto23(&mut self) -> PttoW<'_, PtorSpec> {
403        PttoW::new(self, 23)
404    }
405    #[doc = "Bit 24 - Port Toggle Output"]
406    #[inline(always)]
407    pub fn ptto24(&mut self) -> PttoW<'_, PtorSpec> {
408        PttoW::new(self, 24)
409    }
410    #[doc = "Bit 25 - Port Toggle Output"]
411    #[inline(always)]
412    pub fn ptto25(&mut self) -> PttoW<'_, PtorSpec> {
413        PttoW::new(self, 25)
414    }
415    #[doc = "Bit 26 - Port Toggle Output"]
416    #[inline(always)]
417    pub fn ptto26(&mut self) -> PttoW<'_, PtorSpec> {
418        PttoW::new(self, 26)
419    }
420    #[doc = "Bit 27 - Port Toggle Output"]
421    #[inline(always)]
422    pub fn ptto27(&mut self) -> PttoW<'_, PtorSpec> {
423        PttoW::new(self, 27)
424    }
425    #[doc = "Bit 28 - Port Toggle Output"]
426    #[inline(always)]
427    pub fn ptto28(&mut self) -> PttoW<'_, PtorSpec> {
428        PttoW::new(self, 28)
429    }
430    #[doc = "Bit 29 - Port Toggle Output"]
431    #[inline(always)]
432    pub fn ptto29(&mut self) -> PttoW<'_, PtorSpec> {
433        PttoW::new(self, 29)
434    }
435    #[doc = "Bit 30 - Port Toggle Output"]
436    #[inline(always)]
437    pub fn ptto30(&mut self) -> PttoW<'_, PtorSpec> {
438        PttoW::new(self, 30)
439    }
440    #[doc = "Bit 31 - Port Toggle Output"]
441    #[inline(always)]
442    pub fn ptto31(&mut self) -> PttoW<'_, PtorSpec> {
443        PttoW::new(self, 31)
444    }
445}
446#[doc = "Port Toggle Output\n\nYou can [`read`](crate::Reg::read) this register and get [`ptor::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ptor::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
447pub struct PtorSpec;
448impl crate::RegisterSpec for PtorSpec {
449    type Ux = u32;
450}
451#[doc = "`read()` method returns [`ptor::R`](R) reader structure"]
452impl crate::Readable for PtorSpec {}
453#[doc = "`write(|w| ..)` method takes [`ptor::W`](W) writer structure"]
454impl crate::Writable for PtorSpec {
455    type Safety = crate::Unsafe;
456}
457#[doc = "`reset()` method sets PTOR to value 0"]
458impl crate::Resettable for PtorSpec {}