32 while (written < len) {
33 size_t avail = tud_cdc_write_available();
36 tud_cdc_write_flush();
38 avail = tud_cdc_write_available();
44 size_t to_write = (len - written) < avail ? (len - written) : avail;
45 size_t n = tud_cdc_write(data + written, to_write);
53 tud_cdc_write_flush();
59 return write(
reinterpret_cast<const uint8_t*
>(str), strlen(str));
67 if (tud_cdc_write_available() == 0) {
68 tud_cdc_write_flush();
70 if (tud_cdc_write_available() == 0) {
75 return tud_cdc_write_char(
byte) == 1;
79 if (!tud_cdc_available()) {
82 return tud_cdc_read(data, max_len);
86 if (!tud_cdc_available()) {
89 return tud_cdc_read_char();
93 return tud_cdc_available();
97 return tud_cdc_connected();
101 bool ready = tud_ready();
120 tud_cdc_write_flush();
123 for (
int i = 0; i < 1000; i++) {
125 if (tud_cdc_write_available() == CFG_TUD_CDC_TX_BUFSIZE) {
129 for (
volatile int j = 0; j < 1000; j++) {}
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
static volatile bool s_dtr_rose
USB CDC (Virtual COM Port) interface.
static size_t write(const uint8_t *data, size_t len)
Write data to USB serial (non-blocking)
static size_t puts(const char *str)
Write null-terminated string.
static void flush()
Flush TX buffer.
static size_t available()
Get number of bytes available to read.
static size_t read(uint8_t *data, size_t max_len)
Read data from USB serial (non-blocking)
static bool write_byte(uint8_t byte)
Write single byte.
static bool connected()
Check if host has terminal connected (DTR set)
static bool just_connected()
Check if a terminal just connected (DTR rising edge)
static int read_byte()
Read single byte.
bool ready()
Check if USB is enumerated and ready.