mk66f18/smc/
stopctrl.rs

1#[doc = "Reader of register STOPCTRL"]
2pub type R = crate::R<u8, super::STOPCTRL>;
3#[doc = "Writer for register STOPCTRL"]
4pub type W = crate::W<u8, super::STOPCTRL>;
5#[doc = "Register STOPCTRL `reset()`'s with value 0x03"]
6impl crate::ResetValue for super::STOPCTRL {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x03
11    }
12}
13#[doc = "LLS or VLLS Mode Control\n\nValue on reset: 3"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum LLSM_A {
16    #[doc = "0: VLLS0 if PMCTRL\\[STOPM\\]=VLLSx, reserved if PMCTRL\\[STOPM\\]=LLSx"]
17    _000,
18    #[doc = "1: VLLS1 if PMCTRL\\[STOPM\\]=VLLSx, reserved if PMCTRL\\[STOPM\\]=LLSx"]
19    _001,
20    #[doc = "2: VLLS2 if PMCTRL\\[STOPM\\]=VLLSx, LLS2 if PMCTRL\\[STOPM\\]=LLSx"]
21    _010,
22    #[doc = "3: VLLS3 if PMCTRL\\[STOPM\\]=VLLSx, LLS3 if PMCTRL\\[STOPM\\]=LLSx"]
23    _011,
24}
25impl From<LLSM_A> for u8 {
26    #[inline(always)]
27    fn from(variant: LLSM_A) -> Self {
28        match variant {
29            LLSM_A::_000 => 0,
30            LLSM_A::_001 => 1,
31            LLSM_A::_010 => 2,
32            LLSM_A::_011 => 3,
33        }
34    }
35}
36#[doc = "Reader of field `LLSM`"]
37pub type LLSM_R = crate::R<u8, LLSM_A>;
38impl LLSM_R {
39    #[doc = r"Get enumerated values variant"]
40    #[inline(always)]
41    pub fn variant(&self) -> crate::Variant<u8, LLSM_A> {
42        use crate::Variant::*;
43        match self.bits {
44            0 => Val(LLSM_A::_000),
45            1 => Val(LLSM_A::_001),
46            2 => Val(LLSM_A::_010),
47            3 => Val(LLSM_A::_011),
48            i => Res(i),
49        }
50    }
51    #[doc = "Checks if the value of the field is `_000`"]
52    #[inline(always)]
53    pub fn is_000(&self) -> bool {
54        *self == LLSM_A::_000
55    }
56    #[doc = "Checks if the value of the field is `_001`"]
57    #[inline(always)]
58    pub fn is_001(&self) -> bool {
59        *self == LLSM_A::_001
60    }
61    #[doc = "Checks if the value of the field is `_010`"]
62    #[inline(always)]
63    pub fn is_010(&self) -> bool {
64        *self == LLSM_A::_010
65    }
66    #[doc = "Checks if the value of the field is `_011`"]
67    #[inline(always)]
68    pub fn is_011(&self) -> bool {
69        *self == LLSM_A::_011
70    }
71}
72#[doc = "Write proxy for field `LLSM`"]
73pub struct LLSM_W<'a> {
74    w: &'a mut W,
75}
76impl<'a> LLSM_W<'a> {
77    #[doc = r"Writes `variant` to the field"]
78    #[inline(always)]
79    pub fn variant(self, variant: LLSM_A) -> &'a mut W {
80        unsafe { self.bits(variant.into()) }
81    }
82    #[doc = "VLLS0 if PMCTRL\\[STOPM\\]=VLLSx, reserved if PMCTRL\\[STOPM\\]=LLSx"]
83    #[inline(always)]
84    pub fn _000(self) -> &'a mut W {
85        self.variant(LLSM_A::_000)
86    }
87    #[doc = "VLLS1 if PMCTRL\\[STOPM\\]=VLLSx, reserved if PMCTRL\\[STOPM\\]=LLSx"]
88    #[inline(always)]
89    pub fn _001(self) -> &'a mut W {
90        self.variant(LLSM_A::_001)
91    }
92    #[doc = "VLLS2 if PMCTRL\\[STOPM\\]=VLLSx, LLS2 if PMCTRL\\[STOPM\\]=LLSx"]
93    #[inline(always)]
94    pub fn _010(self) -> &'a mut W {
95        self.variant(LLSM_A::_010)
96    }
97    #[doc = "VLLS3 if PMCTRL\\[STOPM\\]=VLLSx, LLS3 if PMCTRL\\[STOPM\\]=LLSx"]
98    #[inline(always)]
99    pub fn _011(self) -> &'a mut W {
100        self.variant(LLSM_A::_011)
101    }
102    #[doc = r"Writes raw bits to the field"]
103    #[inline(always)]
104    pub unsafe fn bits(self, value: u8) -> &'a mut W {
105        self.w.bits = (self.w.bits & !0x07) | ((value as u8) & 0x07);
106        self.w
107    }
108}
109#[doc = "RAM2 Power Option\n\nValue on reset: 0"]
110#[derive(Clone, Copy, Debug, PartialEq)]
111pub enum RAM2PO_A {
112    #[doc = "0: RAM2 not powered in LLS2/VLLS2"]
113    _0,
114    #[doc = "1: RAM2 powered in LLS2/VLLS2"]
115    _1,
116}
117impl From<RAM2PO_A> for bool {
118    #[inline(always)]
119    fn from(variant: RAM2PO_A) -> Self {
120        match variant {
121            RAM2PO_A::_0 => false,
122            RAM2PO_A::_1 => true,
123        }
124    }
125}
126#[doc = "Reader of field `RAM2PO`"]
127pub type RAM2PO_R = crate::R<bool, RAM2PO_A>;
128impl RAM2PO_R {
129    #[doc = r"Get enumerated values variant"]
130    #[inline(always)]
131    pub fn variant(&self) -> RAM2PO_A {
132        match self.bits {
133            false => RAM2PO_A::_0,
134            true => RAM2PO_A::_1,
135        }
136    }
137    #[doc = "Checks if the value of the field is `_0`"]
138    #[inline(always)]
139    pub fn is_0(&self) -> bool {
140        *self == RAM2PO_A::_0
141    }
142    #[doc = "Checks if the value of the field is `_1`"]
143    #[inline(always)]
144    pub fn is_1(&self) -> bool {
145        *self == RAM2PO_A::_1
146    }
147}
148#[doc = "Write proxy for field `RAM2PO`"]
149pub struct RAM2PO_W<'a> {
150    w: &'a mut W,
151}
152impl<'a> RAM2PO_W<'a> {
153    #[doc = r"Writes `variant` to the field"]
154    #[inline(always)]
155    pub fn variant(self, variant: RAM2PO_A) -> &'a mut W {
156        {
157            self.bit(variant.into())
158        }
159    }
160    #[doc = "RAM2 not powered in LLS2/VLLS2"]
161    #[inline(always)]
162    pub fn _0(self) -> &'a mut W {
163        self.variant(RAM2PO_A::_0)
164    }
165    #[doc = "RAM2 powered in LLS2/VLLS2"]
166    #[inline(always)]
167    pub fn _1(self) -> &'a mut W {
168        self.variant(RAM2PO_A::_1)
169    }
170    #[doc = r"Sets the field bit"]
171    #[inline(always)]
172    pub fn set_bit(self) -> &'a mut W {
173        self.bit(true)
174    }
175    #[doc = r"Clears the field bit"]
176    #[inline(always)]
177    pub fn clear_bit(self) -> &'a mut W {
178        self.bit(false)
179    }
180    #[doc = r"Writes raw bits to the field"]
181    #[inline(always)]
182    pub fn bit(self, value: bool) -> &'a mut W {
183        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u8) & 0x01) << 4);
184        self.w
185    }
186}
187#[doc = "POR Power Option\n\nValue on reset: 0"]
188#[derive(Clone, Copy, Debug, PartialEq)]
189pub enum PORPO_A {
190    #[doc = "0: POR detect circuit is enabled in VLLS0"]
191    _0,
192    #[doc = "1: POR detect circuit is disabled in VLLS0"]
193    _1,
194}
195impl From<PORPO_A> for bool {
196    #[inline(always)]
197    fn from(variant: PORPO_A) -> Self {
198        match variant {
199            PORPO_A::_0 => false,
200            PORPO_A::_1 => true,
201        }
202    }
203}
204#[doc = "Reader of field `PORPO`"]
205pub type PORPO_R = crate::R<bool, PORPO_A>;
206impl PORPO_R {
207    #[doc = r"Get enumerated values variant"]
208    #[inline(always)]
209    pub fn variant(&self) -> PORPO_A {
210        match self.bits {
211            false => PORPO_A::_0,
212            true => PORPO_A::_1,
213        }
214    }
215    #[doc = "Checks if the value of the field is `_0`"]
216    #[inline(always)]
217    pub fn is_0(&self) -> bool {
218        *self == PORPO_A::_0
219    }
220    #[doc = "Checks if the value of the field is `_1`"]
221    #[inline(always)]
222    pub fn is_1(&self) -> bool {
223        *self == PORPO_A::_1
224    }
225}
226#[doc = "Write proxy for field `PORPO`"]
227pub struct PORPO_W<'a> {
228    w: &'a mut W,
229}
230impl<'a> PORPO_W<'a> {
231    #[doc = r"Writes `variant` to the field"]
232    #[inline(always)]
233    pub fn variant(self, variant: PORPO_A) -> &'a mut W {
234        {
235            self.bit(variant.into())
236        }
237    }
238    #[doc = "POR detect circuit is enabled in VLLS0"]
239    #[inline(always)]
240    pub fn _0(self) -> &'a mut W {
241        self.variant(PORPO_A::_0)
242    }
243    #[doc = "POR detect circuit is disabled in VLLS0"]
244    #[inline(always)]
245    pub fn _1(self) -> &'a mut W {
246        self.variant(PORPO_A::_1)
247    }
248    #[doc = r"Sets the field bit"]
249    #[inline(always)]
250    pub fn set_bit(self) -> &'a mut W {
251        self.bit(true)
252    }
253    #[doc = r"Clears the field bit"]
254    #[inline(always)]
255    pub fn clear_bit(self) -> &'a mut W {
256        self.bit(false)
257    }
258    #[doc = r"Writes raw bits to the field"]
259    #[inline(always)]
260    pub fn bit(self, value: bool) -> &'a mut W {
261        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u8) & 0x01) << 5);
262        self.w
263    }
264}
265#[doc = "Partial Stop Option\n\nValue on reset: 0"]
266#[derive(Clone, Copy, Debug, PartialEq)]
267pub enum PSTOPO_A {
268    #[doc = "0: STOP - Normal Stop mode"]
269    _00,
270    #[doc = "1: PSTOP1 - Partial Stop with both system and bus clocks disabled"]
271    _01,
272    #[doc = "2: PSTOP2 - Partial Stop with system clock disabled and bus clock enabled"]
273    _10,
274}
275impl From<PSTOPO_A> for u8 {
276    #[inline(always)]
277    fn from(variant: PSTOPO_A) -> Self {
278        match variant {
279            PSTOPO_A::_00 => 0,
280            PSTOPO_A::_01 => 1,
281            PSTOPO_A::_10 => 2,
282        }
283    }
284}
285#[doc = "Reader of field `PSTOPO`"]
286pub type PSTOPO_R = crate::R<u8, PSTOPO_A>;
287impl PSTOPO_R {
288    #[doc = r"Get enumerated values variant"]
289    #[inline(always)]
290    pub fn variant(&self) -> crate::Variant<u8, PSTOPO_A> {
291        use crate::Variant::*;
292        match self.bits {
293            0 => Val(PSTOPO_A::_00),
294            1 => Val(PSTOPO_A::_01),
295            2 => Val(PSTOPO_A::_10),
296            i => Res(i),
297        }
298    }
299    #[doc = "Checks if the value of the field is `_00`"]
300    #[inline(always)]
301    pub fn is_00(&self) -> bool {
302        *self == PSTOPO_A::_00
303    }
304    #[doc = "Checks if the value of the field is `_01`"]
305    #[inline(always)]
306    pub fn is_01(&self) -> bool {
307        *self == PSTOPO_A::_01
308    }
309    #[doc = "Checks if the value of the field is `_10`"]
310    #[inline(always)]
311    pub fn is_10(&self) -> bool {
312        *self == PSTOPO_A::_10
313    }
314}
315#[doc = "Write proxy for field `PSTOPO`"]
316pub struct PSTOPO_W<'a> {
317    w: &'a mut W,
318}
319impl<'a> PSTOPO_W<'a> {
320    #[doc = r"Writes `variant` to the field"]
321    #[inline(always)]
322    pub fn variant(self, variant: PSTOPO_A) -> &'a mut W {
323        unsafe { self.bits(variant.into()) }
324    }
325    #[doc = "STOP - Normal Stop mode"]
326    #[inline(always)]
327    pub fn _00(self) -> &'a mut W {
328        self.variant(PSTOPO_A::_00)
329    }
330    #[doc = "PSTOP1 - Partial Stop with both system and bus clocks disabled"]
331    #[inline(always)]
332    pub fn _01(self) -> &'a mut W {
333        self.variant(PSTOPO_A::_01)
334    }
335    #[doc = "PSTOP2 - Partial Stop with system clock disabled and bus clock enabled"]
336    #[inline(always)]
337    pub fn _10(self) -> &'a mut W {
338        self.variant(PSTOPO_A::_10)
339    }
340    #[doc = r"Writes raw bits to the field"]
341    #[inline(always)]
342    pub unsafe fn bits(self, value: u8) -> &'a mut W {
343        self.w.bits = (self.w.bits & !(0x03 << 6)) | (((value as u8) & 0x03) << 6);
344        self.w
345    }
346}
347impl R {
348    #[doc = "Bits 0:2 - LLS or VLLS Mode Control"]
349    #[inline(always)]
350    pub fn llsm(&self) -> LLSM_R {
351        LLSM_R::new((self.bits & 0x07) as u8)
352    }
353    #[doc = "Bit 4 - RAM2 Power Option"]
354    #[inline(always)]
355    pub fn ram2po(&self) -> RAM2PO_R {
356        RAM2PO_R::new(((self.bits >> 4) & 0x01) != 0)
357    }
358    #[doc = "Bit 5 - POR Power Option"]
359    #[inline(always)]
360    pub fn porpo(&self) -> PORPO_R {
361        PORPO_R::new(((self.bits >> 5) & 0x01) != 0)
362    }
363    #[doc = "Bits 6:7 - Partial Stop Option"]
364    #[inline(always)]
365    pub fn pstopo(&self) -> PSTOPO_R {
366        PSTOPO_R::new(((self.bits >> 6) & 0x03) as u8)
367    }
368}
369impl W {
370    #[doc = "Bits 0:2 - LLS or VLLS Mode Control"]
371    #[inline(always)]
372    pub fn llsm(&mut self) -> LLSM_W {
373        LLSM_W { w: self }
374    }
375    #[doc = "Bit 4 - RAM2 Power Option"]
376    #[inline(always)]
377    pub fn ram2po(&mut self) -> RAM2PO_W {
378        RAM2PO_W { w: self }
379    }
380    #[doc = "Bit 5 - POR Power Option"]
381    #[inline(always)]
382    pub fn porpo(&mut self) -> PORPO_W {
383        PORPO_W { w: self }
384    }
385    #[doc = "Bits 6:7 - Partial Stop Option"]
386    #[inline(always)]
387    pub fn pstopo(&mut self) -> PSTOPO_W {
388        PSTOPO_W { w: self }
389    }
390}