From 8fb9fbb0b19de3422645e65fbd422c86cb548c62 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Mar 2019 23:58:24 +0700 Subject: add tud_mounted() check in tud_cdc_connected() mark device as disconnected immed with DCD_EVENT_UNPLUGGED --- src/class/cdc/cdc_device.c | 2 +- src/class/cdc/cdc_device.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/class') diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 2ac8d471c..7b8f1bf72 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -99,7 +99,7 @@ static void _prep_out_transaction (uint8_t itf) bool tud_cdc_n_connected(uint8_t itf) { // DTR (bit 0) active is considered as connected - return TU_BIT_TEST(_cdcd_itf[itf].line_state, 0); + return tud_mounted() && TU_BIT_TEST(_cdcd_itf[itf].line_state, 0); } uint8_t tud_cdc_n_get_line_state (uint8_t itf) diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index 468edef45..d9a200dd4 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -97,7 +97,6 @@ ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_li //--------------------------------------------------------------------+ // INTERNAL USBD-CLASS DRIVER API - //--------------------------------------------------------------------+ void cdcd_init (void); bool cdcd_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); -- cgit v1.3.1