efm32pg1b_pac/cmu/
lock.rs1pub type R = crate::R<LOCKrs>;
3pub type W = crate::W<LOCKrs>;
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10#[repr(u16)]
11pub enum LOCKKEY {
12 Unlocked = 0,
14 Locked = 1,
16}
17impl From<LOCKKEY> for u16 {
18 #[inline(always)]
19 fn from(variant: LOCKKEY) -> Self {
20 variant as _
21 }
22}
23impl crate::FieldSpec for LOCKKEY {
24 type Ux = u16;
25}
26impl crate::IsEnum for LOCKKEY {}
27pub type LockkeyR = crate::FieldReader<LOCKKEY>;
29impl LockkeyR {
30 #[inline(always)]
32 pub const fn variant(&self) -> Option<LOCKKEY> {
33 match self.bits {
34 0 => Some(LOCKKEY::Unlocked),
35 1 => Some(LOCKKEY::Locked),
36 _ => None,
37 }
38 }
39 #[inline(always)]
41 pub fn is_unlocked(&self) -> bool {
42 *self == LOCKKEY::Unlocked
43 }
44 #[inline(always)]
46 pub fn is_locked(&self) -> bool {
47 *self == LOCKKEY::Locked
48 }
49}
50pub type LockkeyW<'a, REG> = crate::FieldWriter<'a, REG, 16, LOCKKEY>;
52impl<'a, REG> LockkeyW<'a, REG>
53where
54 REG: crate::Writable + crate::RegisterSpec,
55 REG::Ux: From<u16>,
56{
57 #[inline(always)]
59 pub fn unlocked(self) -> &'a mut crate::W<REG> {
60 self.variant(LOCKKEY::Unlocked)
61 }
62 #[inline(always)]
64 pub fn locked(self) -> &'a mut crate::W<REG> {
65 self.variant(LOCKKEY::Locked)
66 }
67}
68impl R {
69 #[inline(always)]
71 pub fn lockkey(&self) -> LockkeyR {
72 LockkeyR::new((self.bits & 0xffff) as u16)
73 }
74}
75impl core::fmt::Debug for R {
76 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
77 f.debug_struct("LOCK")
78 .field("lockkey", &self.lockkey())
79 .finish()
80 }
81}
82impl W {
83 #[inline(always)]
85 pub fn lockkey(&mut self) -> LockkeyW<'_, LOCKrs> {
86 LockkeyW::new(self, 0)
87 }
88}
89pub struct LOCKrs;
93impl crate::RegisterSpec for LOCKrs {
94 type Ux = u32;
95}
96impl crate::Readable for LOCKrs {}
98impl crate::Writable for LOCKrs {
100 type Safety = crate::Unsafe;
101}
102impl crate::Resettable for LOCKrs {}