Pinscape Controller version 1 fork. This is a fork to allow for ongoing bug fixes to the original controller version, from before the major changes for the expansion board project.
Dependencies: FastIO FastPWM SimpleDMA mbed
Fork of Pinscape_Controller by
USBDevice/USBHID/USBHID.cpp@68:edfecf67a931, 2016-02-15 (annotated)
- Committer:
- mjr
- Date:
- Mon Feb 15 23:03:55 2016 +0000
- Revision:
- 68:edfecf67a931
- Parent:
- 55:e47a4b7ab348
Finalize USB library updates to fix compatibility problems introduced in USBHAL_KL25Z overhaul.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mjr | 52:63f0a9b45f0c | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
mjr | 52:63f0a9b45f0c | 2 | * |
mjr | 52:63f0a9b45f0c | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
mjr | 52:63f0a9b45f0c | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
mjr | 52:63f0a9b45f0c | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
mjr | 52:63f0a9b45f0c | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
mjr | 52:63f0a9b45f0c | 7 | * Software is furnished to do so, subject to the following conditions: |
mjr | 52:63f0a9b45f0c | 8 | * |
mjr | 52:63f0a9b45f0c | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
mjr | 52:63f0a9b45f0c | 10 | * substantial portions of the Software. |
mjr | 52:63f0a9b45f0c | 11 | * |
mjr | 52:63f0a9b45f0c | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
mjr | 52:63f0a9b45f0c | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
mjr | 52:63f0a9b45f0c | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
mjr | 52:63f0a9b45f0c | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
mjr | 52:63f0a9b45f0c | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
mjr | 52:63f0a9b45f0c | 17 | */ |
mjr | 52:63f0a9b45f0c | 18 | |
mjr | 52:63f0a9b45f0c | 19 | #include "stdint.h" |
mjr | 52:63f0a9b45f0c | 20 | #include "USBHAL.h" |
mjr | 52:63f0a9b45f0c | 21 | #include "USBHID.h" |
mjr | 52:63f0a9b45f0c | 22 | |
mjr | 52:63f0a9b45f0c | 23 | |
mjr | 52:63f0a9b45f0c | 24 | USBHID::USBHID(uint8_t output_report_length, uint8_t input_report_length, uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect): USBDevice(vendor_id, product_id, product_release) |
mjr | 52:63f0a9b45f0c | 25 | { |
mjr | 52:63f0a9b45f0c | 26 | output_length = output_report_length; |
mjr | 52:63f0a9b45f0c | 27 | input_length = input_report_length; |
mjr | 52:63f0a9b45f0c | 28 | if(connect) { |
mjr | 52:63f0a9b45f0c | 29 | USBDevice::connect(); |
mjr | 52:63f0a9b45f0c | 30 | } |
mjr | 52:63f0a9b45f0c | 31 | } |
mjr | 52:63f0a9b45f0c | 32 | |
mjr | 52:63f0a9b45f0c | 33 | |
mjr | 52:63f0a9b45f0c | 34 | bool USBHID::send(HID_REPORT *report) |
mjr | 52:63f0a9b45f0c | 35 | { |
mjr | 52:63f0a9b45f0c | 36 | return write(EPINT_IN, report->data, report->length, MAX_HID_REPORT_SIZE); |
mjr | 52:63f0a9b45f0c | 37 | } |
mjr | 52:63f0a9b45f0c | 38 | |
mjr | 52:63f0a9b45f0c | 39 | bool USBHID::sendNB(HID_REPORT *report) |
mjr | 52:63f0a9b45f0c | 40 | { |
mjr | 52:63f0a9b45f0c | 41 | return writeNB(EPINT_IN, report->data, report->length, MAX_HID_REPORT_SIZE); |
mjr | 52:63f0a9b45f0c | 42 | } |
mjr | 52:63f0a9b45f0c | 43 | |
mjr | 52:63f0a9b45f0c | 44 | bool USBHID::sendTO(HID_REPORT *report, int timeout_ms) |
mjr | 52:63f0a9b45f0c | 45 | { |
mjr | 52:63f0a9b45f0c | 46 | return writeTO(EPINT_IN, report->data, report->length, MAX_HID_REPORT_SIZE, timeout_ms); |
mjr | 52:63f0a9b45f0c | 47 | } |
mjr | 52:63f0a9b45f0c | 48 | |
mjr | 52:63f0a9b45f0c | 49 | |
mjr | 52:63f0a9b45f0c | 50 | bool USBHID::read(HID_REPORT *report) |
mjr | 52:63f0a9b45f0c | 51 | { |
mjr | 52:63f0a9b45f0c | 52 | uint32_t bytesRead = 0; |
mjr | 52:63f0a9b45f0c | 53 | bool result; |
mjr | 52:63f0a9b45f0c | 54 | result = USBDevice::readEP(EPINT_OUT, report->data, &bytesRead, MAX_HID_REPORT_SIZE); |
mjr | 52:63f0a9b45f0c | 55 | if(!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE)) |
mjr | 52:63f0a9b45f0c | 56 | return false; |
mjr | 52:63f0a9b45f0c | 57 | report->length = bytesRead; |
mjr | 52:63f0a9b45f0c | 58 | return result; |
mjr | 52:63f0a9b45f0c | 59 | } |
mjr | 52:63f0a9b45f0c | 60 | |
mjr | 52:63f0a9b45f0c | 61 | |
mjr | 52:63f0a9b45f0c | 62 | bool USBHID::readNB(HID_REPORT *report) |
mjr | 52:63f0a9b45f0c | 63 | { |
mjr | 52:63f0a9b45f0c | 64 | uint32_t bytesRead = 0; |
mjr | 52:63f0a9b45f0c | 65 | bool result; |
mjr | 52:63f0a9b45f0c | 66 | result = USBDevice::readEP_NB(EPINT_OUT, report->data, &bytesRead, MAX_HID_REPORT_SIZE); |
mjr | 52:63f0a9b45f0c | 67 | // if readEP_NB did not succeed, does not issue a readStart |
mjr | 52:63f0a9b45f0c | 68 | if (!result) |
mjr | 52:63f0a9b45f0c | 69 | return false; |
mjr | 52:63f0a9b45f0c | 70 | report->length = bytesRead; |
mjr | 52:63f0a9b45f0c | 71 | if(!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE)) |
mjr | 52:63f0a9b45f0c | 72 | return false; |
mjr | 52:63f0a9b45f0c | 73 | return result; |
mjr | 52:63f0a9b45f0c | 74 | } |
mjr | 52:63f0a9b45f0c | 75 | |
mjr | 52:63f0a9b45f0c | 76 | |
mjr | 52:63f0a9b45f0c | 77 | uint16_t USBHID::reportDescLength() { |
mjr | 52:63f0a9b45f0c | 78 | reportDesc(); |
mjr | 52:63f0a9b45f0c | 79 | return reportLength; |
mjr | 52:63f0a9b45f0c | 80 | } |
mjr | 52:63f0a9b45f0c | 81 | |
mjr | 52:63f0a9b45f0c | 82 | |
mjr | 52:63f0a9b45f0c | 83 | |
mjr | 52:63f0a9b45f0c | 84 | // |
mjr | 52:63f0a9b45f0c | 85 | // Route callbacks from lower layers to class(es) |
mjr | 52:63f0a9b45f0c | 86 | // |
mjr | 52:63f0a9b45f0c | 87 | |
mjr | 52:63f0a9b45f0c | 88 | |
mjr | 52:63f0a9b45f0c | 89 | // Called in ISR context |
mjr | 52:63f0a9b45f0c | 90 | // Called by USBDevice on Endpoint0 request |
mjr | 52:63f0a9b45f0c | 91 | // This is used to handle extensions to standard requests |
mjr | 52:63f0a9b45f0c | 92 | // and class specific requests |
mjr | 52:63f0a9b45f0c | 93 | // Return true if class handles this request |
mjr | 52:63f0a9b45f0c | 94 | bool USBHID::USBCallback_request() { |
mjr | 52:63f0a9b45f0c | 95 | bool success = false; |
mjr | 52:63f0a9b45f0c | 96 | CONTROL_TRANSFER * transfer = getTransferPtr(); |
mjr | 52:63f0a9b45f0c | 97 | uint8_t *hidDescriptor; |
mjr | 52:63f0a9b45f0c | 98 | |
mjr | 52:63f0a9b45f0c | 99 | // Process additional standard requests |
mjr | 52:63f0a9b45f0c | 100 | |
mjr | 52:63f0a9b45f0c | 101 | if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE)) |
mjr | 52:63f0a9b45f0c | 102 | { |
mjr | 52:63f0a9b45f0c | 103 | switch (transfer->setup.bRequest) |
mjr | 52:63f0a9b45f0c | 104 | { |
mjr | 52:63f0a9b45f0c | 105 | case GET_DESCRIPTOR: |
mjr | 52:63f0a9b45f0c | 106 | switch (DESCRIPTOR_TYPE(transfer->setup.wValue)) |
mjr | 52:63f0a9b45f0c | 107 | { |
mjr | 52:63f0a9b45f0c | 108 | case REPORT_DESCRIPTOR: |
mjr | 52:63f0a9b45f0c | 109 | if ((reportDesc() != NULL) && (reportDescLength() != 0)) |
mjr | 52:63f0a9b45f0c | 110 | { |
mjr | 52:63f0a9b45f0c | 111 | // Get the interface index. In cases where one device exposes |
mjr | 52:63f0a9b45f0c | 112 | // multiple interfaces, this is used to identify which interface |
mjr | 52:63f0a9b45f0c | 113 | // is being queried. The base mbed implementation ignores this, |
mjr | 52:63f0a9b45f0c | 114 | // which makes it impossible to implement multiple interfaces. |
mjr | 53:02408ec83097 | 115 | int idx = transfer->setup.wIndex; |
mjr | 52:63f0a9b45f0c | 116 | transfer->remaining = reportDescLengthN(idx); |
mjr | 52:63f0a9b45f0c | 117 | transfer->ptr = reportDescN(idx); |
mjr | 52:63f0a9b45f0c | 118 | transfer->direction = DEVICE_TO_HOST; |
mjr | 52:63f0a9b45f0c | 119 | success = true; |
mjr | 52:63f0a9b45f0c | 120 | } |
mjr | 52:63f0a9b45f0c | 121 | break; |
mjr | 52:63f0a9b45f0c | 122 | case HID_DESCRIPTOR: |
mjr | 52:63f0a9b45f0c | 123 | // Find the HID descriptor, after the configuration descriptor |
mjr | 53:02408ec83097 | 124 | hidDescriptor = findDescriptor(HID_DESCRIPTOR, transfer->setup.wIndex); |
mjr | 52:63f0a9b45f0c | 125 | if (hidDescriptor != NULL) |
mjr | 52:63f0a9b45f0c | 126 | { |
mjr | 52:63f0a9b45f0c | 127 | transfer->remaining = HID_DESCRIPTOR_LENGTH; |
mjr | 52:63f0a9b45f0c | 128 | transfer->ptr = hidDescriptor; |
mjr | 52:63f0a9b45f0c | 129 | transfer->direction = DEVICE_TO_HOST; |
mjr | 52:63f0a9b45f0c | 130 | success = true; |
mjr | 52:63f0a9b45f0c | 131 | } |
mjr | 53:02408ec83097 | 132 | break; |
mjr | 52:63f0a9b45f0c | 133 | |
mjr | 52:63f0a9b45f0c | 134 | default: |
mjr | 52:63f0a9b45f0c | 135 | break; |
mjr | 52:63f0a9b45f0c | 136 | } |
mjr | 52:63f0a9b45f0c | 137 | break; |
mjr | 52:63f0a9b45f0c | 138 | default: |
mjr | 52:63f0a9b45f0c | 139 | break; |
mjr | 52:63f0a9b45f0c | 140 | } |
mjr | 52:63f0a9b45f0c | 141 | } |
mjr | 52:63f0a9b45f0c | 142 | |
mjr | 52:63f0a9b45f0c | 143 | // Process class-specific requests |
mjr | 52:63f0a9b45f0c | 144 | |
mjr | 52:63f0a9b45f0c | 145 | if (transfer->setup.bmRequestType.Type == CLASS_TYPE) |
mjr | 52:63f0a9b45f0c | 146 | { |
mjr | 52:63f0a9b45f0c | 147 | switch (transfer->setup.bRequest) |
mjr | 52:63f0a9b45f0c | 148 | { |
mjr | 55:e47a4b7ab348 | 149 | case GET_REPORT: |
mjr | 55:e47a4b7ab348 | 150 | // not implemented |
mjr | 55:e47a4b7ab348 | 151 | break; |
mjr | 55:e47a4b7ab348 | 152 | |
mjr | 55:e47a4b7ab348 | 153 | case GET_IDLE: |
mjr | 55:e47a4b7ab348 | 154 | // retrieve the idle rate from an interface |
mjr | 55:e47a4b7ab348 | 155 | idleData = getIdleTime(transfer->setup.wIndex, LSB(transfer->setup.wValue)); |
mjr | 55:e47a4b7ab348 | 156 | transfer->ptr = &idleData; |
mjr | 55:e47a4b7ab348 | 157 | transfer->remaining = 1; |
mjr | 55:e47a4b7ab348 | 158 | transfer->direction = DEVICE_TO_HOST; |
mjr | 55:e47a4b7ab348 | 159 | success = true; |
mjr | 55:e47a4b7ab348 | 160 | break; |
mjr | 55:e47a4b7ab348 | 161 | |
mjr | 55:e47a4b7ab348 | 162 | case GET_PROTOCOL: |
mjr | 55:e47a4b7ab348 | 163 | // not implemented |
mjr | 55:e47a4b7ab348 | 164 | break; |
mjr | 55:e47a4b7ab348 | 165 | |
mjr | 53:02408ec83097 | 166 | case SET_REPORT: |
mjr | 52:63f0a9b45f0c | 167 | // First byte will be used for report ID |
mjr | 52:63f0a9b45f0c | 168 | outputReport.data[0] = transfer->setup.wValue & 0xff; |
mjr | 52:63f0a9b45f0c | 169 | outputReport.length = transfer->setup.wLength + 1; |
mjr | 52:63f0a9b45f0c | 170 | |
mjr | 52:63f0a9b45f0c | 171 | transfer->remaining = sizeof(outputReport.data) - 1; |
mjr | 52:63f0a9b45f0c | 172 | transfer->ptr = &outputReport.data[1]; |
mjr | 52:63f0a9b45f0c | 173 | transfer->direction = HOST_TO_DEVICE; |
mjr | 52:63f0a9b45f0c | 174 | transfer->notify = true; |
mjr | 52:63f0a9b45f0c | 175 | success = true; |
mjr | 55:e47a4b7ab348 | 176 | break; |
mjr | 68:edfecf67a931 | 177 | |
mjr | 55:e47a4b7ab348 | 178 | case SET_IDLE: |
mjr | 55:e47a4b7ab348 | 179 | // Set idle time - time between INTERRUPT IN reports from the |
mjr | 55:e47a4b7ab348 | 180 | // device when there are no changes to report. setup.wIndex |
mjr | 55:e47a4b7ab348 | 181 | // is the interface index (we're setting the idle time for the |
mjr | 55:e47a4b7ab348 | 182 | // given interface only). MSB(setup.wValue) gives the interval |
mjr | 55:e47a4b7ab348 | 183 | // in 4ms units, with the special case that 0 means infinity. |
mjr | 55:e47a4b7ab348 | 184 | setIdleTime(transfer->setup.wIndex, LSB(transfer->setup.wValue), MSB(transfer->setup.wValue)); |
mjr | 55:e47a4b7ab348 | 185 | transfer->remaining = 0; |
mjr | 55:e47a4b7ab348 | 186 | transfer->direction = DEVICE_TO_HOST; |
mjr | 55:e47a4b7ab348 | 187 | success = true; |
mjr | 68:edfecf67a931 | 188 | break; |
mjr | 55:e47a4b7ab348 | 189 | |
mjr | 55:e47a4b7ab348 | 190 | case SET_PROTOCOL: |
mjr | 55:e47a4b7ab348 | 191 | // not implemented |
mjr | 55:e47a4b7ab348 | 192 | break; |
mjr | 55:e47a4b7ab348 | 193 | |
mjr | 52:63f0a9b45f0c | 194 | default: |
mjr | 52:63f0a9b45f0c | 195 | break; |
mjr | 52:63f0a9b45f0c | 196 | } |
mjr | 52:63f0a9b45f0c | 197 | } |
mjr | 52:63f0a9b45f0c | 198 | |
mjr | 52:63f0a9b45f0c | 199 | return success; |
mjr | 52:63f0a9b45f0c | 200 | } |
mjr | 52:63f0a9b45f0c | 201 | |
mjr | 52:63f0a9b45f0c | 202 | |
mjr | 52:63f0a9b45f0c | 203 | #define DEFAULT_CONFIGURATION (1) |
mjr | 52:63f0a9b45f0c | 204 | |
mjr | 52:63f0a9b45f0c | 205 | |
mjr | 52:63f0a9b45f0c | 206 | // Called in ISR context |
mjr | 52:63f0a9b45f0c | 207 | // Set configuration. Return false if the |
mjr | 52:63f0a9b45f0c | 208 | // configuration is not supported |
mjr | 52:63f0a9b45f0c | 209 | bool USBHID::USBCallback_setConfiguration(uint8_t configuration) { |
mjr | 52:63f0a9b45f0c | 210 | if (configuration != DEFAULT_CONFIGURATION) { |
mjr | 52:63f0a9b45f0c | 211 | return false; |
mjr | 52:63f0a9b45f0c | 212 | } |
mjr | 52:63f0a9b45f0c | 213 | |
mjr | 52:63f0a9b45f0c | 214 | // Configure endpoints > 0 |
mjr | 52:63f0a9b45f0c | 215 | addEndpoint(EPINT_IN, MAX_PACKET_SIZE_EPINT); |
mjr | 52:63f0a9b45f0c | 216 | addEndpoint(EPINT_OUT, MAX_PACKET_SIZE_EPINT); |
mjr | 52:63f0a9b45f0c | 217 | |
mjr | 52:63f0a9b45f0c | 218 | // We activate the endpoint to be able to recceive data |
mjr | 52:63f0a9b45f0c | 219 | readStart(EPINT_OUT, MAX_PACKET_SIZE_EPINT); |
mjr | 52:63f0a9b45f0c | 220 | return true; |
mjr | 52:63f0a9b45f0c | 221 | } |
mjr | 52:63f0a9b45f0c | 222 | |
mjr | 52:63f0a9b45f0c | 223 | |
mjr | 52:63f0a9b45f0c | 224 | uint8_t * USBHID::stringIinterfaceDesc() { |
mjr | 52:63f0a9b45f0c | 225 | static uint8_t stringIinterfaceDescriptor[] = { |
mjr | 52:63f0a9b45f0c | 226 | 0x08, //bLength |
mjr | 52:63f0a9b45f0c | 227 | STRING_DESCRIPTOR, //bDescriptorType 0x03 |
mjr | 52:63f0a9b45f0c | 228 | 'H',0,'I',0,'D',0, //bString iInterface - HID |
mjr | 52:63f0a9b45f0c | 229 | }; |
mjr | 52:63f0a9b45f0c | 230 | return stringIinterfaceDescriptor; |
mjr | 52:63f0a9b45f0c | 231 | } |
mjr | 52:63f0a9b45f0c | 232 | |
mjr | 52:63f0a9b45f0c | 233 | uint8_t * USBHID::stringIproductDesc() { |
mjr | 52:63f0a9b45f0c | 234 | static uint8_t stringIproductDescriptor[] = { |
mjr | 52:63f0a9b45f0c | 235 | 0x16, //bLength |
mjr | 52:63f0a9b45f0c | 236 | STRING_DESCRIPTOR, //bDescriptorType 0x03 |
mjr | 52:63f0a9b45f0c | 237 | 'H',0,'I',0,'D',0,' ',0,'D',0,'E',0,'V',0,'I',0,'C',0,'E',0 //bString iProduct - HID device |
mjr | 52:63f0a9b45f0c | 238 | }; |
mjr | 52:63f0a9b45f0c | 239 | return stringIproductDescriptor; |
mjr | 52:63f0a9b45f0c | 240 | } |
mjr | 52:63f0a9b45f0c | 241 | |
mjr | 52:63f0a9b45f0c | 242 | |
mjr | 52:63f0a9b45f0c | 243 | |
mjr | 52:63f0a9b45f0c | 244 | uint8_t * USBHID::reportDesc() { |
mjr | 52:63f0a9b45f0c | 245 | static uint8_t reportDescriptor[] = { |
mjr | 52:63f0a9b45f0c | 246 | 0x06, LSB(0xFFAB), MSB(0xFFAB), |
mjr | 52:63f0a9b45f0c | 247 | 0x0A, LSB(0x0200), MSB(0x0200), |
mjr | 52:63f0a9b45f0c | 248 | 0xA1, 0x01, // Collection 0x01 |
mjr | 52:63f0a9b45f0c | 249 | 0x75, 0x08, // report size = 8 bits |
mjr | 52:63f0a9b45f0c | 250 | 0x15, 0x00, // logical minimum = 0 |
mjr | 52:63f0a9b45f0c | 251 | 0x26, 0xFF, 0x00, // logical maximum = 255 |
mjr | 52:63f0a9b45f0c | 252 | 0x95, input_length, // report count |
mjr | 52:63f0a9b45f0c | 253 | 0x09, 0x01, // usage |
mjr | 52:63f0a9b45f0c | 254 | 0x81, 0x02, // Input (array) |
mjr | 52:63f0a9b45f0c | 255 | 0x95, output_length,// report count |
mjr | 52:63f0a9b45f0c | 256 | 0x09, 0x02, // usage |
mjr | 52:63f0a9b45f0c | 257 | 0x91, 0x02, // Output (array) |
mjr | 52:63f0a9b45f0c | 258 | 0xC0 // end collection |
mjr | 52:63f0a9b45f0c | 259 | |
mjr | 52:63f0a9b45f0c | 260 | }; |
mjr | 52:63f0a9b45f0c | 261 | reportLength = sizeof(reportDescriptor); |
mjr | 52:63f0a9b45f0c | 262 | return reportDescriptor; |
mjr | 52:63f0a9b45f0c | 263 | } |
mjr | 52:63f0a9b45f0c | 264 | |
mjr | 52:63f0a9b45f0c | 265 | #define DEFAULT_CONFIGURATION (1) |
mjr | 52:63f0a9b45f0c | 266 | #define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ |
mjr | 52:63f0a9b45f0c | 267 | + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ |
mjr | 52:63f0a9b45f0c | 268 | + (1 * HID_DESCRIPTOR_LENGTH) \ |
mjr | 52:63f0a9b45f0c | 269 | + (2 * ENDPOINT_DESCRIPTOR_LENGTH)) |
mjr | 52:63f0a9b45f0c | 270 | |
mjr | 52:63f0a9b45f0c | 271 | uint8_t * USBHID::configurationDesc() { |
mjr | 52:63f0a9b45f0c | 272 | static uint8_t configurationDescriptor[] = { |
mjr | 52:63f0a9b45f0c | 273 | CONFIGURATION_DESCRIPTOR_LENGTH,// bLength |
mjr | 52:63f0a9b45f0c | 274 | CONFIGURATION_DESCRIPTOR, // bDescriptorType |
mjr | 52:63f0a9b45f0c | 275 | LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) |
mjr | 52:63f0a9b45f0c | 276 | MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) |
mjr | 52:63f0a9b45f0c | 277 | 0x01, // bNumInterfaces |
mjr | 52:63f0a9b45f0c | 278 | DEFAULT_CONFIGURATION, // bConfigurationValue |
mjr | 52:63f0a9b45f0c | 279 | 0x00, // iConfiguration |
mjr | 52:63f0a9b45f0c | 280 | C_RESERVED | C_SELF_POWERED, // bmAttributes |
mjr | 52:63f0a9b45f0c | 281 | C_POWER(0), // bMaxPower |
mjr | 52:63f0a9b45f0c | 282 | |
mjr | 52:63f0a9b45f0c | 283 | INTERFACE_DESCRIPTOR_LENGTH, // bLength |
mjr | 52:63f0a9b45f0c | 284 | INTERFACE_DESCRIPTOR, // bDescriptorType |
mjr | 52:63f0a9b45f0c | 285 | 0x00, // bInterfaceNumber |
mjr | 52:63f0a9b45f0c | 286 | 0x00, // bAlternateSetting |
mjr | 52:63f0a9b45f0c | 287 | 0x02, // bNumEndpoints |
mjr | 52:63f0a9b45f0c | 288 | HID_CLASS, // bInterfaceClass |
mjr | 52:63f0a9b45f0c | 289 | HID_SUBCLASS_NONE, // bInterfaceSubClass |
mjr | 52:63f0a9b45f0c | 290 | HID_PROTOCOL_NONE, // bInterfaceProtocol |
mjr | 52:63f0a9b45f0c | 291 | 0x00, // iInterface |
mjr | 52:63f0a9b45f0c | 292 | |
mjr | 52:63f0a9b45f0c | 293 | HID_DESCRIPTOR_LENGTH, // bLength |
mjr | 52:63f0a9b45f0c | 294 | HID_DESCRIPTOR, // bDescriptorType |
mjr | 52:63f0a9b45f0c | 295 | LSB(HID_VERSION_1_11), // bcdHID (LSB) |
mjr | 52:63f0a9b45f0c | 296 | MSB(HID_VERSION_1_11), // bcdHID (MSB) |
mjr | 52:63f0a9b45f0c | 297 | 0x00, // bCountryCode |
mjr | 52:63f0a9b45f0c | 298 | 0x01, // bNumDescriptors |
mjr | 52:63f0a9b45f0c | 299 | REPORT_DESCRIPTOR, // bDescriptorType |
mjr | 52:63f0a9b45f0c | 300 | (uint8_t)(LSB(this->reportDescLength())), // wDescriptorLength (LSB) |
mjr | 52:63f0a9b45f0c | 301 | (uint8_t)(MSB(this->reportDescLength())), // wDescriptorLength (MSB) |
mjr | 52:63f0a9b45f0c | 302 | |
mjr | 52:63f0a9b45f0c | 303 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
mjr | 52:63f0a9b45f0c | 304 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
mjr | 52:63f0a9b45f0c | 305 | PHY_TO_DESC(EPINT_IN), // bEndpointAddress |
mjr | 52:63f0a9b45f0c | 306 | E_INTERRUPT, // bmAttributes |
mjr | 52:63f0a9b45f0c | 307 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
mjr | 52:63f0a9b45f0c | 308 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
mjr | 52:63f0a9b45f0c | 309 | 1, // bInterval (milliseconds) |
mjr | 52:63f0a9b45f0c | 310 | |
mjr | 52:63f0a9b45f0c | 311 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
mjr | 52:63f0a9b45f0c | 312 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
mjr | 52:63f0a9b45f0c | 313 | PHY_TO_DESC(EPINT_OUT), // bEndpointAddress |
mjr | 52:63f0a9b45f0c | 314 | E_INTERRUPT, // bmAttributes |
mjr | 52:63f0a9b45f0c | 315 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
mjr | 52:63f0a9b45f0c | 316 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
mjr | 52:63f0a9b45f0c | 317 | 1, // bInterval (milliseconds) |
mjr | 52:63f0a9b45f0c | 318 | }; |
mjr | 52:63f0a9b45f0c | 319 | return configurationDescriptor; |
mjr | 52:63f0a9b45f0c | 320 | } |