Terminating a USB bulk OUT transfer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
david-given
Level 4
Level 4
10 sign-ins 5 sign-ins First solution authored

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?

0 Likes
1 Solution

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 .

View solution in original post

0 Likes
4 Replies
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

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:

http://www.cypress.com/file/136211/download

0 Likes

Thanks, but I mentioned trying that in my original post.

0 Likes

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 .

0 Likes

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.

0 Likes