From 9e9772fde793bd151d177233cdacf7f3a21e10be Mon Sep 17 00:00:00 2001 From: Zhihong Chen Date: Mon, 4 Mar 2024 16:35:43 +0800 Subject: [PATCH] HPMicro: port: fix usbd_ep_close() not reset ep_enable flag - fix usbd_ep_close() not reset ep_enable flag Signed-off-by: Zhihong Chen --- port/hpm/usb_dc_hpm.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/port/hpm/usb_dc_hpm.c b/port/hpm/usb_dc_hpm.c index 43b91579..3533a887 100644 --- a/port/hpm/usb_dc_hpm.c +++ b/port/hpm/usb_dc_hpm.c @@ -165,6 +165,13 @@ int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep) int usbd_ep_close(uint8_t busid, const uint8_t ep) { usb_device_handle_t *handle = g_hpm_udc[busid].handle; + uint8_t ep_idx = USB_EP_GET_IDX(ep); + + if (USB_EP_DIR_IS_OUT(ep)) { + g_hpm_udc[busid].out_ep[ep_idx].ep_enable = false; + } else { + g_hpm_udc[busid].in_ep[ep_idx].ep_enable = false; + } usb_device_edpt_close(handle, ep); return 0; @@ -252,6 +259,10 @@ void USBD_IRQHandler(uint8_t busid) return; } + if (int_status & intr_error) { + USB_LOG_ERR("usbd intr error!\r\n"); + } + if (int_status & intr_reset) { memset(g_hpm_udc[busid].in_ep, 0, sizeof(struct hpm_ep_state) * USB_NUM_BIDIR_ENDPOINTS); memset(g_hpm_udc[busid].out_ep, 0, sizeof(struct hpm_ep_state) * USB_NUM_BIDIR_ENDPOINTS); @@ -262,8 +273,7 @@ void USBD_IRQHandler(uint8_t busid) if (int_status & intr_suspend) { if (usb_device_get_suspend_status(handle)) { usbd_event_suspend_handler(busid); - /* Note: Host may delay more than 3 ms before and/or after bus reset - * before doing enumeration. */ + /* Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration. */ if (usb_device_get_address(handle)) { } }