lpc55_pac/adc0/
pause.rs

1#[doc = "Register `PAUSE` reader"]
2pub struct R(crate::R<PAUSE_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PAUSE_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PAUSE_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PAUSE_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PAUSE` writer"]
17pub struct W(crate::W<PAUSE_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PAUSE_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<PAUSE_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PAUSE_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `PAUSEDLY` reader - Pause Delay"]
38pub struct PAUSEDLY_R(crate::FieldReader<u16, u16>);
39impl PAUSEDLY_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: u16) -> Self {
42        PAUSEDLY_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for PAUSEDLY_R {
46    type Target = crate::FieldReader<u16, u16>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `PAUSEDLY` writer - Pause Delay"]
53pub struct PAUSEDLY_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> PAUSEDLY_W<'a> {
57    #[doc = r"Writes raw bits to the field"]
58    #[inline(always)]
59    pub unsafe fn bits(self, value: u16) -> &'a mut W {
60        self.w.bits = (self.w.bits & !0x01ff) | (value as u32 & 0x01ff);
61        self.w
62    }
63}
64#[doc = "PAUSE Option Enable\n\nValue on reset: 0"]
65#[derive(Clone, Copy, Debug, PartialEq)]
66pub enum PAUSEEN_A {
67    #[doc = "0: Pause operation disabled"]
68    PAUSEEN_0 = 0,
69    #[doc = "1: Pause operation enabled"]
70    PAUSEEN_1 = 1,
71}
72impl From<PAUSEEN_A> for bool {
73    #[inline(always)]
74    fn from(variant: PAUSEEN_A) -> Self {
75        variant as u8 != 0
76    }
77}
78#[doc = "Field `PAUSEEN` reader - PAUSE Option Enable"]
79pub struct PAUSEEN_R(crate::FieldReader<bool, PAUSEEN_A>);
80impl PAUSEEN_R {
81    #[inline(always)]
82    pub(crate) fn new(bits: bool) -> Self {
83        PAUSEEN_R(crate::FieldReader::new(bits))
84    }
85    #[doc = r"Get enumerated values variant"]
86    #[inline(always)]
87    pub fn variant(&self) -> PAUSEEN_A {
88        match self.bits {
89            false => PAUSEEN_A::PAUSEEN_0,
90            true => PAUSEEN_A::PAUSEEN_1,
91        }
92    }
93    #[doc = "Checks if the value of the field is `PAUSEEN_0`"]
94    #[inline(always)]
95    pub fn is_pauseen_0(&self) -> bool {
96        **self == PAUSEEN_A::PAUSEEN_0
97    }
98    #[doc = "Checks if the value of the field is `PAUSEEN_1`"]
99    #[inline(always)]
100    pub fn is_pauseen_1(&self) -> bool {
101        **self == PAUSEEN_A::PAUSEEN_1
102    }
103}
104impl core::ops::Deref for PAUSEEN_R {
105    type Target = crate::FieldReader<bool, PAUSEEN_A>;
106    #[inline(always)]
107    fn deref(&self) -> &Self::Target {
108        &self.0
109    }
110}
111#[doc = "Field `PAUSEEN` writer - PAUSE Option Enable"]
112pub struct PAUSEEN_W<'a> {
113    w: &'a mut W,
114}
115impl<'a> PAUSEEN_W<'a> {
116    #[doc = r"Writes `variant` to the field"]
117    #[inline(always)]
118    pub fn variant(self, variant: PAUSEEN_A) -> &'a mut W {
119        self.bit(variant.into())
120    }
121    #[doc = "Pause operation disabled"]
122    #[inline(always)]
123    pub fn pauseen_0(self) -> &'a mut W {
124        self.variant(PAUSEEN_A::PAUSEEN_0)
125    }
126    #[doc = "Pause operation enabled"]
127    #[inline(always)]
128    pub fn pauseen_1(self) -> &'a mut W {
129        self.variant(PAUSEEN_A::PAUSEEN_1)
130    }
131    #[doc = r"Sets the field bit"]
132    #[inline(always)]
133    pub fn set_bit(self) -> &'a mut W {
134        self.bit(true)
135    }
136    #[doc = r"Clears the field bit"]
137    #[inline(always)]
138    pub fn clear_bit(self) -> &'a mut W {
139        self.bit(false)
140    }
141    #[doc = r"Writes raw bits to the field"]
142    #[inline(always)]
143    pub fn bit(self, value: bool) -> &'a mut W {
144        self.w.bits = (self.w.bits & !(0x01 << 31)) | ((value as u32 & 0x01) << 31);
145        self.w
146    }
147}
148impl R {
149    #[doc = "Bits 0:8 - Pause Delay"]
150    #[inline(always)]
151    pub fn pausedly(&self) -> PAUSEDLY_R {
152        PAUSEDLY_R::new((self.bits & 0x01ff) as u16)
153    }
154    #[doc = "Bit 31 - PAUSE Option Enable"]
155    #[inline(always)]
156    pub fn pauseen(&self) -> PAUSEEN_R {
157        PAUSEEN_R::new(((self.bits >> 31) & 0x01) != 0)
158    }
159}
160impl W {
161    #[doc = "Bits 0:8 - Pause Delay"]
162    #[inline(always)]
163    pub fn pausedly(&mut self) -> PAUSEDLY_W {
164        PAUSEDLY_W { w: self }
165    }
166    #[doc = "Bit 31 - PAUSE Option Enable"]
167    #[inline(always)]
168    pub fn pauseen(&mut self) -> PAUSEEN_W {
169        PAUSEEN_W { w: self }
170    }
171    #[doc = "Writes raw bits to the register."]
172    #[inline(always)]
173    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
174        self.0.bits(bits);
175        self
176    }
177}
178#[doc = "ADC Pause 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 [pause](index.html) module"]
179pub struct PAUSE_SPEC;
180impl crate::RegisterSpec for PAUSE_SPEC {
181    type Ux = u32;
182}
183#[doc = "`read()` method returns [pause::R](R) reader structure"]
184impl crate::Readable for PAUSE_SPEC {
185    type Reader = R;
186}
187#[doc = "`write(|w| ..)` method takes [pause::W](W) writer structure"]
188impl crate::Writable for PAUSE_SPEC {
189    type Writer = W;
190}
191#[doc = "`reset()` method sets PAUSE to value 0"]
192impl crate::Resettable for PAUSE_SPEC {
193    #[inline(always)]
194    fn reset_value() -> Self::Ux {
195        0
196    }
197}