2 * @brief Common definitions and declarations for the USB ROM based stack
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
35 /** Common definitions and declarations for the USB stack.
\r
36 * @addtogroup USBD_Core
\r
42 #if defined(__GNUC__)
\r
43 /* As per http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax,
\r
44 6.29 Attributes Syntax
\r
45 "An attribute specifier list may appear as part of a struct, union or
\r
46 enum specifier. It may go either immediately after the struct, union
\r
47 or enum keyword, or after the closing brace. The former syntax is
\r
48 preferred. Where attribute specifiers follow the closing brace, they
\r
49 are considered to relate to the structure, union or enumerated type
\r
50 defined, not to any enclosing declaration the type specifier appears
\r
51 in, and the type defined is not complete until after the attribute
\r
53 So use POST_PACK immediately after struct keyword
\r
56 #define POST_PACK __attribute__((__packed__))
\r
57 #define ALIGNED(n) __attribute__((aligned (n)))
\r
58 #elif defined(__arm)
\r
59 #define PRE_PACK __packed
\r
61 #define ALIGNED(n) __align(n)
\r
62 #elif defined(__ICCARM__)
\r
63 #define PRE_PACK __packed
\r
67 /** Structure to pack lower and upper byte to form 16 bit word. */
\r
68 PRE_PACK struct POST_PACK _WB_T
\r
70 uint8_t L; /**< lower byte */
\r
71 uint8_t H; /**< upper byte */
\r
73 /** Structure to pack lower and upper byte to form 16 bit word.*/
\r
74 typedef struct _WB_T WB_T;
\r
76 /** Union of @ref _WB_T struct and 16 bit word.*/
\r
79 PRE_PACK uint16_t POST_PACK W; /**< data member to do 16 bit access */
\r
80 WB_T WB; /**< data member to do 8 bit access */
\r
82 /** Union of @ref _WB_T struct and 16 bit word.*/
\r
83 typedef union __WORD_BYTE WORD_BYTE;
\r
85 /** bmRequestType.Dir defines
\r
88 /** Request from host to device */
\r
89 #define REQUEST_HOST_TO_DEVICE 0
\r
90 /** Request from device to host */
\r
91 #define REQUEST_DEVICE_TO_HOST 1
\r
94 /** bmRequestType.Type defines
\r
97 /** Standard Request */
\r
98 #define REQUEST_STANDARD 0
\r
99 /** Class Request */
\r
100 #define REQUEST_CLASS 1
\r
101 /** Vendor Request */
\r
102 #define REQUEST_VENDOR 2
\r
103 /** Reserved Request */
\r
104 #define REQUEST_RESERVED 3
\r
107 /** bmRequestType.Recipient defines
\r
110 /** Request to device */
\r
111 #define REQUEST_TO_DEVICE 0
\r
112 /** Request to interface */
\r
113 #define REQUEST_TO_INTERFACE 1
\r
114 /** Request to endpoint */
\r
115 #define REQUEST_TO_ENDPOINT 2
\r
116 /** Request to other */
\r
117 #define REQUEST_TO_OTHER 3
\r
120 /** Structure to define 8 bit USB request.*/
\r
121 PRE_PACK struct POST_PACK _BM_T
\r
123 uint8_t Recipient : 5; /**< Recipeint type. */
\r
124 uint8_t Type : 2; /**< Request type. */
\r
125 uint8_t Dir : 1; /**< Directtion type. */
\r
127 /** Structure to define 8 bit USB request.*/
\r
128 typedef struct _BM_T BM_T;
\r
130 /** Union of @ref _BM_T struct and 8 bit byte.*/
\r
131 union _REQUEST_TYPE
\r
133 // PRE_PACK uint8_t POST_PACK B; /**< byte wide access memeber */
\r
135 BM_T BM; /**< bitfield structure access memeber */
\r
137 /** Union of @ref _BM_T struct and 8 bit byte.*/
\r
138 typedef union _REQUEST_TYPE REQUEST_TYPE;
\r
140 /** USB Standard Request Codes
\r
143 /** GET_STATUS request */
\r
144 #define USB_REQUEST_GET_STATUS 0
\r
145 /** CLEAR_FEATURE request */
\r
146 #define USB_REQUEST_CLEAR_FEATURE 1
\r
147 /** SET_FEATURE request */
\r
148 #define USB_REQUEST_SET_FEATURE 3
\r
149 /** SET_ADDRESS request */
\r
150 #define USB_REQUEST_SET_ADDRESS 5
\r
151 /** GET_DESCRIPTOR request */
\r
152 #define USB_REQUEST_GET_DESCRIPTOR 6
\r
153 /** SET_DESCRIPTOR request */
\r
154 #define USB_REQUEST_SET_DESCRIPTOR 7
\r
155 /** GET_CONFIGURATION request */
\r
156 #define USB_REQUEST_GET_CONFIGURATION 8
\r
157 /** SET_CONFIGURATION request */
\r
158 #define USB_REQUEST_SET_CONFIGURATION 9
\r
159 /** GET_INTERFACE request */
\r
160 #define USB_REQUEST_GET_INTERFACE 10
\r
161 /** SET_INTERFACE request */
\r
162 #define USB_REQUEST_SET_INTERFACE 11
\r
163 /** SYNC_FRAME request */
\r
164 #define USB_REQUEST_SYNC_FRAME 12
\r
167 /** USB GET_STATUS Bit Values
\r
170 /** SELF_POWERED status*/
\r
171 #define USB_GETSTATUS_SELF_POWERED 0x01
\r
172 /** REMOTE_WAKEUP capable status*/
\r
173 #define USB_GETSTATUS_REMOTE_WAKEUP 0x02
\r
174 /** ENDPOINT_STALL status*/
\r
175 #define USB_GETSTATUS_ENDPOINT_STALL 0x01
\r
178 /** USB Standard Feature selectors
\r
181 /** ENDPOINT_STALL feature*/
\r
182 #define USB_FEATURE_ENDPOINT_STALL 0
\r
183 /** REMOTE_WAKEUP feature*/
\r
184 #define USB_FEATURE_REMOTE_WAKEUP 1
\r
185 /** TEST_MODE feature*/
\r
186 #define USB_FEATURE_TEST_MODE 2
\r
189 /** USB Default Control Pipe Setup Packet*/
\r
190 PRE_PACK struct POST_PACK _USB_SETUP_PACKET
\r
192 REQUEST_TYPE bmRequestType; /**< This bitmapped field identifies the characteristics
\r
193 of the specific request. \sa _BM_T.
\r
195 uint8_t bRequest; /**< This field specifies the particular request. The
\r
196 Type bits in the bmRequestType field modify the meaning
\r
197 of this field. \sa USBD_REQUEST.
\r
199 WORD_BYTE wValue; /**< Used to pass a parameter to the device, specific
\r
202 WORD_BYTE wIndex; /**< Used to pass a parameter to the device, specific
\r
203 to the request. The wIndex field is often used in
\r
204 requests to specify an endpoint or an interface.
\r
206 uint16_t wLength; /**< This field specifies the length of the data
\r
207 transferred during the second phase of the control
\r
211 /** USB Default Control Pipe Setup Packet*/
\r
212 typedef struct _USB_SETUP_PACKET USB_SETUP_PACKET;
\r
215 /** USB Descriptor Types
\r
218 /** Device descriptor type */
\r
219 #define USB_DEVICE_DESCRIPTOR_TYPE 1
\r
220 /** Configuration descriptor type */
\r
221 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
\r
222 /** String descriptor type */
\r
223 #define USB_STRING_DESCRIPTOR_TYPE 3
\r
224 /** Interface descriptor type */
\r
225 #define USB_INTERFACE_DESCRIPTOR_TYPE 4
\r
226 /** Endpoint descriptor type */
\r
227 #define USB_ENDPOINT_DESCRIPTOR_TYPE 5
\r
228 /** Device qualifier descriptor type */
\r
229 #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6
\r
230 /** Other speed configuration descriptor type */
\r
231 #define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
\r
232 /** Interface power descriptor type */
\r
233 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8
\r
234 /** OTG descriptor type */
\r
235 #define USB_OTG_DESCRIPTOR_TYPE 9
\r
236 /** Debug descriptor type */
\r
237 #define USB_DEBUG_DESCRIPTOR_TYPE 10
\r
238 /** Interface association descriptor type */
\r
239 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11
\r
242 /** USB Device Classes
\r
245 /** Reserved device class */
\r
246 #define USB_DEVICE_CLASS_RESERVED 0x00
\r
247 /** Audio device class */
\r
248 #define USB_DEVICE_CLASS_AUDIO 0x01
\r
249 /** Communications device class */
\r
250 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
\r
251 /** Human interface device class */
\r
252 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
\r
253 /** monitor device class */
\r
254 #define USB_DEVICE_CLASS_MONITOR 0x04
\r
255 /** physical interface device class */
\r
256 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
\r
257 /** power device class */
\r
258 #define USB_DEVICE_CLASS_POWER 0x06
\r
259 /** Printer device class */
\r
260 #define USB_DEVICE_CLASS_PRINTER 0x07
\r
261 /** Storage device class */
\r
262 #define USB_DEVICE_CLASS_STORAGE 0x08
\r
263 /** Hub device class */
\r
264 #define USB_DEVICE_CLASS_HUB 0x09
\r
265 /** miscellaneous device class */
\r
266 #define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF
\r
267 /** Application device class */
\r
268 #define USB_DEVICE_CLASS_APP 0xFE
\r
269 /** Vendor specific device class */
\r
270 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
\r
273 /** bmAttributes in Configuration Descriptor
\r
276 /** Power field mask */
\r
277 #define USB_CONFIG_POWERED_MASK 0x40
\r
279 #define USB_CONFIG_BUS_POWERED 0x80
\r
280 /** Self powered */
\r
281 #define USB_CONFIG_SELF_POWERED 0xC0
\r
282 /** remote wakeup */
\r
283 #define USB_CONFIG_REMOTE_WAKEUP 0x20
\r
286 /** bMaxPower in Configuration Descriptor */
\r
287 //#define USB_CONFIG_POWER_MA(mA) ((mA)/2)
\r
289 /** bEndpointAddress in Endpoint Descriptor
\r
292 /** Endopint address mask */
\r
293 #define USB_ENDPOINT_DIRECTION_MASK 0x80
\r
294 /** Macro to convert OUT endopint number to endpoint address value. */
\r
295 #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)
\r
296 /** Macro to convert IN endopint number to endpoint address value. */
\r
297 #define USB_ENDPOINT_IN(addr) ((addr) | 0x80)
\r
300 /** bmAttributes in Endpoint Descriptor
\r
303 /** Endopint type mask */
\r
304 #define USB_ENDPOINT_TYPE_MASK 0x03
\r
305 /** Control Endopint type */
\r
306 #define USB_ENDPOINT_TYPE_CONTROL 0x00
\r
307 /** isochronous Endopint type */
\r
308 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
\r
309 /** bulk Endopint type */
\r
310 #define USB_ENDPOINT_TYPE_BULK 0x02
\r
311 /** interrupt Endopint type */
\r
312 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
\r
313 /** Endopint sync type mask */
\r
314 #define USB_ENDPOINT_SYNC_MASK 0x0C
\r
315 /** no synchronization Endopint */
\r
316 #define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00
\r
317 /** Asynchronous sync Endopint */
\r
318 #define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04
\r
319 /** Adaptive sync Endopint */
\r
320 #define USB_ENDPOINT_SYNC_ADAPTIVE 0x08
\r
321 /** Synchronous sync Endopint */
\r
322 #define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C
\r
323 /** Endopint usage type mask */
\r
324 #define USB_ENDPOINT_USAGE_MASK 0x30
\r
325 /** Endopint data usage type */
\r
326 #define USB_ENDPOINT_USAGE_DATA 0x00
\r
327 /** Endopint feedback usage type */
\r
328 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10
\r
329 /** Endopint implicit feedback usage type */
\r
330 #define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20
\r
331 /** Endopint reserved usage type */
\r
332 #define USB_ENDPOINT_USAGE_RESERVED 0x30
\r
335 /** Control endopint EP0's maximum packet size in high-speed mode.*/
\r
336 #define USB_ENDPOINT_0_HS_MAXP 64
\r
337 /** Control endopint EP0's maximum packet size in low-speed mode.*/
\r
338 #define USB_ENDPOINT_0_LS_MAXP 8
\r
339 /** Bulk endopint's maximum packet size in high-speed mode.*/
\r
340 #define USB_ENDPOINT_BULK_HS_MAXP 512
\r
342 /** USB Standard Device Descriptor */
\r
343 PRE_PACK struct POST_PACK _USB_DEVICE_DESCRIPTOR
\r
345 uint8_t bLength; /**< Size of this descriptor in bytes. */
\r
346 uint8_t bDescriptorType; /**< DEVICE Descriptor Type. */
\r
347 uint16_t bcdUSB; /**< BUSB Specification Release Number in
\r
348 Binary-Coded Decimal (i.e., 2.10 is 210H).
\r
349 This field identifies the release of the USB
\r
350 Specification with which the device and its
\r
351 descriptors are compliant.
\r
353 uint8_t bDeviceClass; /**< Class code (assigned by the USB-IF).
\r
354 If this field is reset to zero, each interface
\r
355 within a configuration specifies its own
\r
356 class information and the various
\r
357 interfaces operate independently.\n
\r
358 If this field is set to a value between 1 and
\r
359 FEH, the device supports different class
\r
360 specifications on different interfaces and
\r
361 the interfaces may not operate
\r
362 independently. This value identifies the
\r
363 class definition used for the aggregate
\r
365 If this field is set to FFH, the device class
\r
366 is vendor-specific.
\r
368 uint8_t bDeviceSubClass; /**< Subclass code (assigned by the USB-IF).
\r
369 These codes are qualified by the value of
\r
370 the bDeviceClass field. \n
\r
371 If the bDeviceClass field is reset to zero,
\r
372 this field must also be reset to zero. \n
\r
373 If the bDeviceClass field is not set to FFH,
\r
374 all values are reserved for assignment by
\r
377 uint8_t bDeviceProtocol; /**< Protocol code (assigned by the USB-IF).
\r
378 These codes are qualified by the value of
\r
379 the bDeviceClass and the
\r
380 bDeviceSubClass fields. If a device
\r
381 supports class-specific protocols on a
\r
382 device basis as opposed to an interface
\r
383 basis, this code identifies the protocols
\r
384 that the device uses as defined by the
\r
385 specification of the device class. \n
\r
386 If this field is reset to zero, the device
\r
387 does not use class-specific protocols on a
\r
388 device basis. However, it may use classspecific
\r
389 protocols on an interface basis. \n
\r
390 If this field is set to FFH, the device uses a
\r
391 vendor-specific protocol on a device basis.
\r
393 uint8_t bMaxPacketSize0; /**< Maximum packet size for endpoint zero
\r
394 (only 8, 16, 32, or 64 are valid). For HS devices
\r
398 uint16_t idVendor; /**< Vendor ID (assigned by the USB-IF). */
\r
399 uint16_t idProduct; /**< Product ID (assigned by the manufacturer). */
\r
400 uint16_t bcdDevice; /**< Device release number in binary-coded decimal. */
\r
401 uint8_t iManufacturer; /**< Index of string descriptor describing manufacturer. */
\r
402 uint8_t iProduct; /**< Index of string descriptor describing product. */
\r
403 uint8_t iSerialNumber; /**< Index of string descriptor describing the device’s
\r
406 uint8_t bNumConfigurations; /**< Number of possible configurations. */
\r
408 /** USB Standard Device Descriptor */
\r
409 typedef struct _USB_DEVICE_DESCRIPTOR USB_DEVICE_DESCRIPTOR;
\r
411 /** USB 2.0 Device Qualifier Descriptor */
\r
412 PRE_PACK struct POST_PACK _USB_DEVICE_QUALIFIER_DESCRIPTOR
\r
414 uint8_t bLength; /**< Size of descriptor */
\r
415 uint8_t bDescriptorType; /**< Device Qualifier Type */
\r
416 uint16_t bcdUSB; /**< USB specification version number (e.g., 0200H for V2.00) */
\r
417 uint8_t bDeviceClass; /**< Class Code */
\r
418 uint8_t bDeviceSubClass; /**< SubClass Code */
\r
419 uint8_t bDeviceProtocol; /**< Protocol Code */
\r
420 uint8_t bMaxPacketSize0; /**< Maximum packet size for other speed */
\r
421 uint8_t bNumConfigurations; /**< Number of Other-speed Configurations */
\r
422 uint8_t bReserved; /**< Reserved for future use, must be zero */
\r
424 /** USB 2.0 Device Qualifier Descriptor */
\r
425 typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR USB_DEVICE_QUALIFIER_DESCRIPTOR;
\r
427 /** USB Standard Configuration Descriptor */
\r
428 PRE_PACK struct POST_PACK _USB_CONFIGURATION_DESCRIPTOR
\r
430 uint8_t bLength; /**< Size of this descriptor in bytes */
\r
431 uint8_t bDescriptorType; /**< CONFIGURATION Descriptor Type*/
\r
432 uint16_t wTotalLength; /**< Total length of data returned for this
\r
433 configuration. Includes the combined length
\r
434 of all descriptors (configuration, interface,
\r
435 endpoint, and class- or vendor-specific)
\r
436 returned for this configuration.*/
\r
437 uint8_t bNumInterfaces; /**< Number of interfaces supported by this configuration*/
\r
438 uint8_t bConfigurationValue; /**< Value to use as an argument to the
\r
439 SetConfiguration() request to select this
\r
441 uint8_t iConfiguration; /**< Index of string descriptor describing this
\r
443 uint8_t bmAttributes; /**< Configuration characteristics \n
\r
444 D7: Reserved (set to one)\n
\r
445 D6: Self-powered \n
\r
446 D5: Remote Wakeup \n
\r
447 D4...0: Reserved (reset to zero) \n
\r
448 D7 is reserved and must be set to one for
\r
449 historical reasons. \n
\r
450 A device configuration that uses power from
\r
451 the bus and a local source reports a non-zero
\r
452 value in bMaxPower to indicate the amount of
\r
453 bus power required and sets D6. The actual
\r
454 power source at runtime may be determined
\r
455 using the GetStatus(DEVICE) request (see
\r
456 USB 2.0 spec Section 9.4.5). \n
\r
457 If a device configuration supports remote
\r
458 wakeup, D5 is set to one.*/
\r
459 uint8_t bMaxPower; /**< Maximum power consumption of the USB
\r
460 device from the bus in this specific
\r
461 configuration when the device is fully
\r
462 operational. Expressed in 2 mA units
\r
463 (i.e., 50 = 100 mA). \n
\r
464 Note: A device configuration reports whether
\r
465 the configuration is bus-powered or selfpowered.
\r
466 Device status reports whether the
\r
467 device is currently self-powered. If a device is
\r
468 disconnected from its external power source, it
\r
469 updates device status to indicate that it is no
\r
470 longer self-powered. \n
\r
471 A device may not increase its power draw
\r
472 from the bus, when it loses its external power
\r
473 source, beyond the amount reported by its
\r
475 If a device can continue to operate when
\r
476 disconnected from its external power source, it
\r
477 continues to do so. If the device cannot
\r
478 continue to operate, it fails operations it can
\r
479 no longer support. The USB System Software
\r
480 may determine the cause of the failure by
\r
481 checking the status and noting the loss of the
\r
482 device’s power source.*/
\r
484 /** USB Standard Configuration Descriptor */
\r
485 typedef struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR;
\r
487 /** USB Standard Interface Descriptor */
\r
488 PRE_PACK struct POST_PACK _USB_INTERFACE_DESCRIPTOR
\r
490 uint8_t bLength; /**< Size of this descriptor in bytes*/
\r
491 uint8_t bDescriptorType; /**< INTERFACE Descriptor Type*/
\r
492 uint8_t bInterfaceNumber; /**< Number of this interface. Zero-based
\r
493 value identifying the index in the array of
\r
494 concurrent interfaces supported by this
\r
496 uint8_t bAlternateSetting; /**< Value used to select this alternate setting
\r
497 for the interface identified in the prior field*/
\r
498 uint8_t bNumEndpoints; /**< Number of endpoints used by this
\r
499 interface (excluding endpoint zero). If this
\r
500 value is zero, this interface only uses the
\r
501 Default Control Pipe.*/
\r
502 uint8_t bInterfaceClass; /**< Class code (assigned by the USB-IF). \n
\r
503 A value of zero is reserved for future
\r
504 standardization. \n
\r
505 If this field is set to FFH, the interface
\r
506 class is vendor-specific. \n
\r
507 All other values are reserved for
\r
508 assignment by the USB-IF.*/
\r
509 uint8_t bInterfaceSubClass; /**< Subclass code (assigned by the USB-IF). \n
\r
510 These codes are qualified by the value of
\r
511 the bInterfaceClass field. \n
\r
512 If the bInterfaceClass field is reset to zero,
\r
513 this field must also be reset to zero. \n
\r
514 If the bInterfaceClass field is not set to
\r
515 FFH, all values are reserved for
\r
516 assignment by the USB-IF.*/
\r
517 uint8_t bInterfaceProtocol; /**< Protocol code (assigned by the USB). \n
\r
518 These codes are qualified by the value of
\r
519 the bInterfaceClass and the
\r
520 bInterfaceSubClass fields. If an interface
\r
521 supports class-specific requests, this code
\r
522 identifies the protocols that the device
\r
523 uses as defined by the specification of the
\r
525 If this field is reset to zero, the device
\r
526 does not use a class-specific protocol on
\r
528 If this field is set to FFH, the device uses
\r
529 a vendor-specific protocol for this
\r
531 uint8_t iInterface; /**< Index of string descriptor describing this interface*/
\r
533 /** USB Standard Interface Descriptor */
\r
534 typedef struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR;
\r
536 /** USB Standard Endpoint Descriptor */
\r
537 PRE_PACK struct POST_PACK _USB_ENDPOINT_DESCRIPTOR
\r
539 uint8_t bLength; /**< Size of this descriptor in bytes*/
\r
540 uint8_t bDescriptorType; /**< ENDPOINT Descriptor Type*/
\r
541 uint8_t bEndpointAddress; /**< The address of the endpoint on the USB device
\r
542 described by this descriptor. The address is
\r
543 encoded as follows: \n
\r
544 Bit 3...0: The endpoint number \n
\r
545 Bit 6...4: Reserved, reset to zero \n
\r
546 Bit 7: Direction, ignored for control endpoints
\r
548 1 = IN endpoint. \n \sa USBD_ENDPOINT_ADR_T*/
\r
549 uint8_t bmAttributes; /**< This field describes the endpoint’s attributes when it is
\r
550 configured using the bConfigurationValue. \n
\r
551 Bits 1..0: Transfer Type
\r
553 \li 01 = Isochronous
\r
555 \li 11 = Interrupt \n
\r
556 If not an isochronous endpoint, bits 5..2 are reserved
\r
557 and must be set to zero. If isochronous, they are
\r
558 defined as follows: \n
\r
559 Bits 3..2: Synchronization Type
\r
560 \li 00 = No Synchronization
\r
561 \li 01 = Asynchronous
\r
563 \li 11 = Synchronous \n
\r
564 Bits 5..4: Usage Type
\r
565 \li 00 = Data endpoint
\r
566 \li 01 = Feedback endpoint
\r
567 \li 10 = Implicit feedback Data endpoint
\r
568 \li 11 = Reserved \n
\r
569 Refer to Chapter 5 of USB 2.0 specification for more information. \n
\r
570 All other bits are reserved and must be reset to zero.
\r
571 Reserved bits must be ignored by the host.
\r
572 \n \sa USBD_EP_ATTR_T*/
\r
573 uint16_t wMaxPacketSize; /**< Maximum packet size this endpoint is capable of
\r
574 sending or receiving when this configuration is
\r
576 For isochronous endpoints, this value is used to
\r
577 reserve the bus time in the schedule, required for the
\r
578 per-(micro)frame data payloads. The pipe may, on an
\r
579 ongoing basis, actually use less bandwidth than that
\r
580 reserved. The device reports, if necessary, the actual
\r
581 bandwidth used via its normal, non-USB defined
\r
583 For all endpoints, bits 10..0 specify the maximum
\r
584 packet size (in bytes). \n
\r
585 For high-speed isochronous and interrupt endpoints: \n
\r
586 Bits 12..11 specify the number of additional transaction
\r
587 opportunities per microframe: \n
\r
588 \li 00 = None (1 transaction per microframe)
\r
589 \li 01 = 1 additional (2 per microframe)
\r
590 \li 10 = 2 additional (3 per microframe)
\r
591 \li 11 = Reserved \n
\r
592 Bits 15..13 are reserved and must be set to zero.*/
\r
593 uint8_t bInterval; /**< Interval for polling endpoint for data transfers.
\r
594 Expressed in frames or microframes depending on the
\r
595 device operating speed (i.e., either 1 millisecond or
\r
597 \li For full-/high-speed isochronous endpoints, this value
\r
598 must be in the range from 1 to 16. The bInterval value
\r
599 is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a
\r
600 bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$).
\r
601 \li For full-/low-speed interrupt endpoints, the value of
\r
602 this field may be from 1 to 255.
\r
603 \li For high-speed interrupt endpoints, the bInterval value
\r
604 is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a
\r
605 bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$) . This value
\r
606 must be from 1 to 16.
\r
607 \li For high-speed bulk/control OUT endpoints, the
\r
608 bInterval must specify the maximum NAK rate of the
\r
609 endpoint. A value of 0 indicates the endpoint never
\r
610 NAKs. Other values indicate at most 1 NAK each
\r
611 bInterval number of microframes. This value must be
\r
612 in the range from 0 to 255. \n
\r
613 Refer to Chapter 5 of USB 2.0 specification for more information.
\r
616 /** USB Standard Endpoint Descriptor */
\r
617 typedef struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR;
\r
619 /** USB String Descriptor */
\r
620 PRE_PACK struct POST_PACK _USB_STRING_DESCRIPTOR
\r
622 uint8_t bLength; /**< Size of this descriptor in bytes*/
\r
623 uint8_t bDescriptorType; /**< STRING Descriptor Type*/
\r
624 uint16_t bString/*[]*/; /**< UNICODE encoded string */
\r
626 /** USB String Descriptor */
\r
627 typedef struct _USB_STRING_DESCRIPTOR USB_STRING_DESCRIPTOR;
\r
629 /** USB Common Descriptor */
\r
630 PRE_PACK struct POST_PACK _USB_COMMON_DESCRIPTOR
\r
632 uint8_t bLength; /**< Size of this descriptor in bytes*/
\r
633 uint8_t bDescriptorType; /**< Descriptor Type*/
\r
635 /** USB Common Descriptor */
\r
636 typedef struct _USB_COMMON_DESCRIPTOR USB_COMMON_DESCRIPTOR;
\r
638 /** USB Other Speed Configuration */
\r
639 PRE_PACK struct POST_PACK _USB_OTHER_SPEED_CONFIGURATION
\r
641 uint8_t bLength; /**< Size of descriptor*/
\r
642 uint8_t bDescriptorType; /**< Other_speed_Configuration Type*/
\r
643 uint16_t wTotalLength; /**< Total length of data returned*/
\r
644 uint8_t bNumInterfaces; /**< Number of interfaces supported by this speed configuration*/
\r
645 uint8_t bConfigurationValue; /**< Value to use to select configuration*/
\r
646 uint8_t IConfiguration; /**< Index of string descriptor*/
\r
647 uint8_t bmAttributes; /**< Same as Configuration descriptor*/
\r
648 uint8_t bMaxPower; /**< Same as Configuration descriptor*/
\r
650 /** USB Other Speed Configuration */
\r
651 typedef struct _USB_OTHER_SPEED_CONFIGURATION USB_OTHER_SPEED_CONFIGURATION;
\r
653 /** @ingroup USBD_Core
\r
654 * USB device stack/module handle.
\r
656 typedef void* USBD_HANDLE_T;
\r
658 #define WBVAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
\r
659 #define B3VAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF),(((x) >> 16) & 0xFF)
\r
661 #define USB_DEVICE_DESC_SIZE (sizeof(USB_DEVICE_DESCRIPTOR))
\r
662 #define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
\r
663 #define USB_INTERFACE_DESC_SIZE (sizeof(USB_INTERFACE_DESCRIPTOR))
\r
664 #define USB_ENDPOINT_DESC_SIZE (sizeof(USB_ENDPOINT_DESCRIPTOR))
\r
665 #define USB_DEVICE_QUALI_SIZE (sizeof(USB_DEVICE_QUALIFIER_DESCRIPTOR))
\r
666 #define USB_OTHER_SPEED_CONF_SIZE (sizeof(USB_OTHER_SPEED_CONFIGURATION))
\r
669 uint32_t CALLBACK_UsbdRom_Register_DeviceDescriptor(void);
\r
670 uint32_t CALLBACK_UsbdRom_Register_ConfigurationDescriptor(void);
\r
671 uint32_t CALLBACK_UsbdRom_Register_StringDescriptor(void);
\r
672 uint32_t CALLBACK_UsbdRom_Register_DeviceQualifierDescriptor(void);
\r
673 uint8_t CALLBACK_UsbdRom_Register_ConfigureEndpoint(void);
\r
674 #endif /* __USB_H__ */
\r