max78000_pac/trng/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub type R = crate::R<CtrlSpec>;
3#[doc = "Register `CTRL` writer"]
4pub type W = crate::W<CtrlSpec>;
5#[doc = "To enable IRQ generation when a new 32-bit Random number is ready.\n\nValue on reset: 1"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum RndIe {
8    #[doc = "0: Disable"]
9    Disable = 0,
10    #[doc = "1: Enable"]
11    Enable = 1,
12}
13impl From<RndIe> for bool {
14    #[inline(always)]
15    fn from(variant: RndIe) -> Self {
16        variant as u8 != 0
17    }
18}
19#[doc = "Field `RND_IE` reader - To enable IRQ generation when a new 32-bit Random number is ready."]
20pub type RndIeR = crate::BitReader<RndIe>;
21impl RndIeR {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> RndIe {
25        match self.bits {
26            false => RndIe::Disable,
27            true => RndIe::Enable,
28        }
29    }
30    #[doc = "Disable"]
31    #[inline(always)]
32    pub fn is_disable(&self) -> bool {
33        *self == RndIe::Disable
34    }
35    #[doc = "Enable"]
36    #[inline(always)]
37    pub fn is_enable(&self) -> bool {
38        *self == RndIe::Enable
39    }
40}
41#[doc = "Field `RND_IE` writer - To enable IRQ generation when a new 32-bit Random number is ready."]
42pub type RndIeW<'a, REG> = crate::BitWriter<'a, REG, RndIe>;
43impl<'a, REG> RndIeW<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "Disable"]
48    #[inline(always)]
49    pub fn disable(self) -> &'a mut crate::W<REG> {
50        self.variant(RndIe::Disable)
51    }
52    #[doc = "Enable"]
53    #[inline(always)]
54    pub fn enable(self) -> &'a mut crate::W<REG> {
55        self.variant(RndIe::Enable)
56    }
57}
58#[doc = "Field `KEYGEN` reader - AES Key Generate. When enabled, the key for securing NVSRAM is generated and transferred to the secure key register automatically without user visibility or intervention. This bit is cleared by hardware once the key has been transferred to the secure key register."]
59pub type KeygenR = crate::BitReader;
60#[doc = "Field `KEYGEN` writer - AES Key Generate. When enabled, the key for securing NVSRAM is generated and transferred to the secure key register automatically without user visibility or intervention. This bit is cleared by hardware once the key has been transferred to the secure key register."]
61pub type KeygenW<'a, REG> = crate::BitWriter<'a, REG>;
62#[doc = "Field `KEYWIPE` reader - To wipe the Battery Backed key."]
63pub type KeywipeR = crate::BitReader;
64#[doc = "Field `KEYWIPE` writer - To wipe the Battery Backed key."]
65pub type KeywipeW<'a, REG> = crate::BitWriter<'a, REG>;
66impl R {
67    #[doc = "Bit 1 - To enable IRQ generation when a new 32-bit Random number is ready."]
68    #[inline(always)]
69    pub fn rnd_ie(&self) -> RndIeR {
70        RndIeR::new(((self.bits >> 1) & 1) != 0)
71    }
72    #[doc = "Bit 3 - AES Key Generate. When enabled, the key for securing NVSRAM is generated and transferred to the secure key register automatically without user visibility or intervention. This bit is cleared by hardware once the key has been transferred to the secure key register."]
73    #[inline(always)]
74    pub fn keygen(&self) -> KeygenR {
75        KeygenR::new(((self.bits >> 3) & 1) != 0)
76    }
77    #[doc = "Bit 15 - To wipe the Battery Backed key."]
78    #[inline(always)]
79    pub fn keywipe(&self) -> KeywipeR {
80        KeywipeR::new(((self.bits >> 15) & 1) != 0)
81    }
82}
83impl W {
84    #[doc = "Bit 1 - To enable IRQ generation when a new 32-bit Random number is ready."]
85    #[inline(always)]
86    pub fn rnd_ie(&mut self) -> RndIeW<CtrlSpec> {
87        RndIeW::new(self, 1)
88    }
89    #[doc = "Bit 3 - AES Key Generate. When enabled, the key for securing NVSRAM is generated and transferred to the secure key register automatically without user visibility or intervention. This bit is cleared by hardware once the key has been transferred to the secure key register."]
90    #[inline(always)]
91    pub fn keygen(&mut self) -> KeygenW<CtrlSpec> {
92        KeygenW::new(self, 3)
93    }
94    #[doc = "Bit 15 - To wipe the Battery Backed key."]
95    #[inline(always)]
96    pub fn keywipe(&mut self) -> KeywipeW<CtrlSpec> {
97        KeywipeW::new(self, 15)
98    }
99}
100#[doc = "TRNG Control Register.\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
101pub struct CtrlSpec;
102impl crate::RegisterSpec for CtrlSpec {
103    type Ux = u32;
104}
105#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
106impl crate::Readable for CtrlSpec {}
107#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
108impl crate::Writable for CtrlSpec {
109    type Safety = crate::Unsafe;
110    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
111    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
112}
113#[doc = "`reset()` method sets CTRL to value 0x03"]
114impl crate::Resettable for CtrlSpec {
115    const RESET_VALUE: u32 = 0x03;
116}