1#[doc = r" Value read from the register"]
2pub struct R {
3 bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7 bits: u32,
8}
9impl super::PIO1_5 {
10 #[doc = r" Modifies the contents of the register"]
11 #[inline]
12 pub fn modify<F>(&self, f: F)
13 where
14 for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15 {
16 let bits = self.register.get();
17 let r = R { bits: bits };
18 let mut w = W { bits: bits };
19 f(&r, &mut w);
20 self.register.set(w.bits);
21 }
22 #[doc = r" Reads the contents of the register"]
23 #[inline]
24 pub fn read(&self) -> R {
25 R {
26 bits: self.register.get(),
27 }
28 }
29 #[doc = r" Writes to the register"]
30 #[inline]
31 pub fn write<F>(&self, f: F)
32 where
33 F: FnOnce(&mut W) -> &mut W,
34 {
35 let mut w = W::reset_value();
36 f(&mut w);
37 self.register.set(w.bits);
38 }
39 #[doc = r" Writes the reset value to the register"]
40 #[inline]
41 pub fn reset(&self) {
42 self.write(|w| w)
43 }
44}
45#[doc = "Possible values of the field `FUNC`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum FUNCR {
48 #[doc = "PIO1_5."]
49 PIO1_5,
50 #[doc = "CT32B1_CAP1."]
51 CT32B1_CAP1,
52 #[doc = r" Reserved"]
53 _Reserved(u8),
54}
55impl FUNCR {
56 #[doc = r" Value of the field as raw bits"]
57 #[inline]
58 pub fn bits(&self) -> u8 {
59 match *self {
60 FUNCR::PIO1_5 => 0,
61 FUNCR::CT32B1_CAP1 => 1,
62 FUNCR::_Reserved(bits) => bits,
63 }
64 }
65 #[allow(missing_docs)]
66 #[doc(hidden)]
67 #[inline]
68 pub fn _from(value: u8) -> FUNCR {
69 match value {
70 0 => FUNCR::PIO1_5,
71 1 => FUNCR::CT32B1_CAP1,
72 i => FUNCR::_Reserved(i),
73 }
74 }
75 #[doc = "Checks if the value of the field is `PIO1_5`"]
76 #[inline]
77 pub fn is_pio1_5(&self) -> bool {
78 *self == FUNCR::PIO1_5
79 }
80 #[doc = "Checks if the value of the field is `CT32B1_CAP1`"]
81 #[inline]
82 pub fn is_ct32b1_cap1(&self) -> bool {
83 *self == FUNCR::CT32B1_CAP1
84 }
85}
86#[doc = "Possible values of the field `MODE`"]
87#[derive(Clone, Copy, Debug, PartialEq)]
88pub enum MODER {
89 #[doc = "Inactive (no pull-down/pull-up resistor enabled)."]
90 INACTIVE,
91 #[doc = "Pull-down resistor enabled."]
92 PULL_DOWN,
93 #[doc = "Pull-up resistor enabled."]
94 PULL_UP,
95 #[doc = "Repeater mode."]
96 REPEATER,
97}
98impl MODER {
99 #[doc = r" Value of the field as raw bits"]
100 #[inline]
101 pub fn bits(&self) -> u8 {
102 match *self {
103 MODER::INACTIVE => 0,
104 MODER::PULL_DOWN => 1,
105 MODER::PULL_UP => 2,
106 MODER::REPEATER => 3,
107 }
108 }
109 #[allow(missing_docs)]
110 #[doc(hidden)]
111 #[inline]
112 pub fn _from(value: u8) -> MODER {
113 match value {
114 0 => MODER::INACTIVE,
115 1 => MODER::PULL_DOWN,
116 2 => MODER::PULL_UP,
117 3 => MODER::REPEATER,
118 _ => unreachable!(),
119 }
120 }
121 #[doc = "Checks if the value of the field is `INACTIVE`"]
122 #[inline]
123 pub fn is_inactive(&self) -> bool {
124 *self == MODER::INACTIVE
125 }
126 #[doc = "Checks if the value of the field is `PULL_DOWN`"]
127 #[inline]
128 pub fn is_pull_down(&self) -> bool {
129 *self == MODER::PULL_DOWN
130 }
131 #[doc = "Checks if the value of the field is `PULL_UP`"]
132 #[inline]
133 pub fn is_pull_up(&self) -> bool {
134 *self == MODER::PULL_UP
135 }
136 #[doc = "Checks if the value of the field is `REPEATER`"]
137 #[inline]
138 pub fn is_repeater(&self) -> bool {
139 *self == MODER::REPEATER
140 }
141}
142#[doc = "Possible values of the field `HYS`"]
143#[derive(Clone, Copy, Debug, PartialEq)]
144pub enum HYSR {
145 #[doc = "Disable."]
146 DISABLED,
147 #[doc = "Enable."]
148 ENABLED,
149}
150impl HYSR {
151 #[doc = r" Returns `true` if the bit is clear (0)"]
152 #[inline]
153 pub fn bit_is_clear(&self) -> bool {
154 !self.bit()
155 }
156 #[doc = r" Returns `true` if the bit is set (1)"]
157 #[inline]
158 pub fn bit_is_set(&self) -> bool {
159 self.bit()
160 }
161 #[doc = r" Value of the field as raw bits"]
162 #[inline]
163 pub fn bit(&self) -> bool {
164 match *self {
165 HYSR::DISABLED => false,
166 HYSR::ENABLED => true,
167 }
168 }
169 #[allow(missing_docs)]
170 #[doc(hidden)]
171 #[inline]
172 pub fn _from(value: bool) -> HYSR {
173 match value {
174 false => HYSR::DISABLED,
175 true => HYSR::ENABLED,
176 }
177 }
178 #[doc = "Checks if the value of the field is `DISABLED`"]
179 #[inline]
180 pub fn is_disabled(&self) -> bool {
181 *self == HYSR::DISABLED
182 }
183 #[doc = "Checks if the value of the field is `ENABLED`"]
184 #[inline]
185 pub fn is_enabled(&self) -> bool {
186 *self == HYSR::ENABLED
187 }
188}
189#[doc = "Possible values of the field `INV`"]
190#[derive(Clone, Copy, Debug, PartialEq)]
191pub enum INVR {
192 #[doc = "Input not inverted (HIGH on pin reads as 1, LOW on pin reads as 0)."]
193 NOT_INVERTED,
194 #[doc = "Input inverted (HIGH on pin reads as 0, LOW on pin reads as 1)."]
195 INVERTED,
196}
197impl INVR {
198 #[doc = r" Returns `true` if the bit is clear (0)"]
199 #[inline]
200 pub fn bit_is_clear(&self) -> bool {
201 !self.bit()
202 }
203 #[doc = r" Returns `true` if the bit is set (1)"]
204 #[inline]
205 pub fn bit_is_set(&self) -> bool {
206 self.bit()
207 }
208 #[doc = r" Value of the field as raw bits"]
209 #[inline]
210 pub fn bit(&self) -> bool {
211 match *self {
212 INVR::NOT_INVERTED => false,
213 INVR::INVERTED => true,
214 }
215 }
216 #[allow(missing_docs)]
217 #[doc(hidden)]
218 #[inline]
219 pub fn _from(value: bool) -> INVR {
220 match value {
221 false => INVR::NOT_INVERTED,
222 true => INVR::INVERTED,
223 }
224 }
225 #[doc = "Checks if the value of the field is `NOT_INVERTED`"]
226 #[inline]
227 pub fn is_not_inverted(&self) -> bool {
228 *self == INVR::NOT_INVERTED
229 }
230 #[doc = "Checks if the value of the field is `INVERTED`"]
231 #[inline]
232 pub fn is_inverted(&self) -> bool {
233 *self == INVR::INVERTED
234 }
235}
236#[doc = "Possible values of the field `OD`"]
237#[derive(Clone, Copy, Debug, PartialEq)]
238pub enum ODR {
239 #[doc = "Disable."]
240 DISABLED,
241 #[doc = "Open-drain mode enabled. This is not a true open-drain mode."]
242 OPEN_DRAIN,
243}
244impl ODR {
245 #[doc = r" Returns `true` if the bit is clear (0)"]
246 #[inline]
247 pub fn bit_is_clear(&self) -> bool {
248 !self.bit()
249 }
250 #[doc = r" Returns `true` if the bit is set (1)"]
251 #[inline]
252 pub fn bit_is_set(&self) -> bool {
253 self.bit()
254 }
255 #[doc = r" Value of the field as raw bits"]
256 #[inline]
257 pub fn bit(&self) -> bool {
258 match *self {
259 ODR::DISABLED => false,
260 ODR::OPEN_DRAIN => true,
261 }
262 }
263 #[allow(missing_docs)]
264 #[doc(hidden)]
265 #[inline]
266 pub fn _from(value: bool) -> ODR {
267 match value {
268 false => ODR::DISABLED,
269 true => ODR::OPEN_DRAIN,
270 }
271 }
272 #[doc = "Checks if the value of the field is `DISABLED`"]
273 #[inline]
274 pub fn is_disabled(&self) -> bool {
275 *self == ODR::DISABLED
276 }
277 #[doc = "Checks if the value of the field is `OPEN_DRAIN`"]
278 #[inline]
279 pub fn is_open_drain(&self) -> bool {
280 *self == ODR::OPEN_DRAIN
281 }
282}
283#[doc = "Values that can be written to the field `FUNC`"]
284pub enum FUNCW {
285 #[doc = "PIO1_5."]
286 PIO1_5,
287 #[doc = "CT32B1_CAP1."]
288 CT32B1_CAP1,
289}
290impl FUNCW {
291 #[allow(missing_docs)]
292 #[doc(hidden)]
293 #[inline]
294 pub fn _bits(&self) -> u8 {
295 match *self {
296 FUNCW::PIO1_5 => 0,
297 FUNCW::CT32B1_CAP1 => 1,
298 }
299 }
300}
301#[doc = r" Proxy"]
302pub struct _FUNCW<'a> {
303 w: &'a mut W,
304}
305impl<'a> _FUNCW<'a> {
306 #[doc = r" Writes `variant` to the field"]
307 #[inline]
308 pub fn variant(self, variant: FUNCW) -> &'a mut W {
309 unsafe { self.bits(variant._bits()) }
310 }
311 #[doc = "PIO1_5."]
312 #[inline]
313 pub fn pio1_5(self) -> &'a mut W {
314 self.variant(FUNCW::PIO1_5)
315 }
316 #[doc = "CT32B1_CAP1."]
317 #[inline]
318 pub fn ct32b1_cap1(self) -> &'a mut W {
319 self.variant(FUNCW::CT32B1_CAP1)
320 }
321 #[doc = r" Writes raw bits to the field"]
322 #[inline]
323 pub unsafe fn bits(self, value: u8) -> &'a mut W {
324 const MASK: u8 = 7;
325 const OFFSET: u8 = 0;
326 self.w.bits &= !((MASK as u32) << OFFSET);
327 self.w.bits |= ((value & MASK) as u32) << OFFSET;
328 self.w
329 }
330}
331#[doc = "Values that can be written to the field `MODE`"]
332pub enum MODEW {
333 #[doc = "Inactive (no pull-down/pull-up resistor enabled)."]
334 INACTIVE,
335 #[doc = "Pull-down resistor enabled."]
336 PULL_DOWN,
337 #[doc = "Pull-up resistor enabled."]
338 PULL_UP,
339 #[doc = "Repeater mode."]
340 REPEATER,
341}
342impl MODEW {
343 #[allow(missing_docs)]
344 #[doc(hidden)]
345 #[inline]
346 pub fn _bits(&self) -> u8 {
347 match *self {
348 MODEW::INACTIVE => 0,
349 MODEW::PULL_DOWN => 1,
350 MODEW::PULL_UP => 2,
351 MODEW::REPEATER => 3,
352 }
353 }
354}
355#[doc = r" Proxy"]
356pub struct _MODEW<'a> {
357 w: &'a mut W,
358}
359impl<'a> _MODEW<'a> {
360 #[doc = r" Writes `variant` to the field"]
361 #[inline]
362 pub fn variant(self, variant: MODEW) -> &'a mut W {
363 {
364 self.bits(variant._bits())
365 }
366 }
367 #[doc = "Inactive (no pull-down/pull-up resistor enabled)."]
368 #[inline]
369 pub fn inactive(self) -> &'a mut W {
370 self.variant(MODEW::INACTIVE)
371 }
372 #[doc = "Pull-down resistor enabled."]
373 #[inline]
374 pub fn pull_down(self) -> &'a mut W {
375 self.variant(MODEW::PULL_DOWN)
376 }
377 #[doc = "Pull-up resistor enabled."]
378 #[inline]
379 pub fn pull_up(self) -> &'a mut W {
380 self.variant(MODEW::PULL_UP)
381 }
382 #[doc = "Repeater mode."]
383 #[inline]
384 pub fn repeater(self) -> &'a mut W {
385 self.variant(MODEW::REPEATER)
386 }
387 #[doc = r" Writes raw bits to the field"]
388 #[inline]
389 pub fn bits(self, value: u8) -> &'a mut W {
390 const MASK: u8 = 3;
391 const OFFSET: u8 = 3;
392 self.w.bits &= !((MASK as u32) << OFFSET);
393 self.w.bits |= ((value & MASK) as u32) << OFFSET;
394 self.w
395 }
396}
397#[doc = "Values that can be written to the field `HYS`"]
398pub enum HYSW {
399 #[doc = "Disable."]
400 DISABLED,
401 #[doc = "Enable."]
402 ENABLED,
403}
404impl HYSW {
405 #[allow(missing_docs)]
406 #[doc(hidden)]
407 #[inline]
408 pub fn _bits(&self) -> bool {
409 match *self {
410 HYSW::DISABLED => false,
411 HYSW::ENABLED => true,
412 }
413 }
414}
415#[doc = r" Proxy"]
416pub struct _HYSW<'a> {
417 w: &'a mut W,
418}
419impl<'a> _HYSW<'a> {
420 #[doc = r" Writes `variant` to the field"]
421 #[inline]
422 pub fn variant(self, variant: HYSW) -> &'a mut W {
423 {
424 self.bit(variant._bits())
425 }
426 }
427 #[doc = "Disable."]
428 #[inline]
429 pub fn disabled(self) -> &'a mut W {
430 self.variant(HYSW::DISABLED)
431 }
432 #[doc = "Enable."]
433 #[inline]
434 pub fn enabled(self) -> &'a mut W {
435 self.variant(HYSW::ENABLED)
436 }
437 #[doc = r" Sets the field bit"]
438 pub fn set_bit(self) -> &'a mut W {
439 self.bit(true)
440 }
441 #[doc = r" Clears the field bit"]
442 pub fn clear_bit(self) -> &'a mut W {
443 self.bit(false)
444 }
445 #[doc = r" Writes raw bits to the field"]
446 #[inline]
447 pub fn bit(self, value: bool) -> &'a mut W {
448 const MASK: bool = true;
449 const OFFSET: u8 = 5;
450 self.w.bits &= !((MASK as u32) << OFFSET);
451 self.w.bits |= ((value & MASK) as u32) << OFFSET;
452 self.w
453 }
454}
455#[doc = "Values that can be written to the field `INV`"]
456pub enum INVW {
457 #[doc = "Input not inverted (HIGH on pin reads as 1, LOW on pin reads as 0)."]
458 NOT_INVERTED,
459 #[doc = "Input inverted (HIGH on pin reads as 0, LOW on pin reads as 1)."]
460 INVERTED,
461}
462impl INVW {
463 #[allow(missing_docs)]
464 #[doc(hidden)]
465 #[inline]
466 pub fn _bits(&self) -> bool {
467 match *self {
468 INVW::NOT_INVERTED => false,
469 INVW::INVERTED => true,
470 }
471 }
472}
473#[doc = r" Proxy"]
474pub struct _INVW<'a> {
475 w: &'a mut W,
476}
477impl<'a> _INVW<'a> {
478 #[doc = r" Writes `variant` to the field"]
479 #[inline]
480 pub fn variant(self, variant: INVW) -> &'a mut W {
481 {
482 self.bit(variant._bits())
483 }
484 }
485 #[doc = "Input not inverted (HIGH on pin reads as 1, LOW on pin reads as 0)."]
486 #[inline]
487 pub fn not_inverted(self) -> &'a mut W {
488 self.variant(INVW::NOT_INVERTED)
489 }
490 #[doc = "Input inverted (HIGH on pin reads as 0, LOW on pin reads as 1)."]
491 #[inline]
492 pub fn inverted(self) -> &'a mut W {
493 self.variant(INVW::INVERTED)
494 }
495 #[doc = r" Sets the field bit"]
496 pub fn set_bit(self) -> &'a mut W {
497 self.bit(true)
498 }
499 #[doc = r" Clears the field bit"]
500 pub fn clear_bit(self) -> &'a mut W {
501 self.bit(false)
502 }
503 #[doc = r" Writes raw bits to the field"]
504 #[inline]
505 pub fn bit(self, value: bool) -> &'a mut W {
506 const MASK: bool = true;
507 const OFFSET: u8 = 6;
508 self.w.bits &= !((MASK as u32) << OFFSET);
509 self.w.bits |= ((value & MASK) as u32) << OFFSET;
510 self.w
511 }
512}
513#[doc = "Values that can be written to the field `OD`"]
514pub enum ODW {
515 #[doc = "Disable."]
516 DISABLED,
517 #[doc = "Open-drain mode enabled. This is not a true open-drain mode."]
518 OPEN_DRAIN,
519}
520impl ODW {
521 #[allow(missing_docs)]
522 #[doc(hidden)]
523 #[inline]
524 pub fn _bits(&self) -> bool {
525 match *self {
526 ODW::DISABLED => false,
527 ODW::OPEN_DRAIN => true,
528 }
529 }
530}
531#[doc = r" Proxy"]
532pub struct _ODW<'a> {
533 w: &'a mut W,
534}
535impl<'a> _ODW<'a> {
536 #[doc = r" Writes `variant` to the field"]
537 #[inline]
538 pub fn variant(self, variant: ODW) -> &'a mut W {
539 {
540 self.bit(variant._bits())
541 }
542 }
543 #[doc = "Disable."]
544 #[inline]
545 pub fn disabled(self) -> &'a mut W {
546 self.variant(ODW::DISABLED)
547 }
548 #[doc = "Open-drain mode enabled. This is not a true open-drain mode."]
549 #[inline]
550 pub fn open_drain(self) -> &'a mut W {
551 self.variant(ODW::OPEN_DRAIN)
552 }
553 #[doc = r" Sets the field bit"]
554 pub fn set_bit(self) -> &'a mut W {
555 self.bit(true)
556 }
557 #[doc = r" Clears the field bit"]
558 pub fn clear_bit(self) -> &'a mut W {
559 self.bit(false)
560 }
561 #[doc = r" Writes raw bits to the field"]
562 #[inline]
563 pub fn bit(self, value: bool) -> &'a mut W {
564 const MASK: bool = true;
565 const OFFSET: u8 = 10;
566 self.w.bits &= !((MASK as u32) << OFFSET);
567 self.w.bits |= ((value & MASK) as u32) << OFFSET;
568 self.w
569 }
570}
571impl R {
572 #[doc = r" Value of the register as raw bits"]
573 #[inline]
574 pub fn bits(&self) -> u32 {
575 self.bits
576 }
577 #[doc = "Bits 0:2 - Selects pin function. Values 0x2 to 0x7 are reserved."]
578 #[inline]
579 pub fn func(&self) -> FUNCR {
580 FUNCR::_from({
581 const MASK: u8 = 7;
582 const OFFSET: u8 = 0;
583 ((self.bits >> OFFSET) & MASK as u32) as u8
584 })
585 }
586 #[doc = "Bits 3:4 - Selects function mode (on-chip pull-up/pull-down resistor control)."]
587 #[inline]
588 pub fn mode(&self) -> MODER {
589 MODER::_from({
590 const MASK: u8 = 3;
591 const OFFSET: u8 = 3;
592 ((self.bits >> OFFSET) & MASK as u32) as u8
593 })
594 }
595 #[doc = "Bit 5 - Hysteresis."]
596 #[inline]
597 pub fn hys(&self) -> HYSR {
598 HYSR::_from({
599 const MASK: bool = true;
600 const OFFSET: u8 = 5;
601 ((self.bits >> OFFSET) & MASK as u32) != 0
602 })
603 }
604 #[doc = "Bit 6 - Invert input"]
605 #[inline]
606 pub fn inv(&self) -> INVR {
607 INVR::_from({
608 const MASK: bool = true;
609 const OFFSET: u8 = 6;
610 ((self.bits >> OFFSET) & MASK as u32) != 0
611 })
612 }
613 #[doc = "Bit 10 - Open-drain mode."]
614 #[inline]
615 pub fn od(&self) -> ODR {
616 ODR::_from({
617 const MASK: bool = true;
618 const OFFSET: u8 = 10;
619 ((self.bits >> OFFSET) & MASK as u32) != 0
620 })
621 }
622}
623impl W {
624 #[doc = r" Reset value of the register"]
625 #[inline]
626 pub fn reset_value() -> W {
627 W { bits: 144 }
628 }
629 #[doc = r" Writes raw bits to the register"]
630 #[inline]
631 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
632 self.bits = bits;
633 self
634 }
635 #[doc = "Bits 0:2 - Selects pin function. Values 0x2 to 0x7 are reserved."]
636 #[inline]
637 pub fn func(&mut self) -> _FUNCW {
638 _FUNCW { w: self }
639 }
640 #[doc = "Bits 3:4 - Selects function mode (on-chip pull-up/pull-down resistor control)."]
641 #[inline]
642 pub fn mode(&mut self) -> _MODEW {
643 _MODEW { w: self }
644 }
645 #[doc = "Bit 5 - Hysteresis."]
646 #[inline]
647 pub fn hys(&mut self) -> _HYSW {
648 _HYSW { w: self }
649 }
650 #[doc = "Bit 6 - Invert input"]
651 #[inline]
652 pub fn inv(&mut self) -> _INVW {
653 _INVW { w: self }
654 }
655 #[doc = "Bit 10 - Open-drain mode."]
656 #[inline]
657 pub fn od(&mut self) -> _ODW {
658 _ODW { w: self }
659 }
660}