summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2020-08-21 11:14:06 +0700
committerGitHub <[email protected]>2020-08-21 11:14:06 +0700
commite5d622b749593d5bab893a8d6a826b1d384677ac (patch)
tree7e93890839e0db93b791d521736b66279510f4c3 /src/class
parente90cf7a676eddcbd9c35d2d99a0a9cd14686e2ce (diff)
parent72183c7bb44ff117d9abac7b6e9c373c0945fb0b (diff)
Merge pull request #434 from gh2o/master
Add TX callback to CDC device
Diffstat (limited to 'src/class')
-rw-r--r--src/class/cdc/cdc_device.c3
-rw-r--r--src/class/cdc/cdc_device.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index 89326f71d..94473d036 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -416,6 +416,9 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
// Though maybe the baudrate is not really important !!!
if ( ep_addr == p_cdc->ep_in )
{
+ // invoke transmit callback to possibly refill tx fifo
+ if ( tud_cdc_tx_complete_cb ) tud_cdc_tx_complete_cb(itf);
+
if ( 0 == tud_cdc_n_write_flush(itf) )
{
// There is no data left, a ZLP should be sent if
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h
index 9d257bbe9..f9692e20f 100644
--- a/src/class/cdc/cdc_device.h
+++ b/src/class/cdc/cdc_device.h
@@ -133,6 +133,9 @@ TU_ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf);
// Invoked when received `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
+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
TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);