Skip to main content

mcxa_pac/sgi0/
sgi_status.rs

1#[doc = "Register `sgi_status` reader"]
2pub type R = crate::R<SgiStatusSpec>;
3#[doc = "Register `sgi_status` writer"]
4pub type W = crate::W<SgiStatusSpec>;
5#[doc = "Field `busy` reader - Combined busy flag that remains high"]
6pub type BusyR = crate::BitReader;
7#[doc = "Field `oflow` reader - Overflow in INCR operation flag"]
8pub type OflowR = crate::BitReader;
9#[doc = "Field `oflow` writer - Overflow in INCR operation flag"]
10pub type OflowW<'a, REG> = crate::BitWriter<'a, REG>;
11#[doc = "Field `prng_rdy` reader - prng is ready after boot-up-phase"]
12pub type PrngRdyR = crate::BitReader;
13#[doc = "Error detected\n\nValue on reset: 0"]
14#[cfg_attr(feature = "defmt", derive(defmt::Format))]
15#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16#[repr(u8)]
17pub enum Error {
18    #[doc = "0: ERROR(all values other than 0x05 indicate ERROR)"]
19    Error = 0,
20    #[doc = "5: NO_ERROR"]
21    NoError = 5,
22}
23impl From<Error> for u8 {
24    #[inline(always)]
25    fn from(variant: Error) -> Self {
26        variant as _
27    }
28}
29impl crate::FieldSpec for Error {
30    type Ux = u8;
31}
32impl crate::IsEnum for Error {}
33#[doc = "Field `error` reader - Error detected"]
34pub type ErrorR = crate::FieldReader<Error>;
35impl ErrorR {
36    #[doc = "Get enumerated values variant"]
37    #[inline(always)]
38    pub const fn variant(&self) -> Option<Error> {
39        match self.bits {
40            0 => Some(Error::Error),
41            5 => Some(Error::NoError),
42            _ => None,
43        }
44    }
45    #[doc = "ERROR(all values other than 0x05 indicate ERROR)"]
46    #[inline(always)]
47    pub fn is_error(&self) -> bool {
48        *self == Error::Error
49    }
50    #[doc = "NO_ERROR"]
51    #[inline(always)]
52    pub fn is_no_error(&self) -> bool {
53        *self == Error::NoError
54    }
55}
56#[doc = "Field `error` writer - Error detected"]
57pub type ErrorW<'a, REG> = crate::FieldWriter<'a, REG, 3, Error>;
58impl<'a, REG> ErrorW<'a, REG>
59where
60    REG: crate::Writable + crate::RegisterSpec,
61    REG::Ux: From<u8>,
62{
63    #[doc = "ERROR(all values other than 0x05 indicate ERROR)"]
64    #[inline(always)]
65    pub fn error(self) -> &'a mut crate::W<REG> {
66        self.variant(Error::Error)
67    }
68    #[doc = "NO_ERROR"]
69    #[inline(always)]
70    pub fn no_error(self) -> &'a mut crate::W<REG> {
71        self.variant(Error::NoError)
72    }
73}
74#[doc = "Field `sha2_busy` reader - SHA2 is busy"]
75pub type Sha2BusyR = crate::BitReader;
76#[doc = "Field `irq` reader - interrupt detected"]
77pub type IrqR = crate::BitReader;
78#[doc = "Field `irq` writer - interrupt detected"]
79pub type IrqW<'a, REG> = crate::BitWriter<'a, REG>;
80#[doc = "Field `sha_fifo_full` reader - SHA FIFO is full(operates in SHA AUTO mode)"]
81pub type ShaFifoFullR = crate::BitReader;
82#[doc = "Field `sha_fifo_level` reader - SHA FIFO level"]
83pub type ShaFifoLevelR = crate::FieldReader;
84#[doc = "Field `sha_error` reader - SHA ERROR"]
85pub type ShaErrorR = crate::BitReader;
86#[doc = "Field `key_read_err` reader - KEY SFR READ ERROR, sticky, cleared only with reset or flush"]
87pub type KeyReadErrR = crate::BitReader;
88#[doc = "Field `key_read_err` writer - KEY SFR READ ERROR, sticky, cleared only with reset or flush"]
89pub type KeyReadErrW<'a, REG> = crate::BitWriter<'a, REG>;
90#[doc = "Field `key_unwrap_err` reader - KEY UNWRAP ERROR , sticky, cleared only with reset or flush"]
91pub type KeyUnwrapErrR = crate::BitReader;
92#[doc = "Field `key_unwrap_err` writer - KEY UNWRAP ERROR , sticky, cleared only with reset or flush"]
93pub type KeyUnwrapErrW<'a, REG> = crate::BitWriter<'a, REG>;
94#[doc = "Field `status_rsvd3` reader - reserved"]
95pub type StatusRsvd3R = crate::BitReader;
96#[doc = "Field `status_rsvd` reader - reserved"]
97pub type StatusRsvdR = crate::FieldReader<u16>;
98impl R {
99    #[doc = "Bit 0 - Combined busy flag that remains high"]
100    #[inline(always)]
101    pub fn busy(&self) -> BusyR {
102        BusyR::new((self.bits & 1) != 0)
103    }
104    #[doc = "Bit 1 - Overflow in INCR operation flag"]
105    #[inline(always)]
106    pub fn oflow(&self) -> OflowR {
107        OflowR::new(((self.bits >> 1) & 1) != 0)
108    }
109    #[doc = "Bit 2 - prng is ready after boot-up-phase"]
110    #[inline(always)]
111    pub fn prng_rdy(&self) -> PrngRdyR {
112        PrngRdyR::new(((self.bits >> 2) & 1) != 0)
113    }
114    #[doc = "Bits 3:5 - Error detected"]
115    #[inline(always)]
116    pub fn error(&self) -> ErrorR {
117        ErrorR::new(((self.bits >> 3) & 7) as u8)
118    }
119    #[doc = "Bit 6 - SHA2 is busy"]
120    #[inline(always)]
121    pub fn sha2_busy(&self) -> Sha2BusyR {
122        Sha2BusyR::new(((self.bits >> 6) & 1) != 0)
123    }
124    #[doc = "Bit 7 - interrupt detected"]
125    #[inline(always)]
126    pub fn irq(&self) -> IrqR {
127        IrqR::new(((self.bits >> 7) & 1) != 0)
128    }
129    #[doc = "Bit 8 - SHA FIFO is full(operates in SHA AUTO mode)"]
130    #[inline(always)]
131    pub fn sha_fifo_full(&self) -> ShaFifoFullR {
132        ShaFifoFullR::new(((self.bits >> 8) & 1) != 0)
133    }
134    #[doc = "Bits 9:14 - SHA FIFO level"]
135    #[inline(always)]
136    pub fn sha_fifo_level(&self) -> ShaFifoLevelR {
137        ShaFifoLevelR::new(((self.bits >> 9) & 0x3f) as u8)
138    }
139    #[doc = "Bit 15 - SHA ERROR"]
140    #[inline(always)]
141    pub fn sha_error(&self) -> ShaErrorR {
142        ShaErrorR::new(((self.bits >> 15) & 1) != 0)
143    }
144    #[doc = "Bit 16 - KEY SFR READ ERROR, sticky, cleared only with reset or flush"]
145    #[inline(always)]
146    pub fn key_read_err(&self) -> KeyReadErrR {
147        KeyReadErrR::new(((self.bits >> 16) & 1) != 0)
148    }
149    #[doc = "Bit 17 - KEY UNWRAP ERROR , sticky, cleared only with reset or flush"]
150    #[inline(always)]
151    pub fn key_unwrap_err(&self) -> KeyUnwrapErrR {
152        KeyUnwrapErrR::new(((self.bits >> 17) & 1) != 0)
153    }
154    #[doc = "Bit 18 - reserved"]
155    #[inline(always)]
156    pub fn status_rsvd3(&self) -> StatusRsvd3R {
157        StatusRsvd3R::new(((self.bits >> 18) & 1) != 0)
158    }
159    #[doc = "Bits 19:31 - reserved"]
160    #[inline(always)]
161    pub fn status_rsvd(&self) -> StatusRsvdR {
162        StatusRsvdR::new(((self.bits >> 19) & 0x1fff) as u16)
163    }
164}
165#[cfg(feature = "debug")]
166impl core::fmt::Debug for R {
167    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
168        f.debug_struct("sgi_status")
169            .field("busy", &self.busy())
170            .field("oflow", &self.oflow())
171            .field("prng_rdy", &self.prng_rdy())
172            .field("error", &self.error())
173            .field("sha2_busy", &self.sha2_busy())
174            .field("irq", &self.irq())
175            .field("sha_fifo_full", &self.sha_fifo_full())
176            .field("sha_fifo_level", &self.sha_fifo_level())
177            .field("sha_error", &self.sha_error())
178            .field("key_read_err", &self.key_read_err())
179            .field("key_unwrap_err", &self.key_unwrap_err())
180            .field("status_rsvd3", &self.status_rsvd3())
181            .field("status_rsvd", &self.status_rsvd())
182            .finish()
183    }
184}
185impl W {
186    #[doc = "Bit 1 - Overflow in INCR operation flag"]
187    #[inline(always)]
188    pub fn oflow(&mut self) -> OflowW<'_, SgiStatusSpec> {
189        OflowW::new(self, 1)
190    }
191    #[doc = "Bits 3:5 - Error detected"]
192    #[inline(always)]
193    pub fn error(&mut self) -> ErrorW<'_, SgiStatusSpec> {
194        ErrorW::new(self, 3)
195    }
196    #[doc = "Bit 7 - interrupt detected"]
197    #[inline(always)]
198    pub fn irq(&mut self) -> IrqW<'_, SgiStatusSpec> {
199        IrqW::new(self, 7)
200    }
201    #[doc = "Bit 16 - KEY SFR READ ERROR, sticky, cleared only with reset or flush"]
202    #[inline(always)]
203    pub fn key_read_err(&mut self) -> KeyReadErrW<'_, SgiStatusSpec> {
204        KeyReadErrW::new(self, 16)
205    }
206    #[doc = "Bit 17 - KEY UNWRAP ERROR , sticky, cleared only with reset or flush"]
207    #[inline(always)]
208    pub fn key_unwrap_err(&mut self) -> KeyUnwrapErrW<'_, SgiStatusSpec> {
209        KeyUnwrapErrW::new(self, 17)
210    }
211}
212#[doc = "Status register\n\nYou can [`read`](crate::Reg::read) this register and get [`sgi_status::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sgi_status::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
213pub struct SgiStatusSpec;
214impl crate::RegisterSpec for SgiStatusSpec {
215    type Ux = u32;
216}
217#[doc = "`read()` method returns [`sgi_status::R`](R) reader structure"]
218impl crate::Readable for SgiStatusSpec {}
219#[doc = "`write(|w| ..)` method takes [`sgi_status::W`](W) writer structure"]
220impl crate::Writable for SgiStatusSpec {
221    type Safety = crate::Unsafe;
222}
223#[doc = "`reset()` method sets sgi_status to value 0"]
224impl crate::Resettable for SgiStatusSpec {}