lpc82x_pac/i2c0/
slvctl.rs

1#[doc = "Register `SLVCTL` reader"]
2pub struct R(crate::R<SLVCTL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SLVCTL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SLVCTL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SLVCTL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SLVCTL` writer"]
17pub struct W(crate::W<SLVCTL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SLVCTL_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<SLVCTL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SLVCTL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Slave Continue.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum SLVCONTINUE_A {
40    #[doc = "0: No effect."]
41    NO_EFFECT = 0,
42    #[doc = "1: Informs the Slave function to continue to the next operation."]
43    CONTINUE = 1,
44}
45impl From<SLVCONTINUE_A> for bool {
46    #[inline(always)]
47    fn from(variant: SLVCONTINUE_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `SLVCONTINUE` reader - Slave Continue."]
52pub struct SLVCONTINUE_R(crate::FieldReader<bool, SLVCONTINUE_A>);
53impl SLVCONTINUE_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        SLVCONTINUE_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> SLVCONTINUE_A {
60        match self.bits {
61            false => SLVCONTINUE_A::NO_EFFECT,
62            true => SLVCONTINUE_A::CONTINUE,
63        }
64    }
65    #[doc = "Checks if the value of the field is `NO_EFFECT`"]
66    #[inline(always)]
67    pub fn is_no_effect(&self) -> bool {
68        **self == SLVCONTINUE_A::NO_EFFECT
69    }
70    #[doc = "Checks if the value of the field is `CONTINUE`"]
71    #[inline(always)]
72    pub fn is_continue(&self) -> bool {
73        **self == SLVCONTINUE_A::CONTINUE
74    }
75}
76impl core::ops::Deref for SLVCONTINUE_R {
77    type Target = crate::FieldReader<bool, SLVCONTINUE_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `SLVCONTINUE` writer - Slave Continue."]
84pub struct SLVCONTINUE_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> SLVCONTINUE_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: SLVCONTINUE_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "No effect."]
94    #[inline(always)]
95    pub fn no_effect(self) -> &'a mut W {
96        self.variant(SLVCONTINUE_A::NO_EFFECT)
97    }
98    #[doc = "Informs the Slave function to continue to the next operation."]
99    #[inline(always)]
100    pub fn continue_(self) -> &'a mut W {
101        self.variant(SLVCONTINUE_A::CONTINUE)
102    }
103    #[doc = r"Sets the field bit"]
104    #[inline(always)]
105    pub fn set_bit(self) -> &'a mut W {
106        self.bit(true)
107    }
108    #[doc = r"Clears the field bit"]
109    #[inline(always)]
110    pub fn clear_bit(self) -> &'a mut W {
111        self.bit(false)
112    }
113    #[doc = r"Writes raw bits to the field"]
114    #[inline(always)]
115    pub fn bit(self, value: bool) -> &'a mut W {
116        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
117        self.w
118    }
119}
120#[doc = "Slave NACK.\n\nValue on reset: 0"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122pub enum SLVNACK_A {
123    #[doc = "0: No effect."]
124    NO_EFFECT = 0,
125    #[doc = "1: NACK. Causes the Slave function to NACK the master when the slave is receiving data from the master (Slave Receiver mode)."]
126    NACK = 1,
127}
128impl From<SLVNACK_A> for bool {
129    #[inline(always)]
130    fn from(variant: SLVNACK_A) -> Self {
131        variant as u8 != 0
132    }
133}
134#[doc = "Field `SLVNACK` reader - Slave NACK."]
135pub struct SLVNACK_R(crate::FieldReader<bool, SLVNACK_A>);
136impl SLVNACK_R {
137    pub(crate) fn new(bits: bool) -> Self {
138        SLVNACK_R(crate::FieldReader::new(bits))
139    }
140    #[doc = r"Get enumerated values variant"]
141    #[inline(always)]
142    pub fn variant(&self) -> SLVNACK_A {
143        match self.bits {
144            false => SLVNACK_A::NO_EFFECT,
145            true => SLVNACK_A::NACK,
146        }
147    }
148    #[doc = "Checks if the value of the field is `NO_EFFECT`"]
149    #[inline(always)]
150    pub fn is_no_effect(&self) -> bool {
151        **self == SLVNACK_A::NO_EFFECT
152    }
153    #[doc = "Checks if the value of the field is `NACK`"]
154    #[inline(always)]
155    pub fn is_nack(&self) -> bool {
156        **self == SLVNACK_A::NACK
157    }
158}
159impl core::ops::Deref for SLVNACK_R {
160    type Target = crate::FieldReader<bool, SLVNACK_A>;
161    #[inline(always)]
162    fn deref(&self) -> &Self::Target {
163        &self.0
164    }
165}
166#[doc = "Field `SLVNACK` writer - Slave NACK."]
167pub struct SLVNACK_W<'a> {
168    w: &'a mut W,
169}
170impl<'a> SLVNACK_W<'a> {
171    #[doc = r"Writes `variant` to the field"]
172    #[inline(always)]
173    pub fn variant(self, variant: SLVNACK_A) -> &'a mut W {
174        self.bit(variant.into())
175    }
176    #[doc = "No effect."]
177    #[inline(always)]
178    pub fn no_effect(self) -> &'a mut W {
179        self.variant(SLVNACK_A::NO_EFFECT)
180    }
181    #[doc = "NACK. Causes the Slave function to NACK the master when the slave is receiving data from the master (Slave Receiver mode)."]
182    #[inline(always)]
183    pub fn nack(self) -> &'a mut W {
184        self.variant(SLVNACK_A::NACK)
185    }
186    #[doc = r"Sets the field bit"]
187    #[inline(always)]
188    pub fn set_bit(self) -> &'a mut W {
189        self.bit(true)
190    }
191    #[doc = r"Clears the field bit"]
192    #[inline(always)]
193    pub fn clear_bit(self) -> &'a mut W {
194        self.bit(false)
195    }
196    #[doc = r"Writes raw bits to the field"]
197    #[inline(always)]
198    pub fn bit(self, value: bool) -> &'a mut W {
199        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
200        self.w
201    }
202}
203#[doc = "Slave DMA enable.\n\nValue on reset: 0"]
204#[derive(Clone, Copy, Debug, PartialEq)]
205pub enum SLVDMA_A {
206    #[doc = "0: Disabled. No DMA requests are issued for Slave mode operation."]
207    DISABLED = 0,
208    #[doc = "1: Enabled. DMA requests are issued for I2C slave data transmission and reception."]
209    ENABLED = 1,
210}
211impl From<SLVDMA_A> for bool {
212    #[inline(always)]
213    fn from(variant: SLVDMA_A) -> Self {
214        variant as u8 != 0
215    }
216}
217#[doc = "Field `SLVDMA` reader - Slave DMA enable."]
218pub struct SLVDMA_R(crate::FieldReader<bool, SLVDMA_A>);
219impl SLVDMA_R {
220    pub(crate) fn new(bits: bool) -> Self {
221        SLVDMA_R(crate::FieldReader::new(bits))
222    }
223    #[doc = r"Get enumerated values variant"]
224    #[inline(always)]
225    pub fn variant(&self) -> SLVDMA_A {
226        match self.bits {
227            false => SLVDMA_A::DISABLED,
228            true => SLVDMA_A::ENABLED,
229        }
230    }
231    #[doc = "Checks if the value of the field is `DISABLED`"]
232    #[inline(always)]
233    pub fn is_disabled(&self) -> bool {
234        **self == SLVDMA_A::DISABLED
235    }
236    #[doc = "Checks if the value of the field is `ENABLED`"]
237    #[inline(always)]
238    pub fn is_enabled(&self) -> bool {
239        **self == SLVDMA_A::ENABLED
240    }
241}
242impl core::ops::Deref for SLVDMA_R {
243    type Target = crate::FieldReader<bool, SLVDMA_A>;
244    #[inline(always)]
245    fn deref(&self) -> &Self::Target {
246        &self.0
247    }
248}
249#[doc = "Field `SLVDMA` writer - Slave DMA enable."]
250pub struct SLVDMA_W<'a> {
251    w: &'a mut W,
252}
253impl<'a> SLVDMA_W<'a> {
254    #[doc = r"Writes `variant` to the field"]
255    #[inline(always)]
256    pub fn variant(self, variant: SLVDMA_A) -> &'a mut W {
257        self.bit(variant.into())
258    }
259    #[doc = "Disabled. No DMA requests are issued for Slave mode operation."]
260    #[inline(always)]
261    pub fn disabled(self) -> &'a mut W {
262        self.variant(SLVDMA_A::DISABLED)
263    }
264    #[doc = "Enabled. DMA requests are issued for I2C slave data transmission and reception."]
265    #[inline(always)]
266    pub fn enabled(self) -> &'a mut W {
267        self.variant(SLVDMA_A::ENABLED)
268    }
269    #[doc = r"Sets the field bit"]
270    #[inline(always)]
271    pub fn set_bit(self) -> &'a mut W {
272        self.bit(true)
273    }
274    #[doc = r"Clears the field bit"]
275    #[inline(always)]
276    pub fn clear_bit(self) -> &'a mut W {
277        self.bit(false)
278    }
279    #[doc = r"Writes raw bits to the field"]
280    #[inline(always)]
281    pub fn bit(self, value: bool) -> &'a mut W {
282        self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
283        self.w
284    }
285}
286impl R {
287    #[doc = "Bit 0 - Slave Continue."]
288    #[inline(always)]
289    pub fn slvcontinue(&self) -> SLVCONTINUE_R {
290        SLVCONTINUE_R::new((self.bits & 0x01) != 0)
291    }
292    #[doc = "Bit 1 - Slave NACK."]
293    #[inline(always)]
294    pub fn slvnack(&self) -> SLVNACK_R {
295        SLVNACK_R::new(((self.bits >> 1) & 0x01) != 0)
296    }
297    #[doc = "Bit 3 - Slave DMA enable."]
298    #[inline(always)]
299    pub fn slvdma(&self) -> SLVDMA_R {
300        SLVDMA_R::new(((self.bits >> 3) & 0x01) != 0)
301    }
302}
303impl W {
304    #[doc = "Bit 0 - Slave Continue."]
305    #[inline(always)]
306    pub fn slvcontinue(&mut self) -> SLVCONTINUE_W {
307        SLVCONTINUE_W { w: self }
308    }
309    #[doc = "Bit 1 - Slave NACK."]
310    #[inline(always)]
311    pub fn slvnack(&mut self) -> SLVNACK_W {
312        SLVNACK_W { w: self }
313    }
314    #[doc = "Bit 3 - Slave DMA enable."]
315    #[inline(always)]
316    pub fn slvdma(&mut self) -> SLVDMA_W {
317        SLVDMA_W { w: self }
318    }
319    #[doc = "Writes raw bits to the register."]
320    #[inline(always)]
321    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
322        self.0.bits(bits);
323        self
324    }
325}
326#[doc = "Slave control 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 [slvctl](index.html) module"]
327pub struct SLVCTL_SPEC;
328impl crate::RegisterSpec for SLVCTL_SPEC {
329    type Ux = u32;
330}
331#[doc = "`read()` method returns [slvctl::R](R) reader structure"]
332impl crate::Readable for SLVCTL_SPEC {
333    type Reader = R;
334}
335#[doc = "`write(|w| ..)` method takes [slvctl::W](W) writer structure"]
336impl crate::Writable for SLVCTL_SPEC {
337    type Writer = W;
338}
339#[doc = "`reset()` method sets SLVCTL to value 0"]
340impl crate::Resettable for SLVCTL_SPEC {
341    #[inline(always)]
342    fn reset_value() -> Self::Ux {
343        0
344    }
345}