efm32pg12_pac/gpio/
routeloc0.rs

1#[doc = "Reader of register ROUTELOC0"]
2pub type R = crate::R<u32, super::ROUTELOC0>;
3#[doc = "Writer for register ROUTELOC0"]
4pub type W = crate::W<u32, super::ROUTELOC0>;
5#[doc = "Register ROUTELOC0 `reset()`'s with value 0"]
6impl crate::ResetValue for super::ROUTELOC0 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "I/O Location\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum SWVLOC_A {
17    #[doc = "0: Location 0"]
18    LOC0 = 0,
19    #[doc = "1: Location 1"]
20    LOC1 = 1,
21    #[doc = "2: Location 2"]
22    LOC2 = 2,
23    #[doc = "3: Location 3"]
24    LOC3 = 3,
25}
26impl From<SWVLOC_A> for u8 {
27    #[inline(always)]
28    fn from(variant: SWVLOC_A) -> Self {
29        variant as _
30    }
31}
32#[doc = "Reader of field `SWVLOC`"]
33pub type SWVLOC_R = crate::R<u8, SWVLOC_A>;
34impl SWVLOC_R {
35    #[doc = r"Get enumerated values variant"]
36    #[inline(always)]
37    pub fn variant(&self) -> crate::Variant<u8, SWVLOC_A> {
38        use crate::Variant::*;
39        match self.bits {
40            0 => Val(SWVLOC_A::LOC0),
41            1 => Val(SWVLOC_A::LOC1),
42            2 => Val(SWVLOC_A::LOC2),
43            3 => Val(SWVLOC_A::LOC3),
44            i => Res(i),
45        }
46    }
47    #[doc = "Checks if the value of the field is `LOC0`"]
48    #[inline(always)]
49    pub fn is_loc0(&self) -> bool {
50        *self == SWVLOC_A::LOC0
51    }
52    #[doc = "Checks if the value of the field is `LOC1`"]
53    #[inline(always)]
54    pub fn is_loc1(&self) -> bool {
55        *self == SWVLOC_A::LOC1
56    }
57    #[doc = "Checks if the value of the field is `LOC2`"]
58    #[inline(always)]
59    pub fn is_loc2(&self) -> bool {
60        *self == SWVLOC_A::LOC2
61    }
62    #[doc = "Checks if the value of the field is `LOC3`"]
63    #[inline(always)]
64    pub fn is_loc3(&self) -> bool {
65        *self == SWVLOC_A::LOC3
66    }
67}
68#[doc = "Write proxy for field `SWVLOC`"]
69pub struct SWVLOC_W<'a> {
70    w: &'a mut W,
71}
72impl<'a> SWVLOC_W<'a> {
73    #[doc = r"Writes `variant` to the field"]
74    #[inline(always)]
75    pub fn variant(self, variant: SWVLOC_A) -> &'a mut W {
76        unsafe { self.bits(variant.into()) }
77    }
78    #[doc = "Location 0"]
79    #[inline(always)]
80    pub fn loc0(self) -> &'a mut W {
81        self.variant(SWVLOC_A::LOC0)
82    }
83    #[doc = "Location 1"]
84    #[inline(always)]
85    pub fn loc1(self) -> &'a mut W {
86        self.variant(SWVLOC_A::LOC1)
87    }
88    #[doc = "Location 2"]
89    #[inline(always)]
90    pub fn loc2(self) -> &'a mut W {
91        self.variant(SWVLOC_A::LOC2)
92    }
93    #[doc = "Location 3"]
94    #[inline(always)]
95    pub fn loc3(self) -> &'a mut W {
96        self.variant(SWVLOC_A::LOC3)
97    }
98    #[doc = r"Writes raw bits to the field"]
99    #[inline(always)]
100    pub unsafe fn bits(self, value: u8) -> &'a mut W {
101        self.w.bits = (self.w.bits & !0x3f) | ((value as u32) & 0x3f);
102        self.w
103    }
104}
105impl R {
106    #[doc = "Bits 0:5 - I/O Location"]
107    #[inline(always)]
108    pub fn swvloc(&self) -> SWVLOC_R {
109        SWVLOC_R::new((self.bits & 0x3f) as u8)
110    }
111}
112impl W {
113    #[doc = "Bits 0:5 - I/O Location"]
114    #[inline(always)]
115    pub fn swvloc(&mut self) -> SWVLOC_W {
116        SWVLOC_W { w: self }
117    }
118}