@@ -424,6 +424,9 @@ static inline __force_inline endpoint_t * _find_ep(uint8_t root_idx,
424424bool pio_usb_host_endpoint_open (uint8_t root_idx , uint8_t device_address ,
425425 uint8_t const * desc_endpoint , bool need_pre ) {
426426 const endpoint_descriptor_t * d = (const endpoint_descriptor_t * )desc_endpoint ;
427+ if (NULL != _find_ep (root_idx , device_address , d -> epaddr )) {
428+ return false; // endpoint already opened
429+ }
427430 for (int ep_pool_idx = 0 ; ep_pool_idx < PIO_USB_EP_POOL_CNT ; ep_pool_idx ++ ) {
428431 endpoint_t * ep = PIO_USB_ENDPOINT (ep_pool_idx );
429432 // ep size is used as valid indicator
@@ -440,6 +443,17 @@ bool pio_usb_host_endpoint_open(uint8_t root_idx, uint8_t device_address,
440443 return false;
441444}
442445
446+ bool pio_usb_host_endpoint_close (uint8_t root_idx , uint8_t device_address ,
447+ uint8_t ep_address ) {
448+ endpoint_t * ep = _find_ep (root_idx , device_address , ep_address );
449+ if (!ep ) {
450+ return false; // endpoint not opened
451+ }
452+
453+ ep -> size = 0 ; // mark as closed
454+ return true;
455+ }
456+
443457bool pio_usb_host_send_setup (uint8_t root_idx , uint8_t device_address ,
444458 uint8_t const setup_packet [8 ]) {
445459 endpoint_t * ep = _find_ep (root_idx , device_address , 0 );
0 commit comments