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