atsamd51g/dmac/channel/
chctrlb.rs

1#[doc = "Register `CHCTRLB` reader"]
2pub type R = crate::R<ChctrlbSpec>;
3#[doc = "Register `CHCTRLB` writer"]
4pub type W = crate::W<ChctrlbSpec>;
5#[doc = "Software Command\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Cmdselect {
9    #[doc = "0: No action"]
10    Noact = 0,
11    #[doc = "1: Channel suspend operation"]
12    Suspend = 1,
13    #[doc = "2: Channel resume operation"]
14    Resume = 2,
15}
16impl From<Cmdselect> for u8 {
17    #[inline(always)]
18    fn from(variant: Cmdselect) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for Cmdselect {
23    type Ux = u8;
24}
25impl crate::IsEnum for Cmdselect {}
26#[doc = "Field `CMD` reader - Software Command"]
27pub type CmdR = crate::FieldReader<Cmdselect>;
28impl CmdR {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<Cmdselect> {
32        match self.bits {
33            0 => Some(Cmdselect::Noact),
34            1 => Some(Cmdselect::Suspend),
35            2 => Some(Cmdselect::Resume),
36            _ => None,
37        }
38    }
39    #[doc = "No action"]
40    #[inline(always)]
41    pub fn is_noact(&self) -> bool {
42        *self == Cmdselect::Noact
43    }
44    #[doc = "Channel suspend operation"]
45    #[inline(always)]
46    pub fn is_suspend(&self) -> bool {
47        *self == Cmdselect::Suspend
48    }
49    #[doc = "Channel resume operation"]
50    #[inline(always)]
51    pub fn is_resume(&self) -> bool {
52        *self == Cmdselect::Resume
53    }
54}
55#[doc = "Field `CMD` writer - Software Command"]
56pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 2, Cmdselect>;
57impl<'a, REG> CmdW<'a, REG>
58where
59    REG: crate::Writable + crate::RegisterSpec,
60    REG::Ux: From<u8>,
61{
62    #[doc = "No action"]
63    #[inline(always)]
64    pub fn noact(self) -> &'a mut crate::W<REG> {
65        self.variant(Cmdselect::Noact)
66    }
67    #[doc = "Channel suspend operation"]
68    #[inline(always)]
69    pub fn suspend(self) -> &'a mut crate::W<REG> {
70        self.variant(Cmdselect::Suspend)
71    }
72    #[doc = "Channel resume operation"]
73    #[inline(always)]
74    pub fn resume(self) -> &'a mut crate::W<REG> {
75        self.variant(Cmdselect::Resume)
76    }
77}
78impl R {
79    #[doc = "Bits 0:1 - Software Command"]
80    #[inline(always)]
81    pub fn cmd(&self) -> CmdR {
82        CmdR::new(self.bits & 3)
83    }
84}
85impl W {
86    #[doc = "Bits 0:1 - Software Command"]
87    #[inline(always)]
88    #[must_use]
89    pub fn cmd(&mut self) -> CmdW<ChctrlbSpec> {
90        CmdW::new(self, 0)
91    }
92}
93#[doc = "Channel n Control B\n\nYou can [`read`](crate::Reg::read) this register and get [`chctrlb::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`chctrlb::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
94pub struct ChctrlbSpec;
95impl crate::RegisterSpec for ChctrlbSpec {
96    type Ux = u8;
97}
98#[doc = "`read()` method returns [`chctrlb::R`](R) reader structure"]
99impl crate::Readable for ChctrlbSpec {}
100#[doc = "`write(|w| ..)` method takes [`chctrlb::W`](W) writer structure"]
101impl crate::Writable for ChctrlbSpec {
102    type Safety = crate::Unsafe;
103    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
104    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
105}
106#[doc = "`reset()` method sets CHCTRLB to value 0"]
107impl crate::Resettable for ChctrlbSpec {
108    const RESET_VALUE: u8 = 0;
109}