mcxa_pac/adc0/
tctrl.rs

1#[doc = "Register `TCTRL[%s]` reader"]
2pub type R = crate::R<TctrlSpec>;
3#[doc = "Register `TCTRL[%s]` writer"]
4pub type W = crate::W<TctrlSpec>;
5#[doc = "Trigger Enable\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Hten {
9    #[doc = "0: Hardware trigger source disabled"]
10    Disabled = 0,
11    #[doc = "1: Hardware trigger source enabled"]
12    Enabled = 1,
13}
14impl From<Hten> for bool {
15    #[inline(always)]
16    fn from(variant: Hten) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `HTEN` reader - Trigger Enable"]
21pub type HtenR = crate::BitReader<Hten>;
22impl HtenR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Hten {
26        match self.bits {
27            false => Hten::Disabled,
28            true => Hten::Enabled,
29        }
30    }
31    #[doc = "Hardware trigger source disabled"]
32    #[inline(always)]
33    pub fn is_disabled(&self) -> bool {
34        *self == Hten::Disabled
35    }
36    #[doc = "Hardware trigger source enabled"]
37    #[inline(always)]
38    pub fn is_enabled(&self) -> bool {
39        *self == Hten::Enabled
40    }
41}
42#[doc = "Field `HTEN` writer - Trigger Enable"]
43pub type HtenW<'a, REG> = crate::BitWriter<'a, REG, Hten>;
44impl<'a, REG> HtenW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "Hardware trigger source disabled"]
49    #[inline(always)]
50    pub fn disabled(self) -> &'a mut crate::W<REG> {
51        self.variant(Hten::Disabled)
52    }
53    #[doc = "Hardware trigger source enabled"]
54    #[inline(always)]
55    pub fn enabled(self) -> &'a mut crate::W<REG> {
56        self.variant(Hten::Enabled)
57    }
58}
59#[doc = "Trigger Priority Setting\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62#[repr(u8)]
63pub enum Tpri {
64    #[doc = "0: Set to highest priority, Level 1"]
65    HighestPriority = 0,
66    #[doc = "1: Set to corresponding priority level"]
67    CorrespondingLowerPriority1 = 1,
68    #[doc = "2: Set to corresponding priority level"]
69    CorrespondingLowerPriority2 = 2,
70    #[doc = "3: Set to lowest priority, Level 4"]
71    LowestPriority = 3,
72}
73impl From<Tpri> for u8 {
74    #[inline(always)]
75    fn from(variant: Tpri) -> Self {
76        variant as _
77    }
78}
79impl crate::FieldSpec for Tpri {
80    type Ux = u8;
81}
82impl crate::IsEnum for Tpri {}
83#[doc = "Field `TPRI` reader - Trigger Priority Setting"]
84pub type TpriR = crate::FieldReader<Tpri>;
85impl TpriR {
86    #[doc = "Get enumerated values variant"]
87    #[inline(always)]
88    pub const fn variant(&self) -> Tpri {
89        match self.bits {
90            0 => Tpri::HighestPriority,
91            1 => Tpri::CorrespondingLowerPriority1,
92            2 => Tpri::CorrespondingLowerPriority2,
93            3 => Tpri::LowestPriority,
94            _ => unreachable!(),
95        }
96    }
97    #[doc = "Set to highest priority, Level 1"]
98    #[inline(always)]
99    pub fn is_highest_priority(&self) -> bool {
100        *self == Tpri::HighestPriority
101    }
102    #[doc = "Set to corresponding priority level"]
103    #[inline(always)]
104    pub fn is_corresponding_lower_priority_1(&self) -> bool {
105        *self == Tpri::CorrespondingLowerPriority1
106    }
107    #[doc = "Set to corresponding priority level"]
108    #[inline(always)]
109    pub fn is_corresponding_lower_priority_2(&self) -> bool {
110        *self == Tpri::CorrespondingLowerPriority2
111    }
112    #[doc = "Set to lowest priority, Level 4"]
113    #[inline(always)]
114    pub fn is_lowest_priority(&self) -> bool {
115        *self == Tpri::LowestPriority
116    }
117}
118#[doc = "Field `TPRI` writer - Trigger Priority Setting"]
119pub type TpriW<'a, REG> = crate::FieldWriter<'a, REG, 2, Tpri, crate::Safe>;
120impl<'a, REG> TpriW<'a, REG>
121where
122    REG: crate::Writable + crate::RegisterSpec,
123    REG::Ux: From<u8>,
124{
125    #[doc = "Set to highest priority, Level 1"]
126    #[inline(always)]
127    pub fn highest_priority(self) -> &'a mut crate::W<REG> {
128        self.variant(Tpri::HighestPriority)
129    }
130    #[doc = "Set to corresponding priority level"]
131    #[inline(always)]
132    pub fn corresponding_lower_priority_1(self) -> &'a mut crate::W<REG> {
133        self.variant(Tpri::CorrespondingLowerPriority1)
134    }
135    #[doc = "Set to corresponding priority level"]
136    #[inline(always)]
137    pub fn corresponding_lower_priority_2(self) -> &'a mut crate::W<REG> {
138        self.variant(Tpri::CorrespondingLowerPriority2)
139    }
140    #[doc = "Set to lowest priority, Level 4"]
141    #[inline(always)]
142    pub fn lowest_priority(self) -> &'a mut crate::W<REG> {
143        self.variant(Tpri::LowestPriority)
144    }
145}
146#[doc = "Field `RSYNC` reader - Trigger Resync"]
147pub type RsyncR = crate::BitReader;
148#[doc = "Field `RSYNC` writer - Trigger Resync"]
149pub type RsyncW<'a, REG> = crate::BitWriter<'a, REG>;
150#[doc = "Field `TDLY` reader - Trigger Delay Select"]
151pub type TdlyR = crate::FieldReader;
152#[doc = "Field `TDLY` writer - Trigger Delay Select"]
153pub type TdlyW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
154#[doc = "Field `TSYNC` reader - Trigger Synchronous Select"]
155pub type TsyncR = crate::BitReader;
156#[doc = "Field `TSYNC` writer - Trigger Synchronous Select"]
157pub type TsyncW<'a, REG> = crate::BitWriter<'a, REG>;
158#[doc = "Trigger Command Select\n\nValue on reset: 0"]
159#[cfg_attr(feature = "defmt", derive(defmt::Format))]
160#[derive(Clone, Copy, Debug, PartialEq, Eq)]
161#[repr(u8)]
162pub enum Tcmd {
163    #[doc = "0: Not a valid selection from the command buffer. Trigger event is ignored."]
164    NotValid = 0,
165    #[doc = "1: CMD1 is executed"]
166    ExecuteCmd1 = 1,
167    #[doc = "2: Corresponding CMD is executed"]
168    ExecuteCorrespondingCmd2 = 2,
169    #[doc = "3: Corresponding CMD is executed"]
170    ExecuteCorrespondingCmd3 = 3,
171    #[doc = "4: Corresponding CMD is executed"]
172    ExecuteCorrespondingCmd4 = 4,
173    #[doc = "5: Corresponding CMD is executed"]
174    ExecuteCorrespondingCmd5 = 5,
175    #[doc = "6: Corresponding CMD is executed"]
176    ExecuteCorrespondingCmd6 = 6,
177    #[doc = "7: CMD7 is executed"]
178    ExecuteCmd7 = 7,
179}
180impl From<Tcmd> for u8 {
181    #[inline(always)]
182    fn from(variant: Tcmd) -> Self {
183        variant as _
184    }
185}
186impl crate::FieldSpec for Tcmd {
187    type Ux = u8;
188}
189impl crate::IsEnum for Tcmd {}
190#[doc = "Field `TCMD` reader - Trigger Command Select"]
191pub type TcmdR = crate::FieldReader<Tcmd>;
192impl TcmdR {
193    #[doc = "Get enumerated values variant"]
194    #[inline(always)]
195    pub const fn variant(&self) -> Tcmd {
196        match self.bits {
197            0 => Tcmd::NotValid,
198            1 => Tcmd::ExecuteCmd1,
199            2 => Tcmd::ExecuteCorrespondingCmd2,
200            3 => Tcmd::ExecuteCorrespondingCmd3,
201            4 => Tcmd::ExecuteCorrespondingCmd4,
202            5 => Tcmd::ExecuteCorrespondingCmd5,
203            6 => Tcmd::ExecuteCorrespondingCmd6,
204            7 => Tcmd::ExecuteCmd7,
205            _ => unreachable!(),
206        }
207    }
208    #[doc = "Not a valid selection from the command buffer. Trigger event is ignored."]
209    #[inline(always)]
210    pub fn is_not_valid(&self) -> bool {
211        *self == Tcmd::NotValid
212    }
213    #[doc = "CMD1 is executed"]
214    #[inline(always)]
215    pub fn is_execute_cmd1(&self) -> bool {
216        *self == Tcmd::ExecuteCmd1
217    }
218    #[doc = "Corresponding CMD is executed"]
219    #[inline(always)]
220    pub fn is_execute_corresponding_cmd_2(&self) -> bool {
221        *self == Tcmd::ExecuteCorrespondingCmd2
222    }
223    #[doc = "Corresponding CMD is executed"]
224    #[inline(always)]
225    pub fn is_execute_corresponding_cmd_3(&self) -> bool {
226        *self == Tcmd::ExecuteCorrespondingCmd3
227    }
228    #[doc = "Corresponding CMD is executed"]
229    #[inline(always)]
230    pub fn is_execute_corresponding_cmd_4(&self) -> bool {
231        *self == Tcmd::ExecuteCorrespondingCmd4
232    }
233    #[doc = "Corresponding CMD is executed"]
234    #[inline(always)]
235    pub fn is_execute_corresponding_cmd_5(&self) -> bool {
236        *self == Tcmd::ExecuteCorrespondingCmd5
237    }
238    #[doc = "Corresponding CMD is executed"]
239    #[inline(always)]
240    pub fn is_execute_corresponding_cmd_6(&self) -> bool {
241        *self == Tcmd::ExecuteCorrespondingCmd6
242    }
243    #[doc = "CMD7 is executed"]
244    #[inline(always)]
245    pub fn is_execute_cmd7(&self) -> bool {
246        *self == Tcmd::ExecuteCmd7
247    }
248}
249#[doc = "Field `TCMD` writer - Trigger Command Select"]
250pub type TcmdW<'a, REG> = crate::FieldWriter<'a, REG, 3, Tcmd, crate::Safe>;
251impl<'a, REG> TcmdW<'a, REG>
252where
253    REG: crate::Writable + crate::RegisterSpec,
254    REG::Ux: From<u8>,
255{
256    #[doc = "Not a valid selection from the command buffer. Trigger event is ignored."]
257    #[inline(always)]
258    pub fn not_valid(self) -> &'a mut crate::W<REG> {
259        self.variant(Tcmd::NotValid)
260    }
261    #[doc = "CMD1 is executed"]
262    #[inline(always)]
263    pub fn execute_cmd1(self) -> &'a mut crate::W<REG> {
264        self.variant(Tcmd::ExecuteCmd1)
265    }
266    #[doc = "Corresponding CMD is executed"]
267    #[inline(always)]
268    pub fn execute_corresponding_cmd_2(self) -> &'a mut crate::W<REG> {
269        self.variant(Tcmd::ExecuteCorrespondingCmd2)
270    }
271    #[doc = "Corresponding CMD is executed"]
272    #[inline(always)]
273    pub fn execute_corresponding_cmd_3(self) -> &'a mut crate::W<REG> {
274        self.variant(Tcmd::ExecuteCorrespondingCmd3)
275    }
276    #[doc = "Corresponding CMD is executed"]
277    #[inline(always)]
278    pub fn execute_corresponding_cmd_4(self) -> &'a mut crate::W<REG> {
279        self.variant(Tcmd::ExecuteCorrespondingCmd4)
280    }
281    #[doc = "Corresponding CMD is executed"]
282    #[inline(always)]
283    pub fn execute_corresponding_cmd_5(self) -> &'a mut crate::W<REG> {
284        self.variant(Tcmd::ExecuteCorrespondingCmd5)
285    }
286    #[doc = "Corresponding CMD is executed"]
287    #[inline(always)]
288    pub fn execute_corresponding_cmd_6(self) -> &'a mut crate::W<REG> {
289        self.variant(Tcmd::ExecuteCorrespondingCmd6)
290    }
291    #[doc = "CMD7 is executed"]
292    #[inline(always)]
293    pub fn execute_cmd7(self) -> &'a mut crate::W<REG> {
294        self.variant(Tcmd::ExecuteCmd7)
295    }
296}
297impl R {
298    #[doc = "Bit 0 - Trigger Enable"]
299    #[inline(always)]
300    pub fn hten(&self) -> HtenR {
301        HtenR::new((self.bits & 1) != 0)
302    }
303    #[doc = "Bits 8:9 - Trigger Priority Setting"]
304    #[inline(always)]
305    pub fn tpri(&self) -> TpriR {
306        TpriR::new(((self.bits >> 8) & 3) as u8)
307    }
308    #[doc = "Bit 15 - Trigger Resync"]
309    #[inline(always)]
310    pub fn rsync(&self) -> RsyncR {
311        RsyncR::new(((self.bits >> 15) & 1) != 0)
312    }
313    #[doc = "Bits 16:19 - Trigger Delay Select"]
314    #[inline(always)]
315    pub fn tdly(&self) -> TdlyR {
316        TdlyR::new(((self.bits >> 16) & 0x0f) as u8)
317    }
318    #[doc = "Bit 23 - Trigger Synchronous Select"]
319    #[inline(always)]
320    pub fn tsync(&self) -> TsyncR {
321        TsyncR::new(((self.bits >> 23) & 1) != 0)
322    }
323    #[doc = "Bits 24:26 - Trigger Command Select"]
324    #[inline(always)]
325    pub fn tcmd(&self) -> TcmdR {
326        TcmdR::new(((self.bits >> 24) & 7) as u8)
327    }
328}
329#[cfg(feature = "debug")]
330impl core::fmt::Debug for R {
331    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
332        f.debug_struct("TCTRL")
333            .field("hten", &self.hten())
334            .field("tpri", &self.tpri())
335            .field("rsync", &self.rsync())
336            .field("tdly", &self.tdly())
337            .field("tsync", &self.tsync())
338            .field("tcmd", &self.tcmd())
339            .finish()
340    }
341}
342impl W {
343    #[doc = "Bit 0 - Trigger Enable"]
344    #[inline(always)]
345    pub fn hten(&mut self) -> HtenW<'_, TctrlSpec> {
346        HtenW::new(self, 0)
347    }
348    #[doc = "Bits 8:9 - Trigger Priority Setting"]
349    #[inline(always)]
350    pub fn tpri(&mut self) -> TpriW<'_, TctrlSpec> {
351        TpriW::new(self, 8)
352    }
353    #[doc = "Bit 15 - Trigger Resync"]
354    #[inline(always)]
355    pub fn rsync(&mut self) -> RsyncW<'_, TctrlSpec> {
356        RsyncW::new(self, 15)
357    }
358    #[doc = "Bits 16:19 - Trigger Delay Select"]
359    #[inline(always)]
360    pub fn tdly(&mut self) -> TdlyW<'_, TctrlSpec> {
361        TdlyW::new(self, 16)
362    }
363    #[doc = "Bit 23 - Trigger Synchronous Select"]
364    #[inline(always)]
365    pub fn tsync(&mut self) -> TsyncW<'_, TctrlSpec> {
366        TsyncW::new(self, 23)
367    }
368    #[doc = "Bits 24:26 - Trigger Command Select"]
369    #[inline(always)]
370    pub fn tcmd(&mut self) -> TcmdW<'_, TctrlSpec> {
371        TcmdW::new(self, 24)
372    }
373}
374#[doc = "Trigger Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`tctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`tctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
375pub struct TctrlSpec;
376impl crate::RegisterSpec for TctrlSpec {
377    type Ux = u32;
378}
379#[doc = "`read()` method returns [`tctrl::R`](R) reader structure"]
380impl crate::Readable for TctrlSpec {}
381#[doc = "`write(|w| ..)` method takes [`tctrl::W`](W) writer structure"]
382impl crate::Writable for TctrlSpec {
383    type Safety = crate::Unsafe;
384}
385#[doc = "`reset()` method sets TCTRL[%s] to value 0"]
386impl crate::Resettable for TctrlSpec {}