stm32f1/stm32f100/tim16/
cr2.rs1#[doc = "Register `CR2` reader"]
2pub struct R(crate::R<CR2_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CR2_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CR2_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CR2_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CR2` writer"]
17pub struct W(crate::W<CR2_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CR2_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<CR2_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CR2_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Output Idle state 1\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum OIS1N_A {
40 #[doc = "0: OC1N=0 after a dead-time when MOE=0"]
41 Low = 0,
42 #[doc = "1: OC1N=1 after a dead-time when MOE=0"]
43 High = 1,
44}
45impl From<OIS1N_A> for bool {
46 #[inline(always)]
47 fn from(variant: OIS1N_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `OIS1N` reader - Output Idle state 1"]
52pub type OIS1N_R = crate::BitReader<OIS1N_A>;
53impl OIS1N_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> OIS1N_A {
57 match self.bits {
58 false => OIS1N_A::Low,
59 true => OIS1N_A::High,
60 }
61 }
62 #[doc = "Checks if the value of the field is `Low`"]
63 #[inline(always)]
64 pub fn is_low(&self) -> bool {
65 *self == OIS1N_A::Low
66 }
67 #[doc = "Checks if the value of the field is `High`"]
68 #[inline(always)]
69 pub fn is_high(&self) -> bool {
70 *self == OIS1N_A::High
71 }
72}
73#[doc = "Field `OIS1N` writer - Output Idle state 1"]
74pub type OIS1N_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR2_SPEC, OIS1N_A, O>;
75impl<'a, const O: u8> OIS1N_W<'a, O> {
76 #[doc = "OC1N=0 after a dead-time when MOE=0"]
77 #[inline(always)]
78 pub fn low(self) -> &'a mut W {
79 self.variant(OIS1N_A::Low)
80 }
81 #[doc = "OC1N=1 after a dead-time when MOE=0"]
82 #[inline(always)]
83 pub fn high(self) -> &'a mut W {
84 self.variant(OIS1N_A::High)
85 }
86}
87#[doc = "Output Idle state 1\n\nValue on reset: 0"]
88#[derive(Clone, Copy, Debug, PartialEq)]
89pub enum OIS1_A {
90 #[doc = "0: OC1=0 (after a dead-time if OC1N is implemented) when MOE=0"]
91 Low = 0,
92 #[doc = "1: OC1=1 (after a dead-time if OC1N is implemented) when MOE=0"]
93 High = 1,
94}
95impl From<OIS1_A> for bool {
96 #[inline(always)]
97 fn from(variant: OIS1_A) -> Self {
98 variant as u8 != 0
99 }
100}
101#[doc = "Field `OIS1` reader - Output Idle state 1"]
102pub type OIS1_R = crate::BitReader<OIS1_A>;
103impl OIS1_R {
104 #[doc = "Get enumerated values variant"]
105 #[inline(always)]
106 pub fn variant(&self) -> OIS1_A {
107 match self.bits {
108 false => OIS1_A::Low,
109 true => OIS1_A::High,
110 }
111 }
112 #[doc = "Checks if the value of the field is `Low`"]
113 #[inline(always)]
114 pub fn is_low(&self) -> bool {
115 *self == OIS1_A::Low
116 }
117 #[doc = "Checks if the value of the field is `High`"]
118 #[inline(always)]
119 pub fn is_high(&self) -> bool {
120 *self == OIS1_A::High
121 }
122}
123#[doc = "Field `OIS1` writer - Output Idle state 1"]
124pub type OIS1_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR2_SPEC, OIS1_A, O>;
125impl<'a, const O: u8> OIS1_W<'a, O> {
126 #[doc = "OC1=0 (after a dead-time if OC1N is implemented) when MOE=0"]
127 #[inline(always)]
128 pub fn low(self) -> &'a mut W {
129 self.variant(OIS1_A::Low)
130 }
131 #[doc = "OC1=1 (after a dead-time if OC1N is implemented) when MOE=0"]
132 #[inline(always)]
133 pub fn high(self) -> &'a mut W {
134 self.variant(OIS1_A::High)
135 }
136}
137#[doc = "Capture/compare DMA selection\n\nValue on reset: 0"]
138#[derive(Clone, Copy, Debug, PartialEq)]
139pub enum CCDS_A {
140 #[doc = "0: CCx DMA request sent when CCx event occurs"]
141 OnCompare = 0,
142 #[doc = "1: CCx DMA request sent when update event occurs"]
143 OnUpdate = 1,
144}
145impl From<CCDS_A> for bool {
146 #[inline(always)]
147 fn from(variant: CCDS_A) -> Self {
148 variant as u8 != 0
149 }
150}
151#[doc = "Field `CCDS` reader - Capture/compare DMA selection"]
152pub type CCDS_R = crate::BitReader<CCDS_A>;
153impl CCDS_R {
154 #[doc = "Get enumerated values variant"]
155 #[inline(always)]
156 pub fn variant(&self) -> CCDS_A {
157 match self.bits {
158 false => CCDS_A::OnCompare,
159 true => CCDS_A::OnUpdate,
160 }
161 }
162 #[doc = "Checks if the value of the field is `OnCompare`"]
163 #[inline(always)]
164 pub fn is_on_compare(&self) -> bool {
165 *self == CCDS_A::OnCompare
166 }
167 #[doc = "Checks if the value of the field is `OnUpdate`"]
168 #[inline(always)]
169 pub fn is_on_update(&self) -> bool {
170 *self == CCDS_A::OnUpdate
171 }
172}
173#[doc = "Field `CCDS` writer - Capture/compare DMA selection"]
174pub type CCDS_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR2_SPEC, CCDS_A, O>;
175impl<'a, const O: u8> CCDS_W<'a, O> {
176 #[doc = "CCx DMA request sent when CCx event occurs"]
177 #[inline(always)]
178 pub fn on_compare(self) -> &'a mut W {
179 self.variant(CCDS_A::OnCompare)
180 }
181 #[doc = "CCx DMA request sent when update event occurs"]
182 #[inline(always)]
183 pub fn on_update(self) -> &'a mut W {
184 self.variant(CCDS_A::OnUpdate)
185 }
186}
187#[doc = "Capture/compare control update selection\n\nValue on reset: 0"]
188#[derive(Clone, Copy, Debug, PartialEq)]
189pub enum CCUS_A {
190 #[doc = "0: Capture/compare are updated only by setting the COMG bit"]
191 Default = 0,
192 #[doc = "1: Capture/compare are updated by setting the COMG bit or when an rising edge occurs on TRGI"]
193 WithRisingEdge = 1,
194}
195impl From<CCUS_A> for bool {
196 #[inline(always)]
197 fn from(variant: CCUS_A) -> Self {
198 variant as u8 != 0
199 }
200}
201#[doc = "Field `CCUS` reader - Capture/compare control update selection"]
202pub type CCUS_R = crate::BitReader<CCUS_A>;
203impl CCUS_R {
204 #[doc = "Get enumerated values variant"]
205 #[inline(always)]
206 pub fn variant(&self) -> CCUS_A {
207 match self.bits {
208 false => CCUS_A::Default,
209 true => CCUS_A::WithRisingEdge,
210 }
211 }
212 #[doc = "Checks if the value of the field is `Default`"]
213 #[inline(always)]
214 pub fn is_default(&self) -> bool {
215 *self == CCUS_A::Default
216 }
217 #[doc = "Checks if the value of the field is `WithRisingEdge`"]
218 #[inline(always)]
219 pub fn is_with_rising_edge(&self) -> bool {
220 *self == CCUS_A::WithRisingEdge
221 }
222}
223#[doc = "Field `CCUS` writer - Capture/compare control update selection"]
224pub type CCUS_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR2_SPEC, CCUS_A, O>;
225impl<'a, const O: u8> CCUS_W<'a, O> {
226 #[doc = "Capture/compare are updated only by setting the COMG bit"]
227 #[inline(always)]
228 pub fn default(self) -> &'a mut W {
229 self.variant(CCUS_A::Default)
230 }
231 #[doc = "Capture/compare are updated by setting the COMG bit or when an rising edge occurs on TRGI"]
232 #[inline(always)]
233 pub fn with_rising_edge(self) -> &'a mut W {
234 self.variant(CCUS_A::WithRisingEdge)
235 }
236}
237#[doc = "Capture/compare preloaded control\n\nValue on reset: 0"]
238#[derive(Clone, Copy, Debug, PartialEq)]
239pub enum CCPC_A {
240 #[doc = "0: CCxE, CCxNE and OCxM bits are not preloaded"]
241 NotPreloaded = 0,
242 #[doc = "1: CCxE, CCxNE and OCxM bits are preloaded"]
243 Preloaded = 1,
244}
245impl From<CCPC_A> for bool {
246 #[inline(always)]
247 fn from(variant: CCPC_A) -> Self {
248 variant as u8 != 0
249 }
250}
251#[doc = "Field `CCPC` reader - Capture/compare preloaded control"]
252pub type CCPC_R = crate::BitReader<CCPC_A>;
253impl CCPC_R {
254 #[doc = "Get enumerated values variant"]
255 #[inline(always)]
256 pub fn variant(&self) -> CCPC_A {
257 match self.bits {
258 false => CCPC_A::NotPreloaded,
259 true => CCPC_A::Preloaded,
260 }
261 }
262 #[doc = "Checks if the value of the field is `NotPreloaded`"]
263 #[inline(always)]
264 pub fn is_not_preloaded(&self) -> bool {
265 *self == CCPC_A::NotPreloaded
266 }
267 #[doc = "Checks if the value of the field is `Preloaded`"]
268 #[inline(always)]
269 pub fn is_preloaded(&self) -> bool {
270 *self == CCPC_A::Preloaded
271 }
272}
273#[doc = "Field `CCPC` writer - Capture/compare preloaded control"]
274pub type CCPC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR2_SPEC, CCPC_A, O>;
275impl<'a, const O: u8> CCPC_W<'a, O> {
276 #[doc = "CCxE, CCxNE and OCxM bits are not preloaded"]
277 #[inline(always)]
278 pub fn not_preloaded(self) -> &'a mut W {
279 self.variant(CCPC_A::NotPreloaded)
280 }
281 #[doc = "CCxE, CCxNE and OCxM bits are preloaded"]
282 #[inline(always)]
283 pub fn preloaded(self) -> &'a mut W {
284 self.variant(CCPC_A::Preloaded)
285 }
286}
287impl R {
288 #[doc = "Bit 9 - Output Idle state 1"]
289 #[inline(always)]
290 pub fn ois1n(&self) -> OIS1N_R {
291 OIS1N_R::new(((self.bits >> 9) & 1) != 0)
292 }
293 #[doc = "Bit 8 - Output Idle state 1"]
294 #[inline(always)]
295 pub fn ois1(&self) -> OIS1_R {
296 OIS1_R::new(((self.bits >> 8) & 1) != 0)
297 }
298 #[doc = "Bit 3 - Capture/compare DMA selection"]
299 #[inline(always)]
300 pub fn ccds(&self) -> CCDS_R {
301 CCDS_R::new(((self.bits >> 3) & 1) != 0)
302 }
303 #[doc = "Bit 2 - Capture/compare control update selection"]
304 #[inline(always)]
305 pub fn ccus(&self) -> CCUS_R {
306 CCUS_R::new(((self.bits >> 2) & 1) != 0)
307 }
308 #[doc = "Bit 0 - Capture/compare preloaded control"]
309 #[inline(always)]
310 pub fn ccpc(&self) -> CCPC_R {
311 CCPC_R::new((self.bits & 1) != 0)
312 }
313}
314impl W {
315 #[doc = "Bit 9 - Output Idle state 1"]
316 #[inline(always)]
317 pub fn ois1n(&mut self) -> OIS1N_W<9> {
318 OIS1N_W::new(self)
319 }
320 #[doc = "Bit 8 - Output Idle state 1"]
321 #[inline(always)]
322 pub fn ois1(&mut self) -> OIS1_W<8> {
323 OIS1_W::new(self)
324 }
325 #[doc = "Bit 3 - Capture/compare DMA selection"]
326 #[inline(always)]
327 pub fn ccds(&mut self) -> CCDS_W<3> {
328 CCDS_W::new(self)
329 }
330 #[doc = "Bit 2 - Capture/compare control update selection"]
331 #[inline(always)]
332 pub fn ccus(&mut self) -> CCUS_W<2> {
333 CCUS_W::new(self)
334 }
335 #[doc = "Bit 0 - Capture/compare preloaded control"]
336 #[inline(always)]
337 pub fn ccpc(&mut self) -> CCPC_W<0> {
338 CCPC_W::new(self)
339 }
340 #[doc = "Writes raw bits to the register."]
341 #[inline(always)]
342 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
343 self.0.bits(bits);
344 self
345 }
346}
347#[doc = "control register 2\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 [cr2](index.html) module"]
348pub struct CR2_SPEC;
349impl crate::RegisterSpec for CR2_SPEC {
350 type Ux = u32;
351}
352#[doc = "`read()` method returns [cr2::R](R) reader structure"]
353impl crate::Readable for CR2_SPEC {
354 type Reader = R;
355}
356#[doc = "`write(|w| ..)` method takes [cr2::W](W) writer structure"]
357impl crate::Writable for CR2_SPEC {
358 type Writer = W;
359}
360#[doc = "`reset()` method sets CR2 to value 0"]
361impl crate::Resettable for CR2_SPEC {
362 #[inline(always)]
363 fn reset_value() -> Self::Ux {
364 0
365 }
366}