2019-12-19 05:36 PM
I'm implementing USB CDC for my project.
In the USB callback function (CDC_Receive_HS), I copy the contents to a user's data array and exit the function. I process the received data in the main function. (not in USB interrupt routine)
What I want to do is not to receive any data while while the program is processing the data.
After data processing is done, re-enable the receiving.
(I think) the most proper way is to make USB engine response to OUT with NACK.
Is there a way to enable/disable "Response to OUT with NACK" ?
Is there more appropriate way ?
Solved! Go to Solution.
2019-12-20 09:06 AM
In CDC_Receive_HS(), don't re-enable the receive process (for USB FS devices, that is USBD_CDC_SetRxBuffer() and USBD_CDC_ReceivePacket(), I don't know what functions HS interfaces use). Then in your main loop, when you are done processing the data call those two functions (or their HS equivalent) to tell the UBS interface to stop NAK-ing and accept more data.
2019-12-20 09:06 AM
In CDC_Receive_HS(), don't re-enable the receive process (for USB FS devices, that is USBD_CDC_SetRxBuffer() and USBD_CDC_ReceivePacket(), I don't know what functions HS interfaces use). Then in your main loop, when you are done processing the data call those two functions (or their HS equivalent) to tell the UBS interface to stop NAK-ing and accept more data.
2019-12-22 10:24 PM
Great Thanks.
As your comment, "moving USBD_CDC_ReceivePacket( ) into main routine" does what I want.
if USBD_CDC_ReceivePacket( ) is not called in ISR (interrupt service routine), USBD_CDC OUT (from PC to MCU) is not activated (MCU responses with NACK).
After I finish all necessary processing and call USBD_CDC_ReceivePacket ( ), USB_CD_ OUT is activated back.