sanguino/firmwares/arduino-usbserial/Descriptors.c

Fri, 17 Nov 2017 10:13:31 +0100

author
mdd
date
Fri, 17 Nov 2017 10:13:31 +0100
changeset 3
770b218a4931
parent 2
b373b0288715
permissions
-rw-r--r--

proper configuration, homing and planner optimization

2
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
1 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
2 LUFA Library
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
3 Copyright (C) Dean Camera, 2010.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
4
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
5 dean [at] fourwalledcubicle [dot] com
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
6 www.fourwalledcubicle.com
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
7 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
8
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
9 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
11
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
12 Permission to use, copy, modify, distribute, and sell this
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
13 software and its documentation for any purpose is hereby granted
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
14 without fee, provided that the above copyright notice appear in
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
15 all copies and that both that the copyright notice and this
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
16 permission notice and warranty disclaimer appear in supporting
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
17 documentation, and that the name of the author not be used in
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
18 advertising or publicity pertaining to distribution of the
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
19 software without specific, written prior permission.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
20
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
21 The author disclaim all warranties with regard to this
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
22 software, including all implied warranties of merchantability
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
23 and fitness. In no event shall the author be liable for any
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
24 special, indirect or consequential damages or any damages
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
25 whatsoever resulting from loss of use, data or profits, whether
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
26 in an action of contract, negligence or other tortious action,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
27 arising out of or in connection with the use or performance of
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
28 this software.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
29 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
30
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
31 /** \file
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
32 *
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
33 * USB Device Descriptors, for library use when in USB device mode. Descriptors are special
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
34 * computer-readable structures which the host requests upon device enumeration, to determine
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
35 * the device's capabilities and functions.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
36 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
37
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
38 #include "Descriptors.h"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
39
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
40 /* On some devices, there is a factory set internal serial number which can be automatically sent to the host as
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
41 * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
42 * This allows the host to track a device across insertions on different ports, allowing them to retain allocated
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
43 * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
44 * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
45 * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
46 * port location).
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
47 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
48 #if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
49 #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
50 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
51
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
52 /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
53 * device characteristics, including the supported USB version, control endpoint size and the
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
54 * number of device configurations. The descriptor is read out by the USB host when the enumeration
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
55 * process begins.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
56 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
57 USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
58 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
59 .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
60
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
61 .USBSpecification = VERSION_BCD(01.10),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
62 .Class = 0x02,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
63 .SubClass = 0x00,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
64 .Protocol = 0x00,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
65
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
66 .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
67
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
68 .VendorID = 0x03EB, // Atmel
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
69
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
70 .ProductID = 0x204B, // LUFA USB to Serial Demo Application
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
71 .ReleaseNumber = 0x0001,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
72
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
73 .ManufacturerStrIndex = 0x01,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
74 .ProductStrIndex = 0x02,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
75 .SerialNumStrIndex = USE_INTERNAL_SERIAL,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
76
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
77 .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
78 };
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
79
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
80 /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
81 * of the device in one of its supported configurations, including information about any device interfaces
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
82 * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
83 * a configuration so that the host may correctly communicate with the USB device.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
84 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
85 USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
86 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
87 .Config =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
88 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
89 .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
90
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
91 .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
92 .TotalInterfaces = 2,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
93
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
94 .ConfigurationNumber = 1,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
95 .ConfigurationStrIndex = NO_DESCRIPTOR,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
96
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
97 .ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
98
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
99 .MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
100 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
101
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
102 .CDC_CCI_Interface =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
103 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
104 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
105
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
106 .InterfaceNumber = 0,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
107 .AlternateSetting = 0,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
108
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
109 .TotalEndpoints = 1,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
110
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
111 .Class = 0x02,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
112 .SubClass = 0x02,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
113 .Protocol = 0x01,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
114
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
115 .InterfaceStrIndex = NO_DESCRIPTOR
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
116 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
117
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
118 .CDC_Functional_IntHeader =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
119 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
120 .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
121 .SubType = 0x00,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
122
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
123 .Data = {0x01, 0x10}
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
124 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
125
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
126 .CDC_Functional_AbstractControlManagement =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
127 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
128 .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
129 .SubType = 0x02,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
130
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
131 .Data = {0x06}
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
132 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
133
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
134 .CDC_Functional_Union =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
135 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
136 .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
137 .SubType = 0x06,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
138
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
139 .Data = {0x00, 0x01}
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
140 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
141
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
142 .CDC_NotificationEndpoint =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
143 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
144 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
145
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
146 .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
147 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
148 .EndpointSize = CDC_NOTIFICATION_EPSIZE,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
149 .PollingIntervalMS = 0xFF
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
150 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
151
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
152 .CDC_DCI_Interface =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
153 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
154 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
155
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
156 .InterfaceNumber = 1,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
157 .AlternateSetting = 0,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
158
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
159 .TotalEndpoints = 2,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
160
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
161 .Class = 0x0A,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
162 .SubClass = 0x00,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
163 .Protocol = 0x00,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
164
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
165 .InterfaceStrIndex = NO_DESCRIPTOR
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
166 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
167
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
168 .CDC_DataOutEndpoint =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
169 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
170 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
171
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
172 .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
173 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
174 .EndpointSize = CDC_TXRX_EPSIZE,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
175 .PollingIntervalMS = 0x01
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
176 },
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
177
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
178 .CDC_DataInEndpoint =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
179 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
180 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
181
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
182 .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
183 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
184 .EndpointSize = CDC_TXRX_EPSIZE,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
185 .PollingIntervalMS = 0x01
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
186 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
187 };
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
188
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
189 /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
190 * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
191 * via the language ID table available at USB.org what languages the device supports for its string descriptors.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
192 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
193 USB_Descriptor_String_t PROGMEM LanguageString =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
194 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
195 .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
196
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
197 .UnicodeString = {LANGUAGE_ID_ENG}
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
198 };
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
199
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
200 /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
201 * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
202 * Descriptor.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
203 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
204 USB_Descriptor_String_t PROGMEM ManufacturerString =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
205 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
206 .Header = {.Size = USB_STRING_LEN(24), .Type = DTYPE_String},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
207
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
208 .UnicodeString = L"Arduino (www.arduino.cc)"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
209 };
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
210
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
211 /** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
212 * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
213 * Descriptor.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
214 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
215 USB_Descriptor_String_t PROGMEM ProductString =
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
216 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
217 #if (ARDUINO_MODEL_PID == ARDUINO_UNO_PID)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
218 .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
219
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
220 .UnicodeString = L"Arduino Uno"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
221 #elif (ARDUINO_MODEL_PID == ARDUINO_MEGA2560_PID)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
222 .Header = {.Size = USB_STRING_LEN(17), .Type = DTYPE_String},
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
223
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
224 .UnicodeString = L"Arduino Mega 2560"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
225 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
226
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
227 };
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
228
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
229 /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
230 * documentation) by the application code so that the address and size of a requested descriptor can be given
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
231 * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
232 * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
233 * USB host.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
234 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
235 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
236 const uint8_t wIndex,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
237 void** const DescriptorAddress)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
238 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
239 const uint8_t DescriptorType = (wValue >> 8);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
240 const uint8_t DescriptorNumber = (wValue & 0xFF);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
241
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
242 void* Address = NULL;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
243 uint16_t Size = NO_DESCRIPTOR;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
244
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
245 switch (DescriptorType)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
246 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
247 case DTYPE_Device:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
248 Address = (void*)&DeviceDescriptor;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
249 Size = sizeof(USB_Descriptor_Device_t);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
250 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
251 case DTYPE_Configuration:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
252 Address = (void*)&ConfigurationDescriptor;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
253 Size = sizeof(USB_Descriptor_Configuration_t);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
254 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
255 case DTYPE_String:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
256 switch (DescriptorNumber)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
257 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
258 case 0x00:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
259 Address = (void*)&LanguageString;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
260 Size = pgm_read_byte(&LanguageString.Header.Size);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
261 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
262 case 0x01:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
263 Address = (void*)&ManufacturerString;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
264 Size = pgm_read_byte(&ManufacturerString.Header.Size);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
265 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
266 case 0x02:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
267 Address = (void*)&ProductString;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
268 Size = pgm_read_byte(&ProductString.Header.Size);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
269 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
270 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
271
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
272 break;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
273 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
274
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
275 *DescriptorAddress = Address;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
276 return Size;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
277 }

mercurial