Skip to main content
dger
Associate
September 22, 2009
Question

How to use USB_NOT_READY in ClassDataSetup()

  • September 22, 2009
  • 2 replies
  • 658 views
Posted on September 22, 2009 at 20:48

How to use USB_NOT_READY in ClassDataSetup()

    This topic has been closed for replies.

    2 replies

    dger
    dgerAuthor
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 13:23

    The answer to this question can be found in the USB section of this forum:

    http://www.st.com/mcu/forums-cat-8927-12.html

    -Dan

    dger
    dgerAuthor
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 13:23

    The STM32 USB library documentation gives a list of the possible return values for my ClassDataSetup() function. One of them, USB_NOT_READY, seems like it should be used when the device isn't ready to respond right away. That makes perfect sense for a USB transaction that requires data to be returned using an operation like an SEEPROM read, which might take a few msec to retrieve the data.

    But the documentation does not explain how to resume the transaction and return the data.

    My presumption is:

    1. In my ClassDataSetup() function (which is called from interrupt context), I save any info I need to complete the request from the setup packet, and set a flag so that my main loop knows to do the EEPROM read. Instead of setting a CopyRoutine, I call SetEPTxStatus(ENDP0, EP_TX_NAK) and return USB_NOT_READY.

    2. In my main loop, I see the flag, pick up the relevant info I saved in step 1, and do the SEEPROM read.

    3. When I've read the data, I need to do something to get the USB core out of state=PAUSE so that it can copy the initial data and resume the transaction.

    What do I do in step 3?

    Thank you!

    -Dan