atsam4e8e_pac/hsmci/
sdcr.rs

1#[doc = "Register `SDCR` reader"]
2pub struct R(crate::R<SDCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SDCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SDCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SDCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SDCR` writer"]
17pub struct W(crate::W<SDCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SDCR_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<SDCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SDCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SDCSEL` reader - SDCard/SDIO Slot"]
38pub type SDCSEL_R = crate::FieldReader<u8, SDCSEL_A>;
39#[doc = "SDCard/SDIO Slot\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum SDCSEL_A {
43    #[doc = "0: Slot A is selected."]
44    SLOTA = 0,
45    #[doc = "1: -"]
46    SLOTB = 1,
47    #[doc = "2: -"]
48    SLOTC = 2,
49    #[doc = "3: -"]
50    SLOTD = 3,
51}
52impl From<SDCSEL_A> for u8 {
53    #[inline(always)]
54    fn from(variant: SDCSEL_A) -> Self {
55        variant as _
56    }
57}
58impl SDCSEL_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> SDCSEL_A {
62        match self.bits {
63            0 => SDCSEL_A::SLOTA,
64            1 => SDCSEL_A::SLOTB,
65            2 => SDCSEL_A::SLOTC,
66            3 => SDCSEL_A::SLOTD,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `SLOTA`"]
71    #[inline(always)]
72    pub fn is_slota(&self) -> bool {
73        *self == SDCSEL_A::SLOTA
74    }
75    #[doc = "Checks if the value of the field is `SLOTB`"]
76    #[inline(always)]
77    pub fn is_slotb(&self) -> bool {
78        *self == SDCSEL_A::SLOTB
79    }
80    #[doc = "Checks if the value of the field is `SLOTC`"]
81    #[inline(always)]
82    pub fn is_slotc(&self) -> bool {
83        *self == SDCSEL_A::SLOTC
84    }
85    #[doc = "Checks if the value of the field is `SLOTD`"]
86    #[inline(always)]
87    pub fn is_slotd(&self) -> bool {
88        *self == SDCSEL_A::SLOTD
89    }
90}
91#[doc = "Field `SDCSEL` writer - SDCard/SDIO Slot"]
92pub type SDCSEL_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, SDCR_SPEC, u8, SDCSEL_A, 2, O>;
93impl<'a, const O: u8> SDCSEL_W<'a, O> {
94    #[doc = "Slot A is selected."]
95    #[inline(always)]
96    pub fn slota(self) -> &'a mut W {
97        self.variant(SDCSEL_A::SLOTA)
98    }
99    #[doc = "-"]
100    #[inline(always)]
101    pub fn slotb(self) -> &'a mut W {
102        self.variant(SDCSEL_A::SLOTB)
103    }
104    #[doc = "-"]
105    #[inline(always)]
106    pub fn slotc(self) -> &'a mut W {
107        self.variant(SDCSEL_A::SLOTC)
108    }
109    #[doc = "-"]
110    #[inline(always)]
111    pub fn slotd(self) -> &'a mut W {
112        self.variant(SDCSEL_A::SLOTD)
113    }
114}
115#[doc = "Field `SDCBUS` reader - SDCard/SDIO Bus Width"]
116pub type SDCBUS_R = crate::FieldReader<u8, SDCBUS_A>;
117#[doc = "SDCard/SDIO Bus Width\n\nValue on reset: 0"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119#[repr(u8)]
120pub enum SDCBUS_A {
121    #[doc = "0: 1 bit"]
122    _1 = 0,
123    #[doc = "2: 4 bits"]
124    _4 = 2,
125    #[doc = "3: 8 bits"]
126    _8 = 3,
127}
128impl From<SDCBUS_A> for u8 {
129    #[inline(always)]
130    fn from(variant: SDCBUS_A) -> Self {
131        variant as _
132    }
133}
134impl SDCBUS_R {
135    #[doc = "Get enumerated values variant"]
136    #[inline(always)]
137    pub fn variant(&self) -> Option<SDCBUS_A> {
138        match self.bits {
139            0 => Some(SDCBUS_A::_1),
140            2 => Some(SDCBUS_A::_4),
141            3 => Some(SDCBUS_A::_8),
142            _ => None,
143        }
144    }
145    #[doc = "Checks if the value of the field is `_1`"]
146    #[inline(always)]
147    pub fn is_1(&self) -> bool {
148        *self == SDCBUS_A::_1
149    }
150    #[doc = "Checks if the value of the field is `_4`"]
151    #[inline(always)]
152    pub fn is_4(&self) -> bool {
153        *self == SDCBUS_A::_4
154    }
155    #[doc = "Checks if the value of the field is `_8`"]
156    #[inline(always)]
157    pub fn is_8(&self) -> bool {
158        *self == SDCBUS_A::_8
159    }
160}
161#[doc = "Field `SDCBUS` writer - SDCard/SDIO Bus Width"]
162pub type SDCBUS_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SDCR_SPEC, u8, SDCBUS_A, 2, O>;
163impl<'a, const O: u8> SDCBUS_W<'a, O> {
164    #[doc = "1 bit"]
165    #[inline(always)]
166    pub fn _1(self) -> &'a mut W {
167        self.variant(SDCBUS_A::_1)
168    }
169    #[doc = "4 bits"]
170    #[inline(always)]
171    pub fn _4(self) -> &'a mut W {
172        self.variant(SDCBUS_A::_4)
173    }
174    #[doc = "8 bits"]
175    #[inline(always)]
176    pub fn _8(self) -> &'a mut W {
177        self.variant(SDCBUS_A::_8)
178    }
179}
180impl R {
181    #[doc = "Bits 0:1 - SDCard/SDIO Slot"]
182    #[inline(always)]
183    pub fn sdcsel(&self) -> SDCSEL_R {
184        SDCSEL_R::new((self.bits & 3) as u8)
185    }
186    #[doc = "Bits 6:7 - SDCard/SDIO Bus Width"]
187    #[inline(always)]
188    pub fn sdcbus(&self) -> SDCBUS_R {
189        SDCBUS_R::new(((self.bits >> 6) & 3) as u8)
190    }
191}
192impl W {
193    #[doc = "Bits 0:1 - SDCard/SDIO Slot"]
194    #[inline(always)]
195    #[must_use]
196    pub fn sdcsel(&mut self) -> SDCSEL_W<0> {
197        SDCSEL_W::new(self)
198    }
199    #[doc = "Bits 6:7 - SDCard/SDIO Bus Width"]
200    #[inline(always)]
201    #[must_use]
202    pub fn sdcbus(&mut self) -> SDCBUS_W<6> {
203        SDCBUS_W::new(self)
204    }
205    #[doc = "Writes raw bits to the register."]
206    #[inline(always)]
207    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
208        self.0.bits(bits);
209        self
210    }
211}
212#[doc = "SD/SDIO Card 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 [sdcr](index.html) module"]
213pub struct SDCR_SPEC;
214impl crate::RegisterSpec for SDCR_SPEC {
215    type Ux = u32;
216}
217#[doc = "`read()` method returns [sdcr::R](R) reader structure"]
218impl crate::Readable for SDCR_SPEC {
219    type Reader = R;
220}
221#[doc = "`write(|w| ..)` method takes [sdcr::W](W) writer structure"]
222impl crate::Writable for SDCR_SPEC {
223    type Writer = W;
224    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
225    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
226}
227#[doc = "`reset()` method sets SDCR to value 0"]
228impl crate::Resettable for SDCR_SPEC {
229    const RESET_VALUE: Self::Ux = 0;
230}