atsamd51p/nvmctrl/
ctrlb.rs

1#[doc = "Register `CTRLB` writer"]
2pub type W = crate::W<CtrlbSpec>;
3#[doc = "Command\n\nValue on reset: 0"]
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5#[repr(u8)]
6pub enum Cmdselect {
7    #[doc = "0: Erase Page - Only supported in the USER and AUX pages."]
8    Ep = 0,
9    #[doc = "1: Erase Block - Erases the block addressed by the ADDR register, not supported in the user page"]
10    Eb = 1,
11    #[doc = "3: Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register, not supported in the user page"]
12    Wp = 3,
13    #[doc = "4: Write Quad Word - Writes a 128-bit word at the location addressed by the ADDR register."]
14    Wqw = 4,
15    #[doc = "16: Software Reset - Power-Cycle the NVM memory and replay the device automatic calibration procedure and resets the module configuration registers"]
16    Swrst = 16,
17    #[doc = "17: Lock Region - Locks the region containing the address location in the ADDR register."]
18    Lr = 17,
19    #[doc = "18: Unlock Region - Unlocks the region containing the address location in the ADDR register."]
20    Ur = 18,
21    #[doc = "19: Sets the power reduction mode."]
22    Sprm = 19,
23    #[doc = "20: Clears the power reduction mode."]
24    Cprm = 20,
25    #[doc = "21: Page Buffer Clear - Clears the page buffer."]
26    Pbc = 21,
27    #[doc = "22: Set Security Bit"]
28    Ssb = 22,
29    #[doc = "23: Bank swap and system reset, if SMEE is used also reallocate SMEE data into the opposite BANK"]
30    Bkswrst = 23,
31    #[doc = "24: Chip Erase Lock - DSU.CE command is not available"]
32    Celck = 24,
33    #[doc = "25: Chip Erase Unlock - DSU.CE command is available"]
34    Ceulck = 25,
35    #[doc = "26: Sets STATUS.BPDIS, Boot loader protection is discarded until CBPDIS is issued or next start-up sequence"]
36    Sbpdis = 26,
37    #[doc = "27: Clears STATUS.BPDIS, Boot loader protection is not discarded"]
38    Cbpdis = 27,
39    #[doc = "48: Activate SmartEEPROM Sector 0, deactivate Sector 1"]
40    Asees0 = 48,
41    #[doc = "49: Activate SmartEEPROM Sector 1, deactivate Sector 0"]
42    Asees1 = 49,
43    #[doc = "50: Starts SmartEEPROM sector reallocation algorithm"]
44    Seeraloc = 50,
45    #[doc = "51: Flush SMEE data when in buffered mode"]
46    Seeflush = 51,
47    #[doc = "52: Lock access to SmartEEPROM data from any mean"]
48    Lsee = 52,
49    #[doc = "53: Unlock access to SmartEEPROM data"]
50    Usee = 53,
51    #[doc = "54: Lock access to the SmartEEPROM Register Address Space (above 64KB)"]
52    Lseer = 54,
53    #[doc = "55: Unlock access to the SmartEEPROM Register Address Space (above 64KB)"]
54    Useer = 55,
55}
56impl From<Cmdselect> for u8 {
57    #[inline(always)]
58    fn from(variant: Cmdselect) -> Self {
59        variant as _
60    }
61}
62impl crate::FieldSpec for Cmdselect {
63    type Ux = u8;
64}
65impl crate::IsEnum for Cmdselect {}
66#[doc = "Field `CMD` writer - Command"]
67pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 7, Cmdselect>;
68impl<'a, REG> CmdW<'a, REG>
69where
70    REG: crate::Writable + crate::RegisterSpec,
71    REG::Ux: From<u8>,
72{
73    #[doc = "Erase Page - Only supported in the USER and AUX pages."]
74    #[inline(always)]
75    pub fn ep(self) -> &'a mut crate::W<REG> {
76        self.variant(Cmdselect::Ep)
77    }
78    #[doc = "Erase Block - Erases the block addressed by the ADDR register, not supported in the user page"]
79    #[inline(always)]
80    pub fn eb(self) -> &'a mut crate::W<REG> {
81        self.variant(Cmdselect::Eb)
82    }
83    #[doc = "Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register, not supported in the user page"]
84    #[inline(always)]
85    pub fn wp(self) -> &'a mut crate::W<REG> {
86        self.variant(Cmdselect::Wp)
87    }
88    #[doc = "Write Quad Word - Writes a 128-bit word at the location addressed by the ADDR register."]
89    #[inline(always)]
90    pub fn wqw(self) -> &'a mut crate::W<REG> {
91        self.variant(Cmdselect::Wqw)
92    }
93    #[doc = "Software Reset - Power-Cycle the NVM memory and replay the device automatic calibration procedure and resets the module configuration registers"]
94    #[inline(always)]
95    pub fn swrst(self) -> &'a mut crate::W<REG> {
96        self.variant(Cmdselect::Swrst)
97    }
98    #[doc = "Lock Region - Locks the region containing the address location in the ADDR register."]
99    #[inline(always)]
100    pub fn lr(self) -> &'a mut crate::W<REG> {
101        self.variant(Cmdselect::Lr)
102    }
103    #[doc = "Unlock Region - Unlocks the region containing the address location in the ADDR register."]
104    #[inline(always)]
105    pub fn ur(self) -> &'a mut crate::W<REG> {
106        self.variant(Cmdselect::Ur)
107    }
108    #[doc = "Sets the power reduction mode."]
109    #[inline(always)]
110    pub fn sprm(self) -> &'a mut crate::W<REG> {
111        self.variant(Cmdselect::Sprm)
112    }
113    #[doc = "Clears the power reduction mode."]
114    #[inline(always)]
115    pub fn cprm(self) -> &'a mut crate::W<REG> {
116        self.variant(Cmdselect::Cprm)
117    }
118    #[doc = "Page Buffer Clear - Clears the page buffer."]
119    #[inline(always)]
120    pub fn pbc(self) -> &'a mut crate::W<REG> {
121        self.variant(Cmdselect::Pbc)
122    }
123    #[doc = "Set Security Bit"]
124    #[inline(always)]
125    pub fn ssb(self) -> &'a mut crate::W<REG> {
126        self.variant(Cmdselect::Ssb)
127    }
128    #[doc = "Bank swap and system reset, if SMEE is used also reallocate SMEE data into the opposite BANK"]
129    #[inline(always)]
130    pub fn bkswrst(self) -> &'a mut crate::W<REG> {
131        self.variant(Cmdselect::Bkswrst)
132    }
133    #[doc = "Chip Erase Lock - DSU.CE command is not available"]
134    #[inline(always)]
135    pub fn celck(self) -> &'a mut crate::W<REG> {
136        self.variant(Cmdselect::Celck)
137    }
138    #[doc = "Chip Erase Unlock - DSU.CE command is available"]
139    #[inline(always)]
140    pub fn ceulck(self) -> &'a mut crate::W<REG> {
141        self.variant(Cmdselect::Ceulck)
142    }
143    #[doc = "Sets STATUS.BPDIS, Boot loader protection is discarded until CBPDIS is issued or next start-up sequence"]
144    #[inline(always)]
145    pub fn sbpdis(self) -> &'a mut crate::W<REG> {
146        self.variant(Cmdselect::Sbpdis)
147    }
148    #[doc = "Clears STATUS.BPDIS, Boot loader protection is not discarded"]
149    #[inline(always)]
150    pub fn cbpdis(self) -> &'a mut crate::W<REG> {
151        self.variant(Cmdselect::Cbpdis)
152    }
153    #[doc = "Activate SmartEEPROM Sector 0, deactivate Sector 1"]
154    #[inline(always)]
155    pub fn asees0(self) -> &'a mut crate::W<REG> {
156        self.variant(Cmdselect::Asees0)
157    }
158    #[doc = "Activate SmartEEPROM Sector 1, deactivate Sector 0"]
159    #[inline(always)]
160    pub fn asees1(self) -> &'a mut crate::W<REG> {
161        self.variant(Cmdselect::Asees1)
162    }
163    #[doc = "Starts SmartEEPROM sector reallocation algorithm"]
164    #[inline(always)]
165    pub fn seeraloc(self) -> &'a mut crate::W<REG> {
166        self.variant(Cmdselect::Seeraloc)
167    }
168    #[doc = "Flush SMEE data when in buffered mode"]
169    #[inline(always)]
170    pub fn seeflush(self) -> &'a mut crate::W<REG> {
171        self.variant(Cmdselect::Seeflush)
172    }
173    #[doc = "Lock access to SmartEEPROM data from any mean"]
174    #[inline(always)]
175    pub fn lsee(self) -> &'a mut crate::W<REG> {
176        self.variant(Cmdselect::Lsee)
177    }
178    #[doc = "Unlock access to SmartEEPROM data"]
179    #[inline(always)]
180    pub fn usee(self) -> &'a mut crate::W<REG> {
181        self.variant(Cmdselect::Usee)
182    }
183    #[doc = "Lock access to the SmartEEPROM Register Address Space (above 64KB)"]
184    #[inline(always)]
185    pub fn lseer(self) -> &'a mut crate::W<REG> {
186        self.variant(Cmdselect::Lseer)
187    }
188    #[doc = "Unlock access to the SmartEEPROM Register Address Space (above 64KB)"]
189    #[inline(always)]
190    pub fn useer(self) -> &'a mut crate::W<REG> {
191        self.variant(Cmdselect::Useer)
192    }
193}
194#[doc = "Command Execution\n\nValue on reset: 0"]
195#[derive(Clone, Copy, Debug, PartialEq, Eq)]
196#[repr(u8)]
197pub enum Cmdexselect {
198    #[doc = "165: Execution Key"]
199    Key = 165,
200}
201impl From<Cmdexselect> for u8 {
202    #[inline(always)]
203    fn from(variant: Cmdexselect) -> Self {
204        variant as _
205    }
206}
207impl crate::FieldSpec for Cmdexselect {
208    type Ux = u8;
209}
210impl crate::IsEnum for Cmdexselect {}
211#[doc = "Field `CMDEX` writer - Command Execution"]
212pub type CmdexW<'a, REG> = crate::FieldWriter<'a, REG, 8, Cmdexselect>;
213impl<'a, REG> CmdexW<'a, REG>
214where
215    REG: crate::Writable + crate::RegisterSpec,
216    REG::Ux: From<u8>,
217{
218    #[doc = "Execution Key"]
219    #[inline(always)]
220    pub fn key(self) -> &'a mut crate::W<REG> {
221        self.variant(Cmdexselect::Key)
222    }
223}
224impl W {
225    #[doc = "Bits 0:6 - Command"]
226    #[inline(always)]
227    #[must_use]
228    pub fn cmd(&mut self) -> CmdW<CtrlbSpec> {
229        CmdW::new(self, 0)
230    }
231    #[doc = "Bits 8:15 - Command Execution"]
232    #[inline(always)]
233    #[must_use]
234    pub fn cmdex(&mut self) -> CmdexW<CtrlbSpec> {
235        CmdexW::new(self, 8)
236    }
237}
238#[doc = "Control B\n\nYou can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlb::W`](W). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
239pub struct CtrlbSpec;
240impl crate::RegisterSpec for CtrlbSpec {
241    type Ux = u16;
242}
243#[doc = "`write(|w| ..)` method takes [`ctrlb::W`](W) writer structure"]
244impl crate::Writable for CtrlbSpec {
245    type Safety = crate::Unsafe;
246    const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
247    const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
248}
249#[doc = "`reset()` method sets CTRLB to value 0"]
250impl crate::Resettable for CtrlbSpec {
251    const RESET_VALUE: u16 = 0;
252}