Explorar o código

fix cdc_device flush send zero bytes

hathach %!s(int64=8) %!d(string=hai) anos
pai
achega
fb27ae96b0
Modificáronse 2 ficheiros con 7 adicións e 3 borrados
  1. 5 1
      tinyusb/class/cdc/cdc_device.c
  2. 2 2
      tinyusb/class/cdc/cdc_device.h

+ 5 - 1
tinyusb/class/cdc/cdc_device.c

@@ -289,7 +289,11 @@ bool tud_n_cdc_flush (uint8_t rhport)
   VERIFY( !dcd_edpt_busy(rhport, edpt) );
 
   uint16_t count = fifo_read_n(&_tx_ff, _tmp_tx_buf, sizeof(_tmp_tx_buf));
-  TU_ASSERT( dcd_edpt_xfer(rhport, edpt, _tmp_tx_buf, count) );
+  
+  if ( count ) 
+  {
+    TU_ASSERT( dcd_edpt_xfer(rhport, edpt, _tmp_tx_buf, count) );
+  }
 
   return true;
 }

+ 2 - 2
tinyusb/class/cdc/cdc_device.h

@@ -79,10 +79,10 @@ static inline uint32_t tud_cdc_write      (void const* buffer, uint32_t bufsize)
 static inline bool     tud_cdc_flush      (void)                                 { return tud_n_cdc_flush(0);                  }
 
 //--------------------------------------------------------------------+
-// APPLICATION CALLBACK API
+// APPLICATION CALLBACK API (WEAK is optional)
 //--------------------------------------------------------------------+
 //void tud_cdc_line_coding_changed_cb(uint8_t rhport, cdc_line_coding_t* p_line_coding);
-void tud_cdc_rx_cb(uint8_t rhport);
+void tud_cdc_rx_cb(uint8_t rhport) ATTR_WEAK;
 
 //--------------------------------------------------------------------+
 // USBD-CLASS DRIVER API