lpc82x_pac/i2c0/
slvadr.rs1#[doc = "Register `SLVADR[%s]` reader"]
2pub struct R(crate::R<SLVADR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<SLVADR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<SLVADR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<SLVADR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `SLVADR[%s]` writer"]
17pub struct W(crate::W<SLVADR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<SLVADR_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<SLVADR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<SLVADR_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 pub(crate) fn new(bits: bool) -> Self {
55 SADISABLE_R(crate::FieldReader::new(bits))
56 }
57 #[doc = r"Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> SADISABLE_A {
60 match self.bits {
61 false => SADISABLE_A::ENABLED,
62 true => SADISABLE_A::DISABLED,
63 }
64 }
65 #[doc = "Checks if the value of the field is `ENABLED`"]
66 #[inline(always)]
67 pub fn is_enabled(&self) -> bool {
68 **self == SADISABLE_A::ENABLED
69 }
70 #[doc = "Checks if the value of the field is `DISABLED`"]
71 #[inline(always)]
72 pub fn is_disabled(&self) -> bool {
73 **self == SADISABLE_A::DISABLED
74 }
75}
76impl core::ops::Deref for SADISABLE_R {
77 type Target = crate::FieldReader<bool, SADISABLE_A>;
78 #[inline(always)]
79 fn deref(&self) -> &Self::Target {
80 &self.0
81 }
82}
83#[doc = "Field `SADISABLE` writer - Slave Address n Disable."]
84pub struct SADISABLE_W<'a> {
85 w: &'a mut W,
86}
87impl<'a> SADISABLE_W<'a> {
88 #[doc = r"Writes `variant` to the field"]
89 #[inline(always)]
90 pub fn variant(self, variant: SADISABLE_A) -> &'a mut W {
91 self.bit(variant.into())
92 }
93 #[doc = "Enabled. Slave Address n is enabled."]
94 #[inline(always)]
95 pub fn enabled(self) -> &'a mut W {
96 self.variant(SADISABLE_A::ENABLED)
97 }
98 #[doc = "Ignored Slave Address n is ignored."]
99 #[inline(always)]
100 pub fn disabled(self) -> &'a mut W {
101 self.variant(SADISABLE_A::DISABLED)
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 = "Field `SLVADR` reader - Slave Address. Seven bit slave address that is compared to received addresses if enabled."]
121pub struct SLVADR_R(crate::FieldReader<u8, u8>);
122impl SLVADR_R {
123 pub(crate) fn new(bits: u8) -> Self {
124 SLVADR_R(crate::FieldReader::new(bits))
125 }
126}
127impl core::ops::Deref for SLVADR_R {
128 type Target = crate::FieldReader<u8, u8>;
129 #[inline(always)]
130 fn deref(&self) -> &Self::Target {
131 &self.0
132 }
133}
134#[doc = "Field `SLVADR` writer - Slave Address. Seven bit slave address that is compared to received addresses if enabled."]
135pub struct SLVADR_W<'a> {
136 w: &'a mut W,
137}
138impl<'a> SLVADR_W<'a> {
139 #[doc = r"Writes raw bits to the field"]
140 #[inline(always)]
141 pub unsafe fn bits(self, value: u8) -> &'a mut W {
142 self.w.bits = (self.w.bits & !(0x7f << 1)) | ((value as u32 & 0x7f) << 1);
143 self.w
144 }
145}
146impl R {
147 #[doc = "Bit 0 - Slave Address n Disable."]
148 #[inline(always)]
149 pub fn sadisable(&self) -> SADISABLE_R {
150 SADISABLE_R::new((self.bits & 0x01) != 0)
151 }
152 #[doc = "Bits 1:7 - Slave Address. Seven bit slave address that is compared to received addresses if enabled."]
153 #[inline(always)]
154 pub fn slvadr(&self) -> SLVADR_R {
155 SLVADR_R::new(((self.bits >> 1) & 0x7f) as u8)
156 }
157}
158impl W {
159 #[doc = "Bit 0 - Slave Address n Disable."]
160 #[inline(always)]
161 pub fn sadisable(&mut self) -> SADISABLE_W {
162 SADISABLE_W { w: self }
163 }
164 #[doc = "Bits 1:7 - Slave Address. Seven bit slave address that is compared to received addresses if enabled."]
165 #[inline(always)]
166 pub fn slvadr(&mut self) -> SLVADR_W {
167 SLVADR_W { w: self }
168 }
169 #[doc = "Writes raw bits to the register."]
170 #[inline(always)]
171 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
172 self.0.bits(bits);
173 self
174 }
175}
176#[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 [slvadr](index.html) module"]
177pub struct SLVADR_SPEC;
178impl crate::RegisterSpec for SLVADR_SPEC {
179 type Ux = u32;
180}
181#[doc = "`read()` method returns [slvadr::R](R) reader structure"]
182impl crate::Readable for SLVADR_SPEC {
183 type Reader = R;
184}
185#[doc = "`write(|w| ..)` method takes [slvadr::W](W) writer structure"]
186impl crate::Writable for SLVADR_SPEC {
187 type Writer = W;
188}
189#[doc = "`reset()` method sets SLVADR[%s]
190to value 0x01"]
191impl crate::Resettable for SLVADR_SPEC {
192 #[inline(always)]
193 fn reset_value() -> Self::Ux {
194 0x01
195 }
196}