- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am a USB device. My host is sending me a large amount of data. But I've read everything I need, so I need to tell it to stop. How?
Simply disabling the endpoint won't work, because the host will assume I'm busy and will just keep waiting for me to reenable the port. If it waits long enough, it'll time out, but that's a lousy user experience and I don't want to do that.
The USB spec talks about stalling the endpoint to indicate an error condition, but I can't find any API to do this in the Cypress code. Plus, this isn't really an error condition, just an end of file. I did try this:
USBFS_SIE_EP_BASE.sieEp[ep].epCr0 = USBFS_MODE_STALL_DATA_EP;
...but it just caused the entire USB connection to crash and burn as everything got out of sync.
What I can't do is tell the host upfront how much data to send, because I don't know (this all depends on external hardware). So what should I be doing?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if the device does not want the data, it has to NACK the packets... the host will keep on attempting to send the packets.. device will keep on nacking.
Device has only options of ACK, Nack or Stall to send as response to Host according to USB2.0 spec. Thus I think your requirement cannot be met according to USB2.0 spec.
Stall should be used only in an error condition .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The register USB_SIE_EP1_CR0 could be used to STALL the end point and clear the end point. If the 7th bit of the register is set, this STALL the end point. If the 7th bit is cleared, this could clear the STALL. Could you please refer the below link, page no 744, to get more information about this register:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, but I mentioned trying that in my original post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if the device does not want the data, it has to NACK the packets... the host will keep on attempting to send the packets.. device will keep on nacking.
Device has only options of ACK, Nack or Stall to send as response to Host according to USB2.0 spec. Thus I think your requirement cannot be met according to USB2.0 spec.
Stall should be used only in an error condition .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sadly I'm using libusb for my client, and sending a NAK just causes it to block and retry --- eventually it times out. So my choices are either to time out or to stall, both of which produce client-side error conditions rather than a clean short transfer.