stm32f3_staging/stm32f373/usb/
istr.rs

1///Register `ISTR` reader
2pub type R = crate::R<ISTRrs>;
3///Register `ISTR` writer
4pub type W = crate::W<ISTRrs>;
5///Field `EP_ID` reader - Endpoint Identifier
6pub type EP_ID_R = crate::FieldReader;
7/**Direction of transaction
8
9Value on reset: 0*/
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum DIR {
13    ///0: data transmitted by the USB peripheral to the host PC
14    To = 0,
15    ///1: data received by the USB peripheral from the host PC
16    From = 1,
17}
18impl From<DIR> for bool {
19    #[inline(always)]
20    fn from(variant: DIR) -> Self {
21        variant as u8 != 0
22    }
23}
24///Field `DIR` reader - Direction of transaction
25pub type DIR_R = crate::BitReader<DIR>;
26impl DIR_R {
27    ///Get enumerated values variant
28    #[inline(always)]
29    pub const fn variant(&self) -> DIR {
30        match self.bits {
31            false => DIR::To,
32            true => DIR::From,
33        }
34    }
35    ///data transmitted by the USB peripheral to the host PC
36    #[inline(always)]
37    pub fn is_to(&self) -> bool {
38        *self == DIR::To
39    }
40    ///data received by the USB peripheral from the host PC
41    #[inline(always)]
42    pub fn is_from(&self) -> bool {
43        *self == DIR::From
44    }
45}
46/**Expected start frame
47
48Value on reset: 0*/
49#[cfg_attr(feature = "defmt", derive(defmt::Format))]
50#[derive(Clone, Copy, Debug, PartialEq, Eq)]
51pub enum ESOFR {
52    ///0: NotExpectedStartOfFrame
53    NotExpectedStartOfFrame = 0,
54    ///1: an SOF packet is expected but not received
55    ExpectedStartOfFrame = 1,
56}
57impl From<ESOFR> for bool {
58    #[inline(always)]
59    fn from(variant: ESOFR) -> Self {
60        variant as u8 != 0
61    }
62}
63///Field `ESOF` reader - Expected start frame
64pub type ESOF_R = crate::BitReader<ESOFR>;
65impl ESOF_R {
66    ///Get enumerated values variant
67    #[inline(always)]
68    pub const fn variant(&self) -> ESOFR {
69        match self.bits {
70            false => ESOFR::NotExpectedStartOfFrame,
71            true => ESOFR::ExpectedStartOfFrame,
72        }
73    }
74    ///NotExpectedStartOfFrame
75    #[inline(always)]
76    pub fn is_not_expected_start_of_frame(&self) -> bool {
77        *self == ESOFR::NotExpectedStartOfFrame
78    }
79    ///an SOF packet is expected but not received
80    #[inline(always)]
81    pub fn is_expected_start_of_frame(&self) -> bool {
82        *self == ESOFR::ExpectedStartOfFrame
83    }
84}
85/**Expected start frame
86
87Value on reset: 0*/
88#[cfg_attr(feature = "defmt", derive(defmt::Format))]
89#[derive(Clone, Copy, Debug, PartialEq, Eq)]
90pub enum ESOFW {
91    ///0: Clear flag
92    Clear = 0,
93}
94impl From<ESOFW> for bool {
95    #[inline(always)]
96    fn from(variant: ESOFW) -> Self {
97        variant as u8 != 0
98    }
99}
100///Field `ESOF` writer - Expected start frame
101pub type ESOF_W<'a, REG> = crate::BitWriter0C<'a, REG, ESOFW>;
102impl<'a, REG> ESOF_W<'a, REG>
103where
104    REG: crate::Writable + crate::RegisterSpec,
105{
106    ///Clear flag
107    #[inline(always)]
108    pub fn clear(self) -> &'a mut crate::W<REG> {
109        self.variant(ESOFW::Clear)
110    }
111}
112/**start of frame
113
114Value on reset: 0*/
115#[cfg_attr(feature = "defmt", derive(defmt::Format))]
116#[derive(Clone, Copy, Debug, PartialEq, Eq)]
117pub enum SOFR {
118    ///0: NotStartOfFrame
119    NotStartOfFrame = 0,
120    ///1: beginning of a new USB frame and it is set when a SOF packet arrives through the USB bus
121    StartOfFrame = 1,
122}
123impl From<SOFR> for bool {
124    #[inline(always)]
125    fn from(variant: SOFR) -> Self {
126        variant as u8 != 0
127    }
128}
129///Field `SOF` reader - start of frame
130pub type SOF_R = crate::BitReader<SOFR>;
131impl SOF_R {
132    ///Get enumerated values variant
133    #[inline(always)]
134    pub const fn variant(&self) -> SOFR {
135        match self.bits {
136            false => SOFR::NotStartOfFrame,
137            true => SOFR::StartOfFrame,
138        }
139    }
140    ///NotStartOfFrame
141    #[inline(always)]
142    pub fn is_not_start_of_frame(&self) -> bool {
143        *self == SOFR::NotStartOfFrame
144    }
145    ///beginning of a new USB frame and it is set when a SOF packet arrives through the USB bus
146    #[inline(always)]
147    pub fn is_start_of_frame(&self) -> bool {
148        *self == SOFR::StartOfFrame
149    }
150}
151/**start of frame
152
153Value on reset: 0*/
154#[cfg_attr(feature = "defmt", derive(defmt::Format))]
155#[derive(Clone, Copy, Debug, PartialEq, Eq)]
156pub enum SOFW {
157    ///0: Clear flag
158    Clear = 0,
159}
160impl From<SOFW> for bool {
161    #[inline(always)]
162    fn from(variant: SOFW) -> Self {
163        variant as u8 != 0
164    }
165}
166///Field `SOF` writer - start of frame
167pub type SOF_W<'a, REG> = crate::BitWriter0C<'a, REG, SOFW>;
168impl<'a, REG> SOF_W<'a, REG>
169where
170    REG: crate::Writable + crate::RegisterSpec,
171{
172    ///Clear flag
173    #[inline(always)]
174    pub fn clear(self) -> &'a mut crate::W<REG> {
175        self.variant(SOFW::Clear)
176    }
177}
178/**reset request
179
180Value on reset: 0*/
181#[cfg_attr(feature = "defmt", derive(defmt::Format))]
182#[derive(Clone, Copy, Debug, PartialEq, Eq)]
183pub enum RESETR {
184    ///0: NotReset
185    NotReset = 0,
186    ///1: peripheral detects an active USB RESET signal at its inputs
187    Reset = 1,
188}
189impl From<RESETR> for bool {
190    #[inline(always)]
191    fn from(variant: RESETR) -> Self {
192        variant as u8 != 0
193    }
194}
195///Field `RESET` reader - reset request
196pub type RESET_R = crate::BitReader<RESETR>;
197impl RESET_R {
198    ///Get enumerated values variant
199    #[inline(always)]
200    pub const fn variant(&self) -> RESETR {
201        match self.bits {
202            false => RESETR::NotReset,
203            true => RESETR::Reset,
204        }
205    }
206    ///NotReset
207    #[inline(always)]
208    pub fn is_not_reset(&self) -> bool {
209        *self == RESETR::NotReset
210    }
211    ///peripheral detects an active USB RESET signal at its inputs
212    #[inline(always)]
213    pub fn is_reset(&self) -> bool {
214        *self == RESETR::Reset
215    }
216}
217/**reset request
218
219Value on reset: 0*/
220#[cfg_attr(feature = "defmt", derive(defmt::Format))]
221#[derive(Clone, Copy, Debug, PartialEq, Eq)]
222pub enum RESETW {
223    ///0: Clear flag
224    Clear = 0,
225}
226impl From<RESETW> for bool {
227    #[inline(always)]
228    fn from(variant: RESETW) -> Self {
229        variant as u8 != 0
230    }
231}
232///Field `RESET` writer - reset request
233pub type RESET_W<'a, REG> = crate::BitWriter0C<'a, REG, RESETW>;
234impl<'a, REG> RESET_W<'a, REG>
235where
236    REG: crate::Writable + crate::RegisterSpec,
237{
238    ///Clear flag
239    #[inline(always)]
240    pub fn clear(self) -> &'a mut crate::W<REG> {
241        self.variant(RESETW::Clear)
242    }
243}
244/**Suspend mode request
245
246Value on reset: 0*/
247#[cfg_attr(feature = "defmt", derive(defmt::Format))]
248#[derive(Clone, Copy, Debug, PartialEq, Eq)]
249pub enum SUSPR {
250    ///0: NotSuspend
251    NotSuspend = 0,
252    ///1: no traffic has been received for 3 ms, indicating a suspend mode request from the USB bus
253    Suspend = 1,
254}
255impl From<SUSPR> for bool {
256    #[inline(always)]
257    fn from(variant: SUSPR) -> Self {
258        variant as u8 != 0
259    }
260}
261///Field `SUSP` reader - Suspend mode request
262pub type SUSP_R = crate::BitReader<SUSPR>;
263impl SUSP_R {
264    ///Get enumerated values variant
265    #[inline(always)]
266    pub const fn variant(&self) -> SUSPR {
267        match self.bits {
268            false => SUSPR::NotSuspend,
269            true => SUSPR::Suspend,
270        }
271    }
272    ///NotSuspend
273    #[inline(always)]
274    pub fn is_not_suspend(&self) -> bool {
275        *self == SUSPR::NotSuspend
276    }
277    ///no traffic has been received for 3 ms, indicating a suspend mode request from the USB bus
278    #[inline(always)]
279    pub fn is_suspend(&self) -> bool {
280        *self == SUSPR::Suspend
281    }
282}
283/**Suspend mode request
284
285Value on reset: 0*/
286#[cfg_attr(feature = "defmt", derive(defmt::Format))]
287#[derive(Clone, Copy, Debug, PartialEq, Eq)]
288pub enum SUSPW {
289    ///0: Clear flag
290    Clear = 0,
291}
292impl From<SUSPW> for bool {
293    #[inline(always)]
294    fn from(variant: SUSPW) -> Self {
295        variant as u8 != 0
296    }
297}
298///Field `SUSP` writer - Suspend mode request
299pub type SUSP_W<'a, REG> = crate::BitWriter0C<'a, REG, SUSPW>;
300impl<'a, REG> SUSP_W<'a, REG>
301where
302    REG: crate::Writable + crate::RegisterSpec,
303{
304    ///Clear flag
305    #[inline(always)]
306    pub fn clear(self) -> &'a mut crate::W<REG> {
307        self.variant(SUSPW::Clear)
308    }
309}
310/**Wakeup
311
312Value on reset: 0*/
313#[cfg_attr(feature = "defmt", derive(defmt::Format))]
314#[derive(Clone, Copy, Debug, PartialEq, Eq)]
315pub enum WKUPR {
316    ///0: NotWakeup
317    NotWakeup = 0,
318    ///1: activity is detected that wakes up the USB peripheral
319    Wakeup = 1,
320}
321impl From<WKUPR> for bool {
322    #[inline(always)]
323    fn from(variant: WKUPR) -> Self {
324        variant as u8 != 0
325    }
326}
327///Field `WKUP` reader - Wakeup
328pub type WKUP_R = crate::BitReader<WKUPR>;
329impl WKUP_R {
330    ///Get enumerated values variant
331    #[inline(always)]
332    pub const fn variant(&self) -> WKUPR {
333        match self.bits {
334            false => WKUPR::NotWakeup,
335            true => WKUPR::Wakeup,
336        }
337    }
338    ///NotWakeup
339    #[inline(always)]
340    pub fn is_not_wakeup(&self) -> bool {
341        *self == WKUPR::NotWakeup
342    }
343    ///activity is detected that wakes up the USB peripheral
344    #[inline(always)]
345    pub fn is_wakeup(&self) -> bool {
346        *self == WKUPR::Wakeup
347    }
348}
349/**Wakeup
350
351Value on reset: 0*/
352#[cfg_attr(feature = "defmt", derive(defmt::Format))]
353#[derive(Clone, Copy, Debug, PartialEq, Eq)]
354pub enum WKUPW {
355    ///0: Clear flag
356    Clear = 0,
357}
358impl From<WKUPW> for bool {
359    #[inline(always)]
360    fn from(variant: WKUPW) -> Self {
361        variant as u8 != 0
362    }
363}
364///Field `WKUP` writer - Wakeup
365pub type WKUP_W<'a, REG> = crate::BitWriter0C<'a, REG, WKUPW>;
366impl<'a, REG> WKUP_W<'a, REG>
367where
368    REG: crate::Writable + crate::RegisterSpec,
369{
370    ///Clear flag
371    #[inline(always)]
372    pub fn clear(self) -> &'a mut crate::W<REG> {
373        self.variant(WKUPW::Clear)
374    }
375}
376/**Error
377
378Value on reset: 0*/
379#[cfg_attr(feature = "defmt", derive(defmt::Format))]
380#[derive(Clone, Copy, Debug, PartialEq, Eq)]
381pub enum ERRR {
382    ///0: Errors are not occurred
383    NotOverrun = 0,
384    ///1: One of No ANSwer, Cyclic Redundancy Check, Bit Stuffing or Framing format Violation error occurred
385    Error = 1,
386}
387impl From<ERRR> for bool {
388    #[inline(always)]
389    fn from(variant: ERRR) -> Self {
390        variant as u8 != 0
391    }
392}
393///Field `ERR` reader - Error
394pub type ERR_R = crate::BitReader<ERRR>;
395impl ERR_R {
396    ///Get enumerated values variant
397    #[inline(always)]
398    pub const fn variant(&self) -> ERRR {
399        match self.bits {
400            false => ERRR::NotOverrun,
401            true => ERRR::Error,
402        }
403    }
404    ///Errors are not occurred
405    #[inline(always)]
406    pub fn is_not_overrun(&self) -> bool {
407        *self == ERRR::NotOverrun
408    }
409    ///One of No ANSwer, Cyclic Redundancy Check, Bit Stuffing or Framing format Violation error occurred
410    #[inline(always)]
411    pub fn is_error(&self) -> bool {
412        *self == ERRR::Error
413    }
414}
415/**Error
416
417Value on reset: 0*/
418#[cfg_attr(feature = "defmt", derive(defmt::Format))]
419#[derive(Clone, Copy, Debug, PartialEq, Eq)]
420pub enum ERRW {
421    ///0: Clear flag
422    Clear = 0,
423}
424impl From<ERRW> for bool {
425    #[inline(always)]
426    fn from(variant: ERRW) -> Self {
427        variant as u8 != 0
428    }
429}
430///Field `ERR` writer - Error
431pub type ERR_W<'a, REG> = crate::BitWriter0C<'a, REG, ERRW>;
432impl<'a, REG> ERR_W<'a, REG>
433where
434    REG: crate::Writable + crate::RegisterSpec,
435{
436    ///Clear flag
437    #[inline(always)]
438    pub fn clear(self) -> &'a mut crate::W<REG> {
439        self.variant(ERRW::Clear)
440    }
441}
442/**Packet memory area over / underrun
443
444Value on reset: 0*/
445#[cfg_attr(feature = "defmt", derive(defmt::Format))]
446#[derive(Clone, Copy, Debug, PartialEq, Eq)]
447pub enum PMAOVRR {
448    ///0: Overrun is not occurred
449    NotOverrun = 0,
450    ///1: microcontroller has not been able to respond in time to an USB memory request
451    Overrun = 1,
452}
453impl From<PMAOVRR> for bool {
454    #[inline(always)]
455    fn from(variant: PMAOVRR) -> Self {
456        variant as u8 != 0
457    }
458}
459///Field `PMAOVR` reader - Packet memory area over / underrun
460pub type PMAOVR_R = crate::BitReader<PMAOVRR>;
461impl PMAOVR_R {
462    ///Get enumerated values variant
463    #[inline(always)]
464    pub const fn variant(&self) -> PMAOVRR {
465        match self.bits {
466            false => PMAOVRR::NotOverrun,
467            true => PMAOVRR::Overrun,
468        }
469    }
470    ///Overrun is not occurred
471    #[inline(always)]
472    pub fn is_not_overrun(&self) -> bool {
473        *self == PMAOVRR::NotOverrun
474    }
475    ///microcontroller has not been able to respond in time to an USB memory request
476    #[inline(always)]
477    pub fn is_overrun(&self) -> bool {
478        *self == PMAOVRR::Overrun
479    }
480}
481/**Packet memory area over / underrun
482
483Value on reset: 0*/
484#[cfg_attr(feature = "defmt", derive(defmt::Format))]
485#[derive(Clone, Copy, Debug, PartialEq, Eq)]
486pub enum PMAOVRW {
487    ///0: Clear flag
488    Clear = 0,
489}
490impl From<PMAOVRW> for bool {
491    #[inline(always)]
492    fn from(variant: PMAOVRW) -> Self {
493        variant as u8 != 0
494    }
495}
496///Field `PMAOVR` writer - Packet memory area over / underrun
497pub type PMAOVR_W<'a, REG> = crate::BitWriter0C<'a, REG, PMAOVRW>;
498impl<'a, REG> PMAOVR_W<'a, REG>
499where
500    REG: crate::Writable + crate::RegisterSpec,
501{
502    ///Clear flag
503    #[inline(always)]
504    pub fn clear(self) -> &'a mut crate::W<REG> {
505        self.variant(PMAOVRW::Clear)
506    }
507}
508/**Correct transfer
509
510Value on reset: 0*/
511#[cfg_attr(feature = "defmt", derive(defmt::Format))]
512#[derive(Clone, Copy, Debug, PartialEq, Eq)]
513pub enum CTR {
514    ///1: endpoint has successfully completed a transaction
515    Completed = 1,
516}
517impl From<CTR> for bool {
518    #[inline(always)]
519    fn from(variant: CTR) -> Self {
520        variant as u8 != 0
521    }
522}
523///Field `CTR` reader - Correct transfer
524pub type CTR_R = crate::BitReader<CTR>;
525impl CTR_R {
526    ///Get enumerated values variant
527    #[inline(always)]
528    pub const fn variant(&self) -> Option<CTR> {
529        match self.bits {
530            true => Some(CTR::Completed),
531            _ => None,
532        }
533    }
534    ///endpoint has successfully completed a transaction
535    #[inline(always)]
536    pub fn is_completed(&self) -> bool {
537        *self == CTR::Completed
538    }
539}
540impl R {
541    ///Bits 0:3 - Endpoint Identifier
542    #[inline(always)]
543    pub fn ep_id(&self) -> EP_ID_R {
544        EP_ID_R::new((self.bits & 0x0f) as u8)
545    }
546    ///Bit 4 - Direction of transaction
547    #[inline(always)]
548    pub fn dir(&self) -> DIR_R {
549        DIR_R::new(((self.bits >> 4) & 1) != 0)
550    }
551    ///Bit 8 - Expected start frame
552    #[inline(always)]
553    pub fn esof(&self) -> ESOF_R {
554        ESOF_R::new(((self.bits >> 8) & 1) != 0)
555    }
556    ///Bit 9 - start of frame
557    #[inline(always)]
558    pub fn sof(&self) -> SOF_R {
559        SOF_R::new(((self.bits >> 9) & 1) != 0)
560    }
561    ///Bit 10 - reset request
562    #[inline(always)]
563    pub fn reset(&self) -> RESET_R {
564        RESET_R::new(((self.bits >> 10) & 1) != 0)
565    }
566    ///Bit 11 - Suspend mode request
567    #[inline(always)]
568    pub fn susp(&self) -> SUSP_R {
569        SUSP_R::new(((self.bits >> 11) & 1) != 0)
570    }
571    ///Bit 12 - Wakeup
572    #[inline(always)]
573    pub fn wkup(&self) -> WKUP_R {
574        WKUP_R::new(((self.bits >> 12) & 1) != 0)
575    }
576    ///Bit 13 - Error
577    #[inline(always)]
578    pub fn err(&self) -> ERR_R {
579        ERR_R::new(((self.bits >> 13) & 1) != 0)
580    }
581    ///Bit 14 - Packet memory area over / underrun
582    #[inline(always)]
583    pub fn pmaovr(&self) -> PMAOVR_R {
584        PMAOVR_R::new(((self.bits >> 14) & 1) != 0)
585    }
586    ///Bit 15 - Correct transfer
587    #[inline(always)]
588    pub fn ctr(&self) -> CTR_R {
589        CTR_R::new(((self.bits >> 15) & 1) != 0)
590    }
591}
592impl core::fmt::Debug for R {
593    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
594        f.debug_struct("ISTR")
595            .field("ep_id", &self.ep_id())
596            .field("dir", &self.dir())
597            .field("esof", &self.esof())
598            .field("sof", &self.sof())
599            .field("reset", &self.reset())
600            .field("susp", &self.susp())
601            .field("wkup", &self.wkup())
602            .field("err", &self.err())
603            .field("pmaovr", &self.pmaovr())
604            .field("ctr", &self.ctr())
605            .finish()
606    }
607}
608impl W {
609    ///Bit 8 - Expected start frame
610    #[inline(always)]
611    pub fn esof(&mut self) -> ESOF_W<ISTRrs> {
612        ESOF_W::new(self, 8)
613    }
614    ///Bit 9 - start of frame
615    #[inline(always)]
616    pub fn sof(&mut self) -> SOF_W<ISTRrs> {
617        SOF_W::new(self, 9)
618    }
619    ///Bit 10 - reset request
620    #[inline(always)]
621    pub fn reset(&mut self) -> RESET_W<ISTRrs> {
622        RESET_W::new(self, 10)
623    }
624    ///Bit 11 - Suspend mode request
625    #[inline(always)]
626    pub fn susp(&mut self) -> SUSP_W<ISTRrs> {
627        SUSP_W::new(self, 11)
628    }
629    ///Bit 12 - Wakeup
630    #[inline(always)]
631    pub fn wkup(&mut self) -> WKUP_W<ISTRrs> {
632        WKUP_W::new(self, 12)
633    }
634    ///Bit 13 - Error
635    #[inline(always)]
636    pub fn err(&mut self) -> ERR_W<ISTRrs> {
637        ERR_W::new(self, 13)
638    }
639    ///Bit 14 - Packet memory area over / underrun
640    #[inline(always)]
641    pub fn pmaovr(&mut self) -> PMAOVR_W<ISTRrs> {
642        PMAOVR_W::new(self, 14)
643    }
644}
645/**interrupt status register
646
647You can [`read`](crate::Reg::read) this register and get [`istr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`istr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
648
649See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F373.html#USB:ISTR)*/
650pub struct ISTRrs;
651impl crate::RegisterSpec for ISTRrs {
652    type Ux = u32;
653}
654///`read()` method returns [`istr::R`](R) reader structure
655impl crate::Readable for ISTRrs {}
656///`write(|w| ..)` method takes [`istr::W`](W) writer structure
657impl crate::Writable for ISTRrs {
658    type Safety = crate::Unsafe;
659    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0x7f00;
660    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
661}
662///`reset()` method sets ISTR to value 0
663impl crate::Resettable for ISTRrs {
664    const RESET_VALUE: u32 = 0;
665}