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
USBDevice/USBDescriptor.h@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 | /* Standard descriptor types */ |
DieterGraef | 0:0a2eaa300982 | 20 | #define DEVICE_DESCRIPTOR (1) |
DieterGraef | 0:0a2eaa300982 | 21 | #define CONFIGURATION_DESCRIPTOR (2) |
DieterGraef | 0:0a2eaa300982 | 22 | #define STRING_DESCRIPTOR (3) |
DieterGraef | 0:0a2eaa300982 | 23 | #define INTERFACE_DESCRIPTOR (4) |
DieterGraef | 0:0a2eaa300982 | 24 | #define ENDPOINT_DESCRIPTOR (5) |
DieterGraef | 0:0a2eaa300982 | 25 | #define QUALIFIER_DESCRIPTOR (6) |
DieterGraef | 0:0a2eaa300982 | 26 | |
DieterGraef | 0:0a2eaa300982 | 27 | /* Standard descriptor lengths */ |
DieterGraef | 0:0a2eaa300982 | 28 | #define DEVICE_DESCRIPTOR_LENGTH (0x12) |
DieterGraef | 0:0a2eaa300982 | 29 | #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09) |
DieterGraef | 0:0a2eaa300982 | 30 | #define INTERFACE_DESCRIPTOR_LENGTH (0x09) |
DieterGraef | 0:0a2eaa300982 | 31 | #define ENDPOINT_DESCRIPTOR_LENGTH (0x07) |
DieterGraef | 0:0a2eaa300982 | 32 | |
DieterGraef | 0:0a2eaa300982 | 33 | |
DieterGraef | 0:0a2eaa300982 | 34 | /*string offset*/ |
DieterGraef | 0:0a2eaa300982 | 35 | #define STRING_OFFSET_LANGID (0) |
DieterGraef | 0:0a2eaa300982 | 36 | #define STRING_OFFSET_IMANUFACTURER (1) |
DieterGraef | 0:0a2eaa300982 | 37 | #define STRING_OFFSET_IPRODUCT (2) |
DieterGraef | 0:0a2eaa300982 | 38 | #define STRING_OFFSET_ISERIAL (3) |
DieterGraef | 0:0a2eaa300982 | 39 | #define STRING_OFFSET_ICONFIGURATION (4) |
DieterGraef | 0:0a2eaa300982 | 40 | #define STRING_OFFSET_IINTERFACE (5) |
DieterGraef | 0:0a2eaa300982 | 41 | |
DieterGraef | 0:0a2eaa300982 | 42 | /* USB Specification Release Number */ |
DieterGraef | 0:0a2eaa300982 | 43 | #define USB_VERSION_1_0 (0x0101) |
DieterGraef | 0:0a2eaa300982 | 44 | #define USB_VERSION_2_0 (0x0200) |
DieterGraef | 0:0a2eaa300982 | 45 | |
DieterGraef | 0:0a2eaa300982 | 46 | /* Least/Most significant byte of short integer */ |
DieterGraef | 0:0a2eaa300982 | 47 | #define LSB(n) ((n)&0xff) |
DieterGraef | 0:0a2eaa300982 | 48 | #define MSB(n) (((n)&0xff00)>>8) |
DieterGraef | 0:0a2eaa300982 | 49 | |
DieterGraef | 0:0a2eaa300982 | 50 | /* Convert physical endpoint number to descriptor endpoint number */ |
DieterGraef | 0:0a2eaa300982 | 51 | #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0)) |
DieterGraef | 0:0a2eaa300982 | 52 | |
DieterGraef | 0:0a2eaa300982 | 53 | /* bmAttributes in configuration descriptor */ |
DieterGraef | 0:0a2eaa300982 | 54 | /* C_RESERVED must always be set */ |
DieterGraef | 0:0a2eaa300982 | 55 | #define C_RESERVED (1U<<7) |
DieterGraef | 0:0a2eaa300982 | 56 | #define C_SELF_POWERED (1U<<6) |
DieterGraef | 0:0a2eaa300982 | 57 | #define C_REMOTE_WAKEUP (1U<<5) |
DieterGraef | 0:0a2eaa300982 | 58 | |
DieterGraef | 0:0a2eaa300982 | 59 | /* bMaxPower in configuration descriptor */ |
DieterGraef | 0:0a2eaa300982 | 60 | #define C_POWER(mA) ((mA)/2) |
DieterGraef | 0:0a2eaa300982 | 61 | |
DieterGraef | 0:0a2eaa300982 | 62 | /* bmAttributes in endpoint descriptor */ |
DieterGraef | 0:0a2eaa300982 | 63 | #define E_CONTROL (0x00) |
DieterGraef | 0:0a2eaa300982 | 64 | #define E_ISOCHRONOUS (0x01) |
DieterGraef | 0:0a2eaa300982 | 65 | #define E_BULK (0x02) |
DieterGraef | 0:0a2eaa300982 | 66 | #define E_INTERRUPT (0x03) |
DieterGraef | 0:0a2eaa300982 | 67 | |
DieterGraef | 0:0a2eaa300982 | 68 | /* For isochronous endpoints only: */ |
DieterGraef | 0:0a2eaa300982 | 69 | #define E_NO_SYNCHRONIZATION (0x00) |
DieterGraef | 0:0a2eaa300982 | 70 | #define E_ASYNCHRONOUS (0x04) |
DieterGraef | 0:0a2eaa300982 | 71 | #define E_ADAPTIVE (0x08) |
DieterGraef | 0:0a2eaa300982 | 72 | #define E_SYNCHRONOUS (0x0C) |
DieterGraef | 0:0a2eaa300982 | 73 | #define E_DATA (0x00) |
DieterGraef | 0:0a2eaa300982 | 74 | #define E_FEEDBACK (0x10) |
DieterGraef | 0:0a2eaa300982 | 75 | #define E_IMPLICIT_FEEDBACK (0x20) |