replace speed reconfig with mult

This commit is contained in:
sakimisu
2023-03-12 15:04:21 +08:00
parent cda6e48fc1
commit 4cd9031d31
8 changed files with 70 additions and 76 deletions

View File

@@ -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);

View File

@@ -669,24 +669,13 @@ 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 speed)
{
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");
chusbh_set_self_speed(USB_SPEED_HIGH);
} 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);
}
USBHS_HOST->DEV_AD = dev_addr & 0x7f;
return 0;
}
@@ -723,6 +712,16 @@ 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");
chusbh_set_self_speed(USB_SPEED_HIGH);
} 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) {
if ((ep_cfg->ep_type == USB_ENDPOINT_TYPE_ISOCHRONOUS) ||
@@ -914,7 +913,7 @@ static int8_t chusb_outpipe_irq_handler(uint8_t res_state)
urb->errorcode = 0;
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
*/
g_chusb_hcd.prv_set_zero = false;
@@ -1172,7 +1171,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)) {

View File

@@ -676,7 +676,7 @@ 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 dwc2_pipe *chan;
@@ -684,7 +684,6 @@ int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps
chan->dev_addr = dev_addr;
chan->ep_mps = ep_mps;
chan->speed = speed;
return 0;
}

View File

@@ -959,13 +959,13 @@ 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 ehci_pipe *ppipe = (struct ehci_pipe *)pipe;
ppipe->dev_addr = dev_addr;
ppipe->ep_mps = ep_mps;
ppipe->speed = speed;
ppipe->mult = mult;
return 0;
}

View File

@@ -551,21 +551,13 @@ 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 musb_pipe *ppipe = (struct musb_pipe *)pipe;
ppipe->dev_addr = dev_addr;
ppipe->ep_mps = ep_mps;
if (speed == USB_SPEED_HIGH) {
ppipe->speed = USB_TYPE0_SPEED_HIGH;
} else if (speed == USB_SPEED_FULL) {
ppipe->speed = USB_TYPE0_SPEED_FULL;
} else if (speed == USB_SPEED_LOW) {
ppipe->speed = USB_TYPE0_SPEED_LOW;
}
return 0;
}
@@ -605,6 +597,13 @@ 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) {
ppipe->speed = USB_TYPE0_SPEED_HIGH;
} else if (ppipe->speed == USB_SPEED_FULL) {
ppipe->speed = USB_TYPE0_SPEED_FULL;
} else if (ppipe->speed == USB_SPEED_LOW) {
ppipe->speed = USB_TYPE0_SPEED_LOW;
}
} else {
if (ppipe->speed == USB_SPEED_HIGH) {
ppipe->speed = USB_TXTYPE1_SPEED_HIGH;

View File

@@ -185,7 +185,7 @@ 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 dwc2_pipe *chan;
@@ -193,7 +193,6 @@ int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps
chan->dev_addr = dev_addr;
chan->ep_mps = ep_mps;
chan->speed = speed;
return 0;
}