efm32pg12_pac/msc/
bankswitchlock.rs1#[doc = "Reader of register BANKSWITCHLOCK"]
2pub type R = crate::R<u32, super::BANKSWITCHLOCK>;
3#[doc = "Writer for register BANKSWITCHLOCK"]
4pub type W = crate::W<u32, super::BANKSWITCHLOCK>;
5#[doc = "Register BANKSWITCHLOCK `reset()`'s with value 0x01"]
6impl crate::ResetValue for super::BANKSWITCHLOCK {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0x01
11 }
12}
13#[doc = "Bank Switching Lock\n\nValue on reset: 1"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u16)]
16pub enum BANKSWITCHLOCKKEY_A {
17 #[doc = "0: `0`"]
18 UNLOCKED = 0,
19 #[doc = "1: `1`"]
20 LOCKED = 1,
21}
22impl From<BANKSWITCHLOCKKEY_A> for u16 {
23 #[inline(always)]
24 fn from(variant: BANKSWITCHLOCKKEY_A) -> Self {
25 variant as _
26 }
27}
28#[doc = "Reader of field `BANKSWITCHLOCKKEY`"]
29pub type BANKSWITCHLOCKKEY_R = crate::R<u16, BANKSWITCHLOCKKEY_A>;
30impl BANKSWITCHLOCKKEY_R {
31 #[doc = r"Get enumerated values variant"]
32 #[inline(always)]
33 pub fn variant(&self) -> crate::Variant<u16, BANKSWITCHLOCKKEY_A> {
34 use crate::Variant::*;
35 match self.bits {
36 0 => Val(BANKSWITCHLOCKKEY_A::UNLOCKED),
37 1 => Val(BANKSWITCHLOCKKEY_A::LOCKED),
38 i => Res(i),
39 }
40 }
41 #[doc = "Checks if the value of the field is `UNLOCKED`"]
42 #[inline(always)]
43 pub fn is_unlocked(&self) -> bool {
44 *self == BANKSWITCHLOCKKEY_A::UNLOCKED
45 }
46 #[doc = "Checks if the value of the field is `LOCKED`"]
47 #[inline(always)]
48 pub fn is_locked(&self) -> bool {
49 *self == BANKSWITCHLOCKKEY_A::LOCKED
50 }
51}
52#[doc = "Write proxy for field `BANKSWITCHLOCKKEY`"]
53pub struct BANKSWITCHLOCKKEY_W<'a> {
54 w: &'a mut W,
55}
56impl<'a> BANKSWITCHLOCKKEY_W<'a> {
57 #[doc = r"Writes `variant` to the field"]
58 #[inline(always)]
59 pub fn variant(self, variant: BANKSWITCHLOCKKEY_A) -> &'a mut W {
60 unsafe { self.bits(variant.into()) }
61 }
62 #[doc = "`0`"]
63 #[inline(always)]
64 pub fn unlocked(self) -> &'a mut W {
65 self.variant(BANKSWITCHLOCKKEY_A::UNLOCKED)
66 }
67 #[doc = "`1`"]
68 #[inline(always)]
69 pub fn locked(self) -> &'a mut W {
70 self.variant(BANKSWITCHLOCKKEY_A::LOCKED)
71 }
72 #[doc = r"Writes raw bits to the field"]
73 #[inline(always)]
74 pub unsafe fn bits(self, value: u16) -> &'a mut W {
75 self.w.bits = (self.w.bits & !0xffff) | ((value as u32) & 0xffff);
76 self.w
77 }
78}
79impl R {
80 #[doc = "Bits 0:15 - Bank Switching Lock"]
81 #[inline(always)]
82 pub fn bankswitchlockkey(&self) -> BANKSWITCHLOCKKEY_R {
83 BANKSWITCHLOCKKEY_R::new((self.bits & 0xffff) as u16)
84 }
85}
86impl W {
87 #[doc = "Bits 0:15 - Bank Switching Lock"]
88 #[inline(always)]
89 pub fn bankswitchlockkey(&mut self) -> BANKSWITCHLOCKKEY_W {
90 BANKSWITCHLOCKKEY_W { w: self }
91 }
92}