atsamd21g/tc3/count32/
ctrlbset.rs

1#[doc = "Register `CTRLBSET` reader"]
2pub type R = crate::R<CtrlbsetSpec>;
3#[doc = "Register `CTRLBSET` writer"]
4pub type W = crate::W<CtrlbsetSpec>;
5#[doc = "Field `DIR` reader - Counter Direction"]
6pub type DirR = crate::BitReader;
7#[doc = "Field `DIR` writer - Counter Direction"]
8pub type DirW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `ONESHOT` reader - One-Shot"]
10pub type OneshotR = crate::BitReader;
11#[doc = "Field `ONESHOT` writer - One-Shot"]
12pub type OneshotW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Command\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15#[repr(u8)]
16pub enum Cmdselect {
17    #[doc = "0: No action"]
18    None = 0,
19    #[doc = "1: Force a start, restart or retrigger"]
20    Retrigger = 1,
21    #[doc = "2: Force a stop"]
22    Stop = 2,
23}
24impl From<Cmdselect> for u8 {
25    #[inline(always)]
26    fn from(variant: Cmdselect) -> Self {
27        variant as _
28    }
29}
30impl crate::FieldSpec for Cmdselect {
31    type Ux = u8;
32}
33impl crate::IsEnum for Cmdselect {}
34#[doc = "Field `CMD` reader - Command"]
35pub type CmdR = crate::FieldReader<Cmdselect>;
36impl CmdR {
37    #[doc = "Get enumerated values variant"]
38    #[inline(always)]
39    pub const fn variant(&self) -> Option<Cmdselect> {
40        match self.bits {
41            0 => Some(Cmdselect::None),
42            1 => Some(Cmdselect::Retrigger),
43            2 => Some(Cmdselect::Stop),
44            _ => None,
45        }
46    }
47    #[doc = "No action"]
48    #[inline(always)]
49    pub fn is_none(&self) -> bool {
50        *self == Cmdselect::None
51    }
52    #[doc = "Force a start, restart or retrigger"]
53    #[inline(always)]
54    pub fn is_retrigger(&self) -> bool {
55        *self == Cmdselect::Retrigger
56    }
57    #[doc = "Force a stop"]
58    #[inline(always)]
59    pub fn is_stop(&self) -> bool {
60        *self == Cmdselect::Stop
61    }
62}
63#[doc = "Field `CMD` writer - Command"]
64pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 2, Cmdselect>;
65impl<'a, REG> CmdW<'a, REG>
66where
67    REG: crate::Writable + crate::RegisterSpec,
68    REG::Ux: From<u8>,
69{
70    #[doc = "No action"]
71    #[inline(always)]
72    pub fn none(self) -> &'a mut crate::W<REG> {
73        self.variant(Cmdselect::None)
74    }
75    #[doc = "Force a start, restart or retrigger"]
76    #[inline(always)]
77    pub fn retrigger(self) -> &'a mut crate::W<REG> {
78        self.variant(Cmdselect::Retrigger)
79    }
80    #[doc = "Force a stop"]
81    #[inline(always)]
82    pub fn stop(self) -> &'a mut crate::W<REG> {
83        self.variant(Cmdselect::Stop)
84    }
85}
86impl R {
87    #[doc = "Bit 0 - Counter Direction"]
88    #[inline(always)]
89    pub fn dir(&self) -> DirR {
90        DirR::new((self.bits & 1) != 0)
91    }
92    #[doc = "Bit 2 - One-Shot"]
93    #[inline(always)]
94    pub fn oneshot(&self) -> OneshotR {
95        OneshotR::new(((self.bits >> 2) & 1) != 0)
96    }
97    #[doc = "Bits 6:7 - Command"]
98    #[inline(always)]
99    pub fn cmd(&self) -> CmdR {
100        CmdR::new((self.bits >> 6) & 3)
101    }
102}
103impl W {
104    #[doc = "Bit 0 - Counter Direction"]
105    #[inline(always)]
106    #[must_use]
107    pub fn dir(&mut self) -> DirW<CtrlbsetSpec> {
108        DirW::new(self, 0)
109    }
110    #[doc = "Bit 2 - One-Shot"]
111    #[inline(always)]
112    #[must_use]
113    pub fn oneshot(&mut self) -> OneshotW<CtrlbsetSpec> {
114        OneshotW::new(self, 2)
115    }
116    #[doc = "Bits 6:7 - Command"]
117    #[inline(always)]
118    #[must_use]
119    pub fn cmd(&mut self) -> CmdW<CtrlbsetSpec> {
120        CmdW::new(self, 6)
121    }
122}
123#[doc = "Control B Set\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlbset::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlbset::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
124pub struct CtrlbsetSpec;
125impl crate::RegisterSpec for CtrlbsetSpec {
126    type Ux = u8;
127}
128#[doc = "`read()` method returns [`ctrlbset::R`](R) reader structure"]
129impl crate::Readable for CtrlbsetSpec {}
130#[doc = "`write(|w| ..)` method takes [`ctrlbset::W`](W) writer structure"]
131impl crate::Writable for CtrlbsetSpec {
132    type Safety = crate::Unsafe;
133    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
134    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
135}
136#[doc = "`reset()` method sets CTRLBSET to value 0"]
137impl crate::Resettable for CtrlbsetSpec {
138    const RESET_VALUE: u8 = 0;
139}