atsamd51j/dmac/channel/
chevctrl.rs

1#[doc = "Register `CHEVCTRL` reader"]
2pub type R = crate::R<ChevctrlSpec>;
3#[doc = "Register `CHEVCTRL` writer"]
4pub type W = crate::W<ChevctrlSpec>;
5#[doc = "Channel Event Input Action\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Evactselect {
9    #[doc = "0: No action"]
10    Noact = 0,
11    #[doc = "1: Transfer and periodic transfer trigger"]
12    Trig = 1,
13    #[doc = "2: Conditional transfer trigger"]
14    Ctrig = 2,
15    #[doc = "3: Conditional block transfer"]
16    Cblock = 3,
17    #[doc = "4: Channel suspend operation"]
18    Suspend = 4,
19    #[doc = "5: Channel resume operation"]
20    Resume = 5,
21    #[doc = "6: Skip next block suspend action"]
22    Sskip = 6,
23    #[doc = "7: Increase priority"]
24    Incpri = 7,
25}
26impl From<Evactselect> for u8 {
27    #[inline(always)]
28    fn from(variant: Evactselect) -> Self {
29        variant as _
30    }
31}
32impl crate::FieldSpec for Evactselect {
33    type Ux = u8;
34}
35impl crate::IsEnum for Evactselect {}
36#[doc = "Field `EVACT` reader - Channel Event Input Action"]
37pub type EvactR = crate::FieldReader<Evactselect>;
38impl EvactR {
39    #[doc = "Get enumerated values variant"]
40    #[inline(always)]
41    pub const fn variant(&self) -> Evactselect {
42        match self.bits {
43            0 => Evactselect::Noact,
44            1 => Evactselect::Trig,
45            2 => Evactselect::Ctrig,
46            3 => Evactselect::Cblock,
47            4 => Evactselect::Suspend,
48            5 => Evactselect::Resume,
49            6 => Evactselect::Sskip,
50            7 => Evactselect::Incpri,
51            _ => unreachable!(),
52        }
53    }
54    #[doc = "No action"]
55    #[inline(always)]
56    pub fn is_noact(&self) -> bool {
57        *self == Evactselect::Noact
58    }
59    #[doc = "Transfer and periodic transfer trigger"]
60    #[inline(always)]
61    pub fn is_trig(&self) -> bool {
62        *self == Evactselect::Trig
63    }
64    #[doc = "Conditional transfer trigger"]
65    #[inline(always)]
66    pub fn is_ctrig(&self) -> bool {
67        *self == Evactselect::Ctrig
68    }
69    #[doc = "Conditional block transfer"]
70    #[inline(always)]
71    pub fn is_cblock(&self) -> bool {
72        *self == Evactselect::Cblock
73    }
74    #[doc = "Channel suspend operation"]
75    #[inline(always)]
76    pub fn is_suspend(&self) -> bool {
77        *self == Evactselect::Suspend
78    }
79    #[doc = "Channel resume operation"]
80    #[inline(always)]
81    pub fn is_resume(&self) -> bool {
82        *self == Evactselect::Resume
83    }
84    #[doc = "Skip next block suspend action"]
85    #[inline(always)]
86    pub fn is_sskip(&self) -> bool {
87        *self == Evactselect::Sskip
88    }
89    #[doc = "Increase priority"]
90    #[inline(always)]
91    pub fn is_incpri(&self) -> bool {
92        *self == Evactselect::Incpri
93    }
94}
95#[doc = "Field `EVACT` writer - Channel Event Input Action"]
96pub type EvactW<'a, REG> = crate::FieldWriter<'a, REG, 3, Evactselect, crate::Safe>;
97impl<'a, REG> EvactW<'a, REG>
98where
99    REG: crate::Writable + crate::RegisterSpec,
100    REG::Ux: From<u8>,
101{
102    #[doc = "No action"]
103    #[inline(always)]
104    pub fn noact(self) -> &'a mut crate::W<REG> {
105        self.variant(Evactselect::Noact)
106    }
107    #[doc = "Transfer and periodic transfer trigger"]
108    #[inline(always)]
109    pub fn trig(self) -> &'a mut crate::W<REG> {
110        self.variant(Evactselect::Trig)
111    }
112    #[doc = "Conditional transfer trigger"]
113    #[inline(always)]
114    pub fn ctrig(self) -> &'a mut crate::W<REG> {
115        self.variant(Evactselect::Ctrig)
116    }
117    #[doc = "Conditional block transfer"]
118    #[inline(always)]
119    pub fn cblock(self) -> &'a mut crate::W<REG> {
120        self.variant(Evactselect::Cblock)
121    }
122    #[doc = "Channel suspend operation"]
123    #[inline(always)]
124    pub fn suspend(self) -> &'a mut crate::W<REG> {
125        self.variant(Evactselect::Suspend)
126    }
127    #[doc = "Channel resume operation"]
128    #[inline(always)]
129    pub fn resume(self) -> &'a mut crate::W<REG> {
130        self.variant(Evactselect::Resume)
131    }
132    #[doc = "Skip next block suspend action"]
133    #[inline(always)]
134    pub fn sskip(self) -> &'a mut crate::W<REG> {
135        self.variant(Evactselect::Sskip)
136    }
137    #[doc = "Increase priority"]
138    #[inline(always)]
139    pub fn incpri(self) -> &'a mut crate::W<REG> {
140        self.variant(Evactselect::Incpri)
141    }
142}
143#[doc = "Channel Event Output Mode\n\nValue on reset: 0"]
144#[derive(Clone, Copy, Debug, PartialEq, Eq)]
145#[repr(u8)]
146pub enum Evomodeselect {
147    #[doc = "0: Block event output selection. Refer to BTCTRL.EVOSEL for available selections."]
148    Default = 0,
149    #[doc = "1: Ongoing trigger action"]
150    Trigact = 1,
151}
152impl From<Evomodeselect> for u8 {
153    #[inline(always)]
154    fn from(variant: Evomodeselect) -> Self {
155        variant as _
156    }
157}
158impl crate::FieldSpec for Evomodeselect {
159    type Ux = u8;
160}
161impl crate::IsEnum for Evomodeselect {}
162#[doc = "Field `EVOMODE` reader - Channel Event Output Mode"]
163pub type EvomodeR = crate::FieldReader<Evomodeselect>;
164impl EvomodeR {
165    #[doc = "Get enumerated values variant"]
166    #[inline(always)]
167    pub const fn variant(&self) -> Option<Evomodeselect> {
168        match self.bits {
169            0 => Some(Evomodeselect::Default),
170            1 => Some(Evomodeselect::Trigact),
171            _ => None,
172        }
173    }
174    #[doc = "Block event output selection. Refer to BTCTRL.EVOSEL for available selections."]
175    #[inline(always)]
176    pub fn is_default(&self) -> bool {
177        *self == Evomodeselect::Default
178    }
179    #[doc = "Ongoing trigger action"]
180    #[inline(always)]
181    pub fn is_trigact(&self) -> bool {
182        *self == Evomodeselect::Trigact
183    }
184}
185#[doc = "Field `EVOMODE` writer - Channel Event Output Mode"]
186pub type EvomodeW<'a, REG> = crate::FieldWriter<'a, REG, 2, Evomodeselect>;
187impl<'a, REG> EvomodeW<'a, REG>
188where
189    REG: crate::Writable + crate::RegisterSpec,
190    REG::Ux: From<u8>,
191{
192    #[doc = "Block event output selection. Refer to BTCTRL.EVOSEL for available selections."]
193    #[inline(always)]
194    pub fn default(self) -> &'a mut crate::W<REG> {
195        self.variant(Evomodeselect::Default)
196    }
197    #[doc = "Ongoing trigger action"]
198    #[inline(always)]
199    pub fn trigact(self) -> &'a mut crate::W<REG> {
200        self.variant(Evomodeselect::Trigact)
201    }
202}
203#[doc = "Field `EVIE` reader - Channel Event Input Enable"]
204pub type EvieR = crate::BitReader;
205#[doc = "Field `EVIE` writer - Channel Event Input Enable"]
206pub type EvieW<'a, REG> = crate::BitWriter<'a, REG>;
207#[doc = "Field `EVOE` reader - Channel Event Output Enable"]
208pub type EvoeR = crate::BitReader;
209#[doc = "Field `EVOE` writer - Channel Event Output Enable"]
210pub type EvoeW<'a, REG> = crate::BitWriter<'a, REG>;
211impl R {
212    #[doc = "Bits 0:2 - Channel Event Input Action"]
213    #[inline(always)]
214    pub fn evact(&self) -> EvactR {
215        EvactR::new(self.bits & 7)
216    }
217    #[doc = "Bits 4:5 - Channel Event Output Mode"]
218    #[inline(always)]
219    pub fn evomode(&self) -> EvomodeR {
220        EvomodeR::new((self.bits >> 4) & 3)
221    }
222    #[doc = "Bit 6 - Channel Event Input Enable"]
223    #[inline(always)]
224    pub fn evie(&self) -> EvieR {
225        EvieR::new(((self.bits >> 6) & 1) != 0)
226    }
227    #[doc = "Bit 7 - Channel Event Output Enable"]
228    #[inline(always)]
229    pub fn evoe(&self) -> EvoeR {
230        EvoeR::new(((self.bits >> 7) & 1) != 0)
231    }
232}
233impl W {
234    #[doc = "Bits 0:2 - Channel Event Input Action"]
235    #[inline(always)]
236    #[must_use]
237    pub fn evact(&mut self) -> EvactW<ChevctrlSpec> {
238        EvactW::new(self, 0)
239    }
240    #[doc = "Bits 4:5 - Channel Event Output Mode"]
241    #[inline(always)]
242    #[must_use]
243    pub fn evomode(&mut self) -> EvomodeW<ChevctrlSpec> {
244        EvomodeW::new(self, 4)
245    }
246    #[doc = "Bit 6 - Channel Event Input Enable"]
247    #[inline(always)]
248    #[must_use]
249    pub fn evie(&mut self) -> EvieW<ChevctrlSpec> {
250        EvieW::new(self, 6)
251    }
252    #[doc = "Bit 7 - Channel Event Output Enable"]
253    #[inline(always)]
254    #[must_use]
255    pub fn evoe(&mut self) -> EvoeW<ChevctrlSpec> {
256        EvoeW::new(self, 7)
257    }
258}
259#[doc = "Channel n Event Control\n\nYou can [`read`](crate::Reg::read) this register and get [`chevctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`chevctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
260pub struct ChevctrlSpec;
261impl crate::RegisterSpec for ChevctrlSpec {
262    type Ux = u8;
263}
264#[doc = "`read()` method returns [`chevctrl::R`](R) reader structure"]
265impl crate::Readable for ChevctrlSpec {}
266#[doc = "`write(|w| ..)` method takes [`chevctrl::W`](W) writer structure"]
267impl crate::Writable for ChevctrlSpec {
268    type Safety = crate::Unsafe;
269    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
270    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
271}
272#[doc = "`reset()` method sets CHEVCTRL to value 0"]
273impl crate::Resettable for ChevctrlSpec {
274    const RESET_VALUE: u8 = 0;
275}