Skip to main content

atsamd51j19a/dmac/channel/
chctrlb.rs

1#[doc = "Reader of register CHCTRLB"]
2pub type R = crate::R<u8, super::CHCTRLB>;
3#[doc = "Writer for register CHCTRLB"]
4pub type W = crate::W<u8, super::CHCTRLB>;
5#[doc = "Register CHCTRLB `reset()`'s with value 0"]
6impl crate::ResetValue for super::CHCTRLB {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Software Command\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum CMD_A {
17    #[doc = "0: No action"]
18    NOACT = 0,
19    #[doc = "1: Channel suspend operation"]
20    SUSPEND = 1,
21    #[doc = "2: Channel resume operation"]
22    RESUME = 2,
23}
24impl From<CMD_A> for u8 {
25    #[inline(always)]
26    fn from(variant: CMD_A) -> Self {
27        variant as _
28    }
29}
30#[doc = "Reader of field `CMD`"]
31pub type CMD_R = crate::R<u8, CMD_A>;
32impl CMD_R {
33    #[doc = r"Get enumerated values variant"]
34    #[inline(always)]
35    pub fn variant(&self) -> crate::Variant<u8, CMD_A> {
36        use crate::Variant::*;
37        match self.bits {
38            0 => Val(CMD_A::NOACT),
39            1 => Val(CMD_A::SUSPEND),
40            2 => Val(CMD_A::RESUME),
41            i => Res(i),
42        }
43    }
44    #[doc = "Checks if the value of the field is `NOACT`"]
45    #[inline(always)]
46    pub fn is_noact(&self) -> bool {
47        *self == CMD_A::NOACT
48    }
49    #[doc = "Checks if the value of the field is `SUSPEND`"]
50    #[inline(always)]
51    pub fn is_suspend(&self) -> bool {
52        *self == CMD_A::SUSPEND
53    }
54    #[doc = "Checks if the value of the field is `RESUME`"]
55    #[inline(always)]
56    pub fn is_resume(&self) -> bool {
57        *self == CMD_A::RESUME
58    }
59}
60#[doc = "Write proxy for field `CMD`"]
61pub struct CMD_W<'a> {
62    w: &'a mut W,
63}
64impl<'a> CMD_W<'a> {
65    #[doc = r"Writes `variant` to the field"]
66    #[inline(always)]
67    pub fn variant(self, variant: CMD_A) -> &'a mut W {
68        unsafe { self.bits(variant.into()) }
69    }
70    #[doc = "No action"]
71    #[inline(always)]
72    pub fn noact(self) -> &'a mut W {
73        self.variant(CMD_A::NOACT)
74    }
75    #[doc = "Channel suspend operation"]
76    #[inline(always)]
77    pub fn suspend(self) -> &'a mut W {
78        self.variant(CMD_A::SUSPEND)
79    }
80    #[doc = "Channel resume operation"]
81    #[inline(always)]
82    pub fn resume(self) -> &'a mut W {
83        self.variant(CMD_A::RESUME)
84    }
85    #[doc = r"Writes raw bits to the field"]
86    #[inline(always)]
87    pub unsafe fn bits(self, value: u8) -> &'a mut W {
88        self.w.bits = (self.w.bits & !0x03) | ((value as u8) & 0x03);
89        self.w
90    }
91}
92impl R {
93    #[doc = "Bits 0:1 - Software Command"]
94    #[inline(always)]
95    pub fn cmd(&self) -> CMD_R {
96        CMD_R::new((self.bits & 0x03) as u8)
97    }
98}
99impl W {
100    #[doc = "Bits 0:1 - Software Command"]
101    #[inline(always)]
102    pub fn cmd(&mut self) -> CMD_W {
103        CMD_W { w: self }
104    }
105}