xmc4800/sdmmc/
power_ctrl.rs

1#[doc = "Register `POWER_CTRL` reader"]
2pub type R = crate::R<POWER_CTRL_SPEC>;
3#[doc = "Register `POWER_CTRL` writer"]
4pub type W = crate::W<POWER_CTRL_SPEC>;
5#[doc = "SD Bus Power\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum SD_BUS_POWER_A {
8    #[doc = "0: Power off"]
9    VALUE1 = 0,
10    #[doc = "1: Power on"]
11    VALUE2 = 1,
12}
13impl From<SD_BUS_POWER_A> for bool {
14    #[inline(always)]
15    fn from(variant: SD_BUS_POWER_A) -> Self {
16        variant as u8 != 0
17    }
18}
19#[doc = "Field `SD_BUS_POWER` reader - SD Bus Power"]
20pub type SD_BUS_POWER_R = crate::BitReader<SD_BUS_POWER_A>;
21impl SD_BUS_POWER_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> SD_BUS_POWER_A {
25        match self.bits {
26            false => SD_BUS_POWER_A::VALUE1,
27            true => SD_BUS_POWER_A::VALUE2,
28        }
29    }
30    #[doc = "Power off"]
31    #[inline(always)]
32    pub fn is_value1(&self) -> bool {
33        *self == SD_BUS_POWER_A::VALUE1
34    }
35    #[doc = "Power on"]
36    #[inline(always)]
37    pub fn is_value2(&self) -> bool {
38        *self == SD_BUS_POWER_A::VALUE2
39    }
40}
41#[doc = "Field `SD_BUS_POWER` writer - SD Bus Power"]
42pub type SD_BUS_POWER_W<'a, REG> = crate::BitWriter<'a, REG, SD_BUS_POWER_A>;
43impl<'a, REG> SD_BUS_POWER_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "Power off"]
48    #[inline(always)]
49    pub fn value1(self) -> &'a mut crate::W<REG> {
50        self.variant(SD_BUS_POWER_A::VALUE1)
51    }
52    #[doc = "Power on"]
53    #[inline(always)]
54    pub fn value2(self) -> &'a mut crate::W<REG> {
55        self.variant(SD_BUS_POWER_A::VALUE2)
56    }
57}
58#[doc = "SD Bus Voltage Select\n\nValue on reset: 0"]
59#[derive(Clone, Copy, Debug, PartialEq, Eq)]
60#[repr(u8)]
61pub enum SD_BUS_VOLTAGE_SEL_A {
62    #[doc = "7: 3.3V (Flattop.)"]
63    VALUE1 = 7,
64}
65impl From<SD_BUS_VOLTAGE_SEL_A> for u8 {
66    #[inline(always)]
67    fn from(variant: SD_BUS_VOLTAGE_SEL_A) -> Self {
68        variant as _
69    }
70}
71impl crate::FieldSpec for SD_BUS_VOLTAGE_SEL_A {
72    type Ux = u8;
73}
74impl crate::IsEnum for SD_BUS_VOLTAGE_SEL_A {}
75#[doc = "Field `SD_BUS_VOLTAGE_SEL` reader - SD Bus Voltage Select"]
76pub type SD_BUS_VOLTAGE_SEL_R = crate::FieldReader<SD_BUS_VOLTAGE_SEL_A>;
77impl SD_BUS_VOLTAGE_SEL_R {
78    #[doc = "Get enumerated values variant"]
79    #[inline(always)]
80    pub const fn variant(&self) -> Option<SD_BUS_VOLTAGE_SEL_A> {
81        match self.bits {
82            7 => Some(SD_BUS_VOLTAGE_SEL_A::VALUE1),
83            _ => None,
84        }
85    }
86    #[doc = "3.3V (Flattop.)"]
87    #[inline(always)]
88    pub fn is_value1(&self) -> bool {
89        *self == SD_BUS_VOLTAGE_SEL_A::VALUE1
90    }
91}
92#[doc = "Field `SD_BUS_VOLTAGE_SEL` writer - SD Bus Voltage Select"]
93pub type SD_BUS_VOLTAGE_SEL_W<'a, REG> = crate::FieldWriter<'a, REG, 3, SD_BUS_VOLTAGE_SEL_A>;
94impl<'a, REG> SD_BUS_VOLTAGE_SEL_W<'a, REG>
95where
96    REG: crate::Writable + crate::RegisterSpec,
97    REG::Ux: From<u8>,
98{
99    #[doc = "3.3V (Flattop.)"]
100    #[inline(always)]
101    pub fn value1(self) -> &'a mut crate::W<REG> {
102        self.variant(SD_BUS_VOLTAGE_SEL_A::VALUE1)
103    }
104}
105#[doc = "Field `HARDWARE_RESET` reader - Hardware reset"]
106pub type HARDWARE_RESET_R = crate::BitReader;
107#[doc = "Field `HARDWARE_RESET` writer - Hardware reset"]
108pub type HARDWARE_RESET_W<'a, REG> = crate::BitWriter<'a, REG>;
109impl R {
110    #[doc = "Bit 0 - SD Bus Power"]
111    #[inline(always)]
112    pub fn sd_bus_power(&self) -> SD_BUS_POWER_R {
113        SD_BUS_POWER_R::new((self.bits & 1) != 0)
114    }
115    #[doc = "Bits 1:3 - SD Bus Voltage Select"]
116    #[inline(always)]
117    pub fn sd_bus_voltage_sel(&self) -> SD_BUS_VOLTAGE_SEL_R {
118        SD_BUS_VOLTAGE_SEL_R::new((self.bits >> 1) & 7)
119    }
120    #[doc = "Bit 4 - Hardware reset"]
121    #[inline(always)]
122    pub fn hardware_reset(&self) -> HARDWARE_RESET_R {
123        HARDWARE_RESET_R::new(((self.bits >> 4) & 1) != 0)
124    }
125}
126impl W {
127    #[doc = "Bit 0 - SD Bus Power"]
128    #[inline(always)]
129    pub fn sd_bus_power(&mut self) -> SD_BUS_POWER_W<POWER_CTRL_SPEC> {
130        SD_BUS_POWER_W::new(self, 0)
131    }
132    #[doc = "Bits 1:3 - SD Bus Voltage Select"]
133    #[inline(always)]
134    pub fn sd_bus_voltage_sel(&mut self) -> SD_BUS_VOLTAGE_SEL_W<POWER_CTRL_SPEC> {
135        SD_BUS_VOLTAGE_SEL_W::new(self, 1)
136    }
137    #[doc = "Bit 4 - Hardware reset"]
138    #[inline(always)]
139    pub fn hardware_reset(&mut self) -> HARDWARE_RESET_W<POWER_CTRL_SPEC> {
140        HARDWARE_RESET_W::new(self, 4)
141    }
142}
143#[doc = "Power Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`power_ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`power_ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
144pub struct POWER_CTRL_SPEC;
145impl crate::RegisterSpec for POWER_CTRL_SPEC {
146    type Ux = u8;
147}
148#[doc = "`read()` method returns [`power_ctrl::R`](R) reader structure"]
149impl crate::Readable for POWER_CTRL_SPEC {}
150#[doc = "`write(|w| ..)` method takes [`power_ctrl::W`](W) writer structure"]
151impl crate::Writable for POWER_CTRL_SPEC {
152    type Safety = crate::Unsafe;
153    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
154    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
155}
156#[doc = "`reset()` method sets POWER_CTRL to value 0"]
157impl crate::Resettable for POWER_CTRL_SPEC {
158    const RESET_VALUE: u8 = 0;
159}