@@ -45,7 +45,6 @@ EndBSPDependencies */
45
45
/* Includes ------------------------------------------------------------------*/
46
46
#include "usbd_customhid.h"
47
47
#include "usbd_ctlreq.h"
48
- #include "usbd_def.h"
49
48
50
49
51
50
/** @addtogroup STM32_USB_DEVICE_LIBRARY
@@ -168,7 +167,8 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgDesc[USB_CUSTOM_HID_CONFIG_DESC_
168
167
0x11 , /* bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number */
169
168
0x01 ,
170
169
0x00 , /* bCountryCode: Hardware target country */
171
- 0x01 , /* bNumDescriptors: Number of CUSTOM_HID class descriptors to follow */
170
+ 0x01 , /* bNumDescriptors: Number of CUSTOM_HID class descriptors
171
+ to follow */
172
172
0x22 , /* bDescriptorType */
173
173
LOBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ), /* wItemLength: Total length of Report descriptor */
174
174
HIBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ),
@@ -193,128 +193,6 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgDesc[USB_CUSTOM_HID_CONFIG_DESC_
193
193
CUSTOM_HID_FS_BINTERVAL , /* bInterval: Polling Interval */
194
194
/* 41 */
195
195
};
196
-
197
- /* USB CUSTOM_HID device HS Configuration Descriptor */
198
- __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgHSDesc [USB_CUSTOM_HID_CONFIG_DESC_SIZ ] __ALIGN_END =
199
- {
200
- 0x09 , /* bLength: Configuration Descriptor size */
201
- USB_DESC_TYPE_CONFIGURATION , /* bDescriptorType: Configuration */
202
- LOBYTE (USB_CUSTOM_HID_CONFIG_DESC_SIZ ), /* wTotalLength: Bytes returned */
203
- HIBYTE (USB_CUSTOM_HID_CONFIG_DESC_SIZ ),
204
- 0x01 , /* bNumInterfaces: 1 interface */
205
- 0x01 , /* bConfigurationValue: Configuration value */
206
- 0x00 , /* iConfiguration: Index of string descriptor describing the configuration */
207
- #if (USBD_SELF_POWERED == 1U )
208
- 0xC0 , /* bmAttributes: Bus Powered according to user configuration */
209
- #else
210
- 0x80 , /* bmAttributes: Bus Powered according to user configuration */
211
- #endif
212
- USBD_MAX_POWER , /* MaxPower (mA) */
213
-
214
- /************** Descriptor of CUSTOM HID interface ****************/
215
- /* 09 */
216
- 0x09 , /* bLength: Interface Descriptor size */
217
- USB_DESC_TYPE_INTERFACE , /* bDescriptorType: Interface descriptor type */
218
- 0x00 , /* bInterfaceNumber: Number of Interface */
219
- 0x00 , /* bAlternateSetting: Alternate setting */
220
- 0x02 , /* bNumEndpoints */
221
- 0x03 , /* bInterfaceClass: CUSTOM_HID */
222
- 0x00 , /* bInterfaceSubClass : 1=BOOT, 0=no boot */
223
- 0x00 , /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
224
- 0 , /* iInterface: Index of string descriptor */
225
- /******************** Descriptor of CUSTOM_HID *************************/
226
- /* 18 */
227
- 0x09 , /* bLength: CUSTOM_HID Descriptor size */
228
- CUSTOM_HID_DESCRIPTOR_TYPE , /* bDescriptorType: CUSTOM_HID */
229
- 0x11 , /* bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number */
230
- 0x01 ,
231
- 0x00 , /* bCountryCode: Hardware target country */
232
- 0x01 , /* bNumDescriptors: Number of CUSTOM_HID class descriptors to follow */
233
- 0x22 , /* bDescriptorType */
234
- LOBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ), /* wItemLength: Total length of Report descriptor */
235
- HIBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ),
236
- /******************** Descriptor of Custom HID endpoints ********************/
237
- /* 27 */
238
- 0x07 , /* bLength: Endpoint Descriptor size */
239
- USB_DESC_TYPE_ENDPOINT , /* bDescriptorType */
240
-
241
- CUSTOM_HID_EPIN_ADDR , /* bEndpointAddress: Endpoint Address (IN) */
242
- 0x03 , /* bmAttributes: Interrupt endpoint */
243
- LOBYTE (CUSTOM_HID_EPIN_SIZE ), /* wMaxPacketSize: 2 Bytes max */
244
- HIBYTE (CUSTOM_HID_EPIN_SIZE ),
245
- CUSTOM_HID_HS_BINTERVAL , /* bInterval: Polling Interval */
246
- /* 34 */
247
-
248
- 0x07 , /* bLength: Endpoint Descriptor size */
249
- USB_DESC_TYPE_ENDPOINT , /* bDescriptorType: */
250
- CUSTOM_HID_EPOUT_ADDR , /* bEndpointAddress: Endpoint Address (OUT) */
251
- 0x03 , /* bmAttributes: Interrupt endpoint */
252
- LOBYTE (CUSTOM_HID_EPOUT_SIZE ), /* wMaxPacketSize: 2 Bytes max */
253
- HIBYTE (CUSTOM_HID_EPOUT_SIZE ),
254
- CUSTOM_HID_HS_BINTERVAL , /* bInterval: Polling Interval */
255
- /* 41 */
256
- };
257
-
258
- /* USB CUSTOM_HID device Other Speed Configuration Descriptor */
259
- __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_OtherSpeedCfgDesc [USB_CUSTOM_HID_CONFIG_DESC_SIZ ] __ALIGN_END =
260
- {
261
- 0x09 , /* bLength: Configuration Descriptor size */
262
- USB_DESC_TYPE_CONFIGURATION , /* bDescriptorType: Configuration */
263
- LOBYTE (USB_CUSTOM_HID_CONFIG_DESC_SIZ ), /* wTotalLength: Bytes returned */
264
- HIBYTE (USB_CUSTOM_HID_CONFIG_DESC_SIZ ),
265
- 0x01 , /* bNumInterfaces: 1 interface */
266
- 0x01 , /* bConfigurationValue: Configuration value */
267
- 0x00 , /* iConfiguration: Index of string descriptor describing the configuration */
268
- #if (USBD_SELF_POWERED == 1U )
269
- 0xC0 , /* bmAttributes: Bus Powered according to user configuration */
270
- #else
271
- 0x80 , /* bmAttributes: Bus Powered according to user configuration */
272
- #endif
273
- USBD_MAX_POWER , /* MaxPower (mA) */
274
-
275
- /************** Descriptor of CUSTOM HID interface ****************/
276
- /* 09 */
277
- 0x09 , /* bLength: Interface Descriptor size */
278
- USB_DESC_TYPE_INTERFACE , /* bDescriptorType: Interface descriptor type */
279
- 0x00 , /* bInterfaceNumber: Number of Interface */
280
- 0x00 , /* bAlternateSetting: Alternate setting */
281
- 0x02 , /* bNumEndpoints */
282
- 0x03 , /* bInterfaceClass: CUSTOM_HID */
283
- 0x00 , /* bInterfaceSubClass : 1=BOOT, 0=no boot */
284
- 0x00 , /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
285
- 0 , /* iInterface: Index of string descriptor */
286
- /******************** Descriptor of CUSTOM_HID *************************/
287
- /* 18 */
288
- 0x09 , /* bLength: CUSTOM_HID Descriptor size */
289
- CUSTOM_HID_DESCRIPTOR_TYPE , /* bDescriptorType: CUSTOM_HID */
290
- 0x11 , /* bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number */
291
- 0x01 ,
292
- 0x00 , /* bCountryCode: Hardware target country */
293
- 0x01 , /* bNumDescriptors: Number of CUSTOM_HID class descriptors to follow */
294
- 0x22 , /* bDescriptorType */
295
- LOBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ), /* wItemLength: Total length of Report descriptor */
296
- HIBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ),
297
- /******************** Descriptor of Custom HID endpoints ********************/
298
- /* 27 */
299
- 0x07 , /* bLength: Endpoint Descriptor size */
300
- USB_DESC_TYPE_ENDPOINT , /* bDescriptorType: */
301
-
302
- CUSTOM_HID_EPIN_ADDR , /* bEndpointAddress: Endpoint Address (IN) */
303
- 0x03 , /* bmAttributes: Interrupt endpoint */
304
- LOBYTE (CUSTOM_HID_EPIN_SIZE ), /* wMaxPacketSize: 2 Bytes max */
305
- HIBYTE (CUSTOM_HID_EPIN_SIZE ),
306
- CUSTOM_HID_FS_BINTERVAL , /* bInterval: Polling Interval */
307
- /* 34 */
308
-
309
- 0x07 , /* bLength: Endpoint Descriptor size */
310
- USB_DESC_TYPE_ENDPOINT , /* bDescriptorType: */
311
- CUSTOM_HID_EPOUT_ADDR , /* bEndpointAddress: Endpoint Address (OUT) */
312
- 0x03 , /* bmAttributes: Interrupt endpoint */
313
- LOBYTE (CUSTOM_HID_EPOUT_SIZE ), /* wMaxPacketSize: 2 Bytes max */
314
- HIBYTE (CUSTOM_HID_EPOUT_SIZE ),
315
- CUSTOM_HID_FS_BINTERVAL , /* bInterval: Polling Interval */
316
- /* 41 */
317
- };
318
196
#endif /* USE_USBD_COMPOSITE */
319
197
320
198
/* USB CUSTOM_HID device Configuration Descriptor */
@@ -329,7 +207,7 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_Desc[USB_CUSTOM_HID_DESC_SIZ] __ALI
329
207
0x01 , /* bNumDescriptors: Number of CUSTOM_HID class descriptors
330
208
to follow */
331
209
0x22 , /* bDescriptorType */
332
- LOBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ), /* wItemLength: Total length of Report descriptor */
210
+ LOBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ), /* wItemLength: Total length of Report descriptor */
333
211
HIBYTE (USBD_CUSTOM_HID_REPORT_DESC_SIZE ),
334
212
};
335
213
@@ -601,7 +479,15 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
601
479
}
602
480
}
603
481
604
- (void )USBD_CtlSendData (pdev , pbuf , len );
482
+ if (pbuf != NULL )
483
+ {
484
+ (void )USBD_CtlSendData (pdev , pbuf , len );
485
+ }
486
+ else
487
+ {
488
+ USBD_CtlError (pdev , req );
489
+ ret = USBD_FAIL ;
490
+ }
605
491
break ;
606
492
607
493
case USB_REQ_GET_INTERFACE :
0 commit comments