mk66f18/i2c2/
flt.rs

1#[doc = "Reader of register FLT"]
2pub type R = crate::R<u8, super::FLT>;
3#[doc = "Writer for register FLT"]
4pub type W = crate::W<u8, super::FLT>;
5#[doc = "Register FLT `reset()`'s with value 0"]
6impl crate::ResetValue for super::FLT {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "I2C Programmable Filter Factor\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum FLT_A {
16    #[doc = "0: No filter/bypass"]
17    _0,
18}
19impl From<FLT_A> for u8 {
20    #[inline(always)]
21    fn from(variant: FLT_A) -> Self {
22        match variant {
23            FLT_A::_0 => 0,
24        }
25    }
26}
27#[doc = "Reader of field `FLT`"]
28pub type FLT_R = crate::R<u8, FLT_A>;
29impl FLT_R {
30    #[doc = r"Get enumerated values variant"]
31    #[inline(always)]
32    pub fn variant(&self) -> crate::Variant<u8, FLT_A> {
33        use crate::Variant::*;
34        match self.bits {
35            0 => Val(FLT_A::_0),
36            i => Res(i),
37        }
38    }
39    #[doc = "Checks if the value of the field is `_0`"]
40    #[inline(always)]
41    pub fn is_0(&self) -> bool {
42        *self == FLT_A::_0
43    }
44}
45#[doc = "Write proxy for field `FLT`"]
46pub struct FLT_W<'a> {
47    w: &'a mut W,
48}
49impl<'a> FLT_W<'a> {
50    #[doc = r"Writes `variant` to the field"]
51    #[inline(always)]
52    pub fn variant(self, variant: FLT_A) -> &'a mut W {
53        unsafe { self.bits(variant.into()) }
54    }
55    #[doc = "No filter/bypass"]
56    #[inline(always)]
57    pub fn _0(self) -> &'a mut W {
58        self.variant(FLT_A::_0)
59    }
60    #[doc = r"Writes raw bits to the field"]
61    #[inline(always)]
62    pub unsafe fn bits(self, value: u8) -> &'a mut W {
63        self.w.bits = (self.w.bits & !0x0f) | ((value as u8) & 0x0f);
64        self.w
65    }
66}
67#[doc = "I2C Bus Start Detect Flag\n\nValue on reset: 0"]
68#[derive(Clone, Copy, Debug, PartialEq)]
69pub enum STARTF_A {
70    #[doc = "0: No start happens on I2C bus"]
71    _0,
72    #[doc = "1: Start detected on I2C bus"]
73    _1,
74}
75impl From<STARTF_A> for bool {
76    #[inline(always)]
77    fn from(variant: STARTF_A) -> Self {
78        match variant {
79            STARTF_A::_0 => false,
80            STARTF_A::_1 => true,
81        }
82    }
83}
84#[doc = "Reader of field `STARTF`"]
85pub type STARTF_R = crate::R<bool, STARTF_A>;
86impl STARTF_R {
87    #[doc = r"Get enumerated values variant"]
88    #[inline(always)]
89    pub fn variant(&self) -> STARTF_A {
90        match self.bits {
91            false => STARTF_A::_0,
92            true => STARTF_A::_1,
93        }
94    }
95    #[doc = "Checks if the value of the field is `_0`"]
96    #[inline(always)]
97    pub fn is_0(&self) -> bool {
98        *self == STARTF_A::_0
99    }
100    #[doc = "Checks if the value of the field is `_1`"]
101    #[inline(always)]
102    pub fn is_1(&self) -> bool {
103        *self == STARTF_A::_1
104    }
105}
106#[doc = "Write proxy for field `STARTF`"]
107pub struct STARTF_W<'a> {
108    w: &'a mut W,
109}
110impl<'a> STARTF_W<'a> {
111    #[doc = r"Writes `variant` to the field"]
112    #[inline(always)]
113    pub fn variant(self, variant: STARTF_A) -> &'a mut W {
114        {
115            self.bit(variant.into())
116        }
117    }
118    #[doc = "No start happens on I2C bus"]
119    #[inline(always)]
120    pub fn _0(self) -> &'a mut W {
121        self.variant(STARTF_A::_0)
122    }
123    #[doc = "Start detected on I2C bus"]
124    #[inline(always)]
125    pub fn _1(self) -> &'a mut W {
126        self.variant(STARTF_A::_1)
127    }
128    #[doc = r"Sets the field bit"]
129    #[inline(always)]
130    pub fn set_bit(self) -> &'a mut W {
131        self.bit(true)
132    }
133    #[doc = r"Clears the field bit"]
134    #[inline(always)]
135    pub fn clear_bit(self) -> &'a mut W {
136        self.bit(false)
137    }
138    #[doc = r"Writes raw bits to the field"]
139    #[inline(always)]
140    pub fn bit(self, value: bool) -> &'a mut W {
141        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u8) & 0x01) << 4);
142        self.w
143    }
144}
145#[doc = "I2C Bus Stop or Start Interrupt Enable\n\nValue on reset: 0"]
146#[derive(Clone, Copy, Debug, PartialEq)]
147pub enum SSIE_A {
148    #[doc = "0: Stop or start detection interrupt is disabled"]
149    _0,
150    #[doc = "1: Stop or start detection interrupt is enabled"]
151    _1,
152}
153impl From<SSIE_A> for bool {
154    #[inline(always)]
155    fn from(variant: SSIE_A) -> Self {
156        match variant {
157            SSIE_A::_0 => false,
158            SSIE_A::_1 => true,
159        }
160    }
161}
162#[doc = "Reader of field `SSIE`"]
163pub type SSIE_R = crate::R<bool, SSIE_A>;
164impl SSIE_R {
165    #[doc = r"Get enumerated values variant"]
166    #[inline(always)]
167    pub fn variant(&self) -> SSIE_A {
168        match self.bits {
169            false => SSIE_A::_0,
170            true => SSIE_A::_1,
171        }
172    }
173    #[doc = "Checks if the value of the field is `_0`"]
174    #[inline(always)]
175    pub fn is_0(&self) -> bool {
176        *self == SSIE_A::_0
177    }
178    #[doc = "Checks if the value of the field is `_1`"]
179    #[inline(always)]
180    pub fn is_1(&self) -> bool {
181        *self == SSIE_A::_1
182    }
183}
184#[doc = "Write proxy for field `SSIE`"]
185pub struct SSIE_W<'a> {
186    w: &'a mut W,
187}
188impl<'a> SSIE_W<'a> {
189    #[doc = r"Writes `variant` to the field"]
190    #[inline(always)]
191    pub fn variant(self, variant: SSIE_A) -> &'a mut W {
192        {
193            self.bit(variant.into())
194        }
195    }
196    #[doc = "Stop or start detection interrupt is disabled"]
197    #[inline(always)]
198    pub fn _0(self) -> &'a mut W {
199        self.variant(SSIE_A::_0)
200    }
201    #[doc = "Stop or start detection interrupt is enabled"]
202    #[inline(always)]
203    pub fn _1(self) -> &'a mut W {
204        self.variant(SSIE_A::_1)
205    }
206    #[doc = r"Sets the field bit"]
207    #[inline(always)]
208    pub fn set_bit(self) -> &'a mut W {
209        self.bit(true)
210    }
211    #[doc = r"Clears the field bit"]
212    #[inline(always)]
213    pub fn clear_bit(self) -> &'a mut W {
214        self.bit(false)
215    }
216    #[doc = r"Writes raw bits to the field"]
217    #[inline(always)]
218    pub fn bit(self, value: bool) -> &'a mut W {
219        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u8) & 0x01) << 5);
220        self.w
221    }
222}
223#[doc = "I2C Bus Stop Detect Flag\n\nValue on reset: 0"]
224#[derive(Clone, Copy, Debug, PartialEq)]
225pub enum STOPF_A {
226    #[doc = "0: No stop happens on I2C bus"]
227    _0,
228    #[doc = "1: Stop detected on I2C bus"]
229    _1,
230}
231impl From<STOPF_A> for bool {
232    #[inline(always)]
233    fn from(variant: STOPF_A) -> Self {
234        match variant {
235            STOPF_A::_0 => false,
236            STOPF_A::_1 => true,
237        }
238    }
239}
240#[doc = "Reader of field `STOPF`"]
241pub type STOPF_R = crate::R<bool, STOPF_A>;
242impl STOPF_R {
243    #[doc = r"Get enumerated values variant"]
244    #[inline(always)]
245    pub fn variant(&self) -> STOPF_A {
246        match self.bits {
247            false => STOPF_A::_0,
248            true => STOPF_A::_1,
249        }
250    }
251    #[doc = "Checks if the value of the field is `_0`"]
252    #[inline(always)]
253    pub fn is_0(&self) -> bool {
254        *self == STOPF_A::_0
255    }
256    #[doc = "Checks if the value of the field is `_1`"]
257    #[inline(always)]
258    pub fn is_1(&self) -> bool {
259        *self == STOPF_A::_1
260    }
261}
262#[doc = "Write proxy for field `STOPF`"]
263pub struct STOPF_W<'a> {
264    w: &'a mut W,
265}
266impl<'a> STOPF_W<'a> {
267    #[doc = r"Writes `variant` to the field"]
268    #[inline(always)]
269    pub fn variant(self, variant: STOPF_A) -> &'a mut W {
270        {
271            self.bit(variant.into())
272        }
273    }
274    #[doc = "No stop happens on I2C bus"]
275    #[inline(always)]
276    pub fn _0(self) -> &'a mut W {
277        self.variant(STOPF_A::_0)
278    }
279    #[doc = "Stop detected on I2C bus"]
280    #[inline(always)]
281    pub fn _1(self) -> &'a mut W {
282        self.variant(STOPF_A::_1)
283    }
284    #[doc = r"Sets the field bit"]
285    #[inline(always)]
286    pub fn set_bit(self) -> &'a mut W {
287        self.bit(true)
288    }
289    #[doc = r"Clears the field bit"]
290    #[inline(always)]
291    pub fn clear_bit(self) -> &'a mut W {
292        self.bit(false)
293    }
294    #[doc = r"Writes raw bits to the field"]
295    #[inline(always)]
296    pub fn bit(self, value: bool) -> &'a mut W {
297        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u8) & 0x01) << 6);
298        self.w
299    }
300}
301#[doc = "Stop Hold Enable\n\nValue on reset: 0"]
302#[derive(Clone, Copy, Debug, PartialEq)]
303pub enum SHEN_A {
304    #[doc = "0: Stop holdoff is disabled. The MCU's entry to stop mode is not gated."]
305    _0,
306    #[doc = "1: Stop holdoff is enabled."]
307    _1,
308}
309impl From<SHEN_A> for bool {
310    #[inline(always)]
311    fn from(variant: SHEN_A) -> Self {
312        match variant {
313            SHEN_A::_0 => false,
314            SHEN_A::_1 => true,
315        }
316    }
317}
318#[doc = "Reader of field `SHEN`"]
319pub type SHEN_R = crate::R<bool, SHEN_A>;
320impl SHEN_R {
321    #[doc = r"Get enumerated values variant"]
322    #[inline(always)]
323    pub fn variant(&self) -> SHEN_A {
324        match self.bits {
325            false => SHEN_A::_0,
326            true => SHEN_A::_1,
327        }
328    }
329    #[doc = "Checks if the value of the field is `_0`"]
330    #[inline(always)]
331    pub fn is_0(&self) -> bool {
332        *self == SHEN_A::_0
333    }
334    #[doc = "Checks if the value of the field is `_1`"]
335    #[inline(always)]
336    pub fn is_1(&self) -> bool {
337        *self == SHEN_A::_1
338    }
339}
340#[doc = "Write proxy for field `SHEN`"]
341pub struct SHEN_W<'a> {
342    w: &'a mut W,
343}
344impl<'a> SHEN_W<'a> {
345    #[doc = r"Writes `variant` to the field"]
346    #[inline(always)]
347    pub fn variant(self, variant: SHEN_A) -> &'a mut W {
348        {
349            self.bit(variant.into())
350        }
351    }
352    #[doc = "Stop holdoff is disabled. The MCU's entry to stop mode is not gated."]
353    #[inline(always)]
354    pub fn _0(self) -> &'a mut W {
355        self.variant(SHEN_A::_0)
356    }
357    #[doc = "Stop holdoff is enabled."]
358    #[inline(always)]
359    pub fn _1(self) -> &'a mut W {
360        self.variant(SHEN_A::_1)
361    }
362    #[doc = r"Sets the field bit"]
363    #[inline(always)]
364    pub fn set_bit(self) -> &'a mut W {
365        self.bit(true)
366    }
367    #[doc = r"Clears the field bit"]
368    #[inline(always)]
369    pub fn clear_bit(self) -> &'a mut W {
370        self.bit(false)
371    }
372    #[doc = r"Writes raw bits to the field"]
373    #[inline(always)]
374    pub fn bit(self, value: bool) -> &'a mut W {
375        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u8) & 0x01) << 7);
376        self.w
377    }
378}
379impl R {
380    #[doc = "Bits 0:3 - I2C Programmable Filter Factor"]
381    #[inline(always)]
382    pub fn flt(&self) -> FLT_R {
383        FLT_R::new((self.bits & 0x0f) as u8)
384    }
385    #[doc = "Bit 4 - I2C Bus Start Detect Flag"]
386    #[inline(always)]
387    pub fn startf(&self) -> STARTF_R {
388        STARTF_R::new(((self.bits >> 4) & 0x01) != 0)
389    }
390    #[doc = "Bit 5 - I2C Bus Stop or Start Interrupt Enable"]
391    #[inline(always)]
392    pub fn ssie(&self) -> SSIE_R {
393        SSIE_R::new(((self.bits >> 5) & 0x01) != 0)
394    }
395    #[doc = "Bit 6 - I2C Bus Stop Detect Flag"]
396    #[inline(always)]
397    pub fn stopf(&self) -> STOPF_R {
398        STOPF_R::new(((self.bits >> 6) & 0x01) != 0)
399    }
400    #[doc = "Bit 7 - Stop Hold Enable"]
401    #[inline(always)]
402    pub fn shen(&self) -> SHEN_R {
403        SHEN_R::new(((self.bits >> 7) & 0x01) != 0)
404    }
405}
406impl W {
407    #[doc = "Bits 0:3 - I2C Programmable Filter Factor"]
408    #[inline(always)]
409    pub fn flt(&mut self) -> FLT_W {
410        FLT_W { w: self }
411    }
412    #[doc = "Bit 4 - I2C Bus Start Detect Flag"]
413    #[inline(always)]
414    pub fn startf(&mut self) -> STARTF_W {
415        STARTF_W { w: self }
416    }
417    #[doc = "Bit 5 - I2C Bus Stop or Start Interrupt Enable"]
418    #[inline(always)]
419    pub fn ssie(&mut self) -> SSIE_W {
420        SSIE_W { w: self }
421    }
422    #[doc = "Bit 6 - I2C Bus Stop Detect Flag"]
423    #[inline(always)]
424    pub fn stopf(&mut self) -> STOPF_W {
425        STOPF_W { w: self }
426    }
427    #[doc = "Bit 7 - Stop Hold Enable"]
428    #[inline(always)]
429    pub fn shen(&mut self) -> SHEN_W {
430        SHEN_W { w: self }
431    }
432}