atsamd51p/tc0/count8/
ctrlbclr.rs
1#[doc = "Register `CTRLBCLR` reader"]
2pub type R = crate::R<CtrlbclrSpec>;
3#[doc = "Register `CTRLBCLR` writer"]
4pub type W = crate::W<CtrlbclrSpec>;
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 `LUPD` reader - Lock Update"]
10pub type LupdR = crate::BitReader;
11#[doc = "Field `LUPD` writer - Lock Update"]
12pub type LupdW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `ONESHOT` reader - One-Shot on Counter"]
14pub type OneshotR = crate::BitReader;
15#[doc = "Field `ONESHOT` writer - One-Shot on Counter"]
16pub type OneshotW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Command\n\nValue on reset: 0"]
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19#[repr(u8)]
20pub enum Cmdselect {
21 #[doc = "0: No action"]
22 None = 0,
23 #[doc = "1: Force a start, restart or retrigger"]
24 Retrigger = 1,
25 #[doc = "2: Force a stop"]
26 Stop = 2,
27 #[doc = "3: Force update of double-buffered register"]
28 Update = 3,
29 #[doc = "4: Force a read synchronization of COUNT"]
30 Readsync = 4,
31}
32impl From<Cmdselect> for u8 {
33 #[inline(always)]
34 fn from(variant: Cmdselect) -> Self {
35 variant as _
36 }
37}
38impl crate::FieldSpec for Cmdselect {
39 type Ux = u8;
40}
41impl crate::IsEnum for Cmdselect {}
42#[doc = "Field `CMD` reader - Command"]
43pub type CmdR = crate::FieldReader<Cmdselect>;
44impl CmdR {
45 #[doc = "Get enumerated values variant"]
46 #[inline(always)]
47 pub const fn variant(&self) -> Option<Cmdselect> {
48 match self.bits {
49 0 => Some(Cmdselect::None),
50 1 => Some(Cmdselect::Retrigger),
51 2 => Some(Cmdselect::Stop),
52 3 => Some(Cmdselect::Update),
53 4 => Some(Cmdselect::Readsync),
54 _ => None,
55 }
56 }
57 #[doc = "No action"]
58 #[inline(always)]
59 pub fn is_none(&self) -> bool {
60 *self == Cmdselect::None
61 }
62 #[doc = "Force a start, restart or retrigger"]
63 #[inline(always)]
64 pub fn is_retrigger(&self) -> bool {
65 *self == Cmdselect::Retrigger
66 }
67 #[doc = "Force a stop"]
68 #[inline(always)]
69 pub fn is_stop(&self) -> bool {
70 *self == Cmdselect::Stop
71 }
72 #[doc = "Force update of double-buffered register"]
73 #[inline(always)]
74 pub fn is_update(&self) -> bool {
75 *self == Cmdselect::Update
76 }
77 #[doc = "Force a read synchronization of COUNT"]
78 #[inline(always)]
79 pub fn is_readsync(&self) -> bool {
80 *self == Cmdselect::Readsync
81 }
82}
83#[doc = "Field `CMD` writer - Command"]
84pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 3, Cmdselect>;
85impl<'a, REG> CmdW<'a, REG>
86where
87 REG: crate::Writable + crate::RegisterSpec,
88 REG::Ux: From<u8>,
89{
90 #[doc = "No action"]
91 #[inline(always)]
92 pub fn none(self) -> &'a mut crate::W<REG> {
93 self.variant(Cmdselect::None)
94 }
95 #[doc = "Force a start, restart or retrigger"]
96 #[inline(always)]
97 pub fn retrigger(self) -> &'a mut crate::W<REG> {
98 self.variant(Cmdselect::Retrigger)
99 }
100 #[doc = "Force a stop"]
101 #[inline(always)]
102 pub fn stop(self) -> &'a mut crate::W<REG> {
103 self.variant(Cmdselect::Stop)
104 }
105 #[doc = "Force update of double-buffered register"]
106 #[inline(always)]
107 pub fn update(self) -> &'a mut crate::W<REG> {
108 self.variant(Cmdselect::Update)
109 }
110 #[doc = "Force a read synchronization of COUNT"]
111 #[inline(always)]
112 pub fn readsync(self) -> &'a mut crate::W<REG> {
113 self.variant(Cmdselect::Readsync)
114 }
115}
116impl R {
117 #[doc = "Bit 0 - Counter Direction"]
118 #[inline(always)]
119 pub fn dir(&self) -> DirR {
120 DirR::new((self.bits & 1) != 0)
121 }
122 #[doc = "Bit 1 - Lock Update"]
123 #[inline(always)]
124 pub fn lupd(&self) -> LupdR {
125 LupdR::new(((self.bits >> 1) & 1) != 0)
126 }
127 #[doc = "Bit 2 - One-Shot on Counter"]
128 #[inline(always)]
129 pub fn oneshot(&self) -> OneshotR {
130 OneshotR::new(((self.bits >> 2) & 1) != 0)
131 }
132 #[doc = "Bits 5:7 - Command"]
133 #[inline(always)]
134 pub fn cmd(&self) -> CmdR {
135 CmdR::new((self.bits >> 5) & 7)
136 }
137}
138impl W {
139 #[doc = "Bit 0 - Counter Direction"]
140 #[inline(always)]
141 #[must_use]
142 pub fn dir(&mut self) -> DirW<CtrlbclrSpec> {
143 DirW::new(self, 0)
144 }
145 #[doc = "Bit 1 - Lock Update"]
146 #[inline(always)]
147 #[must_use]
148 pub fn lupd(&mut self) -> LupdW<CtrlbclrSpec> {
149 LupdW::new(self, 1)
150 }
151 #[doc = "Bit 2 - One-Shot on Counter"]
152 #[inline(always)]
153 #[must_use]
154 pub fn oneshot(&mut self) -> OneshotW<CtrlbclrSpec> {
155 OneshotW::new(self, 2)
156 }
157 #[doc = "Bits 5:7 - Command"]
158 #[inline(always)]
159 #[must_use]
160 pub fn cmd(&mut self) -> CmdW<CtrlbclrSpec> {
161 CmdW::new(self, 5)
162 }
163}
164#[doc = "Control B Clear\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlbclr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlbclr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
165pub struct CtrlbclrSpec;
166impl crate::RegisterSpec for CtrlbclrSpec {
167 type Ux = u8;
168}
169#[doc = "`read()` method returns [`ctrlbclr::R`](R) reader structure"]
170impl crate::Readable for CtrlbclrSpec {}
171#[doc = "`write(|w| ..)` method takes [`ctrlbclr::W`](W) writer structure"]
172impl crate::Writable for CtrlbclrSpec {
173 type Safety = crate::Unsafe;
174 const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
175 const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
176}
177#[doc = "`reset()` method sets CTRLBCLR to value 0"]
178impl crate::Resettable for CtrlbclrSpec {
179 const RESET_VALUE: u8 = 0;
180}