library
USBDevice/USBDevice_Types.h@0:d5bb9a9c3e24, 2012-08-24 (annotated)
- Committer:
- sherckuith
- Date:
- Fri Aug 24 02:01:51 2012 +0000
- Revision:
- 0:d5bb9a9c3e24
[mbed] converted /USB_CDC_MSD_Hello/USBDevice
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sherckuith | 0:d5bb9a9c3e24 | 1 | /* USBDevice_Types.h */ |
sherckuith | 0:d5bb9a9c3e24 | 2 | /* USB Device type definitions, conversions and constants */ |
sherckuith | 0:d5bb9a9c3e24 | 3 | /* Copyright (c) 2011 ARM Limited. All rights reserved. */ |
sherckuith | 0:d5bb9a9c3e24 | 4 | |
sherckuith | 0:d5bb9a9c3e24 | 5 | #ifndef USBDEVICE_TYPES_H |
sherckuith | 0:d5bb9a9c3e24 | 6 | #define USBDEVICE_TYPES_H |
sherckuith | 0:d5bb9a9c3e24 | 7 | |
sherckuith | 0:d5bb9a9c3e24 | 8 | /* Standard requests */ |
sherckuith | 0:d5bb9a9c3e24 | 9 | #define GET_STATUS (0) |
sherckuith | 0:d5bb9a9c3e24 | 10 | #define CLEAR_FEATURE (1) |
sherckuith | 0:d5bb9a9c3e24 | 11 | #define SET_FEATURE (3) |
sherckuith | 0:d5bb9a9c3e24 | 12 | #define SET_ADDRESS (5) |
sherckuith | 0:d5bb9a9c3e24 | 13 | #define GET_DESCRIPTOR (6) |
sherckuith | 0:d5bb9a9c3e24 | 14 | #define SET_DESCRIPTOR (7) |
sherckuith | 0:d5bb9a9c3e24 | 15 | #define GET_CONFIGURATION (8) |
sherckuith | 0:d5bb9a9c3e24 | 16 | #define SET_CONFIGURATION (9) |
sherckuith | 0:d5bb9a9c3e24 | 17 | #define GET_INTERFACE (10) |
sherckuith | 0:d5bb9a9c3e24 | 18 | #define SET_INTERFACE (11) |
sherckuith | 0:d5bb9a9c3e24 | 19 | |
sherckuith | 0:d5bb9a9c3e24 | 20 | /* bmRequestType.dataTransferDirection */ |
sherckuith | 0:d5bb9a9c3e24 | 21 | #define HOST_TO_DEVICE (0) |
sherckuith | 0:d5bb9a9c3e24 | 22 | #define DEVICE_TO_HOST (1) |
sherckuith | 0:d5bb9a9c3e24 | 23 | |
sherckuith | 0:d5bb9a9c3e24 | 24 | /* bmRequestType.Type*/ |
sherckuith | 0:d5bb9a9c3e24 | 25 | #define STANDARD_TYPE (0) |
sherckuith | 0:d5bb9a9c3e24 | 26 | #define CLASS_TYPE (1) |
sherckuith | 0:d5bb9a9c3e24 | 27 | #define VENDOR_TYPE (2) |
sherckuith | 0:d5bb9a9c3e24 | 28 | #define RESERVED_TYPE (3) |
sherckuith | 0:d5bb9a9c3e24 | 29 | |
sherckuith | 0:d5bb9a9c3e24 | 30 | /* bmRequestType.Recipient */ |
sherckuith | 0:d5bb9a9c3e24 | 31 | #define DEVICE_RECIPIENT (0) |
sherckuith | 0:d5bb9a9c3e24 | 32 | #define INTERFACE_RECIPIENT (1) |
sherckuith | 0:d5bb9a9c3e24 | 33 | #define ENDPOINT_RECIPIENT (2) |
sherckuith | 0:d5bb9a9c3e24 | 34 | #define OTHER_RECIPIENT (3) |
sherckuith | 0:d5bb9a9c3e24 | 35 | |
sherckuith | 0:d5bb9a9c3e24 | 36 | /* Descriptors */ |
sherckuith | 0:d5bb9a9c3e24 | 37 | #define DESCRIPTOR_TYPE(wValue) (wValue >> 8) |
sherckuith | 0:d5bb9a9c3e24 | 38 | #define DESCRIPTOR_INDEX(wValue) (wValue & 0xf) |
sherckuith | 0:d5bb9a9c3e24 | 39 | |
sherckuith | 0:d5bb9a9c3e24 | 40 | typedef struct { |
sherckuith | 0:d5bb9a9c3e24 | 41 | struct { |
sherckuith | 0:d5bb9a9c3e24 | 42 | uint8_t dataTransferDirection; |
sherckuith | 0:d5bb9a9c3e24 | 43 | uint8_t Type; |
sherckuith | 0:d5bb9a9c3e24 | 44 | uint8_t Recipient; |
sherckuith | 0:d5bb9a9c3e24 | 45 | } bmRequestType; |
sherckuith | 0:d5bb9a9c3e24 | 46 | uint8_t bRequest; |
sherckuith | 0:d5bb9a9c3e24 | 47 | uint16_t wValue; |
sherckuith | 0:d5bb9a9c3e24 | 48 | uint16_t wIndex; |
sherckuith | 0:d5bb9a9c3e24 | 49 | uint16_t wLength; |
sherckuith | 0:d5bb9a9c3e24 | 50 | } SETUP_PACKET; |
sherckuith | 0:d5bb9a9c3e24 | 51 | |
sherckuith | 0:d5bb9a9c3e24 | 52 | typedef struct { |
sherckuith | 0:d5bb9a9c3e24 | 53 | SETUP_PACKET setup; |
sherckuith | 0:d5bb9a9c3e24 | 54 | uint8_t *ptr; |
sherckuith | 0:d5bb9a9c3e24 | 55 | uint32_t remaining; |
sherckuith | 0:d5bb9a9c3e24 | 56 | uint8_t direction; |
sherckuith | 0:d5bb9a9c3e24 | 57 | bool zlp; |
sherckuith | 0:d5bb9a9c3e24 | 58 | bool notify; |
sherckuith | 0:d5bb9a9c3e24 | 59 | } CONTROL_TRANSFER; |
sherckuith | 0:d5bb9a9c3e24 | 60 | |
sherckuith | 0:d5bb9a9c3e24 | 61 | typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE; |
sherckuith | 0:d5bb9a9c3e24 | 62 | |
sherckuith | 0:d5bb9a9c3e24 | 63 | typedef struct { |
sherckuith | 0:d5bb9a9c3e24 | 64 | volatile DEVICE_STATE state; |
sherckuith | 0:d5bb9a9c3e24 | 65 | uint8_t configuration; |
sherckuith | 0:d5bb9a9c3e24 | 66 | bool suspended; |
sherckuith | 0:d5bb9a9c3e24 | 67 | } USB_DEVICE; |
sherckuith | 0:d5bb9a9c3e24 | 68 | |
sherckuith | 0:d5bb9a9c3e24 | 69 | #endif |