Skip to content

Commit

Permalink
rename tud_cdc_flush() to tud_cdc_write_flush(), add tud_cdc_read_flu…
Browse files Browse the repository at this point in the history
…sh()
  • Loading branch information
hathach committed Jul 14, 2018
1 parent 19b6bbf commit abb37e9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/device/device_virtual_com/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

//--------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion examples/device/nrf52840/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/device/nrf52840/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion examples/obsolete/device/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 6 additions & 1 deletion src/class/cdc/cdc_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
//--------------------------------------------------------------------+
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/class/cdc/cdc_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/common/tusb_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abb37e9

Please sign in to comment.