mimxrt685s_pac/casper/
lock.rs1#[doc = "Register `LOCK` reader"]
2pub type R = crate::R<LockSpec>;
3#[doc = "Register `LOCK` writer"]
4pub type W = crate::W<LockSpec>;
5#[doc = "Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock.\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Lock {
9 #[doc = "0: unlock"]
10 Unlock = 0,
11 #[doc = "1: Lock to current security level"]
12 Lock = 1,
13}
14impl From<Lock> for bool {
15 #[inline(always)]
16 fn from(variant: Lock) -> Self {
17 variant as u8 != 0
18 }
19}
20#[doc = "Field `LOCK` reader - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
21pub type LockR = crate::BitReader<Lock>;
22impl LockR {
23 #[doc = "Get enumerated values variant"]
24 #[inline(always)]
25 pub const fn variant(&self) -> Lock {
26 match self.bits {
27 false => Lock::Unlock,
28 true => Lock::Lock,
29 }
30 }
31 #[doc = "unlock"]
32 #[inline(always)]
33 pub fn is_unlock(&self) -> bool {
34 *self == Lock::Unlock
35 }
36 #[doc = "Lock to current security level"]
37 #[inline(always)]
38 pub fn is_lock(&self) -> bool {
39 *self == Lock::Lock
40 }
41}
42#[doc = "Field `LOCK` writer - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
43pub type LockW<'a, REG> = crate::BitWriter<'a, REG, Lock>;
44impl<'a, REG> LockW<'a, REG>
45where
46 REG: crate::Writable + crate::RegisterSpec,
47{
48 #[doc = "unlock"]
49 #[inline(always)]
50 pub fn unlock(self) -> &'a mut crate::W<REG> {
51 self.variant(Lock::Unlock)
52 }
53 #[doc = "Lock to current security level"]
54 #[inline(always)]
55 pub fn lock(self) -> &'a mut crate::W<REG> {
56 self.variant(Lock::Lock)
57 }
58}
59#[doc = "Must be written as 0x73D to change the register.\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62#[repr(u16)]
63pub enum Key {
64 #[doc = "1853: If set during write, will allow lock or unlock"]
65 KwyValue = 1853,
66}
67impl From<Key> for u16 {
68 #[inline(always)]
69 fn from(variant: Key) -> Self {
70 variant as _
71 }
72}
73impl crate::FieldSpec for Key {
74 type Ux = u16;
75}
76impl crate::IsEnum for Key {}
77#[doc = "Field `KEY` reader - Must be written as 0x73D to change the register."]
78pub type KeyR = crate::FieldReader<Key>;
79impl KeyR {
80 #[doc = "Get enumerated values variant"]
81 #[inline(always)]
82 pub const fn variant(&self) -> Option<Key> {
83 match self.bits {
84 1853 => Some(Key::KwyValue),
85 _ => None,
86 }
87 }
88 #[doc = "If set during write, will allow lock or unlock"]
89 #[inline(always)]
90 pub fn is_kwy_value(&self) -> bool {
91 *self == Key::KwyValue
92 }
93}
94#[doc = "Field `KEY` writer - Must be written as 0x73D to change the register."]
95pub type KeyW<'a, REG> = crate::FieldWriter<'a, REG, 13, Key>;
96impl<'a, REG> KeyW<'a, REG>
97where
98 REG: crate::Writable + crate::RegisterSpec,
99 REG::Ux: From<u16>,
100{
101 #[doc = "If set during write, will allow lock or unlock"]
102 #[inline(always)]
103 pub fn kwy_value(self) -> &'a mut crate::W<REG> {
104 self.variant(Key::KwyValue)
105 }
106}
107impl R {
108 #[doc = "Bit 0 - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
109 #[inline(always)]
110 pub fn lock(&self) -> LockR {
111 LockR::new((self.bits & 1) != 0)
112 }
113 #[doc = "Bits 4:16 - Must be written as 0x73D to change the register."]
114 #[inline(always)]
115 pub fn key(&self) -> KeyR {
116 KeyR::new(((self.bits >> 4) & 0x1fff) as u16)
117 }
118}
119#[cfg(feature = "debug")]
120impl core::fmt::Debug for R {
121 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
122 f.debug_struct("LOCK")
123 .field("lock", &self.lock())
124 .field("key", &self.key())
125 .finish()
126 }
127}
128impl W {
129 #[doc = "Bit 0 - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
130 #[inline(always)]
131 pub fn lock(&mut self) -> LockW<LockSpec> {
132 LockW::new(self, 0)
133 }
134 #[doc = "Bits 4:16 - Must be written as 0x73D to change the register."]
135 #[inline(always)]
136 pub fn key(&mut self) -> KeyW<LockSpec> {
137 KeyW::new(self, 4)
138 }
139}
140#[doc = "Security lock register\n\nYou can [`read`](crate::Reg::read) this register and get [`lock::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`lock::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
141pub struct LockSpec;
142impl crate::RegisterSpec for LockSpec {
143 type Ux = u32;
144}
145#[doc = "`read()` method returns [`lock::R`](R) reader structure"]
146impl crate::Readable for LockSpec {}
147#[doc = "`write(|w| ..)` method takes [`lock::W`](W) writer structure"]
148impl crate::Writable for LockSpec {
149 type Safety = crate::Unsafe;
150 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
151 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
152}
153#[doc = "`reset()` method sets LOCK to value 0"]
154impl crate::Resettable for LockSpec {
155 const RESET_VALUE: u32 = 0;
156}