Skip to content

Commit 83b638f

Browse files
authored
Open OUT endpoint for HID host
1 parent c0a65ba commit 83b638f

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/class/hid/hid_host.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -286,28 +286,35 @@ bool hidh_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *de
286286
hidh_device_t* hid_dev = get_dev(dev_addr);
287287
TU_ASSERT(hid_dev->inst_count < CFG_TUH_HID, 0);
288288

289-
//------------- Endpoint Descriptor -------------//
289+
hidh_interface_t* hid_itf = get_instance(dev_addr, hid_dev->inst_count);
290+
291+
//------------- Endpoint Descriptors -------------//
290292
p_desc = tu_desc_next(p_desc);
291293
tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const *) p_desc;
292-
TU_ASSERT(TUSB_DESC_ENDPOINT == desc_ep->bDescriptorType);
293294

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++)
297296
{
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+
298311
p_desc = tu_desc_next(p_desc);
299312
desc_ep = (tusb_desc_endpoint_t const *) p_desc;
300-
TU_ASSERT(TUSB_DESC_ENDPOINT == desc_ep->bDescriptorType);
301313
}
302314

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);
306315
hid_dev->inst_count++;
307316

308317
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);
311318

312319
// Assume bNumDescriptors = 1
313320
hid_itf->report_desc_type = desc_hid->bReportType;

0 commit comments

Comments
 (0)