Commit 4dcf881007757711016db70a54aa4a7d289cb54f

Authored by rguillom
1 parent 58268c72

Descripteurs au propre

lufa-master/PolytechLille/PAD/Descriptors.c
@@ -29,7 +29,6 @@ @@ -29,7 +29,6 @@
29 this software. 29 this software.
30 */ 30 */
31 31
32 -  
33 /** \file 32 /** \file
34 * 33 *
35 * USB Device Descriptors, for library use when in USB device mode. Descriptors are special 34 * USB Device Descriptors, for library use when in USB device mode. Descriptors are special
@@ -39,13 +38,10 @@ @@ -39,13 +38,10 @@
39 38
40 #include "Descriptors.h" 39 #include "Descriptors.h"
41 40
42 -//////////////////////////////////////////////////////////////////////////  
43 -  
44 -  
45 -/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage  
46 - * of the device in one of its supported configurations, including information about any device interfaces  
47 - * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting  
48 - * a configuration so that the host may correctly communicate with the USB device. 41 +/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
  42 + * device characteristics, including the supported USB version, control endpoint size and the
  43 + * number of device configurations. The descriptor is read out by the USB host when the enumeration
  44 + * process begins.
49 */ 45 */
50 const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor = 46 const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor =
51 { 47 {
@@ -58,8 +54,8 @@ const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor = @@ -58,8 +54,8 @@ const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor =
58 54
59 .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, 55 .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
60 56
61 - .VendorID = 0x04B4,  
62 - .ProductID = 0xFD11, 57 + .VendorID = 0x04B4, //A MODIFIER avec VendorID Carte
  58 + .ProductID = 0xFD11, //A MODIFIER
63 .ReleaseNumber = VERSION_BCD(2,0,0), 59 .ReleaseNumber = VERSION_BCD(2,0,0),
64 60
65 .ManufacturerStrIndex = STRING_ID_Manufacturer, 61 .ManufacturerStrIndex = STRING_ID_Manufacturer,
@@ -67,50 +63,58 @@ const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor = @@ -67,50 +63,58 @@ const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor =
67 .SerialNumStrIndex = STRING_ID_Serial, 63 .SerialNumStrIndex = STRING_ID_Serial,
68 64
69 .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS 65 .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
70 -  
71 -  
72 -////////////////////////////////////////////////////////////////////////////  
73 -  
74 - 66 +};
75 67
76 /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage 68 /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
77 * of the device in one of its supported configurations, including information about any device interfaces 69 * of the device in one of its supported configurations, including information about any device interfaces
78 * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting 70 * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
79 * a configuration so that the host may correctly communicate with the USB device. 71 * a configuration so that the host may correctly communicate with the USB device.
80 */ 72 */
81 -const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = 73 +const USB_Descriptor_Configuration_t PROGMEM RelayBoard_ConfigurationDescriptor =
82 { 74 {
83 .Config = 75 .Config =
84 { 76 {
85 .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, 77 .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
86 78
87 .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), 79 .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
88 - .TotalInterfaces = 2,// MODIF ICI (1 au début) 80 + .TotalInterfaces = 2,
89 81
90 .ConfigurationNumber = 1, 82 .ConfigurationNumber = 1,
91 .ConfigurationStrIndex = NO_DESCRIPTOR, 83 .ConfigurationStrIndex = NO_DESCRIPTOR,
92 84
93 - .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED), 85 + .ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
94 86
95 - .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) 87 + .MaxPowerConsumption = USB_CONFIG_POWER_MA(500)
96 }, 88 },
97 -////////////////////////////////////////////////////////////////////////////// AJOUT  
98 - .InterfaceOUT = 89 +
  90 + /* Description Interface SORTIE (LED)*/
  91 + .InferfaceOUT =
99 { 92 {
100 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 93 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
101 94
102 - .InterfaceNumber = INTERFACE_ID_InterfaceOUT, //pas sur mais presque  
103 - .AlternateSetting = 0x00, 95 + .InterfaceNumber = INTERFACE_ID_InterfaceOUT,
  96 + .AlternateSetting = 0,
104 97
105 .TotalEndpoints = 1, 98 .TotalEndpoints = 1,
106 99
107 - .Class = HID_CSCP_HIDClass,  
108 - .SubClass = HID_CSCP_BootSubclass,  
109 - .Protocol = HID_CSCP_KeyboardBootProtocol, 100 + .Class = USB_CSCP_VendorSpecificClass,
  101 + .SubClass = 0x00,
  102 + .Protocol = 0x00,
110 103
111 .InterfaceStrIndex = NO_DESCRIPTOR 104 .InterfaceStrIndex = NO_DESCRIPTOR
112 }, 105 },
  106 +
  107 + .HID_KeyboardHID =
  108 + {
  109 + .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
113 110
  111 + .HIDSpec = VERSION_BCD(1,1,1),
  112 + .CountryCode = 0x00,
  113 + .TotalReportDescriptors = 1,
  114 + .HIDReportType = HID_DTYPE_Report,
  115 + .HIDReportLength = sizeof(KeyboardReport)
  116 + },
  117 +
114 .ReportOUTEndpoint = 118 .ReportOUTEndpoint =
115 { 119 {
116 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 120 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
@@ -120,7 +124,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = @@ -120,7 +124,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
120 .EndpointSize = KEYBOARD_EPSIZE, 124 .EndpointSize = KEYBOARD_EPSIZE,
121 .PollingIntervalMS = 0x05 125 .PollingIntervalMS = 0x05
122 }, 126 },
123 -////////////////////////////////////////////////////////////////////////////// FIN AJOUT 127 +
  128 +
  129 + /* Description interface IN (Boutons)*/
124 .InterfaceIN = 130 .InterfaceIN =
125 { 131 {
126 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 132 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
@@ -137,7 +143,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = @@ -137,7 +143,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
137 .InterfaceStrIndex = NO_DESCRIPTOR 143 .InterfaceStrIndex = NO_DESCRIPTOR
138 }, 144 },
139 145
140 - .ReportINEndpoint1 = 146 + .ReportINEndpointBoutons =
141 { 147 {
142 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 148 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
143 149
@@ -147,7 +153,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = @@ -147,7 +153,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
147 .PollingIntervalMS = 0x05 153 .PollingIntervalMS = 0x05
148 }, 154 },
149 155
150 - .ReportINEndpoint2 = 156 + .ReportINEndpointJoysticks =
151 { 157 {
152 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 158 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
153 159
@@ -158,36 +164,6 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = @@ -158,36 +164,6 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
158 } 164 }
159 }; 165 };
160 166
161 -////////////////////////////////////////////////////////////////////////////////////////////////////////////  
162 -////////////////////////////////////////////////////////////////////////////////////////////////////////////  
163 -  
164 -/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests  
165 - * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate  
166 - * via the language ID table available at USB.org what languages the device supports for its string descriptors.  
167 - */  
168 -const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG);  
169 -  
170 -/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable  
171 - * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device  
172 - * Descriptor.  
173 - */  
174 -const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"LUFA Library");  
175 -  
176 -/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,  
177 - * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device  
178 - * Descriptor.  
179 - */  
180 -const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA Keyboard Demo");  
181 -  
182 -/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"  
183 - * documentation) by the application code so that the address and size of a requested descriptor can be given  
184 - * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function  
185 - * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the  
186 - * USB host.  
187 - */  
188 -  
189 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////  
190 -  
191 /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests 167 /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
192 * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate 168 * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
193 * via the language ID table available at USB.org what languages the device supports for its string descriptors. 169 * via the language ID table available at USB.org what languages the device supports for its string descriptors.
@@ -222,12 +198,6 @@ const USB_Descriptor_String_t PROGMEM RelayBoard_SerialString = USB_STRING_DESCR @@ -222,12 +198,6 @@ const USB_Descriptor_String_t PROGMEM RelayBoard_SerialString = USB_STRING_DESCR
222 * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the 198 * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
223 * USB host. 199 * USB host.
224 */ 200 */
225 -  
226 -  
227 -  
228 -  
229 -////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
230 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////  
231 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 201 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
232 const uint16_t wIndex, 202 const uint16_t wIndex,
233 const void** const DescriptorAddress) 203 const void** const DescriptorAddress)
@@ -241,67 +211,6 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, @@ -241,67 +211,6 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
241 switch (DescriptorType) 211 switch (DescriptorType)
242 { 212 {
243 case DTYPE_Device: 213 case DTYPE_Device:
244 - Address = &DeviceDescriptor;  
245 - Size = sizeof(USB_Descriptor_Device_t);  
246 - break;  
247 - case DTYPE_Configuration:  
248 - Address = &ConfigurationDescriptor;  
249 - Size = sizeof(USB_Descriptor_Configuration_t);  
250 - break;  
251 - case DTYPE_String:  
252 - switch (DescriptorNumber)  
253 - {  
254 - case STRING_ID_Language:  
255 - Address = &LanguageString;  
256 - Size = pgm_read_byte(&LanguageString.Header.Size);  
257 - break;  
258 - case STRING_ID_Manufacturer:  
259 - Address = &ManufacturerString;  
260 - Size = pgm_read_byte(&ManufacturerString.Header.Size);  
261 - break;  
262 - case STRING_ID_Product:  
263 - Address = &ProductString;  
264 - Size = pgm_read_byte(&ProductString.Header.Size);  
265 - break;  
266 - }  
267 -  
268 - break;  
269 - case HID_DTYPE_HID:  
270 - Address = &ConfigurationDescriptor.HID_KeyboardHID;  
271 - Size = sizeof(USB_HID_Descriptor_HID_t);  
272 - break;  
273 - case HID_DTYPE_Report:  
274 - Address = &KeyboardReport;  
275 - Size = sizeof(KeyboardReport);  
276 - break;  
277 - }  
278 -  
279 - *DescriptorAddress = Address;  
280 - return Size;  
281 -}  
282 -  
283 -  
284 -/////////////////////////////////////////////////////////////////////////////////  
285 -  
286 -  
287 -uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,  
288 - const uint16_t wIndex,  
289 - const void** const DescriptorAddress)  
290 -{  
291 - cons  
292 -/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage  
293 - * of the device in one of its supported configurations, including information about any device interfaces  
294 - * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting  
295 - * a configuration so that the host may correctly communicate with the USB device.  
296 - */t uint8_t DescriptorType = (wValue >> 8);  
297 - const uint8_t DescriptorNumber = (wValue & 0xFF);  
298 -  
299 - const void* Address = NULL;  
300 - uint16_t Size = NO_DESCRIPTOR;  
301 -  
302 - switch (DescriptorType)  
303 - {  
304 - case DTYPE_Device:  
305 Address = &RelayBoard_DeviceDescriptor; 214 Address = &RelayBoard_DeviceDescriptor;
306 Size = sizeof(USB_Descriptor_Device_t); 215 Size = sizeof(USB_Descriptor_Device_t);
307 break; 216 break;
@@ -337,27 +246,3 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, @@ -337,27 +246,3 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
337 return Size; 246 return Size;
338 } 247 }
339 248
340 -  
341 -  
342 -  
343 -  
344 -  
345 -  
346 -  
347 -  
348 -  
349 -  
350 -  
351 -  
352 -  
353 -  
354 -  
355 -  
356 -  
357 -  
358 -  
359 -  
360 -  
361 -  
362 -  
363 -  
lufa-master/PolytechLille/PAD/Descriptors.h
@@ -51,7 +51,13 @@ @@ -51,7 +51,13 @@
51 USB_Descriptor_Configuration_Header_t Config; 51 USB_Descriptor_Configuration_Header_t Config;
52 52
53 // Relay Board Interface 53 // Relay Board Interface
54 - USB_Descriptor_Interface_t RelayBoardInterface; 54 + USB_Descriptor_Interface_t InterfaceOUT;
  55 + USB_HID_Descriptor_HID_t HID_KeyboardHID; //UTILE ?
  56 + USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint;
  57 +
  58 + USB_Descriptor_Interface_t InterfaceIN;
  59 + USB_Descriptor_Endpoint_t HID_ReportINEndpointBoutons;
  60 + USB_Descriptor_Endpoint_t HID_ReportOUTEndpointJoysticks;
55 } USB_Descriptor_Configuration_t; 61 } USB_Descriptor_Configuration_t;
56 62
57 /** Enum for the device interface descriptor IDs within the device. Each interface descriptor 63 /** Enum for the device interface descriptor IDs within the device. Each interface descriptor
@@ -60,8 +66,7 @@ @@ -60,8 +66,7 @@
60 */ 66 */
61 enum InterfaceDescriptors_t 67 enum InterfaceDescriptors_t
62 { 68 {
63 - INTERFACE_ID_InterfaceOUT = 0,  
64 - INTERFACE_ID_InterfaceIN = 1,/**< Relay board interface descriptor ID */ 69 + INTERFACE_ID_RelayBoard = 0, /**< Relay board interface descriptor ID */
65 }; 70 };
66 71
67 /** Enum for the device string descriptor IDs within the device. Each string descriptor should 72 /** Enum for the device string descriptor IDs within the device. Each string descriptor should