1#[doc = "Register `SLVADR0` reader"]
2pub struct R(crate::R<SLVADR0_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<SLVADR0_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<SLVADR0_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<SLVADR0_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `SLVADR0` writer"]
17pub struct W(crate::W<SLVADR0_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<SLVADR0_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<SLVADR0_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<SLVADR0_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `SADISABLE` reader - Slave Address n Disable."]
38pub type SADISABLE_R = crate::BitReader<SADISABLE_A>;
39#[doc = "Slave Address n Disable.\n\nValue on reset: 1"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum SADISABLE_A {
42 #[doc = "0: Enabled. Slave Address n is enabled."]
43 ENABLED = 0,
44 #[doc = "1: Ignored Slave Address n is ignored."]
45 DISABLED = 1,
46}
47impl From<SADISABLE_A> for bool {
48 #[inline(always)]
49 fn from(variant: SADISABLE_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl SADISABLE_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> SADISABLE_A {
57 match self.bits {
58 false => SADISABLE_A::ENABLED,
59 true => SADISABLE_A::DISABLED,
60 }
61 }
62 #[doc = "Checks if the value of the field is `ENABLED`"]
63 #[inline(always)]
64 pub fn is_enabled(&self) -> bool {
65 *self == SADISABLE_A::ENABLED
66 }
67 #[doc = "Checks if the value of the field is `DISABLED`"]
68 #[inline(always)]
69 pub fn is_disabled(&self) -> bool {
70 *self == SADISABLE_A::DISABLED
71 }
72}
73#[doc = "Field `SADISABLE` writer - Slave Address n Disable."]
74pub type SADISABLE_W<'a, const O: u8> = crate::BitWriter<'a, u32, SLVADR0_SPEC, SADISABLE_A, O>;
75impl<'a, const O: u8> SADISABLE_W<'a, O> {
76 #[doc = "Enabled. Slave Address n is enabled."]
77 #[inline(always)]
78 pub fn enabled(self) -> &'a mut W {
79 self.variant(SADISABLE_A::ENABLED)
80 }
81 #[doc = "Ignored Slave Address n is ignored."]
82 #[inline(always)]
83 pub fn disabled(self) -> &'a mut W {
84 self.variant(SADISABLE_A::DISABLED)
85 }
86}
87#[doc = "Field `SLVADR` reader - Slave Address. Seven bit slave address that is compared to received addresses if enabled."]
88pub type SLVADR_R = crate::FieldReader<u8, u8>;
89#[doc = "Field `SLVADR` writer - Slave Address. Seven bit slave address that is compared to received addresses if enabled."]
90pub type SLVADR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SLVADR0_SPEC, u8, u8, 7, O>;
91#[doc = "Field `AUTONACK` reader - Automatic NACK operation. Used in conjunction with AUTOACK and AUTOMATCHREAD, allows software to ignore I2C traffic while handling previous I2C data or other operations."]
92pub type AUTONACK_R = crate::BitReader<AUTONACK_A>;
93#[doc = "Automatic NACK operation. Used in conjunction with AUTOACK and AUTOMATCHREAD, allows software to ignore I2C traffic while handling previous I2C data or other operations.\n\nValue on reset: 0"]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95pub enum AUTONACK_A {
96 #[doc = "0: Normal operation, matching I2C addresses are not ignored."]
97 NORMAL = 0,
98 #[doc = "1: Automatic-only mode. All incoming addresses are ignored (NACKed), unless AUTOACK is set, it matches SLVADRn, and AUTOMATCHREAD matches the direction."]
99 AUTOMATIC = 1,
100}
101impl From<AUTONACK_A> for bool {
102 #[inline(always)]
103 fn from(variant: AUTONACK_A) -> Self {
104 variant as u8 != 0
105 }
106}
107impl AUTONACK_R {
108 #[doc = "Get enumerated values variant"]
109 #[inline(always)]
110 pub fn variant(&self) -> AUTONACK_A {
111 match self.bits {
112 false => AUTONACK_A::NORMAL,
113 true => AUTONACK_A::AUTOMATIC,
114 }
115 }
116 #[doc = "Checks if the value of the field is `NORMAL`"]
117 #[inline(always)]
118 pub fn is_normal(&self) -> bool {
119 *self == AUTONACK_A::NORMAL
120 }
121 #[doc = "Checks if the value of the field is `AUTOMATIC`"]
122 #[inline(always)]
123 pub fn is_automatic(&self) -> bool {
124 *self == AUTONACK_A::AUTOMATIC
125 }
126}
127#[doc = "Field `AUTONACK` writer - Automatic NACK operation. Used in conjunction with AUTOACK and AUTOMATCHREAD, allows software to ignore I2C traffic while handling previous I2C data or other operations."]
128pub type AUTONACK_W<'a, const O: u8> = crate::BitWriter<'a, u32, SLVADR0_SPEC, AUTONACK_A, O>;
129impl<'a, const O: u8> AUTONACK_W<'a, O> {
130 #[doc = "Normal operation, matching I2C addresses are not ignored."]
131 #[inline(always)]
132 pub fn normal(self) -> &'a mut W {
133 self.variant(AUTONACK_A::NORMAL)
134 }
135 #[doc = "Automatic-only mode. All incoming addresses are ignored (NACKed), unless AUTOACK is set, it matches SLVADRn, and AUTOMATCHREAD matches the direction."]
136 #[inline(always)]
137 pub fn automatic(self) -> &'a mut W {
138 self.variant(AUTONACK_A::AUTOMATIC)
139 }
140}
141impl R {
142 #[doc = "Bit 0 - Slave Address n Disable."]
143 #[inline(always)]
144 pub fn sadisable(&self) -> SADISABLE_R {
145 SADISABLE_R::new((self.bits & 1) != 0)
146 }
147 #[doc = "Bits 1:7 - Slave Address. Seven bit slave address that is compared to received addresses if enabled."]
148 #[inline(always)]
149 pub fn slvadr(&self) -> SLVADR_R {
150 SLVADR_R::new(((self.bits >> 1) & 0x7f) as u8)
151 }
152 #[doc = "Bit 15 - Automatic NACK operation. Used in conjunction with AUTOACK and AUTOMATCHREAD, allows software to ignore I2C traffic while handling previous I2C data or other operations."]
153 #[inline(always)]
154 pub fn autonack(&self) -> AUTONACK_R {
155 AUTONACK_R::new(((self.bits >> 15) & 1) != 0)
156 }
157}
158impl W {
159 #[doc = "Bit 0 - Slave Address n Disable."]
160 #[inline(always)]
161 pub fn sadisable(&mut self) -> SADISABLE_W<0> {
162 SADISABLE_W::new(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<1> {
167 SLVADR_W::new(self)
168 }
169 #[doc = "Bit 15 - Automatic NACK operation. Used in conjunction with AUTOACK and AUTOMATCHREAD, allows software to ignore I2C traffic while handling previous I2C data or other operations."]
170 #[inline(always)]
171 pub fn autonack(&mut self) -> AUTONACK_W<15> {
172 AUTONACK_W::new(self)
173 }
174 #[doc = "Writes raw bits to the register."]
175 #[inline(always)]
176 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
177 self.0.bits(bits);
178 self
179 }
180}
181#[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 [slvadr0](index.html) module"]
182pub struct SLVADR0_SPEC;
183impl crate::RegisterSpec for SLVADR0_SPEC {
184 type Ux = u32;
185}
186#[doc = "`read()` method returns [slvadr0::R](R) reader structure"]
187impl crate::Readable for SLVADR0_SPEC {
188 type Reader = R;
189}
190#[doc = "`write(|w| ..)` method takes [slvadr0::W](W) writer structure"]
191impl crate::Writable for SLVADR0_SPEC {
192 type Writer = W;
193}
194#[doc = "`reset()` method sets SLVADR0 to value 0x01"]
195impl crate::Resettable for SLVADR0_SPEC {
196 #[inline(always)]
197 fn reset_value() -> Self::Ux {
198 0x01
199 }
200}