stm32f1/stm32f101/usb/
istr.rs

1#[doc = "Register `ISTR` reader"]
2pub struct R(crate::R<ISTR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ISTR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ISTR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ISTR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ISTR` writer"]
17pub struct W(crate::W<ISTR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ISTR_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<ISTR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ISTR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EP_ID` reader - Endpoint Identifier"]
38pub type EP_ID_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `EP_ID` writer - Endpoint Identifier"]
40pub type EP_ID_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, ISTR_SPEC, u8, u8, 4, O>;
41#[doc = "Direction of transaction\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43pub enum DIR_A {
44    #[doc = "0: data transmitted by the USB peripheral to the host PC"]
45    To = 0,
46    #[doc = "1: data received by the USB peripheral from the host PC"]
47    From = 1,
48}
49impl From<DIR_A> for bool {
50    #[inline(always)]
51    fn from(variant: DIR_A) -> Self {
52        variant as u8 != 0
53    }
54}
55#[doc = "Field `DIR` reader - Direction of transaction"]
56pub type DIR_R = crate::BitReader<DIR_A>;
57impl DIR_R {
58    #[doc = "Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> DIR_A {
61        match self.bits {
62            false => DIR_A::To,
63            true => DIR_A::From,
64        }
65    }
66    #[doc = "Checks if the value of the field is `To`"]
67    #[inline(always)]
68    pub fn is_to(&self) -> bool {
69        *self == DIR_A::To
70    }
71    #[doc = "Checks if the value of the field is `From`"]
72    #[inline(always)]
73    pub fn is_from(&self) -> bool {
74        *self == DIR_A::From
75    }
76}
77#[doc = "Field `DIR` writer - Direction of transaction"]
78pub type DIR_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, DIR_A, O>;
79impl<'a, const O: u8> DIR_W<'a, O> {
80    #[doc = "data transmitted by the USB peripheral to the host PC"]
81    #[inline(always)]
82    pub fn to(self) -> &'a mut W {
83        self.variant(DIR_A::To)
84    }
85    #[doc = "data received by the USB peripheral from the host PC"]
86    #[inline(always)]
87    pub fn from(self) -> &'a mut W {
88        self.variant(DIR_A::From)
89    }
90}
91#[doc = "Expected start frame\n\nValue on reset: 0"]
92#[derive(Clone, Copy, Debug, PartialEq)]
93pub enum ESOF_A {
94    #[doc = "1: an SOF packet is expected but not received"]
95    ExpectedStartOfFrame = 1,
96}
97impl From<ESOF_A> for bool {
98    #[inline(always)]
99    fn from(variant: ESOF_A) -> Self {
100        variant as u8 != 0
101    }
102}
103#[doc = "Field `ESOF` reader - Expected start frame"]
104pub type ESOF_R = crate::BitReader<ESOF_A>;
105impl ESOF_R {
106    #[doc = "Get enumerated values variant"]
107    #[inline(always)]
108    pub fn variant(&self) -> Option<ESOF_A> {
109        match self.bits {
110            true => Some(ESOF_A::ExpectedStartOfFrame),
111            _ => None,
112        }
113    }
114    #[doc = "Checks if the value of the field is `ExpectedStartOfFrame`"]
115    #[inline(always)]
116    pub fn is_expected_start_of_frame(&self) -> bool {
117        *self == ESOF_A::ExpectedStartOfFrame
118    }
119}
120#[doc = "Field `ESOF` writer - Expected start frame"]
121pub type ESOF_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, ESOF_A, O>;
122impl<'a, const O: u8> ESOF_W<'a, O> {
123    #[doc = "an SOF packet is expected but not received"]
124    #[inline(always)]
125    pub fn expected_start_of_frame(self) -> &'a mut W {
126        self.variant(ESOF_A::ExpectedStartOfFrame)
127    }
128}
129#[doc = "start of frame\n\nValue on reset: 0"]
130#[derive(Clone, Copy, Debug, PartialEq)]
131pub enum SOF_A {
132    #[doc = "1: beginning of a new USB frame and it is set when a SOF packet arrives through the USB bus"]
133    StartOfFrame = 1,
134}
135impl From<SOF_A> for bool {
136    #[inline(always)]
137    fn from(variant: SOF_A) -> Self {
138        variant as u8 != 0
139    }
140}
141#[doc = "Field `SOF` reader - start of frame"]
142pub type SOF_R = crate::BitReader<SOF_A>;
143impl SOF_R {
144    #[doc = "Get enumerated values variant"]
145    #[inline(always)]
146    pub fn variant(&self) -> Option<SOF_A> {
147        match self.bits {
148            true => Some(SOF_A::StartOfFrame),
149            _ => None,
150        }
151    }
152    #[doc = "Checks if the value of the field is `StartOfFrame`"]
153    #[inline(always)]
154    pub fn is_start_of_frame(&self) -> bool {
155        *self == SOF_A::StartOfFrame
156    }
157}
158#[doc = "Field `SOF` writer - start of frame"]
159pub type SOF_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, SOF_A, O>;
160impl<'a, const O: u8> SOF_W<'a, O> {
161    #[doc = "beginning of a new USB frame and it is set when a SOF packet arrives through the USB bus"]
162    #[inline(always)]
163    pub fn start_of_frame(self) -> &'a mut W {
164        self.variant(SOF_A::StartOfFrame)
165    }
166}
167#[doc = "reset request\n\nValue on reset: 0"]
168#[derive(Clone, Copy, Debug, PartialEq)]
169pub enum RESET_A {
170    #[doc = "1: peripheral detects an active USB RESET signal at its inputs"]
171    Reset = 1,
172}
173impl From<RESET_A> for bool {
174    #[inline(always)]
175    fn from(variant: RESET_A) -> Self {
176        variant as u8 != 0
177    }
178}
179#[doc = "Field `RESET` reader - reset request"]
180pub type RESET_R = crate::BitReader<RESET_A>;
181impl RESET_R {
182    #[doc = "Get enumerated values variant"]
183    #[inline(always)]
184    pub fn variant(&self) -> Option<RESET_A> {
185        match self.bits {
186            true => Some(RESET_A::Reset),
187            _ => None,
188        }
189    }
190    #[doc = "Checks if the value of the field is `Reset`"]
191    #[inline(always)]
192    pub fn is_reset(&self) -> bool {
193        *self == RESET_A::Reset
194    }
195}
196#[doc = "Field `RESET` writer - reset request"]
197pub type RESET_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, RESET_A, O>;
198impl<'a, const O: u8> RESET_W<'a, O> {
199    #[doc = "peripheral detects an active USB RESET signal at its inputs"]
200    #[inline(always)]
201    pub fn reset(self) -> &'a mut W {
202        self.variant(RESET_A::Reset)
203    }
204}
205#[doc = "Suspend mode request\n\nValue on reset: 0"]
206#[derive(Clone, Copy, Debug, PartialEq)]
207pub enum SUSP_A {
208    #[doc = "1: no traffic has been received for 3 ms, indicating a suspend mode request from the USB bus"]
209    Suspend = 1,
210}
211impl From<SUSP_A> for bool {
212    #[inline(always)]
213    fn from(variant: SUSP_A) -> Self {
214        variant as u8 != 0
215    }
216}
217#[doc = "Field `SUSP` reader - Suspend mode request"]
218pub type SUSP_R = crate::BitReader<SUSP_A>;
219impl SUSP_R {
220    #[doc = "Get enumerated values variant"]
221    #[inline(always)]
222    pub fn variant(&self) -> Option<SUSP_A> {
223        match self.bits {
224            true => Some(SUSP_A::Suspend),
225            _ => None,
226        }
227    }
228    #[doc = "Checks if the value of the field is `Suspend`"]
229    #[inline(always)]
230    pub fn is_suspend(&self) -> bool {
231        *self == SUSP_A::Suspend
232    }
233}
234#[doc = "Field `SUSP` writer - Suspend mode request"]
235pub type SUSP_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, SUSP_A, O>;
236impl<'a, const O: u8> SUSP_W<'a, O> {
237    #[doc = "no traffic has been received for 3 ms, indicating a suspend mode request from the USB bus"]
238    #[inline(always)]
239    pub fn suspend(self) -> &'a mut W {
240        self.variant(SUSP_A::Suspend)
241    }
242}
243#[doc = "Wakeup\n\nValue on reset: 0"]
244#[derive(Clone, Copy, Debug, PartialEq)]
245pub enum WKUP_A {
246    #[doc = "1: activity is detected that wakes up the USB peripheral"]
247    Wakeup = 1,
248}
249impl From<WKUP_A> for bool {
250    #[inline(always)]
251    fn from(variant: WKUP_A) -> Self {
252        variant as u8 != 0
253    }
254}
255#[doc = "Field `WKUP` reader - Wakeup"]
256pub type WKUP_R = crate::BitReader<WKUP_A>;
257impl WKUP_R {
258    #[doc = "Get enumerated values variant"]
259    #[inline(always)]
260    pub fn variant(&self) -> Option<WKUP_A> {
261        match self.bits {
262            true => Some(WKUP_A::Wakeup),
263            _ => None,
264        }
265    }
266    #[doc = "Checks if the value of the field is `Wakeup`"]
267    #[inline(always)]
268    pub fn is_wakeup(&self) -> bool {
269        *self == WKUP_A::Wakeup
270    }
271}
272#[doc = "Field `WKUP` writer - Wakeup"]
273pub type WKUP_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, WKUP_A, O>;
274impl<'a, const O: u8> WKUP_W<'a, O> {
275    #[doc = "activity is detected that wakes up the USB peripheral"]
276    #[inline(always)]
277    pub fn wakeup(self) -> &'a mut W {
278        self.variant(WKUP_A::Wakeup)
279    }
280}
281#[doc = "Error\n\nValue on reset: 0"]
282#[derive(Clone, Copy, Debug, PartialEq)]
283pub enum ERR_A {
284    #[doc = "1: One of No ANSwer, Cyclic Redundancy Check, Bit Stuffing or Framing format Violation error occurred"]
285    Error = 1,
286}
287impl From<ERR_A> for bool {
288    #[inline(always)]
289    fn from(variant: ERR_A) -> Self {
290        variant as u8 != 0
291    }
292}
293#[doc = "Field `ERR` reader - Error"]
294pub type ERR_R = crate::BitReader<ERR_A>;
295impl ERR_R {
296    #[doc = "Get enumerated values variant"]
297    #[inline(always)]
298    pub fn variant(&self) -> Option<ERR_A> {
299        match self.bits {
300            true => Some(ERR_A::Error),
301            _ => None,
302        }
303    }
304    #[doc = "Checks if the value of the field is `Error`"]
305    #[inline(always)]
306    pub fn is_error(&self) -> bool {
307        *self == ERR_A::Error
308    }
309}
310#[doc = "Field `ERR` writer - Error"]
311pub type ERR_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, ERR_A, O>;
312impl<'a, const O: u8> ERR_W<'a, O> {
313    #[doc = "One of No ANSwer, Cyclic Redundancy Check, Bit Stuffing or Framing format Violation error occurred"]
314    #[inline(always)]
315    pub fn error(self) -> &'a mut W {
316        self.variant(ERR_A::Error)
317    }
318}
319#[doc = "Packet memory area over / underrun\n\nValue on reset: 0"]
320#[derive(Clone, Copy, Debug, PartialEq)]
321pub enum PMAOVR_A {
322    #[doc = "1: microcontroller has not been able to respond in time to an USB memory request"]
323    Overrun = 1,
324}
325impl From<PMAOVR_A> for bool {
326    #[inline(always)]
327    fn from(variant: PMAOVR_A) -> Self {
328        variant as u8 != 0
329    }
330}
331#[doc = "Field `PMAOVR` reader - Packet memory area over / underrun"]
332pub type PMAOVR_R = crate::BitReader<PMAOVR_A>;
333impl PMAOVR_R {
334    #[doc = "Get enumerated values variant"]
335    #[inline(always)]
336    pub fn variant(&self) -> Option<PMAOVR_A> {
337        match self.bits {
338            true => Some(PMAOVR_A::Overrun),
339            _ => None,
340        }
341    }
342    #[doc = "Checks if the value of the field is `Overrun`"]
343    #[inline(always)]
344    pub fn is_overrun(&self) -> bool {
345        *self == PMAOVR_A::Overrun
346    }
347}
348#[doc = "Field `PMAOVR` writer - Packet memory area over / underrun"]
349pub type PMAOVR_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, PMAOVR_A, O>;
350impl<'a, const O: u8> PMAOVR_W<'a, O> {
351    #[doc = "microcontroller has not been able to respond in time to an USB memory request"]
352    #[inline(always)]
353    pub fn overrun(self) -> &'a mut W {
354        self.variant(PMAOVR_A::Overrun)
355    }
356}
357#[doc = "Correct transfer\n\nValue on reset: 0"]
358#[derive(Clone, Copy, Debug, PartialEq)]
359pub enum CTR_A {
360    #[doc = "1: endpoint has successfully completed a transaction"]
361    Completed = 1,
362}
363impl From<CTR_A> for bool {
364    #[inline(always)]
365    fn from(variant: CTR_A) -> Self {
366        variant as u8 != 0
367    }
368}
369#[doc = "Field `CTR` reader - Correct transfer"]
370pub type CTR_R = crate::BitReader<CTR_A>;
371impl CTR_R {
372    #[doc = "Get enumerated values variant"]
373    #[inline(always)]
374    pub fn variant(&self) -> Option<CTR_A> {
375        match self.bits {
376            true => Some(CTR_A::Completed),
377            _ => None,
378        }
379    }
380    #[doc = "Checks if the value of the field is `Completed`"]
381    #[inline(always)]
382    pub fn is_completed(&self) -> bool {
383        *self == CTR_A::Completed
384    }
385}
386#[doc = "Field `CTR` writer - Correct transfer"]
387pub type CTR_W<'a, const O: u8> = crate::BitWriter<'a, u32, ISTR_SPEC, CTR_A, O>;
388impl<'a, const O: u8> CTR_W<'a, O> {
389    #[doc = "endpoint has successfully completed a transaction"]
390    #[inline(always)]
391    pub fn completed(self) -> &'a mut W {
392        self.variant(CTR_A::Completed)
393    }
394}
395impl R {
396    #[doc = "Bits 0:3 - Endpoint Identifier"]
397    #[inline(always)]
398    pub fn ep_id(&self) -> EP_ID_R {
399        EP_ID_R::new((self.bits & 0x0f) as u8)
400    }
401    #[doc = "Bit 4 - Direction of transaction"]
402    #[inline(always)]
403    pub fn dir(&self) -> DIR_R {
404        DIR_R::new(((self.bits >> 4) & 1) != 0)
405    }
406    #[doc = "Bit 8 - Expected start frame"]
407    #[inline(always)]
408    pub fn esof(&self) -> ESOF_R {
409        ESOF_R::new(((self.bits >> 8) & 1) != 0)
410    }
411    #[doc = "Bit 9 - start of frame"]
412    #[inline(always)]
413    pub fn sof(&self) -> SOF_R {
414        SOF_R::new(((self.bits >> 9) & 1) != 0)
415    }
416    #[doc = "Bit 10 - reset request"]
417    #[inline(always)]
418    pub fn reset(&self) -> RESET_R {
419        RESET_R::new(((self.bits >> 10) & 1) != 0)
420    }
421    #[doc = "Bit 11 - Suspend mode request"]
422    #[inline(always)]
423    pub fn susp(&self) -> SUSP_R {
424        SUSP_R::new(((self.bits >> 11) & 1) != 0)
425    }
426    #[doc = "Bit 12 - Wakeup"]
427    #[inline(always)]
428    pub fn wkup(&self) -> WKUP_R {
429        WKUP_R::new(((self.bits >> 12) & 1) != 0)
430    }
431    #[doc = "Bit 13 - Error"]
432    #[inline(always)]
433    pub fn err(&self) -> ERR_R {
434        ERR_R::new(((self.bits >> 13) & 1) != 0)
435    }
436    #[doc = "Bit 14 - Packet memory area over / underrun"]
437    #[inline(always)]
438    pub fn pmaovr(&self) -> PMAOVR_R {
439        PMAOVR_R::new(((self.bits >> 14) & 1) != 0)
440    }
441    #[doc = "Bit 15 - Correct transfer"]
442    #[inline(always)]
443    pub fn ctr(&self) -> CTR_R {
444        CTR_R::new(((self.bits >> 15) & 1) != 0)
445    }
446}
447impl W {
448    #[doc = "Bits 0:3 - Endpoint Identifier"]
449    #[inline(always)]
450    pub fn ep_id(&mut self) -> EP_ID_W<0> {
451        EP_ID_W::new(self)
452    }
453    #[doc = "Bit 4 - Direction of transaction"]
454    #[inline(always)]
455    pub fn dir(&mut self) -> DIR_W<4> {
456        DIR_W::new(self)
457    }
458    #[doc = "Bit 8 - Expected start frame"]
459    #[inline(always)]
460    pub fn esof(&mut self) -> ESOF_W<8> {
461        ESOF_W::new(self)
462    }
463    #[doc = "Bit 9 - start of frame"]
464    #[inline(always)]
465    pub fn sof(&mut self) -> SOF_W<9> {
466        SOF_W::new(self)
467    }
468    #[doc = "Bit 10 - reset request"]
469    #[inline(always)]
470    pub fn reset(&mut self) -> RESET_W<10> {
471        RESET_W::new(self)
472    }
473    #[doc = "Bit 11 - Suspend mode request"]
474    #[inline(always)]
475    pub fn susp(&mut self) -> SUSP_W<11> {
476        SUSP_W::new(self)
477    }
478    #[doc = "Bit 12 - Wakeup"]
479    #[inline(always)]
480    pub fn wkup(&mut self) -> WKUP_W<12> {
481        WKUP_W::new(self)
482    }
483    #[doc = "Bit 13 - Error"]
484    #[inline(always)]
485    pub fn err(&mut self) -> ERR_W<13> {
486        ERR_W::new(self)
487    }
488    #[doc = "Bit 14 - Packet memory area over / underrun"]
489    #[inline(always)]
490    pub fn pmaovr(&mut self) -> PMAOVR_W<14> {
491        PMAOVR_W::new(self)
492    }
493    #[doc = "Bit 15 - Correct transfer"]
494    #[inline(always)]
495    pub fn ctr(&mut self) -> CTR_W<15> {
496        CTR_W::new(self)
497    }
498    #[doc = "Writes raw bits to the register."]
499    #[inline(always)]
500    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
501        self.0.bits(bits);
502        self
503    }
504}
505#[doc = "interrupt status register\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 [istr](index.html) module"]
506pub struct ISTR_SPEC;
507impl crate::RegisterSpec for ISTR_SPEC {
508    type Ux = u32;
509}
510#[doc = "`read()` method returns [istr::R](R) reader structure"]
511impl crate::Readable for ISTR_SPEC {
512    type Reader = R;
513}
514#[doc = "`write(|w| ..)` method takes [istr::W](W) writer structure"]
515impl crate::Writable for ISTR_SPEC {
516    type Writer = W;
517}
518#[doc = "`reset()` method sets ISTR to value 0"]
519impl crate::Resettable for ISTR_SPEC {
520    #[inline(always)]
521    fn reset_value() -> Self::Ux {
522        0
523    }
524}