Skip to main content

xmc1100/prng/
ctrl.rs

1#[doc = "Reader of register CTRL"]
2pub type R = crate::R<u16, super::CTRL>;
3#[doc = "Writer for register CTRL"]
4pub type W = crate::W<u16, super::CTRL>;
5#[doc = "Register CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRL {
7    type Type = u16;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Key Load Operation Mode\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum KLD_A {
16    #[doc = "0: Streaming mode (default)"]
17    VALUE1,
18    #[doc = "1: Key loading mode"]
19    VALUE2,
20}
21impl From<KLD_A> for bool {
22    #[inline(always)]
23    fn from(variant: KLD_A) -> Self {
24        match variant {
25            KLD_A::VALUE1 => false,
26            KLD_A::VALUE2 => true,
27        }
28    }
29}
30#[doc = "Reader of field `KLD`"]
31pub type KLD_R = crate::R<bool, KLD_A>;
32impl KLD_R {
33    #[doc = r"Get enumerated values variant"]
34    #[inline(always)]
35    pub fn variant(&self) -> KLD_A {
36        match self.bits {
37            false => KLD_A::VALUE1,
38            true => KLD_A::VALUE2,
39        }
40    }
41    #[doc = "Checks if the value of the field is `VALUE1`"]
42    #[inline(always)]
43    pub fn is_value1(&self) -> bool {
44        *self == KLD_A::VALUE1
45    }
46    #[doc = "Checks if the value of the field is `VALUE2`"]
47    #[inline(always)]
48    pub fn is_value2(&self) -> bool {
49        *self == KLD_A::VALUE2
50    }
51}
52#[doc = "Write proxy for field `KLD`"]
53pub struct KLD_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> KLD_W<'a> {
57    #[doc = r"Writes `variant` to the field"]
58    #[inline(always)]
59    pub fn variant(self, variant: KLD_A) -> &'a mut W {
60        {
61            self.bit(variant.into())
62        }
63    }
64    #[doc = "Streaming mode (default)"]
65    #[inline(always)]
66    pub fn value1(self) -> &'a mut W {
67        self.variant(KLD_A::VALUE1)
68    }
69    #[doc = "Key loading mode"]
70    #[inline(always)]
71    pub fn value2(self) -> &'a mut W {
72        self.variant(KLD_A::VALUE2)
73    }
74    #[doc = r"Sets the field bit"]
75    #[inline(always)]
76    pub fn set_bit(self) -> &'a mut W {
77        self.bit(true)
78    }
79    #[doc = r"Clears the field bit"]
80    #[inline(always)]
81    pub fn clear_bit(self) -> &'a mut W {
82        self.bit(false)
83    }
84    #[doc = r"Writes raw bits to the field"]
85    #[inline(always)]
86    pub fn bit(self, value: bool) -> &'a mut W {
87        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u16) & 0x01) << 3);
88        self.w
89    }
90}
91#[doc = "Random Data Block Size\n\nValue on reset: 0"]
92#[derive(Clone, Copy, Debug, PartialEq)]
93pub enum RDBS_A {
94    #[doc = "0: Reset state (no random data block size defined), value of PRNG_WORD is undefined."]
95    VALUE1,
96    #[doc = "1: 8 bits in PRNG_WORD.RDATA\\[7:0\\]"]
97    VALUE2,
98    #[doc = "2: 16 bits in PRNG_WORD.RDATA\\[15:0\\]"]
99    VALUE3,
100}
101impl From<RDBS_A> for u8 {
102    #[inline(always)]
103    fn from(variant: RDBS_A) -> Self {
104        match variant {
105            RDBS_A::VALUE1 => 0,
106            RDBS_A::VALUE2 => 1,
107            RDBS_A::VALUE3 => 2,
108        }
109    }
110}
111#[doc = "Reader of field `RDBS`"]
112pub type RDBS_R = crate::R<u8, RDBS_A>;
113impl RDBS_R {
114    #[doc = r"Get enumerated values variant"]
115    #[inline(always)]
116    pub fn variant(&self) -> crate::Variant<u8, RDBS_A> {
117        use crate::Variant::*;
118        match self.bits {
119            0 => Val(RDBS_A::VALUE1),
120            1 => Val(RDBS_A::VALUE2),
121            2 => Val(RDBS_A::VALUE3),
122            i => Res(i),
123        }
124    }
125    #[doc = "Checks if the value of the field is `VALUE1`"]
126    #[inline(always)]
127    pub fn is_value1(&self) -> bool {
128        *self == RDBS_A::VALUE1
129    }
130    #[doc = "Checks if the value of the field is `VALUE2`"]
131    #[inline(always)]
132    pub fn is_value2(&self) -> bool {
133        *self == RDBS_A::VALUE2
134    }
135    #[doc = "Checks if the value of the field is `VALUE3`"]
136    #[inline(always)]
137    pub fn is_value3(&self) -> bool {
138        *self == RDBS_A::VALUE3
139    }
140}
141#[doc = "Write proxy for field `RDBS`"]
142pub struct RDBS_W<'a> {
143    w: &'a mut W,
144}
145impl<'a> RDBS_W<'a> {
146    #[doc = r"Writes `variant` to the field"]
147    #[inline(always)]
148    pub fn variant(self, variant: RDBS_A) -> &'a mut W {
149        unsafe { self.bits(variant.into()) }
150    }
151    #[doc = "Reset state (no random data block size defined), value of PRNG_WORD is undefined."]
152    #[inline(always)]
153    pub fn value1(self) -> &'a mut W {
154        self.variant(RDBS_A::VALUE1)
155    }
156    #[doc = "8 bits in PRNG_WORD.RDATA\\[7:0\\]"]
157    #[inline(always)]
158    pub fn value2(self) -> &'a mut W {
159        self.variant(RDBS_A::VALUE2)
160    }
161    #[doc = "16 bits in PRNG_WORD.RDATA\\[15:0\\]"]
162    #[inline(always)]
163    pub fn value3(self) -> &'a mut W {
164        self.variant(RDBS_A::VALUE3)
165    }
166    #[doc = r"Writes raw bits to the field"]
167    #[inline(always)]
168    pub unsafe fn bits(self, value: u8) -> &'a mut W {
169        self.w.bits = (self.w.bits & !(0x03 << 1)) | (((value as u16) & 0x03) << 1);
170        self.w
171    }
172}
173impl R {
174    #[doc = "Bit 3 - Key Load Operation Mode"]
175    #[inline(always)]
176    pub fn kld(&self) -> KLD_R {
177        KLD_R::new(((self.bits >> 3) & 0x01) != 0)
178    }
179    #[doc = "Bits 1:2 - Random Data Block Size"]
180    #[inline(always)]
181    pub fn rdbs(&self) -> RDBS_R {
182        RDBS_R::new(((self.bits >> 1) & 0x03) as u8)
183    }
184}
185impl W {
186    #[doc = "Bit 3 - Key Load Operation Mode"]
187    #[inline(always)]
188    pub fn kld(&mut self) -> KLD_W {
189        KLD_W { w: self }
190    }
191    #[doc = "Bits 1:2 - Random Data Block Size"]
192    #[inline(always)]
193    pub fn rdbs(&mut self) -> RDBS_W {
194        RDBS_W { w: self }
195    }
196}