|
|
@@ -607,23 +607,12 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
|
|
|
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult)
|
|
|
{
|
|
|
struct chusb_pipe *ppipe = (struct chusb_pipe *)pipe;
|
|
|
|
|
|
ppipe->dev_addr = dev_addr;
|
|
|
ppipe->ep_mps = ep_mps;
|
|
|
- ppipe->speed = speed;
|
|
|
-
|
|
|
- if (speed == USB_SPEED_HIGH) {
|
|
|
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_HIGH \r\n");
|
|
|
- } else if (speed == USB_SPEED_FULL) {
|
|
|
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_FULL \r\n");
|
|
|
- chusbh_set_self_speed(USB_SPEED_FULL);
|
|
|
- } else if (speed == USB_SPEED_LOW) {
|
|
|
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_LOW \r\n");
|
|
|
- chusbh_set_self_speed(USB_SPEED_LOW);
|
|
|
- }
|
|
|
|
|
|
USBFS_HOST->DEV_ADDR = (USBFS_DEV_ADDR_OFFSET & USBFS_UDA_GP_BIT) | (dev_addr & USBFS_USB_ADDR_MASK);
|
|
|
return 0;
|
|
|
@@ -661,6 +650,15 @@ int usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg)
|
|
|
ppipe->hport = ep_cfg->hport;
|
|
|
|
|
|
if (ep_cfg->ep_type == USB_ENDPOINT_TYPE_CONTROL) {
|
|
|
+ if (ppipe->speed == USB_SPEED_HIGH) {
|
|
|
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_HIGH \r\n");
|
|
|
+ } else if (ppipe->speed == USB_SPEED_FULL) {
|
|
|
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_FULL \r\n");
|
|
|
+ chusbh_set_self_speed(USB_SPEED_FULL);
|
|
|
+ } else if (ppipe->speed == USB_SPEED_LOW) {
|
|
|
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_LOW \r\n");
|
|
|
+ chusbh_set_self_speed(USB_SPEED_LOW);
|
|
|
+ }
|
|
|
} else {
|
|
|
if (ppipe->speed == USB_SPEED_HIGH) {
|
|
|
} else if (ppipe->speed == USB_SPEED_FULL) {
|
|
|
@@ -842,7 +840,7 @@ static int8_t chusb_outpipe_irq_handler(uint8_t res_state)
|
|
|
} else {
|
|
|
if (g_chusb_hcd.prv_set_zero == true) {
|
|
|
/**
|
|
|
- * It is unlikely to run here,
|
|
|
+ * It is unlikely to run here,
|
|
|
* because the device can probably receive 0 length byte packets
|
|
|
*/
|
|
|
urb->errorcode = 0;
|
|
|
@@ -1121,7 +1119,7 @@ static int8_t chusb_inpipe_irq_handler(uint8_t res_state)
|
|
|
/*!< Ctrol endpoint */
|
|
|
/**
|
|
|
* Status stage
|
|
|
- *
|
|
|
+ *
|
|
|
* Setup ---> out data ---> in status stage
|
|
|
*/
|
|
|
if ((g_chusb_hcd.ep0_state == USB_EP0_STATE_IN_STATUS) && (rx_len == 0)) {
|
|
|
@@ -1252,37 +1250,37 @@ void USBH_IRQHandler(void)
|
|
|
}
|
|
|
} else if (intflag & USBFS_UIF_DETECT) {
|
|
|
if (USBFS_HOST->MIS_ST & USBFS_UMS_DEV_ATTACH) {
|
|
|
- USB_LOG_INFO("Dev connect \r\n");
|
|
|
- g_chusb_hcd.port_csc = 1;
|
|
|
- g_chusb_hcd.port_pec = 1;
|
|
|
- g_chusb_hcd.port_pe = 1;
|
|
|
- usbh_roothub_thread_wakeup(1);
|
|
|
+ USB_LOG_INFO("Dev connect \r\n");
|
|
|
+ g_chusb_hcd.port_csc = 1;
|
|
|
+ g_chusb_hcd.port_pec = 1;
|
|
|
+ g_chusb_hcd.port_pe = 1;
|
|
|
+ usbh_roothub_thread_wakeup(1);
|
|
|
} else {
|
|
|
- USB_LOG_INFO("Dev remove \r\n");
|
|
|
- /**
|
|
|
+ USB_LOG_INFO("Dev remove \r\n");
|
|
|
+ /**
|
|
|
* Device remove
|
|
|
* Disable port and stop send sof
|
|
|
*/
|
|
|
- USBFS_HOST->HOST_SETUP &= ~USBFS_UH_SOF_EN;
|
|
|
- USBFS_HOST->HOST_CTRL &= ~USBFS_UH_PORT_EN;
|
|
|
- if (g_chusb_hcd.main_pipe_using) {
|
|
|
- g_chusb_hcd.main_pipe_using = false;
|
|
|
- }
|
|
|
- g_chusb_hcd.port_csc = 1;
|
|
|
- g_chusb_hcd.port_pec = 1;
|
|
|
- g_chusb_hcd.port_pe = 0;
|
|
|
- for (uint8_t index = 0; index < CONFIG_USBHOST_PIPE_NUM; index++) {
|
|
|
- for (uint8_t j = 0; j < 2; j++) {
|
|
|
- struct chusb_pipe *pipe = &g_chusb_hcd.pipe_pool[index][j];
|
|
|
- struct usbh_urb *urb = pipe->urb;
|
|
|
- if (pipe->waiter) {
|
|
|
- pipe->waiter = false;
|
|
|
- urb->errorcode = -ESHUTDOWN;
|
|
|
- usb_osal_sem_give(pipe->waitsem);
|
|
|
- }
|
|
|
+ USBFS_HOST->HOST_SETUP &= ~USBFS_UH_SOF_EN;
|
|
|
+ USBFS_HOST->HOST_CTRL &= ~USBFS_UH_PORT_EN;
|
|
|
+ if (g_chusb_hcd.main_pipe_using) {
|
|
|
+ g_chusb_hcd.main_pipe_using = false;
|
|
|
+ }
|
|
|
+ g_chusb_hcd.port_csc = 1;
|
|
|
+ g_chusb_hcd.port_pec = 1;
|
|
|
+ g_chusb_hcd.port_pe = 0;
|
|
|
+ for (uint8_t index = 0; index < CONFIG_USBHOST_PIPE_NUM; index++) {
|
|
|
+ for (uint8_t j = 0; j < 2; j++) {
|
|
|
+ struct chusb_pipe *pipe = &g_chusb_hcd.pipe_pool[index][j];
|
|
|
+ struct usbh_urb *urb = pipe->urb;
|
|
|
+ if (pipe->waiter) {
|
|
|
+ pipe->waiter = false;
|
|
|
+ urb->errorcode = -ESHUTDOWN;
|
|
|
+ usb_osal_sem_give(pipe->waitsem);
|
|
|
}
|
|
|
}
|
|
|
- usbh_roothub_thread_wakeup(1);
|
|
|
+ }
|
|
|
+ usbh_roothub_thread_wakeup(1);
|
|
|
}
|
|
|
USBFS_HOST->INT_FG = USBFS_UIF_DETECT;
|
|
|
} else {
|
|
|
@@ -1293,8 +1291,8 @@ void USBH_IRQHandler(void)
|
|
|
return;
|
|
|
pipe_wait:
|
|
|
/**
|
|
|
- * enerally, only errors can arrive here.
|
|
|
- * After testing, most cases arrive here because of the problem of the DATA PID,
|
|
|
+ * enerally, only errors can arrive here.
|
|
|
+ * After testing, most cases arrive here because of the problem of the DATA PID,
|
|
|
* but the transmission will be completed correctly next time.
|
|
|
*/
|
|
|
chusb_pipe_waitup(g_chusb_hcd.current_pipe, true);
|