@@ -286,28 +286,35 @@ bool hidh_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *de
286
286
hidh_device_t * hid_dev = get_dev (dev_addr );
287
287
TU_ASSERT (hid_dev -> inst_count < CFG_TUH_HID , 0 );
288
288
289
- //------------- Endpoint Descriptor -------------//
289
+ hidh_interface_t * hid_itf = get_instance (dev_addr , hid_dev -> inst_count );
290
+
291
+ //------------- Endpoint Descriptors -------------//
290
292
p_desc = tu_desc_next (p_desc );
291
293
tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const * ) p_desc ;
292
- TU_ASSERT (TUSB_DESC_ENDPOINT == desc_ep -> bDescriptorType );
293
294
294
- // first endpoint may be OUT, skip to IN endpoint
295
- // TODO also open endpoint OUT
296
- if (tu_edpt_dir (desc_ep -> bEndpointAddress ) == TUSB_DIR_OUT )
295
+ for (int i = 0 ; i < desc_itf -> bNumEndpoints ; i ++ )
297
296
{
297
+ TU_ASSERT (TUSB_DESC_ENDPOINT == desc_ep -> bDescriptorType );
298
+ TU_ASSERT ( usbh_edpt_open (rhport , dev_addr , desc_ep ) );
299
+
300
+ if (tu_edpt_dir (desc_ep -> bEndpointAddress ) == TUSB_DIR_IN )
301
+ {
302
+ hid_itf -> ep_in = desc_ep -> bEndpointAddress ;
303
+ hid_itf -> epin_size = tu_edpt_packet_size (desc_ep );
304
+ }
305
+ else
306
+ {
307
+ hid_itf -> ep_out = desc_ep -> bEndpointAddress ;
308
+ hid_itf -> epout_size = tu_edpt_packet_size (desc_ep );
309
+ }
310
+
298
311
p_desc = tu_desc_next (p_desc );
299
312
desc_ep = (tusb_desc_endpoint_t const * ) p_desc ;
300
- TU_ASSERT (TUSB_DESC_ENDPOINT == desc_ep -> bDescriptorType );
301
313
}
302
314
303
- TU_ASSERT ( usbh_edpt_open (rhport , dev_addr , desc_ep ) );
304
-
305
- hidh_interface_t * hid_itf = get_instance (dev_addr , hid_dev -> inst_count );
306
315
hid_dev -> inst_count ++ ;
307
316
308
317
hid_itf -> itf_num = desc_itf -> bInterfaceNumber ;
309
- hid_itf -> ep_in = desc_ep -> bEndpointAddress ;
310
- hid_itf -> epin_size = tu_edpt_packet_size (desc_ep );
311
318
312
319
// Assume bNumDescriptors = 1
313
320
hid_itf -> report_desc_type = desc_hid -> bReportType ;
0 commit comments