ra4m3/sdhi0/
sd_cmd.rs

1#[doc = "Register `SD_CMD` reader"]
2pub struct R(crate::R<SD_CMD_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SD_CMD_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SD_CMD_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SD_CMD_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SD_CMD` writer"]
17pub struct W(crate::W<SD_CMD_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SD_CMD_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<SD_CMD_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SD_CMD_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CMDIDX` reader - Command Index Field Value Select"]
38pub type CMDIDX_R = crate::FieldReader<u8, CMDIDX_A>;
39#[doc = "Command Index Field Value Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CMDIDX_A {
43    #[doc = "6: CMD6"]
44    CMD6 = 6,
45    #[doc = "13: ACMD13"]
46    ACMD13 = 13,
47    #[doc = "18: CMD18"]
48    CMD18 = 18,
49}
50impl From<CMDIDX_A> for u8 {
51    #[inline(always)]
52    fn from(variant: CMDIDX_A) -> Self {
53        variant as _
54    }
55}
56impl CMDIDX_R {
57    #[doc = "Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> Option<CMDIDX_A> {
60        match self.bits {
61            6 => Some(CMDIDX_A::CMD6),
62            13 => Some(CMDIDX_A::ACMD13),
63            18 => Some(CMDIDX_A::CMD18),
64            _ => None,
65        }
66    }
67    #[doc = "Checks if the value of the field is `CMD6`"]
68    #[inline(always)]
69    pub fn is_cmd6(&self) -> bool {
70        *self == CMDIDX_A::CMD6
71    }
72    #[doc = "Checks if the value of the field is `ACMD13`"]
73    #[inline(always)]
74    pub fn is_acmd13(&self) -> bool {
75        *self == CMDIDX_A::ACMD13
76    }
77    #[doc = "Checks if the value of the field is `CMD18`"]
78    #[inline(always)]
79    pub fn is_cmd18(&self) -> bool {
80        *self == CMDIDX_A::CMD18
81    }
82}
83#[doc = "Field `CMDIDX` writer - Command Index Field Value Select"]
84pub type CMDIDX_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SD_CMD_SPEC, u8, CMDIDX_A, 6, O>;
85impl<'a, const O: u8> CMDIDX_W<'a, O> {
86    #[doc = "CMD6"]
87    #[inline(always)]
88    pub fn cmd6(self) -> &'a mut W {
89        self.variant(CMDIDX_A::CMD6)
90    }
91    #[doc = "ACMD13"]
92    #[inline(always)]
93    pub fn acmd13(self) -> &'a mut W {
94        self.variant(CMDIDX_A::ACMD13)
95    }
96    #[doc = "CMD18"]
97    #[inline(always)]
98    pub fn cmd18(self) -> &'a mut W {
99        self.variant(CMDIDX_A::CMD18)
100    }
101}
102#[doc = "Field `ACMD` reader - Command Type Select"]
103pub type ACMD_R = crate::FieldReader<u8, ACMD_A>;
104#[doc = "Command Type Select\n\nValue on reset: 0"]
105#[derive(Clone, Copy, Debug, PartialEq, Eq)]
106#[repr(u8)]
107pub enum ACMD_A {
108    #[doc = "0: CMD"]
109    _00 = 0,
110    #[doc = "1: ACMD"]
111    _01 = 1,
112}
113impl From<ACMD_A> for u8 {
114    #[inline(always)]
115    fn from(variant: ACMD_A) -> Self {
116        variant as _
117    }
118}
119impl ACMD_R {
120    #[doc = "Get enumerated values variant"]
121    #[inline(always)]
122    pub fn variant(&self) -> Option<ACMD_A> {
123        match self.bits {
124            0 => Some(ACMD_A::_00),
125            1 => Some(ACMD_A::_01),
126            _ => None,
127        }
128    }
129    #[doc = "Checks if the value of the field is `_00`"]
130    #[inline(always)]
131    pub fn is_00(&self) -> bool {
132        *self == ACMD_A::_00
133    }
134    #[doc = "Checks if the value of the field is `_01`"]
135    #[inline(always)]
136    pub fn is_01(&self) -> bool {
137        *self == ACMD_A::_01
138    }
139}
140#[doc = "Field `ACMD` writer - Command Type Select"]
141pub type ACMD_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SD_CMD_SPEC, u8, ACMD_A, 2, O>;
142impl<'a, const O: u8> ACMD_W<'a, O> {
143    #[doc = "CMD"]
144    #[inline(always)]
145    pub fn _00(self) -> &'a mut W {
146        self.variant(ACMD_A::_00)
147    }
148    #[doc = "ACMD"]
149    #[inline(always)]
150    pub fn _01(self) -> &'a mut W {
151        self.variant(ACMD_A::_01)
152    }
153}
154#[doc = "Field `RSPTP` reader - Response Type Select"]
155pub type RSPTP_R = crate::FieldReader<u8, RSPTP_A>;
156#[doc = "Response Type Select\n\nValue on reset: 0"]
157#[derive(Clone, Copy, Debug, PartialEq, Eq)]
158#[repr(u8)]
159pub enum RSPTP_A {
160    #[doc = "0: Normal mode Depending on the command, the response type and transfer method are selected in the ACMD\\[1:0\\]
161and CMDIDX\\[5:0\\]
162bits. At this time, the values for bits 15 to 11 in this register are invalid."]
163    _000 = 0,
164    #[doc = "3: Extended mode and no response"]
165    _011 = 3,
166    #[doc = "4: Extended mode and R1, R5, R6, or R7 response"]
167    _100 = 4,
168    #[doc = "5: Extended mode and R1b response"]
169    _101 = 5,
170    #[doc = "6: Extended mode and R2 response"]
171    _110 = 6,
172    #[doc = "7: Extended mode and R3 or R4 response"]
173    _111 = 7,
174}
175impl From<RSPTP_A> for u8 {
176    #[inline(always)]
177    fn from(variant: RSPTP_A) -> Self {
178        variant as _
179    }
180}
181impl RSPTP_R {
182    #[doc = "Get enumerated values variant"]
183    #[inline(always)]
184    pub fn variant(&self) -> Option<RSPTP_A> {
185        match self.bits {
186            0 => Some(RSPTP_A::_000),
187            3 => Some(RSPTP_A::_011),
188            4 => Some(RSPTP_A::_100),
189            5 => Some(RSPTP_A::_101),
190            6 => Some(RSPTP_A::_110),
191            7 => Some(RSPTP_A::_111),
192            _ => None,
193        }
194    }
195    #[doc = "Checks if the value of the field is `_000`"]
196    #[inline(always)]
197    pub fn is_000(&self) -> bool {
198        *self == RSPTP_A::_000
199    }
200    #[doc = "Checks if the value of the field is `_011`"]
201    #[inline(always)]
202    pub fn is_011(&self) -> bool {
203        *self == RSPTP_A::_011
204    }
205    #[doc = "Checks if the value of the field is `_100`"]
206    #[inline(always)]
207    pub fn is_100(&self) -> bool {
208        *self == RSPTP_A::_100
209    }
210    #[doc = "Checks if the value of the field is `_101`"]
211    #[inline(always)]
212    pub fn is_101(&self) -> bool {
213        *self == RSPTP_A::_101
214    }
215    #[doc = "Checks if the value of the field is `_110`"]
216    #[inline(always)]
217    pub fn is_110(&self) -> bool {
218        *self == RSPTP_A::_110
219    }
220    #[doc = "Checks if the value of the field is `_111`"]
221    #[inline(always)]
222    pub fn is_111(&self) -> bool {
223        *self == RSPTP_A::_111
224    }
225}
226#[doc = "Field `RSPTP` writer - Response Type Select"]
227pub type RSPTP_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SD_CMD_SPEC, u8, RSPTP_A, 3, O>;
228impl<'a, const O: u8> RSPTP_W<'a, O> {
229    #[doc = "Normal mode Depending on the command, the response type and transfer method are selected in the ACMD\\[1:0\\]
230and CMDIDX\\[5:0\\]
231bits. At this time, the values for bits 15 to 11 in this register are invalid."]
232    #[inline(always)]
233    pub fn _000(self) -> &'a mut W {
234        self.variant(RSPTP_A::_000)
235    }
236    #[doc = "Extended mode and no response"]
237    #[inline(always)]
238    pub fn _011(self) -> &'a mut W {
239        self.variant(RSPTP_A::_011)
240    }
241    #[doc = "Extended mode and R1, R5, R6, or R7 response"]
242    #[inline(always)]
243    pub fn _100(self) -> &'a mut W {
244        self.variant(RSPTP_A::_100)
245    }
246    #[doc = "Extended mode and R1b response"]
247    #[inline(always)]
248    pub fn _101(self) -> &'a mut W {
249        self.variant(RSPTP_A::_101)
250    }
251    #[doc = "Extended mode and R2 response"]
252    #[inline(always)]
253    pub fn _110(self) -> &'a mut W {
254        self.variant(RSPTP_A::_110)
255    }
256    #[doc = "Extended mode and R3 or R4 response"]
257    #[inline(always)]
258    pub fn _111(self) -> &'a mut W {
259        self.variant(RSPTP_A::_111)
260    }
261}
262#[doc = "Field `CMDTP` reader - Data Transfer Select"]
263pub type CMDTP_R = crate::BitReader<CMDTP_A>;
264#[doc = "Data Transfer Select\n\nValue on reset: 0"]
265#[derive(Clone, Copy, Debug, PartialEq, Eq)]
266pub enum CMDTP_A {
267    #[doc = "0: Do not include data transfer (bc, bcr, or ac) in command"]
268    _0 = 0,
269    #[doc = "1: Include data transfer (adtc) in command"]
270    _1 = 1,
271}
272impl From<CMDTP_A> for bool {
273    #[inline(always)]
274    fn from(variant: CMDTP_A) -> Self {
275        variant as u8 != 0
276    }
277}
278impl CMDTP_R {
279    #[doc = "Get enumerated values variant"]
280    #[inline(always)]
281    pub fn variant(&self) -> CMDTP_A {
282        match self.bits {
283            false => CMDTP_A::_0,
284            true => CMDTP_A::_1,
285        }
286    }
287    #[doc = "Checks if the value of the field is `_0`"]
288    #[inline(always)]
289    pub fn is_0(&self) -> bool {
290        *self == CMDTP_A::_0
291    }
292    #[doc = "Checks if the value of the field is `_1`"]
293    #[inline(always)]
294    pub fn is_1(&self) -> bool {
295        *self == CMDTP_A::_1
296    }
297}
298#[doc = "Field `CMDTP` writer - Data Transfer Select"]
299pub type CMDTP_W<'a, const O: u8> = crate::BitWriter<'a, u32, SD_CMD_SPEC, CMDTP_A, O>;
300impl<'a, const O: u8> CMDTP_W<'a, O> {
301    #[doc = "Do not include data transfer (bc, bcr, or ac) in command"]
302    #[inline(always)]
303    pub fn _0(self) -> &'a mut W {
304        self.variant(CMDTP_A::_0)
305    }
306    #[doc = "Include data transfer (adtc) in command"]
307    #[inline(always)]
308    pub fn _1(self) -> &'a mut W {
309        self.variant(CMDTP_A::_1)
310    }
311}
312#[doc = "Field `CMDRW` reader - Data Transfer Direction Select"]
313pub type CMDRW_R = crate::BitReader<CMDRW_A>;
314#[doc = "Data Transfer Direction Select\n\nValue on reset: 0"]
315#[derive(Clone, Copy, Debug, PartialEq, Eq)]
316pub enum CMDRW_A {
317    #[doc = "0: Write (SD/MMC Host Interface → SD card/MMC)"]
318    _0 = 0,
319    #[doc = "1: Read (SD/MMC Host Interface ← SD card/MMC)"]
320    _1 = 1,
321}
322impl From<CMDRW_A> for bool {
323    #[inline(always)]
324    fn from(variant: CMDRW_A) -> Self {
325        variant as u8 != 0
326    }
327}
328impl CMDRW_R {
329    #[doc = "Get enumerated values variant"]
330    #[inline(always)]
331    pub fn variant(&self) -> CMDRW_A {
332        match self.bits {
333            false => CMDRW_A::_0,
334            true => CMDRW_A::_1,
335        }
336    }
337    #[doc = "Checks if the value of the field is `_0`"]
338    #[inline(always)]
339    pub fn is_0(&self) -> bool {
340        *self == CMDRW_A::_0
341    }
342    #[doc = "Checks if the value of the field is `_1`"]
343    #[inline(always)]
344    pub fn is_1(&self) -> bool {
345        *self == CMDRW_A::_1
346    }
347}
348#[doc = "Field `CMDRW` writer - Data Transfer Direction Select"]
349pub type CMDRW_W<'a, const O: u8> = crate::BitWriter<'a, u32, SD_CMD_SPEC, CMDRW_A, O>;
350impl<'a, const O: u8> CMDRW_W<'a, O> {
351    #[doc = "Write (SD/MMC Host Interface → SD card/MMC)"]
352    #[inline(always)]
353    pub fn _0(self) -> &'a mut W {
354        self.variant(CMDRW_A::_0)
355    }
356    #[doc = "Read (SD/MMC Host Interface ← SD card/MMC)"]
357    #[inline(always)]
358    pub fn _1(self) -> &'a mut W {
359        self.variant(CMDRW_A::_1)
360    }
361}
362#[doc = "Field `TRSTP` reader - Block Transfer Select"]
363pub type TRSTP_R = crate::BitReader<TRSTP_A>;
364#[doc = "Block Transfer Select\n\nValue on reset: 0"]
365#[derive(Clone, Copy, Debug, PartialEq, Eq)]
366pub enum TRSTP_A {
367    #[doc = "0: Single block transfer"]
368    _0 = 0,
369    #[doc = "1: Multiple blocks transfer"]
370    _1 = 1,
371}
372impl From<TRSTP_A> for bool {
373    #[inline(always)]
374    fn from(variant: TRSTP_A) -> Self {
375        variant as u8 != 0
376    }
377}
378impl TRSTP_R {
379    #[doc = "Get enumerated values variant"]
380    #[inline(always)]
381    pub fn variant(&self) -> TRSTP_A {
382        match self.bits {
383            false => TRSTP_A::_0,
384            true => TRSTP_A::_1,
385        }
386    }
387    #[doc = "Checks if the value of the field is `_0`"]
388    #[inline(always)]
389    pub fn is_0(&self) -> bool {
390        *self == TRSTP_A::_0
391    }
392    #[doc = "Checks if the value of the field is `_1`"]
393    #[inline(always)]
394    pub fn is_1(&self) -> bool {
395        *self == TRSTP_A::_1
396    }
397}
398#[doc = "Field `TRSTP` writer - Block Transfer Select"]
399pub type TRSTP_W<'a, const O: u8> = crate::BitWriter<'a, u32, SD_CMD_SPEC, TRSTP_A, O>;
400impl<'a, const O: u8> TRSTP_W<'a, O> {
401    #[doc = "Single block transfer"]
402    #[inline(always)]
403    pub fn _0(self) -> &'a mut W {
404        self.variant(TRSTP_A::_0)
405    }
406    #[doc = "Multiple blocks transfer"]
407    #[inline(always)]
408    pub fn _1(self) -> &'a mut W {
409        self.variant(TRSTP_A::_1)
410    }
411}
412#[doc = "Field `CMD12AT` reader - CMD12 Automatic Issue Select"]
413pub type CMD12AT_R = crate::FieldReader<u8, CMD12AT_A>;
414#[doc = "CMD12 Automatic Issue Select\n\nValue on reset: 0"]
415#[derive(Clone, Copy, Debug, PartialEq, Eq)]
416#[repr(u8)]
417pub enum CMD12AT_A {
418    #[doc = "0: Automatically issue CMD12 during multiblock transfer"]
419    _00 = 0,
420    #[doc = "1: Do not automatically issue CMD12 during multiblock transfer"]
421    _01 = 1,
422}
423impl From<CMD12AT_A> for u8 {
424    #[inline(always)]
425    fn from(variant: CMD12AT_A) -> Self {
426        variant as _
427    }
428}
429impl CMD12AT_R {
430    #[doc = "Get enumerated values variant"]
431    #[inline(always)]
432    pub fn variant(&self) -> Option<CMD12AT_A> {
433        match self.bits {
434            0 => Some(CMD12AT_A::_00),
435            1 => Some(CMD12AT_A::_01),
436            _ => None,
437        }
438    }
439    #[doc = "Checks if the value of the field is `_00`"]
440    #[inline(always)]
441    pub fn is_00(&self) -> bool {
442        *self == CMD12AT_A::_00
443    }
444    #[doc = "Checks if the value of the field is `_01`"]
445    #[inline(always)]
446    pub fn is_01(&self) -> bool {
447        *self == CMD12AT_A::_01
448    }
449}
450#[doc = "Field `CMD12AT` writer - CMD12 Automatic Issue Select"]
451pub type CMD12AT_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SD_CMD_SPEC, u8, CMD12AT_A, 2, O>;
452impl<'a, const O: u8> CMD12AT_W<'a, O> {
453    #[doc = "Automatically issue CMD12 during multiblock transfer"]
454    #[inline(always)]
455    pub fn _00(self) -> &'a mut W {
456        self.variant(CMD12AT_A::_00)
457    }
458    #[doc = "Do not automatically issue CMD12 during multiblock transfer"]
459    #[inline(always)]
460    pub fn _01(self) -> &'a mut W {
461        self.variant(CMD12AT_A::_01)
462    }
463}
464impl R {
465    #[doc = "Bits 0:5 - Command Index Field Value Select"]
466    #[inline(always)]
467    pub fn cmdidx(&self) -> CMDIDX_R {
468        CMDIDX_R::new((self.bits & 0x3f) as u8)
469    }
470    #[doc = "Bits 6:7 - Command Type Select"]
471    #[inline(always)]
472    pub fn acmd(&self) -> ACMD_R {
473        ACMD_R::new(((self.bits >> 6) & 3) as u8)
474    }
475    #[doc = "Bits 8:10 - Response Type Select"]
476    #[inline(always)]
477    pub fn rsptp(&self) -> RSPTP_R {
478        RSPTP_R::new(((self.bits >> 8) & 7) as u8)
479    }
480    #[doc = "Bit 11 - Data Transfer Select"]
481    #[inline(always)]
482    pub fn cmdtp(&self) -> CMDTP_R {
483        CMDTP_R::new(((self.bits >> 11) & 1) != 0)
484    }
485    #[doc = "Bit 12 - Data Transfer Direction Select"]
486    #[inline(always)]
487    pub fn cmdrw(&self) -> CMDRW_R {
488        CMDRW_R::new(((self.bits >> 12) & 1) != 0)
489    }
490    #[doc = "Bit 13 - Block Transfer Select"]
491    #[inline(always)]
492    pub fn trstp(&self) -> TRSTP_R {
493        TRSTP_R::new(((self.bits >> 13) & 1) != 0)
494    }
495    #[doc = "Bits 14:15 - CMD12 Automatic Issue Select"]
496    #[inline(always)]
497    pub fn cmd12at(&self) -> CMD12AT_R {
498        CMD12AT_R::new(((self.bits >> 14) & 3) as u8)
499    }
500}
501impl W {
502    #[doc = "Bits 0:5 - Command Index Field Value Select"]
503    #[inline(always)]
504    #[must_use]
505    pub fn cmdidx(&mut self) -> CMDIDX_W<0> {
506        CMDIDX_W::new(self)
507    }
508    #[doc = "Bits 6:7 - Command Type Select"]
509    #[inline(always)]
510    #[must_use]
511    pub fn acmd(&mut self) -> ACMD_W<6> {
512        ACMD_W::new(self)
513    }
514    #[doc = "Bits 8:10 - Response Type Select"]
515    #[inline(always)]
516    #[must_use]
517    pub fn rsptp(&mut self) -> RSPTP_W<8> {
518        RSPTP_W::new(self)
519    }
520    #[doc = "Bit 11 - Data Transfer Select"]
521    #[inline(always)]
522    #[must_use]
523    pub fn cmdtp(&mut self) -> CMDTP_W<11> {
524        CMDTP_W::new(self)
525    }
526    #[doc = "Bit 12 - Data Transfer Direction Select"]
527    #[inline(always)]
528    #[must_use]
529    pub fn cmdrw(&mut self) -> CMDRW_W<12> {
530        CMDRW_W::new(self)
531    }
532    #[doc = "Bit 13 - Block Transfer Select"]
533    #[inline(always)]
534    #[must_use]
535    pub fn trstp(&mut self) -> TRSTP_W<13> {
536        TRSTP_W::new(self)
537    }
538    #[doc = "Bits 14:15 - CMD12 Automatic Issue Select"]
539    #[inline(always)]
540    #[must_use]
541    pub fn cmd12at(&mut self) -> CMD12AT_W<14> {
542        CMD12AT_W::new(self)
543    }
544    #[doc = "Writes raw bits to the register."]
545    #[inline(always)]
546    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
547        self.0.bits(bits);
548        self
549    }
550}
551#[doc = "Command Type Register\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 [sd_cmd](index.html) module"]
552pub struct SD_CMD_SPEC;
553impl crate::RegisterSpec for SD_CMD_SPEC {
554    type Ux = u32;
555}
556#[doc = "`read()` method returns [sd_cmd::R](R) reader structure"]
557impl crate::Readable for SD_CMD_SPEC {
558    type Reader = R;
559}
560#[doc = "`write(|w| ..)` method takes [sd_cmd::W](W) writer structure"]
561impl crate::Writable for SD_CMD_SPEC {
562    type Writer = W;
563    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
564    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
565}
566#[doc = "`reset()` method sets SD_CMD to value 0"]
567impl crate::Resettable for SD_CMD_SPEC {
568    const RESET_VALUE: Self::Ux = 0;
569}