diff options
| author | hathach <[email protected]> | 2018-08-30 15:26:53 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-08-30 15:28:19 +0700 |
| commit | e623fc656d4973ca32b8c9547409e65e12ad9b4c (patch) | |
| tree | b9f1d5a4780d47f3835baf320ce4e581bdb09736 | |
| parent | 4ef01d721ad6b49775f067d89faa5545d918f32f (diff) | |
cdc flush on write() if queue more than epsize
| -rw-r--r-- | src/class/cdc/cdc_device.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 6858b6ad0..2215e00ea 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -146,12 +146,20 @@ void tud_cdc_n_read_flush (uint8_t itf) uint32_t tud_cdc_n_write_char(uint8_t itf, char ch)
{
- return tu_fifo_write(&_cdcd_itf[itf].tx_ff, &ch) ? 1 : 0;
+ return tud_cdc_n_write(itf, &ch, 1);
}
uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize)
{
- return tu_fifo_write_n(&_cdcd_itf[itf].tx_ff, buffer, bufsize);
+ uint16_t ret = tu_fifo_write_n(&_cdcd_itf[itf].tx_ff, buffer, bufsize);
+
+ // flush if queue more than endpoint size
+ if ( tu_fifo_count(&_cdcd_itf[itf].tx_ff) >= CFG_TUD_CDC_EPSIZE )
+ {
+ tud_cdc_n_write_flush(itf);
+ }
+
+ return ret;
}
bool tud_cdc_n_write_flush (uint8_t itf)
|
