xmc4800/dsd/
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 = "OCDS Suspend Control\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum SUS_A {
9    #[doc = "0: Will not suspend"]
10    VALUE1 = 0,
11    #[doc = "1: Hard suspend: Clock is switched off immediately."]
12    VALUE2 = 1,
13    #[doc = "2: Soft suspend channel 0"]
14    VALUE3 = 2,
15    #[doc = "3: Soft suspend channel 1"]
16    VALUE4 = 3,
17    #[doc = "5: Soft suspend channel 3"]
18    VALUE5 = 5,
19}
20impl From<SUS_A> for u8 {
21    #[inline(always)]
22    fn from(variant: SUS_A) -> Self {
23        variant as _
24    }
25}
26impl crate::FieldSpec for SUS_A {
27    type Ux = u8;
28}
29impl crate::IsEnum for SUS_A {}
30#[doc = "Field `SUS` reader - OCDS Suspend Control"]
31pub type SUS_R = crate::FieldReader<SUS_A>;
32impl SUS_R {
33    #[doc = "Get enumerated values variant"]
34    #[inline(always)]
35    pub const fn variant(&self) -> Option<SUS_A> {
36        match self.bits {
37            0 => Some(SUS_A::VALUE1),
38            1 => Some(SUS_A::VALUE2),
39            2 => Some(SUS_A::VALUE3),
40            3 => Some(SUS_A::VALUE4),
41            5 => Some(SUS_A::VALUE5),
42            _ => None,
43        }
44    }
45    #[doc = "Will not suspend"]
46    #[inline(always)]
47    pub fn is_value1(&self) -> bool {
48        *self == SUS_A::VALUE1
49    }
50    #[doc = "Hard suspend: Clock is switched off immediately."]
51    #[inline(always)]
52    pub fn is_value2(&self) -> bool {
53        *self == SUS_A::VALUE2
54    }
55    #[doc = "Soft suspend channel 0"]
56    #[inline(always)]
57    pub fn is_value3(&self) -> bool {
58        *self == SUS_A::VALUE3
59    }
60    #[doc = "Soft suspend channel 1"]
61    #[inline(always)]
62    pub fn is_value4(&self) -> bool {
63        *self == SUS_A::VALUE4
64    }
65    #[doc = "Soft suspend channel 3"]
66    #[inline(always)]
67    pub fn is_value5(&self) -> bool {
68        *self == SUS_A::VALUE5
69    }
70}
71#[doc = "Field `SUS` writer - OCDS Suspend Control"]
72pub type SUS_W<'a, REG> = crate::FieldWriter<'a, REG, 4, SUS_A>;
73impl<'a, REG> SUS_W<'a, REG>
74where
75    REG: crate::Writable + crate::RegisterSpec,
76    REG::Ux: From<u8>,
77{
78    #[doc = "Will not suspend"]
79    #[inline(always)]
80    pub fn value1(self) -> &'a mut crate::W<REG> {
81        self.variant(SUS_A::VALUE1)
82    }
83    #[doc = "Hard suspend: Clock is switched off immediately."]
84    #[inline(always)]
85    pub fn value2(self) -> &'a mut crate::W<REG> {
86        self.variant(SUS_A::VALUE2)
87    }
88    #[doc = "Soft suspend channel 0"]
89    #[inline(always)]
90    pub fn value3(self) -> &'a mut crate::W<REG> {
91        self.variant(SUS_A::VALUE3)
92    }
93    #[doc = "Soft suspend channel 1"]
94    #[inline(always)]
95    pub fn value4(self) -> &'a mut crate::W<REG> {
96        self.variant(SUS_A::VALUE4)
97    }
98    #[doc = "Soft suspend channel 3"]
99    #[inline(always)]
100    pub fn value5(self) -> &'a mut crate::W<REG> {
101        self.variant(SUS_A::VALUE5)
102    }
103}
104#[doc = "Field `SUS_P` writer - SUS Write Protection"]
105pub type SUS_P_W<'a, REG> = crate::BitWriter<'a, REG>;
106#[doc = "Suspend State\n\nValue on reset: 0"]
107#[derive(Clone, Copy, Debug, PartialEq, Eq)]
108pub enum SUSSTA_A {
109    #[doc = "0: Module is not (yet) suspended"]
110    VALUE1 = 0,
111    #[doc = "1: Module is suspended"]
112    VALUE2 = 1,
113}
114impl From<SUSSTA_A> for bool {
115    #[inline(always)]
116    fn from(variant: SUSSTA_A) -> Self {
117        variant as u8 != 0
118    }
119}
120#[doc = "Field `SUSSTA` reader - Suspend State"]
121pub type SUSSTA_R = crate::BitReader<SUSSTA_A>;
122impl SUSSTA_R {
123    #[doc = "Get enumerated values variant"]
124    #[inline(always)]
125    pub const fn variant(&self) -> SUSSTA_A {
126        match self.bits {
127            false => SUSSTA_A::VALUE1,
128            true => SUSSTA_A::VALUE2,
129        }
130    }
131    #[doc = "Module is not (yet) suspended"]
132    #[inline(always)]
133    pub fn is_value1(&self) -> bool {
134        *self == SUSSTA_A::VALUE1
135    }
136    #[doc = "Module is suspended"]
137    #[inline(always)]
138    pub fn is_value2(&self) -> bool {
139        *self == SUSSTA_A::VALUE2
140    }
141}
142impl R {
143    #[doc = "Bits 24:27 - OCDS Suspend Control"]
144    #[inline(always)]
145    pub fn sus(&self) -> SUS_R {
146        SUS_R::new(((self.bits >> 24) & 0x0f) as u8)
147    }
148    #[doc = "Bit 29 - Suspend State"]
149    #[inline(always)]
150    pub fn sussta(&self) -> SUSSTA_R {
151        SUSSTA_R::new(((self.bits >> 29) & 1) != 0)
152    }
153}
154impl W {
155    #[doc = "Bits 24:27 - OCDS Suspend Control"]
156    #[inline(always)]
157    pub fn sus(&mut self) -> SUS_W<OCS_SPEC> {
158        SUS_W::new(self, 24)
159    }
160    #[doc = "Bit 28 - SUS Write Protection"]
161    #[inline(always)]
162    pub fn sus_p(&mut self) -> SUS_P_W<OCS_SPEC> {
163        SUS_P_W::new(self, 28)
164    }
165}
166#[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)."]
167pub struct OCS_SPEC;
168impl crate::RegisterSpec for OCS_SPEC {
169    type Ux = u32;
170}
171#[doc = "`read()` method returns [`ocs::R`](R) reader structure"]
172impl crate::Readable for OCS_SPEC {}
173#[doc = "`write(|w| ..)` method takes [`ocs::W`](W) writer structure"]
174impl crate::Writable for OCS_SPEC {
175    type Safety = crate::Unsafe;
176    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
177    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
178}
179#[doc = "`reset()` method sets OCS to value 0"]
180impl crate::Resettable for OCS_SPEC {
181    const RESET_VALUE: u32 = 0;
182}