avr_device/devices/atmega4809/nvmctrl/
ctrla.rs1#[doc = "Register `CTRLA` reader"]
2pub struct R(crate::R<CTRLA_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRLA_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRLA_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRLA_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRLA` writer"]
17pub struct W(crate::W<CTRLA_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRLA_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<CTRLA_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRLA_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CMD` reader - Command"]
38pub type CMD_R = crate::FieldReader<u8, CMD_A>;
39#[doc = "Command\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CMD_A {
43 #[doc = "0: No Command"]
44 NONE = 0,
45 #[doc = "1: Write page"]
46 PAGEWRITE = 1,
47 #[doc = "2: Erase page"]
48 PAGEERASE = 2,
49 #[doc = "3: Erase and write page"]
50 PAGEERASEWRITE = 3,
51 #[doc = "4: Page buffer clear"]
52 PAGEBUFCLR = 4,
53 #[doc = "5: Chip erase"]
54 CHIPERASE = 5,
55 #[doc = "6: EEPROM erase"]
56 EEERASE = 6,
57 #[doc = "7: Write fuse (PDI only)"]
58 FUSEWRITE = 7,
59}
60impl From<CMD_A> for u8 {
61 #[inline(always)]
62 fn from(variant: CMD_A) -> Self {
63 variant as _
64 }
65}
66impl CMD_R {
67 #[doc = "Get enumerated values variant"]
68 #[inline(always)]
69 pub fn variant(&self) -> CMD_A {
70 match self.bits {
71 0 => CMD_A::NONE,
72 1 => CMD_A::PAGEWRITE,
73 2 => CMD_A::PAGEERASE,
74 3 => CMD_A::PAGEERASEWRITE,
75 4 => CMD_A::PAGEBUFCLR,
76 5 => CMD_A::CHIPERASE,
77 6 => CMD_A::EEERASE,
78 7 => CMD_A::FUSEWRITE,
79 _ => unreachable!(),
80 }
81 }
82 #[doc = "Checks if the value of the field is `NONE`"]
83 #[inline(always)]
84 pub fn is_none(&self) -> bool {
85 *self == CMD_A::NONE
86 }
87 #[doc = "Checks if the value of the field is `PAGEWRITE`"]
88 #[inline(always)]
89 pub fn is_pagewrite(&self) -> bool {
90 *self == CMD_A::PAGEWRITE
91 }
92 #[doc = "Checks if the value of the field is `PAGEERASE`"]
93 #[inline(always)]
94 pub fn is_pageerase(&self) -> bool {
95 *self == CMD_A::PAGEERASE
96 }
97 #[doc = "Checks if the value of the field is `PAGEERASEWRITE`"]
98 #[inline(always)]
99 pub fn is_pageerasewrite(&self) -> bool {
100 *self == CMD_A::PAGEERASEWRITE
101 }
102 #[doc = "Checks if the value of the field is `PAGEBUFCLR`"]
103 #[inline(always)]
104 pub fn is_pagebufclr(&self) -> bool {
105 *self == CMD_A::PAGEBUFCLR
106 }
107 #[doc = "Checks if the value of the field is `CHIPERASE`"]
108 #[inline(always)]
109 pub fn is_chiperase(&self) -> bool {
110 *self == CMD_A::CHIPERASE
111 }
112 #[doc = "Checks if the value of the field is `EEERASE`"]
113 #[inline(always)]
114 pub fn is_eeerase(&self) -> bool {
115 *self == CMD_A::EEERASE
116 }
117 #[doc = "Checks if the value of the field is `FUSEWRITE`"]
118 #[inline(always)]
119 pub fn is_fusewrite(&self) -> bool {
120 *self == CMD_A::FUSEWRITE
121 }
122}
123#[doc = "Field `CMD` writer - Command"]
124pub type CMD_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CTRLA_SPEC, u8, CMD_A, 3, O>;
125impl<'a, const O: u8> CMD_W<'a, O> {
126 #[doc = "No Command"]
127 #[inline(always)]
128 pub fn none(self) -> &'a mut W {
129 self.variant(CMD_A::NONE)
130 }
131 #[doc = "Write page"]
132 #[inline(always)]
133 pub fn pagewrite(self) -> &'a mut W {
134 self.variant(CMD_A::PAGEWRITE)
135 }
136 #[doc = "Erase page"]
137 #[inline(always)]
138 pub fn pageerase(self) -> &'a mut W {
139 self.variant(CMD_A::PAGEERASE)
140 }
141 #[doc = "Erase and write page"]
142 #[inline(always)]
143 pub fn pageerasewrite(self) -> &'a mut W {
144 self.variant(CMD_A::PAGEERASEWRITE)
145 }
146 #[doc = "Page buffer clear"]
147 #[inline(always)]
148 pub fn pagebufclr(self) -> &'a mut W {
149 self.variant(CMD_A::PAGEBUFCLR)
150 }
151 #[doc = "Chip erase"]
152 #[inline(always)]
153 pub fn chiperase(self) -> &'a mut W {
154 self.variant(CMD_A::CHIPERASE)
155 }
156 #[doc = "EEPROM erase"]
157 #[inline(always)]
158 pub fn eeerase(self) -> &'a mut W {
159 self.variant(CMD_A::EEERASE)
160 }
161 #[doc = "Write fuse (PDI only)"]
162 #[inline(always)]
163 pub fn fusewrite(self) -> &'a mut W {
164 self.variant(CMD_A::FUSEWRITE)
165 }
166}
167impl R {
168 #[doc = "Bits 0:2 - Command"]
169 #[inline(always)]
170 pub fn cmd(&self) -> CMD_R {
171 CMD_R::new(self.bits & 7)
172 }
173}
174impl W {
175 #[doc = "Bits 0:2 - Command"]
176 #[inline(always)]
177 #[must_use]
178 pub fn cmd(&mut self) -> CMD_W<0> {
179 CMD_W::new(self)
180 }
181 #[doc = "Writes raw bits to the register."]
182 #[inline(always)]
183 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
184 self.0.bits(bits);
185 self
186 }
187}
188#[doc = "Control A\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 [ctrla](index.html) module"]
189pub struct CTRLA_SPEC;
190impl crate::RegisterSpec for CTRLA_SPEC {
191 type Ux = u8;
192}
193#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
194impl crate::Readable for CTRLA_SPEC {
195 type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
198impl crate::Writable for CTRLA_SPEC {
199 type Writer = W;
200 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
201 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
202}
203#[doc = "`reset()` method sets CTRLA to value 0"]
204impl crate::Resettable for CTRLA_SPEC {
205 const RESET_VALUE: Self::Ux = 0;
206}