lpc82x_pac/i2c0/
slvqual0.rs1#[doc = "Register `SLVQUAL0` reader"]
2pub struct R(crate::R<SLVQUAL0_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<SLVQUAL0_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<SLVQUAL0_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<SLVQUAL0_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `SLVQUAL0` writer"]
17pub struct W(crate::W<SLVQUAL0_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<SLVQUAL0_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<SLVQUAL0_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<SLVQUAL0_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Qualify mode for slave address 0.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum QUALMODE0_A {
40 #[doc = "0: Mask. The SLVQUAL0 field is used as a logical mask for matching address 0."]
41 MASK = 0,
42 #[doc = "1: Extend. The SLVQUAL0 field is used to extend address 0 matching in a range of addresses."]
43 EXTEND = 1,
44}
45impl From<QUALMODE0_A> for bool {
46 #[inline(always)]
47 fn from(variant: QUALMODE0_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `QUALMODE0` reader - Qualify mode for slave address 0."]
52pub struct QUALMODE0_R(crate::FieldReader<bool, QUALMODE0_A>);
53impl QUALMODE0_R {
54 pub(crate) fn new(bits: bool) -> Self {
55 QUALMODE0_R(crate::FieldReader::new(bits))
56 }
57 #[doc = r"Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> QUALMODE0_A {
60 match self.bits {
61 false => QUALMODE0_A::MASK,
62 true => QUALMODE0_A::EXTEND,
63 }
64 }
65 #[doc = "Checks if the value of the field is `MASK`"]
66 #[inline(always)]
67 pub fn is_mask(&self) -> bool {
68 **self == QUALMODE0_A::MASK
69 }
70 #[doc = "Checks if the value of the field is `EXTEND`"]
71 #[inline(always)]
72 pub fn is_extend(&self) -> bool {
73 **self == QUALMODE0_A::EXTEND
74 }
75}
76impl core::ops::Deref for QUALMODE0_R {
77 type Target = crate::FieldReader<bool, QUALMODE0_A>;
78 #[inline(always)]
79 fn deref(&self) -> &Self::Target {
80 &self.0
81 }
82}
83#[doc = "Field `QUALMODE0` writer - Qualify mode for slave address 0."]
84pub struct QUALMODE0_W<'a> {
85 w: &'a mut W,
86}
87impl<'a> QUALMODE0_W<'a> {
88 #[doc = r"Writes `variant` to the field"]
89 #[inline(always)]
90 pub fn variant(self, variant: QUALMODE0_A) -> &'a mut W {
91 self.bit(variant.into())
92 }
93 #[doc = "Mask. The SLVQUAL0 field is used as a logical mask for matching address 0."]
94 #[inline(always)]
95 pub fn mask(self) -> &'a mut W {
96 self.variant(QUALMODE0_A::MASK)
97 }
98 #[doc = "Extend. The SLVQUAL0 field is used to extend address 0 matching in a range of addresses."]
99 #[inline(always)]
100 pub fn extend(self) -> &'a mut W {
101 self.variant(QUALMODE0_A::EXTEND)
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 `SLVQUAL0` reader - Slave address Qualifier for address 0. A value of 0 causes the address in SLVADR0 to be used as-is, assuming that it is enabled. If QUALMODE0 = 0, any bit in this field which is set to 1 will cause an automatic match of the corresponding bit of the received address when it is compared to the SLVADR0 register. If QUALMODE0 = 1, an address range is matched for address 0. This range extends from the value defined by SLVADR0 to the address defined by SLVQUAL0 (address matches when SLVADR0\\[7:1\\]
121<= received address <= SLVQUAL0\\[7:1\\])."]
122pub struct SLVQUAL0_R(crate::FieldReader<u8, u8>);
123impl SLVQUAL0_R {
124 pub(crate) fn new(bits: u8) -> Self {
125 SLVQUAL0_R(crate::FieldReader::new(bits))
126 }
127}
128impl core::ops::Deref for SLVQUAL0_R {
129 type Target = crate::FieldReader<u8, u8>;
130 #[inline(always)]
131 fn deref(&self) -> &Self::Target {
132 &self.0
133 }
134}
135#[doc = "Field `SLVQUAL0` writer - Slave address Qualifier for address 0. A value of 0 causes the address in SLVADR0 to be used as-is, assuming that it is enabled. If QUALMODE0 = 0, any bit in this field which is set to 1 will cause an automatic match of the corresponding bit of the received address when it is compared to the SLVADR0 register. If QUALMODE0 = 1, an address range is matched for address 0. This range extends from the value defined by SLVADR0 to the address defined by SLVQUAL0 (address matches when SLVADR0\\[7:1\\]
136<= received address <= SLVQUAL0\\[7:1\\])."]
137pub struct SLVQUAL0_W<'a> {
138 w: &'a mut W,
139}
140impl<'a> SLVQUAL0_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 - Qualify mode for slave address 0."]
150 #[inline(always)]
151 pub fn qualmode0(&self) -> QUALMODE0_R {
152 QUALMODE0_R::new((self.bits & 0x01) != 0)
153 }
154 #[doc = "Bits 1:7 - Slave address Qualifier for address 0. A value of 0 causes the address in SLVADR0 to be used as-is, assuming that it is enabled. If QUALMODE0 = 0, any bit in this field which is set to 1 will cause an automatic match of the corresponding bit of the received address when it is compared to the SLVADR0 register. If QUALMODE0 = 1, an address range is matched for address 0. This range extends from the value defined by SLVADR0 to the address defined by SLVQUAL0 (address matches when SLVADR0\\[7:1\\]
155<= received address <= SLVQUAL0\\[7:1\\])."]
156 #[inline(always)]
157 pub fn slvqual0(&self) -> SLVQUAL0_R {
158 SLVQUAL0_R::new(((self.bits >> 1) & 0x7f) as u8)
159 }
160}
161impl W {
162 #[doc = "Bit 0 - Qualify mode for slave address 0."]
163 #[inline(always)]
164 pub fn qualmode0(&mut self) -> QUALMODE0_W {
165 QUALMODE0_W { w: self }
166 }
167 #[doc = "Bits 1:7 - Slave address Qualifier for address 0. A value of 0 causes the address in SLVADR0 to be used as-is, assuming that it is enabled. If QUALMODE0 = 0, any bit in this field which is set to 1 will cause an automatic match of the corresponding bit of the received address when it is compared to the SLVADR0 register. If QUALMODE0 = 1, an address range is matched for address 0. This range extends from the value defined by SLVADR0 to the address defined by SLVQUAL0 (address matches when SLVADR0\\[7:1\\]
168<= received address <= SLVQUAL0\\[7:1\\])."]
169 #[inline(always)]
170 pub fn slvqual0(&mut self) -> SLVQUAL0_W {
171 SLVQUAL0_W { w: self }
172 }
173 #[doc = "Writes raw bits to the register."]
174 #[inline(always)]
175 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
176 self.0.bits(bits);
177 self
178 }
179}
180#[doc = "Slave Qualification for address 0.\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 [slvqual0](index.html) module"]
181pub struct SLVQUAL0_SPEC;
182impl crate::RegisterSpec for SLVQUAL0_SPEC {
183 type Ux = u32;
184}
185#[doc = "`read()` method returns [slvqual0::R](R) reader structure"]
186impl crate::Readable for SLVQUAL0_SPEC {
187 type Reader = R;
188}
189#[doc = "`write(|w| ..)` method takes [slvqual0::W](W) writer structure"]
190impl crate::Writable for SLVQUAL0_SPEC {
191 type Writer = W;
192}
193#[doc = "`reset()` method sets SLVQUAL0 to value 0"]
194impl crate::Resettable for SLVQUAL0_SPEC {
195 #[inline(always)]
196 fn reset_value() -> Self::Ux {
197 0
198 }
199}