atsaml21j18b/dmac/
chctrlb.rs

1#[doc = "Register `CHCTRLB` reader"]
2pub struct R(crate::R<CHCTRLB_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CHCTRLB_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CHCTRLB_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CHCTRLB_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CHCTRLB` writer"]
17pub struct W(crate::W<CHCTRLB_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CHCTRLB_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<CHCTRLB_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CHCTRLB_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EVACT` reader - Event Input Action"]
38pub type EVACT_R = crate::FieldReader<u8, EVACTSELECT_A>;
39#[doc = "Event Input Action\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum EVACTSELECT_A {
43    #[doc = "0: No action"]
44    NOACT = 0,
45    #[doc = "1: Transfer and periodic transfer trigger"]
46    TRIG = 1,
47    #[doc = "2: Conditional transfer trigger"]
48    CTRIG = 2,
49    #[doc = "3: Conditional block transfer"]
50    CBLOCK = 3,
51    #[doc = "4: Channel suspend operation"]
52    SUSPEND = 4,
53    #[doc = "5: Channel resume operation"]
54    RESUME = 5,
55    #[doc = "6: Skip next block suspend action"]
56    SSKIP = 6,
57}
58impl From<EVACTSELECT_A> for u8 {
59    #[inline(always)]
60    fn from(variant: EVACTSELECT_A) -> Self {
61        variant as _
62    }
63}
64impl EVACT_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<EVACTSELECT_A> {
68        match self.bits {
69            0 => Some(EVACTSELECT_A::NOACT),
70            1 => Some(EVACTSELECT_A::TRIG),
71            2 => Some(EVACTSELECT_A::CTRIG),
72            3 => Some(EVACTSELECT_A::CBLOCK),
73            4 => Some(EVACTSELECT_A::SUSPEND),
74            5 => Some(EVACTSELECT_A::RESUME),
75            6 => Some(EVACTSELECT_A::SSKIP),
76            _ => None,
77        }
78    }
79    #[doc = "Checks if the value of the field is `NOACT`"]
80    #[inline(always)]
81    pub fn is_noact(&self) -> bool {
82        *self == EVACTSELECT_A::NOACT
83    }
84    #[doc = "Checks if the value of the field is `TRIG`"]
85    #[inline(always)]
86    pub fn is_trig(&self) -> bool {
87        *self == EVACTSELECT_A::TRIG
88    }
89    #[doc = "Checks if the value of the field is `CTRIG`"]
90    #[inline(always)]
91    pub fn is_ctrig(&self) -> bool {
92        *self == EVACTSELECT_A::CTRIG
93    }
94    #[doc = "Checks if the value of the field is `CBLOCK`"]
95    #[inline(always)]
96    pub fn is_cblock(&self) -> bool {
97        *self == EVACTSELECT_A::CBLOCK
98    }
99    #[doc = "Checks if the value of the field is `SUSPEND`"]
100    #[inline(always)]
101    pub fn is_suspend(&self) -> bool {
102        *self == EVACTSELECT_A::SUSPEND
103    }
104    #[doc = "Checks if the value of the field is `RESUME`"]
105    #[inline(always)]
106    pub fn is_resume(&self) -> bool {
107        *self == EVACTSELECT_A::RESUME
108    }
109    #[doc = "Checks if the value of the field is `SSKIP`"]
110    #[inline(always)]
111    pub fn is_sskip(&self) -> bool {
112        *self == EVACTSELECT_A::SSKIP
113    }
114}
115#[doc = "Field `EVACT` writer - Event Input Action"]
116pub type EVACT_W<'a, const O: u8> =
117    crate::FieldWriter<'a, u32, CHCTRLB_SPEC, u8, EVACTSELECT_A, 3, O>;
118impl<'a, const O: u8> EVACT_W<'a, O> {
119    #[doc = "No action"]
120    #[inline(always)]
121    pub fn noact(self) -> &'a mut W {
122        self.variant(EVACTSELECT_A::NOACT)
123    }
124    #[doc = "Transfer and periodic transfer trigger"]
125    #[inline(always)]
126    pub fn trig(self) -> &'a mut W {
127        self.variant(EVACTSELECT_A::TRIG)
128    }
129    #[doc = "Conditional transfer trigger"]
130    #[inline(always)]
131    pub fn ctrig(self) -> &'a mut W {
132        self.variant(EVACTSELECT_A::CTRIG)
133    }
134    #[doc = "Conditional block transfer"]
135    #[inline(always)]
136    pub fn cblock(self) -> &'a mut W {
137        self.variant(EVACTSELECT_A::CBLOCK)
138    }
139    #[doc = "Channel suspend operation"]
140    #[inline(always)]
141    pub fn suspend(self) -> &'a mut W {
142        self.variant(EVACTSELECT_A::SUSPEND)
143    }
144    #[doc = "Channel resume operation"]
145    #[inline(always)]
146    pub fn resume(self) -> &'a mut W {
147        self.variant(EVACTSELECT_A::RESUME)
148    }
149    #[doc = "Skip next block suspend action"]
150    #[inline(always)]
151    pub fn sskip(self) -> &'a mut W {
152        self.variant(EVACTSELECT_A::SSKIP)
153    }
154}
155#[doc = "Field `EVIE` reader - Channel Event Input Enable"]
156pub type EVIE_R = crate::BitReader<bool>;
157#[doc = "Field `EVIE` writer - Channel Event Input Enable"]
158pub type EVIE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CHCTRLB_SPEC, bool, O>;
159#[doc = "Field `EVOE` reader - Channel Event Output Enable"]
160pub type EVOE_R = crate::BitReader<bool>;
161#[doc = "Field `EVOE` writer - Channel Event Output Enable"]
162pub type EVOE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CHCTRLB_SPEC, bool, O>;
163#[doc = "Field `LVL` reader - Channel Arbitration Level"]
164pub type LVL_R = crate::FieldReader<u8, u8>;
165#[doc = "Field `LVL` writer - Channel Arbitration Level"]
166pub type LVL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CHCTRLB_SPEC, u8, u8, 2, O>;
167#[doc = "Field `TRIGSRC` reader - Trigger Source"]
168pub type TRIGSRC_R = crate::FieldReader<u8, TRIGSRCSELECT_A>;
169#[doc = "Trigger Source\n\nValue on reset: 0"]
170#[derive(Clone, Copy, Debug, PartialEq, Eq)]
171#[repr(u8)]
172pub enum TRIGSRCSELECT_A {
173    #[doc = "0: Only software/event triggers"]
174    DISABLE = 0,
175}
176impl From<TRIGSRCSELECT_A> for u8 {
177    #[inline(always)]
178    fn from(variant: TRIGSRCSELECT_A) -> Self {
179        variant as _
180    }
181}
182impl TRIGSRC_R {
183    #[doc = "Get enumerated values variant"]
184    #[inline(always)]
185    pub fn variant(&self) -> Option<TRIGSRCSELECT_A> {
186        match self.bits {
187            0 => Some(TRIGSRCSELECT_A::DISABLE),
188            _ => None,
189        }
190    }
191    #[doc = "Checks if the value of the field is `DISABLE`"]
192    #[inline(always)]
193    pub fn is_disable(&self) -> bool {
194        *self == TRIGSRCSELECT_A::DISABLE
195    }
196}
197#[doc = "Field `TRIGSRC` writer - Trigger Source"]
198pub type TRIGSRC_W<'a, const O: u8> =
199    crate::FieldWriter<'a, u32, CHCTRLB_SPEC, u8, TRIGSRCSELECT_A, 6, O>;
200impl<'a, const O: u8> TRIGSRC_W<'a, O> {
201    #[doc = "Only software/event triggers"]
202    #[inline(always)]
203    pub fn disable(self) -> &'a mut W {
204        self.variant(TRIGSRCSELECT_A::DISABLE)
205    }
206}
207#[doc = "Field `TRIGACT` reader - Trigger Action"]
208pub type TRIGACT_R = crate::FieldReader<u8, TRIGACTSELECT_A>;
209#[doc = "Trigger Action\n\nValue on reset: 0"]
210#[derive(Clone, Copy, Debug, PartialEq, Eq)]
211#[repr(u8)]
212pub enum TRIGACTSELECT_A {
213    #[doc = "0: One trigger required for each block transfer"]
214    BLOCK = 0,
215    #[doc = "2: One trigger required for each beat transfer"]
216    BEAT = 2,
217    #[doc = "3: One trigger required for each transaction"]
218    TRANSACTION = 3,
219}
220impl From<TRIGACTSELECT_A> for u8 {
221    #[inline(always)]
222    fn from(variant: TRIGACTSELECT_A) -> Self {
223        variant as _
224    }
225}
226impl TRIGACT_R {
227    #[doc = "Get enumerated values variant"]
228    #[inline(always)]
229    pub fn variant(&self) -> Option<TRIGACTSELECT_A> {
230        match self.bits {
231            0 => Some(TRIGACTSELECT_A::BLOCK),
232            2 => Some(TRIGACTSELECT_A::BEAT),
233            3 => Some(TRIGACTSELECT_A::TRANSACTION),
234            _ => None,
235        }
236    }
237    #[doc = "Checks if the value of the field is `BLOCK`"]
238    #[inline(always)]
239    pub fn is_block(&self) -> bool {
240        *self == TRIGACTSELECT_A::BLOCK
241    }
242    #[doc = "Checks if the value of the field is `BEAT`"]
243    #[inline(always)]
244    pub fn is_beat(&self) -> bool {
245        *self == TRIGACTSELECT_A::BEAT
246    }
247    #[doc = "Checks if the value of the field is `TRANSACTION`"]
248    #[inline(always)]
249    pub fn is_transaction(&self) -> bool {
250        *self == TRIGACTSELECT_A::TRANSACTION
251    }
252}
253#[doc = "Field `TRIGACT` writer - Trigger Action"]
254pub type TRIGACT_W<'a, const O: u8> =
255    crate::FieldWriter<'a, u32, CHCTRLB_SPEC, u8, TRIGACTSELECT_A, 2, O>;
256impl<'a, const O: u8> TRIGACT_W<'a, O> {
257    #[doc = "One trigger required for each block transfer"]
258    #[inline(always)]
259    pub fn block(self) -> &'a mut W {
260        self.variant(TRIGACTSELECT_A::BLOCK)
261    }
262    #[doc = "One trigger required for each beat transfer"]
263    #[inline(always)]
264    pub fn beat(self) -> &'a mut W {
265        self.variant(TRIGACTSELECT_A::BEAT)
266    }
267    #[doc = "One trigger required for each transaction"]
268    #[inline(always)]
269    pub fn transaction(self) -> &'a mut W {
270        self.variant(TRIGACTSELECT_A::TRANSACTION)
271    }
272}
273#[doc = "Field `CMD` reader - Software Command"]
274pub type CMD_R = crate::FieldReader<u8, CMDSELECT_A>;
275#[doc = "Software Command\n\nValue on reset: 0"]
276#[derive(Clone, Copy, Debug, PartialEq, Eq)]
277#[repr(u8)]
278pub enum CMDSELECT_A {
279    #[doc = "0: No action"]
280    NOACT = 0,
281    #[doc = "1: Channel suspend operation"]
282    SUSPEND = 1,
283    #[doc = "2: Channel resume operation"]
284    RESUME = 2,
285}
286impl From<CMDSELECT_A> for u8 {
287    #[inline(always)]
288    fn from(variant: CMDSELECT_A) -> Self {
289        variant as _
290    }
291}
292impl CMD_R {
293    #[doc = "Get enumerated values variant"]
294    #[inline(always)]
295    pub fn variant(&self) -> Option<CMDSELECT_A> {
296        match self.bits {
297            0 => Some(CMDSELECT_A::NOACT),
298            1 => Some(CMDSELECT_A::SUSPEND),
299            2 => Some(CMDSELECT_A::RESUME),
300            _ => None,
301        }
302    }
303    #[doc = "Checks if the value of the field is `NOACT`"]
304    #[inline(always)]
305    pub fn is_noact(&self) -> bool {
306        *self == CMDSELECT_A::NOACT
307    }
308    #[doc = "Checks if the value of the field is `SUSPEND`"]
309    #[inline(always)]
310    pub fn is_suspend(&self) -> bool {
311        *self == CMDSELECT_A::SUSPEND
312    }
313    #[doc = "Checks if the value of the field is `RESUME`"]
314    #[inline(always)]
315    pub fn is_resume(&self) -> bool {
316        *self == CMDSELECT_A::RESUME
317    }
318}
319#[doc = "Field `CMD` writer - Software Command"]
320pub type CMD_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CHCTRLB_SPEC, u8, CMDSELECT_A, 2, O>;
321impl<'a, const O: u8> CMD_W<'a, O> {
322    #[doc = "No action"]
323    #[inline(always)]
324    pub fn noact(self) -> &'a mut W {
325        self.variant(CMDSELECT_A::NOACT)
326    }
327    #[doc = "Channel suspend operation"]
328    #[inline(always)]
329    pub fn suspend(self) -> &'a mut W {
330        self.variant(CMDSELECT_A::SUSPEND)
331    }
332    #[doc = "Channel resume operation"]
333    #[inline(always)]
334    pub fn resume(self) -> &'a mut W {
335        self.variant(CMDSELECT_A::RESUME)
336    }
337}
338impl R {
339    #[doc = "Bits 0:2 - Event Input Action"]
340    #[inline(always)]
341    pub fn evact(&self) -> EVACT_R {
342        EVACT_R::new((self.bits & 7) as u8)
343    }
344    #[doc = "Bit 3 - Channel Event Input Enable"]
345    #[inline(always)]
346    pub fn evie(&self) -> EVIE_R {
347        EVIE_R::new(((self.bits >> 3) & 1) != 0)
348    }
349    #[doc = "Bit 4 - Channel Event Output Enable"]
350    #[inline(always)]
351    pub fn evoe(&self) -> EVOE_R {
352        EVOE_R::new(((self.bits >> 4) & 1) != 0)
353    }
354    #[doc = "Bits 5:6 - Channel Arbitration Level"]
355    #[inline(always)]
356    pub fn lvl(&self) -> LVL_R {
357        LVL_R::new(((self.bits >> 5) & 3) as u8)
358    }
359    #[doc = "Bits 8:13 - Trigger Source"]
360    #[inline(always)]
361    pub fn trigsrc(&self) -> TRIGSRC_R {
362        TRIGSRC_R::new(((self.bits >> 8) & 0x3f) as u8)
363    }
364    #[doc = "Bits 22:23 - Trigger Action"]
365    #[inline(always)]
366    pub fn trigact(&self) -> TRIGACT_R {
367        TRIGACT_R::new(((self.bits >> 22) & 3) as u8)
368    }
369    #[doc = "Bits 24:25 - Software Command"]
370    #[inline(always)]
371    pub fn cmd(&self) -> CMD_R {
372        CMD_R::new(((self.bits >> 24) & 3) as u8)
373    }
374}
375impl W {
376    #[doc = "Bits 0:2 - Event Input Action"]
377    #[inline(always)]
378    #[must_use]
379    pub fn evact(&mut self) -> EVACT_W<0> {
380        EVACT_W::new(self)
381    }
382    #[doc = "Bit 3 - Channel Event Input Enable"]
383    #[inline(always)]
384    #[must_use]
385    pub fn evie(&mut self) -> EVIE_W<3> {
386        EVIE_W::new(self)
387    }
388    #[doc = "Bit 4 - Channel Event Output Enable"]
389    #[inline(always)]
390    #[must_use]
391    pub fn evoe(&mut self) -> EVOE_W<4> {
392        EVOE_W::new(self)
393    }
394    #[doc = "Bits 5:6 - Channel Arbitration Level"]
395    #[inline(always)]
396    #[must_use]
397    pub fn lvl(&mut self) -> LVL_W<5> {
398        LVL_W::new(self)
399    }
400    #[doc = "Bits 8:13 - Trigger Source"]
401    #[inline(always)]
402    #[must_use]
403    pub fn trigsrc(&mut self) -> TRIGSRC_W<8> {
404        TRIGSRC_W::new(self)
405    }
406    #[doc = "Bits 22:23 - Trigger Action"]
407    #[inline(always)]
408    #[must_use]
409    pub fn trigact(&mut self) -> TRIGACT_W<22> {
410        TRIGACT_W::new(self)
411    }
412    #[doc = "Bits 24:25 - Software Command"]
413    #[inline(always)]
414    #[must_use]
415    pub fn cmd(&mut self) -> CMD_W<24> {
416        CMD_W::new(self)
417    }
418    #[doc = "Writes raw bits to the register."]
419    #[inline(always)]
420    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
421        self.0.bits(bits);
422        self
423    }
424}
425#[doc = "Channel Control B\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [chctrlb](index.html) module"]
426pub struct CHCTRLB_SPEC;
427impl crate::RegisterSpec for CHCTRLB_SPEC {
428    type Ux = u32;
429}
430#[doc = "`read()` method returns [chctrlb::R](R) reader structure"]
431impl crate::Readable for CHCTRLB_SPEC {
432    type Reader = R;
433}
434#[doc = "`write(|w| ..)` method takes [chctrlb::W](W) writer structure"]
435impl crate::Writable for CHCTRLB_SPEC {
436    type Writer = W;
437    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
438    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
439}
440#[doc = "`reset()` method sets CHCTRLB to value 0"]
441impl crate::Resettable for CHCTRLB_SPEC {
442    const RESET_VALUE: Self::Ux = 0;
443}