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