@@ -550,50 +550,48 @@ void cdch_close(uint8_t daddr)
550550 }
551551}
552552
553- bool cdch_xfer_cb (uint8_t daddr , uint8_t ep_addr , xfer_result_t event , uint32_t xferred_bytes )
554- {
553+ bool cdch_xfer_cb (uint8_t daddr , uint8_t ep_addr , xfer_result_t event , uint32_t xferred_bytes ) {
555554 // TODO handle stall response, retry failed transfer ...
556555 TU_ASSERT (event == XFER_RESULT_SUCCESS );
557556
558557 uint8_t const idx = get_idx_by_ep_addr (daddr , ep_addr );
559558 cdch_interface_t * p_cdc = get_itf (idx );
560559 TU_ASSERT (p_cdc );
561560
562- if ( ep_addr == p_cdc -> stream .tx .ep_addr )
563- {
561+ if ( ep_addr == p_cdc -> stream .tx .ep_addr ) {
564562 // invoke tx complete callback to possibly refill tx fifo
565563 if (tuh_cdc_tx_complete_cb ) tuh_cdc_tx_complete_cb (idx );
566564
567- if ( 0 == tu_edpt_stream_write_xfer (& p_cdc -> stream .tx ) )
568- {
565+ if ( 0 == tu_edpt_stream_write_xfer (& p_cdc -> stream .tx ) ) {
569566 // If there is no data left, a ZLP should be sent if:
570567 // - xferred_bytes is multiple of EP Packet size and not zero
571568 tu_edpt_stream_write_zlp_if_needed (& p_cdc -> stream .tx , xferred_bytes );
572569 }
573570 }
574- else if ( ep_addr == p_cdc -> stream .rx .ep_addr )
575- {
576- tu_edpt_stream_read_xfer_complete (& p_cdc -> stream .rx , xferred_bytes );
577-
571+ else if ( ep_addr == p_cdc -> stream .rx .ep_addr ) {
578572 #if CFG_TUH_CDC_FTDI
579- // FTDI reserve 2 bytes for status
580573 if (p_cdc -> serial_drid == SERIAL_DRIVER_FTDI ) {
581- uint8_t status [2 ];
582- tu_edpt_stream_read (& p_cdc -> stream .rx , status , 2 );
583- (void ) status ; // TODO handle status
584- }
574+ // FTDI reserve 2 bytes for status
575+ // FTDI status
576+ // uint8_t status[2] = {
577+ // p_cdc->stream.rx.ep_buf[0],
578+ // p_cdc->stream.rx.ep_buf[1]
579+ // };
580+ tu_edpt_stream_read_xfer_complete_offset (& p_cdc -> stream .rx , xferred_bytes , 2 );
581+ }else
585582 #endif
583+ {
584+ tu_edpt_stream_read_xfer_complete (& p_cdc -> stream .rx , xferred_bytes );
585+ }
586586
587587 // invoke receive callback
588588 if (tuh_cdc_rx_cb ) tuh_cdc_rx_cb (idx );
589589
590590 // prepare for next transfer if needed
591591 tu_edpt_stream_read_xfer (& p_cdc -> stream .rx );
592- }else if ( ep_addr == p_cdc -> ep_notif )
593- {
592+ }else if ( ep_addr == p_cdc -> ep_notif ) {
594593 // TODO handle notification endpoint
595- }else
596- {
594+ }else {
597595 TU_ASSERT (false);
598596 }
599597
0 commit comments