xmc4300/scu_general/
stcon.rs

1#[doc = "Register `STCON` reader"]
2pub type R = crate::R<STCON_SPEC>;
3#[doc = "Register `STCON` writer"]
4pub type W = crate::W<STCON_SPEC>;
5#[doc = "HW Configuration\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum HWCON_A {
9    #[doc = "0: Normal mode, JTAG"]
10    CONST_00 = 0,
11    #[doc = "1: ASC BSL enabled"]
12    CONST_01 = 1,
13    #[doc = "2: BMI customized boot enabled"]
14    CONST_10 = 2,
15    #[doc = "3: CAN BSL enabled"]
16    CONST_11 = 3,
17}
18impl From<HWCON_A> for u8 {
19    #[inline(always)]
20    fn from(variant: HWCON_A) -> Self {
21        variant as _
22    }
23}
24impl crate::FieldSpec for HWCON_A {
25    type Ux = u8;
26}
27impl crate::IsEnum for HWCON_A {}
28#[doc = "Field `HWCON` reader - HW Configuration"]
29pub type HWCON_R = crate::FieldReader<HWCON_A>;
30impl HWCON_R {
31    #[doc = "Get enumerated values variant"]
32    #[inline(always)]
33    pub const fn variant(&self) -> HWCON_A {
34        match self.bits {
35            0 => HWCON_A::CONST_00,
36            1 => HWCON_A::CONST_01,
37            2 => HWCON_A::CONST_10,
38            3 => HWCON_A::CONST_11,
39            _ => unreachable!(),
40        }
41    }
42    #[doc = "Normal mode, JTAG"]
43    #[inline(always)]
44    pub fn is_const_00(&self) -> bool {
45        *self == HWCON_A::CONST_00
46    }
47    #[doc = "ASC BSL enabled"]
48    #[inline(always)]
49    pub fn is_const_01(&self) -> bool {
50        *self == HWCON_A::CONST_01
51    }
52    #[doc = "BMI customized boot enabled"]
53    #[inline(always)]
54    pub fn is_const_10(&self) -> bool {
55        *self == HWCON_A::CONST_10
56    }
57    #[doc = "CAN BSL enabled"]
58    #[inline(always)]
59    pub fn is_const_11(&self) -> bool {
60        *self == HWCON_A::CONST_11
61    }
62}
63#[doc = "SW Configuration\n\nValue on reset: 0"]
64#[derive(Clone, Copy, Debug, PartialEq, Eq)]
65#[repr(u8)]
66pub enum SWCON_A {
67    #[doc = "0: Normal mode, boot from Boot ROM"]
68    CONST_0000 = 0,
69    #[doc = "1: ASC BSL enabled"]
70    CONST_0001 = 1,
71    #[doc = "2: BMI customized boot enabled"]
72    CONST_0010 = 2,
73    #[doc = "3: CAN BSL enabled"]
74    CONST_0011 = 3,
75    #[doc = "4: Boot from Code SRAM"]
76    CONST_0100 = 4,
77    #[doc = "8: Boot from alternate Flash Address 0"]
78    CONST_1000 = 8,
79    #[doc = "12: Boot from alternate Flash Address 1"]
80    CONST_1100 = 12,
81    #[doc = "14: Enable fallback Alternate Boot Mode (ABM)"]
82    CONST_1110 = 14,
83}
84impl From<SWCON_A> for u8 {
85    #[inline(always)]
86    fn from(variant: SWCON_A) -> Self {
87        variant as _
88    }
89}
90impl crate::FieldSpec for SWCON_A {
91    type Ux = u8;
92}
93impl crate::IsEnum for SWCON_A {}
94#[doc = "Field `SWCON` reader - SW Configuration"]
95pub type SWCON_R = crate::FieldReader<SWCON_A>;
96impl SWCON_R {
97    #[doc = "Get enumerated values variant"]
98    #[inline(always)]
99    pub const fn variant(&self) -> Option<SWCON_A> {
100        match self.bits {
101            0 => Some(SWCON_A::CONST_0000),
102            1 => Some(SWCON_A::CONST_0001),
103            2 => Some(SWCON_A::CONST_0010),
104            3 => Some(SWCON_A::CONST_0011),
105            4 => Some(SWCON_A::CONST_0100),
106            8 => Some(SWCON_A::CONST_1000),
107            12 => Some(SWCON_A::CONST_1100),
108            14 => Some(SWCON_A::CONST_1110),
109            _ => None,
110        }
111    }
112    #[doc = "Normal mode, boot from Boot ROM"]
113    #[inline(always)]
114    pub fn is_const_0000(&self) -> bool {
115        *self == SWCON_A::CONST_0000
116    }
117    #[doc = "ASC BSL enabled"]
118    #[inline(always)]
119    pub fn is_const_0001(&self) -> bool {
120        *self == SWCON_A::CONST_0001
121    }
122    #[doc = "BMI customized boot enabled"]
123    #[inline(always)]
124    pub fn is_const_0010(&self) -> bool {
125        *self == SWCON_A::CONST_0010
126    }
127    #[doc = "CAN BSL enabled"]
128    #[inline(always)]
129    pub fn is_const_0011(&self) -> bool {
130        *self == SWCON_A::CONST_0011
131    }
132    #[doc = "Boot from Code SRAM"]
133    #[inline(always)]
134    pub fn is_const_0100(&self) -> bool {
135        *self == SWCON_A::CONST_0100
136    }
137    #[doc = "Boot from alternate Flash Address 0"]
138    #[inline(always)]
139    pub fn is_const_1000(&self) -> bool {
140        *self == SWCON_A::CONST_1000
141    }
142    #[doc = "Boot from alternate Flash Address 1"]
143    #[inline(always)]
144    pub fn is_const_1100(&self) -> bool {
145        *self == SWCON_A::CONST_1100
146    }
147    #[doc = "Enable fallback Alternate Boot Mode (ABM)"]
148    #[inline(always)]
149    pub fn is_const_1110(&self) -> bool {
150        *self == SWCON_A::CONST_1110
151    }
152}
153#[doc = "Field `SWCON` writer - SW Configuration"]
154pub type SWCON_W<'a, REG> = crate::FieldWriter<'a, REG, 4, SWCON_A>;
155impl<'a, REG> SWCON_W<'a, REG>
156where
157    REG: crate::Writable + crate::RegisterSpec,
158    REG::Ux: From<u8>,
159{
160    #[doc = "Normal mode, boot from Boot ROM"]
161    #[inline(always)]
162    pub fn const_0000(self) -> &'a mut crate::W<REG> {
163        self.variant(SWCON_A::CONST_0000)
164    }
165    #[doc = "ASC BSL enabled"]
166    #[inline(always)]
167    pub fn const_0001(self) -> &'a mut crate::W<REG> {
168        self.variant(SWCON_A::CONST_0001)
169    }
170    #[doc = "BMI customized boot enabled"]
171    #[inline(always)]
172    pub fn const_0010(self) -> &'a mut crate::W<REG> {
173        self.variant(SWCON_A::CONST_0010)
174    }
175    #[doc = "CAN BSL enabled"]
176    #[inline(always)]
177    pub fn const_0011(self) -> &'a mut crate::W<REG> {
178        self.variant(SWCON_A::CONST_0011)
179    }
180    #[doc = "Boot from Code SRAM"]
181    #[inline(always)]
182    pub fn const_0100(self) -> &'a mut crate::W<REG> {
183        self.variant(SWCON_A::CONST_0100)
184    }
185    #[doc = "Boot from alternate Flash Address 0"]
186    #[inline(always)]
187    pub fn const_1000(self) -> &'a mut crate::W<REG> {
188        self.variant(SWCON_A::CONST_1000)
189    }
190    #[doc = "Boot from alternate Flash Address 1"]
191    #[inline(always)]
192    pub fn const_1100(self) -> &'a mut crate::W<REG> {
193        self.variant(SWCON_A::CONST_1100)
194    }
195    #[doc = "Enable fallback Alternate Boot Mode (ABM)"]
196    #[inline(always)]
197    pub fn const_1110(self) -> &'a mut crate::W<REG> {
198        self.variant(SWCON_A::CONST_1110)
199    }
200}
201impl R {
202    #[doc = "Bits 0:1 - HW Configuration"]
203    #[inline(always)]
204    pub fn hwcon(&self) -> HWCON_R {
205        HWCON_R::new((self.bits & 3) as u8)
206    }
207    #[doc = "Bits 8:11 - SW Configuration"]
208    #[inline(always)]
209    pub fn swcon(&self) -> SWCON_R {
210        SWCON_R::new(((self.bits >> 8) & 0x0f) as u8)
211    }
212}
213impl W {
214    #[doc = "Bits 8:11 - SW Configuration"]
215    #[inline(always)]
216    pub fn swcon(&mut self) -> SWCON_W<STCON_SPEC> {
217        SWCON_W::new(self, 8)
218    }
219}
220#[doc = "Startup Configuration Register\n\nYou can [`read`](crate::Reg::read) this register and get [`stcon::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`stcon::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
221pub struct STCON_SPEC;
222impl crate::RegisterSpec for STCON_SPEC {
223    type Ux = u32;
224}
225#[doc = "`read()` method returns [`stcon::R`](R) reader structure"]
226impl crate::Readable for STCON_SPEC {}
227#[doc = "`write(|w| ..)` method takes [`stcon::W`](W) writer structure"]
228impl crate::Writable for STCON_SPEC {
229    type Safety = crate::Unsafe;
230    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
231    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
232}
233#[doc = "`reset()` method sets STCON to value 0"]
234impl crate::Resettable for STCON_SPEC {
235    const RESET_VALUE: u32 = 0;
236}