atsame70n21/rswdt/
rswdt_cr.rs

1#[doc = "Register `RSWDT_CR` writer"]
2pub struct W(crate::W<RSWDT_CR_SPEC>);
3impl core::ops::Deref for W {
4    type Target = crate::W<RSWDT_CR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl core::ops::DerefMut for W {
11    #[inline(always)]
12    fn deref_mut(&mut self) -> &mut Self::Target {
13        &mut self.0
14    }
15}
16impl From<crate::W<RSWDT_CR_SPEC>> for W {
17    #[inline(always)]
18    fn from(writer: crate::W<RSWDT_CR_SPEC>) -> Self {
19        W(writer)
20    }
21}
22#[doc = "Field `WDRSTT` writer - Watchdog Restart"]
23pub struct WDRSTT_W<'a> {
24    w: &'a mut W,
25}
26impl<'a> WDRSTT_W<'a> {
27    #[doc = r"Sets the field bit"]
28    #[inline(always)]
29    pub fn set_bit(self) -> &'a mut W {
30        self.bit(true)
31    }
32    #[doc = r"Clears the field bit"]
33    #[inline(always)]
34    pub fn clear_bit(self) -> &'a mut W {
35        self.bit(false)
36    }
37    #[doc = r"Writes raw bits to the field"]
38    #[inline(always)]
39    pub fn bit(self, value: bool) -> &'a mut W {
40        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
41        self.w
42    }
43}
44#[doc = "Password\n\nValue on reset: 0"]
45#[derive(Clone, Copy, Debug, PartialEq)]
46#[repr(u8)]
47pub enum KEY_AW {
48    #[doc = "196: Writing any other value in this field aborts the write operation."]
49    PASSWD = 196,
50}
51impl From<KEY_AW> for u8 {
52    #[inline(always)]
53    fn from(variant: KEY_AW) -> Self {
54        variant as _
55    }
56}
57#[doc = "Field `KEY` writer - Password"]
58pub struct KEY_W<'a> {
59    w: &'a mut W,
60}
61impl<'a> KEY_W<'a> {
62    #[doc = r"Writes `variant` to the field"]
63    #[inline(always)]
64    pub fn variant(self, variant: KEY_AW) -> &'a mut W {
65        unsafe { self.bits(variant.into()) }
66    }
67    #[doc = "Writing any other value in this field aborts the write operation."]
68    #[inline(always)]
69    pub fn passwd(self) -> &'a mut W {
70        self.variant(KEY_AW::PASSWD)
71    }
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub unsafe fn bits(self, value: u8) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0xff << 24)) | ((value as u32 & 0xff) << 24);
76        self.w
77    }
78}
79impl W {
80    #[doc = "Bit 0 - Watchdog Restart"]
81    #[inline(always)]
82    pub fn wdrstt(&mut self) -> WDRSTT_W {
83        WDRSTT_W { w: self }
84    }
85    #[doc = "Bits 24:31 - Password"]
86    #[inline(always)]
87    pub fn key(&mut self) -> KEY_W {
88        KEY_W { w: self }
89    }
90    #[doc = "Writes raw bits to the register."]
91    #[inline(always)]
92    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
93        self.0.bits(bits);
94        self
95    }
96}
97#[doc = "Control Register\n\nThis register you can [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rswdt_cr](index.html) module"]
98pub struct RSWDT_CR_SPEC;
99impl crate::RegisterSpec for RSWDT_CR_SPEC {
100    type Ux = u32;
101}
102#[doc = "`write(|w| ..)` method takes [rswdt_cr::W](W) writer structure"]
103impl crate::Writable for RSWDT_CR_SPEC {
104    type Writer = W;
105}
106#[doc = "`reset()` method sets RSWDT_CR to value 0"]
107impl crate::Resettable for RSWDT_CR_SPEC {
108    #[inline(always)]
109    fn reset_value() -> Self::Ux {
110        0
111    }
112}