mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
add tud_mounted() check in tud_cdc_connected()
mark device as disconnected immed with DCD_EVENT_UNPLUGGED
This commit is contained in:
parent
c09d754654
commit
8fb9fbb0b1
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -40,7 +40,7 @@
|
||||
// Device Data
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct {
|
||||
uint8_t config_num;
|
||||
volatile uint8_t config_num;
|
||||
|
||||
uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
|
||||
uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid )
|
||||
@ -332,7 +332,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
break;
|
||||
|
||||
case TUSB_REQ_GET_CONFIGURATION:
|
||||
data_buf = &_usbd_dev.config_num;
|
||||
data_buf = (uint8_t*) &_usbd_dev.config_num;
|
||||
data_len = 1;
|
||||
break;
|
||||
|
||||
@ -543,7 +543,11 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
||||
switch (event->event_id)
|
||||
{
|
||||
case DCD_EVENT_BUS_RESET:
|
||||
osal_queue_send(_usbd_q, event, in_isr);
|
||||
break;
|
||||
|
||||
case DCD_EVENT_UNPLUGGED:
|
||||
_usbd_dev.config_num = 0; // mark disconnected
|
||||
osal_queue_send(_usbd_q, event, in_isr);
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user