xmc4100/vadc/
ocs.rs

1#[doc = "Register `OCS` reader"]
2pub type R = crate::R<OCS_SPEC>;
3#[doc = "Register `OCS` writer"]
4pub type W = crate::W<OCS_SPEC>;
5#[doc = "Trigger Set for OTGB0/1\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum TGS_A {
9    #[doc = "0: No Trigger Set output"]
10    VALUE1 = 0,
11    #[doc = "1: Trigger Set 1: TS16_SSIG, input sample signals"]
12    VALUE2 = 1,
13}
14impl From<TGS_A> for u8 {
15    #[inline(always)]
16    fn from(variant: TGS_A) -> Self {
17        variant as _
18    }
19}
20impl crate::FieldSpec for TGS_A {
21    type Ux = u8;
22}
23impl crate::IsEnum for TGS_A {}
24#[doc = "Field `TGS` reader - Trigger Set for OTGB0/1"]
25pub type TGS_R = crate::FieldReader<TGS_A>;
26impl TGS_R {
27    #[doc = "Get enumerated values variant"]
28    #[inline(always)]
29    pub const fn variant(&self) -> Option<TGS_A> {
30        match self.bits {
31            0 => Some(TGS_A::VALUE1),
32            1 => Some(TGS_A::VALUE2),
33            _ => None,
34        }
35    }
36    #[doc = "No Trigger Set output"]
37    #[inline(always)]
38    pub fn is_value1(&self) -> bool {
39        *self == TGS_A::VALUE1
40    }
41    #[doc = "Trigger Set 1: TS16_SSIG, input sample signals"]
42    #[inline(always)]
43    pub fn is_value2(&self) -> bool {
44        *self == TGS_A::VALUE2
45    }
46}
47#[doc = "Field `TGS` writer - Trigger Set for OTGB0/1"]
48pub type TGS_W<'a, REG> = crate::FieldWriter<'a, REG, 2, TGS_A>;
49impl<'a, REG> TGS_W<'a, REG>
50where
51    REG: crate::Writable + crate::RegisterSpec,
52    REG::Ux: From<u8>,
53{
54    #[doc = "No Trigger Set output"]
55    #[inline(always)]
56    pub fn value1(self) -> &'a mut crate::W<REG> {
57        self.variant(TGS_A::VALUE1)
58    }
59    #[doc = "Trigger Set 1: TS16_SSIG, input sample signals"]
60    #[inline(always)]
61    pub fn value2(self) -> &'a mut crate::W<REG> {
62        self.variant(TGS_A::VALUE2)
63    }
64}
65#[doc = "OTGB0/1 Bus Select\n\nValue on reset: 0"]
66#[derive(Clone, Copy, Debug, PartialEq, Eq)]
67pub enum TGB_A {
68    #[doc = "0: Trigger Set is output on OTGB0"]
69    VALUE1 = 0,
70    #[doc = "1: Trigger Set is output on OTGB1"]
71    VALUE2 = 1,
72}
73impl From<TGB_A> for bool {
74    #[inline(always)]
75    fn from(variant: TGB_A) -> Self {
76        variant as u8 != 0
77    }
78}
79#[doc = "Field `TGB` reader - OTGB0/1 Bus Select"]
80pub type TGB_R = crate::BitReader<TGB_A>;
81impl TGB_R {
82    #[doc = "Get enumerated values variant"]
83    #[inline(always)]
84    pub const fn variant(&self) -> TGB_A {
85        match self.bits {
86            false => TGB_A::VALUE1,
87            true => TGB_A::VALUE2,
88        }
89    }
90    #[doc = "Trigger Set is output on OTGB0"]
91    #[inline(always)]
92    pub fn is_value1(&self) -> bool {
93        *self == TGB_A::VALUE1
94    }
95    #[doc = "Trigger Set is output on OTGB1"]
96    #[inline(always)]
97    pub fn is_value2(&self) -> bool {
98        *self == TGB_A::VALUE2
99    }
100}
101#[doc = "Field `TGB` writer - OTGB0/1 Bus Select"]
102pub type TGB_W<'a, REG> = crate::BitWriter<'a, REG, TGB_A>;
103impl<'a, REG> TGB_W<'a, REG>
104where
105    REG: crate::Writable + crate::RegisterSpec,
106{
107    #[doc = "Trigger Set is output on OTGB0"]
108    #[inline(always)]
109    pub fn value1(self) -> &'a mut crate::W<REG> {
110        self.variant(TGB_A::VALUE1)
111    }
112    #[doc = "Trigger Set is output on OTGB1"]
113    #[inline(always)]
114    pub fn value2(self) -> &'a mut crate::W<REG> {
115        self.variant(TGB_A::VALUE2)
116    }
117}
118#[doc = "Field `TG_P` writer - TGS, TGB Write Protection"]
119pub type TG_P_W<'a, REG> = crate::BitWriter<'a, REG>;
120#[doc = "OCDS Suspend Control\n\nValue on reset: 0"]
121#[derive(Clone, Copy, Debug, PartialEq, Eq)]
122#[repr(u8)]
123pub enum SUS_A {
124    #[doc = "0: Will not suspend"]
125    VALUE1 = 0,
126    #[doc = "1: Hard suspend: Clock is switched off immediately."]
127    VALUE2 = 1,
128    #[doc = "2: Soft suspend mode 0: Stop conversions after the currently running one is completed and its result has been stored. No change for the arbiter."]
129    VALUE3 = 2,
130    #[doc = "3: Soft suspend mode 1: Stop conversions after the currently running one is completed and its result has been stored. Stop arbiter after the current arbitration round."]
131    VALUE4 = 3,
132}
133impl From<SUS_A> for u8 {
134    #[inline(always)]
135    fn from(variant: SUS_A) -> Self {
136        variant as _
137    }
138}
139impl crate::FieldSpec for SUS_A {
140    type Ux = u8;
141}
142impl crate::IsEnum for SUS_A {}
143#[doc = "Field `SUS` reader - OCDS Suspend Control"]
144pub type SUS_R = crate::FieldReader<SUS_A>;
145impl SUS_R {
146    #[doc = "Get enumerated values variant"]
147    #[inline(always)]
148    pub const fn variant(&self) -> Option<SUS_A> {
149        match self.bits {
150            0 => Some(SUS_A::VALUE1),
151            1 => Some(SUS_A::VALUE2),
152            2 => Some(SUS_A::VALUE3),
153            3 => Some(SUS_A::VALUE4),
154            _ => None,
155        }
156    }
157    #[doc = "Will not suspend"]
158    #[inline(always)]
159    pub fn is_value1(&self) -> bool {
160        *self == SUS_A::VALUE1
161    }
162    #[doc = "Hard suspend: Clock is switched off immediately."]
163    #[inline(always)]
164    pub fn is_value2(&self) -> bool {
165        *self == SUS_A::VALUE2
166    }
167    #[doc = "Soft suspend mode 0: Stop conversions after the currently running one is completed and its result has been stored. No change for the arbiter."]
168    #[inline(always)]
169    pub fn is_value3(&self) -> bool {
170        *self == SUS_A::VALUE3
171    }
172    #[doc = "Soft suspend mode 1: Stop conversions after the currently running one is completed and its result has been stored. Stop arbiter after the current arbitration round."]
173    #[inline(always)]
174    pub fn is_value4(&self) -> bool {
175        *self == SUS_A::VALUE4
176    }
177}
178#[doc = "Field `SUS` writer - OCDS Suspend Control"]
179pub type SUS_W<'a, REG> = crate::FieldWriter<'a, REG, 4, SUS_A>;
180impl<'a, REG> SUS_W<'a, REG>
181where
182    REG: crate::Writable + crate::RegisterSpec,
183    REG::Ux: From<u8>,
184{
185    #[doc = "Will not suspend"]
186    #[inline(always)]
187    pub fn value1(self) -> &'a mut crate::W<REG> {
188        self.variant(SUS_A::VALUE1)
189    }
190    #[doc = "Hard suspend: Clock is switched off immediately."]
191    #[inline(always)]
192    pub fn value2(self) -> &'a mut crate::W<REG> {
193        self.variant(SUS_A::VALUE2)
194    }
195    #[doc = "Soft suspend mode 0: Stop conversions after the currently running one is completed and its result has been stored. No change for the arbiter."]
196    #[inline(always)]
197    pub fn value3(self) -> &'a mut crate::W<REG> {
198        self.variant(SUS_A::VALUE3)
199    }
200    #[doc = "Soft suspend mode 1: Stop conversions after the currently running one is completed and its result has been stored. Stop arbiter after the current arbitration round."]
201    #[inline(always)]
202    pub fn value4(self) -> &'a mut crate::W<REG> {
203        self.variant(SUS_A::VALUE4)
204    }
205}
206#[doc = "Field `SUS_P` writer - SUS Write Protection"]
207pub type SUS_P_W<'a, REG> = crate::BitWriter<'a, REG>;
208#[doc = "Suspend State\n\nValue on reset: 0"]
209#[derive(Clone, Copy, Debug, PartialEq, Eq)]
210pub enum SUSSTA_A {
211    #[doc = "0: Module is not (yet) suspended"]
212    VALUE1 = 0,
213    #[doc = "1: Module is suspended"]
214    VALUE2 = 1,
215}
216impl From<SUSSTA_A> for bool {
217    #[inline(always)]
218    fn from(variant: SUSSTA_A) -> Self {
219        variant as u8 != 0
220    }
221}
222#[doc = "Field `SUSSTA` reader - Suspend State"]
223pub type SUSSTA_R = crate::BitReader<SUSSTA_A>;
224impl SUSSTA_R {
225    #[doc = "Get enumerated values variant"]
226    #[inline(always)]
227    pub const fn variant(&self) -> SUSSTA_A {
228        match self.bits {
229            false => SUSSTA_A::VALUE1,
230            true => SUSSTA_A::VALUE2,
231        }
232    }
233    #[doc = "Module is not (yet) suspended"]
234    #[inline(always)]
235    pub fn is_value1(&self) -> bool {
236        *self == SUSSTA_A::VALUE1
237    }
238    #[doc = "Module is suspended"]
239    #[inline(always)]
240    pub fn is_value2(&self) -> bool {
241        *self == SUSSTA_A::VALUE2
242    }
243}
244impl R {
245    #[doc = "Bits 0:1 - Trigger Set for OTGB0/1"]
246    #[inline(always)]
247    pub fn tgs(&self) -> TGS_R {
248        TGS_R::new((self.bits & 3) as u8)
249    }
250    #[doc = "Bit 2 - OTGB0/1 Bus Select"]
251    #[inline(always)]
252    pub fn tgb(&self) -> TGB_R {
253        TGB_R::new(((self.bits >> 2) & 1) != 0)
254    }
255    #[doc = "Bits 24:27 - OCDS Suspend Control"]
256    #[inline(always)]
257    pub fn sus(&self) -> SUS_R {
258        SUS_R::new(((self.bits >> 24) & 0x0f) as u8)
259    }
260    #[doc = "Bit 29 - Suspend State"]
261    #[inline(always)]
262    pub fn sussta(&self) -> SUSSTA_R {
263        SUSSTA_R::new(((self.bits >> 29) & 1) != 0)
264    }
265}
266impl W {
267    #[doc = "Bits 0:1 - Trigger Set for OTGB0/1"]
268    #[inline(always)]
269    pub fn tgs(&mut self) -> TGS_W<OCS_SPEC> {
270        TGS_W::new(self, 0)
271    }
272    #[doc = "Bit 2 - OTGB0/1 Bus Select"]
273    #[inline(always)]
274    pub fn tgb(&mut self) -> TGB_W<OCS_SPEC> {
275        TGB_W::new(self, 2)
276    }
277    #[doc = "Bit 3 - TGS, TGB Write Protection"]
278    #[inline(always)]
279    pub fn tg_p(&mut self) -> TG_P_W<OCS_SPEC> {
280        TG_P_W::new(self, 3)
281    }
282    #[doc = "Bits 24:27 - OCDS Suspend Control"]
283    #[inline(always)]
284    pub fn sus(&mut self) -> SUS_W<OCS_SPEC> {
285        SUS_W::new(self, 24)
286    }
287    #[doc = "Bit 28 - SUS Write Protection"]
288    #[inline(always)]
289    pub fn sus_p(&mut self) -> SUS_P_W<OCS_SPEC> {
290        SUS_P_W::new(self, 28)
291    }
292}
293#[doc = "OCDS Control and Status Register\n\nYou can [`read`](crate::Reg::read) this register and get [`ocs::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ocs::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
294pub struct OCS_SPEC;
295impl crate::RegisterSpec for OCS_SPEC {
296    type Ux = u32;
297}
298#[doc = "`read()` method returns [`ocs::R`](R) reader structure"]
299impl crate::Readable for OCS_SPEC {}
300#[doc = "`write(|w| ..)` method takes [`ocs::W`](W) writer structure"]
301impl crate::Writable for OCS_SPEC {
302    type Safety = crate::Unsafe;
303    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
304    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
305}
306#[doc = "`reset()` method sets OCS to value 0"]
307impl crate::Resettable for OCS_SPEC {
308    const RESET_VALUE: u32 = 0;
309}