saml10e15a/nvmctrl/
sulck.rs

1#[doc = "Reader of register SULCK"]
2pub type R = crate::R<u16, super::SULCK>;
3#[doc = "Writer for register SULCK"]
4pub type W = crate::W<u16, super::SULCK>;
5#[doc = "Register SULCK `reset()`'s with value 0"]
6impl crate::ResetValue for super::SULCK {
7    type Type = u16;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `BS`"]
14pub type BS_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `BS`"]
16pub struct BS_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> BS_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !0x01) | ((value as u16) & 0x01);
34        self.w
35    }
36}
37#[doc = "Reader of field `AS`"]
38pub type AS_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `AS`"]
40pub struct AS_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> AS_W<'a> {
44    #[doc = r"Sets the field bit"]
45    #[inline(always)]
46    pub fn set_bit(self) -> &'a mut W {
47        self.bit(true)
48    }
49    #[doc = r"Clears the field bit"]
50    #[inline(always)]
51    pub fn clear_bit(self) -> &'a mut W {
52        self.bit(false)
53    }
54    #[doc = r"Writes raw bits to the field"]
55    #[inline(always)]
56    pub fn bit(self, value: bool) -> &'a mut W {
57        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u16) & 0x01) << 1);
58        self.w
59    }
60}
61#[doc = "Reader of field `DS`"]
62pub type DS_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `DS`"]
64pub struct DS_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> DS_W<'a> {
68    #[doc = r"Sets the field bit"]
69    #[inline(always)]
70    pub fn set_bit(self) -> &'a mut W {
71        self.bit(true)
72    }
73    #[doc = r"Clears the field bit"]
74    #[inline(always)]
75    pub fn clear_bit(self) -> &'a mut W {
76        self.bit(false)
77    }
78    #[doc = r"Writes raw bits to the field"]
79    #[inline(always)]
80    pub fn bit(self, value: bool) -> &'a mut W {
81        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u16) & 0x01) << 2);
82        self.w
83    }
84}
85#[doc = "Possible values of the field `SLKEY`"]
86#[derive(Clone, Copy, Debug, PartialEq)]
87pub enum SLKEY_A {
88    #[doc = "Write Key"]
89    KEY,
90}
91impl crate::ToBits<u8> for SLKEY_A {
92    #[inline(always)]
93    fn _bits(&self) -> u8 {
94        match *self {
95            SLKEY_A::KEY => 165,
96        }
97    }
98}
99#[doc = "Reader of field `SLKEY`"]
100pub type SLKEY_R = crate::R<u8, SLKEY_A>;
101impl SLKEY_R {
102    #[doc = r"Get enumerated values variant"]
103    #[inline(always)]
104    pub fn variant(&self) -> crate::Variant<u8, SLKEY_A> {
105        use crate::Variant::*;
106        match self.bits {
107            165 => Val(SLKEY_A::KEY),
108            i => Res(i),
109        }
110    }
111    #[doc = "Checks if the value of the field is `KEY`"]
112    #[inline(always)]
113    pub fn is_key(&self) -> bool {
114        *self == SLKEY_A::KEY
115    }
116}
117#[doc = "Write proxy for field `SLKEY`"]
118pub struct SLKEY_W<'a> {
119    w: &'a mut W,
120}
121impl<'a> SLKEY_W<'a> {
122    #[doc = r"Writes `variant` to the field"]
123    #[inline(always)]
124    pub fn variant(self, variant: SLKEY_A) -> &'a mut W {
125        use crate::ToBits;
126        unsafe { self.bits(variant._bits()) }
127    }
128    #[doc = "Write Key"]
129    #[inline(always)]
130    pub fn key(self) -> &'a mut W {
131        self.variant(SLKEY_A::KEY)
132    }
133    #[doc = r"Writes raw bits to the field"]
134    #[inline(always)]
135    pub unsafe fn bits(self, value: u8) -> &'a mut W {
136        self.w.bits = (self.w.bits & !(0xff << 8)) | (((value as u16) & 0xff) << 8);
137        self.w
138    }
139}
140impl R {
141    #[doc = "Bit 0 - Secure Boot Region"]
142    #[inline(always)]
143    pub fn bs(&self) -> BS_R {
144        BS_R::new((self.bits & 0x01) != 0)
145    }
146    #[doc = "Bit 1 - Secure Application Region"]
147    #[inline(always)]
148    pub fn as_(&self) -> AS_R {
149        AS_R::new(((self.bits >> 1) & 0x01) != 0)
150    }
151    #[doc = "Bit 2 - Data Secure Region"]
152    #[inline(always)]
153    pub fn ds(&self) -> DS_R {
154        DS_R::new(((self.bits >> 2) & 0x01) != 0)
155    }
156    #[doc = "Bits 8:15 - Write Key"]
157    #[inline(always)]
158    pub fn slkey(&self) -> SLKEY_R {
159        SLKEY_R::new(((self.bits >> 8) & 0xff) as u8)
160    }
161}
162impl W {
163    #[doc = "Bit 0 - Secure Boot Region"]
164    #[inline(always)]
165    pub fn bs(&mut self) -> BS_W {
166        BS_W { w: self }
167    }
168    #[doc = "Bit 1 - Secure Application Region"]
169    #[inline(always)]
170    pub fn as_(&mut self) -> AS_W {
171        AS_W { w: self }
172    }
173    #[doc = "Bit 2 - Data Secure Region"]
174    #[inline(always)]
175    pub fn ds(&mut self) -> DS_W {
176        DS_W { w: self }
177    }
178    #[doc = "Bits 8:15 - Write Key"]
179    #[inline(always)]
180    pub fn slkey(&mut self) -> SLKEY_W {
181        SLKEY_W { w: self }
182    }
183}