@@ -426,6 +426,9 @@ static inline __force_inline endpoint_t * _find_ep(uint8_t root_idx,
426426bool pio_usb_host_endpoint_open (uint8_t root_idx , uint8_t device_address ,
427427 uint8_t const * desc_endpoint , bool need_pre ) {
428428 const endpoint_descriptor_t * d = (const endpoint_descriptor_t * )desc_endpoint ;
429+ if (NULL != _find_ep (root_idx , device_address , d -> epaddr )) {
430+ return false; // endpoint already opened
431+ }
429432 for (int ep_pool_idx = 0 ; ep_pool_idx < PIO_USB_EP_POOL_CNT ; ep_pool_idx ++ ) {
430433 endpoint_t * ep = PIO_USB_ENDPOINT (ep_pool_idx );
431434 // ep size is used as valid indicator
@@ -442,6 +445,17 @@ bool pio_usb_host_endpoint_open(uint8_t root_idx, uint8_t device_address,
442445 return false;
443446}
444447
448+ bool pio_usb_host_endpoint_close (uint8_t root_idx , uint8_t device_address ,
449+ uint8_t ep_address ) {
450+ endpoint_t * ep = _find_ep (root_idx , device_address , ep_address );
451+ if (!ep ) {
452+ return false; // endpoint not opened
453+ }
454+
455+ ep -> size = 0 ; // mark as closed
456+ return true;
457+ }
458+
445459bool pio_usb_host_send_setup (uint8_t root_idx , uint8_t device_address ,
446460 uint8_t const setup_packet [8 ]) {
447461 endpoint_t * ep = _find_ep (root_idx , device_address , 0 );
0 commit comments