stm32/usbd_cdc_interface: Handle disconnect IRQ to set VCP disconnected.
pyb.USB_VCP().isconnected() will now return False if the USB is disconnected after having previously been connected. See issue #4210.
This commit is contained in:
parent
de71035e02
commit
53ccbe6cec
|
@ -81,6 +81,11 @@ uint8_t *usbd_cdc_init(usbd_cdc_state_t *cdc_in) {
|
|||
return cdc->rx_packet_buf;
|
||||
}
|
||||
|
||||
void usbd_cdc_deinit(usbd_cdc_state_t *cdc_in) {
|
||||
usbd_cdc_itf_t *cdc = (usbd_cdc_itf_t*)cdc_in;
|
||||
cdc->dev_is_connected = 0;
|
||||
}
|
||||
|
||||
// Manage the CDC class requests
|
||||
// cmd: command code
|
||||
// pbuf: buffer containing command data (request parameters)
|
||||
|
|
|
@ -185,6 +185,7 @@ uint8_t USBD_HID_ClearNAK(usbd_hid_state_t *usbd);
|
|||
|
||||
// These are provided externally to implement the CDC interface
|
||||
uint8_t *usbd_cdc_init(usbd_cdc_state_t *cdc);
|
||||
void usbd_cdc_deinit(usbd_cdc_state_t *cdc);
|
||||
int8_t usbd_cdc_control(usbd_cdc_state_t *cdc, uint8_t cmd, uint8_t* pbuf, uint16_t length);
|
||||
int8_t usbd_cdc_receive(usbd_cdc_state_t *cdc, size_t len);
|
||||
|
||||
|
|
|
@ -820,6 +820,8 @@ static uint8_t USBD_CDC_MSC_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
if ((usbd->usbd_mode & USBD_MODE_CDC) && usbd->cdc) {
|
||||
// CDC VCP component
|
||||
|
||||
usbd_cdc_deinit(usbd->cdc);
|
||||
|
||||
// close endpoints
|
||||
USBD_LL_CloseEP(pdev, CDC_IN_EP);
|
||||
USBD_LL_CloseEP(pdev, CDC_OUT_EP);
|
||||
|
@ -830,6 +832,8 @@ static uint8_t USBD_CDC_MSC_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
if ((usbd->usbd_mode & USBD_MODE_CDC2) && usbd->cdc2) {
|
||||
// CDC VCP #2 component
|
||||
|
||||
usbd_cdc_deinit(usbd->cdc2);
|
||||
|
||||
// close endpoints
|
||||
USBD_LL_CloseEP(pdev, CDC2_IN_EP);
|
||||
USBD_LL_CloseEP(pdev, CDC2_OUT_EP);
|
||||
|
|
Loading…
Reference in New Issue