mcxa_pac/adc0/
resfifo0.rs

1#[doc = "Register `RESFIFO0` reader"]
2pub type R = crate::R<Resfifo0Spec>;
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    Trigger0 = 0,
12    #[doc = "1: Trigger source 1 initiated this conversion."]
13    Trigger1 = 1,
14    #[doc = "2: Trigger source 2 initiated this conversion."]
15    Trigger2 = 2,
16    #[doc = "3: Trigger source 3 initiated this conversion."]
17    Trigger3 = 3,
18}
19impl From<Tsrc> for u8 {
20    #[inline(always)]
21    fn from(variant: Tsrc) -> Self {
22        variant as _
23    }
24}
25impl crate::FieldSpec for Tsrc {
26    type Ux = u8;
27}
28impl crate::IsEnum for Tsrc {}
29#[doc = "Field `TSRC` reader - Trigger Source"]
30pub type TsrcR = crate::FieldReader<Tsrc>;
31impl TsrcR {
32    #[doc = "Get enumerated values variant"]
33    #[inline(always)]
34    pub const fn variant(&self) -> Tsrc {
35        match self.bits {
36            0 => Tsrc::Trigger0,
37            1 => Tsrc::Trigger1,
38            2 => Tsrc::Trigger2,
39            3 => Tsrc::Trigger3,
40            _ => unreachable!(),
41        }
42    }
43    #[doc = "Trigger source 0 initiated this conversion."]
44    #[inline(always)]
45    pub fn is_trigger_0(&self) -> bool {
46        *self == Tsrc::Trigger0
47    }
48    #[doc = "Trigger source 1 initiated this conversion."]
49    #[inline(always)]
50    pub fn is_trigger_1(&self) -> bool {
51        *self == Tsrc::Trigger1
52    }
53    #[doc = "Trigger source 2 initiated this conversion."]
54    #[inline(always)]
55    pub fn is_trigger_2(&self) -> bool {
56        *self == Tsrc::Trigger2
57    }
58    #[doc = "Trigger source 3 initiated this conversion."]
59    #[inline(always)]
60    pub fn is_trigger_3(&self) -> bool {
61        *self == Tsrc::Trigger3
62    }
63}
64#[doc = "Loop Count Value\n\nValue on reset: 0"]
65#[cfg_attr(feature = "defmt", derive(defmt::Format))]
66#[derive(Clone, Copy, Debug, PartialEq, Eq)]
67#[repr(u8)]
68pub enum Loopcnt {
69    #[doc = "0: Result is from initial conversion in command."]
70    Result1 = 0,
71    #[doc = "1: Result is from second conversion in command."]
72    Result2 = 1,
73    #[doc = "2: Result is from LOOPCNT+1 conversion in command."]
74    CorrespondingResult2 = 2,
75    #[doc = "3: Result is from LOOPCNT+1 conversion in command."]
76    CorrespondingResult3 = 3,
77    #[doc = "4: Result is from LOOPCNT+1 conversion in command."]
78    CorrespondingResult4 = 4,
79    #[doc = "5: Result is from LOOPCNT+1 conversion in command."]
80    CorrespondingResult5 = 5,
81    #[doc = "6: Result is from LOOPCNT+1 conversion in command."]
82    CorrespondingResult6 = 6,
83    #[doc = "7: Result is from LOOPCNT+1 conversion in command."]
84    CorrespondingResult7 = 7,
85    #[doc = "8: Result is from LOOPCNT+1 conversion in command."]
86    CorrespondingResult8 = 8,
87    #[doc = "9: Result is from LOOPCNT+1 conversion in command."]
88    CorrespondingResult9 = 9,
89    #[doc = "15: Result is from 16th conversion in command."]
90    Result16 = 15,
91}
92impl From<Loopcnt> for u8 {
93    #[inline(always)]
94    fn from(variant: Loopcnt) -> Self {
95        variant as _
96    }
97}
98impl crate::FieldSpec for Loopcnt {
99    type Ux = u8;
100}
101impl crate::IsEnum for Loopcnt {}
102#[doc = "Field `LOOPCNT` reader - Loop Count Value"]
103pub type LoopcntR = crate::FieldReader<Loopcnt>;
104impl LoopcntR {
105    #[doc = "Get enumerated values variant"]
106    #[inline(always)]
107    pub const fn variant(&self) -> Option<Loopcnt> {
108        match self.bits {
109            0 => Some(Loopcnt::Result1),
110            1 => Some(Loopcnt::Result2),
111            2 => Some(Loopcnt::CorrespondingResult2),
112            3 => Some(Loopcnt::CorrespondingResult3),
113            4 => Some(Loopcnt::CorrespondingResult4),
114            5 => Some(Loopcnt::CorrespondingResult5),
115            6 => Some(Loopcnt::CorrespondingResult6),
116            7 => Some(Loopcnt::CorrespondingResult7),
117            8 => Some(Loopcnt::CorrespondingResult8),
118            9 => Some(Loopcnt::CorrespondingResult9),
119            15 => Some(Loopcnt::Result16),
120            _ => None,
121        }
122    }
123    #[doc = "Result is from initial conversion in command."]
124    #[inline(always)]
125    pub fn is_result_1(&self) -> bool {
126        *self == Loopcnt::Result1
127    }
128    #[doc = "Result is from second conversion in command."]
129    #[inline(always)]
130    pub fn is_result_2(&self) -> bool {
131        *self == Loopcnt::Result2
132    }
133    #[doc = "Result is from LOOPCNT+1 conversion in command."]
134    #[inline(always)]
135    pub fn is_corresponding_result_2(&self) -> bool {
136        *self == Loopcnt::CorrespondingResult2
137    }
138    #[doc = "Result is from LOOPCNT+1 conversion in command."]
139    #[inline(always)]
140    pub fn is_corresponding_result_3(&self) -> bool {
141        *self == Loopcnt::CorrespondingResult3
142    }
143    #[doc = "Result is from LOOPCNT+1 conversion in command."]
144    #[inline(always)]
145    pub fn is_corresponding_result_4(&self) -> bool {
146        *self == Loopcnt::CorrespondingResult4
147    }
148    #[doc = "Result is from LOOPCNT+1 conversion in command."]
149    #[inline(always)]
150    pub fn is_corresponding_result_5(&self) -> bool {
151        *self == Loopcnt::CorrespondingResult5
152    }
153    #[doc = "Result is from LOOPCNT+1 conversion in command."]
154    #[inline(always)]
155    pub fn is_corresponding_result_6(&self) -> bool {
156        *self == Loopcnt::CorrespondingResult6
157    }
158    #[doc = "Result is from LOOPCNT+1 conversion in command."]
159    #[inline(always)]
160    pub fn is_corresponding_result_7(&self) -> bool {
161        *self == Loopcnt::CorrespondingResult7
162    }
163    #[doc = "Result is from LOOPCNT+1 conversion in command."]
164    #[inline(always)]
165    pub fn is_corresponding_result_8(&self) -> bool {
166        *self == Loopcnt::CorrespondingResult8
167    }
168    #[doc = "Result is from LOOPCNT+1 conversion in command."]
169    #[inline(always)]
170    pub fn is_corresponding_result_9(&self) -> bool {
171        *self == Loopcnt::CorrespondingResult9
172    }
173    #[doc = "Result is from 16th conversion in command."]
174    #[inline(always)]
175    pub fn is_result_16(&self) -> bool {
176        *self == Loopcnt::Result16
177    }
178}
179#[doc = "Command Buffer Source\n\nValue on reset: 0"]
180#[cfg_attr(feature = "defmt", derive(defmt::Format))]
181#[derive(Clone, Copy, Debug, PartialEq, Eq)]
182#[repr(u8)]
183pub enum Cmdsrc {
184    #[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."]
185    NotValid = 0,
186    #[doc = "1: CMD1 buffer used as control settings for this conversion."]
187    Cmd1 = 1,
188    #[doc = "2: Corresponding command buffer used as control settings for this conversion."]
189    CorrespondingCmd2 = 2,
190    #[doc = "3: Corresponding command buffer used as control settings for this conversion."]
191    CorrespondingCmd3 = 3,
192    #[doc = "4: Corresponding command buffer used as control settings for this conversion."]
193    CorrespondingCmd4 = 4,
194    #[doc = "5: Corresponding command buffer used as control settings for this conversion."]
195    CorrespondingCmd5 = 5,
196    #[doc = "6: Corresponding command buffer used as control settings for this conversion."]
197    CorrespondingCmd6 = 6,
198    #[doc = "7: CMD7 buffer used as control settings for this conversion."]
199    Cmd7 = 7,
200}
201impl From<Cmdsrc> for u8 {
202    #[inline(always)]
203    fn from(variant: Cmdsrc) -> Self {
204        variant as _
205    }
206}
207impl crate::FieldSpec for Cmdsrc {
208    type Ux = u8;
209}
210impl crate::IsEnum for Cmdsrc {}
211#[doc = "Field `CMDSRC` reader - Command Buffer Source"]
212pub type CmdsrcR = crate::FieldReader<Cmdsrc>;
213impl CmdsrcR {
214    #[doc = "Get enumerated values variant"]
215    #[inline(always)]
216    pub const fn variant(&self) -> Cmdsrc {
217        match self.bits {
218            0 => Cmdsrc::NotValid,
219            1 => Cmdsrc::Cmd1,
220            2 => Cmdsrc::CorrespondingCmd2,
221            3 => Cmdsrc::CorrespondingCmd3,
222            4 => Cmdsrc::CorrespondingCmd4,
223            5 => Cmdsrc::CorrespondingCmd5,
224            6 => Cmdsrc::CorrespondingCmd6,
225            7 => Cmdsrc::Cmd7,
226            _ => unreachable!(),
227        }
228    }
229    #[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."]
230    #[inline(always)]
231    pub fn is_not_valid(&self) -> bool {
232        *self == Cmdsrc::NotValid
233    }
234    #[doc = "CMD1 buffer used as control settings for this conversion."]
235    #[inline(always)]
236    pub fn is_cmd1(&self) -> bool {
237        *self == Cmdsrc::Cmd1
238    }
239    #[doc = "Corresponding command buffer used as control settings for this conversion."]
240    #[inline(always)]
241    pub fn is_corresponding_cmd_2(&self) -> bool {
242        *self == Cmdsrc::CorrespondingCmd2
243    }
244    #[doc = "Corresponding command buffer used as control settings for this conversion."]
245    #[inline(always)]
246    pub fn is_corresponding_cmd_3(&self) -> bool {
247        *self == Cmdsrc::CorrespondingCmd3
248    }
249    #[doc = "Corresponding command buffer used as control settings for this conversion."]
250    #[inline(always)]
251    pub fn is_corresponding_cmd_4(&self) -> bool {
252        *self == Cmdsrc::CorrespondingCmd4
253    }
254    #[doc = "Corresponding command buffer used as control settings for this conversion."]
255    #[inline(always)]
256    pub fn is_corresponding_cmd_5(&self) -> bool {
257        *self == Cmdsrc::CorrespondingCmd5
258    }
259    #[doc = "Corresponding command buffer used as control settings for this conversion."]
260    #[inline(always)]
261    pub fn is_corresponding_cmd_6(&self) -> bool {
262        *self == Cmdsrc::CorrespondingCmd6
263    }
264    #[doc = "CMD7 buffer used as control settings for this conversion."]
265    #[inline(always)]
266    pub fn is_cmd7(&self) -> bool {
267        *self == Cmdsrc::Cmd7
268    }
269}
270#[doc = "FIFO Entry is Valid\n\nValue on reset: 0"]
271#[cfg_attr(feature = "defmt", derive(defmt::Format))]
272#[derive(Clone, Copy, Debug, PartialEq, Eq)]
273pub enum Valid {
274    #[doc = "0: FIFO is empty. Discard any read from RESFIFO."]
275    NotValid = 0,
276    #[doc = "1: FIFO record read from RESFIFO is valid."]
277    Valid = 1,
278}
279impl From<Valid> for bool {
280    #[inline(always)]
281    fn from(variant: Valid) -> Self {
282        variant as u8 != 0
283    }
284}
285#[doc = "Field `VALID` reader - FIFO Entry is Valid"]
286pub type ValidR = crate::BitReader<Valid>;
287impl ValidR {
288    #[doc = "Get enumerated values variant"]
289    #[inline(always)]
290    pub const fn variant(&self) -> Valid {
291        match self.bits {
292            false => Valid::NotValid,
293            true => Valid::Valid,
294        }
295    }
296    #[doc = "FIFO is empty. Discard any read from RESFIFO."]
297    #[inline(always)]
298    pub fn is_not_valid(&self) -> bool {
299        *self == Valid::NotValid
300    }
301    #[doc = "FIFO record read from RESFIFO is valid."]
302    #[inline(always)]
303    pub fn is_valid(&self) -> bool {
304        *self == Valid::Valid
305    }
306}
307impl R {
308    #[doc = "Bits 0:15 - Data Result"]
309    #[inline(always)]
310    pub fn d(&self) -> DR {
311        DR::new((self.bits & 0xffff) as u16)
312    }
313    #[doc = "Bits 16:17 - Trigger Source"]
314    #[inline(always)]
315    pub fn tsrc(&self) -> TsrcR {
316        TsrcR::new(((self.bits >> 16) & 3) as u8)
317    }
318    #[doc = "Bits 20:23 - Loop Count Value"]
319    #[inline(always)]
320    pub fn loopcnt(&self) -> LoopcntR {
321        LoopcntR::new(((self.bits >> 20) & 0x0f) as u8)
322    }
323    #[doc = "Bits 24:26 - Command Buffer Source"]
324    #[inline(always)]
325    pub fn cmdsrc(&self) -> CmdsrcR {
326        CmdsrcR::new(((self.bits >> 24) & 7) as u8)
327    }
328    #[doc = "Bit 31 - FIFO Entry is Valid"]
329    #[inline(always)]
330    pub fn valid(&self) -> ValidR {
331        ValidR::new(((self.bits >> 31) & 1) != 0)
332    }
333}
334#[cfg(feature = "debug")]
335impl core::fmt::Debug for R {
336    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
337        f.debug_struct("RESFIFO0")
338            .field("d", &self.d())
339            .field("tsrc", &self.tsrc())
340            .field("loopcnt", &self.loopcnt())
341            .field("cmdsrc", &self.cmdsrc())
342            .field("valid", &self.valid())
343            .finish()
344    }
345}
346#[doc = "Data Result FIFO Register\n\nYou can [`read`](crate::Reg::read) this register and get [`resfifo0::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
347pub struct Resfifo0Spec;
348impl crate::RegisterSpec for Resfifo0Spec {
349    type Ux = u32;
350}
351#[doc = "`read()` method returns [`resfifo0::R`](R) reader structure"]
352impl crate::Readable for Resfifo0Spec {}
353#[doc = "`reset()` method sets RESFIFO0 to value 0"]
354impl crate::Resettable for Resfifo0Spec {}