nrf52 cdc example work on nrf52840pdk
- add tud_cdc_flush(), auto flush with sof is enabled by default. -
This commit is contained in:
@@ -280,18 +280,24 @@ tusb_error_t cdcd_xfer_cb(uint8_t port, uint8_t ep_addr, tusb_event_t event, uin
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
void cdcd_sof(uint8_t port)
|
||||
bool tud_n_cdc_flush (uint8_t port)
|
||||
{
|
||||
if ( !tud_n_cdc_connected(port) ) return;
|
||||
VERIFY( tud_n_cdc_connected(port) );
|
||||
|
||||
uint8_t edpt = cdcd_data[port].ep_addr[CDC_PIPE_DATA_IN];
|
||||
|
||||
if ( !tusb_dcd_edpt_busy(port, edpt) )
|
||||
{
|
||||
uint16_t count = fifo_read_n(&_tx_ff, _tmp_tx_buf, sizeof(_tmp_tx_buf));
|
||||
VERIFY( !tusb_dcd_edpt_busy(port, edpt) );
|
||||
|
||||
TU_ASSERT( tusb_dcd_edpt_xfer(port, edpt, _tmp_tx_buf, count, false), TUSB_ERROR_DCD_EDPT_XFER);
|
||||
}
|
||||
|
||||
uint16_t count = fifo_read_n(&_tx_ff, _tmp_tx_buf, sizeof(_tmp_tx_buf));
|
||||
TU_ASSERT( tusb_dcd_edpt_xfer(port, edpt, _tmp_tx_buf, count, false) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cdcd_sof(uint8_t port)
|
||||
{
|
||||
tud_n_cdc_flush(port);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -63,18 +63,20 @@ uint32_t tud_n_cdc_read (uint8_t port, void* buffer, uint32_t bufsize);
|
||||
|
||||
uint32_t tud_n_cdc_write_char (uint8_t port, char ch);
|
||||
uint32_t tud_n_cdc_write (uint8_t port, void const* buffer, uint32_t bufsize);
|
||||
bool tud_n_cdc_flush (uint8_t port);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API (Single Port)
|
||||
//--------------------------------------------------------------------+
|
||||
static inline bool tud_cdc_connected (void) { return tud_n_cdc_connected(0); }
|
||||
static inline uint32_t tud_cdc_available (void) { return tud_n_cdc_available(0); }
|
||||
static inline bool tud_cdc_connected (void) { return tud_n_cdc_connected(0); }
|
||||
static inline uint32_t tud_cdc_available (void) { return tud_n_cdc_available(0); }
|
||||
|
||||
static inline int tud_cdc_read_char (void) { return tud_n_cdc_read_char(0); }
|
||||
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize) { return tud_n_cdc_read(0, buffer, bufsize); }
|
||||
static inline int tud_cdc_read_char (void) { return tud_n_cdc_read_char(0); }
|
||||
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize) { return tud_n_cdc_read(0, buffer, bufsize); }
|
||||
|
||||
static inline uint32_t tud_cdc_write_char (char ch) { return tud_n_cdc_write_char(0, ch); }
|
||||
static inline uint32_t tud_cdc_write_char (char ch) { return tud_n_cdc_write_char(0, ch); }
|
||||
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize) { return tud_n_cdc_write(0, buffer, bufsize); }
|
||||
static inline bool tud_cdc_flush (void) { return tud_n_cdc_flush(0); }
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION CALLBACK API
|
||||
|
||||
Reference in New Issue
Block a user