Skip to main content

efm32pg1b_pac/cmu/
lock.rs

1///Register `LOCK` reader
2pub type R = crate::R<LOCKrs>;
3///Register `LOCK` writer
4pub type W = crate::W<LOCKrs>;
5///Configuration Lock Key
6///
7///Value on reset: 0
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10#[repr(u16)]
11pub enum LOCKKEY {
12    ///0: `0`
13    Unlocked = 0,
14    ///1: `1`
15    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 {}
27///Field `LOCKKEY` reader - Configuration Lock Key
28pub type LockkeyR = crate::FieldReader<LOCKKEY>;
29impl LockkeyR {
30    ///Get enumerated values variant
31    #[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    ///`0`
40    #[inline(always)]
41    pub fn is_unlocked(&self) -> bool {
42        *self == LOCKKEY::Unlocked
43    }
44    ///`1`
45    #[inline(always)]
46    pub fn is_locked(&self) -> bool {
47        *self == LOCKKEY::Locked
48    }
49}
50///Field `LOCKKEY` writer - Configuration Lock Key
51pub 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    ///`0`
58    #[inline(always)]
59    pub fn unlocked(self) -> &'a mut crate::W<REG> {
60        self.variant(LOCKKEY::Unlocked)
61    }
62    ///`1`
63    #[inline(always)]
64    pub fn locked(self) -> &'a mut crate::W<REG> {
65        self.variant(LOCKKEY::Locked)
66    }
67}
68impl R {
69    ///Bits 0:15 - Configuration Lock Key
70    #[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    ///Bits 0:15 - Configuration Lock Key
84    #[inline(always)]
85    pub fn lockkey(&mut self) -> LockkeyW<'_, LOCKrs> {
86        LockkeyW::new(self, 0)
87    }
88}
89///Configuration Lock Register
90///
91///You 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).
92pub struct LOCKrs;
93impl crate::RegisterSpec for LOCKrs {
94    type Ux = u32;
95}
96///`read()` method returns [`lock::R`](R) reader structure
97impl crate::Readable for LOCKrs {}
98///`write(|w| ..)` method takes [`lock::W`](W) writer structure
99impl crate::Writable for LOCKrs {
100    type Safety = crate::Unsafe;
101}
102///`reset()` method sets LOCK to value 0
103impl crate::Resettable for LOCKrs {}