partly working USB Device lib for STM32F746NG Discovery both Interface are working
Dependents: DISCO-F746NG-USB_Device McLighTT project_Keyboard_to_the_Keyboard MIDIInstrumentPADProject ... more
USBSerial/USBCDC.cpp@0:0a2eaa300982, 2016-07-31 (annotated)
- Committer:
- DieterGraef
- Date:
- Sun Jul 31 17:47:35 2016 +0000
- Revision:
- 0:0a2eaa300982
partly working USB Device library - serial and MIDI is working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DieterGraef | 0:0a2eaa300982 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
DieterGraef | 0:0a2eaa300982 | 2 | * |
DieterGraef | 0:0a2eaa300982 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
DieterGraef | 0:0a2eaa300982 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
DieterGraef | 0:0a2eaa300982 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
DieterGraef | 0:0a2eaa300982 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
DieterGraef | 0:0a2eaa300982 | 7 | * Software is furnished to do so, subject to the following conditions: |
DieterGraef | 0:0a2eaa300982 | 8 | * |
DieterGraef | 0:0a2eaa300982 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
DieterGraef | 0:0a2eaa300982 | 10 | * substantial portions of the Software. |
DieterGraef | 0:0a2eaa300982 | 11 | * |
DieterGraef | 0:0a2eaa300982 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
DieterGraef | 0:0a2eaa300982 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
DieterGraef | 0:0a2eaa300982 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
DieterGraef | 0:0a2eaa300982 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
DieterGraef | 0:0a2eaa300982 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
DieterGraef | 0:0a2eaa300982 | 17 | */ |
DieterGraef | 0:0a2eaa300982 | 18 | |
DieterGraef | 0:0a2eaa300982 | 19 | #include "stdint.h" |
DieterGraef | 0:0a2eaa300982 | 20 | #include "USBCDC.h" |
DieterGraef | 0:0a2eaa300982 | 21 | |
DieterGraef | 0:0a2eaa300982 | 22 | static uint8_t cdc_line_coding[7]= {0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08}; |
DieterGraef | 0:0a2eaa300982 | 23 | |
DieterGraef | 0:0a2eaa300982 | 24 | #define DEFAULT_CONFIGURATION (1) |
DieterGraef | 0:0a2eaa300982 | 25 | |
DieterGraef | 0:0a2eaa300982 | 26 | #define CDC_SET_LINE_CODING 0x20 |
DieterGraef | 0:0a2eaa300982 | 27 | #define CDC_GET_LINE_CODING 0x21 |
DieterGraef | 0:0a2eaa300982 | 28 | #define CDC_SET_CONTROL_LINE_STATE 0x22 |
DieterGraef | 0:0a2eaa300982 | 29 | |
DieterGraef | 0:0a2eaa300982 | 30 | // Control Line State bits |
DieterGraef | 0:0a2eaa300982 | 31 | #define CLS_DTR (1 << 0) |
DieterGraef | 0:0a2eaa300982 | 32 | #define CLS_RTS (1 << 1) |
DieterGraef | 0:0a2eaa300982 | 33 | |
DieterGraef | 0:0a2eaa300982 | 34 | #define MAX_CDC_REPORT_SIZE MAX_PACKET_SIZE_EPBULK |
DieterGraef | 0:0a2eaa300982 | 35 | |
DieterGraef | 0:0a2eaa300982 | 36 | USBCDC::USBCDC(uint16_t HW_Interface, uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking): USBDevice(HW_Interface,vendor_id, product_id, product_release) { |
DieterGraef | 0:0a2eaa300982 | 37 | terminal_connected = false; |
DieterGraef | 0:0a2eaa300982 | 38 | USBDevice::connect(connect_blocking); |
DieterGraef | 0:0a2eaa300982 | 39 | |
DieterGraef | 0:0a2eaa300982 | 40 | } |
DieterGraef | 0:0a2eaa300982 | 41 | |
DieterGraef | 0:0a2eaa300982 | 42 | bool USBCDC::USBCallback_request(void) { |
DieterGraef | 0:0a2eaa300982 | 43 | /* Called in ISR context */ |
DieterGraef | 0:0a2eaa300982 | 44 | |
DieterGraef | 0:0a2eaa300982 | 45 | bool success = false; |
DieterGraef | 0:0a2eaa300982 | 46 | CONTROL_TRANSFER * transfer = getTransferPtr(); |
DieterGraef | 0:0a2eaa300982 | 47 | |
DieterGraef | 0:0a2eaa300982 | 48 | /* Process class-specific requests */ |
DieterGraef | 0:0a2eaa300982 | 49 | |
DieterGraef | 0:0a2eaa300982 | 50 | if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { |
DieterGraef | 0:0a2eaa300982 | 51 | switch (transfer->setup.bRequest) { |
DieterGraef | 0:0a2eaa300982 | 52 | case CDC_GET_LINE_CODING: |
DieterGraef | 0:0a2eaa300982 | 53 | transfer->remaining = 7; |
DieterGraef | 0:0a2eaa300982 | 54 | transfer->ptr = cdc_line_coding; |
DieterGraef | 0:0a2eaa300982 | 55 | transfer->direction = DEVICE_TO_HOST; |
DieterGraef | 0:0a2eaa300982 | 56 | success = true; |
DieterGraef | 0:0a2eaa300982 | 57 | break; |
DieterGraef | 0:0a2eaa300982 | 58 | case CDC_SET_LINE_CODING: |
DieterGraef | 0:0a2eaa300982 | 59 | transfer->remaining = 7; |
DieterGraef | 0:0a2eaa300982 | 60 | transfer->notify = true; |
DieterGraef | 0:0a2eaa300982 | 61 | success = true; |
DieterGraef | 0:0a2eaa300982 | 62 | break; |
DieterGraef | 0:0a2eaa300982 | 63 | case CDC_SET_CONTROL_LINE_STATE: |
DieterGraef | 0:0a2eaa300982 | 64 | if (transfer->setup.wValue & CLS_DTR) { |
DieterGraef | 0:0a2eaa300982 | 65 | terminal_connected = true; |
DieterGraef | 0:0a2eaa300982 | 66 | } else { |
DieterGraef | 0:0a2eaa300982 | 67 | terminal_connected = false; |
DieterGraef | 0:0a2eaa300982 | 68 | } |
DieterGraef | 0:0a2eaa300982 | 69 | success = true; |
DieterGraef | 0:0a2eaa300982 | 70 | break; |
DieterGraef | 0:0a2eaa300982 | 71 | default: |
DieterGraef | 0:0a2eaa300982 | 72 | break; |
DieterGraef | 0:0a2eaa300982 | 73 | } |
DieterGraef | 0:0a2eaa300982 | 74 | } |
DieterGraef | 0:0a2eaa300982 | 75 | |
DieterGraef | 0:0a2eaa300982 | 76 | return success; |
DieterGraef | 0:0a2eaa300982 | 77 | } |
DieterGraef | 0:0a2eaa300982 | 78 | |
DieterGraef | 0:0a2eaa300982 | 79 | void USBCDC::USBCallback_requestCompleted(uint8_t *buf, uint32_t length) { |
DieterGraef | 0:0a2eaa300982 | 80 | // Request of setting line coding has 7 bytes |
DieterGraef | 0:0a2eaa300982 | 81 | if (length != 7) { |
DieterGraef | 0:0a2eaa300982 | 82 | return; |
DieterGraef | 0:0a2eaa300982 | 83 | } |
DieterGraef | 0:0a2eaa300982 | 84 | |
DieterGraef | 0:0a2eaa300982 | 85 | CONTROL_TRANSFER * transfer = getTransferPtr(); |
DieterGraef | 0:0a2eaa300982 | 86 | |
DieterGraef | 0:0a2eaa300982 | 87 | /* Process class-specific requests */ |
DieterGraef | 0:0a2eaa300982 | 88 | if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { |
DieterGraef | 0:0a2eaa300982 | 89 | if (transfer->setup.bRequest == CDC_SET_LINE_CODING) { |
DieterGraef | 0:0a2eaa300982 | 90 | if (memcmp(cdc_line_coding, buf, 7)) { |
DieterGraef | 0:0a2eaa300982 | 91 | memcpy(cdc_line_coding, buf, 7); |
DieterGraef | 0:0a2eaa300982 | 92 | |
DieterGraef | 0:0a2eaa300982 | 93 | int baud = buf[0] + (buf[1] << 8) |
DieterGraef | 0:0a2eaa300982 | 94 | + (buf[2] << 16) + (buf[3] << 24); |
DieterGraef | 0:0a2eaa300982 | 95 | int stop = buf[4]; |
DieterGraef | 0:0a2eaa300982 | 96 | int bits = buf[6]; |
DieterGraef | 0:0a2eaa300982 | 97 | int parity = buf[5]; |
DieterGraef | 0:0a2eaa300982 | 98 | |
DieterGraef | 0:0a2eaa300982 | 99 | lineCodingChanged(baud, bits, parity, stop); |
DieterGraef | 0:0a2eaa300982 | 100 | } |
DieterGraef | 0:0a2eaa300982 | 101 | } |
DieterGraef | 0:0a2eaa300982 | 102 | } |
DieterGraef | 0:0a2eaa300982 | 103 | } |
DieterGraef | 0:0a2eaa300982 | 104 | |
DieterGraef | 0:0a2eaa300982 | 105 | // Called in ISR context |
DieterGraef | 0:0a2eaa300982 | 106 | // Set configuration. Return false if the |
DieterGraef | 0:0a2eaa300982 | 107 | // configuration is not supported. |
DieterGraef | 0:0a2eaa300982 | 108 | bool USBCDC::USBCallback_setConfiguration(uint8_t configuration) { |
DieterGraef | 0:0a2eaa300982 | 109 | if (configuration != DEFAULT_CONFIGURATION) { |
DieterGraef | 0:0a2eaa300982 | 110 | return false; |
DieterGraef | 0:0a2eaa300982 | 111 | } |
DieterGraef | 0:0a2eaa300982 | 112 | |
DieterGraef | 0:0a2eaa300982 | 113 | // Configure endpoints > 0 |
DieterGraef | 0:0a2eaa300982 | 114 | addEndpoint(EPINT_IN, MAX_PACKET_SIZE_EPINT); |
DieterGraef | 0:0a2eaa300982 | 115 | addEndpoint(EPBULK_IN, MAX_PACKET_SIZE_EPBULK); |
DieterGraef | 0:0a2eaa300982 | 116 | addEndpoint(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK); |
DieterGraef | 0:0a2eaa300982 | 117 | |
DieterGraef | 0:0a2eaa300982 | 118 | // We activate the endpoint to be able to recceive data |
DieterGraef | 0:0a2eaa300982 | 119 | readStart(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK); |
DieterGraef | 0:0a2eaa300982 | 120 | return true; |
DieterGraef | 0:0a2eaa300982 | 121 | } |
DieterGraef | 0:0a2eaa300982 | 122 | |
DieterGraef | 0:0a2eaa300982 | 123 | bool USBCDC::send(uint8_t * buffer, uint32_t size) { |
DieterGraef | 0:0a2eaa300982 | 124 | return USBDevice::write(EPBULK_IN, buffer, size, MAX_CDC_REPORT_SIZE); |
DieterGraef | 0:0a2eaa300982 | 125 | } |
DieterGraef | 0:0a2eaa300982 | 126 | |
DieterGraef | 0:0a2eaa300982 | 127 | bool USBCDC::readEP(uint8_t * buffer, uint32_t * size) { |
DieterGraef | 0:0a2eaa300982 | 128 | if (!USBDevice::readEP(EPBULK_OUT, buffer, size, MAX_CDC_REPORT_SIZE)) |
DieterGraef | 0:0a2eaa300982 | 129 | return false; |
DieterGraef | 0:0a2eaa300982 | 130 | if (!readStart(EPBULK_OUT, MAX_CDC_REPORT_SIZE)) |
DieterGraef | 0:0a2eaa300982 | 131 | return false; |
DieterGraef | 0:0a2eaa300982 | 132 | return true; |
DieterGraef | 0:0a2eaa300982 | 133 | } |
DieterGraef | 0:0a2eaa300982 | 134 | |
DieterGraef | 0:0a2eaa300982 | 135 | bool USBCDC::readEP_NB(uint8_t * buffer, uint32_t * size) { |
DieterGraef | 0:0a2eaa300982 | 136 | if (!USBDevice::readEP_NB(EPBULK_OUT, buffer, size, MAX_CDC_REPORT_SIZE)) |
DieterGraef | 0:0a2eaa300982 | 137 | return false; |
DieterGraef | 0:0a2eaa300982 | 138 | if (!readStart(EPBULK_OUT, MAX_CDC_REPORT_SIZE)) |
DieterGraef | 0:0a2eaa300982 | 139 | return false; |
DieterGraef | 0:0a2eaa300982 | 140 | return true; |
DieterGraef | 0:0a2eaa300982 | 141 | } |
DieterGraef | 0:0a2eaa300982 | 142 | |
DieterGraef | 0:0a2eaa300982 | 143 | |
DieterGraef | 0:0a2eaa300982 | 144 | uint8_t * USBCDC::deviceDesc() { |
DieterGraef | 0:0a2eaa300982 | 145 | static uint8_t deviceDescriptor[] = { |
DieterGraef | 0:0a2eaa300982 | 146 | 18, // bLength |
DieterGraef | 0:0a2eaa300982 | 147 | DEVICE_DESCRIPTOR, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 148 | LSB(USB_VERSION_2_0), /* bcdUSB (LSB) */ |
DieterGraef | 0:0a2eaa300982 | 149 | MSB(USB_VERSION_2_0), /* bcdUSB (MSB) */ |
DieterGraef | 0:0a2eaa300982 | 150 | 0, // bDeviceClass |
DieterGraef | 0:0a2eaa300982 | 151 | 0, // bDeviceSubClass |
DieterGraef | 0:0a2eaa300982 | 152 | 0, // bDeviceProtocol |
DieterGraef | 0:0a2eaa300982 | 153 | MAX_PACKET_SIZE_EP0, // bMaxPacketSize0 |
DieterGraef | 0:0a2eaa300982 | 154 | (uint8_t)(LSB(VENDOR_ID)), (uint8_t)(MSB(VENDOR_ID)), // idVendor |
DieterGraef | 0:0a2eaa300982 | 155 | (uint8_t)(LSB(PRODUCT_ID)), (uint8_t)(MSB(PRODUCT_ID)), // idProduct |
DieterGraef | 0:0a2eaa300982 | 156 | 0x00, 0x02, // bcdDevice |
DieterGraef | 0:0a2eaa300982 | 157 | STRING_OFFSET_IMANUFACTURER, /* iManufacturer */ |
DieterGraef | 0:0a2eaa300982 | 158 | STRING_OFFSET_IPRODUCT, /* iProduct */ |
DieterGraef | 0:0a2eaa300982 | 159 | STRING_OFFSET_ISERIAL, /* iSerialNumber */ |
DieterGraef | 0:0a2eaa300982 | 160 | 0x01 /* bNumConfigurations */ |
DieterGraef | 0:0a2eaa300982 | 161 | }; |
DieterGraef | 0:0a2eaa300982 | 162 | return deviceDescriptor; |
DieterGraef | 0:0a2eaa300982 | 163 | } |
DieterGraef | 0:0a2eaa300982 | 164 | |
DieterGraef | 0:0a2eaa300982 | 165 | uint8_t * USBCDC::stringIinterfaceDesc() { |
DieterGraef | 0:0a2eaa300982 | 166 | static uint8_t stringIinterfaceDescriptor[] = { |
DieterGraef | 0:0a2eaa300982 | 167 | 0x08, |
DieterGraef | 0:0a2eaa300982 | 168 | STRING_DESCRIPTOR, |
DieterGraef | 0:0a2eaa300982 | 169 | 'C',0,'D',0,'C',0, |
DieterGraef | 0:0a2eaa300982 | 170 | }; |
DieterGraef | 0:0a2eaa300982 | 171 | return stringIinterfaceDescriptor; |
DieterGraef | 0:0a2eaa300982 | 172 | } |
DieterGraef | 0:0a2eaa300982 | 173 | |
DieterGraef | 0:0a2eaa300982 | 174 | uint8_t * USBCDC::stringIproductDesc() { |
DieterGraef | 0:0a2eaa300982 | 175 | static uint8_t stringIproductDescriptor[] = { |
DieterGraef | 0:0a2eaa300982 | 176 | 0x16, |
DieterGraef | 0:0a2eaa300982 | 177 | STRING_DESCRIPTOR, |
DieterGraef | 0:0a2eaa300982 | 178 | 'C',0,'D',0,'C',0,' ',0,'D',0,'E',0,'V',0,'I',0,'C',0,'E',0 |
DieterGraef | 0:0a2eaa300982 | 179 | }; |
DieterGraef | 0:0a2eaa300982 | 180 | return stringIproductDescriptor; |
DieterGraef | 0:0a2eaa300982 | 181 | } |
DieterGraef | 0:0a2eaa300982 | 182 | |
DieterGraef | 0:0a2eaa300982 | 183 | |
DieterGraef | 0:0a2eaa300982 | 184 | #define CONFIG1_DESC_SIZE (9+8+9+5+5+4+5+7+9+7+7) |
DieterGraef | 0:0a2eaa300982 | 185 | |
DieterGraef | 0:0a2eaa300982 | 186 | uint8_t * USBCDC::configurationDesc() { |
DieterGraef | 0:0a2eaa300982 | 187 | static uint8_t configDescriptor[] = { |
DieterGraef | 0:0a2eaa300982 | 188 | // configuration descriptor |
DieterGraef | 0:0a2eaa300982 | 189 | 9, // bLength |
DieterGraef | 0:0a2eaa300982 | 190 | 2, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 191 | LSB(CONFIG1_DESC_SIZE), // wTotalLength |
DieterGraef | 0:0a2eaa300982 | 192 | MSB(CONFIG1_DESC_SIZE), |
DieterGraef | 0:0a2eaa300982 | 193 | 2, // bNumInterfaces |
DieterGraef | 0:0a2eaa300982 | 194 | 1, // bConfigurationValue |
DieterGraef | 0:0a2eaa300982 | 195 | 0, // iConfiguration |
DieterGraef | 0:0a2eaa300982 | 196 | 0x80, // bmAttributes |
DieterGraef | 0:0a2eaa300982 | 197 | 50, // bMaxPower |
DieterGraef | 0:0a2eaa300982 | 198 | |
DieterGraef | 0:0a2eaa300982 | 199 | // IAD to associate the two CDC interfaces |
DieterGraef | 0:0a2eaa300982 | 200 | 0x08, // bLength |
DieterGraef | 0:0a2eaa300982 | 201 | 0x0b, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 202 | 0x00, // bFirstInterface |
DieterGraef | 0:0a2eaa300982 | 203 | 0x02, // bInterfaceCount |
DieterGraef | 0:0a2eaa300982 | 204 | 0x02, // bFunctionClass |
DieterGraef | 0:0a2eaa300982 | 205 | 0x02, // bFunctionSubClass |
DieterGraef | 0:0a2eaa300982 | 206 | 0, // bFunctionProtocol |
DieterGraef | 0:0a2eaa300982 | 207 | 0, // iFunction |
DieterGraef | 0:0a2eaa300982 | 208 | |
DieterGraef | 0:0a2eaa300982 | 209 | // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 |
DieterGraef | 0:0a2eaa300982 | 210 | 9, // bLength |
DieterGraef | 0:0a2eaa300982 | 211 | 4, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 212 | 0, // bInterfaceNumber |
DieterGraef | 0:0a2eaa300982 | 213 | 0, // bAlternateSetting |
DieterGraef | 0:0a2eaa300982 | 214 | 1, // bNumEndpoints |
DieterGraef | 0:0a2eaa300982 | 215 | 0x02, // bInterfaceClass |
DieterGraef | 0:0a2eaa300982 | 216 | 0x02, // bInterfaceSubClass |
DieterGraef | 0:0a2eaa300982 | 217 | 0x01, // bInterfaceProtocol |
DieterGraef | 0:0a2eaa300982 | 218 | 0, // iInterface |
DieterGraef | 0:0a2eaa300982 | 219 | |
DieterGraef | 0:0a2eaa300982 | 220 | // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26 |
DieterGraef | 0:0a2eaa300982 | 221 | 5, // bFunctionLength |
DieterGraef | 0:0a2eaa300982 | 222 | 0x24, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 223 | 0x00, // bDescriptorSubtype |
DieterGraef | 0:0a2eaa300982 | 224 | 0x10, 0x01, // bcdCDC |
DieterGraef | 0:0a2eaa300982 | 225 | |
DieterGraef | 0:0a2eaa300982 | 226 | // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27 |
DieterGraef | 0:0a2eaa300982 | 227 | 5, // bFunctionLength |
DieterGraef | 0:0a2eaa300982 | 228 | 0x24, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 229 | 0x01, // bDescriptorSubtype |
DieterGraef | 0:0a2eaa300982 | 230 | 0x03, // bmCapabilities |
DieterGraef | 0:0a2eaa300982 | 231 | 1, // bDataInterface |
DieterGraef | 0:0a2eaa300982 | 232 | |
DieterGraef | 0:0a2eaa300982 | 233 | // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28 |
DieterGraef | 0:0a2eaa300982 | 234 | 4, // bFunctionLength |
DieterGraef | 0:0a2eaa300982 | 235 | 0x24, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 236 | 0x02, // bDescriptorSubtype |
DieterGraef | 0:0a2eaa300982 | 237 | 0x06, // bmCapabilities |
DieterGraef | 0:0a2eaa300982 | 238 | |
DieterGraef | 0:0a2eaa300982 | 239 | // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33 |
DieterGraef | 0:0a2eaa300982 | 240 | 5, // bFunctionLength |
DieterGraef | 0:0a2eaa300982 | 241 | 0x24, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 242 | 0x06, // bDescriptorSubtype |
DieterGraef | 0:0a2eaa300982 | 243 | 0, // bMasterInterface |
DieterGraef | 0:0a2eaa300982 | 244 | 1, // bSlaveInterface0 |
DieterGraef | 0:0a2eaa300982 | 245 | |
DieterGraef | 0:0a2eaa300982 | 246 | // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 |
DieterGraef | 0:0a2eaa300982 | 247 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
DieterGraef | 0:0a2eaa300982 | 248 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 249 | PHY_TO_DESC(EPINT_IN), // bEndpointAddress |
DieterGraef | 0:0a2eaa300982 | 250 | E_INTERRUPT, // bmAttributes (0x03=intr) |
DieterGraef | 0:0a2eaa300982 | 251 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
DieterGraef | 0:0a2eaa300982 | 252 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
DieterGraef | 0:0a2eaa300982 | 253 | 16, // bInterval |
DieterGraef | 0:0a2eaa300982 | 254 | |
DieterGraef | 0:0a2eaa300982 | 255 | |
DieterGraef | 0:0a2eaa300982 | 256 | |
DieterGraef | 0:0a2eaa300982 | 257 | |
DieterGraef | 0:0a2eaa300982 | 258 | // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 |
DieterGraef | 0:0a2eaa300982 | 259 | 9, // bLength |
DieterGraef | 0:0a2eaa300982 | 260 | 4, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 261 | 1, // bInterfaceNumber |
DieterGraef | 0:0a2eaa300982 | 262 | 0, // bAlternateSetting |
DieterGraef | 0:0a2eaa300982 | 263 | 2, // bNumEndpoints |
DieterGraef | 0:0a2eaa300982 | 264 | 0x0A, // bInterfaceClass |
DieterGraef | 0:0a2eaa300982 | 265 | 0x00, // bInterfaceSubClass |
DieterGraef | 0:0a2eaa300982 | 266 | 0x00, // bInterfaceProtocol |
DieterGraef | 0:0a2eaa300982 | 267 | 0, // iInterface |
DieterGraef | 0:0a2eaa300982 | 268 | |
DieterGraef | 0:0a2eaa300982 | 269 | // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 |
DieterGraef | 0:0a2eaa300982 | 270 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
DieterGraef | 0:0a2eaa300982 | 271 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 272 | PHY_TO_DESC(EPBULK_IN), // bEndpointAddress |
DieterGraef | 0:0a2eaa300982 | 273 | E_BULK, // bmAttributes (0x02=bulk) |
DieterGraef | 0:0a2eaa300982 | 274 | LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB) |
DieterGraef | 0:0a2eaa300982 | 275 | MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB) |
DieterGraef | 0:0a2eaa300982 | 276 | 0, // bInterval |
DieterGraef | 0:0a2eaa300982 | 277 | |
DieterGraef | 0:0a2eaa300982 | 278 | // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 |
DieterGraef | 0:0a2eaa300982 | 279 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
DieterGraef | 0:0a2eaa300982 | 280 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
DieterGraef | 0:0a2eaa300982 | 281 | PHY_TO_DESC(EPBULK_OUT), // bEndpointAddress |
DieterGraef | 0:0a2eaa300982 | 282 | E_BULK, // bmAttributes (0x02=bulk) |
DieterGraef | 0:0a2eaa300982 | 283 | LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB) |
DieterGraef | 0:0a2eaa300982 | 284 | MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB) |
DieterGraef | 0:0a2eaa300982 | 285 | 0 // bInterval |
DieterGraef | 0:0a2eaa300982 | 286 | }; |
DieterGraef | 0:0a2eaa300982 | 287 | return configDescriptor; |
DieterGraef | 0:0a2eaa300982 | 288 | } |