mk66f18/sdhc/
blkattr.rs

1#[doc = "Reader of register BLKATTR"]
2pub type R = crate::R<u32, super::BLKATTR>;
3#[doc = "Writer for register BLKATTR"]
4pub type W = crate::W<u32, super::BLKATTR>;
5#[doc = "Register BLKATTR `reset()`'s with value 0"]
6impl crate::ResetValue for super::BLKATTR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Transfer Block Size\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum BLKSIZE_A {
16    #[doc = "0: No data transfer."]
17    _0,
18    #[doc = "1: 1 Byte"]
19    _1,
20    #[doc = "2: 2 Bytes"]
21    _10,
22    #[doc = "3: 3 Bytes"]
23    _11,
24    #[doc = "4: 4 Bytes"]
25    _100,
26    #[doc = "511: 511 Bytes"]
27    _111111111,
28    #[doc = "512: 512 Bytes"]
29    _1000000000,
30    #[doc = "2048: 2048 Bytes"]
31    _100000000000,
32    #[doc = "4096: 4096 Bytes"]
33    _1000000000000,
34}
35impl From<BLKSIZE_A> for u16 {
36    #[inline(always)]
37    fn from(variant: BLKSIZE_A) -> Self {
38        match variant {
39            BLKSIZE_A::_0 => 0,
40            BLKSIZE_A::_1 => 1,
41            BLKSIZE_A::_10 => 2,
42            BLKSIZE_A::_11 => 3,
43            BLKSIZE_A::_100 => 4,
44            BLKSIZE_A::_111111111 => 511,
45            BLKSIZE_A::_1000000000 => 512,
46            BLKSIZE_A::_100000000000 => 2048,
47            BLKSIZE_A::_1000000000000 => 4096,
48        }
49    }
50}
51#[doc = "Reader of field `BLKSIZE`"]
52pub type BLKSIZE_R = crate::R<u16, BLKSIZE_A>;
53impl BLKSIZE_R {
54    #[doc = r"Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> crate::Variant<u16, BLKSIZE_A> {
57        use crate::Variant::*;
58        match self.bits {
59            0 => Val(BLKSIZE_A::_0),
60            1 => Val(BLKSIZE_A::_1),
61            2 => Val(BLKSIZE_A::_10),
62            3 => Val(BLKSIZE_A::_11),
63            4 => Val(BLKSIZE_A::_100),
64            511 => Val(BLKSIZE_A::_111111111),
65            512 => Val(BLKSIZE_A::_1000000000),
66            2048 => Val(BLKSIZE_A::_100000000000),
67            4096 => Val(BLKSIZE_A::_1000000000000),
68            i => Res(i),
69        }
70    }
71    #[doc = "Checks if the value of the field is `_0`"]
72    #[inline(always)]
73    pub fn is_0(&self) -> bool {
74        *self == BLKSIZE_A::_0
75    }
76    #[doc = "Checks if the value of the field is `_1`"]
77    #[inline(always)]
78    pub fn is_1(&self) -> bool {
79        *self == BLKSIZE_A::_1
80    }
81    #[doc = "Checks if the value of the field is `_10`"]
82    #[inline(always)]
83    pub fn is_10(&self) -> bool {
84        *self == BLKSIZE_A::_10
85    }
86    #[doc = "Checks if the value of the field is `_11`"]
87    #[inline(always)]
88    pub fn is_11(&self) -> bool {
89        *self == BLKSIZE_A::_11
90    }
91    #[doc = "Checks if the value of the field is `_100`"]
92    #[inline(always)]
93    pub fn is_100(&self) -> bool {
94        *self == BLKSIZE_A::_100
95    }
96    #[doc = "Checks if the value of the field is `_111111111`"]
97    #[inline(always)]
98    pub fn is_111111111(&self) -> bool {
99        *self == BLKSIZE_A::_111111111
100    }
101    #[doc = "Checks if the value of the field is `_1000000000`"]
102    #[inline(always)]
103    pub fn is_1000000000(&self) -> bool {
104        *self == BLKSIZE_A::_1000000000
105    }
106    #[doc = "Checks if the value of the field is `_100000000000`"]
107    #[inline(always)]
108    pub fn is_100000000000(&self) -> bool {
109        *self == BLKSIZE_A::_100000000000
110    }
111    #[doc = "Checks if the value of the field is `_1000000000000`"]
112    #[inline(always)]
113    pub fn is_1000000000000(&self) -> bool {
114        *self == BLKSIZE_A::_1000000000000
115    }
116}
117#[doc = "Write proxy for field `BLKSIZE`"]
118pub struct BLKSIZE_W<'a> {
119    w: &'a mut W,
120}
121impl<'a> BLKSIZE_W<'a> {
122    #[doc = r"Writes `variant` to the field"]
123    #[inline(always)]
124    pub fn variant(self, variant: BLKSIZE_A) -> &'a mut W {
125        unsafe { self.bits(variant.into()) }
126    }
127    #[doc = "No data transfer."]
128    #[inline(always)]
129    pub fn _0(self) -> &'a mut W {
130        self.variant(BLKSIZE_A::_0)
131    }
132    #[doc = "1 Byte"]
133    #[inline(always)]
134    pub fn _1(self) -> &'a mut W {
135        self.variant(BLKSIZE_A::_1)
136    }
137    #[doc = "2 Bytes"]
138    #[inline(always)]
139    pub fn _10(self) -> &'a mut W {
140        self.variant(BLKSIZE_A::_10)
141    }
142    #[doc = "3 Bytes"]
143    #[inline(always)]
144    pub fn _11(self) -> &'a mut W {
145        self.variant(BLKSIZE_A::_11)
146    }
147    #[doc = "4 Bytes"]
148    #[inline(always)]
149    pub fn _100(self) -> &'a mut W {
150        self.variant(BLKSIZE_A::_100)
151    }
152    #[doc = "511 Bytes"]
153    #[inline(always)]
154    pub fn _111111111(self) -> &'a mut W {
155        self.variant(BLKSIZE_A::_111111111)
156    }
157    #[doc = "512 Bytes"]
158    #[inline(always)]
159    pub fn _1000000000(self) -> &'a mut W {
160        self.variant(BLKSIZE_A::_1000000000)
161    }
162    #[doc = "2048 Bytes"]
163    #[inline(always)]
164    pub fn _100000000000(self) -> &'a mut W {
165        self.variant(BLKSIZE_A::_100000000000)
166    }
167    #[doc = "4096 Bytes"]
168    #[inline(always)]
169    pub fn _1000000000000(self) -> &'a mut W {
170        self.variant(BLKSIZE_A::_1000000000000)
171    }
172    #[doc = r"Writes raw bits to the field"]
173    #[inline(always)]
174    pub unsafe fn bits(self, value: u16) -> &'a mut W {
175        self.w.bits = (self.w.bits & !0x1fff) | ((value as u32) & 0x1fff);
176        self.w
177    }
178}
179#[doc = "Blocks Count For Current Transfer\n\nValue on reset: 0"]
180#[derive(Clone, Copy, Debug, PartialEq)]
181pub enum BLKCNT_A {
182    #[doc = "0: Stop count."]
183    _0,
184    #[doc = "1: 1 block"]
185    _1,
186    #[doc = "2: 2 blocks"]
187    _10,
188    #[doc = "65535: 65535 blocks"]
189    _1111111111111111,
190}
191impl From<BLKCNT_A> for u16 {
192    #[inline(always)]
193    fn from(variant: BLKCNT_A) -> Self {
194        match variant {
195            BLKCNT_A::_0 => 0,
196            BLKCNT_A::_1 => 1,
197            BLKCNT_A::_10 => 2,
198            BLKCNT_A::_1111111111111111 => 65535,
199        }
200    }
201}
202#[doc = "Reader of field `BLKCNT`"]
203pub type BLKCNT_R = crate::R<u16, BLKCNT_A>;
204impl BLKCNT_R {
205    #[doc = r"Get enumerated values variant"]
206    #[inline(always)]
207    pub fn variant(&self) -> crate::Variant<u16, BLKCNT_A> {
208        use crate::Variant::*;
209        match self.bits {
210            0 => Val(BLKCNT_A::_0),
211            1 => Val(BLKCNT_A::_1),
212            2 => Val(BLKCNT_A::_10),
213            65535 => Val(BLKCNT_A::_1111111111111111),
214            i => Res(i),
215        }
216    }
217    #[doc = "Checks if the value of the field is `_0`"]
218    #[inline(always)]
219    pub fn is_0(&self) -> bool {
220        *self == BLKCNT_A::_0
221    }
222    #[doc = "Checks if the value of the field is `_1`"]
223    #[inline(always)]
224    pub fn is_1(&self) -> bool {
225        *self == BLKCNT_A::_1
226    }
227    #[doc = "Checks if the value of the field is `_10`"]
228    #[inline(always)]
229    pub fn is_10(&self) -> bool {
230        *self == BLKCNT_A::_10
231    }
232    #[doc = "Checks if the value of the field is `_1111111111111111`"]
233    #[inline(always)]
234    pub fn is_1111111111111111(&self) -> bool {
235        *self == BLKCNT_A::_1111111111111111
236    }
237}
238#[doc = "Write proxy for field `BLKCNT`"]
239pub struct BLKCNT_W<'a> {
240    w: &'a mut W,
241}
242impl<'a> BLKCNT_W<'a> {
243    #[doc = r"Writes `variant` to the field"]
244    #[inline(always)]
245    pub fn variant(self, variant: BLKCNT_A) -> &'a mut W {
246        unsafe { self.bits(variant.into()) }
247    }
248    #[doc = "Stop count."]
249    #[inline(always)]
250    pub fn _0(self) -> &'a mut W {
251        self.variant(BLKCNT_A::_0)
252    }
253    #[doc = "1 block"]
254    #[inline(always)]
255    pub fn _1(self) -> &'a mut W {
256        self.variant(BLKCNT_A::_1)
257    }
258    #[doc = "2 blocks"]
259    #[inline(always)]
260    pub fn _10(self) -> &'a mut W {
261        self.variant(BLKCNT_A::_10)
262    }
263    #[doc = "65535 blocks"]
264    #[inline(always)]
265    pub fn _1111111111111111(self) -> &'a mut W {
266        self.variant(BLKCNT_A::_1111111111111111)
267    }
268    #[doc = r"Writes raw bits to the field"]
269    #[inline(always)]
270    pub unsafe fn bits(self, value: u16) -> &'a mut W {
271        self.w.bits = (self.w.bits & !(0xffff << 16)) | (((value as u32) & 0xffff) << 16);
272        self.w
273    }
274}
275impl R {
276    #[doc = "Bits 0:12 - Transfer Block Size"]
277    #[inline(always)]
278    pub fn blksize(&self) -> BLKSIZE_R {
279        BLKSIZE_R::new((self.bits & 0x1fff) as u16)
280    }
281    #[doc = "Bits 16:31 - Blocks Count For Current Transfer"]
282    #[inline(always)]
283    pub fn blkcnt(&self) -> BLKCNT_R {
284        BLKCNT_R::new(((self.bits >> 16) & 0xffff) as u16)
285    }
286}
287impl W {
288    #[doc = "Bits 0:12 - Transfer Block Size"]
289    #[inline(always)]
290    pub fn blksize(&mut self) -> BLKSIZE_W {
291        BLKSIZE_W { w: self }
292    }
293    #[doc = "Bits 16:31 - Blocks Count For Current Transfer"]
294    #[inline(always)]
295    pub fn blkcnt(&mut self) -> BLKCNT_W {
296        BLKCNT_W { w: self }
297    }
298}