stm32f0/stm32f0x1/usb/
fnr.rs

1///Register `FNR` reader
2pub type R = crate::R<FNRrs>;
3///Field `FN` reader - Frame number
4pub type FN_R = crate::FieldReader<u16>;
5///Field `LSOF` reader - Lost SOF
6pub type LSOF_R = crate::FieldReader;
7/**Locked
8
9Value on reset: 0*/
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum LCK {
13    ///1: the frame timer remains in this state until an USB reset or USB suspend event occurs
14    Locked = 1,
15}
16impl From<LCK> for bool {
17    #[inline(always)]
18    fn from(variant: LCK) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `LCK` reader - Locked
23pub type LCK_R = crate::BitReader<LCK>;
24impl LCK_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> Option<LCK> {
28        match self.bits {
29            true => Some(LCK::Locked),
30            _ => None,
31        }
32    }
33    ///the frame timer remains in this state until an USB reset or USB suspend event occurs
34    #[inline(always)]
35    pub fn is_locked(&self) -> bool {
36        *self == LCK::Locked
37    }
38}
39/**Receive data - line status
40
41Value on reset: 0*/
42#[cfg_attr(feature = "defmt", derive(defmt::Format))]
43#[derive(Clone, Copy, Debug, PartialEq, Eq)]
44pub enum RXDM {
45    ///1: received data minus upstream port data line
46    Received = 1,
47}
48impl From<RXDM> for bool {
49    #[inline(always)]
50    fn from(variant: RXDM) -> Self {
51        variant as u8 != 0
52    }
53}
54///Field `RXDM` reader - Receive data - line status
55pub type RXDM_R = crate::BitReader<RXDM>;
56impl RXDM_R {
57    ///Get enumerated values variant
58    #[inline(always)]
59    pub const fn variant(&self) -> Option<RXDM> {
60        match self.bits {
61            true => Some(RXDM::Received),
62            _ => None,
63        }
64    }
65    ///received data minus upstream port data line
66    #[inline(always)]
67    pub fn is_received(&self) -> bool {
68        *self == RXDM::Received
69    }
70}
71/**Receive data + line status
72
73Value on reset: 0*/
74#[cfg_attr(feature = "defmt", derive(defmt::Format))]
75#[derive(Clone, Copy, Debug, PartialEq, Eq)]
76pub enum RXDP {
77    ///1: received data plus upstream port data line
78    Received = 1,
79}
80impl From<RXDP> for bool {
81    #[inline(always)]
82    fn from(variant: RXDP) -> Self {
83        variant as u8 != 0
84    }
85}
86///Field `RXDP` reader - Receive data + line status
87pub type RXDP_R = crate::BitReader<RXDP>;
88impl RXDP_R {
89    ///Get enumerated values variant
90    #[inline(always)]
91    pub const fn variant(&self) -> Option<RXDP> {
92        match self.bits {
93            true => Some(RXDP::Received),
94            _ => None,
95        }
96    }
97    ///received data plus upstream port data line
98    #[inline(always)]
99    pub fn is_received(&self) -> bool {
100        *self == RXDP::Received
101    }
102}
103impl R {
104    ///Bits 0:10 - Frame number
105    #[inline(always)]
106    pub fn fn_(&self) -> FN_R {
107        FN_R::new((self.bits & 0x07ff) as u16)
108    }
109    ///Bits 11:12 - Lost SOF
110    #[inline(always)]
111    pub fn lsof(&self) -> LSOF_R {
112        LSOF_R::new(((self.bits >> 11) & 3) as u8)
113    }
114    ///Bit 13 - Locked
115    #[inline(always)]
116    pub fn lck(&self) -> LCK_R {
117        LCK_R::new(((self.bits >> 13) & 1) != 0)
118    }
119    ///Bit 14 - Receive data - line status
120    #[inline(always)]
121    pub fn rxdm(&self) -> RXDM_R {
122        RXDM_R::new(((self.bits >> 14) & 1) != 0)
123    }
124    ///Bit 15 - Receive data + line status
125    #[inline(always)]
126    pub fn rxdp(&self) -> RXDP_R {
127        RXDP_R::new(((self.bits >> 15) & 1) != 0)
128    }
129}
130impl core::fmt::Debug for R {
131    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
132        f.debug_struct("FNR")
133            .field("fn_", &self.fn_())
134            .field("lsof", &self.lsof())
135            .field("lck", &self.lck())
136            .field("rxdm", &self.rxdm())
137            .field("rxdp", &self.rxdp())
138            .finish()
139    }
140}
141/**frame number register
142
143You can [`read`](crate::Reg::read) this register and get [`fnr::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
144
145See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F0x1.html#USB:FNR)*/
146pub struct FNRrs;
147impl crate::RegisterSpec for FNRrs {
148    type Ux = u32;
149}
150///`read()` method returns [`fnr::R`](R) reader structure
151impl crate::Readable for FNRrs {}
152///`reset()` method sets FNR to value 0
153impl crate::Resettable for FNRrs {}