|
34 | 34 | //--------------------------------------------------------------------+ |
35 | 35 | // MACRO CONSTANT TYPEDEF |
36 | 36 | //--------------------------------------------------------------------+ |
| 37 | +enum |
| 38 | +{ |
| 39 | + BULK_PACKET_SIZE = (TUD_OPT_HIGH_SPEED ? 512 : 64) |
| 40 | +}; |
| 41 | + |
37 | 42 | typedef struct |
38 | 43 | { |
39 | 44 | uint8_t itf_num; |
@@ -160,13 +165,11 @@ uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize) |
160 | 165 | cdcd_interface_t* p_cdc = &_cdcd_itf[itf]; |
161 | 166 | uint16_t ret = tu_fifo_write_n(&p_cdc->tx_ff, buffer, bufsize); |
162 | 167 |
|
163 | | -#if 0 // TODO issue with circuitpython's REPL |
164 | | - // flush if queue more than endpoint size |
165 | | - if ( tu_fifo_count(&p_cdc->tx_ff) >= CFG_TUD_CDC_EP_BUFSIZE ) |
| 168 | + // flush if queue more than packet size |
| 169 | + if ( tu_fifo_count(&p_cdc->tx_ff) >= BULK_PACKET_SIZE ) |
166 | 170 | { |
167 | 171 | tud_cdc_n_write_flush(itf); |
168 | 172 | } |
169 | | -#endif |
170 | 173 |
|
171 | 174 | return ret; |
172 | 175 | } |
@@ -250,8 +253,8 @@ void cdcd_reset(uint8_t rhport) |
250 | 253 | uint16_t cdcd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len) |
251 | 254 | { |
252 | 255 | // Only support ACM subclass |
253 | | - TU_VERIFY ( TUSB_CLASS_CDC == itf_desc->bInterfaceClass && |
254 | | - CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL == itf_desc->bInterfaceSubClass, 0); |
| 256 | + TU_VERIFY( TUSB_CLASS_CDC == itf_desc->bInterfaceClass && |
| 257 | + CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL == itf_desc->bInterfaceSubClass, 0); |
255 | 258 |
|
256 | 259 | // Note: 0xFF can be used with RNDIS |
257 | 260 | TU_VERIFY(tu_within(CDC_COMM_PROTOCOL_NONE, itf_desc->bInterfaceProtocol, CDC_COMM_PROTOCOL_ATCOMMAND_CDMA), 0); |
@@ -446,9 +449,8 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_ |
446 | 449 | if ( 0 == tud_cdc_n_write_flush(itf) ) |
447 | 450 | { |
448 | 451 | // If there is no data left, a ZLP should be sent if |
449 | | - // xferred_bytes is multiple of EP size and not zero |
450 | | - // FIXME CFG_TUD_CDC_EP_BUFSIZE is not Endpoint packet size |
451 | | - if ( !tu_fifo_count(&p_cdc->tx_ff) && xferred_bytes && (0 == (xferred_bytes % CFG_TUD_CDC_EP_BUFSIZE)) ) |
| 452 | + // xferred_bytes is multiple of EP Packet size and not zero |
| 453 | + if ( !tu_fifo_count(&p_cdc->tx_ff) && xferred_bytes && (0 == (xferred_bytes & (BULK_PACKET_SIZE-1))) ) |
452 | 454 | { |
453 | 455 | if ( usbd_edpt_claim(rhport, p_cdc->ep_in) ) |
454 | 456 | { |
|
0 commit comments