ra2l1/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\n\nValue on reset: 1"]
168#[derive(Clone, Copy, Debug, PartialEq, Eq)]
169pub enum BCWP_AW {
170    #[doc = "0: Write enable BC\\[2:0\\]
171bits"]
172    _0 = 0,
173    #[doc = "1: Write protect 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"]
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 = "Write enable BC\\[2:0\\]
187bits"]
188    #[inline(always)]
189    pub fn _0(self) -> &'a mut W {
190        self.variant(BCWP_AW::_0)
191    }
192    #[doc = "Write protect 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 Select"]
200pub type CKS_R = crate::FieldReader<u8, u8>;
201#[doc = "Field `CKS` writer - Internal Reference Clock Select"]
202pub type CKS_W<'a, const O: u8> = crate::FieldWriter<'a, u8, ICMR1_SPEC, u8, u8, 3, O>;
203#[doc = "Field `MTWP` reader - MST/TRS Write Protect"]
204pub type MTWP_R = crate::BitReader<MTWP_A>;
205#[doc = "MST/TRS Write Protect\n\nValue on reset: 0"]
206#[derive(Clone, Copy, Debug, PartialEq, Eq)]
207pub enum MTWP_A {
208    #[doc = "0: Write protect MST and TRS bits in ICCR2"]
209    _0 = 0,
210    #[doc = "1: Write enable MST and TRS bits in ICCR2"]
211    _1 = 1,
212}
213impl From<MTWP_A> for bool {
214    #[inline(always)]
215    fn from(variant: MTWP_A) -> Self {
216        variant as u8 != 0
217    }
218}
219impl MTWP_R {
220    #[doc = "Get enumerated values variant"]
221    #[inline(always)]
222    pub fn variant(&self) -> MTWP_A {
223        match self.bits {
224            false => MTWP_A::_0,
225            true => MTWP_A::_1,
226        }
227    }
228    #[doc = "Checks if the value of the field is `_0`"]
229    #[inline(always)]
230    pub fn is_0(&self) -> bool {
231        *self == MTWP_A::_0
232    }
233    #[doc = "Checks if the value of the field is `_1`"]
234    #[inline(always)]
235    pub fn is_1(&self) -> bool {
236        *self == MTWP_A::_1
237    }
238}
239#[doc = "Field `MTWP` writer - MST/TRS Write Protect"]
240pub type MTWP_W<'a, const O: u8> = crate::BitWriter<'a, u8, ICMR1_SPEC, MTWP_A, O>;
241impl<'a, const O: u8> MTWP_W<'a, O> {
242    #[doc = "Write protect MST and TRS bits in ICCR2"]
243    #[inline(always)]
244    pub fn _0(self) -> &'a mut W {
245        self.variant(MTWP_A::_0)
246    }
247    #[doc = "Write enable MST and TRS bits in ICCR2"]
248    #[inline(always)]
249    pub fn _1(self) -> &'a mut W {
250        self.variant(MTWP_A::_1)
251    }
252}
253impl R {
254    #[doc = "Bits 0:2 - Bit Counter"]
255    #[inline(always)]
256    pub fn bc(&self) -> BC_R {
257        BC_R::new(self.bits & 7)
258    }
259    #[doc = "Bits 4:6 - Internal Reference Clock Select"]
260    #[inline(always)]
261    pub fn cks(&self) -> CKS_R {
262        CKS_R::new((self.bits >> 4) & 7)
263    }
264    #[doc = "Bit 7 - MST/TRS Write Protect"]
265    #[inline(always)]
266    pub fn mtwp(&self) -> MTWP_R {
267        MTWP_R::new(((self.bits >> 7) & 1) != 0)
268    }
269}
270impl W {
271    #[doc = "Bits 0:2 - Bit Counter"]
272    #[inline(always)]
273    #[must_use]
274    pub fn bc(&mut self) -> BC_W<0> {
275        BC_W::new(self)
276    }
277    #[doc = "Bit 3 - BC Write Protect"]
278    #[inline(always)]
279    #[must_use]
280    pub fn bcwp(&mut self) -> BCWP_W<3> {
281        BCWP_W::new(self)
282    }
283    #[doc = "Bits 4:6 - Internal Reference Clock Select"]
284    #[inline(always)]
285    #[must_use]
286    pub fn cks(&mut self) -> CKS_W<4> {
287        CKS_W::new(self)
288    }
289    #[doc = "Bit 7 - MST/TRS Write Protect"]
290    #[inline(always)]
291    #[must_use]
292    pub fn mtwp(&mut self) -> MTWP_W<7> {
293        MTWP_W::new(self)
294    }
295    #[doc = "Writes raw bits to the register."]
296    #[inline(always)]
297    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
298        self.0.bits(bits);
299        self
300    }
301}
302#[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"]
303pub struct ICMR1_SPEC;
304impl crate::RegisterSpec for ICMR1_SPEC {
305    type Ux = u8;
306}
307#[doc = "`read()` method returns [icmr1::R](R) reader structure"]
308impl crate::Readable for ICMR1_SPEC {
309    type Reader = R;
310}
311#[doc = "`write(|w| ..)` method takes [icmr1::W](W) writer structure"]
312impl crate::Writable for ICMR1_SPEC {
313    type Writer = W;
314    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
315    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
316}
317#[doc = "`reset()` method sets ICMR1 to value 0x08"]
318impl crate::Resettable for ICMR1_SPEC {
319    const RESET_VALUE: Self::Ux = 0x08;
320}