mcxa_pac/scg0/
trim_lock.rs

1#[doc = "Register `TRIM_LOCK` reader"]
2pub type R = crate::R<TrimLockSpec>;
3#[doc = "Register `TRIM_LOCK` writer"]
4pub type W = crate::W<TrimLockSpec>;
5#[doc = "TRIM_UNLOCK\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum TrimUnlock {
9    #[doc = "0: SCG Trim Registers locked and not writable."]
10    Locked = 0,
11    #[doc = "1: SCG Trim registers unlocked and writable."]
12    NotLocked = 1,
13}
14impl From<TrimUnlock> for bool {
15    #[inline(always)]
16    fn from(variant: TrimUnlock) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `TRIM_UNLOCK` reader - TRIM_UNLOCK"]
21pub type TrimUnlockR = crate::BitReader<TrimUnlock>;
22impl TrimUnlockR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> TrimUnlock {
26        match self.bits {
27            false => TrimUnlock::Locked,
28            true => TrimUnlock::NotLocked,
29        }
30    }
31    #[doc = "SCG Trim Registers locked and not writable."]
32    #[inline(always)]
33    pub fn is_locked(&self) -> bool {
34        *self == TrimUnlock::Locked
35    }
36    #[doc = "SCG Trim registers unlocked and writable."]
37    #[inline(always)]
38    pub fn is_not_locked(&self) -> bool {
39        *self == TrimUnlock::NotLocked
40    }
41}
42#[doc = "Field `TRIM_UNLOCK` writer - TRIM_UNLOCK"]
43pub type TrimUnlockW<'a, REG> = crate::BitWriter<'a, REG, TrimUnlock>;
44impl<'a, REG> TrimUnlockW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "SCG Trim Registers locked and not writable."]
49    #[inline(always)]
50    pub fn locked(self) -> &'a mut crate::W<REG> {
51        self.variant(TrimUnlock::Locked)
52    }
53    #[doc = "SCG Trim registers unlocked and writable."]
54    #[inline(always)]
55    pub fn not_locked(self) -> &'a mut crate::W<REG> {
56        self.variant(TrimUnlock::NotLocked)
57    }
58}
59#[doc = "IFR_DISABLE\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum IfrDisable {
63    #[doc = "0: IFR write access to SCG trim registers not disabled. The SCG Trim registers are reprogrammed with the IFR values after any system reset."]
64    Enabled = 0,
65    #[doc = "1: IFR write access to SCG trim registers during system reset is blocked."]
66    Disabled = 1,
67}
68impl From<IfrDisable> for bool {
69    #[inline(always)]
70    fn from(variant: IfrDisable) -> Self {
71        variant as u8 != 0
72    }
73}
74#[doc = "Field `IFR_DISABLE` reader - IFR_DISABLE"]
75pub type IfrDisableR = crate::BitReader<IfrDisable>;
76impl IfrDisableR {
77    #[doc = "Get enumerated values variant"]
78    #[inline(always)]
79    pub const fn variant(&self) -> IfrDisable {
80        match self.bits {
81            false => IfrDisable::Enabled,
82            true => IfrDisable::Disabled,
83        }
84    }
85    #[doc = "IFR write access to SCG trim registers not disabled. The SCG Trim registers are reprogrammed with the IFR values after any system reset."]
86    #[inline(always)]
87    pub fn is_enabled(&self) -> bool {
88        *self == IfrDisable::Enabled
89    }
90    #[doc = "IFR write access to SCG trim registers during system reset is blocked."]
91    #[inline(always)]
92    pub fn is_disabled(&self) -> bool {
93        *self == IfrDisable::Disabled
94    }
95}
96#[doc = "Field `IFR_DISABLE` writer - IFR_DISABLE"]
97pub type IfrDisableW<'a, REG> = crate::BitWriter<'a, REG, IfrDisable>;
98impl<'a, REG> IfrDisableW<'a, REG>
99where
100    REG: crate::Writable + crate::RegisterSpec,
101{
102    #[doc = "IFR write access to SCG trim registers not disabled. The SCG Trim registers are reprogrammed with the IFR values after any system reset."]
103    #[inline(always)]
104    pub fn enabled(self) -> &'a mut crate::W<REG> {
105        self.variant(IfrDisable::Enabled)
106    }
107    #[doc = "IFR write access to SCG trim registers during system reset is blocked."]
108    #[inline(always)]
109    pub fn disabled(self) -> &'a mut crate::W<REG> {
110        self.variant(IfrDisable::Disabled)
111    }
112}
113#[doc = "Field `TRIM_LOCK_KEY` reader - TRIM_LOCK_KEY"]
114pub type TrimLockKeyR = crate::FieldReader<u16>;
115#[doc = "Field `TRIM_LOCK_KEY` writer - TRIM_LOCK_KEY"]
116pub type TrimLockKeyW<'a, REG> = crate::FieldWriter<'a, REG, 16, u16>;
117impl R {
118    #[doc = "Bit 0 - TRIM_UNLOCK"]
119    #[inline(always)]
120    pub fn trim_unlock(&self) -> TrimUnlockR {
121        TrimUnlockR::new((self.bits & 1) != 0)
122    }
123    #[doc = "Bit 1 - IFR_DISABLE"]
124    #[inline(always)]
125    pub fn ifr_disable(&self) -> IfrDisableR {
126        IfrDisableR::new(((self.bits >> 1) & 1) != 0)
127    }
128    #[doc = "Bits 16:31 - TRIM_LOCK_KEY"]
129    #[inline(always)]
130    pub fn trim_lock_key(&self) -> TrimLockKeyR {
131        TrimLockKeyR::new(((self.bits >> 16) & 0xffff) as u16)
132    }
133}
134#[cfg(feature = "debug")]
135impl core::fmt::Debug for R {
136    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
137        f.debug_struct("TRIM_LOCK")
138            .field("trim_unlock", &self.trim_unlock())
139            .field("ifr_disable", &self.ifr_disable())
140            .field("trim_lock_key", &self.trim_lock_key())
141            .finish()
142    }
143}
144impl W {
145    #[doc = "Bit 0 - TRIM_UNLOCK"]
146    #[inline(always)]
147    pub fn trim_unlock(&mut self) -> TrimUnlockW<'_, TrimLockSpec> {
148        TrimUnlockW::new(self, 0)
149    }
150    #[doc = "Bit 1 - IFR_DISABLE"]
151    #[inline(always)]
152    pub fn ifr_disable(&mut self) -> IfrDisableW<'_, TrimLockSpec> {
153        IfrDisableW::new(self, 1)
154    }
155    #[doc = "Bits 16:31 - TRIM_LOCK_KEY"]
156    #[inline(always)]
157    pub fn trim_lock_key(&mut self) -> TrimLockKeyW<'_, TrimLockSpec> {
158        TrimLockKeyW::new(self, 16)
159    }
160}
161#[doc = "Trim Lock register\n\nYou can [`read`](crate::Reg::read) this register and get [`trim_lock::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`trim_lock::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
162pub struct TrimLockSpec;
163impl crate::RegisterSpec for TrimLockSpec {
164    type Ux = u32;
165}
166#[doc = "`read()` method returns [`trim_lock::R`](R) reader structure"]
167impl crate::Readable for TrimLockSpec {}
168#[doc = "`write(|w| ..)` method takes [`trim_lock::W`](W) writer structure"]
169impl crate::Writable for TrimLockSpec {
170    type Safety = crate::Unsafe;
171}
172#[doc = "`reset()` method sets TRIM_LOCK to value 0"]
173impl crate::Resettable for TrimLockSpec {}