@@ -91,9 +91,8 @@ struct pios_usb_cdc_dev {
9191 * that are strictly < maxPacketSize for this interface which means we never have
9292 * to bother with zero length packets (ZLP).
9393 */
94- uint8_t tx_packet_buffer [PIOS_USB_BOARD_CDC_DATA_LENGTH - 1 ] __attribute__((aligned (4 )));
94+ uint8_t tx_packet_buffer [PIOS_USB_BOARD_CDC_DATA_LENGTH - 1 ] __attribute__((aligned (4 )));
9595 volatile bool tx_active ;
96- volatile bool rx_active ;
9796
9897 uint8_t ctrl_tx_packet_buffer [PIOS_USB_BOARD_CDC_MGMT_LENGTH ] __attribute__((aligned (4 )));
9998
@@ -194,7 +193,6 @@ int32_t PIOS_USB_CDC_Init(uint32_t *usbcdc_id, const struct pios_usb_cdc_cfg *cf
194193
195194 /* Tx and Rx are not active yet */
196195 usb_cdc_dev -> tx_active = false;
197- usb_cdc_dev -> rx_active = false;
198196
199197 /* Clear stats */
200198 usb_cdc_dev -> rx_dropped = 0 ;
@@ -281,7 +279,6 @@ static void PIOS_USB_CDC_RxStart(uint32_t usbcdc_id, uint16_t rx_bytes_avail)
281279 PIOS_USBHOOK_EndpointRx (usb_cdc_dev -> cfg -> data_rx_ep ,
282280 usb_cdc_dev -> rx_packet_buffer ,
283281 sizeof (usb_cdc_dev -> rx_packet_buffer ));
284- usb_cdc_dev -> rx_active = true;
285282 }
286283}
287284
@@ -611,12 +608,10 @@ static void PIOS_USB_CDC_DATA_IF_Init(uint32_t usb_cdc_id)
611608 (uint32_t )usb_cdc_dev );
612609 usb_cdc_dev -> usb_data_if_enabled = true;
613610 usb_cdc_dev -> tx_active = false;
614- /* Check if rx was previously active, if so we need to reactivate */
615- if (usb_cdc_dev -> rx_active ) {
616- PIOS_USBHOOK_EndpointRx (usb_cdc_dev -> cfg -> data_rx_ep ,
617- usb_cdc_dev -> rx_packet_buffer ,
618- sizeof (usb_cdc_dev -> rx_packet_buffer ));
619- }
611+ /* Activate rx prophylactically */
612+ PIOS_USBHOOK_EndpointRx (usb_cdc_dev -> cfg -> data_rx_ep ,
613+ usb_cdc_dev -> rx_packet_buffer ,
614+ sizeof (usb_cdc_dev -> rx_packet_buffer ));
620615}
621616
622617static void PIOS_USB_CDC_DATA_IF_DeInit (uint32_t usb_cdc_id )
@@ -720,11 +715,9 @@ static bool PIOS_USB_CDC_DATA_EP_OUT_Callback(
720715 usb_cdc_dev -> rx_packet_buffer ,
721716 sizeof (usb_cdc_dev -> rx_packet_buffer ));
722717 rc = true;
723- usb_cdc_dev -> rx_active = true;
724718 } else {
725719 /* Not enough room left for a message, apply backpressure */
726720 rc = false;
727- usb_cdc_dev -> rx_active = false;
728721 }
729722
730723#if defined(PIOS_INCLUDE_FREERTOS )
0 commit comments