efm32pg12_pac/emu/
ram1ctrl.rs

1#[doc = "Reader of register RAM1CTRL"]
2pub type R = crate::R<u32, super::RAM1CTRL>;
3#[doc = "Writer for register RAM1CTRL"]
4pub type W = crate::W<u32, super::RAM1CTRL>;
5#[doc = "Register RAM1CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::RAM1CTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "RAM1 Blockset Power-down\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum RAMPOWERDOWN_A {
17    #[doc = "0: None of the RAM blocks powered down"]
18    NONE = 0,
19    #[doc = "2: Power down RAM block 1 (address range 0x20030000-0x2003FFFF)"]
20    BLK1 = 2,
21    #[doc = "3: Power down RAM blocks 0-1 (address range 0x20020000-0x2003FFFF)"]
22    BLK0TO1 = 3,
23}
24impl From<RAMPOWERDOWN_A> for u8 {
25    #[inline(always)]
26    fn from(variant: RAMPOWERDOWN_A) -> Self {
27        variant as _
28    }
29}
30#[doc = "Reader of field `RAMPOWERDOWN`"]
31pub type RAMPOWERDOWN_R = crate::R<u8, RAMPOWERDOWN_A>;
32impl RAMPOWERDOWN_R {
33    #[doc = r"Get enumerated values variant"]
34    #[inline(always)]
35    pub fn variant(&self) -> crate::Variant<u8, RAMPOWERDOWN_A> {
36        use crate::Variant::*;
37        match self.bits {
38            0 => Val(RAMPOWERDOWN_A::NONE),
39            2 => Val(RAMPOWERDOWN_A::BLK1),
40            3 => Val(RAMPOWERDOWN_A::BLK0TO1),
41            i => Res(i),
42        }
43    }
44    #[doc = "Checks if the value of the field is `NONE`"]
45    #[inline(always)]
46    pub fn is_none(&self) -> bool {
47        *self == RAMPOWERDOWN_A::NONE
48    }
49    #[doc = "Checks if the value of the field is `BLK1`"]
50    #[inline(always)]
51    pub fn is_blk1(&self) -> bool {
52        *self == RAMPOWERDOWN_A::BLK1
53    }
54    #[doc = "Checks if the value of the field is `BLK0TO1`"]
55    #[inline(always)]
56    pub fn is_blk0to1(&self) -> bool {
57        *self == RAMPOWERDOWN_A::BLK0TO1
58    }
59}
60#[doc = "Write proxy for field `RAMPOWERDOWN`"]
61pub struct RAMPOWERDOWN_W<'a> {
62    w: &'a mut W,
63}
64impl<'a> RAMPOWERDOWN_W<'a> {
65    #[doc = r"Writes `variant` to the field"]
66    #[inline(always)]
67    pub fn variant(self, variant: RAMPOWERDOWN_A) -> &'a mut W {
68        unsafe { self.bits(variant.into()) }
69    }
70    #[doc = "None of the RAM blocks powered down"]
71    #[inline(always)]
72    pub fn none(self) -> &'a mut W {
73        self.variant(RAMPOWERDOWN_A::NONE)
74    }
75    #[doc = "Power down RAM block 1 (address range 0x20030000-0x2003FFFF)"]
76    #[inline(always)]
77    pub fn blk1(self) -> &'a mut W {
78        self.variant(RAMPOWERDOWN_A::BLK1)
79    }
80    #[doc = "Power down RAM blocks 0-1 (address range 0x20020000-0x2003FFFF)"]
81    #[inline(always)]
82    pub fn blk0to1(self) -> &'a mut W {
83        self.variant(RAMPOWERDOWN_A::BLK0TO1)
84    }
85    #[doc = r"Writes raw bits to the field"]
86    #[inline(always)]
87    pub unsafe fn bits(self, value: u8) -> &'a mut W {
88        self.w.bits = (self.w.bits & !0x03) | ((value as u32) & 0x03);
89        self.w
90    }
91}
92impl R {
93    #[doc = "Bits 0:1 - RAM1 Blockset Power-down"]
94    #[inline(always)]
95    pub fn rampowerdown(&self) -> RAMPOWERDOWN_R {
96        RAMPOWERDOWN_R::new((self.bits & 0x03) as u8)
97    }
98}
99impl W {
100    #[doc = "Bits 0:1 - RAM1 Blockset Power-down"]
101    #[inline(always)]
102    pub fn rampowerdown(&mut self) -> RAMPOWERDOWN_W {
103        RAMPOWERDOWN_W { w: self }
104    }
105}