ambiq_apollo3_pac/mcuctrl/shadowvalid/
mod.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::SHADOWVALID {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = "Possible values of the field `INFO0_VALID`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum INFO0_VALIDR {
48    #[doc = "Flash info0 (customer) space contains valid data. value."]
49    VALID,
50    #[doc = r" Reserved"]
51    _Reserved(bool),
52}
53impl INFO0_VALIDR {
54    #[doc = r" Returns `true` if the bit is clear (0)"]
55    #[inline]
56    pub fn bit_is_clear(&self) -> bool {
57        !self.bit()
58    }
59    #[doc = r" Returns `true` if the bit is set (1)"]
60    #[inline]
61    pub fn bit_is_set(&self) -> bool {
62        self.bit()
63    }
64    #[doc = r" Value of the field as raw bits"]
65    #[inline]
66    pub fn bit(&self) -> bool {
67        match *self {
68            INFO0_VALIDR::VALID => true,
69            INFO0_VALIDR::_Reserved(bits) => bits,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> INFO0_VALIDR {
76        match value {
77            true => INFO0_VALIDR::VALID,
78            i => INFO0_VALIDR::_Reserved(i),
79        }
80    }
81    #[doc = "Checks if the value of the field is `VALID`"]
82    #[inline]
83    pub fn is_valid(&self) -> bool {
84        *self == INFO0_VALIDR::VALID
85    }
86}
87#[doc = "Possible values of the field `BLDSLEEP`"]
88#[derive(Clone, Copy, Debug, PartialEq)]
89pub enum BLDSLEEPR {
90    #[doc = "Bootloader will go to deep sleep if no flash image loaded value."]
91    DEEPSLEEP,
92    #[doc = r" Reserved"]
93    _Reserved(bool),
94}
95impl BLDSLEEPR {
96    #[doc = r" Returns `true` if the bit is clear (0)"]
97    #[inline]
98    pub fn bit_is_clear(&self) -> bool {
99        !self.bit()
100    }
101    #[doc = r" Returns `true` if the bit is set (1)"]
102    #[inline]
103    pub fn bit_is_set(&self) -> bool {
104        self.bit()
105    }
106    #[doc = r" Value of the field as raw bits"]
107    #[inline]
108    pub fn bit(&self) -> bool {
109        match *self {
110            BLDSLEEPR::DEEPSLEEP => true,
111            BLDSLEEPR::_Reserved(bits) => bits,
112        }
113    }
114    #[allow(missing_docs)]
115    #[doc(hidden)]
116    #[inline]
117    pub fn _from(value: bool) -> BLDSLEEPR {
118        match value {
119            true => BLDSLEEPR::DEEPSLEEP,
120            i => BLDSLEEPR::_Reserved(i),
121        }
122    }
123    #[doc = "Checks if the value of the field is `DEEPSLEEP`"]
124    #[inline]
125    pub fn is_deepsleep(&self) -> bool {
126        *self == BLDSLEEPR::DEEPSLEEP
127    }
128}
129#[doc = "Possible values of the field `VALID`"]
130#[derive(Clone, Copy, Debug, PartialEq)]
131pub enum VALIDR {
132    #[doc = "Flash information space contains valid data. value."]
133    VALID,
134    #[doc = r" Reserved"]
135    _Reserved(bool),
136}
137impl VALIDR {
138    #[doc = r" Returns `true` if the bit is clear (0)"]
139    #[inline]
140    pub fn bit_is_clear(&self) -> bool {
141        !self.bit()
142    }
143    #[doc = r" Returns `true` if the bit is set (1)"]
144    #[inline]
145    pub fn bit_is_set(&self) -> bool {
146        self.bit()
147    }
148    #[doc = r" Value of the field as raw bits"]
149    #[inline]
150    pub fn bit(&self) -> bool {
151        match *self {
152            VALIDR::VALID => true,
153            VALIDR::_Reserved(bits) => bits,
154        }
155    }
156    #[allow(missing_docs)]
157    #[doc(hidden)]
158    #[inline]
159    pub fn _from(value: bool) -> VALIDR {
160        match value {
161            true => VALIDR::VALID,
162            i => VALIDR::_Reserved(i),
163        }
164    }
165    #[doc = "Checks if the value of the field is `VALID`"]
166    #[inline]
167    pub fn is_valid(&self) -> bool {
168        *self == VALIDR::VALID
169    }
170}
171#[doc = "Values that can be written to the field `INFO0_VALID`"]
172pub enum INFO0_VALIDW {
173    #[doc = "Flash info0 (customer) space contains valid data. value."]
174    VALID,
175}
176impl INFO0_VALIDW {
177    #[allow(missing_docs)]
178    #[doc(hidden)]
179    #[inline]
180    pub fn _bits(&self) -> bool {
181        match *self {
182            INFO0_VALIDW::VALID => true,
183        }
184    }
185}
186#[doc = r" Proxy"]
187pub struct _INFO0_VALIDW<'a> {
188    w: &'a mut W,
189}
190impl<'a> _INFO0_VALIDW<'a> {
191    #[doc = r" Writes `variant` to the field"]
192    #[inline]
193    pub fn variant(self, variant: INFO0_VALIDW) -> &'a mut W {
194        {
195            self.bit(variant._bits())
196        }
197    }
198    #[doc = "Flash info0 (customer) space contains valid data. value."]
199    #[inline]
200    pub fn valid(self) -> &'a mut W {
201        self.variant(INFO0_VALIDW::VALID)
202    }
203    #[doc = r" Sets the field bit"]
204    pub fn set_bit(self) -> &'a mut W {
205        self.bit(true)
206    }
207    #[doc = r" Clears the field bit"]
208    pub fn clear_bit(self) -> &'a mut W {
209        self.bit(false)
210    }
211    #[doc = r" Writes raw bits to the field"]
212    #[inline]
213    pub fn bit(self, value: bool) -> &'a mut W {
214        const MASK: bool = true;
215        const OFFSET: u8 = 2;
216        self.w.bits &= !((MASK as u32) << OFFSET);
217        self.w.bits |= ((value & MASK) as u32) << OFFSET;
218        self.w
219    }
220}
221#[doc = "Values that can be written to the field `BLDSLEEP`"]
222pub enum BLDSLEEPW {
223    #[doc = "Bootloader will go to deep sleep if no flash image loaded value."]
224    DEEPSLEEP,
225}
226impl BLDSLEEPW {
227    #[allow(missing_docs)]
228    #[doc(hidden)]
229    #[inline]
230    pub fn _bits(&self) -> bool {
231        match *self {
232            BLDSLEEPW::DEEPSLEEP => true,
233        }
234    }
235}
236#[doc = r" Proxy"]
237pub struct _BLDSLEEPW<'a> {
238    w: &'a mut W,
239}
240impl<'a> _BLDSLEEPW<'a> {
241    #[doc = r" Writes `variant` to the field"]
242    #[inline]
243    pub fn variant(self, variant: BLDSLEEPW) -> &'a mut W {
244        {
245            self.bit(variant._bits())
246        }
247    }
248    #[doc = "Bootloader will go to deep sleep if no flash image loaded value."]
249    #[inline]
250    pub fn deepsleep(self) -> &'a mut W {
251        self.variant(BLDSLEEPW::DEEPSLEEP)
252    }
253    #[doc = r" Sets the field bit"]
254    pub fn set_bit(self) -> &'a mut W {
255        self.bit(true)
256    }
257    #[doc = r" Clears the field bit"]
258    pub fn clear_bit(self) -> &'a mut W {
259        self.bit(false)
260    }
261    #[doc = r" Writes raw bits to the field"]
262    #[inline]
263    pub fn bit(self, value: bool) -> &'a mut W {
264        const MASK: bool = true;
265        const OFFSET: u8 = 1;
266        self.w.bits &= !((MASK as u32) << OFFSET);
267        self.w.bits |= ((value & MASK) as u32) << OFFSET;
268        self.w
269    }
270}
271#[doc = "Values that can be written to the field `VALID`"]
272pub enum VALIDW {
273    #[doc = "Flash information space contains valid data. value."]
274    VALID,
275}
276impl VALIDW {
277    #[allow(missing_docs)]
278    #[doc(hidden)]
279    #[inline]
280    pub fn _bits(&self) -> bool {
281        match *self {
282            VALIDW::VALID => true,
283        }
284    }
285}
286#[doc = r" Proxy"]
287pub struct _VALIDW<'a> {
288    w: &'a mut W,
289}
290impl<'a> _VALIDW<'a> {
291    #[doc = r" Writes `variant` to the field"]
292    #[inline]
293    pub fn variant(self, variant: VALIDW) -> &'a mut W {
294        {
295            self.bit(variant._bits())
296        }
297    }
298    #[doc = "Flash information space contains valid data. value."]
299    #[inline]
300    pub fn valid(self) -> &'a mut W {
301        self.variant(VALIDW::VALID)
302    }
303    #[doc = r" Sets the field bit"]
304    pub fn set_bit(self) -> &'a mut W {
305        self.bit(true)
306    }
307    #[doc = r" Clears the field bit"]
308    pub fn clear_bit(self) -> &'a mut W {
309        self.bit(false)
310    }
311    #[doc = r" Writes raw bits to the field"]
312    #[inline]
313    pub fn bit(self, value: bool) -> &'a mut W {
314        const MASK: bool = true;
315        const OFFSET: u8 = 0;
316        self.w.bits &= !((MASK as u32) << OFFSET);
317        self.w.bits |= ((value & MASK) as u32) << OFFSET;
318        self.w
319    }
320}
321impl R {
322    #[doc = r" Value of the register as raw bits"]
323    #[inline]
324    pub fn bits(&self) -> u32 {
325        self.bits
326    }
327    #[doc = "Bit 2 - Indicates whether info0 contains valid data"]
328    #[inline]
329    pub fn info0_valid(&self) -> INFO0_VALIDR {
330        INFO0_VALIDR::_from({
331            const MASK: bool = true;
332            const OFFSET: u8 = 2;
333            ((self.bits >> OFFSET) & MASK as u32) != 0
334        })
335    }
336    #[doc = "Bit 1 - Indicates whether the bootloader should sleep or deep sleep if no image loaded."]
337    #[inline]
338    pub fn bldsleep(&self) -> BLDSLEEPR {
339        BLDSLEEPR::_from({
340            const MASK: bool = true;
341            const OFFSET: u8 = 1;
342            ((self.bits >> OFFSET) & MASK as u32) != 0
343        })
344    }
345    #[doc = "Bit 0 - Indicates whether the shadow registers contain valid data from the Flash Information Space."]
346    #[inline]
347    pub fn valid(&self) -> VALIDR {
348        VALIDR::_from({
349            const MASK: bool = true;
350            const OFFSET: u8 = 0;
351            ((self.bits >> OFFSET) & MASK as u32) != 0
352        })
353    }
354}
355impl W {
356    #[doc = r" Reset value of the register"]
357    #[inline]
358    pub fn reset_value() -> W {
359        W { bits: 7 }
360    }
361    #[doc = r" Writes raw bits to the register"]
362    #[inline]
363    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
364        self.bits = bits;
365        self
366    }
367    #[doc = "Bit 2 - Indicates whether info0 contains valid data"]
368    #[inline]
369    pub fn info0_valid(&mut self) -> _INFO0_VALIDW {
370        _INFO0_VALIDW { w: self }
371    }
372    #[doc = "Bit 1 - Indicates whether the bootloader should sleep or deep sleep if no image loaded."]
373    #[inline]
374    pub fn bldsleep(&mut self) -> _BLDSLEEPW {
375        _BLDSLEEPW { w: self }
376    }
377    #[doc = "Bit 0 - Indicates whether the shadow registers contain valid data from the Flash Information Space."]
378    #[inline]
379    pub fn valid(&mut self) -> _VALIDW {
380        _VALIDW { w: self }
381    }
382}