diff options
| author | Zhihong Chen <[email protected]> | 2023-11-23 11:46:06 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2023-11-23 15:21:11 +0800 |
| commit | 86c7e435a39200248c6db6464fa7fd34b1011ba3 (patch) | |
| tree | 0bfe551ae44dbdfed9f3b53465b6a0cf397deeb0 | |
| parent | 074f30a7b4a7a3805b3abd9330fe4800417276ee (diff) | |
hpmicro: update port files
- update port files
Signed-off-by: Zhihong Chen <[email protected]>
| -rw-r--r-- | port/ehci/usb_glue_hpm.c | 9 | ||||
| -rw-r--r-- | port/hpm/usb_dc_hpm.c | 37 |
2 files changed, 29 insertions, 17 deletions
diff --git a/port/ehci/usb_glue_hpm.c b/port/ehci/usb_glue_hpm.c index 9034ea7a..327f9241 100644 --- a/port/ehci/usb_glue_hpm.c +++ b/port/ehci/usb_glue_hpm.c @@ -30,19 +30,20 @@ static void usb_host_mode_init(USB_Type *ptr) ptr->USBCMD &= ~USB_USBCMD_ITC_MASK; } -void usb_hc_low_level_init() +void usb_hc_low_level_init(void) { usb_phy_init((USB_Type *)CONFIG_HPM_USBH_BASE); intc_m_enable_irq(CONFIG_HPM_USBH_IRQn); } -void usb_hc_low_level2_init() +void usb_hc_low_level2_init(void) { usb_host_mode_init((USB_Type *)CONFIG_HPM_USBH_BASE); } uint8_t usbh_get_port_speed(const uint8_t port) { + (void)port; uint8_t speed; speed = usb_get_port_speed((USB_Type *)CONFIG_HPM_USBH_BASE); @@ -62,8 +63,8 @@ uint8_t usbh_get_port_speed(const uint8_t port) extern void USBH_IRQHandler(void); -void isr_usb(void) +void isr_usbh(void) { USBH_IRQHandler(); } -SDK_DECLARE_EXT_ISR_M(CONFIG_HPM_USBH_IRQn, isr_usb) +SDK_DECLARE_EXT_ISR_M(CONFIG_HPM_USBH_IRQn, isr_usbh)
\ No newline at end of file diff --git a/port/hpm/usb_dc_hpm.c b/port/hpm/usb_dc_hpm.c index 930e2438..576498f6 100644 --- a/port/hpm/usb_dc_hpm.c +++ b/port/hpm/usb_dc_hpm.c @@ -93,6 +93,7 @@ int usbd_set_address(const uint8_t addr) uint8_t usbd_get_port_speed(const uint8_t port) { + (void)port; uint8_t speed; speed = usb_get_port_speed(g_hpm_udc.handle->regs); @@ -161,6 +162,9 @@ int usbd_ep_clear_stall(const uint8_t ep) int usbd_ep_is_stalled(const uint8_t ep, uint8_t *stalled) { + usb_device_handle_t *handle = g_hpm_udc.handle; + + *stalled = usb_device_edpt_check_stall(handle, ep); return 0; } @@ -210,7 +214,7 @@ void USBD_IRQHandler(void) { uint32_t int_status; usb_device_handle_t *handle = g_hpm_udc.handle; - uint32_t transfer_len; + uint32_t transfer_len = 0; /* Acknowledge handled interrupt */ int_status = usb_device_status_flags(handle); @@ -263,28 +267,35 @@ void USBD_IRQHandler(void) if (edpt_complete & (1 << ep_idx2bit(ep_idx))) { /* Failed QTD also get ENDPTCOMPLETE set */ dcd_qtd_t *p_qtd = usb_device_qtd_get(handle, ep_idx); + while (1) { + if (p_qtd->halted || p_qtd->xact_err || p_qtd->buffer_err) { + USB_LOG_ERR("usbd transfer error!\r\n"); + return; + } else { + transfer_len += p_qtd->expected_bytes - p_qtd->total_bytes; + } - if (p_qtd->halted || p_qtd->xact_err || p_qtd->buffer_err) { - } else { - /* only number of bytes in the IOC qtd */ - uint8_t const ep_addr = (ep_idx / 2) | ((ep_idx & 0x01) ? 0x80 : 0); - - transfer_len = p_qtd->expected_bytes - p_qtd->total_bytes; - - if (ep_addr & 0x80) { - usbd_event_ep_in_complete_handler(ep_addr, transfer_len); + if (p_qtd->next == USB_SOC_DCD_QTD_NEXT_INVALID){ + break; } else { - usbd_event_ep_out_complete_handler(ep_addr, transfer_len); + p_qtd = (dcd_qtd_t *)p_qtd->next; } } + + uint8_t const ep_addr = (ep_idx / 2) | ((ep_idx & 0x01) ? 0x80 : 0); + if (ep_addr & 0x80) { + usbd_event_ep_in_complete_handler(ep_addr, transfer_len); + } else { + usbd_event_ep_out_complete_handler(ep_addr, transfer_len); + } } } } } } -void isr_usb(void) +void isr_usbd(void) { USBD_IRQHandler(); } -SDK_DECLARE_EXT_ISR_M(CONFIG_HPM_USBD_IRQn, isr_usb) +SDK_DECLARE_EXT_ISR_M(CONFIG_HPM_USBD_IRQn, isr_usbd) |
