mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-04 12:24:11 +01:00
LP-602 Re-enable rx_status checking in usb_csc to optionally reenable rx after reset
This partially reverts 1203fa9e66
LP-495 F4 USB CDC: remove internal rx_active state tracking and use actual endpoint status instead (like F1)
However rx_status is only used in the reinit case, without reintroducing issue LP-495
This commit is contained in:
parent
868d787912
commit
8793aaa387
@ -93,6 +93,7 @@ struct pios_usb_cdc_dev {
|
|||||||
*/
|
*/
|
||||||
uint8_t tx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH - 1] __attribute__((aligned(4)));
|
uint8_t tx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH - 1] __attribute__((aligned(4)));
|
||||||
volatile bool tx_active;
|
volatile bool tx_active;
|
||||||
|
volatile bool rx_active;
|
||||||
|
|
||||||
uint8_t ctrl_tx_packet_buffer[PIOS_USB_BOARD_CDC_MGMT_LENGTH] __attribute__((aligned(4)));
|
uint8_t ctrl_tx_packet_buffer[PIOS_USB_BOARD_CDC_MGMT_LENGTH] __attribute__((aligned(4)));
|
||||||
|
|
||||||
@ -191,8 +192,9 @@ int32_t PIOS_USB_CDC_Init(uint32_t *usbcdc_id, const struct pios_usb_cdc_cfg *cf
|
|||||||
|
|
||||||
pios_usb_cdc_id = (uint32_t)usb_cdc_dev;
|
pios_usb_cdc_id = (uint32_t)usb_cdc_dev;
|
||||||
|
|
||||||
/* Tx is not active yet */
|
/* Tx and Rx are not active yet */
|
||||||
usb_cdc_dev->tx_active = false;
|
usb_cdc_dev->tx_active = false;
|
||||||
|
usb_cdc_dev->rx_active = false;
|
||||||
|
|
||||||
/* Clear stats */
|
/* Clear stats */
|
||||||
usb_cdc_dev->rx_dropped = 0;
|
usb_cdc_dev->rx_dropped = 0;
|
||||||
@ -279,6 +281,7 @@ static void PIOS_USB_CDC_RxStart(uint32_t usbcdc_id, uint16_t rx_bytes_avail)
|
|||||||
PIOS_USBHOOK_EndpointRx(usb_cdc_dev->cfg->data_rx_ep,
|
PIOS_USBHOOK_EndpointRx(usb_cdc_dev->cfg->data_rx_ep,
|
||||||
usb_cdc_dev->rx_packet_buffer,
|
usb_cdc_dev->rx_packet_buffer,
|
||||||
sizeof(usb_cdc_dev->rx_packet_buffer));
|
sizeof(usb_cdc_dev->rx_packet_buffer));
|
||||||
|
usb_cdc_dev->rx_active = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,6 +611,12 @@ static void PIOS_USB_CDC_DATA_IF_Init(uint32_t usb_cdc_id)
|
|||||||
(uint32_t)usb_cdc_dev);
|
(uint32_t)usb_cdc_dev);
|
||||||
usb_cdc_dev->usb_data_if_enabled = true;
|
usb_cdc_dev->usb_data_if_enabled = true;
|
||||||
usb_cdc_dev->tx_active = false;
|
usb_cdc_dev->tx_active = false;
|
||||||
|
/* Check if rx was previously active, if so we need to reactivate */
|
||||||
|
if (usb_cdc_dev->rx_active) {
|
||||||
|
PIOS_USBHOOK_EndpointRx(usb_cdc_dev->cfg->data_rx_ep,
|
||||||
|
usb_cdc_dev->rx_packet_buffer,
|
||||||
|
sizeof(usb_cdc_dev->rx_packet_buffer));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PIOS_USB_CDC_DATA_IF_DeInit(uint32_t usb_cdc_id)
|
static void PIOS_USB_CDC_DATA_IF_DeInit(uint32_t usb_cdc_id)
|
||||||
@ -711,9 +720,11 @@ static bool PIOS_USB_CDC_DATA_EP_OUT_Callback(
|
|||||||
usb_cdc_dev->rx_packet_buffer,
|
usb_cdc_dev->rx_packet_buffer,
|
||||||
sizeof(usb_cdc_dev->rx_packet_buffer));
|
sizeof(usb_cdc_dev->rx_packet_buffer));
|
||||||
rc = true;
|
rc = true;
|
||||||
|
usb_cdc_dev->rx_active = true;
|
||||||
} else {
|
} else {
|
||||||
/* Not enough room left for a message, apply backpressure */
|
/* Not enough room left for a message, apply backpressure */
|
||||||
rc = false;
|
rc = false;
|
||||||
|
usb_cdc_dev->rx_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||||
|
Loading…
Reference in New Issue
Block a user