32F4 USB CDC - any way to tell if Host has retrieved the data sent to it?
The Cube IDE code flow is
CDC_Transmit_FS
USBD_CDC_TransmitPacket
USBD_LL_Transmit
HAL_PCD_EP_Transmit
USB_WritePacket
and the last one does 16 32 bit word transfers to the USB FIFO
HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len, uint8_t dma)
{
uint32_t USBx_BASE = (uint32_t)USBx;
uint32_t *pSrc = (uint32_t *)src;
uint32_t count32b, i;
if (dma == 0U)
{
count32b = ((uint32_t)len + 3U) / 4U;
for (i = 0U; i < count32b; i++)
{
USBx_DFIFO((uint32_t)ch_ep_num) = *((__packed uint32_t *)pSrc);
pSrc++;
}
}
return HAL_OK;
}My Q is whether there is any way to tell when that data has been consumed.
I have been doing tests and found
- there is a ~10kHz rate limit on calling CDC_Transmit_FS
- the max CDC_Transmit_FS packet size is 800 bytes
I am sure these are both system dependent, so I am rate limiting to 1kHz and size limiting to 256 bytes.
There are various return codes from various functions but none of these appear to relate to whether you can shove more data out.
Is USB really "open loop" like that? I know it is all polled by the PC, seemingly at ~10kHz
