mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-22 06:40:58 +00:00
Smarter CDC TX refill logic
This commit is contained in:
parent
7ae47a9397
commit
15b063beb2
@ -416,7 +416,12 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
|
|||||||
// Though maybe the baudrate is not really important !!!
|
// Though maybe the baudrate is not really important !!!
|
||||||
if ( ep_addr == p_cdc->ep_in )
|
if ( ep_addr == p_cdc->ep_in )
|
||||||
{
|
{
|
||||||
if ( 0 == tud_cdc_n_write_flush(itf) )
|
uint32_t flushed = tud_cdc_n_write_flush(itf);
|
||||||
|
|
||||||
|
// invoke transmit callback to possibly refill tx fifo
|
||||||
|
if ( tud_cdc_tx_complete_cb ) tud_cdc_tx_complete_cb(itf);
|
||||||
|
|
||||||
|
if ( 0 == flushed && tu_fifo_empty(&p_cdc->tx_ff) )
|
||||||
{
|
{
|
||||||
// There is no data left, a ZLP should be sent if
|
// There is no data left, a ZLP should be sent if
|
||||||
// xferred_bytes is multiple of EP size and not zero
|
// xferred_bytes is multiple of EP size and not zero
|
||||||
@ -425,9 +430,6 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
|
|||||||
usbd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_in, NULL, 0);
|
usbd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_in, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke transmit callback to possibly refill tx fifo
|
|
||||||
if ( tud_cdc_tx_cb && !tu_fifo_full(&p_cdc->tx_ff) ) tud_cdc_tx_cb(itf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nothing to do with notif endpoint for now
|
// nothing to do with notif endpoint for now
|
||||||
|
@ -129,7 +129,7 @@ TU_ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf);
|
|||||||
TU_ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char);
|
TU_ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char);
|
||||||
|
|
||||||
// Invoked when space becomes available in TX buffer
|
// Invoked when space becomes available in TX buffer
|
||||||
TU_ATTR_WEAK void tud_cdc_tx_cb(uint8_t itf);
|
TU_ATTR_WEAK void tud_cdc_tx_complete_cb(uint8_t itf);
|
||||||
|
|
||||||
// Invoked when line state DTR & RTS are changed via SET_CONTROL_LINE_STATE
|
// Invoked when line state DTR & RTS are changed via SET_CONTROL_LINE_STATE
|
||||||
TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
|
TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user