00001 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is confidential property of Nordic 00004 * Semiconductor ASA.Terms and conditions of usage are described in detail 00005 * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRENTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 * 00011 * $LastChangedRevision: 133 $ 00012 */ 00013 00018 #ifndef HAL_USB_DESC_H__ 00019 #define HAL_USB_DESC_H__ 00020 00021 #include <stdint.h> 00022 00023 // Standard request codes 00024 #define USB_REQ_GET_STATUS 0x00 00025 #define USB_REQ_CLEAR_FEATURE 0x01 00026 #define USB_REQ_RESERVED_1 0x02 00027 #define USB_REQ_SET_FEATURE 0x03 00028 #define USB_REQ_RESERVED_2 0x04 00029 #define USB_REQ_SET_ADDRESS 0x05 00030 #define USB_REQ_GET_DESCRIPTOR 0x06 00031 #define USB_REQ_SET_DESCRIPTOR 0x07 00032 #define USB_REQ_GET_CONFIGURATION 0x08 00033 #define USB_REQ_SET_CONFIGURATION 0x09 00034 #define USB_REQ_GET_INTERFACE 0x0a 00035 #define USB_REQ_SET_INTERFACE 0x0b 00036 #define USB_REQ_SYNCH_FRAME 0x0c 00037 00038 // Descriptor types 00039 #define USB_DESC_DEVICE 0x01 00040 #define USB_DESC_CONFIGURATION 0x02 00041 #define USB_DESC_STRING 0x03 00042 #define USB_DESC_INTERFACE 0x04 00043 #define USB_DESC_ENDPOINT 0x05 00044 #define USB_DESC_DEVICE_QUAL 0x06 00045 #define USB_DESC_OTHER_SPEED_CONF 0x07 00046 #define USB_DESC_INTERFACE_POWER 0x08 00047 #define USB_DESC_OTG 0x09 00048 #define USB_DESC_DEBUG 0x0A 00049 #define USB_DESC_INTERFACE_ASSOC 0x0B 00050 00051 #define USB_ENDPOINT_TYPE_CONTROL 0x00 00052 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 00053 #define USB_ENDPOINT_TYPE_BULK 0x02 00054 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 00055 00056 // USB device classes 00057 #define USB_DEVICE_CLASS_RESERVED 0x00 00058 #define USB_DEVICE_CLASS_AUDIO 0x01 00059 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 00060 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 00061 #define USB_DEVICE_CLASS_MONITOR 0x04 00062 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 00063 #define USB_DEVICE_CLASS_POWER 0x06 00064 #define USB_DEVICE_CLASS_PRINTER 0x07 00065 #define USB_DEVICE_CLASS_STORAGE 0x08 00066 #define USB_DEVICE_CLASS_HUB 0x09 00067 #define USB_DEVICE_CLASS_APPLICATION_SPECIFIC 0xFE 00068 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF 00069 00070 00071 #define USB_CLASS_DESCRIPTOR_HID 0x21 00072 #define USB_CLASS_DESCRIPTOR_REPORT 0x22 00073 #define USB_CLASS_DESCRIPTOR_PHYSICAL_DESCRIPTOR 0x23 00074 00075 #define USB_DEVICE_REMOTE_WAKEUP 0x01 00076 #define USB_ENDPOINT_HALT 0x00 00077 #define USB_TEST_MODE 0x02 00078 00079 typedef struct { 00080 volatile uint8_t bLength; 00081 volatile uint8_t bDescriptorType; 00082 volatile uint16_t bcdUSB; 00083 volatile uint8_t bDeviceClass; 00084 volatile uint8_t bDeviceSubClass; 00085 volatile uint8_t bDeviceProtocol; 00086 volatile uint8_t bMaxPacketSize0; 00087 volatile uint16_t idVendor; 00088 volatile uint16_t idProduct; 00089 volatile uint16_t bcdDevice; 00090 volatile uint8_t iManufacturer; 00091 volatile uint8_t iProduct; 00092 volatile uint8_t iSerialNumber; 00093 volatile uint8_t bNumConfigurations; 00094 } hal_usb_dev_desc_t; 00095 00096 typedef struct { 00097 volatile uint8_t bLength; 00098 volatile uint8_t bDescriptorType; 00099 volatile uint16_t wTotalLength; 00100 volatile uint8_t bNumInterfaces; 00101 volatile uint8_t bConfigurationValue; 00102 volatile uint8_t iConfiguration; 00103 volatile uint8_t bmAttributes; 00104 volatile uint8_t bMaxPower; 00105 } hal_usb_conf_desc_t; 00106 00107 typedef struct { 00108 volatile uint8_t bLength; 00109 volatile uint8_t bDescriptorType; 00110 volatile uint8_t bInterfaceNumber; 00111 volatile uint8_t bAlternateSetting; 00112 volatile uint8_t bNumEndpoints; 00113 volatile uint8_t bInterfaceClass; 00114 volatile uint8_t bInterfaceSubClass; 00115 volatile uint8_t bInterfaceProtocol; 00116 volatile uint8_t iInterface; 00117 } hal_usb_if_desc_t; 00118 00119 typedef struct { 00120 volatile uint8_t bLength; 00121 volatile uint8_t bDescriptorType; 00122 volatile uint8_t bEndpointAddress; 00123 volatile uint8_t bmAttributes; 00124 volatile uint16_t wMaxPacketSize; 00125 volatile uint8_t bInterval; 00126 } hal_usb_ep_desc_t; 00127 00128 typedef struct { 00129 volatile uint8_t bLength; 00130 volatile uint8_t bDescriptorType; 00131 volatile uint16_t bcdHID; 00132 volatile uint8_t bCountryCode; 00133 volatile uint8_t bNumDescriptors; 00134 volatile uint8_t bDescriptorType2; 00135 volatile uint16_t wDescriptorLength; 00136 } hal_usb_hid_desc_t; 00137 00138 typedef struct { 00139 volatile uint8_t* desc; 00140 } hal_usb_string_desc_t; 00141 00142 typedef struct { 00143 volatile uint8_t bLength; 00144 volatile uint8_t bDescriptorType; 00145 } hal_usb_common_desc_t; 00146 00147 00148 #endif // HAL_USB_DESC_H__