cherry-embedded / CherryUSB

CherryUSB is a tiny, beautiful and portable USB host and device stack for embedded system with USB IP

Home Page:https://cherryusb.cherry-embedded.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[dwc2 dc] EP0 is bi-direction?

wosayttn opened this issue · comments

commented

Hi,

These if conditional sentences are unnecessary in these function, right?
Or, we should ignore the EP0 checking?

int usbd_ep_start_write(const uint8_t ep, const uint8_t *data, uint32_t data_len)
{
...
    if (USB_OTG_INEP(ep_idx)->DIEPCTL & USB_OTG_DIEPCTL_EPENA)
    {
        return -2;
    }
...
}

int usbd_ep_start_read(const uint8_t ep, uint8_t *data, uint32_t data_len)
{
...
    if (USB_OTG_OUTEP(ep_idx)->DOEPCTL & USB_OTG_DOEPCTL_EPENA)
   {
        return -2;
    }
...
}

This checks if ep transfers done, it is necessary.

commented

This checks if ep transfers done, it is necessary.

After appending "ignore ep_idx=0", the CONFIG_USB_DWC2_DMA_ENABLE mode is workable.

int usbd_ep_start_write(const uint8_t ep, const uint8_t *data, uint32_t data_len)
{
    ....
    if (ep_idx && (USB_OTG_INEP(ep_idx)->DIEPCTL & USB_OTG_DIEPCTL_EPENA))
    {
        return -2;
    }
    ....
}
int usbd_ep_start_read(const uint8_t ep, uint8_t *data, uint32_t data_len)
{
    ...
    if (ep_idx && (USB_OTG_OUTEP(ep_idx)->DOEPCTL & USB_OTG_DOEPCTL_EPENA)) //Endpoint enable?
    {
        return -2;
    }
    ...
}

Not adding works in mine.

You can see my stm32 demo, using stm32f4 and stm32h7 with dma mode. It works.

USB_OTG_DIEPCTL_EPENA will be set when start reading or writing and be cleared when transfers done.

Certainly, this check is not necessary.

commented

Thanks comment, I will check other in our porting. CherryUSB is good implementation. Good job.

Thanks, maybe this check can disable?