xmc4400/scu_general/
dtscon.rs

1#[doc = "Register `DTSCON` reader"]
2pub type R = crate::R<DTSCON_SPEC>;
3#[doc = "Register `DTSCON` writer"]
4pub type W = crate::W<DTSCON_SPEC>;
5#[doc = "Sensor Power Down\n\nValue on reset: 1"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum PWD_A {
8    #[doc = "0: The DTS is powered"]
9    VALUE1 = 0,
10    #[doc = "1: The DTS is not powered"]
11    VALUE2 = 1,
12}
13impl From<PWD_A> for bool {
14    #[inline(always)]
15    fn from(variant: PWD_A) -> Self {
16        variant as u8 != 0
17    }
18}
19#[doc = "Field `PWD` reader - Sensor Power Down"]
20pub type PWD_R = crate::BitReader<PWD_A>;
21impl PWD_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> PWD_A {
25        match self.bits {
26            false => PWD_A::VALUE1,
27            true => PWD_A::VALUE2,
28        }
29    }
30    #[doc = "The DTS is powered"]
31    #[inline(always)]
32    pub fn is_value1(&self) -> bool {
33        *self == PWD_A::VALUE1
34    }
35    #[doc = "The DTS is not powered"]
36    #[inline(always)]
37    pub fn is_value2(&self) -> bool {
38        *self == PWD_A::VALUE2
39    }
40}
41#[doc = "Field `PWD` writer - Sensor Power Down"]
42pub type PWD_W<'a, REG> = crate::BitWriter<'a, REG, PWD_A>;
43impl<'a, REG> PWD_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "The DTS is powered"]
48    #[inline(always)]
49    pub fn value1(self) -> &'a mut crate::W<REG> {
50        self.variant(PWD_A::VALUE1)
51    }
52    #[doc = "The DTS is not powered"]
53    #[inline(always)]
54    pub fn value2(self) -> &'a mut crate::W<REG> {
55        self.variant(PWD_A::VALUE2)
56    }
57}
58#[doc = "Sensor Measurement Start\n\nValue on reset: 0"]
59#[derive(Clone, Copy, Debug, PartialEq, Eq)]
60pub enum START_A {
61    #[doc = "0: No DTS measurement is started"]
62    VALUE1 = 0,
63    #[doc = "1: A DTS measurement is started"]
64    VALUE2 = 1,
65}
66impl From<START_A> for bool {
67    #[inline(always)]
68    fn from(variant: START_A) -> Self {
69        variant as u8 != 0
70    }
71}
72#[doc = "Field `START` writer - Sensor Measurement Start"]
73pub type START_W<'a, REG> = crate::BitWriter<'a, REG, START_A>;
74impl<'a, REG> START_W<'a, REG>
75where
76    REG: crate::Writable + crate::RegisterSpec,
77{
78    #[doc = "No DTS measurement is started"]
79    #[inline(always)]
80    pub fn value1(self) -> &'a mut crate::W<REG> {
81        self.variant(START_A::VALUE1)
82    }
83    #[doc = "A DTS measurement is started"]
84    #[inline(always)]
85    pub fn value2(self) -> &'a mut crate::W<REG> {
86        self.variant(START_A::VALUE2)
87    }
88}
89#[doc = "Field `OFFSET` reader - Offset Calibration Value"]
90pub type OFFSET_R = crate::FieldReader;
91#[doc = "Field `OFFSET` writer - Offset Calibration Value"]
92pub type OFFSET_W<'a, REG> = crate::FieldWriter<'a, REG, 7>;
93#[doc = "Field `GAIN` reader - Gain Calibration Value"]
94pub type GAIN_R = crate::FieldReader;
95#[doc = "Field `GAIN` writer - Gain Calibration Value"]
96pub type GAIN_W<'a, REG> = crate::FieldWriter<'a, REG, 6>;
97#[doc = "Field `REFTRIM` reader - Reference Trim Calibration Value"]
98pub type REFTRIM_R = crate::FieldReader;
99#[doc = "Field `REFTRIM` writer - Reference Trim Calibration Value"]
100pub type REFTRIM_W<'a, REG> = crate::FieldWriter<'a, REG, 3>;
101#[doc = "Field `BGTRIM` reader - Bandgap Trim Calibration Value"]
102pub type BGTRIM_R = crate::FieldReader;
103#[doc = "Field `BGTRIM` writer - Bandgap Trim Calibration Value"]
104pub type BGTRIM_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
105impl R {
106    #[doc = "Bit 0 - Sensor Power Down"]
107    #[inline(always)]
108    pub fn pwd(&self) -> PWD_R {
109        PWD_R::new((self.bits & 1) != 0)
110    }
111    #[doc = "Bits 4:10 - Offset Calibration Value"]
112    #[inline(always)]
113    pub fn offset(&self) -> OFFSET_R {
114        OFFSET_R::new(((self.bits >> 4) & 0x7f) as u8)
115    }
116    #[doc = "Bits 11:16 - Gain Calibration Value"]
117    #[inline(always)]
118    pub fn gain(&self) -> GAIN_R {
119        GAIN_R::new(((self.bits >> 11) & 0x3f) as u8)
120    }
121    #[doc = "Bits 17:19 - Reference Trim Calibration Value"]
122    #[inline(always)]
123    pub fn reftrim(&self) -> REFTRIM_R {
124        REFTRIM_R::new(((self.bits >> 17) & 7) as u8)
125    }
126    #[doc = "Bits 20:23 - Bandgap Trim Calibration Value"]
127    #[inline(always)]
128    pub fn bgtrim(&self) -> BGTRIM_R {
129        BGTRIM_R::new(((self.bits >> 20) & 0x0f) as u8)
130    }
131}
132impl W {
133    #[doc = "Bit 0 - Sensor Power Down"]
134    #[inline(always)]
135    pub fn pwd(&mut self) -> PWD_W<DTSCON_SPEC> {
136        PWD_W::new(self, 0)
137    }
138    #[doc = "Bit 1 - Sensor Measurement Start"]
139    #[inline(always)]
140    pub fn start(&mut self) -> START_W<DTSCON_SPEC> {
141        START_W::new(self, 1)
142    }
143    #[doc = "Bits 4:10 - Offset Calibration Value"]
144    #[inline(always)]
145    pub fn offset(&mut self) -> OFFSET_W<DTSCON_SPEC> {
146        OFFSET_W::new(self, 4)
147    }
148    #[doc = "Bits 11:16 - Gain Calibration Value"]
149    #[inline(always)]
150    pub fn gain(&mut self) -> GAIN_W<DTSCON_SPEC> {
151        GAIN_W::new(self, 11)
152    }
153    #[doc = "Bits 17:19 - Reference Trim Calibration Value"]
154    #[inline(always)]
155    pub fn reftrim(&mut self) -> REFTRIM_W<DTSCON_SPEC> {
156        REFTRIM_W::new(self, 17)
157    }
158    #[doc = "Bits 20:23 - Bandgap Trim Calibration Value"]
159    #[inline(always)]
160    pub fn bgtrim(&mut self) -> BGTRIM_W<DTSCON_SPEC> {
161        BGTRIM_W::new(self, 20)
162    }
163}
164#[doc = "Die Temperature Sensor Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`dtscon::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`dtscon::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
165pub struct DTSCON_SPEC;
166impl crate::RegisterSpec for DTSCON_SPEC {
167    type Ux = u32;
168}
169#[doc = "`read()` method returns [`dtscon::R`](R) reader structure"]
170impl crate::Readable for DTSCON_SPEC {}
171#[doc = "`write(|w| ..)` method takes [`dtscon::W`](W) writer structure"]
172impl crate::Writable for DTSCON_SPEC {
173    type Safety = crate::Unsafe;
174    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
175    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
176}
177#[doc = "`reset()` method sets DTSCON to value 0x01"]
178impl crate::Resettable for DTSCON_SPEC {
179    const RESET_VALUE: u32 = 0x01;
180}