mimxrt685s_pac/adc0/
resfifo.rs

1#[doc = "Register `RESFIFO` reader"]
2pub type R = crate::R<ResfifoSpec>;
3#[doc = "Field `D` reader - Data result"]
4pub type DR = crate::FieldReader<u16>;
5#[doc = "Trigger Source\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8#[repr(u8)]
9pub enum Tsrc {
10    #[doc = "0: Trigger source 0 initiated this conversion."]
11    Tsrc0 = 0,
12    #[doc = "1: Trigger source 1 initiated this conversion."]
13    Tsrc1 = 1,
14    #[doc = "2: Corresponding trigger source initiated this conversion."]
15    Tsrc2 = 2,
16    #[doc = "3: Corresponding trigger source initiated this conversion."]
17    Tsrc3 = 3,
18    #[doc = "4: Corresponding trigger source initiated this conversion."]
19    Tsrc4 = 4,
20    #[doc = "5: Corresponding trigger source initiated this conversion."]
21    Tsrc5 = 5,
22    #[doc = "6: Corresponding trigger source initiated this conversion."]
23    Tsrc6 = 6,
24    #[doc = "7: Corresponding trigger source initiated this conversion."]
25    Tsrc7 = 7,
26    #[doc = "8: Corresponding trigger source initiated this conversion."]
27    Tsrc8 = 8,
28    #[doc = "9: Corresponding trigger source initiated this conversion."]
29    Tsrc9 = 9,
30    #[doc = "15: Trigger source 15 initiated this conversion."]
31    Tsrc15 = 15,
32}
33impl From<Tsrc> for u8 {
34    #[inline(always)]
35    fn from(variant: Tsrc) -> Self {
36        variant as _
37    }
38}
39impl crate::FieldSpec for Tsrc {
40    type Ux = u8;
41}
42impl crate::IsEnum for Tsrc {}
43#[doc = "Field `TSRC` reader - Trigger Source"]
44pub type TsrcR = crate::FieldReader<Tsrc>;
45impl TsrcR {
46    #[doc = "Get enumerated values variant"]
47    #[inline(always)]
48    pub const fn variant(&self) -> Option<Tsrc> {
49        match self.bits {
50            0 => Some(Tsrc::Tsrc0),
51            1 => Some(Tsrc::Tsrc1),
52            2 => Some(Tsrc::Tsrc2),
53            3 => Some(Tsrc::Tsrc3),
54            4 => Some(Tsrc::Tsrc4),
55            5 => Some(Tsrc::Tsrc5),
56            6 => Some(Tsrc::Tsrc6),
57            7 => Some(Tsrc::Tsrc7),
58            8 => Some(Tsrc::Tsrc8),
59            9 => Some(Tsrc::Tsrc9),
60            15 => Some(Tsrc::Tsrc15),
61            _ => None,
62        }
63    }
64    #[doc = "Trigger source 0 initiated this conversion."]
65    #[inline(always)]
66    pub fn is_tsrc_0(&self) -> bool {
67        *self == Tsrc::Tsrc0
68    }
69    #[doc = "Trigger source 1 initiated this conversion."]
70    #[inline(always)]
71    pub fn is_tsrc_1(&self) -> bool {
72        *self == Tsrc::Tsrc1
73    }
74    #[doc = "Corresponding trigger source initiated this conversion."]
75    #[inline(always)]
76    pub fn is_tsrc_2(&self) -> bool {
77        *self == Tsrc::Tsrc2
78    }
79    #[doc = "Corresponding trigger source initiated this conversion."]
80    #[inline(always)]
81    pub fn is_tsrc_3(&self) -> bool {
82        *self == Tsrc::Tsrc3
83    }
84    #[doc = "Corresponding trigger source initiated this conversion."]
85    #[inline(always)]
86    pub fn is_tsrc_4(&self) -> bool {
87        *self == Tsrc::Tsrc4
88    }
89    #[doc = "Corresponding trigger source initiated this conversion."]
90    #[inline(always)]
91    pub fn is_tsrc_5(&self) -> bool {
92        *self == Tsrc::Tsrc5
93    }
94    #[doc = "Corresponding trigger source initiated this conversion."]
95    #[inline(always)]
96    pub fn is_tsrc_6(&self) -> bool {
97        *self == Tsrc::Tsrc6
98    }
99    #[doc = "Corresponding trigger source initiated this conversion."]
100    #[inline(always)]
101    pub fn is_tsrc_7(&self) -> bool {
102        *self == Tsrc::Tsrc7
103    }
104    #[doc = "Corresponding trigger source initiated this conversion."]
105    #[inline(always)]
106    pub fn is_tsrc_8(&self) -> bool {
107        *self == Tsrc::Tsrc8
108    }
109    #[doc = "Corresponding trigger source initiated this conversion."]
110    #[inline(always)]
111    pub fn is_tsrc_9(&self) -> bool {
112        *self == Tsrc::Tsrc9
113    }
114    #[doc = "Trigger source 15 initiated this conversion."]
115    #[inline(always)]
116    pub fn is_tsrc_15(&self) -> bool {
117        *self == Tsrc::Tsrc15
118    }
119}
120#[doc = "Loop count value\n\nValue on reset: 0"]
121#[cfg_attr(feature = "defmt", derive(defmt::Format))]
122#[derive(Clone, Copy, Debug, PartialEq, Eq)]
123#[repr(u8)]
124pub enum Loopcnt {
125    #[doc = "0: Result is from initial conversion in command."]
126    Loopcnt0 = 0,
127    #[doc = "1: Result is from second conversion in command."]
128    Loopcnt1 = 1,
129    #[doc = "2: Result is from LOOPCNT+1 conversion in command."]
130    Loopcnt2 = 2,
131    #[doc = "3: Result is from LOOPCNT+1 conversion in command."]
132    Loopcnt3 = 3,
133    #[doc = "4: Result is from LOOPCNT+1 conversion in command."]
134    Loopcnt4 = 4,
135    #[doc = "5: Result is from LOOPCNT+1 conversion in command."]
136    Loopcnt5 = 5,
137    #[doc = "6: Result is from LOOPCNT+1 conversion in command."]
138    Loopcnt6 = 6,
139    #[doc = "7: Result is from LOOPCNT+1 conversion in command."]
140    Loopcnt7 = 7,
141    #[doc = "8: Result is from LOOPCNT+1 conversion in command."]
142    Loopcnt8 = 8,
143    #[doc = "9: Result is from LOOPCNT+1 conversion in command."]
144    Loopcnt9 = 9,
145    #[doc = "15: Result is from 16th conversion in command."]
146    Loopcnt15 = 15,
147}
148impl From<Loopcnt> for u8 {
149    #[inline(always)]
150    fn from(variant: Loopcnt) -> Self {
151        variant as _
152    }
153}
154impl crate::FieldSpec for Loopcnt {
155    type Ux = u8;
156}
157impl crate::IsEnum for Loopcnt {}
158#[doc = "Field `LOOPCNT` reader - Loop count value"]
159pub type LoopcntR = crate::FieldReader<Loopcnt>;
160impl LoopcntR {
161    #[doc = "Get enumerated values variant"]
162    #[inline(always)]
163    pub const fn variant(&self) -> Option<Loopcnt> {
164        match self.bits {
165            0 => Some(Loopcnt::Loopcnt0),
166            1 => Some(Loopcnt::Loopcnt1),
167            2 => Some(Loopcnt::Loopcnt2),
168            3 => Some(Loopcnt::Loopcnt3),
169            4 => Some(Loopcnt::Loopcnt4),
170            5 => Some(Loopcnt::Loopcnt5),
171            6 => Some(Loopcnt::Loopcnt6),
172            7 => Some(Loopcnt::Loopcnt7),
173            8 => Some(Loopcnt::Loopcnt8),
174            9 => Some(Loopcnt::Loopcnt9),
175            15 => Some(Loopcnt::Loopcnt15),
176            _ => None,
177        }
178    }
179    #[doc = "Result is from initial conversion in command."]
180    #[inline(always)]
181    pub fn is_loopcnt_0(&self) -> bool {
182        *self == Loopcnt::Loopcnt0
183    }
184    #[doc = "Result is from second conversion in command."]
185    #[inline(always)]
186    pub fn is_loopcnt_1(&self) -> bool {
187        *self == Loopcnt::Loopcnt1
188    }
189    #[doc = "Result is from LOOPCNT+1 conversion in command."]
190    #[inline(always)]
191    pub fn is_loopcnt_2(&self) -> bool {
192        *self == Loopcnt::Loopcnt2
193    }
194    #[doc = "Result is from LOOPCNT+1 conversion in command."]
195    #[inline(always)]
196    pub fn is_loopcnt_3(&self) -> bool {
197        *self == Loopcnt::Loopcnt3
198    }
199    #[doc = "Result is from LOOPCNT+1 conversion in command."]
200    #[inline(always)]
201    pub fn is_loopcnt_4(&self) -> bool {
202        *self == Loopcnt::Loopcnt4
203    }
204    #[doc = "Result is from LOOPCNT+1 conversion in command."]
205    #[inline(always)]
206    pub fn is_loopcnt_5(&self) -> bool {
207        *self == Loopcnt::Loopcnt5
208    }
209    #[doc = "Result is from LOOPCNT+1 conversion in command."]
210    #[inline(always)]
211    pub fn is_loopcnt_6(&self) -> bool {
212        *self == Loopcnt::Loopcnt6
213    }
214    #[doc = "Result is from LOOPCNT+1 conversion in command."]
215    #[inline(always)]
216    pub fn is_loopcnt_7(&self) -> bool {
217        *self == Loopcnt::Loopcnt7
218    }
219    #[doc = "Result is from LOOPCNT+1 conversion in command."]
220    #[inline(always)]
221    pub fn is_loopcnt_8(&self) -> bool {
222        *self == Loopcnt::Loopcnt8
223    }
224    #[doc = "Result is from LOOPCNT+1 conversion in command."]
225    #[inline(always)]
226    pub fn is_loopcnt_9(&self) -> bool {
227        *self == Loopcnt::Loopcnt9
228    }
229    #[doc = "Result is from 16th conversion in command."]
230    #[inline(always)]
231    pub fn is_loopcnt_15(&self) -> bool {
232        *self == Loopcnt::Loopcnt15
233    }
234}
235#[doc = "Command Buffer Source\n\nValue on reset: 0"]
236#[cfg_attr(feature = "defmt", derive(defmt::Format))]
237#[derive(Clone, Copy, Debug, PartialEq, Eq)]
238#[repr(u8)]
239pub enum Cmdsrc {
240    #[doc = "0: Not a valid value CMDSRC value for a dataword in RESFIFO. 0x0 is only found in initial FIFO state prior to an ADC conversion result dataword being stored to a RESFIFO buffer."]
241    Cmdsrc0 = 0,
242    #[doc = "1: CMD1 buffer used as control settings for this conversion."]
243    Cmdsrc1 = 1,
244    #[doc = "2: Corresponding command buffer used as control settings for this conversion."]
245    Cmdsrc2 = 2,
246    #[doc = "3: Corresponding command buffer used as control settings for this conversion."]
247    Cmdsrc3 = 3,
248    #[doc = "4: Corresponding command buffer used as control settings for this conversion."]
249    Cmdsrc4 = 4,
250    #[doc = "5: Corresponding command buffer used as control settings for this conversion."]
251    Cmdsrc5 = 5,
252    #[doc = "6: Corresponding command buffer used as control settings for this conversion."]
253    Cmdsrc6 = 6,
254    #[doc = "7: Corresponding command buffer used as control settings for this conversion."]
255    Cmdsrc7 = 7,
256    #[doc = "8: Corresponding command buffer used as control settings for this conversion."]
257    Cmdsrc8 = 8,
258    #[doc = "9: Corresponding command buffer used as control settings for this conversion."]
259    Cmdsrc9 = 9,
260    #[doc = "15: CMD15 buffer used as control settings for this conversion."]
261    Cmdsrc15 = 15,
262}
263impl From<Cmdsrc> for u8 {
264    #[inline(always)]
265    fn from(variant: Cmdsrc) -> Self {
266        variant as _
267    }
268}
269impl crate::FieldSpec for Cmdsrc {
270    type Ux = u8;
271}
272impl crate::IsEnum for Cmdsrc {}
273#[doc = "Field `CMDSRC` reader - Command Buffer Source"]
274pub type CmdsrcR = crate::FieldReader<Cmdsrc>;
275impl CmdsrcR {
276    #[doc = "Get enumerated values variant"]
277    #[inline(always)]
278    pub const fn variant(&self) -> Option<Cmdsrc> {
279        match self.bits {
280            0 => Some(Cmdsrc::Cmdsrc0),
281            1 => Some(Cmdsrc::Cmdsrc1),
282            2 => Some(Cmdsrc::Cmdsrc2),
283            3 => Some(Cmdsrc::Cmdsrc3),
284            4 => Some(Cmdsrc::Cmdsrc4),
285            5 => Some(Cmdsrc::Cmdsrc5),
286            6 => Some(Cmdsrc::Cmdsrc6),
287            7 => Some(Cmdsrc::Cmdsrc7),
288            8 => Some(Cmdsrc::Cmdsrc8),
289            9 => Some(Cmdsrc::Cmdsrc9),
290            15 => Some(Cmdsrc::Cmdsrc15),
291            _ => None,
292        }
293    }
294    #[doc = "Not a valid value CMDSRC value for a dataword in RESFIFO. 0x0 is only found in initial FIFO state prior to an ADC conversion result dataword being stored to a RESFIFO buffer."]
295    #[inline(always)]
296    pub fn is_cmdsrc_0(&self) -> bool {
297        *self == Cmdsrc::Cmdsrc0
298    }
299    #[doc = "CMD1 buffer used as control settings for this conversion."]
300    #[inline(always)]
301    pub fn is_cmdsrc_1(&self) -> bool {
302        *self == Cmdsrc::Cmdsrc1
303    }
304    #[doc = "Corresponding command buffer used as control settings for this conversion."]
305    #[inline(always)]
306    pub fn is_cmdsrc_2(&self) -> bool {
307        *self == Cmdsrc::Cmdsrc2
308    }
309    #[doc = "Corresponding command buffer used as control settings for this conversion."]
310    #[inline(always)]
311    pub fn is_cmdsrc_3(&self) -> bool {
312        *self == Cmdsrc::Cmdsrc3
313    }
314    #[doc = "Corresponding command buffer used as control settings for this conversion."]
315    #[inline(always)]
316    pub fn is_cmdsrc_4(&self) -> bool {
317        *self == Cmdsrc::Cmdsrc4
318    }
319    #[doc = "Corresponding command buffer used as control settings for this conversion."]
320    #[inline(always)]
321    pub fn is_cmdsrc_5(&self) -> bool {
322        *self == Cmdsrc::Cmdsrc5
323    }
324    #[doc = "Corresponding command buffer used as control settings for this conversion."]
325    #[inline(always)]
326    pub fn is_cmdsrc_6(&self) -> bool {
327        *self == Cmdsrc::Cmdsrc6
328    }
329    #[doc = "Corresponding command buffer used as control settings for this conversion."]
330    #[inline(always)]
331    pub fn is_cmdsrc_7(&self) -> bool {
332        *self == Cmdsrc::Cmdsrc7
333    }
334    #[doc = "Corresponding command buffer used as control settings for this conversion."]
335    #[inline(always)]
336    pub fn is_cmdsrc_8(&self) -> bool {
337        *self == Cmdsrc::Cmdsrc8
338    }
339    #[doc = "Corresponding command buffer used as control settings for this conversion."]
340    #[inline(always)]
341    pub fn is_cmdsrc_9(&self) -> bool {
342        *self == Cmdsrc::Cmdsrc9
343    }
344    #[doc = "CMD15 buffer used as control settings for this conversion."]
345    #[inline(always)]
346    pub fn is_cmdsrc_15(&self) -> bool {
347        *self == Cmdsrc::Cmdsrc15
348    }
349}
350#[doc = "FIFO entry is valid\n\nValue on reset: 0"]
351#[cfg_attr(feature = "defmt", derive(defmt::Format))]
352#[derive(Clone, Copy, Debug, PartialEq, Eq)]
353pub enum Valid {
354    #[doc = "0: FIFO is empty. Discard any read from RESFIFO."]
355    Valid0 = 0,
356    #[doc = "1: FIFO record read from RESFIFO is valid."]
357    Valid1 = 1,
358}
359impl From<Valid> for bool {
360    #[inline(always)]
361    fn from(variant: Valid) -> Self {
362        variant as u8 != 0
363    }
364}
365#[doc = "Field `VALID` reader - FIFO entry is valid"]
366pub type ValidR = crate::BitReader<Valid>;
367impl ValidR {
368    #[doc = "Get enumerated values variant"]
369    #[inline(always)]
370    pub const fn variant(&self) -> Valid {
371        match self.bits {
372            false => Valid::Valid0,
373            true => Valid::Valid1,
374        }
375    }
376    #[doc = "FIFO is empty. Discard any read from RESFIFO."]
377    #[inline(always)]
378    pub fn is_valid_0(&self) -> bool {
379        *self == Valid::Valid0
380    }
381    #[doc = "FIFO record read from RESFIFO is valid."]
382    #[inline(always)]
383    pub fn is_valid_1(&self) -> bool {
384        *self == Valid::Valid1
385    }
386}
387impl R {
388    #[doc = "Bits 3:15 - Data result"]
389    #[inline(always)]
390    pub fn d(&self) -> DR {
391        DR::new(((self.bits >> 3) & 0x1fff) as u16)
392    }
393    #[doc = "Bits 16:19 - Trigger Source"]
394    #[inline(always)]
395    pub fn tsrc(&self) -> TsrcR {
396        TsrcR::new(((self.bits >> 16) & 0x0f) as u8)
397    }
398    #[doc = "Bits 20:23 - Loop count value"]
399    #[inline(always)]
400    pub fn loopcnt(&self) -> LoopcntR {
401        LoopcntR::new(((self.bits >> 20) & 0x0f) as u8)
402    }
403    #[doc = "Bits 24:27 - Command Buffer Source"]
404    #[inline(always)]
405    pub fn cmdsrc(&self) -> CmdsrcR {
406        CmdsrcR::new(((self.bits >> 24) & 0x0f) as u8)
407    }
408    #[doc = "Bit 31 - FIFO entry is valid"]
409    #[inline(always)]
410    pub fn valid(&self) -> ValidR {
411        ValidR::new(((self.bits >> 31) & 1) != 0)
412    }
413}
414#[cfg(feature = "debug")]
415impl core::fmt::Debug for R {
416    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
417        f.debug_struct("RESFIFO")
418            .field("d", &self.d())
419            .field("tsrc", &self.tsrc())
420            .field("loopcnt", &self.loopcnt())
421            .field("cmdsrc", &self.cmdsrc())
422            .field("valid", &self.valid())
423            .finish()
424    }
425}
426#[doc = "ADC Data Result FIFO Register\n\nYou can [`read`](crate::Reg::read) this register and get [`resfifo::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
427pub struct ResfifoSpec;
428impl crate::RegisterSpec for ResfifoSpec {
429    type Ux = u32;
430}
431#[doc = "`read()` method returns [`resfifo::R`](R) reader structure"]
432impl crate::Readable for ResfifoSpec {}
433#[doc = "`reset()` method sets RESFIFO to value 0"]
434impl crate::Resettable for ResfifoSpec {
435    const RESET_VALUE: u32 = 0;
436}