efm32pg1b200_pac/emu/
pwrcfg.rs

1#[doc = "Register `PWRCFG` reader"]
2pub struct R(crate::R<PWRCFG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PWRCFG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PWRCFG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PWRCFG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PWRCFG` writer"]
17pub struct W(crate::W<PWRCFG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PWRCFG_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<PWRCFG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PWRCFG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Power Configuration\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum PWRCFG_A {
41    #[doc = "0: Power up configuration. Works with any external configuration."]
42    STARTUP = 0,
43    #[doc = "2: Configured: DCDC control logic is enabled."]
44    DCDCTODVDD = 2,
45}
46impl From<PWRCFG_A> for u8 {
47    #[inline(always)]
48    fn from(variant: PWRCFG_A) -> Self {
49        variant as _
50    }
51}
52#[doc = "Field `PWRCFG` reader - Power Configuration"]
53pub type PWRCFG_R = crate::FieldReader<u8, PWRCFG_A>;
54impl PWRCFG_R {
55    #[doc = "Get enumerated values variant"]
56    #[inline(always)]
57    pub fn variant(&self) -> Option<PWRCFG_A> {
58        match self.bits {
59            0 => Some(PWRCFG_A::STARTUP),
60            2 => Some(PWRCFG_A::DCDCTODVDD),
61            _ => None,
62        }
63    }
64    #[doc = "Checks if the value of the field is `STARTUP`"]
65    #[inline(always)]
66    pub fn is_startup(&self) -> bool {
67        *self == PWRCFG_A::STARTUP
68    }
69    #[doc = "Checks if the value of the field is `DCDCTODVDD`"]
70    #[inline(always)]
71    pub fn is_dcdctodvdd(&self) -> bool {
72        *self == PWRCFG_A::DCDCTODVDD
73    }
74}
75#[doc = "Field `PWRCFG` writer - Power Configuration"]
76pub type PWRCFG_W<'a> = crate::FieldWriter<'a, u32, PWRCFG_SPEC, u8, PWRCFG_A, 4, 0>;
77impl<'a> PWRCFG_W<'a> {
78    #[doc = "Power up configuration. Works with any external configuration."]
79    #[inline(always)]
80    pub fn startup(self) -> &'a mut W {
81        self.variant(PWRCFG_A::STARTUP)
82    }
83    #[doc = "Configured: DCDC control logic is enabled."]
84    #[inline(always)]
85    pub fn dcdctodvdd(self) -> &'a mut W {
86        self.variant(PWRCFG_A::DCDCTODVDD)
87    }
88}
89impl R {
90    #[doc = "Bits 0:3 - Power Configuration"]
91    #[inline(always)]
92    pub fn pwrcfg(&self) -> PWRCFG_R {
93        PWRCFG_R::new((self.bits & 0x0f) as u8)
94    }
95}
96impl W {
97    #[doc = "Bits 0:3 - Power Configuration"]
98    #[inline(always)]
99    pub fn pwrcfg(&mut self) -> PWRCFG_W {
100        PWRCFG_W::new(self)
101    }
102    #[doc = "Writes raw bits to the register."]
103    #[inline(always)]
104    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
105        self.0.bits(bits);
106        self
107    }
108}
109#[doc = "Power Configuration Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pwrcfg](index.html) module"]
110pub struct PWRCFG_SPEC;
111impl crate::RegisterSpec for PWRCFG_SPEC {
112    type Ux = u32;
113}
114#[doc = "`read()` method returns [pwrcfg::R](R) reader structure"]
115impl crate::Readable for PWRCFG_SPEC {
116    type Reader = R;
117}
118#[doc = "`write(|w| ..)` method takes [pwrcfg::W](W) writer structure"]
119impl crate::Writable for PWRCFG_SPEC {
120    type Writer = W;
121}
122#[doc = "`reset()` method sets PWRCFG to value 0"]
123impl crate::Resettable for PWRCFG_SPEC {
124    #[inline(always)]
125    fn reset_value() -> Self::Ux {
126        0
127    }
128}