nrf52840_pac/usbd/
bmrequesttype.rs

1#[doc = "Register `BMREQUESTTYPE` reader"]
2pub struct R(crate::R<BMREQUESTTYPE_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<BMREQUESTTYPE_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<BMREQUESTTYPE_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<BMREQUESTTYPE_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Field `RECIPIENT` reader - Data transfer type"]
17pub type RECIPIENT_R = crate::FieldReader<u8, RECIPIENT_A>;
18#[doc = "Data transfer type\n\nValue on reset: 0"]
19#[derive(Clone, Copy, Debug, PartialEq)]
20#[repr(u8)]
21pub enum RECIPIENT_A {
22    #[doc = "0: Device"]
23    DEVICE = 0,
24    #[doc = "1: Interface"]
25    INTERFACE = 1,
26    #[doc = "2: Endpoint"]
27    ENDPOINT = 2,
28    #[doc = "3: Other"]
29    OTHER = 3,
30}
31impl From<RECIPIENT_A> for u8 {
32    #[inline(always)]
33    fn from(variant: RECIPIENT_A) -> Self {
34        variant as _
35    }
36}
37impl RECIPIENT_R {
38    #[doc = "Get enumerated values variant"]
39    #[inline(always)]
40    pub fn variant(&self) -> Option<RECIPIENT_A> {
41        match self.bits {
42            0 => Some(RECIPIENT_A::DEVICE),
43            1 => Some(RECIPIENT_A::INTERFACE),
44            2 => Some(RECIPIENT_A::ENDPOINT),
45            3 => Some(RECIPIENT_A::OTHER),
46            _ => None,
47        }
48    }
49    #[doc = "Checks if the value of the field is `DEVICE`"]
50    #[inline(always)]
51    pub fn is_device(&self) -> bool {
52        *self == RECIPIENT_A::DEVICE
53    }
54    #[doc = "Checks if the value of the field is `INTERFACE`"]
55    #[inline(always)]
56    pub fn is_interface(&self) -> bool {
57        *self == RECIPIENT_A::INTERFACE
58    }
59    #[doc = "Checks if the value of the field is `ENDPOINT`"]
60    #[inline(always)]
61    pub fn is_endpoint(&self) -> bool {
62        *self == RECIPIENT_A::ENDPOINT
63    }
64    #[doc = "Checks if the value of the field is `OTHER`"]
65    #[inline(always)]
66    pub fn is_other(&self) -> bool {
67        *self == RECIPIENT_A::OTHER
68    }
69}
70#[doc = "Field `TYPE` reader - Data transfer type"]
71pub type TYPE_R = crate::FieldReader<u8, TYPE_A>;
72#[doc = "Data transfer type\n\nValue on reset: 0"]
73#[derive(Clone, Copy, Debug, PartialEq)]
74#[repr(u8)]
75pub enum TYPE_A {
76    #[doc = "0: Standard"]
77    STANDARD = 0,
78    #[doc = "1: Class"]
79    CLASS = 1,
80    #[doc = "2: Vendor"]
81    VENDOR = 2,
82}
83impl From<TYPE_A> for u8 {
84    #[inline(always)]
85    fn from(variant: TYPE_A) -> Self {
86        variant as _
87    }
88}
89impl TYPE_R {
90    #[doc = "Get enumerated values variant"]
91    #[inline(always)]
92    pub fn variant(&self) -> Option<TYPE_A> {
93        match self.bits {
94            0 => Some(TYPE_A::STANDARD),
95            1 => Some(TYPE_A::CLASS),
96            2 => Some(TYPE_A::VENDOR),
97            _ => None,
98        }
99    }
100    #[doc = "Checks if the value of the field is `STANDARD`"]
101    #[inline(always)]
102    pub fn is_standard(&self) -> bool {
103        *self == TYPE_A::STANDARD
104    }
105    #[doc = "Checks if the value of the field is `CLASS`"]
106    #[inline(always)]
107    pub fn is_class(&self) -> bool {
108        *self == TYPE_A::CLASS
109    }
110    #[doc = "Checks if the value of the field is `VENDOR`"]
111    #[inline(always)]
112    pub fn is_vendor(&self) -> bool {
113        *self == TYPE_A::VENDOR
114    }
115}
116#[doc = "Field `DIRECTION` reader - Data transfer direction"]
117pub type DIRECTION_R = crate::BitReader<DIRECTION_A>;
118#[doc = "Data transfer direction\n\nValue on reset: 0"]
119#[derive(Clone, Copy, Debug, PartialEq)]
120pub enum DIRECTION_A {
121    #[doc = "0: Host-to-device"]
122    HOST_TO_DEVICE = 0,
123    #[doc = "1: Device-to-host"]
124    DEVICE_TO_HOST = 1,
125}
126impl From<DIRECTION_A> for bool {
127    #[inline(always)]
128    fn from(variant: DIRECTION_A) -> Self {
129        variant as u8 != 0
130    }
131}
132impl DIRECTION_R {
133    #[doc = "Get enumerated values variant"]
134    #[inline(always)]
135    pub fn variant(&self) -> DIRECTION_A {
136        match self.bits {
137            false => DIRECTION_A::HOST_TO_DEVICE,
138            true => DIRECTION_A::DEVICE_TO_HOST,
139        }
140    }
141    #[doc = "Checks if the value of the field is `HOST_TO_DEVICE`"]
142    #[inline(always)]
143    pub fn is_host_to_device(&self) -> bool {
144        *self == DIRECTION_A::HOST_TO_DEVICE
145    }
146    #[doc = "Checks if the value of the field is `DEVICE_TO_HOST`"]
147    #[inline(always)]
148    pub fn is_device_to_host(&self) -> bool {
149        *self == DIRECTION_A::DEVICE_TO_HOST
150    }
151}
152impl R {
153    #[doc = "Bits 0:4 - Data transfer type"]
154    #[inline(always)]
155    pub fn recipient(&self) -> RECIPIENT_R {
156        RECIPIENT_R::new((self.bits & 0x1f) as u8)
157    }
158    #[doc = "Bits 5:6 - Data transfer type"]
159    #[inline(always)]
160    pub fn type_(&self) -> TYPE_R {
161        TYPE_R::new(((self.bits >> 5) & 3) as u8)
162    }
163    #[doc = "Bit 7 - Data transfer direction"]
164    #[inline(always)]
165    pub fn direction(&self) -> DIRECTION_R {
166        DIRECTION_R::new(((self.bits >> 7) & 1) != 0)
167    }
168}
169#[doc = "SETUP data, byte 0, bmRequestType\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [bmrequesttype](index.html) module"]
170pub struct BMREQUESTTYPE_SPEC;
171impl crate::RegisterSpec for BMREQUESTTYPE_SPEC {
172    type Ux = u32;
173}
174#[doc = "`read()` method returns [bmrequesttype::R](R) reader structure"]
175impl crate::Readable for BMREQUESTTYPE_SPEC {
176    type Reader = R;
177}
178#[doc = "`reset()` method sets BMREQUESTTYPE to value 0"]
179impl crate::Resettable for BMREQUESTTYPE_SPEC {
180    #[inline(always)]
181    fn reset_value() -> Self::Ux {
182        0
183    }
184}