atsaml21e18b/tc0/count8/
ctrlbset.rs1#[doc = "Register `CTRLBSET` reader"]
2pub struct R(crate::R<CTRLBSET_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRLBSET_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRLBSET_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRLBSET_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRLBSET` writer"]
17pub struct W(crate::W<CTRLBSET_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRLBSET_SPEC>;
20 #[inline(always)]
21 fn deref(&self) -> &Self::Target {
22 &self.0
23 }
24}
25impl core::ops::DerefMut for W {
26 #[inline(always)]
27 fn deref_mut(&mut self) -> &mut Self::Target {
28 &mut self.0
29 }
30}
31impl From<crate::W<CTRLBSET_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRLBSET_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `DIR` reader - Counter Direction"]
38pub type DIR_R = crate::BitReader<bool>;
39#[doc = "Field `DIR` writer - Counter Direction"]
40pub type DIR_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLBSET_SPEC, bool, O>;
41#[doc = "Field `LUPD` reader - Lock Update"]
42pub type LUPD_R = crate::BitReader<bool>;
43#[doc = "Field `LUPD` writer - Lock Update"]
44pub type LUPD_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLBSET_SPEC, bool, O>;
45#[doc = "Field `ONESHOT` reader - One-Shot on Counter"]
46pub type ONESHOT_R = crate::BitReader<bool>;
47#[doc = "Field `ONESHOT` writer - One-Shot on Counter"]
48pub type ONESHOT_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLBSET_SPEC, bool, O>;
49#[doc = "Field `CMD` reader - Command"]
50pub type CMD_R = crate::FieldReader<u8, CMDSELECT_A>;
51#[doc = "Command\n\nValue on reset: 0"]
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53#[repr(u8)]
54pub enum CMDSELECT_A {
55 #[doc = "0: No action"]
56 NONE = 0,
57 #[doc = "1: Force a start, restart or retrigger"]
58 RETRIGGER = 1,
59 #[doc = "2: Force a stop"]
60 STOP = 2,
61 #[doc = "3: Force update of double-buffered register"]
62 UPDATE = 3,
63 #[doc = "4: Force a read synchronization of COUNT"]
64 READSYNC = 4,
65 #[doc = "5: One-shot DMA trigger"]
66 DMAOS = 5,
67}
68impl From<CMDSELECT_A> for u8 {
69 #[inline(always)]
70 fn from(variant: CMDSELECT_A) -> Self {
71 variant as _
72 }
73}
74impl CMD_R {
75 #[doc = "Get enumerated values variant"]
76 #[inline(always)]
77 pub fn variant(&self) -> Option<CMDSELECT_A> {
78 match self.bits {
79 0 => Some(CMDSELECT_A::NONE),
80 1 => Some(CMDSELECT_A::RETRIGGER),
81 2 => Some(CMDSELECT_A::STOP),
82 3 => Some(CMDSELECT_A::UPDATE),
83 4 => Some(CMDSELECT_A::READSYNC),
84 5 => Some(CMDSELECT_A::DMAOS),
85 _ => None,
86 }
87 }
88 #[doc = "Checks if the value of the field is `NONE`"]
89 #[inline(always)]
90 pub fn is_none(&self) -> bool {
91 *self == CMDSELECT_A::NONE
92 }
93 #[doc = "Checks if the value of the field is `RETRIGGER`"]
94 #[inline(always)]
95 pub fn is_retrigger(&self) -> bool {
96 *self == CMDSELECT_A::RETRIGGER
97 }
98 #[doc = "Checks if the value of the field is `STOP`"]
99 #[inline(always)]
100 pub fn is_stop(&self) -> bool {
101 *self == CMDSELECT_A::STOP
102 }
103 #[doc = "Checks if the value of the field is `UPDATE`"]
104 #[inline(always)]
105 pub fn is_update(&self) -> bool {
106 *self == CMDSELECT_A::UPDATE
107 }
108 #[doc = "Checks if the value of the field is `READSYNC`"]
109 #[inline(always)]
110 pub fn is_readsync(&self) -> bool {
111 *self == CMDSELECT_A::READSYNC
112 }
113 #[doc = "Checks if the value of the field is `DMAOS`"]
114 #[inline(always)]
115 pub fn is_dmaos(&self) -> bool {
116 *self == CMDSELECT_A::DMAOS
117 }
118}
119#[doc = "Field `CMD` writer - Command"]
120pub type CMD_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CTRLBSET_SPEC, u8, CMDSELECT_A, 3, O>;
121impl<'a, const O: u8> CMD_W<'a, O> {
122 #[doc = "No action"]
123 #[inline(always)]
124 pub fn none(self) -> &'a mut W {
125 self.variant(CMDSELECT_A::NONE)
126 }
127 #[doc = "Force a start, restart or retrigger"]
128 #[inline(always)]
129 pub fn retrigger(self) -> &'a mut W {
130 self.variant(CMDSELECT_A::RETRIGGER)
131 }
132 #[doc = "Force a stop"]
133 #[inline(always)]
134 pub fn stop(self) -> &'a mut W {
135 self.variant(CMDSELECT_A::STOP)
136 }
137 #[doc = "Force update of double-buffered register"]
138 #[inline(always)]
139 pub fn update(self) -> &'a mut W {
140 self.variant(CMDSELECT_A::UPDATE)
141 }
142 #[doc = "Force a read synchronization of COUNT"]
143 #[inline(always)]
144 pub fn readsync(self) -> &'a mut W {
145 self.variant(CMDSELECT_A::READSYNC)
146 }
147 #[doc = "One-shot DMA trigger"]
148 #[inline(always)]
149 pub fn dmaos(self) -> &'a mut W {
150 self.variant(CMDSELECT_A::DMAOS)
151 }
152}
153impl R {
154 #[doc = "Bit 0 - Counter Direction"]
155 #[inline(always)]
156 pub fn dir(&self) -> DIR_R {
157 DIR_R::new((self.bits & 1) != 0)
158 }
159 #[doc = "Bit 1 - Lock Update"]
160 #[inline(always)]
161 pub fn lupd(&self) -> LUPD_R {
162 LUPD_R::new(((self.bits >> 1) & 1) != 0)
163 }
164 #[doc = "Bit 2 - One-Shot on Counter"]
165 #[inline(always)]
166 pub fn oneshot(&self) -> ONESHOT_R {
167 ONESHOT_R::new(((self.bits >> 2) & 1) != 0)
168 }
169 #[doc = "Bits 5:7 - Command"]
170 #[inline(always)]
171 pub fn cmd(&self) -> CMD_R {
172 CMD_R::new((self.bits >> 5) & 7)
173 }
174}
175impl W {
176 #[doc = "Bit 0 - Counter Direction"]
177 #[inline(always)]
178 #[must_use]
179 pub fn dir(&mut self) -> DIR_W<0> {
180 DIR_W::new(self)
181 }
182 #[doc = "Bit 1 - Lock Update"]
183 #[inline(always)]
184 #[must_use]
185 pub fn lupd(&mut self) -> LUPD_W<1> {
186 LUPD_W::new(self)
187 }
188 #[doc = "Bit 2 - One-Shot on Counter"]
189 #[inline(always)]
190 #[must_use]
191 pub fn oneshot(&mut self) -> ONESHOT_W<2> {
192 ONESHOT_W::new(self)
193 }
194 #[doc = "Bits 5:7 - Command"]
195 #[inline(always)]
196 #[must_use]
197 pub fn cmd(&mut self) -> CMD_W<5> {
198 CMD_W::new(self)
199 }
200 #[doc = "Writes raw bits to the register."]
201 #[inline(always)]
202 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
203 self.0.bits(bits);
204 self
205 }
206}
207#[doc = "Control B Set\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ctrlbset](index.html) module"]
208pub struct CTRLBSET_SPEC;
209impl crate::RegisterSpec for CTRLBSET_SPEC {
210 type Ux = u8;
211}
212#[doc = "`read()` method returns [ctrlbset::R](R) reader structure"]
213impl crate::Readable for CTRLBSET_SPEC {
214 type Reader = R;
215}
216#[doc = "`write(|w| ..)` method takes [ctrlbset::W](W) writer structure"]
217impl crate::Writable for CTRLBSET_SPEC {
218 type Writer = W;
219 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
220 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
221}
222#[doc = "`reset()` method sets CTRLBSET to value 0"]
223impl crate::Resettable for CTRLBSET_SPEC {
224 const RESET_VALUE: Self::Ux = 0;
225}