Skip to content

Commit 810653f

Browse files
committed
add pio_usb_host_endpoint_close() API
1 parent e49dc6b commit 810653f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/pio_usb_host.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,17 @@ bool pio_usb_host_endpoint_open(uint8_t root_idx, uint8_t device_address,
443443
return false;
444444
}
445445

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+
446457
bool pio_usb_host_send_setup(uint8_t root_idx, uint8_t device_address,
447458
uint8_t const setup_packet[8]) {
448459
endpoint_t *ep = _find_ep(root_idx, device_address, 0);

src/pio_usb_ll.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ void pio_usb_host_close_device(uint8_t root_idx, uint8_t device_address);
183183

184184
bool pio_usb_host_endpoint_open(uint8_t root_idx, uint8_t device_address,
185185
uint8_t const *desc_endpoint, bool need_pre);
186+
bool pio_usb_host_endpoint_close(uint8_t root_idx, uint8_t device_address,
187+
uint8_t ep_address);
186188
bool pio_usb_host_send_setup(uint8_t root_idx, uint8_t device_address,
187189
uint8_t const setup_packet[8]);
188190
bool pio_usb_host_endpoint_transfer(uint8_t root_idx, uint8_t device_address,

0 commit comments

Comments
 (0)