rv32m1_ri5cy_pac/mscm/
ocmdr1.rs

1#[doc = "Reader of register OCMDR1"]
2pub type R = crate::R<u32, super::OCMDR1>;
3#[doc = "Writer for register OCMDR1"]
4pub type W = crate::W<u32, super::OCMDR1>;
5#[doc = "Register OCMDR1 `reset()`'s with value 0xc706_9000"]
6impl crate::ResetValue for super::OCMDR1 {
7  type Type = u32;
8  #[inline(always)]
9  fn reset_value() -> Self::Type {
10    0xc706_9000
11  }
12}
13#[doc = "Reader of field `OCM1`"]
14pub type OCM1_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `OCM1`"]
16pub struct OCM1_W<'a> {
17  w: &'a mut W,
18}
19impl<'a> OCM1_W<'a> {
20  #[doc = r"Writes raw bits to the field"]
21  #[inline(always)]
22  pub unsafe fn bits(self, value: u8) -> &'a mut W {
23    self.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
24    self.w
25  }
26}
27#[doc = "Reader of field `OCMPU`"]
28pub type OCMPU_R = crate::R<bool, bool>;
29#[doc = "OCMT\n\nValue on reset: 4"]
30#[derive(Clone, Copy, Debug, PartialEq)]
31pub enum OCMT_A {
32  #[doc = "3: OCMEMn is a ROM."]
33  OCMT_3,
34  #[doc = "4: OCMEMn is a Program Flash."]
35  OCMT_4,
36  #[doc = "6: OCMEMn is an EEE."]
37  OCMT_6,
38}
39impl From<OCMT_A> for u8 {
40  #[inline(always)]
41  fn from(variant: OCMT_A) -> Self {
42    match variant {
43      OCMT_A::OCMT_3 => 3,
44      OCMT_A::OCMT_4 => 4,
45      OCMT_A::OCMT_6 => 6,
46    }
47  }
48}
49#[doc = "Reader of field `OCMT`"]
50pub type OCMT_R = crate::R<u8, OCMT_A>;
51impl OCMT_R {
52  #[doc = r"Get enumerated values variant"]
53  #[inline(always)]
54  pub fn variant(&self) -> crate::Variant<u8, OCMT_A> {
55    use crate::Variant::*;
56    match self.bits {
57      3 => Val(OCMT_A::OCMT_3),
58      4 => Val(OCMT_A::OCMT_4),
59      6 => Val(OCMT_A::OCMT_6),
60      i => Res(i),
61    }
62  }
63  #[doc = "Checks if the value of the field is `OCMT_3`"]
64  #[inline(always)]
65  pub fn is_ocmt_3(&self) -> bool {
66    *self == OCMT_A::OCMT_3
67  }
68  #[doc = "Checks if the value of the field is `OCMT_4`"]
69  #[inline(always)]
70  pub fn is_ocmt_4(&self) -> bool {
71    *self == OCMT_A::OCMT_4
72  }
73  #[doc = "Checks if the value of the field is `OCMT_6`"]
74  #[inline(always)]
75  pub fn is_ocmt_6(&self) -> bool {
76    *self == OCMT_A::OCMT_6
77  }
78}
79#[doc = "RO\n\nValue on reset: 0"]
80#[derive(Clone, Copy, Debug, PartialEq)]
81pub enum RO_A {
82  #[doc = "0: Writes to the OCMDRn\\[11:0\\] are allowed"]
83  RO_0,
84  #[doc = "1: Writes to the OCMDRn\\[11:0\\] are ignored"]
85  RO_1,
86}
87impl From<RO_A> for bool {
88  #[inline(always)]
89  fn from(variant: RO_A) -> Self {
90    match variant {
91      RO_A::RO_0 => false,
92      RO_A::RO_1 => true,
93    }
94  }
95}
96#[doc = "Reader of field `RO`"]
97pub type RO_R = crate::R<bool, RO_A>;
98impl RO_R {
99  #[doc = r"Get enumerated values variant"]
100  #[inline(always)]
101  pub fn variant(&self) -> RO_A {
102    match self.bits {
103      false => RO_A::RO_0,
104      true => RO_A::RO_1,
105    }
106  }
107  #[doc = "Checks if the value of the field is `RO_0`"]
108  #[inline(always)]
109  pub fn is_ro_0(&self) -> bool {
110    *self == RO_A::RO_0
111  }
112  #[doc = "Checks if the value of the field is `RO_1`"]
113  #[inline(always)]
114  pub fn is_ro_1(&self) -> bool {
115    *self == RO_A::RO_1
116  }
117}
118#[doc = "Write proxy for field `RO`"]
119pub struct RO_W<'a> {
120  w: &'a mut W,
121}
122impl<'a> RO_W<'a> {
123  #[doc = r"Writes `variant` to the field"]
124  #[inline(always)]
125  pub fn variant(self, variant: RO_A) -> &'a mut W {
126    {
127      self.bit(variant.into())
128    }
129  }
130  #[doc = "Writes to the OCMDRn\\[11:0\\] are allowed"]
131  #[inline(always)]
132  pub fn ro_0(self) -> &'a mut W {
133    self.variant(RO_A::RO_0)
134  }
135  #[doc = "Writes to the OCMDRn\\[11:0\\] are ignored"]
136  #[inline(always)]
137  pub fn ro_1(self) -> &'a mut W {
138    self.variant(RO_A::RO_1)
139  }
140  #[doc = r"Sets the field bit"]
141  #[inline(always)]
142  pub fn set_bit(self) -> &'a mut W {
143    self.bit(true)
144  }
145  #[doc = r"Clears the field bit"]
146  #[inline(always)]
147  pub fn clear_bit(self) -> &'a mut W {
148    self.bit(false)
149  }
150  #[doc = r"Writes raw bits to the field"]
151  #[inline(always)]
152  pub fn bit(self, value: bool) -> &'a mut W {
153    self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16);
154    self.w
155  }
156}
157#[doc = "OCMW\n\nValue on reset: 3"]
158#[derive(Clone, Copy, Debug, PartialEq)]
159pub enum OCMW_A {
160  #[doc = "2: OCMEMn 32-bits wide"]
161  OCMW_2,
162  #[doc = "3: OCMEMn 64-bits wide"]
163  OCMW_3,
164  #[doc = "4: OCMEMn 128-bits wide"]
165  OCMW_4,
166  #[doc = "5: OCMEMn 256-bits wide"]
167  OCMW_5,
168}
169impl From<OCMW_A> for u8 {
170  #[inline(always)]
171  fn from(variant: OCMW_A) -> Self {
172    match variant {
173      OCMW_A::OCMW_2 => 2,
174      OCMW_A::OCMW_3 => 3,
175      OCMW_A::OCMW_4 => 4,
176      OCMW_A::OCMW_5 => 5,
177    }
178  }
179}
180#[doc = "Reader of field `OCMW`"]
181pub type OCMW_R = crate::R<u8, OCMW_A>;
182impl OCMW_R {
183  #[doc = r"Get enumerated values variant"]
184  #[inline(always)]
185  pub fn variant(&self) -> crate::Variant<u8, OCMW_A> {
186    use crate::Variant::*;
187    match self.bits {
188      2 => Val(OCMW_A::OCMW_2),
189      3 => Val(OCMW_A::OCMW_3),
190      4 => Val(OCMW_A::OCMW_4),
191      5 => Val(OCMW_A::OCMW_5),
192      i => Res(i),
193    }
194  }
195  #[doc = "Checks if the value of the field is `OCMW_2`"]
196  #[inline(always)]
197  pub fn is_ocmw_2(&self) -> bool {
198    *self == OCMW_A::OCMW_2
199  }
200  #[doc = "Checks if the value of the field is `OCMW_3`"]
201  #[inline(always)]
202  pub fn is_ocmw_3(&self) -> bool {
203    *self == OCMW_A::OCMW_3
204  }
205  #[doc = "Checks if the value of the field is `OCMW_4`"]
206  #[inline(always)]
207  pub fn is_ocmw_4(&self) -> bool {
208    *self == OCMW_A::OCMW_4
209  }
210  #[doc = "Checks if the value of the field is `OCMW_5`"]
211  #[inline(always)]
212  pub fn is_ocmw_5(&self) -> bool {
213    *self == OCMW_A::OCMW_5
214  }
215}
216#[doc = "OCMSZ\n\nValue on reset: 7"]
217#[derive(Clone, Copy, Debug, PartialEq)]
218pub enum OCMSZ_A {
219  #[doc = "0: no OCMEMn"]
220  OCMSZ_0,
221  #[doc = "1: 1KB OCMEMn"]
222  OCMSZ_1,
223  #[doc = "2: 2KB OCMEMn"]
224  OCMSZ_2,
225  #[doc = "3: 4KB OCMEMn"]
226  OCMSZ_3,
227  #[doc = "4: 8KB OCMEMn"]
228  OCMSZ_4,
229  #[doc = "5: 16KB OCMEMn"]
230  OCMSZ_5,
231  #[doc = "6: 32KB OCMEMn"]
232  OCMSZ_6,
233  #[doc = "7: 64KB OCMEMn"]
234  OCMSZ_7,
235  #[doc = "8: 128KB OCMEMn"]
236  OCMSZ_8,
237  #[doc = "9: 256KB OCMEMn"]
238  OCMSZ_9,
239  #[doc = "10: 512KB OCMEMn"]
240  OCMSZ_10,
241  #[doc = "11: 1MB OCMEMn"]
242  OCMSZ_11,
243  #[doc = "12: 2MB OCMEMn"]
244  OCMSZ_12,
245  #[doc = "13: 4MB OCMEMn"]
246  OCMSZ_13,
247  #[doc = "14: 8MB OCMEMn"]
248  OCMSZ_14,
249  #[doc = "15: 16MB OCMEMn"]
250  OCMSZ_15,
251}
252impl From<OCMSZ_A> for u8 {
253  #[inline(always)]
254  fn from(variant: OCMSZ_A) -> Self {
255    match variant {
256      OCMSZ_A::OCMSZ_0 => 0,
257      OCMSZ_A::OCMSZ_1 => 1,
258      OCMSZ_A::OCMSZ_2 => 2,
259      OCMSZ_A::OCMSZ_3 => 3,
260      OCMSZ_A::OCMSZ_4 => 4,
261      OCMSZ_A::OCMSZ_5 => 5,
262      OCMSZ_A::OCMSZ_6 => 6,
263      OCMSZ_A::OCMSZ_7 => 7,
264      OCMSZ_A::OCMSZ_8 => 8,
265      OCMSZ_A::OCMSZ_9 => 9,
266      OCMSZ_A::OCMSZ_10 => 10,
267      OCMSZ_A::OCMSZ_11 => 11,
268      OCMSZ_A::OCMSZ_12 => 12,
269      OCMSZ_A::OCMSZ_13 => 13,
270      OCMSZ_A::OCMSZ_14 => 14,
271      OCMSZ_A::OCMSZ_15 => 15,
272    }
273  }
274}
275#[doc = "Reader of field `OCMSZ`"]
276pub type OCMSZ_R = crate::R<u8, OCMSZ_A>;
277impl OCMSZ_R {
278  #[doc = r"Get enumerated values variant"]
279  #[inline(always)]
280  pub fn variant(&self) -> OCMSZ_A {
281    match self.bits {
282      0 => OCMSZ_A::OCMSZ_0,
283      1 => OCMSZ_A::OCMSZ_1,
284      2 => OCMSZ_A::OCMSZ_2,
285      3 => OCMSZ_A::OCMSZ_3,
286      4 => OCMSZ_A::OCMSZ_4,
287      5 => OCMSZ_A::OCMSZ_5,
288      6 => OCMSZ_A::OCMSZ_6,
289      7 => OCMSZ_A::OCMSZ_7,
290      8 => OCMSZ_A::OCMSZ_8,
291      9 => OCMSZ_A::OCMSZ_9,
292      10 => OCMSZ_A::OCMSZ_10,
293      11 => OCMSZ_A::OCMSZ_11,
294      12 => OCMSZ_A::OCMSZ_12,
295      13 => OCMSZ_A::OCMSZ_13,
296      14 => OCMSZ_A::OCMSZ_14,
297      15 => OCMSZ_A::OCMSZ_15,
298      _ => unreachable!(),
299    }
300  }
301  #[doc = "Checks if the value of the field is `OCMSZ_0`"]
302  #[inline(always)]
303  pub fn is_ocmsz_0(&self) -> bool {
304    *self == OCMSZ_A::OCMSZ_0
305  }
306  #[doc = "Checks if the value of the field is `OCMSZ_1`"]
307  #[inline(always)]
308  pub fn is_ocmsz_1(&self) -> bool {
309    *self == OCMSZ_A::OCMSZ_1
310  }
311  #[doc = "Checks if the value of the field is `OCMSZ_2`"]
312  #[inline(always)]
313  pub fn is_ocmsz_2(&self) -> bool {
314    *self == OCMSZ_A::OCMSZ_2
315  }
316  #[doc = "Checks if the value of the field is `OCMSZ_3`"]
317  #[inline(always)]
318  pub fn is_ocmsz_3(&self) -> bool {
319    *self == OCMSZ_A::OCMSZ_3
320  }
321  #[doc = "Checks if the value of the field is `OCMSZ_4`"]
322  #[inline(always)]
323  pub fn is_ocmsz_4(&self) -> bool {
324    *self == OCMSZ_A::OCMSZ_4
325  }
326  #[doc = "Checks if the value of the field is `OCMSZ_5`"]
327  #[inline(always)]
328  pub fn is_ocmsz_5(&self) -> bool {
329    *self == OCMSZ_A::OCMSZ_5
330  }
331  #[doc = "Checks if the value of the field is `OCMSZ_6`"]
332  #[inline(always)]
333  pub fn is_ocmsz_6(&self) -> bool {
334    *self == OCMSZ_A::OCMSZ_6
335  }
336  #[doc = "Checks if the value of the field is `OCMSZ_7`"]
337  #[inline(always)]
338  pub fn is_ocmsz_7(&self) -> bool {
339    *self == OCMSZ_A::OCMSZ_7
340  }
341  #[doc = "Checks if the value of the field is `OCMSZ_8`"]
342  #[inline(always)]
343  pub fn is_ocmsz_8(&self) -> bool {
344    *self == OCMSZ_A::OCMSZ_8
345  }
346  #[doc = "Checks if the value of the field is `OCMSZ_9`"]
347  #[inline(always)]
348  pub fn is_ocmsz_9(&self) -> bool {
349    *self == OCMSZ_A::OCMSZ_9
350  }
351  #[doc = "Checks if the value of the field is `OCMSZ_10`"]
352  #[inline(always)]
353  pub fn is_ocmsz_10(&self) -> bool {
354    *self == OCMSZ_A::OCMSZ_10
355  }
356  #[doc = "Checks if the value of the field is `OCMSZ_11`"]
357  #[inline(always)]
358  pub fn is_ocmsz_11(&self) -> bool {
359    *self == OCMSZ_A::OCMSZ_11
360  }
361  #[doc = "Checks if the value of the field is `OCMSZ_12`"]
362  #[inline(always)]
363  pub fn is_ocmsz_12(&self) -> bool {
364    *self == OCMSZ_A::OCMSZ_12
365  }
366  #[doc = "Checks if the value of the field is `OCMSZ_13`"]
367  #[inline(always)]
368  pub fn is_ocmsz_13(&self) -> bool {
369    *self == OCMSZ_A::OCMSZ_13
370  }
371  #[doc = "Checks if the value of the field is `OCMSZ_14`"]
372  #[inline(always)]
373  pub fn is_ocmsz_14(&self) -> bool {
374    *self == OCMSZ_A::OCMSZ_14
375  }
376  #[doc = "Checks if the value of the field is `OCMSZ_15`"]
377  #[inline(always)]
378  pub fn is_ocmsz_15(&self) -> bool {
379    *self == OCMSZ_A::OCMSZ_15
380  }
381}
382#[doc = "OCMSZH\n\nValue on reset: 0"]
383#[derive(Clone, Copy, Debug, PartialEq)]
384pub enum OCMSZH_A {
385  #[doc = "0: OCMEMn is a power-of-2 capacity."]
386  OCMSZH_0,
387  #[doc = "1: OCMEMn is not a power-of-2, with a capacity is 0.75 * OCMSZ."]
388  OCMSZH_1,
389}
390impl From<OCMSZH_A> for bool {
391  #[inline(always)]
392  fn from(variant: OCMSZH_A) -> Self {
393    match variant {
394      OCMSZH_A::OCMSZH_0 => false,
395      OCMSZH_A::OCMSZH_1 => true,
396    }
397  }
398}
399#[doc = "Reader of field `OCMSZH`"]
400pub type OCMSZH_R = crate::R<bool, OCMSZH_A>;
401impl OCMSZH_R {
402  #[doc = r"Get enumerated values variant"]
403  #[inline(always)]
404  pub fn variant(&self) -> OCMSZH_A {
405    match self.bits {
406      false => OCMSZH_A::OCMSZH_0,
407      true => OCMSZH_A::OCMSZH_1,
408    }
409  }
410  #[doc = "Checks if the value of the field is `OCMSZH_0`"]
411  #[inline(always)]
412  pub fn is_ocmszh_0(&self) -> bool {
413    *self == OCMSZH_A::OCMSZH_0
414  }
415  #[doc = "Checks if the value of the field is `OCMSZH_1`"]
416  #[inline(always)]
417  pub fn is_ocmszh_1(&self) -> bool {
418    *self == OCMSZH_A::OCMSZH_1
419  }
420}
421#[doc = "V\n\nValue on reset: 1"]
422#[derive(Clone, Copy, Debug, PartialEq)]
423pub enum V_A {
424  #[doc = "0: OCMEMn is not present."]
425  V_0,
426  #[doc = "1: OCMEMn is present."]
427  V_1,
428}
429impl From<V_A> for bool {
430  #[inline(always)]
431  fn from(variant: V_A) -> Self {
432    match variant {
433      V_A::V_0 => false,
434      V_A::V_1 => true,
435    }
436  }
437}
438#[doc = "Reader of field `V`"]
439pub type V_R = crate::R<bool, V_A>;
440impl V_R {
441  #[doc = r"Get enumerated values variant"]
442  #[inline(always)]
443  pub fn variant(&self) -> V_A {
444    match self.bits {
445      false => V_A::V_0,
446      true => V_A::V_1,
447    }
448  }
449  #[doc = "Checks if the value of the field is `V_0`"]
450  #[inline(always)]
451  pub fn is_v_0(&self) -> bool {
452    *self == V_A::V_0
453  }
454  #[doc = "Checks if the value of the field is `V_1`"]
455  #[inline(always)]
456  pub fn is_v_1(&self) -> bool {
457    *self == V_A::V_1
458  }
459}
460impl R {
461  #[doc = "Bits 4:5 - OCMEM Control Field 1"]
462  #[inline(always)]
463  pub fn ocm1(&self) -> OCM1_R {
464    OCM1_R::new(((self.bits >> 4) & 0x03) as u8)
465  }
466  #[doc = "Bit 12 - OCMPU"]
467  #[inline(always)]
468  pub fn ocmpu(&self) -> OCMPU_R {
469    OCMPU_R::new(((self.bits >> 12) & 0x01) != 0)
470  }
471  #[doc = "Bits 13:15 - OCMT"]
472  #[inline(always)]
473  pub fn ocmt(&self) -> OCMT_R {
474    OCMT_R::new(((self.bits >> 13) & 0x07) as u8)
475  }
476  #[doc = "Bit 16 - RO"]
477  #[inline(always)]
478  pub fn ro(&self) -> RO_R {
479    RO_R::new(((self.bits >> 16) & 0x01) != 0)
480  }
481  #[doc = "Bits 17:19 - OCMW"]
482  #[inline(always)]
483  pub fn ocmw(&self) -> OCMW_R {
484    OCMW_R::new(((self.bits >> 17) & 0x07) as u8)
485  }
486  #[doc = "Bits 24:27 - OCMSZ"]
487  #[inline(always)]
488  pub fn ocmsz(&self) -> OCMSZ_R {
489    OCMSZ_R::new(((self.bits >> 24) & 0x0f) as u8)
490  }
491  #[doc = "Bit 28 - OCMSZH"]
492  #[inline(always)]
493  pub fn ocmszh(&self) -> OCMSZH_R {
494    OCMSZH_R::new(((self.bits >> 28) & 0x01) != 0)
495  }
496  #[doc = "Bit 31 - V"]
497  #[inline(always)]
498  pub fn v(&self) -> V_R {
499    V_R::new(((self.bits >> 31) & 0x01) != 0)
500  }
501}
502impl W {
503  #[doc = "Bits 4:5 - OCMEM Control Field 1"]
504  #[inline(always)]
505  pub fn ocm1(&mut self) -> OCM1_W {
506    OCM1_W { w: self }
507  }
508  #[doc = "Bit 16 - RO"]
509  #[inline(always)]
510  pub fn ro(&mut self) -> RO_W {
511    RO_W { w: self }
512  }
513}