Throttling data from USB serial connection on STM32 microcontroller (flow control)
I appear to have got this working:

void EP3_OUT_Callback(void) {
 ...
  //SetEPRxValid(ENDP3); //&lt;-- Commented out
  SetEPRxStatus(ENDP3, Do_I_Have_Room_For_More_Data() ? EP_RX_VALID : EP_RX_NAK); //&lt;-- Added this
}

void SOF_Callback(void) {
  if(bDeviceState == CONFIGURED) {
    SetEPRxStatus(ENDP3, Do_I_Have_Room_For_More_Data() ? EP_RX_VALID : EP_RX_NAK); //&lt;-- Added this
    ...
    // Original TX code here
  }
}


What's happening is after getting data, and in the Start of Frame callback (every 1ms), I set whether the endpoint is accepting data.

Note: The docs never seem to say just how much data USB_SIL_Read will read - potentially leading to a buffer overrun. However I believe the maximum is what is in VIRTUAL_COM_PORT_DATA_SIZE - and this seems to work great for me.

This would appear to work - however I have no idea if it is the 'right' way of doing it. Please let me know if it's wrong and I'll update it!