atsamd21j/tcc0/
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"]
14pub type OneshotR = crate::BitReader;
15#[doc = "Field `ONESHOT` writer - One-Shot"]
16pub type OneshotW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Ramp Index Command\n\nValue on reset: 0"]
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19#[repr(u8)]
20pub enum Idxcmdselect {
21 #[doc = "0: Command disabled: Index toggles between cycles A and B"]
22 Disable = 0,
23 #[doc = "1: Set index: cycle B will be forced in the next cycle"]
24 Set = 1,
25 #[doc = "2: Clear index: cycle A will be forced in the next cycle"]
26 Clear = 2,
27 #[doc = "3: Hold index: the next cycle will be the same as the current cycle"]
28 Hold = 3,
29}
30impl From<Idxcmdselect> for u8 {
31 #[inline(always)]
32 fn from(variant: Idxcmdselect) -> Self {
33 variant as _
34 }
35}
36impl crate::FieldSpec for Idxcmdselect {
37 type Ux = u8;
38}
39impl crate::IsEnum for Idxcmdselect {}
40#[doc = "Field `IDXCMD` reader - Ramp Index Command"]
41pub type IdxcmdR = crate::FieldReader<Idxcmdselect>;
42impl IdxcmdR {
43 #[doc = "Get enumerated values variant"]
44 #[inline(always)]
45 pub const fn variant(&self) -> Idxcmdselect {
46 match self.bits {
47 0 => Idxcmdselect::Disable,
48 1 => Idxcmdselect::Set,
49 2 => Idxcmdselect::Clear,
50 3 => Idxcmdselect::Hold,
51 _ => unreachable!(),
52 }
53 }
54 #[doc = "Command disabled: Index toggles between cycles A and B"]
55 #[inline(always)]
56 pub fn is_disable(&self) -> bool {
57 *self == Idxcmdselect::Disable
58 }
59 #[doc = "Set index: cycle B will be forced in the next cycle"]
60 #[inline(always)]
61 pub fn is_set(&self) -> bool {
62 *self == Idxcmdselect::Set
63 }
64 #[doc = "Clear index: cycle A will be forced in the next cycle"]
65 #[inline(always)]
66 pub fn is_clear(&self) -> bool {
67 *self == Idxcmdselect::Clear
68 }
69 #[doc = "Hold index: the next cycle will be the same as the current cycle"]
70 #[inline(always)]
71 pub fn is_hold(&self) -> bool {
72 *self == Idxcmdselect::Hold
73 }
74}
75#[doc = "Field `IDXCMD` writer - Ramp Index Command"]
76pub type IdxcmdW<'a, REG> = crate::FieldWriter<'a, REG, 2, Idxcmdselect, crate::Safe>;
77impl<'a, REG> IdxcmdW<'a, REG>
78where
79 REG: crate::Writable + crate::RegisterSpec,
80 REG::Ux: From<u8>,
81{
82 #[doc = "Command disabled: Index toggles between cycles A and B"]
83 #[inline(always)]
84 pub fn disable(self) -> &'a mut crate::W<REG> {
85 self.variant(Idxcmdselect::Disable)
86 }
87 #[doc = "Set index: cycle B will be forced in the next cycle"]
88 #[inline(always)]
89 pub fn set_(self) -> &'a mut crate::W<REG> {
90 self.variant(Idxcmdselect::Set)
91 }
92 #[doc = "Clear index: cycle A will be forced in the next cycle"]
93 #[inline(always)]
94 pub fn clear(self) -> &'a mut crate::W<REG> {
95 self.variant(Idxcmdselect::Clear)
96 }
97 #[doc = "Hold index: the next cycle will be the same as the current cycle"]
98 #[inline(always)]
99 pub fn hold(self) -> &'a mut crate::W<REG> {
100 self.variant(Idxcmdselect::Hold)
101 }
102}
103#[doc = "TCC Command\n\nValue on reset: 0"]
104#[derive(Clone, Copy, Debug, PartialEq, Eq)]
105#[repr(u8)]
106pub enum Cmdselect {
107 #[doc = "0: No action"]
108 None = 0,
109 #[doc = "1: Clear start, restart or retrigger"]
110 Retrigger = 1,
111 #[doc = "2: Force stop"]
112 Stop = 2,
113 #[doc = "3: Force update of double buffered registers"]
114 Update = 3,
115 #[doc = "4: Force COUNT read synchronization"]
116 Readsync = 4,
117}
118impl From<Cmdselect> for u8 {
119 #[inline(always)]
120 fn from(variant: Cmdselect) -> Self {
121 variant as _
122 }
123}
124impl crate::FieldSpec for Cmdselect {
125 type Ux = u8;
126}
127impl crate::IsEnum for Cmdselect {}
128#[doc = "Field `CMD` reader - TCC Command"]
129pub type CmdR = crate::FieldReader<Cmdselect>;
130impl CmdR {
131 #[doc = "Get enumerated values variant"]
132 #[inline(always)]
133 pub const fn variant(&self) -> Option<Cmdselect> {
134 match self.bits {
135 0 => Some(Cmdselect::None),
136 1 => Some(Cmdselect::Retrigger),
137 2 => Some(Cmdselect::Stop),
138 3 => Some(Cmdselect::Update),
139 4 => Some(Cmdselect::Readsync),
140 _ => None,
141 }
142 }
143 #[doc = "No action"]
144 #[inline(always)]
145 pub fn is_none(&self) -> bool {
146 *self == Cmdselect::None
147 }
148 #[doc = "Clear start, restart or retrigger"]
149 #[inline(always)]
150 pub fn is_retrigger(&self) -> bool {
151 *self == Cmdselect::Retrigger
152 }
153 #[doc = "Force stop"]
154 #[inline(always)]
155 pub fn is_stop(&self) -> bool {
156 *self == Cmdselect::Stop
157 }
158 #[doc = "Force update of double buffered registers"]
159 #[inline(always)]
160 pub fn is_update(&self) -> bool {
161 *self == Cmdselect::Update
162 }
163 #[doc = "Force COUNT read synchronization"]
164 #[inline(always)]
165 pub fn is_readsync(&self) -> bool {
166 *self == Cmdselect::Readsync
167 }
168}
169#[doc = "Field `CMD` writer - TCC Command"]
170pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 3, Cmdselect>;
171impl<'a, REG> CmdW<'a, REG>
172where
173 REG: crate::Writable + crate::RegisterSpec,
174 REG::Ux: From<u8>,
175{
176 #[doc = "No action"]
177 #[inline(always)]
178 pub fn none(self) -> &'a mut crate::W<REG> {
179 self.variant(Cmdselect::None)
180 }
181 #[doc = "Clear start, restart or retrigger"]
182 #[inline(always)]
183 pub fn retrigger(self) -> &'a mut crate::W<REG> {
184 self.variant(Cmdselect::Retrigger)
185 }
186 #[doc = "Force stop"]
187 #[inline(always)]
188 pub fn stop(self) -> &'a mut crate::W<REG> {
189 self.variant(Cmdselect::Stop)
190 }
191 #[doc = "Force update of double buffered registers"]
192 #[inline(always)]
193 pub fn update(self) -> &'a mut crate::W<REG> {
194 self.variant(Cmdselect::Update)
195 }
196 #[doc = "Force COUNT read synchronization"]
197 #[inline(always)]
198 pub fn readsync(self) -> &'a mut crate::W<REG> {
199 self.variant(Cmdselect::Readsync)
200 }
201}
202impl R {
203 #[doc = "Bit 0 - Counter Direction"]
204 #[inline(always)]
205 pub fn dir(&self) -> DirR {
206 DirR::new((self.bits & 1) != 0)
207 }
208 #[doc = "Bit 1 - Lock Update"]
209 #[inline(always)]
210 pub fn lupd(&self) -> LupdR {
211 LupdR::new(((self.bits >> 1) & 1) != 0)
212 }
213 #[doc = "Bit 2 - One-Shot"]
214 #[inline(always)]
215 pub fn oneshot(&self) -> OneshotR {
216 OneshotR::new(((self.bits >> 2) & 1) != 0)
217 }
218 #[doc = "Bits 3:4 - Ramp Index Command"]
219 #[inline(always)]
220 pub fn idxcmd(&self) -> IdxcmdR {
221 IdxcmdR::new((self.bits >> 3) & 3)
222 }
223 #[doc = "Bits 5:7 - TCC Command"]
224 #[inline(always)]
225 pub fn cmd(&self) -> CmdR {
226 CmdR::new((self.bits >> 5) & 7)
227 }
228}
229impl W {
230 #[doc = "Bit 0 - Counter Direction"]
231 #[inline(always)]
232 #[must_use]
233 pub fn dir(&mut self) -> DirW<CtrlbclrSpec> {
234 DirW::new(self, 0)
235 }
236 #[doc = "Bit 1 - Lock Update"]
237 #[inline(always)]
238 #[must_use]
239 pub fn lupd(&mut self) -> LupdW<CtrlbclrSpec> {
240 LupdW::new(self, 1)
241 }
242 #[doc = "Bit 2 - One-Shot"]
243 #[inline(always)]
244 #[must_use]
245 pub fn oneshot(&mut self) -> OneshotW<CtrlbclrSpec> {
246 OneshotW::new(self, 2)
247 }
248 #[doc = "Bits 3:4 - Ramp Index Command"]
249 #[inline(always)]
250 #[must_use]
251 pub fn idxcmd(&mut self) -> IdxcmdW<CtrlbclrSpec> {
252 IdxcmdW::new(self, 3)
253 }
254 #[doc = "Bits 5:7 - TCC Command"]
255 #[inline(always)]
256 #[must_use]
257 pub fn cmd(&mut self) -> CmdW<CtrlbclrSpec> {
258 CmdW::new(self, 5)
259 }
260}
261#[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)."]
262pub struct CtrlbclrSpec;
263impl crate::RegisterSpec for CtrlbclrSpec {
264 type Ux = u8;
265}
266#[doc = "`read()` method returns [`ctrlbclr::R`](R) reader structure"]
267impl crate::Readable for CtrlbclrSpec {}
268#[doc = "`write(|w| ..)` method takes [`ctrlbclr::W`](W) writer structure"]
269impl crate::Writable for CtrlbclrSpec {
270 type Safety = crate::Unsafe;
271 const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
272 const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
273}
274#[doc = "`reset()` method sets CTRLBCLR to value 0"]
275impl crate::Resettable for CtrlbclrSpec {
276 const RESET_VALUE: u8 = 0;
277}