efm32pg12_pac/emu/
ram2ctrl.rs

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