Skip to content
Discussion options

You must be logged in to vote

The buffering scheme for cdc may sound complicated but is very simply.

  • cdc write() will put application contents into an cdc's fifo
  • tinyusb will send data to usb bus (flush) when enough data is buffered, mostly 64 bytes for fullspeed and 512 bytes for highspeed.
  • flush() will manually force data (even less than 64 bytes) to be sent to bus immediately.
  • Each bus transfer typically take 1 ms for FS, 125 us for HS.

back to your code, 1st flush() will sent data to bus, 2nd and 3rd flush() will return 0 since the usb bus is busy already. Data remains in the fifo, keeping bumping data will overflow the fifo. You should either add check to see if cdc is ready or write_available(), or increase fifo.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Mrcubix
Comment options

@hathach
Comment options

Answer selected by Mrcubix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants