lpc55_pac/i2c0/
slvadr2.rs

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