How to confirm that the USB data has been successfully sent?
I saw the following function in the USB library.
uint32_t USB_OTG_GetEPStatus(USB_OTG_CORE_HANDLE *pdev ,USB_OTG_EP *ep)
{
··········
if (depctl.b.stall == 1)
{
Status = USB_OTG_EP_TX_STALL;
}
else if (depctl.b.naksts == 1)
{
Status = USB_OTG_EP_TX_NAK;
}
else
{
Status = USB_OTG_EP_TX_VALID;
}
····················
return Status;
}I am using the function USB_OTG_EPStartXfer(pdev, ep); to send data."I then found that the PC could not recognize this USB identifier. Through DEBUG debugging, I discovered that when the USB is first connected, `USB_OTG_GetEPStatus(pdev, ep)` returns `USB_OTG_EP_TX_NAK`, which causes the recognition to fail. Therefore, this method is not very effective. Are there any other ways to detect whether the USB data has been sent successfully or whether the USB port is currently idle and ready to send data?"
if(USB_OTG_GetEPStatus(pdev,ep) == USB_OTG_EP_TX_VALID)) //sending is valid
{
if ( ep->num == 0 )
{
USB_OTG_EP0StartXfer(pdev , ep);
}
else
{
USB_OTG_EPStartXfer(pdev, ep );
}
}