atsamd51j/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 or double buffered registers"]
114 Update = 3,
115 #[doc = "4: Force COUNT read synchronization"]
116 Readsync = 4,
117 #[doc = "5: One-shot DMA trigger"]
118 Dmaos = 5,
119}
120impl From<Cmdselect> for u8 {
121 #[inline(always)]
122 fn from(variant: Cmdselect) -> Self {
123 variant as _
124 }
125}
126impl crate::FieldSpec for Cmdselect {
127 type Ux = u8;
128}
129impl crate::IsEnum for Cmdselect {}
130#[doc = "Field `CMD` reader - TCC Command"]
131pub type CmdR = crate::FieldReader<Cmdselect>;
132impl CmdR {
133 #[doc = "Get enumerated values variant"]
134 #[inline(always)]
135 pub const fn variant(&self) -> Option<Cmdselect> {
136 match self.bits {
137 0 => Some(Cmdselect::None),
138 1 => Some(Cmdselect::Retrigger),
139 2 => Some(Cmdselect::Stop),
140 3 => Some(Cmdselect::Update),
141 4 => Some(Cmdselect::Readsync),
142 5 => Some(Cmdselect::Dmaos),
143 _ => None,
144 }
145 }
146 #[doc = "No action"]
147 #[inline(always)]
148 pub fn is_none(&self) -> bool {
149 *self == Cmdselect::None
150 }
151 #[doc = "Clear start, restart or retrigger"]
152 #[inline(always)]
153 pub fn is_retrigger(&self) -> bool {
154 *self == Cmdselect::Retrigger
155 }
156 #[doc = "Force stop"]
157 #[inline(always)]
158 pub fn is_stop(&self) -> bool {
159 *self == Cmdselect::Stop
160 }
161 #[doc = "Force update or double buffered registers"]
162 #[inline(always)]
163 pub fn is_update(&self) -> bool {
164 *self == Cmdselect::Update
165 }
166 #[doc = "Force COUNT read synchronization"]
167 #[inline(always)]
168 pub fn is_readsync(&self) -> bool {
169 *self == Cmdselect::Readsync
170 }
171 #[doc = "One-shot DMA trigger"]
172 #[inline(always)]
173 pub fn is_dmaos(&self) -> bool {
174 *self == Cmdselect::Dmaos
175 }
176}
177#[doc = "Field `CMD` writer - TCC Command"]
178pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 3, Cmdselect>;
179impl<'a, REG> CmdW<'a, REG>
180where
181 REG: crate::Writable + crate::RegisterSpec,
182 REG::Ux: From<u8>,
183{
184 #[doc = "No action"]
185 #[inline(always)]
186 pub fn none(self) -> &'a mut crate::W<REG> {
187 self.variant(Cmdselect::None)
188 }
189 #[doc = "Clear start, restart or retrigger"]
190 #[inline(always)]
191 pub fn retrigger(self) -> &'a mut crate::W<REG> {
192 self.variant(Cmdselect::Retrigger)
193 }
194 #[doc = "Force stop"]
195 #[inline(always)]
196 pub fn stop(self) -> &'a mut crate::W<REG> {
197 self.variant(Cmdselect::Stop)
198 }
199 #[doc = "Force update or double buffered registers"]
200 #[inline(always)]
201 pub fn update(self) -> &'a mut crate::W<REG> {
202 self.variant(Cmdselect::Update)
203 }
204 #[doc = "Force COUNT read synchronization"]
205 #[inline(always)]
206 pub fn readsync(self) -> &'a mut crate::W<REG> {
207 self.variant(Cmdselect::Readsync)
208 }
209 #[doc = "One-shot DMA trigger"]
210 #[inline(always)]
211 pub fn dmaos(self) -> &'a mut crate::W<REG> {
212 self.variant(Cmdselect::Dmaos)
213 }
214}
215impl R {
216 #[doc = "Bit 0 - Counter Direction"]
217 #[inline(always)]
218 pub fn dir(&self) -> DirR {
219 DirR::new((self.bits & 1) != 0)
220 }
221 #[doc = "Bit 1 - Lock Update"]
222 #[inline(always)]
223 pub fn lupd(&self) -> LupdR {
224 LupdR::new(((self.bits >> 1) & 1) != 0)
225 }
226 #[doc = "Bit 2 - One-Shot"]
227 #[inline(always)]
228 pub fn oneshot(&self) -> OneshotR {
229 OneshotR::new(((self.bits >> 2) & 1) != 0)
230 }
231 #[doc = "Bits 3:4 - Ramp Index Command"]
232 #[inline(always)]
233 pub fn idxcmd(&self) -> IdxcmdR {
234 IdxcmdR::new((self.bits >> 3) & 3)
235 }
236 #[doc = "Bits 5:7 - TCC Command"]
237 #[inline(always)]
238 pub fn cmd(&self) -> CmdR {
239 CmdR::new((self.bits >> 5) & 7)
240 }
241}
242impl W {
243 #[doc = "Bit 0 - Counter Direction"]
244 #[inline(always)]
245 #[must_use]
246 pub fn dir(&mut self) -> DirW<CtrlbclrSpec> {
247 DirW::new(self, 0)
248 }
249 #[doc = "Bit 1 - Lock Update"]
250 #[inline(always)]
251 #[must_use]
252 pub fn lupd(&mut self) -> LupdW<CtrlbclrSpec> {
253 LupdW::new(self, 1)
254 }
255 #[doc = "Bit 2 - One-Shot"]
256 #[inline(always)]
257 #[must_use]
258 pub fn oneshot(&mut self) -> OneshotW<CtrlbclrSpec> {
259 OneshotW::new(self, 2)
260 }
261 #[doc = "Bits 3:4 - Ramp Index Command"]
262 #[inline(always)]
263 #[must_use]
264 pub fn idxcmd(&mut self) -> IdxcmdW<CtrlbclrSpec> {
265 IdxcmdW::new(self, 3)
266 }
267 #[doc = "Bits 5:7 - TCC Command"]
268 #[inline(always)]
269 #[must_use]
270 pub fn cmd(&mut self) -> CmdW<CtrlbclrSpec> {
271 CmdW::new(self, 5)
272 }
273}
274#[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)."]
275pub struct CtrlbclrSpec;
276impl crate::RegisterSpec for CtrlbclrSpec {
277 type Ux = u8;
278}
279#[doc = "`read()` method returns [`ctrlbclr::R`](R) reader structure"]
280impl crate::Readable for CtrlbclrSpec {}
281#[doc = "`write(|w| ..)` method takes [`ctrlbclr::W`](W) writer structure"]
282impl crate::Writable for CtrlbclrSpec {
283 type Safety = crate::Unsafe;
284 const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
285 const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
286}
287#[doc = "`reset()` method sets CTRLBCLR to value 0"]
288impl crate::Resettable for CtrlbclrSpec {
289 const RESET_VALUE: u8 = 0;
290}