efm32gg_pac/efm32gg995/i2c1/
ctrl.rs

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, 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 `CLHR` reader - Clock Low High Ratio"]
66pub type CLHR_R = crate::FieldReader<u8, CLHR_A>;
67#[doc = "Clock Low High Ratio\n\nValue on reset: 0"]
68#[derive(Clone, Copy, Debug, PartialEq, Eq)]
69#[repr(u8)]
70pub enum CLHR_A {
71    #[doc = "0: The ratio between low period and high period counters (Nlow:Nhigh) is 4:4"]
72    STANDARD = 0,
73    #[doc = "1: The ratio between low period and high period counters (Nlow:Nhigh) is 6:3"]
74    ASYMMETRIC = 1,
75    #[doc = "2: The ratio between low period and high period counters (Nlow:Nhigh) is 11:6"]
76    FAST = 2,
77}
78impl From<CLHR_A> for u8 {
79    #[inline(always)]
80    fn from(variant: CLHR_A) -> Self {
81        variant as _
82    }
83}
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, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, CLHR_A, 2, O>;
113impl<'a, const O: u8> CLHR_W<'a, O> {
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 = "Field `BITO` reader - Bus Idle Timeout"]
131pub type BITO_R = crate::FieldReader<u8, BITO_A>;
132#[doc = "Bus Idle Timeout\n\nValue on reset: 0"]
133#[derive(Clone, Copy, Debug, PartialEq, Eq)]
134#[repr(u8)]
135pub enum BITO_A {
136    #[doc = "0: Timeout disabled"]
137    OFF = 0,
138    #[doc = "1: Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."]
139    _40PCC = 1,
140    #[doc = "2: Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."]
141    _80PCC = 2,
142    #[doc = "3: Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."]
143    _160PCC = 3,
144}
145impl From<BITO_A> for u8 {
146    #[inline(always)]
147    fn from(variant: BITO_A) -> Self {
148        variant as _
149    }
150}
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, const O: u8> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, BITO_A, 2, O>;
186impl<'a, const O: u8> BITO_W<'a, O> {
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
212#[doc = "Field `CLTO` reader - Clock Low Timeout"]
213pub type CLTO_R = crate::FieldReader<u8, CLTO_A>;
214#[doc = "Clock Low Timeout\n\nValue on reset: 0"]
215#[derive(Clone, Copy, Debug, PartialEq, Eq)]
216#[repr(u8)]
217pub enum CLTO_A {
218    #[doc = "0: Timeout disabled"]
219    OFF = 0,
220    #[doc = "1: Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."]
221    _40PCC = 1,
222    #[doc = "2: Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."]
223    _80PCC = 2,
224    #[doc = "3: Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."]
225    _160PCC = 3,
226    #[doc = "4: Timeout after 320 prescaled clock cycles. In standard mode at 100 kHz, this results in a 400us timeout."]
227    _320PPC = 4,
228    #[doc = "5: Timeout after 1024 prescaled clock cycles. In standard mode at 100 kHz, this results in a 1280us timeout."]
229    _1024PPC = 5,
230}
231impl From<CLTO_A> for u8 {
232    #[inline(always)]
233    fn from(variant: CLTO_A) -> Self {
234        variant as _
235    }
236}
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, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, CLTO_A, 3, O>;
284impl<'a, const O: u8> CLTO_W<'a, O> {
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    #[must_use]
377    pub fn en(&mut self) -> EN_W<0> {
378        EN_W::new(self)
379    }
380    #[doc = "Bit 1 - Addressable as Slave"]
381    #[inline(always)]
382    #[must_use]
383    pub fn slave(&mut self) -> SLAVE_W<1> {
384        SLAVE_W::new(self)
385    }
386    #[doc = "Bit 2 - Automatic Acknowledge"]
387    #[inline(always)]
388    #[must_use]
389    pub fn autoack(&mut self) -> AUTOACK_W<2> {
390        AUTOACK_W::new(self)
391    }
392    #[doc = "Bit 3 - Automatic STOP when Empty"]
393    #[inline(always)]
394    #[must_use]
395    pub fn autose(&mut self) -> AUTOSE_W<3> {
396        AUTOSE_W::new(self)
397    }
398    #[doc = "Bit 4 - Automatic STOP on NACK"]
399    #[inline(always)]
400    #[must_use]
401    pub fn autosn(&mut self) -> AUTOSN_W<4> {
402        AUTOSN_W::new(self)
403    }
404    #[doc = "Bit 5 - Arbitration Disable"]
405    #[inline(always)]
406    #[must_use]
407    pub fn arbdis(&mut self) -> ARBDIS_W<5> {
408        ARBDIS_W::new(self)
409    }
410    #[doc = "Bit 6 - General Call Address Match Enable"]
411    #[inline(always)]
412    #[must_use]
413    pub fn gcamen(&mut self) -> GCAMEN_W<6> {
414        GCAMEN_W::new(self)
415    }
416    #[doc = "Bits 8:9 - Clock Low High Ratio"]
417    #[inline(always)]
418    #[must_use]
419    pub fn clhr(&mut self) -> CLHR_W<8> {
420        CLHR_W::new(self)
421    }
422    #[doc = "Bits 12:13 - Bus Idle Timeout"]
423    #[inline(always)]
424    #[must_use]
425    pub fn bito(&mut self) -> BITO_W<12> {
426        BITO_W::new(self)
427    }
428    #[doc = "Bit 15 - Go Idle on Bus Idle Timeout"]
429    #[inline(always)]
430    #[must_use]
431    pub fn gibito(&mut self) -> GIBITO_W<15> {
432        GIBITO_W::new(self)
433    }
434    #[doc = "Bits 16:18 - Clock Low Timeout"]
435    #[inline(always)]
436    #[must_use]
437    pub fn clto(&mut self) -> CLTO_W<16> {
438        CLTO_W::new(self)
439    }
440    #[doc = "Writes raw bits to the register."]
441    #[inline(always)]
442    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
443        self.0.bits(bits);
444        self
445    }
446}
447#[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"]
448pub struct CTRL_SPEC;
449impl crate::RegisterSpec for CTRL_SPEC {
450    type Ux = u32;
451}
452#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
453impl crate::Readable for CTRL_SPEC {
454    type Reader = R;
455}
456#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
457impl crate::Writable for CTRL_SPEC {
458    type Writer = W;
459    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
460    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
461}
462#[doc = "`reset()` method sets CTRL to value 0"]
463impl crate::Resettable for CTRL_SPEC {
464    const RESET_VALUE: Self::Ux = 0;
465}