1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `EN` reader - I2C Enable"]
38pub type EN_R = crate::BitReader<bool>;
39#[doc = "Field `EN` writer - I2C Enable"]
40pub type EN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 0>;
41#[doc = "Field `SLAVE` reader - Addressable as Slave"]
42pub type SLAVE_R = crate::BitReader<bool>;
43#[doc = "Field `SLAVE` writer - Addressable as Slave"]
44pub type SLAVE_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 1>;
45#[doc = "Field `AUTOACK` reader - Automatic Acknowledge"]
46pub type AUTOACK_R = crate::BitReader<bool>;
47#[doc = "Field `AUTOACK` writer - Automatic Acknowledge"]
48pub type AUTOACK_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 2>;
49#[doc = "Field `AUTOSE` reader - Automatic STOP when Empty"]
50pub type AUTOSE_R = crate::BitReader<bool>;
51#[doc = "Field `AUTOSE` writer - Automatic STOP when Empty"]
52pub type AUTOSE_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 3>;
53#[doc = "Field `AUTOSN` reader - Automatic STOP on NACK"]
54pub type AUTOSN_R = crate::BitReader<bool>;
55#[doc = "Field `AUTOSN` writer - Automatic STOP on NACK"]
56pub type AUTOSN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 4>;
57#[doc = "Field `ARBDIS` reader - Arbitration Disable"]
58pub type ARBDIS_R = crate::BitReader<bool>;
59#[doc = "Field `ARBDIS` writer - Arbitration Disable"]
60pub type ARBDIS_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 5>;
61#[doc = "Field `GCAMEN` reader - General Call Address Match Enable"]
62pub type GCAMEN_R = crate::BitReader<bool>;
63#[doc = "Field `GCAMEN` writer - General Call Address Match Enable"]
64pub type GCAMEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 6>;
65#[doc = "Clock Low High Ratio\n\nValue on reset: 0"]
66#[derive(Clone, Copy, Debug, PartialEq)]
67#[repr(u8)]
68pub enum CLHR_A {
69 #[doc = "0: The ratio between low period and high period counters (Nlow:Nhigh) is 4:4"]
70 STANDARD = 0,
71 #[doc = "1: The ratio between low period and high period counters (Nlow:Nhigh) is 6:3"]
72 ASYMMETRIC = 1,
73 #[doc = "2: The ratio between low period and high period counters (Nlow:Nhigh) is 11:6"]
74 FAST = 2,
75}
76impl From<CLHR_A> for u8 {
77 #[inline(always)]
78 fn from(variant: CLHR_A) -> Self {
79 variant as _
80 }
81}
82#[doc = "Field `CLHR` reader - Clock Low High Ratio"]
83pub type CLHR_R = crate::FieldReader<u8, CLHR_A>;
84impl CLHR_R {
85 #[doc = "Get enumerated values variant"]
86 #[inline(always)]
87 pub fn variant(&self) -> Option<CLHR_A> {
88 match self.bits {
89 0 => Some(CLHR_A::STANDARD),
90 1 => Some(CLHR_A::ASYMMETRIC),
91 2 => Some(CLHR_A::FAST),
92 _ => None,
93 }
94 }
95 #[doc = "Checks if the value of the field is `STANDARD`"]
96 #[inline(always)]
97 pub fn is_standard(&self) -> bool {
98 *self == CLHR_A::STANDARD
99 }
100 #[doc = "Checks if the value of the field is `ASYMMETRIC`"]
101 #[inline(always)]
102 pub fn is_asymmetric(&self) -> bool {
103 *self == CLHR_A::ASYMMETRIC
104 }
105 #[doc = "Checks if the value of the field is `FAST`"]
106 #[inline(always)]
107 pub fn is_fast(&self) -> bool {
108 *self == CLHR_A::FAST
109 }
110}
111#[doc = "Field `CLHR` writer - Clock Low High Ratio"]
112pub type CLHR_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, CLHR_A, 2, 8>;
113impl<'a> CLHR_W<'a> {
114 #[doc = "The ratio between low period and high period counters (Nlow:Nhigh) is 4:4"]
115 #[inline(always)]
116 pub fn standard(self) -> &'a mut W {
117 self.variant(CLHR_A::STANDARD)
118 }
119 #[doc = "The ratio between low period and high period counters (Nlow:Nhigh) is 6:3"]
120 #[inline(always)]
121 pub fn asymmetric(self) -> &'a mut W {
122 self.variant(CLHR_A::ASYMMETRIC)
123 }
124 #[doc = "The ratio between low period and high period counters (Nlow:Nhigh) is 11:6"]
125 #[inline(always)]
126 pub fn fast(self) -> &'a mut W {
127 self.variant(CLHR_A::FAST)
128 }
129}
130#[doc = "Bus Idle Timeout\n\nValue on reset: 0"]
131#[derive(Clone, Copy, Debug, PartialEq)]
132#[repr(u8)]
133pub enum BITO_A {
134 #[doc = "0: Timeout disabled"]
135 OFF = 0,
136 #[doc = "1: Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."]
137 _40PCC = 1,
138 #[doc = "2: Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."]
139 _80PCC = 2,
140 #[doc = "3: Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."]
141 _160PCC = 3,
142}
143impl From<BITO_A> for u8 {
144 #[inline(always)]
145 fn from(variant: BITO_A) -> Self {
146 variant as _
147 }
148}
149#[doc = "Field `BITO` reader - Bus Idle Timeout"]
150pub type BITO_R = crate::FieldReader<u8, BITO_A>;
151impl BITO_R {
152 #[doc = "Get enumerated values variant"]
153 #[inline(always)]
154 pub fn variant(&self) -> BITO_A {
155 match self.bits {
156 0 => BITO_A::OFF,
157 1 => BITO_A::_40PCC,
158 2 => BITO_A::_80PCC,
159 3 => BITO_A::_160PCC,
160 _ => unreachable!(),
161 }
162 }
163 #[doc = "Checks if the value of the field is `OFF`"]
164 #[inline(always)]
165 pub fn is_off(&self) -> bool {
166 *self == BITO_A::OFF
167 }
168 #[doc = "Checks if the value of the field is `_40PCC`"]
169 #[inline(always)]
170 pub fn is_40pcc(&self) -> bool {
171 *self == BITO_A::_40PCC
172 }
173 #[doc = "Checks if the value of the field is `_80PCC`"]
174 #[inline(always)]
175 pub fn is_80pcc(&self) -> bool {
176 *self == BITO_A::_80PCC
177 }
178 #[doc = "Checks if the value of the field is `_160PCC`"]
179 #[inline(always)]
180 pub fn is_160pcc(&self) -> bool {
181 *self == BITO_A::_160PCC
182 }
183}
184#[doc = "Field `BITO` writer - Bus Idle Timeout"]
185pub type BITO_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, BITO_A, 2, 12>;
186impl<'a> BITO_W<'a> {
187 #[doc = "Timeout disabled"]
188 #[inline(always)]
189 pub fn off(self) -> &'a mut W {
190 self.variant(BITO_A::OFF)
191 }
192 #[doc = "Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."]
193 #[inline(always)]
194 pub fn _40pcc(self) -> &'a mut W {
195 self.variant(BITO_A::_40PCC)
196 }
197 #[doc = "Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."]
198 #[inline(always)]
199 pub fn _80pcc(self) -> &'a mut W {
200 self.variant(BITO_A::_80PCC)
201 }
202 #[doc = "Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."]
203 #[inline(always)]
204 pub fn _160pcc(self) -> &'a mut W {
205 self.variant(BITO_A::_160PCC)
206 }
207}
208#[doc = "Field `GIBITO` reader - Go Idle on Bus Idle Timeout"]
209pub type GIBITO_R = crate::BitReader<bool>;
210#[doc = "Field `GIBITO` writer - Go Idle on Bus Idle Timeout"]
211pub type GIBITO_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 15>;
212#[doc = "Clock Low Timeout\n\nValue on reset: 0"]
213#[derive(Clone, Copy, Debug, PartialEq)]
214#[repr(u8)]
215pub enum CLTO_A {
216 #[doc = "0: Timeout disabled"]
217 OFF = 0,
218 #[doc = "1: Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."]
219 _40PCC = 1,
220 #[doc = "2: Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."]
221 _80PCC = 2,
222 #[doc = "3: Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."]
223 _160PCC = 3,
224 #[doc = "4: Timeout after 320 prescaled clock cycles. In standard mode at 100 kHz, this results in a 400us timeout."]
225 _320PPC = 4,
226 #[doc = "5: Timeout after 1024 prescaled clock cycles. In standard mode at 100 kHz, this results in a 1280us timeout."]
227 _1024PPC = 5,
228}
229impl From<CLTO_A> for u8 {
230 #[inline(always)]
231 fn from(variant: CLTO_A) -> Self {
232 variant as _
233 }
234}
235#[doc = "Field `CLTO` reader - Clock Low Timeout"]
236pub type CLTO_R = crate::FieldReader<u8, CLTO_A>;
237impl CLTO_R {
238 #[doc = "Get enumerated values variant"]
239 #[inline(always)]
240 pub fn variant(&self) -> Option<CLTO_A> {
241 match self.bits {
242 0 => Some(CLTO_A::OFF),
243 1 => Some(CLTO_A::_40PCC),
244 2 => Some(CLTO_A::_80PCC),
245 3 => Some(CLTO_A::_160PCC),
246 4 => Some(CLTO_A::_320PPC),
247 5 => Some(CLTO_A::_1024PPC),
248 _ => None,
249 }
250 }
251 #[doc = "Checks if the value of the field is `OFF`"]
252 #[inline(always)]
253 pub fn is_off(&self) -> bool {
254 *self == CLTO_A::OFF
255 }
256 #[doc = "Checks if the value of the field is `_40PCC`"]
257 #[inline(always)]
258 pub fn is_40pcc(&self) -> bool {
259 *self == CLTO_A::_40PCC
260 }
261 #[doc = "Checks if the value of the field is `_80PCC`"]
262 #[inline(always)]
263 pub fn is_80pcc(&self) -> bool {
264 *self == CLTO_A::_80PCC
265 }
266 #[doc = "Checks if the value of the field is `_160PCC`"]
267 #[inline(always)]
268 pub fn is_160pcc(&self) -> bool {
269 *self == CLTO_A::_160PCC
270 }
271 #[doc = "Checks if the value of the field is `_320PPC`"]
272 #[inline(always)]
273 pub fn is_320ppc(&self) -> bool {
274 *self == CLTO_A::_320PPC
275 }
276 #[doc = "Checks if the value of the field is `_1024PPC`"]
277 #[inline(always)]
278 pub fn is_1024ppc(&self) -> bool {
279 *self == CLTO_A::_1024PPC
280 }
281}
282#[doc = "Field `CLTO` writer - Clock Low Timeout"]
283pub type CLTO_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, CLTO_A, 3, 16>;
284impl<'a> CLTO_W<'a> {
285 #[doc = "Timeout disabled"]
286 #[inline(always)]
287 pub fn off(self) -> &'a mut W {
288 self.variant(CLTO_A::OFF)
289 }
290 #[doc = "Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."]
291 #[inline(always)]
292 pub fn _40pcc(self) -> &'a mut W {
293 self.variant(CLTO_A::_40PCC)
294 }
295 #[doc = "Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."]
296 #[inline(always)]
297 pub fn _80pcc(self) -> &'a mut W {
298 self.variant(CLTO_A::_80PCC)
299 }
300 #[doc = "Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."]
301 #[inline(always)]
302 pub fn _160pcc(self) -> &'a mut W {
303 self.variant(CLTO_A::_160PCC)
304 }
305 #[doc = "Timeout after 320 prescaled clock cycles. In standard mode at 100 kHz, this results in a 400us timeout."]
306 #[inline(always)]
307 pub fn _320ppc(self) -> &'a mut W {
308 self.variant(CLTO_A::_320PPC)
309 }
310 #[doc = "Timeout after 1024 prescaled clock cycles. In standard mode at 100 kHz, this results in a 1280us timeout."]
311 #[inline(always)]
312 pub fn _1024ppc(self) -> &'a mut W {
313 self.variant(CLTO_A::_1024PPC)
314 }
315}
316impl R {
317 #[doc = "Bit 0 - I2C Enable"]
318 #[inline(always)]
319 pub fn en(&self) -> EN_R {
320 EN_R::new((self.bits & 1) != 0)
321 }
322 #[doc = "Bit 1 - Addressable as Slave"]
323 #[inline(always)]
324 pub fn slave(&self) -> SLAVE_R {
325 SLAVE_R::new(((self.bits >> 1) & 1) != 0)
326 }
327 #[doc = "Bit 2 - Automatic Acknowledge"]
328 #[inline(always)]
329 pub fn autoack(&self) -> AUTOACK_R {
330 AUTOACK_R::new(((self.bits >> 2) & 1) != 0)
331 }
332 #[doc = "Bit 3 - Automatic STOP when Empty"]
333 #[inline(always)]
334 pub fn autose(&self) -> AUTOSE_R {
335 AUTOSE_R::new(((self.bits >> 3) & 1) != 0)
336 }
337 #[doc = "Bit 4 - Automatic STOP on NACK"]
338 #[inline(always)]
339 pub fn autosn(&self) -> AUTOSN_R {
340 AUTOSN_R::new(((self.bits >> 4) & 1) != 0)
341 }
342 #[doc = "Bit 5 - Arbitration Disable"]
343 #[inline(always)]
344 pub fn arbdis(&self) -> ARBDIS_R {
345 ARBDIS_R::new(((self.bits >> 5) & 1) != 0)
346 }
347 #[doc = "Bit 6 - General Call Address Match Enable"]
348 #[inline(always)]
349 pub fn gcamen(&self) -> GCAMEN_R {
350 GCAMEN_R::new(((self.bits >> 6) & 1) != 0)
351 }
352 #[doc = "Bits 8:9 - Clock Low High Ratio"]
353 #[inline(always)]
354 pub fn clhr(&self) -> CLHR_R {
355 CLHR_R::new(((self.bits >> 8) & 3) as u8)
356 }
357 #[doc = "Bits 12:13 - Bus Idle Timeout"]
358 #[inline(always)]
359 pub fn bito(&self) -> BITO_R {
360 BITO_R::new(((self.bits >> 12) & 3) as u8)
361 }
362 #[doc = "Bit 15 - Go Idle on Bus Idle Timeout"]
363 #[inline(always)]
364 pub fn gibito(&self) -> GIBITO_R {
365 GIBITO_R::new(((self.bits >> 15) & 1) != 0)
366 }
367 #[doc = "Bits 16:18 - Clock Low Timeout"]
368 #[inline(always)]
369 pub fn clto(&self) -> CLTO_R {
370 CLTO_R::new(((self.bits >> 16) & 7) as u8)
371 }
372}
373impl W {
374 #[doc = "Bit 0 - I2C Enable"]
375 #[inline(always)]
376 pub fn en(&mut self) -> EN_W {
377 EN_W::new(self)
378 }
379 #[doc = "Bit 1 - Addressable as Slave"]
380 #[inline(always)]
381 pub fn slave(&mut self) -> SLAVE_W {
382 SLAVE_W::new(self)
383 }
384 #[doc = "Bit 2 - Automatic Acknowledge"]
385 #[inline(always)]
386 pub fn autoack(&mut self) -> AUTOACK_W {
387 AUTOACK_W::new(self)
388 }
389 #[doc = "Bit 3 - Automatic STOP when Empty"]
390 #[inline(always)]
391 pub fn autose(&mut self) -> AUTOSE_W {
392 AUTOSE_W::new(self)
393 }
394 #[doc = "Bit 4 - Automatic STOP on NACK"]
395 #[inline(always)]
396 pub fn autosn(&mut self) -> AUTOSN_W {
397 AUTOSN_W::new(self)
398 }
399 #[doc = "Bit 5 - Arbitration Disable"]
400 #[inline(always)]
401 pub fn arbdis(&mut self) -> ARBDIS_W {
402 ARBDIS_W::new(self)
403 }
404 #[doc = "Bit 6 - General Call Address Match Enable"]
405 #[inline(always)]
406 pub fn gcamen(&mut self) -> GCAMEN_W {
407 GCAMEN_W::new(self)
408 }
409 #[doc = "Bits 8:9 - Clock Low High Ratio"]
410 #[inline(always)]
411 pub fn clhr(&mut self) -> CLHR_W {
412 CLHR_W::new(self)
413 }
414 #[doc = "Bits 12:13 - Bus Idle Timeout"]
415 #[inline(always)]
416 pub fn bito(&mut self) -> BITO_W {
417 BITO_W::new(self)
418 }
419 #[doc = "Bit 15 - Go Idle on Bus Idle Timeout"]
420 #[inline(always)]
421 pub fn gibito(&mut self) -> GIBITO_W {
422 GIBITO_W::new(self)
423 }
424 #[doc = "Bits 16:18 - Clock Low Timeout"]
425 #[inline(always)]
426 pub fn clto(&mut self) -> CLTO_W {
427 CLTO_W::new(self)
428 }
429 #[doc = "Writes raw bits to the register."]
430 #[inline(always)]
431 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
432 self.0.bits(bits);
433 self
434 }
435}
436#[doc = "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 [ctrl](index.html) module"]
437pub struct CTRL_SPEC;
438impl crate::RegisterSpec for CTRL_SPEC {
439 type Ux = u32;
440}
441#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
442impl crate::Readable for CTRL_SPEC {
443 type Reader = R;
444}
445#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
446impl crate::Writable for CTRL_SPEC {
447 type Writer = W;
448}
449#[doc = "`reset()` method sets CTRL to value 0"]
450impl crate::Resettable for CTRL_SPEC {
451 #[inline(always)]
452 fn reset_value() -> Self::Ux {
453 0
454 }
455}