atsam3s4c/smc/
mode1.rs

1#[doc = "Register `MODE1` reader"]
2pub type R = crate::R<Mode1Spec>;
3#[doc = "Register `MODE1` writer"]
4pub type W = crate::W<Mode1Spec>;
5#[doc = "Field `READ_MODE` reader - "]
6pub type ReadModeR = crate::BitReader;
7#[doc = "Field `READ_MODE` writer - "]
8pub type ReadModeW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `WRITE_MODE` reader - "]
10pub type WriteModeR = crate::BitReader;
11#[doc = "Field `WRITE_MODE` writer - "]
12pub type WriteModeW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "NWAIT Mode\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15#[repr(u8)]
16pub enum ExnwMode {
17    #[doc = "0: Disabled"]
18    Disabled = 0,
19    #[doc = "2: Frozen Mode"]
20    Frozen = 2,
21    #[doc = "3: Ready Mode"]
22    Ready = 3,
23}
24impl From<ExnwMode> for u8 {
25    #[inline(always)]
26    fn from(variant: ExnwMode) -> Self {
27        variant as _
28    }
29}
30impl crate::FieldSpec for ExnwMode {
31    type Ux = u8;
32}
33impl crate::IsEnum for ExnwMode {}
34#[doc = "Field `EXNW_MODE` reader - NWAIT Mode"]
35pub type ExnwModeR = crate::FieldReader<ExnwMode>;
36impl ExnwModeR {
37    #[doc = "Get enumerated values variant"]
38    #[inline(always)]
39    pub const fn variant(&self) -> Option<ExnwMode> {
40        match self.bits {
41            0 => Some(ExnwMode::Disabled),
42            2 => Some(ExnwMode::Frozen),
43            3 => Some(ExnwMode::Ready),
44            _ => None,
45        }
46    }
47    #[doc = "Disabled"]
48    #[inline(always)]
49    pub fn is_disabled(&self) -> bool {
50        *self == ExnwMode::Disabled
51    }
52    #[doc = "Frozen Mode"]
53    #[inline(always)]
54    pub fn is_frozen(&self) -> bool {
55        *self == ExnwMode::Frozen
56    }
57    #[doc = "Ready Mode"]
58    #[inline(always)]
59    pub fn is_ready(&self) -> bool {
60        *self == ExnwMode::Ready
61    }
62}
63#[doc = "Field `EXNW_MODE` writer - NWAIT Mode"]
64pub type ExnwModeW<'a, REG> = crate::FieldWriter<'a, REG, 2, ExnwMode>;
65impl<'a, REG> ExnwModeW<'a, REG>
66where
67    REG: crate::Writable + crate::RegisterSpec,
68    REG::Ux: From<u8>,
69{
70    #[doc = "Disabled"]
71    #[inline(always)]
72    pub fn disabled(self) -> &'a mut crate::W<REG> {
73        self.variant(ExnwMode::Disabled)
74    }
75    #[doc = "Frozen Mode"]
76    #[inline(always)]
77    pub fn frozen(self) -> &'a mut crate::W<REG> {
78        self.variant(ExnwMode::Frozen)
79    }
80    #[doc = "Ready Mode"]
81    #[inline(always)]
82    pub fn ready(self) -> &'a mut crate::W<REG> {
83        self.variant(ExnwMode::Ready)
84    }
85}
86#[doc = "Field `TDF_CYCLES` reader - Data Float Time"]
87pub type TdfCyclesR = crate::FieldReader;
88#[doc = "Field `TDF_CYCLES` writer - Data Float Time"]
89pub type TdfCyclesW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
90#[doc = "Field `TDF_MODE` reader - TDF Optimization"]
91pub type TdfModeR = crate::BitReader;
92#[doc = "Field `TDF_MODE` writer - TDF Optimization"]
93pub type TdfModeW<'a, REG> = crate::BitWriter<'a, REG>;
94#[doc = "Field `PMEN` reader - Page Mode Enabled"]
95pub type PmenR = crate::BitReader;
96#[doc = "Field `PMEN` writer - Page Mode Enabled"]
97pub type PmenW<'a, REG> = crate::BitWriter<'a, REG>;
98#[doc = "Page Size\n\nValue on reset: 1"]
99#[derive(Clone, Copy, Debug, PartialEq, Eq)]
100#[repr(u8)]
101pub enum Ps {
102    #[doc = "0: 4-byte page"]
103    _4Byte = 0,
104    #[doc = "1: 8-byte page"]
105    _8Byte = 1,
106    #[doc = "2: 16-byte page"]
107    _16Byte = 2,
108    #[doc = "3: 32-byte page"]
109    _32Byte = 3,
110}
111impl From<Ps> for u8 {
112    #[inline(always)]
113    fn from(variant: Ps) -> Self {
114        variant as _
115    }
116}
117impl crate::FieldSpec for Ps {
118    type Ux = u8;
119}
120impl crate::IsEnum for Ps {}
121#[doc = "Field `PS` reader - Page Size"]
122pub type PsR = crate::FieldReader<Ps>;
123impl PsR {
124    #[doc = "Get enumerated values variant"]
125    #[inline(always)]
126    pub const fn variant(&self) -> Ps {
127        match self.bits {
128            0 => Ps::_4Byte,
129            1 => Ps::_8Byte,
130            2 => Ps::_16Byte,
131            3 => Ps::_32Byte,
132            _ => unreachable!(),
133        }
134    }
135    #[doc = "4-byte page"]
136    #[inline(always)]
137    pub fn is_4_byte(&self) -> bool {
138        *self == Ps::_4Byte
139    }
140    #[doc = "8-byte page"]
141    #[inline(always)]
142    pub fn is_8_byte(&self) -> bool {
143        *self == Ps::_8Byte
144    }
145    #[doc = "16-byte page"]
146    #[inline(always)]
147    pub fn is_16_byte(&self) -> bool {
148        *self == Ps::_16Byte
149    }
150    #[doc = "32-byte page"]
151    #[inline(always)]
152    pub fn is_32_byte(&self) -> bool {
153        *self == Ps::_32Byte
154    }
155}
156#[doc = "Field `PS` writer - Page Size"]
157pub type PsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Ps, crate::Safe>;
158impl<'a, REG> PsW<'a, REG>
159where
160    REG: crate::Writable + crate::RegisterSpec,
161    REG::Ux: From<u8>,
162{
163    #[doc = "4-byte page"]
164    #[inline(always)]
165    pub fn _4_byte(self) -> &'a mut crate::W<REG> {
166        self.variant(Ps::_4Byte)
167    }
168    #[doc = "8-byte page"]
169    #[inline(always)]
170    pub fn _8_byte(self) -> &'a mut crate::W<REG> {
171        self.variant(Ps::_8Byte)
172    }
173    #[doc = "16-byte page"]
174    #[inline(always)]
175    pub fn _16_byte(self) -> &'a mut crate::W<REG> {
176        self.variant(Ps::_16Byte)
177    }
178    #[doc = "32-byte page"]
179    #[inline(always)]
180    pub fn _32_byte(self) -> &'a mut crate::W<REG> {
181        self.variant(Ps::_32Byte)
182    }
183}
184impl R {
185    #[doc = "Bit 0"]
186    #[inline(always)]
187    pub fn read_mode(&self) -> ReadModeR {
188        ReadModeR::new((self.bits & 1) != 0)
189    }
190    #[doc = "Bit 1"]
191    #[inline(always)]
192    pub fn write_mode(&self) -> WriteModeR {
193        WriteModeR::new(((self.bits >> 1) & 1) != 0)
194    }
195    #[doc = "Bits 4:5 - NWAIT Mode"]
196    #[inline(always)]
197    pub fn exnw_mode(&self) -> ExnwModeR {
198        ExnwModeR::new(((self.bits >> 4) & 3) as u8)
199    }
200    #[doc = "Bits 16:19 - Data Float Time"]
201    #[inline(always)]
202    pub fn tdf_cycles(&self) -> TdfCyclesR {
203        TdfCyclesR::new(((self.bits >> 16) & 0x0f) as u8)
204    }
205    #[doc = "Bit 20 - TDF Optimization"]
206    #[inline(always)]
207    pub fn tdf_mode(&self) -> TdfModeR {
208        TdfModeR::new(((self.bits >> 20) & 1) != 0)
209    }
210    #[doc = "Bit 24 - Page Mode Enabled"]
211    #[inline(always)]
212    pub fn pmen(&self) -> PmenR {
213        PmenR::new(((self.bits >> 24) & 1) != 0)
214    }
215    #[doc = "Bits 28:29 - Page Size"]
216    #[inline(always)]
217    pub fn ps(&self) -> PsR {
218        PsR::new(((self.bits >> 28) & 3) as u8)
219    }
220}
221impl W {
222    #[doc = "Bit 0"]
223    #[inline(always)]
224    #[must_use]
225    pub fn read_mode(&mut self) -> ReadModeW<Mode1Spec> {
226        ReadModeW::new(self, 0)
227    }
228    #[doc = "Bit 1"]
229    #[inline(always)]
230    #[must_use]
231    pub fn write_mode(&mut self) -> WriteModeW<Mode1Spec> {
232        WriteModeW::new(self, 1)
233    }
234    #[doc = "Bits 4:5 - NWAIT Mode"]
235    #[inline(always)]
236    #[must_use]
237    pub fn exnw_mode(&mut self) -> ExnwModeW<Mode1Spec> {
238        ExnwModeW::new(self, 4)
239    }
240    #[doc = "Bits 16:19 - Data Float Time"]
241    #[inline(always)]
242    #[must_use]
243    pub fn tdf_cycles(&mut self) -> TdfCyclesW<Mode1Spec> {
244        TdfCyclesW::new(self, 16)
245    }
246    #[doc = "Bit 20 - TDF Optimization"]
247    #[inline(always)]
248    #[must_use]
249    pub fn tdf_mode(&mut self) -> TdfModeW<Mode1Spec> {
250        TdfModeW::new(self, 20)
251    }
252    #[doc = "Bit 24 - Page Mode Enabled"]
253    #[inline(always)]
254    #[must_use]
255    pub fn pmen(&mut self) -> PmenW<Mode1Spec> {
256        PmenW::new(self, 24)
257    }
258    #[doc = "Bits 28:29 - Page Size"]
259    #[inline(always)]
260    #[must_use]
261    pub fn ps(&mut self) -> PsW<Mode1Spec> {
262        PsW::new(self, 28)
263    }
264}
265#[doc = "SMC Mode Register (CS_number = 1)\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`mode1::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`mode1::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
266pub struct Mode1Spec;
267impl crate::RegisterSpec for Mode1Spec {
268    type Ux = u32;
269}
270#[doc = "`read()` method returns [`mode1::R`](R) reader structure"]
271impl crate::Readable for Mode1Spec {}
272#[doc = "`write(|w| ..)` method takes [`mode1::W`](W) writer structure"]
273impl crate::Writable for Mode1Spec {
274    type Safety = crate::Unsafe;
275    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
276    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
277}
278#[doc = "`reset()` method sets MODE1 to value 0x1000_0003"]
279impl crate::Resettable for Mode1Spec {
280    const RESET_VALUE: u32 = 0x1000_0003;
281}