Skip to content

Commit 9e8ea44

Browse files
committed
add tuh_cdc_write_clear, rename read_flush() to read_clear()
1 parent cd9008e commit 9e8ea44

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/class/cdc/cdc_host.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,16 @@ uint32_t tu_edpt_stream_write_available(tu_edpt_stream_t* s)
190190
return (uint32_t) tu_fifo_remaining(&s->ff);
191191
}
192192

193-
void tu_edpt_stream_read_clear(uint8_t daddr, tu_edpt_stream_t* s)
193+
bool tu_edpt_stream_read_clear(uint8_t daddr, tu_edpt_stream_t* s)
194194
{
195-
tu_fifo_clear(&s->ff);
195+
bool ret = tu_fifo_clear(&s->ff);
196196
tu_edpt_stream_read_xfer(daddr, s);
197+
return ret;
198+
}
199+
200+
bool tu_edpt_stream_write_clear(tu_edpt_stream_t* s)
201+
{
202+
return tu_fifo_clear(&s->ff);
197203
}
198204

199205
typedef struct {
@@ -331,6 +337,14 @@ uint32_t tuh_cdc_write_flush(uint8_t idx)
331337
return tu_edpt_stream_write_xfer(p_cdc->daddr, &p_cdc->stream.tx);
332338
}
333339

340+
bool tuh_cdc_write_clear(uint8_t idx)
341+
{
342+
cdch_interface_t* p_cdc = get_itf(idx);
343+
TU_VERIFY(p_cdc);
344+
345+
return tu_edpt_stream_write_clear(&p_cdc->stream.tx);
346+
}
347+
334348
uint32_t tuh_cdc_write_available(uint8_t idx)
335349
{
336350
cdch_interface_t* p_cdc = get_itf(idx);
@@ -355,12 +369,12 @@ uint32_t tuh_cdc_read_available(uint8_t idx)
355369
return tu_edpt_stream_read_available(&p_cdc->stream.rx);
356370
}
357371

358-
void tuh_cdc_read_flush (uint8_t idx)
372+
bool tuh_cdc_read_clear (uint8_t idx)
359373
{
360374
cdch_interface_t* p_cdc = get_itf(idx);
361-
TU_VERIFY(p_cdc, );
375+
TU_VERIFY(p_cdc);
362376

363-
tu_edpt_stream_read_clear(p_cdc->daddr, &p_cdc->stream.rx);
377+
return tu_edpt_stream_read_clear(p_cdc->daddr, &p_cdc->stream.rx);
364378
}
365379

366380
//--------------------------------------------------------------------+

src/class/cdc/cdc_host.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ uint32_t tuh_cdc_write(uint8_t idx, void const* buffer, uint32_t bufsize);
110110
// Force sending data if possible, return number of forced bytes
111111
uint32_t tuh_cdc_write_flush(uint8_t idx);
112112

113+
// Clear the transmit FIFO
114+
bool tuh_cdc_write_clear(uint8_t idx);
115+
113116
//--------------------------------------------------------------------+
114117
// Read API
115118
//--------------------------------------------------------------------+
@@ -121,7 +124,7 @@ uint32_t tuh_cdc_read_available(uint8_t idx);
121124
uint32_t tuh_cdc_read (uint8_t idx, void* buffer, uint32_t bufsize);
122125

123126
// Clear the received FIFO
124-
void tuh_cdc_read_flush (uint8_t idx);
127+
bool tuh_cdc_read_clear (uint8_t idx);
125128

126129
//--------------------------------------------------------------------+
127130
// Control Endpoint (Request) API

0 commit comments

Comments
 (0)