saml10d16a/nvmctrl/
param.rs

1#[doc = "Reader of register PARAM"]
2pub type R = crate::R<u32, super::PARAM>;
3#[doc = "Writer for register PARAM"]
4pub type W = crate::W<u32, super::PARAM>;
5#[doc = "Register PARAM `reset()`'s with value 0"]
6impl crate::ResetValue for super::PARAM {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `FLASHP`"]
14pub type FLASHP_R = crate::R<u16, u16>;
15#[doc = "Write proxy for field `FLASHP`"]
16pub struct FLASHP_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> FLASHP_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u16) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0xffff) | ((value as u32) & 0xffff);
24        self.w
25    }
26}
27#[doc = "Possible values of the field `PSZ`"]
28#[derive(Clone, Copy, Debug, PartialEq)]
29pub enum PSZ_A {
30    #[doc = "8 bytes"]
31    _8,
32    #[doc = "16 bytes"]
33    _16,
34    #[doc = "32 bytes"]
35    _32,
36    #[doc = "64 bytes"]
37    _64,
38    #[doc = "128 bytes"]
39    _128,
40    #[doc = "256 bytes"]
41    _256,
42    #[doc = "512 bytes"]
43    _512,
44    #[doc = "1024 bytes"]
45    _1024,
46}
47impl crate::ToBits<u8> for PSZ_A {
48    #[inline(always)]
49    fn _bits(&self) -> u8 {
50        match *self {
51            PSZ_A::_8 => 0,
52            PSZ_A::_16 => 1,
53            PSZ_A::_32 => 2,
54            PSZ_A::_64 => 3,
55            PSZ_A::_128 => 4,
56            PSZ_A::_256 => 5,
57            PSZ_A::_512 => 6,
58            PSZ_A::_1024 => 7,
59        }
60    }
61}
62#[doc = "Reader of field `PSZ`"]
63pub type PSZ_R = crate::R<u8, PSZ_A>;
64impl PSZ_R {
65    #[doc = r"Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> PSZ_A {
68        match self.bits {
69            0 => PSZ_A::_8,
70            1 => PSZ_A::_16,
71            2 => PSZ_A::_32,
72            3 => PSZ_A::_64,
73            4 => PSZ_A::_128,
74            5 => PSZ_A::_256,
75            6 => PSZ_A::_512,
76            7 => PSZ_A::_1024,
77            _ => unreachable!(),
78        }
79    }
80    #[doc = "Checks if the value of the field is `_8`"]
81    #[inline(always)]
82    pub fn is_8(&self) -> bool {
83        *self == PSZ_A::_8
84    }
85    #[doc = "Checks if the value of the field is `_16`"]
86    #[inline(always)]
87    pub fn is_16(&self) -> bool {
88        *self == PSZ_A::_16
89    }
90    #[doc = "Checks if the value of the field is `_32`"]
91    #[inline(always)]
92    pub fn is_32(&self) -> bool {
93        *self == PSZ_A::_32
94    }
95    #[doc = "Checks if the value of the field is `_64`"]
96    #[inline(always)]
97    pub fn is_64(&self) -> bool {
98        *self == PSZ_A::_64
99    }
100    #[doc = "Checks if the value of the field is `_128`"]
101    #[inline(always)]
102    pub fn is_128(&self) -> bool {
103        *self == PSZ_A::_128
104    }
105    #[doc = "Checks if the value of the field is `_256`"]
106    #[inline(always)]
107    pub fn is_256(&self) -> bool {
108        *self == PSZ_A::_256
109    }
110    #[doc = "Checks if the value of the field is `_512`"]
111    #[inline(always)]
112    pub fn is_512(&self) -> bool {
113        *self == PSZ_A::_512
114    }
115    #[doc = "Checks if the value of the field is `_1024`"]
116    #[inline(always)]
117    pub fn is_1024(&self) -> bool {
118        *self == PSZ_A::_1024
119    }
120}
121#[doc = "Write proxy for field `PSZ`"]
122pub struct PSZ_W<'a> {
123    w: &'a mut W,
124}
125impl<'a> PSZ_W<'a> {
126    #[doc = r"Writes `variant` to the field"]
127    #[inline(always)]
128    pub fn variant(self, variant: PSZ_A) -> &'a mut W {
129        use crate::ToBits;
130        {
131            self.bits(variant._bits())
132        }
133    }
134    #[doc = "8 bytes"]
135    #[inline(always)]
136    pub fn _8(self) -> &'a mut W {
137        self.variant(PSZ_A::_8)
138    }
139    #[doc = "16 bytes"]
140    #[inline(always)]
141    pub fn _16(self) -> &'a mut W {
142        self.variant(PSZ_A::_16)
143    }
144    #[doc = "32 bytes"]
145    #[inline(always)]
146    pub fn _32(self) -> &'a mut W {
147        self.variant(PSZ_A::_32)
148    }
149    #[doc = "64 bytes"]
150    #[inline(always)]
151    pub fn _64(self) -> &'a mut W {
152        self.variant(PSZ_A::_64)
153    }
154    #[doc = "128 bytes"]
155    #[inline(always)]
156    pub fn _128(self) -> &'a mut W {
157        self.variant(PSZ_A::_128)
158    }
159    #[doc = "256 bytes"]
160    #[inline(always)]
161    pub fn _256(self) -> &'a mut W {
162        self.variant(PSZ_A::_256)
163    }
164    #[doc = "512 bytes"]
165    #[inline(always)]
166    pub fn _512(self) -> &'a mut W {
167        self.variant(PSZ_A::_512)
168    }
169    #[doc = "1024 bytes"]
170    #[inline(always)]
171    pub fn _1024(self) -> &'a mut W {
172        self.variant(PSZ_A::_1024)
173    }
174    #[doc = r"Writes raw bits to the field"]
175    #[inline(always)]
176    pub fn bits(self, value: u8) -> &'a mut W {
177        self.w.bits = (self.w.bits & !(0x07 << 16)) | (((value as u32) & 0x07) << 16);
178        self.w
179    }
180}
181#[doc = "Reader of field `DFLASHP`"]
182pub type DFLASHP_R = crate::R<u16, u16>;
183#[doc = "Write proxy for field `DFLASHP`"]
184pub struct DFLASHP_W<'a> {
185    w: &'a mut W,
186}
187impl<'a> DFLASHP_W<'a> {
188    #[doc = r"Writes raw bits to the field"]
189    #[inline(always)]
190    pub unsafe fn bits(self, value: u16) -> &'a mut W {
191        self.w.bits = (self.w.bits & !(0x0fff << 20)) | (((value as u32) & 0x0fff) << 20);
192        self.w
193    }
194}
195impl R {
196    #[doc = "Bits 0:15 - FLASH Pages"]
197    #[inline(always)]
198    pub fn flashp(&self) -> FLASHP_R {
199        FLASHP_R::new((self.bits & 0xffff) as u16)
200    }
201    #[doc = "Bits 16:18 - Page Size"]
202    #[inline(always)]
203    pub fn psz(&self) -> PSZ_R {
204        PSZ_R::new(((self.bits >> 16) & 0x07) as u8)
205    }
206    #[doc = "Bits 20:31 - DATAFLASH Pages"]
207    #[inline(always)]
208    pub fn dflashp(&self) -> DFLASHP_R {
209        DFLASHP_R::new(((self.bits >> 20) & 0x0fff) as u16)
210    }
211}
212impl W {
213    #[doc = "Bits 0:15 - FLASH Pages"]
214    #[inline(always)]
215    pub fn flashp(&mut self) -> FLASHP_W {
216        FLASHP_W { w: self }
217    }
218    #[doc = "Bits 16:18 - Page Size"]
219    #[inline(always)]
220    pub fn psz(&mut self) -> PSZ_W {
221        PSZ_W { w: self }
222    }
223    #[doc = "Bits 20:31 - DATAFLASH Pages"]
224    #[inline(always)]
225    pub fn dflashp(&mut self) -> DFLASHP_W {
226        DFLASHP_W { w: self }
227    }
228}