ra4m1/iic0/
icmr1.rs

1#[doc = "Register `ICMR1` reader"]
2pub struct R(crate::R<ICMR1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ICMR1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ICMR1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ICMR1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ICMR1` writer"]
17pub struct W(crate::W<ICMR1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ICMR1_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<ICMR1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ICMR1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `BC` reader - Bit Counter"]
38pub type BC_R = crate::FieldReader<u8, BC_A>;
39#[doc = "Bit Counter\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum BC_A {
43    #[doc = "0: 9 bits"]
44    _000 = 0,
45    #[doc = "1: 2 bits"]
46    _001 = 1,
47    #[doc = "2: 3 bits"]
48    _010 = 2,
49    #[doc = "3: 4 bits"]
50    _011 = 3,
51    #[doc = "4: 5 bits"]
52    _100 = 4,
53    #[doc = "5: 6 bits"]
54    _101 = 5,
55    #[doc = "6: 7 bits"]
56    _110 = 6,
57    #[doc = "7: 8 bits"]
58    _111 = 7,
59}
60impl From<BC_A> for u8 {
61    #[inline(always)]
62    fn from(variant: BC_A) -> Self {
63        variant as _
64    }
65}
66impl BC_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> BC_A {
70        match self.bits {
71            0 => BC_A::_000,
72            1 => BC_A::_001,
73            2 => BC_A::_010,
74            3 => BC_A::_011,
75            4 => BC_A::_100,
76            5 => BC_A::_101,
77            6 => BC_A::_110,
78            7 => BC_A::_111,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `_000`"]
83    #[inline(always)]
84    pub fn is_000(&self) -> bool {
85        *self == BC_A::_000
86    }
87    #[doc = "Checks if the value of the field is `_001`"]
88    #[inline(always)]
89    pub fn is_001(&self) -> bool {
90        *self == BC_A::_001
91    }
92    #[doc = "Checks if the value of the field is `_010`"]
93    #[inline(always)]
94    pub fn is_010(&self) -> bool {
95        *self == BC_A::_010
96    }
97    #[doc = "Checks if the value of the field is `_011`"]
98    #[inline(always)]
99    pub fn is_011(&self) -> bool {
100        *self == BC_A::_011
101    }
102    #[doc = "Checks if the value of the field is `_100`"]
103    #[inline(always)]
104    pub fn is_100(&self) -> bool {
105        *self == BC_A::_100
106    }
107    #[doc = "Checks if the value of the field is `_101`"]
108    #[inline(always)]
109    pub fn is_101(&self) -> bool {
110        *self == BC_A::_101
111    }
112    #[doc = "Checks if the value of the field is `_110`"]
113    #[inline(always)]
114    pub fn is_110(&self) -> bool {
115        *self == BC_A::_110
116    }
117    #[doc = "Checks if the value of the field is `_111`"]
118    #[inline(always)]
119    pub fn is_111(&self) -> bool {
120        *self == BC_A::_111
121    }
122}
123#[doc = "Field `BC` writer - Bit Counter"]
124pub type BC_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, ICMR1_SPEC, u8, BC_A, 3, O>;
125impl<'a, const O: u8> BC_W<'a, O> {
126    #[doc = "9 bits"]
127    #[inline(always)]
128    pub fn _000(self) -> &'a mut W {
129        self.variant(BC_A::_000)
130    }
131    #[doc = "2 bits"]
132    #[inline(always)]
133    pub fn _001(self) -> &'a mut W {
134        self.variant(BC_A::_001)
135    }
136    #[doc = "3 bits"]
137    #[inline(always)]
138    pub fn _010(self) -> &'a mut W {
139        self.variant(BC_A::_010)
140    }
141    #[doc = "4 bits"]
142    #[inline(always)]
143    pub fn _011(self) -> &'a mut W {
144        self.variant(BC_A::_011)
145    }
146    #[doc = "5 bits"]
147    #[inline(always)]
148    pub fn _100(self) -> &'a mut W {
149        self.variant(BC_A::_100)
150    }
151    #[doc = "6 bits"]
152    #[inline(always)]
153    pub fn _101(self) -> &'a mut W {
154        self.variant(BC_A::_101)
155    }
156    #[doc = "7 bits"]
157    #[inline(always)]
158    pub fn _110(self) -> &'a mut W {
159        self.variant(BC_A::_110)
160    }
161    #[doc = "8 bits"]
162    #[inline(always)]
163    pub fn _111(self) -> &'a mut W {
164        self.variant(BC_A::_111)
165    }
166}
167#[doc = "BC Write Protect (This bit is read as 1.)\n\nValue on reset: 1"]
168#[derive(Clone, Copy, Debug, PartialEq, Eq)]
169pub enum BCWP_AW {
170    #[doc = "0: Enables a value to be written in the BC\\[2:0\\]
171bits."]
172    _0 = 0,
173    #[doc = "1: Disables a value to be written in the BC\\[2:0\\]
174bits."]
175    _1 = 1,
176}
177impl From<BCWP_AW> for bool {
178    #[inline(always)]
179    fn from(variant: BCWP_AW) -> Self {
180        variant as u8 != 0
181    }
182}
183#[doc = "Field `BCWP` writer - BC Write Protect (This bit is read as 1.)"]
184pub type BCWP_W<'a, const O: u8> = crate::BitWriter<'a, u8, ICMR1_SPEC, BCWP_AW, O>;
185impl<'a, const O: u8> BCWP_W<'a, O> {
186    #[doc = "Enables a value to be written in the BC\\[2:0\\]
187bits."]
188    #[inline(always)]
189    pub fn _0(self) -> &'a mut W {
190        self.variant(BCWP_AW::_0)
191    }
192    #[doc = "Disables a value to be written in the BC\\[2:0\\]
193bits."]
194    #[inline(always)]
195    pub fn _1(self) -> &'a mut W {
196        self.variant(BCWP_AW::_1)
197    }
198}
199#[doc = "Field `CKS` reader - Internal Reference Clock (fIIC) Selection ( fIIC = PCLKB / 2^CKS )"]
200pub type CKS_R = crate::FieldReader<u8, CKS_A>;
201#[doc = "Internal Reference Clock (fIIC) Selection ( fIIC = PCLKB / 2^CKS )\n\nValue on reset: 0"]
202#[derive(Clone, Copy, Debug, PartialEq, Eq)]
203#[repr(u8)]
204pub enum CKS_A {
205    #[doc = "0: PCLKB/1 clock"]
206    _000 = 0,
207    #[doc = "1: PCLKB/2 clock"]
208    _001 = 1,
209    #[doc = "2: PCLKB/4 clock"]
210    _010 = 2,
211    #[doc = "3: PCLKB/8 clock"]
212    _011 = 3,
213    #[doc = "4: PCLKB/16 clock"]
214    _100 = 4,
215    #[doc = "5: PCLKB/32 clock"]
216    _101 = 5,
217    #[doc = "6: PCLKB/64 clock"]
218    _110 = 6,
219    #[doc = "7: PCLKB/128 clock"]
220    _111 = 7,
221}
222impl From<CKS_A> for u8 {
223    #[inline(always)]
224    fn from(variant: CKS_A) -> Self {
225        variant as _
226    }
227}
228impl CKS_R {
229    #[doc = "Get enumerated values variant"]
230    #[inline(always)]
231    pub fn variant(&self) -> CKS_A {
232        match self.bits {
233            0 => CKS_A::_000,
234            1 => CKS_A::_001,
235            2 => CKS_A::_010,
236            3 => CKS_A::_011,
237            4 => CKS_A::_100,
238            5 => CKS_A::_101,
239            6 => CKS_A::_110,
240            7 => CKS_A::_111,
241            _ => unreachable!(),
242        }
243    }
244    #[doc = "Checks if the value of the field is `_000`"]
245    #[inline(always)]
246    pub fn is_000(&self) -> bool {
247        *self == CKS_A::_000
248    }
249    #[doc = "Checks if the value of the field is `_001`"]
250    #[inline(always)]
251    pub fn is_001(&self) -> bool {
252        *self == CKS_A::_001
253    }
254    #[doc = "Checks if the value of the field is `_010`"]
255    #[inline(always)]
256    pub fn is_010(&self) -> bool {
257        *self == CKS_A::_010
258    }
259    #[doc = "Checks if the value of the field is `_011`"]
260    #[inline(always)]
261    pub fn is_011(&self) -> bool {
262        *self == CKS_A::_011
263    }
264    #[doc = "Checks if the value of the field is `_100`"]
265    #[inline(always)]
266    pub fn is_100(&self) -> bool {
267        *self == CKS_A::_100
268    }
269    #[doc = "Checks if the value of the field is `_101`"]
270    #[inline(always)]
271    pub fn is_101(&self) -> bool {
272        *self == CKS_A::_101
273    }
274    #[doc = "Checks if the value of the field is `_110`"]
275    #[inline(always)]
276    pub fn is_110(&self) -> bool {
277        *self == CKS_A::_110
278    }
279    #[doc = "Checks if the value of the field is `_111`"]
280    #[inline(always)]
281    pub fn is_111(&self) -> bool {
282        *self == CKS_A::_111
283    }
284}
285#[doc = "Field `CKS` writer - Internal Reference Clock (fIIC) Selection ( fIIC = PCLKB / 2^CKS )"]
286pub type CKS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, ICMR1_SPEC, u8, CKS_A, 3, O>;
287impl<'a, const O: u8> CKS_W<'a, O> {
288    #[doc = "PCLKB/1 clock"]
289    #[inline(always)]
290    pub fn _000(self) -> &'a mut W {
291        self.variant(CKS_A::_000)
292    }
293    #[doc = "PCLKB/2 clock"]
294    #[inline(always)]
295    pub fn _001(self) -> &'a mut W {
296        self.variant(CKS_A::_001)
297    }
298    #[doc = "PCLKB/4 clock"]
299    #[inline(always)]
300    pub fn _010(self) -> &'a mut W {
301        self.variant(CKS_A::_010)
302    }
303    #[doc = "PCLKB/8 clock"]
304    #[inline(always)]
305    pub fn _011(self) -> &'a mut W {
306        self.variant(CKS_A::_011)
307    }
308    #[doc = "PCLKB/16 clock"]
309    #[inline(always)]
310    pub fn _100(self) -> &'a mut W {
311        self.variant(CKS_A::_100)
312    }
313    #[doc = "PCLKB/32 clock"]
314    #[inline(always)]
315    pub fn _101(self) -> &'a mut W {
316        self.variant(CKS_A::_101)
317    }
318    #[doc = "PCLKB/64 clock"]
319    #[inline(always)]
320    pub fn _110(self) -> &'a mut W {
321        self.variant(CKS_A::_110)
322    }
323    #[doc = "PCLKB/128 clock"]
324    #[inline(always)]
325    pub fn _111(self) -> &'a mut W {
326        self.variant(CKS_A::_111)
327    }
328}
329#[doc = "Field `MTWP` reader - MST/TRS Write Protect"]
330pub type MTWP_R = crate::BitReader<MTWP_A>;
331#[doc = "MST/TRS Write Protect\n\nValue on reset: 0"]
332#[derive(Clone, Copy, Debug, PartialEq, Eq)]
333pub enum MTWP_A {
334    #[doc = "0: Disables writing to the MST and TRS bits in ICCR2."]
335    _0 = 0,
336    #[doc = "1: Enables writing to the MST and TRS bits in ICCR2."]
337    _1 = 1,
338}
339impl From<MTWP_A> for bool {
340    #[inline(always)]
341    fn from(variant: MTWP_A) -> Self {
342        variant as u8 != 0
343    }
344}
345impl MTWP_R {
346    #[doc = "Get enumerated values variant"]
347    #[inline(always)]
348    pub fn variant(&self) -> MTWP_A {
349        match self.bits {
350            false => MTWP_A::_0,
351            true => MTWP_A::_1,
352        }
353    }
354    #[doc = "Checks if the value of the field is `_0`"]
355    #[inline(always)]
356    pub fn is_0(&self) -> bool {
357        *self == MTWP_A::_0
358    }
359    #[doc = "Checks if the value of the field is `_1`"]
360    #[inline(always)]
361    pub fn is_1(&self) -> bool {
362        *self == MTWP_A::_1
363    }
364}
365#[doc = "Field `MTWP` writer - MST/TRS Write Protect"]
366pub type MTWP_W<'a, const O: u8> = crate::BitWriter<'a, u8, ICMR1_SPEC, MTWP_A, O>;
367impl<'a, const O: u8> MTWP_W<'a, O> {
368    #[doc = "Disables writing to the MST and TRS bits in ICCR2."]
369    #[inline(always)]
370    pub fn _0(self) -> &'a mut W {
371        self.variant(MTWP_A::_0)
372    }
373    #[doc = "Enables writing to the MST and TRS bits in ICCR2."]
374    #[inline(always)]
375    pub fn _1(self) -> &'a mut W {
376        self.variant(MTWP_A::_1)
377    }
378}
379impl R {
380    #[doc = "Bits 0:2 - Bit Counter"]
381    #[inline(always)]
382    pub fn bc(&self) -> BC_R {
383        BC_R::new(self.bits & 7)
384    }
385    #[doc = "Bits 4:6 - Internal Reference Clock (fIIC) Selection ( fIIC = PCLKB / 2^CKS )"]
386    #[inline(always)]
387    pub fn cks(&self) -> CKS_R {
388        CKS_R::new((self.bits >> 4) & 7)
389    }
390    #[doc = "Bit 7 - MST/TRS Write Protect"]
391    #[inline(always)]
392    pub fn mtwp(&self) -> MTWP_R {
393        MTWP_R::new(((self.bits >> 7) & 1) != 0)
394    }
395}
396impl W {
397    #[doc = "Bits 0:2 - Bit Counter"]
398    #[inline(always)]
399    #[must_use]
400    pub fn bc(&mut self) -> BC_W<0> {
401        BC_W::new(self)
402    }
403    #[doc = "Bit 3 - BC Write Protect (This bit is read as 1.)"]
404    #[inline(always)]
405    #[must_use]
406    pub fn bcwp(&mut self) -> BCWP_W<3> {
407        BCWP_W::new(self)
408    }
409    #[doc = "Bits 4:6 - Internal Reference Clock (fIIC) Selection ( fIIC = PCLKB / 2^CKS )"]
410    #[inline(always)]
411    #[must_use]
412    pub fn cks(&mut self) -> CKS_W<4> {
413        CKS_W::new(self)
414    }
415    #[doc = "Bit 7 - MST/TRS Write Protect"]
416    #[inline(always)]
417    #[must_use]
418    pub fn mtwp(&mut self) -> MTWP_W<7> {
419        MTWP_W::new(self)
420    }
421    #[doc = "Writes raw bits to the register."]
422    #[inline(always)]
423    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
424        self.0.bits(bits);
425        self
426    }
427}
428#[doc = "I2C Bus Mode Register 1\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 [icmr1](index.html) module"]
429pub struct ICMR1_SPEC;
430impl crate::RegisterSpec for ICMR1_SPEC {
431    type Ux = u8;
432}
433#[doc = "`read()` method returns [icmr1::R](R) reader structure"]
434impl crate::Readable for ICMR1_SPEC {
435    type Reader = R;
436}
437#[doc = "`write(|w| ..)` method takes [icmr1::W](W) writer structure"]
438impl crate::Writable for ICMR1_SPEC {
439    type Writer = W;
440    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
441    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
442}
443#[doc = "`reset()` method sets ICMR1 to value 0x08"]
444impl crate::Resettable for ICMR1_SPEC {
445    const RESET_VALUE: Self::Ux = 0x08;
446}