efm32pg12_pac/emu/
pwrcfg.rs

1#[doc = "Reader of register PWRCFG"]
2pub type R = crate::R<u32, super::PWRCFG>;
3#[doc = "Writer for register PWRCFG"]
4pub type W = crate::W<u32, super::PWRCFG>;
5#[doc = "Register PWRCFG `reset()`'s with value 0"]
6impl crate::ResetValue for super::PWRCFG {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Power Configuration\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum PWRCFG_A {
17    #[doc = "0: Power up configuration. Works with any external configuration."]
18    UNCONFIGURED = 0,
19    #[doc = "2: DCDC is enabled and routed to DVDD."]
20    DCDCTODVDD = 2,
21}
22impl From<PWRCFG_A> for u8 {
23    #[inline(always)]
24    fn from(variant: PWRCFG_A) -> Self {
25        variant as _
26    }
27}
28#[doc = "Reader of field `PWRCFG`"]
29pub type PWRCFG_R = crate::R<u8, PWRCFG_A>;
30impl PWRCFG_R {
31    #[doc = r"Get enumerated values variant"]
32    #[inline(always)]
33    pub fn variant(&self) -> crate::Variant<u8, PWRCFG_A> {
34        use crate::Variant::*;
35        match self.bits {
36            0 => Val(PWRCFG_A::UNCONFIGURED),
37            2 => Val(PWRCFG_A::DCDCTODVDD),
38            i => Res(i),
39        }
40    }
41    #[doc = "Checks if the value of the field is `UNCONFIGURED`"]
42    #[inline(always)]
43    pub fn is_unconfigured(&self) -> bool {
44        *self == PWRCFG_A::UNCONFIGURED
45    }
46    #[doc = "Checks if the value of the field is `DCDCTODVDD`"]
47    #[inline(always)]
48    pub fn is_dcdctodvdd(&self) -> bool {
49        *self == PWRCFG_A::DCDCTODVDD
50    }
51}
52#[doc = "Write proxy for field `PWRCFG`"]
53pub struct PWRCFG_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> PWRCFG_W<'a> {
57    #[doc = r"Writes `variant` to the field"]
58    #[inline(always)]
59    pub fn variant(self, variant: PWRCFG_A) -> &'a mut W {
60        unsafe { self.bits(variant.into()) }
61    }
62    #[doc = "Power up configuration. Works with any external configuration."]
63    #[inline(always)]
64    pub fn unconfigured(self) -> &'a mut W {
65        self.variant(PWRCFG_A::UNCONFIGURED)
66    }
67    #[doc = "DCDC is enabled and routed to DVDD."]
68    #[inline(always)]
69    pub fn dcdctodvdd(self) -> &'a mut W {
70        self.variant(PWRCFG_A::DCDCTODVDD)
71    }
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub unsafe fn bits(self, value: u8) -> &'a mut W {
75        self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
76        self.w
77    }
78}
79impl R {
80    #[doc = "Bits 0:3 - Power Configuration"]
81    #[inline(always)]
82    pub fn pwrcfg(&self) -> PWRCFG_R {
83        PWRCFG_R::new((self.bits & 0x0f) as u8)
84    }
85}
86impl W {
87    #[doc = "Bits 0:3 - Power Configuration"]
88    #[inline(always)]
89    pub fn pwrcfg(&mut self) -> PWRCFG_W {
90        PWRCFG_W { w: self }
91    }
92}