mimxrt685s_pac/casper/
ctrl1.rs

1#[doc = "Register `CTRL1` reader"]
2pub type R = crate::R<Ctrl1Spec>;
3#[doc = "Register `CTRL1` writer"]
4pub type W = crate::W<Ctrl1Spec>;
5#[doc = "Field `ITER` reader - Iteration counter. Is number_cycles - 1. write 0 means Does one cycle - does not iterate."]
6pub type IterR = crate::FieldReader;
7#[doc = "Field `ITER` writer - Iteration counter. Is number_cycles - 1. write 0 means Does one cycle - does not iterate."]
8pub type IterW<'a, REG> = crate::FieldWriter<'a, REG, 8>;
9#[doc = "Field `MODE` reader - Operation mode to perform. write 0 means Accelerator is inactive. write others means accelerator is active."]
10pub type ModeR = crate::FieldReader;
11#[doc = "Field `MODE` writer - Operation mode to perform. write 0 means Accelerator is inactive. write others means accelerator is active."]
12pub type ModeW<'a, REG> = crate::FieldWriter<'a, REG, 8>;
13#[doc = "Which bank-pair the offset RESOFF is within. This must be 0 if only 2-up. Ideally this is not the same bank as ABBPAIR (when 4-up supported)\n\nValue on reset: 0"]
14#[cfg_attr(feature = "defmt", derive(defmt::Format))]
15#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16pub enum Resbpair {
17    #[doc = "0: Bank-pair 0 (1st)"]
18    Pair0 = 0,
19    #[doc = "1: Bank-pair 1 (2nd)"]
20    Pair1 = 1,
21}
22impl From<Resbpair> for bool {
23    #[inline(always)]
24    fn from(variant: Resbpair) -> Self {
25        variant as u8 != 0
26    }
27}
28#[doc = "Field `RESBPAIR` reader - Which bank-pair the offset RESOFF is within. This must be 0 if only 2-up. Ideally this is not the same bank as ABBPAIR (when 4-up supported)"]
29pub type ResbpairR = crate::BitReader<Resbpair>;
30impl ResbpairR {
31    #[doc = "Get enumerated values variant"]
32    #[inline(always)]
33    pub const fn variant(&self) -> Resbpair {
34        match self.bits {
35            false => Resbpair::Pair0,
36            true => Resbpair::Pair1,
37        }
38    }
39    #[doc = "Bank-pair 0 (1st)"]
40    #[inline(always)]
41    pub fn is_pair0(&self) -> bool {
42        *self == Resbpair::Pair0
43    }
44    #[doc = "Bank-pair 1 (2nd)"]
45    #[inline(always)]
46    pub fn is_pair1(&self) -> bool {
47        *self == Resbpair::Pair1
48    }
49}
50#[doc = "Field `RESBPAIR` writer - Which bank-pair the offset RESOFF is within. This must be 0 if only 2-up. Ideally this is not the same bank as ABBPAIR (when 4-up supported)"]
51pub type ResbpairW<'a, REG> = crate::BitWriter<'a, REG, Resbpair>;
52impl<'a, REG> ResbpairW<'a, REG>
53where
54    REG: crate::Writable + crate::RegisterSpec,
55{
56    #[doc = "Bank-pair 0 (1st)"]
57    #[inline(always)]
58    pub fn pair0(self) -> &'a mut crate::W<REG> {
59        self.variant(Resbpair::Pair0)
60    }
61    #[doc = "Bank-pair 1 (2nd)"]
62    #[inline(always)]
63    pub fn pair1(self) -> &'a mut crate::W<REG> {
64        self.variant(Resbpair::Pair1)
65    }
66}
67#[doc = "Field `RESOFF` reader - Word or DWord Offset of result. Word offset only allowed if 32 bit operation. Ideally not in the same RAM as the AB and CD values"]
68pub type ResoffR = crate::FieldReader<u16>;
69#[doc = "Field `RESOFF` writer - Word or DWord Offset of result. Word offset only allowed if 32 bit operation. Ideally not in the same RAM as the AB and CD values"]
70pub type ResoffW<'a, REG> = crate::FieldWriter<'a, REG, 11, u16>;
71#[doc = "Skip rules on Carry if needed. This operation will be skipped based on Carry value (from previous operation) if not 0:\n\nValue on reset: 0"]
72#[cfg_attr(feature = "defmt", derive(defmt::Format))]
73#[derive(Clone, Copy, Debug, PartialEq, Eq)]
74#[repr(u8)]
75pub enum Cskip {
76    #[doc = "0: No Skip"]
77    NoSkip = 0,
78    #[doc = "1: Skip if Carry is 1"]
79    SkipIf1 = 1,
80    #[doc = "2: Skip if Carry is 0"]
81    SkipIf0 = 2,
82    #[doc = "3: Set CTRLOFF to CDOFF and Skip"]
83    SetAndSkip = 3,
84}
85impl From<Cskip> for u8 {
86    #[inline(always)]
87    fn from(variant: Cskip) -> Self {
88        variant as _
89    }
90}
91impl crate::FieldSpec for Cskip {
92    type Ux = u8;
93}
94impl crate::IsEnum for Cskip {}
95#[doc = "Field `CSKIP` reader - Skip rules on Carry if needed. This operation will be skipped based on Carry value (from previous operation) if not 0:"]
96pub type CskipR = crate::FieldReader<Cskip>;
97impl CskipR {
98    #[doc = "Get enumerated values variant"]
99    #[inline(always)]
100    pub const fn variant(&self) -> Cskip {
101        match self.bits {
102            0 => Cskip::NoSkip,
103            1 => Cskip::SkipIf1,
104            2 => Cskip::SkipIf0,
105            3 => Cskip::SetAndSkip,
106            _ => unreachable!(),
107        }
108    }
109    #[doc = "No Skip"]
110    #[inline(always)]
111    pub fn is_no_skip(&self) -> bool {
112        *self == Cskip::NoSkip
113    }
114    #[doc = "Skip if Carry is 1"]
115    #[inline(always)]
116    pub fn is_skip_if_1(&self) -> bool {
117        *self == Cskip::SkipIf1
118    }
119    #[doc = "Skip if Carry is 0"]
120    #[inline(always)]
121    pub fn is_skip_if_0(&self) -> bool {
122        *self == Cskip::SkipIf0
123    }
124    #[doc = "Set CTRLOFF to CDOFF and Skip"]
125    #[inline(always)]
126    pub fn is_set_and_skip(&self) -> bool {
127        *self == Cskip::SetAndSkip
128    }
129}
130#[doc = "Field `CSKIP` writer - Skip rules on Carry if needed. This operation will be skipped based on Carry value (from previous operation) if not 0:"]
131pub type CskipW<'a, REG> = crate::FieldWriter<'a, REG, 2, Cskip, crate::Safe>;
132impl<'a, REG> CskipW<'a, REG>
133where
134    REG: crate::Writable + crate::RegisterSpec,
135    REG::Ux: From<u8>,
136{
137    #[doc = "No Skip"]
138    #[inline(always)]
139    pub fn no_skip(self) -> &'a mut crate::W<REG> {
140        self.variant(Cskip::NoSkip)
141    }
142    #[doc = "Skip if Carry is 1"]
143    #[inline(always)]
144    pub fn skip_if_1(self) -> &'a mut crate::W<REG> {
145        self.variant(Cskip::SkipIf1)
146    }
147    #[doc = "Skip if Carry is 0"]
148    #[inline(always)]
149    pub fn skip_if_0(self) -> &'a mut crate::W<REG> {
150        self.variant(Cskip::SkipIf0)
151    }
152    #[doc = "Set CTRLOFF to CDOFF and Skip"]
153    #[inline(always)]
154    pub fn set_and_skip(self) -> &'a mut crate::W<REG> {
155        self.variant(Cskip::SetAndSkip)
156    }
157}
158impl R {
159    #[doc = "Bits 0:7 - Iteration counter. Is number_cycles - 1. write 0 means Does one cycle - does not iterate."]
160    #[inline(always)]
161    pub fn iter(&self) -> IterR {
162        IterR::new((self.bits & 0xff) as u8)
163    }
164    #[doc = "Bits 8:15 - Operation mode to perform. write 0 means Accelerator is inactive. write others means accelerator is active."]
165    #[inline(always)]
166    pub fn mode(&self) -> ModeR {
167        ModeR::new(((self.bits >> 8) & 0xff) as u8)
168    }
169    #[doc = "Bit 16 - Which bank-pair the offset RESOFF is within. This must be 0 if only 2-up. Ideally this is not the same bank as ABBPAIR (when 4-up supported)"]
170    #[inline(always)]
171    pub fn resbpair(&self) -> ResbpairR {
172        ResbpairR::new(((self.bits >> 16) & 1) != 0)
173    }
174    #[doc = "Bits 18:28 - Word or DWord Offset of result. Word offset only allowed if 32 bit operation. Ideally not in the same RAM as the AB and CD values"]
175    #[inline(always)]
176    pub fn resoff(&self) -> ResoffR {
177        ResoffR::new(((self.bits >> 18) & 0x07ff) as u16)
178    }
179    #[doc = "Bits 30:31 - Skip rules on Carry if needed. This operation will be skipped based on Carry value (from previous operation) if not 0:"]
180    #[inline(always)]
181    pub fn cskip(&self) -> CskipR {
182        CskipR::new(((self.bits >> 30) & 3) as u8)
183    }
184}
185#[cfg(feature = "debug")]
186impl core::fmt::Debug for R {
187    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
188        f.debug_struct("CTRL1")
189            .field("iter", &self.iter())
190            .field("mode", &self.mode())
191            .field("resbpair", &self.resbpair())
192            .field("resoff", &self.resoff())
193            .field("cskip", &self.cskip())
194            .finish()
195    }
196}
197impl W {
198    #[doc = "Bits 0:7 - Iteration counter. Is number_cycles - 1. write 0 means Does one cycle - does not iterate."]
199    #[inline(always)]
200    pub fn iter(&mut self) -> IterW<Ctrl1Spec> {
201        IterW::new(self, 0)
202    }
203    #[doc = "Bits 8:15 - Operation mode to perform. write 0 means Accelerator is inactive. write others means accelerator is active."]
204    #[inline(always)]
205    pub fn mode(&mut self) -> ModeW<Ctrl1Spec> {
206        ModeW::new(self, 8)
207    }
208    #[doc = "Bit 16 - Which bank-pair the offset RESOFF is within. This must be 0 if only 2-up. Ideally this is not the same bank as ABBPAIR (when 4-up supported)"]
209    #[inline(always)]
210    pub fn resbpair(&mut self) -> ResbpairW<Ctrl1Spec> {
211        ResbpairW::new(self, 16)
212    }
213    #[doc = "Bits 18:28 - Word or DWord Offset of result. Word offset only allowed if 32 bit operation. Ideally not in the same RAM as the AB and CD values"]
214    #[inline(always)]
215    pub fn resoff(&mut self) -> ResoffW<Ctrl1Spec> {
216        ResoffW::new(self, 18)
217    }
218    #[doc = "Bits 30:31 - Skip rules on Carry if needed. This operation will be skipped based on Carry value (from previous operation) if not 0:"]
219    #[inline(always)]
220    pub fn cskip(&mut self) -> CskipW<Ctrl1Spec> {
221        CskipW::new(self, 30)
222    }
223}
224#[doc = "Contains the opcode mode, iteration count, and result offset (in RAM) and also launches the accelerator. Note: with CP version: CTRL0 and CRTL1 can be written in one go with MCRR.\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrl1::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl1::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
225pub struct Ctrl1Spec;
226impl crate::RegisterSpec for Ctrl1Spec {
227    type Ux = u32;
228}
229#[doc = "`read()` method returns [`ctrl1::R`](R) reader structure"]
230impl crate::Readable for Ctrl1Spec {}
231#[doc = "`write(|w| ..)` method takes [`ctrl1::W`](W) writer structure"]
232impl crate::Writable for Ctrl1Spec {
233    type Safety = crate::Unsafe;
234    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
235    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
236}
237#[doc = "`reset()` method sets CTRL1 to value 0"]
238impl crate::Resettable for Ctrl1Spec {
239    const RESET_VALUE: u32 = 0;
240}