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