ambiq_apollo4p_pac/security/
lockctrl.rs

1#[doc = "Register `LOCKCTRL` reader"]
2pub type R = crate::R<LockctrlSpec>;
3#[doc = "Register `LOCKCTRL` writer"]
4pub type W = crate::W<LockctrlSpec>;
5#[doc = "LOCK Function Select register.\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Select {
9    #[doc = "1: Enable customer OTP program."]
10    Lock01 = 1,
11    #[doc = "2: Enable customer OTP read."]
12    Lock02 = 2,
13    #[doc = "17: Enable Ambiq OTP program."]
14    Lock11 = 17,
15    #[doc = "18: Enable Ambiq OTP read."]
16    Lock12 = 18,
17    #[doc = "157: Enable Bootloader Recovery."]
18    Lock9d = 157,
19    #[doc = "158: Enable Bootloader info1."]
20    Lock9e = 158,
21    #[doc = "0: Reset all."]
22    Reset = 0,
23}
24impl From<Select> for u8 {
25    #[inline(always)]
26    fn from(variant: Select) -> Self {
27        variant as _
28    }
29}
30impl crate::FieldSpec for Select {
31    type Ux = u8;
32}
33impl crate::IsEnum for Select {}
34#[doc = "Field `SELECT` reader - LOCK Function Select register."]
35pub type SelectR = crate::FieldReader<Select>;
36impl SelectR {
37    #[doc = "Get enumerated values variant"]
38    #[inline(always)]
39    pub const fn variant(&self) -> Option<Select> {
40        match self.bits {
41            1 => Some(Select::Lock01),
42            2 => Some(Select::Lock02),
43            17 => Some(Select::Lock11),
44            18 => Some(Select::Lock12),
45            157 => Some(Select::Lock9d),
46            158 => Some(Select::Lock9e),
47            0 => Some(Select::Reset),
48            _ => None,
49        }
50    }
51    #[doc = "Enable customer OTP program."]
52    #[inline(always)]
53    pub fn is_lock01(&self) -> bool {
54        *self == Select::Lock01
55    }
56    #[doc = "Enable customer OTP read."]
57    #[inline(always)]
58    pub fn is_lock02(&self) -> bool {
59        *self == Select::Lock02
60    }
61    #[doc = "Enable Ambiq OTP program."]
62    #[inline(always)]
63    pub fn is_lock11(&self) -> bool {
64        *self == Select::Lock11
65    }
66    #[doc = "Enable Ambiq OTP read."]
67    #[inline(always)]
68    pub fn is_lock12(&self) -> bool {
69        *self == Select::Lock12
70    }
71    #[doc = "Enable Bootloader Recovery."]
72    #[inline(always)]
73    pub fn is_lock9d(&self) -> bool {
74        *self == Select::Lock9d
75    }
76    #[doc = "Enable Bootloader info1."]
77    #[inline(always)]
78    pub fn is_lock9e(&self) -> bool {
79        *self == Select::Lock9e
80    }
81    #[doc = "Reset all."]
82    #[inline(always)]
83    pub fn is_reset(&self) -> bool {
84        *self == Select::Reset
85    }
86}
87#[doc = "Field `SELECT` writer - LOCK Function Select register."]
88pub type SelectW<'a, REG> = crate::FieldWriter<'a, REG, 8, Select>;
89impl<'a, REG> SelectW<'a, REG>
90where
91    REG: crate::Writable + crate::RegisterSpec,
92    REG::Ux: From<u8>,
93{
94    #[doc = "Enable customer OTP program."]
95    #[inline(always)]
96    pub fn lock01(self) -> &'a mut crate::W<REG> {
97        self.variant(Select::Lock01)
98    }
99    #[doc = "Enable customer OTP read."]
100    #[inline(always)]
101    pub fn lock02(self) -> &'a mut crate::W<REG> {
102        self.variant(Select::Lock02)
103    }
104    #[doc = "Enable Ambiq OTP program."]
105    #[inline(always)]
106    pub fn lock11(self) -> &'a mut crate::W<REG> {
107        self.variant(Select::Lock11)
108    }
109    #[doc = "Enable Ambiq OTP read."]
110    #[inline(always)]
111    pub fn lock12(self) -> &'a mut crate::W<REG> {
112        self.variant(Select::Lock12)
113    }
114    #[doc = "Enable Bootloader Recovery."]
115    #[inline(always)]
116    pub fn lock9d(self) -> &'a mut crate::W<REG> {
117        self.variant(Select::Lock9d)
118    }
119    #[doc = "Enable Bootloader info1."]
120    #[inline(always)]
121    pub fn lock9e(self) -> &'a mut crate::W<REG> {
122        self.variant(Select::Lock9e)
123    }
124    #[doc = "Reset all."]
125    #[inline(always)]
126    pub fn reset(self) -> &'a mut crate::W<REG> {
127        self.variant(Select::Reset)
128    }
129}
130impl R {
131    #[doc = "Bits 0:7 - LOCK Function Select register."]
132    #[inline(always)]
133    pub fn select(&self) -> SelectR {
134        SelectR::new((self.bits & 0xff) as u8)
135    }
136}
137impl W {
138    #[doc = "Bits 0:7 - LOCK Function Select register."]
139    #[inline(always)]
140    #[must_use]
141    pub fn select(&mut self) -> SelectW<LockctrlSpec> {
142        SelectW::new(self, 0)
143    }
144}
145#[doc = "LOCK Control\n\nYou can [`read`](crate::Reg::read) this register and get [`lockctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`lockctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
146pub struct LockctrlSpec;
147impl crate::RegisterSpec for LockctrlSpec {
148    type Ux = u32;
149}
150#[doc = "`read()` method returns [`lockctrl::R`](R) reader structure"]
151impl crate::Readable for LockctrlSpec {}
152#[doc = "`write(|w| ..)` method takes [`lockctrl::W`](W) writer structure"]
153impl crate::Writable for LockctrlSpec {
154    type Safety = crate::Unsafe;
155    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
156    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
157}
158#[doc = "`reset()` method sets LOCKCTRL to value 0"]
159impl crate::Resettable for LockctrlSpec {
160    const RESET_VALUE: u32 = 0;
161}