lpc55_pac/hashcrypt/
status.rs

1#[doc = "Register `STATUS` reader"]
2pub struct R(crate::R<STATUS_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<STATUS_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<STATUS_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<STATUS_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `STATUS` writer"]
17pub struct W(crate::W<STATUS_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<STATUS_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<STATUS_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<STATUS_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "If 1, the block is waiting for more data to process.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum WAITING_A {
40    #[doc = "0: Not waiting for data - may be disabled or may be busy. Note that for cryptographic uses, this is not set if IsLast is set nor will it set until at least 1 word is read of the output."]
41    NOT_WAITING = 0,
42    #[doc = "1: Waiting for data to be written in (16 words)"]
43    WAITING = 1,
44}
45impl From<WAITING_A> for bool {
46    #[inline(always)]
47    fn from(variant: WAITING_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `WAITING` reader - If 1, the block is waiting for more data to process."]
52pub struct WAITING_R(crate::FieldReader<bool, WAITING_A>);
53impl WAITING_R {
54    #[inline(always)]
55    pub(crate) fn new(bits: bool) -> Self {
56        WAITING_R(crate::FieldReader::new(bits))
57    }
58    #[doc = r"Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> WAITING_A {
61        match self.bits {
62            false => WAITING_A::NOT_WAITING,
63            true => WAITING_A::WAITING,
64        }
65    }
66    #[doc = "Checks if the value of the field is `NOT_WAITING`"]
67    #[inline(always)]
68    pub fn is_not_waiting(&self) -> bool {
69        **self == WAITING_A::NOT_WAITING
70    }
71    #[doc = "Checks if the value of the field is `WAITING`"]
72    #[inline(always)]
73    pub fn is_waiting(&self) -> bool {
74        **self == WAITING_A::WAITING
75    }
76}
77impl core::ops::Deref for WAITING_R {
78    type Target = crate::FieldReader<bool, WAITING_A>;
79    #[inline(always)]
80    fn deref(&self) -> &Self::Target {
81        &self.0
82    }
83}
84#[doc = "For Hash, if 1 then a DIGEST is ready and waiting and there is no active next block already started. For Cryptographic uses, this will be set for each block processed, indicating OUTDATA (and OUTDATA2 if larger output) contains the next value to read out. This is cleared when any data is written, when New is written, for Cryptographic uses when the last word is read out, or when the block is disabled.\n\nValue on reset: 0"]
85#[derive(Clone, Copy, Debug, PartialEq)]
86pub enum DIGEST_A {
87    #[doc = "0: No Digest is ready"]
88    NOT_READY = 0,
89    #[doc = "1: Digest is ready. Application may read it or may write more data"]
90    READY = 1,
91}
92impl From<DIGEST_A> for bool {
93    #[inline(always)]
94    fn from(variant: DIGEST_A) -> Self {
95        variant as u8 != 0
96    }
97}
98#[doc = "Field `DIGEST` reader - For Hash, if 1 then a DIGEST is ready and waiting and there is no active next block already started. For Cryptographic uses, this will be set for each block processed, indicating OUTDATA (and OUTDATA2 if larger output) contains the next value to read out. This is cleared when any data is written, when New is written, for Cryptographic uses when the last word is read out, or when the block is disabled."]
99pub struct DIGEST_R(crate::FieldReader<bool, DIGEST_A>);
100impl DIGEST_R {
101    #[inline(always)]
102    pub(crate) fn new(bits: bool) -> Self {
103        DIGEST_R(crate::FieldReader::new(bits))
104    }
105    #[doc = r"Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> DIGEST_A {
108        match self.bits {
109            false => DIGEST_A::NOT_READY,
110            true => DIGEST_A::READY,
111        }
112    }
113    #[doc = "Checks if the value of the field is `NOT_READY`"]
114    #[inline(always)]
115    pub fn is_not_ready(&self) -> bool {
116        **self == DIGEST_A::NOT_READY
117    }
118    #[doc = "Checks if the value of the field is `READY`"]
119    #[inline(always)]
120    pub fn is_ready(&self) -> bool {
121        **self == DIGEST_A::READY
122    }
123}
124impl core::ops::Deref for DIGEST_R {
125    type Target = crate::FieldReader<bool, DIGEST_A>;
126    #[inline(always)]
127    fn deref(&self) -> &Self::Target {
128        &self.0
129    }
130}
131#[doc = "If 1, an error occurred. For normal uses, this is due to an attempted overrun: INDATA was written when it was not appropriate. For Master cases, this is an AHB bus error; the COUNT field will indicate which block it was on.\n\nValue on reset: 0"]
132#[derive(Clone, Copy, Debug, PartialEq)]
133pub enum ERROR_A {
134    #[doc = "0: No error."]
135    NO_ERROR = 0,
136    #[doc = "1: An error occurred since last cleared (written 1 to clear)."]
137    ERROR = 1,
138}
139impl From<ERROR_A> for bool {
140    #[inline(always)]
141    fn from(variant: ERROR_A) -> Self {
142        variant as u8 != 0
143    }
144}
145#[doc = "Field `ERROR` reader - If 1, an error occurred. For normal uses, this is due to an attempted overrun: INDATA was written when it was not appropriate. For Master cases, this is an AHB bus error; the COUNT field will indicate which block it was on."]
146pub struct ERROR_R(crate::FieldReader<bool, ERROR_A>);
147impl ERROR_R {
148    #[inline(always)]
149    pub(crate) fn new(bits: bool) -> Self {
150        ERROR_R(crate::FieldReader::new(bits))
151    }
152    #[doc = r"Get enumerated values variant"]
153    #[inline(always)]
154    pub fn variant(&self) -> ERROR_A {
155        match self.bits {
156            false => ERROR_A::NO_ERROR,
157            true => ERROR_A::ERROR,
158        }
159    }
160    #[doc = "Checks if the value of the field is `NO_ERROR`"]
161    #[inline(always)]
162    pub fn is_no_error(&self) -> bool {
163        **self == ERROR_A::NO_ERROR
164    }
165    #[doc = "Checks if the value of the field is `ERROR`"]
166    #[inline(always)]
167    pub fn is_error(&self) -> bool {
168        **self == ERROR_A::ERROR
169    }
170}
171impl core::ops::Deref for ERROR_R {
172    type Target = crate::FieldReader<bool, ERROR_A>;
173    #[inline(always)]
174    fn deref(&self) -> &Self::Target {
175        &self.0
176    }
177}
178#[doc = "Field `ERROR` writer - If 1, an error occurred. For normal uses, this is due to an attempted overrun: INDATA was written when it was not appropriate. For Master cases, this is an AHB bus error; the COUNT field will indicate which block it was on."]
179pub struct ERROR_W<'a> {
180    w: &'a mut W,
181}
182impl<'a> ERROR_W<'a> {
183    #[doc = r"Writes `variant` to the field"]
184    #[inline(always)]
185    pub fn variant(self, variant: ERROR_A) -> &'a mut W {
186        self.bit(variant.into())
187    }
188    #[doc = "No error."]
189    #[inline(always)]
190    pub fn no_error(self) -> &'a mut W {
191        self.variant(ERROR_A::NO_ERROR)
192    }
193    #[doc = "An error occurred since last cleared (written 1 to clear)."]
194    #[inline(always)]
195    pub fn error(self) -> &'a mut W {
196        self.variant(ERROR_A::ERROR)
197    }
198    #[doc = r"Sets the field bit"]
199    #[inline(always)]
200    pub fn set_bit(self) -> &'a mut W {
201        self.bit(true)
202    }
203    #[doc = r"Clears the field bit"]
204    #[inline(always)]
205    pub fn clear_bit(self) -> &'a mut W {
206        self.bit(false)
207    }
208    #[doc = r"Writes raw bits to the field"]
209    #[inline(always)]
210    pub fn bit(self, value: bool) -> &'a mut W {
211        self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
212        self.w
213    }
214}
215#[doc = "Indicates the block wants the key to be written in (set along with WAITING)\n\nValue on reset: 0"]
216#[derive(Clone, Copy, Debug, PartialEq)]
217pub enum NEEDKEY_A {
218    #[doc = "0: No Key is needed and writes will not be treated as Key"]
219    NOT_NEED = 0,
220    #[doc = "1: Key is needed and INDATA/ALIAS will be accepted as Key. Will also set WAITING."]
221    NEED = 1,
222}
223impl From<NEEDKEY_A> for bool {
224    #[inline(always)]
225    fn from(variant: NEEDKEY_A) -> Self {
226        variant as u8 != 0
227    }
228}
229#[doc = "Field `NEEDKEY` reader - Indicates the block wants the key to be written in (set along with WAITING)"]
230pub struct NEEDKEY_R(crate::FieldReader<bool, NEEDKEY_A>);
231impl NEEDKEY_R {
232    #[inline(always)]
233    pub(crate) fn new(bits: bool) -> Self {
234        NEEDKEY_R(crate::FieldReader::new(bits))
235    }
236    #[doc = r"Get enumerated values variant"]
237    #[inline(always)]
238    pub fn variant(&self) -> NEEDKEY_A {
239        match self.bits {
240            false => NEEDKEY_A::NOT_NEED,
241            true => NEEDKEY_A::NEED,
242        }
243    }
244    #[doc = "Checks if the value of the field is `NOT_NEED`"]
245    #[inline(always)]
246    pub fn is_not_need(&self) -> bool {
247        **self == NEEDKEY_A::NOT_NEED
248    }
249    #[doc = "Checks if the value of the field is `NEED`"]
250    #[inline(always)]
251    pub fn is_need(&self) -> bool {
252        **self == NEEDKEY_A::NEED
253    }
254}
255impl core::ops::Deref for NEEDKEY_R {
256    type Target = crate::FieldReader<bool, NEEDKEY_A>;
257    #[inline(always)]
258    fn deref(&self) -> &Self::Target {
259        &self.0
260    }
261}
262#[doc = "Indicates the block wants an IV/NONE to be written in (set along with WAITING)\n\nValue on reset: 0"]
263#[derive(Clone, Copy, Debug, PartialEq)]
264pub enum NEEDIV_A {
265    #[doc = "0: No IV/Nonce is needed, either because written already or because not needed."]
266    NOT_NEED = 0,
267    #[doc = "1: IV/Nonce is needed and INDATA/ALIAS will be accepted as IV/Nonce. Will also set WAITING."]
268    NEED = 1,
269}
270impl From<NEEDIV_A> for bool {
271    #[inline(always)]
272    fn from(variant: NEEDIV_A) -> Self {
273        variant as u8 != 0
274    }
275}
276#[doc = "Field `NEEDIV` reader - Indicates the block wants an IV/NONE to be written in (set along with WAITING)"]
277pub struct NEEDIV_R(crate::FieldReader<bool, NEEDIV_A>);
278impl NEEDIV_R {
279    #[inline(always)]
280    pub(crate) fn new(bits: bool) -> Self {
281        NEEDIV_R(crate::FieldReader::new(bits))
282    }
283    #[doc = r"Get enumerated values variant"]
284    #[inline(always)]
285    pub fn variant(&self) -> NEEDIV_A {
286        match self.bits {
287            false => NEEDIV_A::NOT_NEED,
288            true => NEEDIV_A::NEED,
289        }
290    }
291    #[doc = "Checks if the value of the field is `NOT_NEED`"]
292    #[inline(always)]
293    pub fn is_not_need(&self) -> bool {
294        **self == NEEDIV_A::NOT_NEED
295    }
296    #[doc = "Checks if the value of the field is `NEED`"]
297    #[inline(always)]
298    pub fn is_need(&self) -> bool {
299        **self == NEEDIV_A::NEED
300    }
301}
302impl core::ops::Deref for NEEDIV_R {
303    type Target = crate::FieldReader<bool, NEEDIV_A>;
304    #[inline(always)]
305    fn deref(&self) -> &Self::Target {
306        &self.0
307    }
308}
309#[doc = "Field `ICBIDX` reader - If ICB-AES is selected, then reads as the ICB index count based on ICBSTRM (from CRYPTCFG). That is, if 3 bits of ICBSTRM, then this will count from 0 to 7 and then back to 0. On 0, it has to compute the full ICB, quicker when not 0."]
310pub struct ICBIDX_R(crate::FieldReader<u8, u8>);
311impl ICBIDX_R {
312    #[inline(always)]
313    pub(crate) fn new(bits: u8) -> Self {
314        ICBIDX_R(crate::FieldReader::new(bits))
315    }
316}
317impl core::ops::Deref for ICBIDX_R {
318    type Target = crate::FieldReader<u8, u8>;
319    #[inline(always)]
320    fn deref(&self) -> &Self::Target {
321        &self.0
322    }
323}
324impl R {
325    #[doc = "Bit 0 - If 1, the block is waiting for more data to process."]
326    #[inline(always)]
327    pub fn waiting(&self) -> WAITING_R {
328        WAITING_R::new((self.bits & 0x01) != 0)
329    }
330    #[doc = "Bit 1 - For Hash, if 1 then a DIGEST is ready and waiting and there is no active next block already started. For Cryptographic uses, this will be set for each block processed, indicating OUTDATA (and OUTDATA2 if larger output) contains the next value to read out. This is cleared when any data is written, when New is written, for Cryptographic uses when the last word is read out, or when the block is disabled."]
331    #[inline(always)]
332    pub fn digest(&self) -> DIGEST_R {
333        DIGEST_R::new(((self.bits >> 1) & 0x01) != 0)
334    }
335    #[doc = "Bit 2 - If 1, an error occurred. For normal uses, this is due to an attempted overrun: INDATA was written when it was not appropriate. For Master cases, this is an AHB bus error; the COUNT field will indicate which block it was on."]
336    #[inline(always)]
337    pub fn error(&self) -> ERROR_R {
338        ERROR_R::new(((self.bits >> 2) & 0x01) != 0)
339    }
340    #[doc = "Bit 4 - Indicates the block wants the key to be written in (set along with WAITING)"]
341    #[inline(always)]
342    pub fn needkey(&self) -> NEEDKEY_R {
343        NEEDKEY_R::new(((self.bits >> 4) & 0x01) != 0)
344    }
345    #[doc = "Bit 5 - Indicates the block wants an IV/NONE to be written in (set along with WAITING)"]
346    #[inline(always)]
347    pub fn neediv(&self) -> NEEDIV_R {
348        NEEDIV_R::new(((self.bits >> 5) & 0x01) != 0)
349    }
350    #[doc = "Bits 16:21 - If ICB-AES is selected, then reads as the ICB index count based on ICBSTRM (from CRYPTCFG). That is, if 3 bits of ICBSTRM, then this will count from 0 to 7 and then back to 0. On 0, it has to compute the full ICB, quicker when not 0."]
351    #[inline(always)]
352    pub fn icbidx(&self) -> ICBIDX_R {
353        ICBIDX_R::new(((self.bits >> 16) & 0x3f) as u8)
354    }
355}
356impl W {
357    #[doc = "Bit 2 - If 1, an error occurred. For normal uses, this is due to an attempted overrun: INDATA was written when it was not appropriate. For Master cases, this is an AHB bus error; the COUNT field will indicate which block it was on."]
358    #[inline(always)]
359    pub fn error(&mut self) -> ERROR_W {
360        ERROR_W { w: self }
361    }
362    #[doc = "Writes raw bits to the register."]
363    #[inline(always)]
364    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
365        self.0.bits(bits);
366        self
367    }
368}
369#[doc = "Indicates status of Hash peripheral.\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [status](index.html) module"]
370pub struct STATUS_SPEC;
371impl crate::RegisterSpec for STATUS_SPEC {
372    type Ux = u32;
373}
374#[doc = "`read()` method returns [status::R](R) reader structure"]
375impl crate::Readable for STATUS_SPEC {
376    type Reader = R;
377}
378#[doc = "`write(|w| ..)` method takes [status::W](W) writer structure"]
379impl crate::Writable for STATUS_SPEC {
380    type Writer = W;
381}
382#[doc = "`reset()` method sets STATUS to value 0"]
383impl crate::Resettable for STATUS_SPEC {
384    #[inline(always)]
385    fn reset_value() -> Self::Ux {
386        0
387    }
388}