mcxa_pac/adc0/
cmdl1.rs

1#[doc = "Register `CMDL1` reader"]
2pub type R = crate::R<Cmdl1Spec>;
3#[doc = "Register `CMDL1` writer"]
4pub type W = crate::W<Cmdl1Spec>;
5#[doc = "Input Channel Select\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 Adch {
10    #[doc = "0: Select CH0A."]
11    SelectCh0 = 0,
12    #[doc = "1: Select CH1A."]
13    SelectCh1 = 1,
14    #[doc = "2: Select CH2A."]
15    SelectCh2 = 2,
16    #[doc = "3: Select CH3A."]
17    SelectCh3 = 3,
18    #[doc = "4: Select corresponding channel CHnA."]
19    SelectCorrespondingChannel4 = 4,
20    #[doc = "5: Select corresponding channel CHnA."]
21    SelectCorrespondingChannel5 = 5,
22    #[doc = "6: Select corresponding channel CHnA."]
23    SelectCorrespondingChannel6 = 6,
24    #[doc = "7: Select corresponding channel CHnA."]
25    SelectCorrespondingChannel7 = 7,
26    #[doc = "8: Select corresponding channel CHnA."]
27    SelectCorrespondingChannel8 = 8,
28    #[doc = "9: Select corresponding channel CHnA."]
29    SelectCorrespondingChannel9 = 9,
30    #[doc = "30: Select CH30A."]
31    SelectCh30 = 30,
32    #[doc = "31: Select CH31A."]
33    SelectCh31 = 31,
34}
35impl From<Adch> for u8 {
36    #[inline(always)]
37    fn from(variant: Adch) -> Self {
38        variant as _
39    }
40}
41impl crate::FieldSpec for Adch {
42    type Ux = u8;
43}
44impl crate::IsEnum for Adch {}
45#[doc = "Field `ADCH` reader - Input Channel Select"]
46pub type AdchR = crate::FieldReader<Adch>;
47impl AdchR {
48    #[doc = "Get enumerated values variant"]
49    #[inline(always)]
50    pub const fn variant(&self) -> Option<Adch> {
51        match self.bits {
52            0 => Some(Adch::SelectCh0),
53            1 => Some(Adch::SelectCh1),
54            2 => Some(Adch::SelectCh2),
55            3 => Some(Adch::SelectCh3),
56            4 => Some(Adch::SelectCorrespondingChannel4),
57            5 => Some(Adch::SelectCorrespondingChannel5),
58            6 => Some(Adch::SelectCorrespondingChannel6),
59            7 => Some(Adch::SelectCorrespondingChannel7),
60            8 => Some(Adch::SelectCorrespondingChannel8),
61            9 => Some(Adch::SelectCorrespondingChannel9),
62            30 => Some(Adch::SelectCh30),
63            31 => Some(Adch::SelectCh31),
64            _ => None,
65        }
66    }
67    #[doc = "Select CH0A."]
68    #[inline(always)]
69    pub fn is_select_ch0(&self) -> bool {
70        *self == Adch::SelectCh0
71    }
72    #[doc = "Select CH1A."]
73    #[inline(always)]
74    pub fn is_select_ch1(&self) -> bool {
75        *self == Adch::SelectCh1
76    }
77    #[doc = "Select CH2A."]
78    #[inline(always)]
79    pub fn is_select_ch2(&self) -> bool {
80        *self == Adch::SelectCh2
81    }
82    #[doc = "Select CH3A."]
83    #[inline(always)]
84    pub fn is_select_ch3(&self) -> bool {
85        *self == Adch::SelectCh3
86    }
87    #[doc = "Select corresponding channel CHnA."]
88    #[inline(always)]
89    pub fn is_select_corresponding_channel_4(&self) -> bool {
90        *self == Adch::SelectCorrespondingChannel4
91    }
92    #[doc = "Select corresponding channel CHnA."]
93    #[inline(always)]
94    pub fn is_select_corresponding_channel_5(&self) -> bool {
95        *self == Adch::SelectCorrespondingChannel5
96    }
97    #[doc = "Select corresponding channel CHnA."]
98    #[inline(always)]
99    pub fn is_select_corresponding_channel_6(&self) -> bool {
100        *self == Adch::SelectCorrespondingChannel6
101    }
102    #[doc = "Select corresponding channel CHnA."]
103    #[inline(always)]
104    pub fn is_select_corresponding_channel_7(&self) -> bool {
105        *self == Adch::SelectCorrespondingChannel7
106    }
107    #[doc = "Select corresponding channel CHnA."]
108    #[inline(always)]
109    pub fn is_select_corresponding_channel_8(&self) -> bool {
110        *self == Adch::SelectCorrespondingChannel8
111    }
112    #[doc = "Select corresponding channel CHnA."]
113    #[inline(always)]
114    pub fn is_select_corresponding_channel_9(&self) -> bool {
115        *self == Adch::SelectCorrespondingChannel9
116    }
117    #[doc = "Select CH30A."]
118    #[inline(always)]
119    pub fn is_select_ch30(&self) -> bool {
120        *self == Adch::SelectCh30
121    }
122    #[doc = "Select CH31A."]
123    #[inline(always)]
124    pub fn is_select_ch31(&self) -> bool {
125        *self == Adch::SelectCh31
126    }
127}
128#[doc = "Field `ADCH` writer - Input Channel Select"]
129pub type AdchW<'a, REG> = crate::FieldWriter<'a, REG, 5, Adch>;
130impl<'a, REG> AdchW<'a, REG>
131where
132    REG: crate::Writable + crate::RegisterSpec,
133    REG::Ux: From<u8>,
134{
135    #[doc = "Select CH0A."]
136    #[inline(always)]
137    pub fn select_ch0(self) -> &'a mut crate::W<REG> {
138        self.variant(Adch::SelectCh0)
139    }
140    #[doc = "Select CH1A."]
141    #[inline(always)]
142    pub fn select_ch1(self) -> &'a mut crate::W<REG> {
143        self.variant(Adch::SelectCh1)
144    }
145    #[doc = "Select CH2A."]
146    #[inline(always)]
147    pub fn select_ch2(self) -> &'a mut crate::W<REG> {
148        self.variant(Adch::SelectCh2)
149    }
150    #[doc = "Select CH3A."]
151    #[inline(always)]
152    pub fn select_ch3(self) -> &'a mut crate::W<REG> {
153        self.variant(Adch::SelectCh3)
154    }
155    #[doc = "Select corresponding channel CHnA."]
156    #[inline(always)]
157    pub fn select_corresponding_channel_4(self) -> &'a mut crate::W<REG> {
158        self.variant(Adch::SelectCorrespondingChannel4)
159    }
160    #[doc = "Select corresponding channel CHnA."]
161    #[inline(always)]
162    pub fn select_corresponding_channel_5(self) -> &'a mut crate::W<REG> {
163        self.variant(Adch::SelectCorrespondingChannel5)
164    }
165    #[doc = "Select corresponding channel CHnA."]
166    #[inline(always)]
167    pub fn select_corresponding_channel_6(self) -> &'a mut crate::W<REG> {
168        self.variant(Adch::SelectCorrespondingChannel6)
169    }
170    #[doc = "Select corresponding channel CHnA."]
171    #[inline(always)]
172    pub fn select_corresponding_channel_7(self) -> &'a mut crate::W<REG> {
173        self.variant(Adch::SelectCorrespondingChannel7)
174    }
175    #[doc = "Select corresponding channel CHnA."]
176    #[inline(always)]
177    pub fn select_corresponding_channel_8(self) -> &'a mut crate::W<REG> {
178        self.variant(Adch::SelectCorrespondingChannel8)
179    }
180    #[doc = "Select corresponding channel CHnA."]
181    #[inline(always)]
182    pub fn select_corresponding_channel_9(self) -> &'a mut crate::W<REG> {
183        self.variant(Adch::SelectCorrespondingChannel9)
184    }
185    #[doc = "Select CH30A."]
186    #[inline(always)]
187    pub fn select_ch30(self) -> &'a mut crate::W<REG> {
188        self.variant(Adch::SelectCh30)
189    }
190    #[doc = "Select CH31A."]
191    #[inline(always)]
192    pub fn select_ch31(self) -> &'a mut crate::W<REG> {
193        self.variant(Adch::SelectCh31)
194    }
195}
196#[doc = "Conversion Type\n\nValue on reset: 0"]
197#[cfg_attr(feature = "defmt", derive(defmt::Format))]
198#[derive(Clone, Copy, Debug, PartialEq, Eq)]
199#[repr(u8)]
200pub enum Ctype {
201    #[doc = "0: Single-Ended Mode. Only A side channel is converted."]
202    SingleEndedASideChannel = 0,
203}
204impl From<Ctype> for u8 {
205    #[inline(always)]
206    fn from(variant: Ctype) -> Self {
207        variant as _
208    }
209}
210impl crate::FieldSpec for Ctype {
211    type Ux = u8;
212}
213impl crate::IsEnum for Ctype {}
214#[doc = "Field `CTYPE` reader - Conversion Type"]
215pub type CtypeR = crate::FieldReader<Ctype>;
216impl CtypeR {
217    #[doc = "Get enumerated values variant"]
218    #[inline(always)]
219    pub const fn variant(&self) -> Option<Ctype> {
220        match self.bits {
221            0 => Some(Ctype::SingleEndedASideChannel),
222            _ => None,
223        }
224    }
225    #[doc = "Single-Ended Mode. Only A side channel is converted."]
226    #[inline(always)]
227    pub fn is_single_ended_a_side_channel(&self) -> bool {
228        *self == Ctype::SingleEndedASideChannel
229    }
230}
231#[doc = "Select Resolution of Conversions\n\nValue on reset: 0"]
232#[cfg_attr(feature = "defmt", derive(defmt::Format))]
233#[derive(Clone, Copy, Debug, PartialEq, Eq)]
234pub enum Mode {
235    #[doc = "0: Standard resolution. Single-ended 12-bit conversion."]
236    Data12Bits = 0,
237    #[doc = "1: High resolution. Single-ended 16-bit conversion."]
238    Data16Bits = 1,
239}
240impl From<Mode> for bool {
241    #[inline(always)]
242    fn from(variant: Mode) -> Self {
243        variant as u8 != 0
244    }
245}
246#[doc = "Field `MODE` reader - Select Resolution of Conversions"]
247pub type ModeR = crate::BitReader<Mode>;
248impl ModeR {
249    #[doc = "Get enumerated values variant"]
250    #[inline(always)]
251    pub const fn variant(&self) -> Mode {
252        match self.bits {
253            false => Mode::Data12Bits,
254            true => Mode::Data16Bits,
255        }
256    }
257    #[doc = "Standard resolution. Single-ended 12-bit conversion."]
258    #[inline(always)]
259    pub fn is_data_12_bits(&self) -> bool {
260        *self == Mode::Data12Bits
261    }
262    #[doc = "High resolution. Single-ended 16-bit conversion."]
263    #[inline(always)]
264    pub fn is_data_16_bits(&self) -> bool {
265        *self == Mode::Data16Bits
266    }
267}
268#[doc = "Field `MODE` writer - Select Resolution of Conversions"]
269pub type ModeW<'a, REG> = crate::BitWriter<'a, REG, Mode>;
270impl<'a, REG> ModeW<'a, REG>
271where
272    REG: crate::Writable + crate::RegisterSpec,
273{
274    #[doc = "Standard resolution. Single-ended 12-bit conversion."]
275    #[inline(always)]
276    pub fn data_12_bits(self) -> &'a mut crate::W<REG> {
277        self.variant(Mode::Data12Bits)
278    }
279    #[doc = "High resolution. Single-ended 16-bit conversion."]
280    #[inline(always)]
281    pub fn data_16_bits(self) -> &'a mut crate::W<REG> {
282        self.variant(Mode::Data16Bits)
283    }
284}
285impl R {
286    #[doc = "Bits 0:4 - Input Channel Select"]
287    #[inline(always)]
288    pub fn adch(&self) -> AdchR {
289        AdchR::new((self.bits & 0x1f) as u8)
290    }
291    #[doc = "Bits 5:6 - Conversion Type"]
292    #[inline(always)]
293    pub fn ctype(&self) -> CtypeR {
294        CtypeR::new(((self.bits >> 5) & 3) as u8)
295    }
296    #[doc = "Bit 7 - Select Resolution of Conversions"]
297    #[inline(always)]
298    pub fn mode(&self) -> ModeR {
299        ModeR::new(((self.bits >> 7) & 1) != 0)
300    }
301}
302#[cfg(feature = "debug")]
303impl core::fmt::Debug for R {
304    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
305        f.debug_struct("CMDL1")
306            .field("adch", &self.adch())
307            .field("ctype", &self.ctype())
308            .field("mode", &self.mode())
309            .finish()
310    }
311}
312impl W {
313    #[doc = "Bits 0:4 - Input Channel Select"]
314    #[inline(always)]
315    pub fn adch(&mut self) -> AdchW<'_, Cmdl1Spec> {
316        AdchW::new(self, 0)
317    }
318    #[doc = "Bit 7 - Select Resolution of Conversions"]
319    #[inline(always)]
320    pub fn mode(&mut self) -> ModeW<'_, Cmdl1Spec> {
321        ModeW::new(self, 7)
322    }
323}
324#[doc = "Command Low Buffer Register\n\nYou can [`read`](crate::Reg::read) this register and get [`cmdl1::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cmdl1::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
325pub struct Cmdl1Spec;
326impl crate::RegisterSpec for Cmdl1Spec {
327    type Ux = u32;
328}
329#[doc = "`read()` method returns [`cmdl1::R`](R) reader structure"]
330impl crate::Readable for Cmdl1Spec {}
331#[doc = "`write(|w| ..)` method takes [`cmdl1::W`](W) writer structure"]
332impl crate::Writable for Cmdl1Spec {
333    type Safety = crate::Unsafe;
334}
335#[doc = "`reset()` method sets CMDL1 to value 0"]
336impl crate::Resettable for Cmdl1Spec {}