atsam4sd32c_pac/smc/
mode0.rs

1#[doc = "Register `MODE0` reader"]
2pub struct R(crate::R<MODE0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MODE0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MODE0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MODE0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MODE0` writer"]
17pub struct W(crate::W<MODE0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MODE0_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<MODE0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MODE0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `READ_MODE` reader - "]
38pub type READ_MODE_R = crate::BitReader<bool>;
39#[doc = "Field `READ_MODE` writer - "]
40pub type READ_MODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE0_SPEC, bool, O>;
41#[doc = "Field `WRITE_MODE` reader - "]
42pub type WRITE_MODE_R = crate::BitReader<bool>;
43#[doc = "Field `WRITE_MODE` writer - "]
44pub type WRITE_MODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE0_SPEC, bool, O>;
45#[doc = "Field `EXNW_MODE` reader - NWAIT Mode"]
46pub type EXNW_MODE_R = crate::FieldReader<u8, EXNW_MODE_A>;
47#[doc = "NWAIT Mode\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49#[repr(u8)]
50pub enum EXNW_MODE_A {
51    #[doc = "0: Disabled"]
52    DISABLED = 0,
53    #[doc = "2: Frozen Mode"]
54    FROZEN = 2,
55    #[doc = "3: Ready Mode"]
56    READY = 3,
57}
58impl From<EXNW_MODE_A> for u8 {
59    #[inline(always)]
60    fn from(variant: EXNW_MODE_A) -> Self {
61        variant as _
62    }
63}
64impl EXNW_MODE_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<EXNW_MODE_A> {
68        match self.bits {
69            0 => Some(EXNW_MODE_A::DISABLED),
70            2 => Some(EXNW_MODE_A::FROZEN),
71            3 => Some(EXNW_MODE_A::READY),
72            _ => None,
73        }
74    }
75    #[doc = "Checks if the value of the field is `DISABLED`"]
76    #[inline(always)]
77    pub fn is_disabled(&self) -> bool {
78        *self == EXNW_MODE_A::DISABLED
79    }
80    #[doc = "Checks if the value of the field is `FROZEN`"]
81    #[inline(always)]
82    pub fn is_frozen(&self) -> bool {
83        *self == EXNW_MODE_A::FROZEN
84    }
85    #[doc = "Checks if the value of the field is `READY`"]
86    #[inline(always)]
87    pub fn is_ready(&self) -> bool {
88        *self == EXNW_MODE_A::READY
89    }
90}
91#[doc = "Field `EXNW_MODE` writer - NWAIT Mode"]
92pub type EXNW_MODE_W<'a, const O: u8> =
93    crate::FieldWriter<'a, u32, MODE0_SPEC, u8, EXNW_MODE_A, 2, O>;
94impl<'a, const O: u8> EXNW_MODE_W<'a, O> {
95    #[doc = "Disabled"]
96    #[inline(always)]
97    pub fn disabled(self) -> &'a mut W {
98        self.variant(EXNW_MODE_A::DISABLED)
99    }
100    #[doc = "Frozen Mode"]
101    #[inline(always)]
102    pub fn frozen(self) -> &'a mut W {
103        self.variant(EXNW_MODE_A::FROZEN)
104    }
105    #[doc = "Ready Mode"]
106    #[inline(always)]
107    pub fn ready(self) -> &'a mut W {
108        self.variant(EXNW_MODE_A::READY)
109    }
110}
111#[doc = "Field `TDF_CYCLES` reader - Data Float Time"]
112pub type TDF_CYCLES_R = crate::FieldReader<u8, u8>;
113#[doc = "Field `TDF_CYCLES` writer - Data Float Time"]
114pub type TDF_CYCLES_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MODE0_SPEC, u8, u8, 4, O>;
115#[doc = "Field `TDF_MODE` reader - TDF Optimization"]
116pub type TDF_MODE_R = crate::BitReader<bool>;
117#[doc = "Field `TDF_MODE` writer - TDF Optimization"]
118pub type TDF_MODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE0_SPEC, bool, O>;
119#[doc = "Field `PMEN` reader - Page Mode Enabled"]
120pub type PMEN_R = crate::BitReader<bool>;
121#[doc = "Field `PMEN` writer - Page Mode Enabled"]
122pub type PMEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE0_SPEC, bool, O>;
123#[doc = "Field `PS` reader - Page Size"]
124pub type PS_R = crate::FieldReader<u8, PS_A>;
125#[doc = "Page Size\n\nValue on reset: 1"]
126#[derive(Clone, Copy, Debug, PartialEq, Eq)]
127#[repr(u8)]
128pub enum PS_A {
129    #[doc = "0: 4-byte page"]
130    _4_BYTE = 0,
131    #[doc = "1: 8-byte page"]
132    _8_BYTE = 1,
133    #[doc = "2: 16-byte page"]
134    _16_BYTE = 2,
135    #[doc = "3: 32-byte page"]
136    _32_BYTE = 3,
137}
138impl From<PS_A> for u8 {
139    #[inline(always)]
140    fn from(variant: PS_A) -> Self {
141        variant as _
142    }
143}
144impl PS_R {
145    #[doc = "Get enumerated values variant"]
146    #[inline(always)]
147    pub fn variant(&self) -> PS_A {
148        match self.bits {
149            0 => PS_A::_4_BYTE,
150            1 => PS_A::_8_BYTE,
151            2 => PS_A::_16_BYTE,
152            3 => PS_A::_32_BYTE,
153            _ => unreachable!(),
154        }
155    }
156    #[doc = "Checks if the value of the field is `_4_BYTE`"]
157    #[inline(always)]
158    pub fn is_4_byte(&self) -> bool {
159        *self == PS_A::_4_BYTE
160    }
161    #[doc = "Checks if the value of the field is `_8_BYTE`"]
162    #[inline(always)]
163    pub fn is_8_byte(&self) -> bool {
164        *self == PS_A::_8_BYTE
165    }
166    #[doc = "Checks if the value of the field is `_16_BYTE`"]
167    #[inline(always)]
168    pub fn is_16_byte(&self) -> bool {
169        *self == PS_A::_16_BYTE
170    }
171    #[doc = "Checks if the value of the field is `_32_BYTE`"]
172    #[inline(always)]
173    pub fn is_32_byte(&self) -> bool {
174        *self == PS_A::_32_BYTE
175    }
176}
177#[doc = "Field `PS` writer - Page Size"]
178pub type PS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, MODE0_SPEC, u8, PS_A, 2, O>;
179impl<'a, const O: u8> PS_W<'a, O> {
180    #[doc = "4-byte page"]
181    #[inline(always)]
182    pub fn _4_byte(self) -> &'a mut W {
183        self.variant(PS_A::_4_BYTE)
184    }
185    #[doc = "8-byte page"]
186    #[inline(always)]
187    pub fn _8_byte(self) -> &'a mut W {
188        self.variant(PS_A::_8_BYTE)
189    }
190    #[doc = "16-byte page"]
191    #[inline(always)]
192    pub fn _16_byte(self) -> &'a mut W {
193        self.variant(PS_A::_16_BYTE)
194    }
195    #[doc = "32-byte page"]
196    #[inline(always)]
197    pub fn _32_byte(self) -> &'a mut W {
198        self.variant(PS_A::_32_BYTE)
199    }
200}
201impl R {
202    #[doc = "Bit 0"]
203    #[inline(always)]
204    pub fn read_mode(&self) -> READ_MODE_R {
205        READ_MODE_R::new((self.bits & 1) != 0)
206    }
207    #[doc = "Bit 1"]
208    #[inline(always)]
209    pub fn write_mode(&self) -> WRITE_MODE_R {
210        WRITE_MODE_R::new(((self.bits >> 1) & 1) != 0)
211    }
212    #[doc = "Bits 4:5 - NWAIT Mode"]
213    #[inline(always)]
214    pub fn exnw_mode(&self) -> EXNW_MODE_R {
215        EXNW_MODE_R::new(((self.bits >> 4) & 3) as u8)
216    }
217    #[doc = "Bits 16:19 - Data Float Time"]
218    #[inline(always)]
219    pub fn tdf_cycles(&self) -> TDF_CYCLES_R {
220        TDF_CYCLES_R::new(((self.bits >> 16) & 0x0f) as u8)
221    }
222    #[doc = "Bit 20 - TDF Optimization"]
223    #[inline(always)]
224    pub fn tdf_mode(&self) -> TDF_MODE_R {
225        TDF_MODE_R::new(((self.bits >> 20) & 1) != 0)
226    }
227    #[doc = "Bit 24 - Page Mode Enabled"]
228    #[inline(always)]
229    pub fn pmen(&self) -> PMEN_R {
230        PMEN_R::new(((self.bits >> 24) & 1) != 0)
231    }
232    #[doc = "Bits 28:29 - Page Size"]
233    #[inline(always)]
234    pub fn ps(&self) -> PS_R {
235        PS_R::new(((self.bits >> 28) & 3) as u8)
236    }
237}
238impl W {
239    #[doc = "Bit 0"]
240    #[inline(always)]
241    #[must_use]
242    pub fn read_mode(&mut self) -> READ_MODE_W<0> {
243        READ_MODE_W::new(self)
244    }
245    #[doc = "Bit 1"]
246    #[inline(always)]
247    #[must_use]
248    pub fn write_mode(&mut self) -> WRITE_MODE_W<1> {
249        WRITE_MODE_W::new(self)
250    }
251    #[doc = "Bits 4:5 - NWAIT Mode"]
252    #[inline(always)]
253    #[must_use]
254    pub fn exnw_mode(&mut self) -> EXNW_MODE_W<4> {
255        EXNW_MODE_W::new(self)
256    }
257    #[doc = "Bits 16:19 - Data Float Time"]
258    #[inline(always)]
259    #[must_use]
260    pub fn tdf_cycles(&mut self) -> TDF_CYCLES_W<16> {
261        TDF_CYCLES_W::new(self)
262    }
263    #[doc = "Bit 20 - TDF Optimization"]
264    #[inline(always)]
265    #[must_use]
266    pub fn tdf_mode(&mut self) -> TDF_MODE_W<20> {
267        TDF_MODE_W::new(self)
268    }
269    #[doc = "Bit 24 - Page Mode Enabled"]
270    #[inline(always)]
271    #[must_use]
272    pub fn pmen(&mut self) -> PMEN_W<24> {
273        PMEN_W::new(self)
274    }
275    #[doc = "Bits 28:29 - Page Size"]
276    #[inline(always)]
277    #[must_use]
278    pub fn ps(&mut self) -> PS_W<28> {
279        PS_W::new(self)
280    }
281    #[doc = "Writes raw bits to the register."]
282    #[inline(always)]
283    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
284        self.0.bits(bits);
285        self
286    }
287}
288#[doc = "SMC Mode Register (CS_number = 0)\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 [mode0](index.html) module"]
289pub struct MODE0_SPEC;
290impl crate::RegisterSpec for MODE0_SPEC {
291    type Ux = u32;
292}
293#[doc = "`read()` method returns [mode0::R](R) reader structure"]
294impl crate::Readable for MODE0_SPEC {
295    type Reader = R;
296}
297#[doc = "`write(|w| ..)` method takes [mode0::W](W) writer structure"]
298impl crate::Writable for MODE0_SPEC {
299    type Writer = W;
300    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
301    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
302}
303#[doc = "`reset()` method sets MODE0 to value 0x1000_0003"]
304impl crate::Resettable for MODE0_SPEC {
305    const RESET_VALUE: Self::Ux = 0x1000_0003;
306}