USBRequests.c
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------- */
2 /* Atmel Microcontroller Software Support */
3 /* SAM Software Package License */
4 /* ---------------------------------------------------------------------------- */
5 /* Copyright (c) 2015, Atmel Corporation */
6 /* */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without */
10 /* modification, are permitted provided that the following condition is met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, */
13 /* this list of conditions and the disclaimer below. */
14 /* */
15 /* Atmel's name may not be used to endorse or promote products derived from */
16 /* this software without specific prior written permission. */
17 /* */
18 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28 /* ---------------------------------------------------------------------------- */
29 
40 /*------------------------------------------------------------------------------
41  * Headers
42  *------------------------------------------------------------------------------*/
43 #include <USBRequests.h>
44 
45 /*------------------------------------------------------------------------------
46  * Exported functions
47  *------------------------------------------------------------------------------*/
48 
54 extern uint8_t USBGenericRequest_GetType(const USBGenericRequest *request)
55 {
56  return ((request->bmRequestType >> 5) & 0x3);
57 }
58 
66 {
67  return request->bRequest;
68 }
69 
76 {
77  return request->wValue;
78 }
79 
86 {
87  return request->wIndex;
88 }
89 
96 {
97  return request->wLength;
98 }
99 
106  const USBGenericRequest *request)
107 {
108  return USBGenericRequest_GetIndex(request) & 0xF;
109 }
110 
118 {
119  /* Recipient is in bits [0..4] of the bmRequestType field */
120  return request->bmRequestType & 0xF;
121 }
122 
130 {
131  /* Transfer direction is located in bit D7 of the bmRequestType field */
132  if ((request->bmRequestType & 0x80) != 0)
133  return USBGenericRequest_IN;
134  else
135  return USBGenericRequest_OUT;
136 }
137 
138 
146  const USBGenericRequest *request)
147 {
148  /* Requested descriptor type is in the high-byte of the wValue field */
149  return (USBGenericRequest_GetValue(request) >> 8) & 0xFF;
150 }
151 
159  const USBGenericRequest *request)
160 {
161  /* Requested descriptor index if in the low byte of the wValue field */
162  return USBGenericRequest_GetValue(request) & 0xFF;
163 }
164 
165 
173 {
174  return USBGenericRequest_GetValue(request) & 0x7F;
175 }
176 
177 
185  const USBGenericRequest *request)
186 {
187  return USBGenericRequest_GetValue(request);
188 }
189 
190 
198 {
199  return (USBGenericRequest_GetIndex(request) & 0xFF);
200 }
201 
209  const USBGenericRequest *request)
210 {
211  return (USBGenericRequest_GetValue(request) & 0xFF);
212 }
213 
214 
222  const USBGenericRequest *request)
223 {
224  return USBGenericRequest_GetValue(request);
225 }
226 
234  const USBGenericRequest *request)
235 {
236  return (USBGenericRequest_GetIndex(request) >> 8) & 0xFF;
237 }
238 
uint8_t USBSetAddressRequest_GetAddress(const USBGenericRequest *request)
Definition: USBRequests.c:172
uint8_t USBGenericRequest_GetRecipient(const USBGenericRequest *request)
Definition: USBRequests.c:117
uint8_t bmRequestType
Definition: USBRequests.h:280
uint8_t USBGenericRequest_GetType(const USBGenericRequest *request)
Definition: USBRequests.c:54
#define USBGenericRequest_OUT
Definition: USBRequests.h:175
uint16_t USBGenericRequest_GetValue(const USBGenericRequest *request)
Definition: USBRequests.c:75
uint8_t USBInterfaceRequest_GetInterface(const USBGenericRequest *request)
Definition: USBRequests.c:197
uint8_t USBSetConfigurationRequest_GetConfiguration(const USBGenericRequest *request)
Definition: USBRequests.c:184
uint16_t USBGenericRequest_GetLength(const USBGenericRequest *request)
Definition: USBRequests.c:95
uint8_t USBFeatureRequest_GetTestSelector(const USBGenericRequest *request)
Definition: USBRequests.c:233
uint8_t USBGenericRequest_GetDirection(const USBGenericRequest *request)
Definition: USBRequests.c:129
uint8_t USBGenericRequest_GetEndpointNumber(const USBGenericRequest *request)
Definition: USBRequests.c:105
uint8_t USBGetDescriptorRequest_GetDescriptorType(const USBGenericRequest *request)
Definition: USBRequests.c:145
uint8_t USBGenericRequest_GetRequest(const USBGenericRequest *request)
Definition: USBRequests.c:65
#define USBGenericRequest_IN
Definition: USBRequests.h:177
uint8_t USBInterfaceRequest_GetAlternateSetting(const USBGenericRequest *request)
Definition: USBRequests.c:208
uint16_t USBGenericRequest_GetIndex(const USBGenericRequest *request)
Definition: USBRequests.c:85
uint8_t USBGetDescriptorRequest_GetDescriptorIndex(const USBGenericRequest *request)
Definition: USBRequests.c:158
uint8_t USBFeatureRequest_GetFeatureSelector(const USBGenericRequest *request)
Definition: USBRequests.c:221


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:05