rename tud_cdc_flush() to tud_cdc_write_flush(), add tud_cdc_read_flush()

This commit is contained in:
hathach 2018-07-14 23:43:19 +07:00
parent 19b6bbfd14
commit abb37e98ba
7 changed files with 14 additions and 7 deletions

View File

@ -90,7 +90,7 @@
// TX is sent automatically every Start of Frame event.
// If not enabled, application must call tud_cdc_flush() periodically
// If not enabled, application must call tud_cdc_write_flush() periodically
#define CFG_TUD_CDC_FLUSH_ON_SOF 1
//--------------------------------------------------------------------+

View File

@ -87,7 +87,7 @@ void virtual_com_task(void)
uint32_t count = tud_cdc_read(buf, sizeof(buf));
tud_cdc_write(buf, count);
tud_cdc_flush();
tud_cdc_write_flush();
}
}

View File

@ -86,7 +86,7 @@
#define CFG_TUD_CDC_TX_BUFSIZE 64
// TX is sent automatically every Start of Frame event.
// If not enabled, application must call tud_cdc_flush() periodically
// If not enabled, application must call tud_cdc_write_flush() periodically
#define CFG_TUD_CDC_FLUSH_ON_SOF 0
/*------------------------------------------------------------------*/

View File

@ -88,7 +88,7 @@
// TX is sent automatically in Start of Frame event.
// If not enabled, application must call tud_cdc_flush() periodically
// If not enabled, application must call tud_cdc_write_flush() periodically
#define CFG_TUD_CDC_FLUSH_ON_SOF 1

View File

@ -136,6 +136,11 @@ char tud_cdc_n_peek(uint8_t itf, int pos)
return tu_fifo_peek_at(&_cdcd_itf[itf].intact.rx_ff, pos, &ch) ? ch : (-1);
}
void tud_cdc_n_read_flush (uint8_t itf)
{
tu_fifo_clear(&_cdcd_itf[itf].intact.rx_ff);
}
//--------------------------------------------------------------------+
// WRITE API
//--------------------------------------------------------------------+
@ -150,7 +155,7 @@ uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize)
return tu_fifo_write_n(&_cdcd_itf[itf].intact.tx_ff, buffer, bufsize);
}
bool tud_cdc_n_flush (uint8_t itf)
bool tud_cdc_n_write_flush (uint8_t itf)
{
uint8_t edpt = _cdcd_itf[itf].ep_in;
VERIFY( !dcd_edpt_busy(TUD_RHPORT, edpt) ); // skip if previous transfer not complete

View File

@ -64,11 +64,12 @@ void tud_cdc_n_set_wanted_char (uint8_t itf, char wanted);
uint32_t tud_cdc_n_available (uint8_t itf);
char tud_cdc_n_read_char (uint8_t itf);
uint32_t tud_cdc_n_read (uint8_t itf, void* buffer, uint32_t bufsize);
void tud_cdc_n_read_flush (uint8_t itf);
char tud_cdc_n_peek (uint8_t itf, int pos);
uint32_t tud_cdc_n_write_char (uint8_t itf, char ch);
uint32_t tud_cdc_n_write (uint8_t itf, void const* buffer, uint32_t bufsize);
bool tud_cdc_n_flush (uint8_t itf);
bool tud_cdc_n_write_flush (uint8_t itf);
//--------------------------------------------------------------------+
// APPLICATION API (Interface0)
@ -85,7 +86,7 @@ static inline char tud_cdc_peek (int pos)
static inline uint32_t tud_cdc_write_char (char ch) { return tud_cdc_n_write_char(0, ch); }
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize) { return tud_cdc_n_write(0, buffer, bufsize); }
static inline bool tud_cdc_flush (void) { return tud_cdc_n_flush(0); }
static inline bool tud_cdc_write_flush (void) { return tud_cdc_n_write_flush(0); }
//--------------------------------------------------------------------+
// APPLICATION CALLBACK API (WEAK is optional)

View File

@ -61,6 +61,7 @@
// VERIFY Helper
//--------------------------------------------------------------------+
#if CFG_TUSB_DEBUG >= 1
#include <stdio.h>
#define _MESS_ERR(_err) printf("%s: %d: failed, error = %s\n", __func__, __LINE__, tusb_strerr[_err])
#define _MESS_FAILED() printf("%s: %d: failed\n", __func__, __LINE__)
#else