diff --git a/examples/device/src/tusb_descriptors.c b/examples/device/src/tusb_descriptors.c index 4a58161f..82d9d1fb 100644 --- a/examples/device/src/tusb_descriptors.c +++ b/examples/device/src/tusb_descriptors.c @@ -181,7 +181,7 @@ app_descriptor_configuration_t const desc_configuration = .bConfigurationValue = 1, .iConfiguration = 0x00, .bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER, - .bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100) + .bMaxPower = TUSB_DESC_CONFIG_POWER_MA(500) }, #if TUSB_CFG_DEVICE_CDC @@ -222,14 +222,22 @@ app_descriptor_configuration_t const desc_configuration = .bcdCDC = 0x0120 }, + .cdc_call = + { + .bLength = sizeof(cdc_desc_func_call_management_t), + .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC, + .bDescriptorSubType = CDC_FUNC_DESC_CALL_MANAGEMENT, + .bmCapabilities = { 0 }, + .bDataInterface = INTERFACE_NO_CDC+1, + }, + .cdc_acm = { .bLength = sizeof(cdc_desc_func_abstract_control_management_t), .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC, .bDescriptorSubType = CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, - .bmCapabilities = { // 0x06 + .bmCapabilities = { // 0x02 .support_line_request = 1, - .support_send_break = 1 } }, @@ -238,8 +246,8 @@ app_descriptor_configuration_t const desc_configuration = .bLength = sizeof(cdc_desc_func_union_t), // plus number of .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC, .bDescriptorSubType = CDC_FUNC_DESC_UNION, - .bControlInterface = 0, - .bSubordinateInterface = 1, + .bControlInterface = INTERFACE_NO_CDC, + .bSubordinateInterface = INTERFACE_NO_CDC+1, }, .cdc_endpoint_notification = @@ -249,7 +257,7 @@ app_descriptor_configuration_t const desc_configuration = .bEndpointAddress = CDC_EDPT_NOTIFICATION_ADDR, .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT }, .wMaxPacketSize = { .size = 0x08 }, - .bInterval = 0x0a + .bInterval = 0x10 }, //------------- CDC Data Interface -------------// diff --git a/examples/device/src/tusb_descriptors.h b/examples/device/src/tusb_descriptors.h index e6a9c01a..322af039 100644 --- a/examples/device/src/tusb_descriptors.h +++ b/examples/device/src/tusb_descriptors.h @@ -130,7 +130,7 @@ //--------------------------------------------------------------------+ // CONFIGURATION DESCRIPTOR //--------------------------------------------------------------------+ -typedef ATTR_PACKED_STRUCT(struct) +typedef struct ATTR_PACKED { tusb_descriptor_configuration_t configuration; @@ -141,6 +141,7 @@ typedef ATTR_PACKED_STRUCT(struct) //CDC Control Interface tusb_descriptor_interface_t cdc_comm_interface; cdc_desc_func_header_t cdc_header; + cdc_desc_func_call_management_t cdc_call; cdc_desc_func_abstract_control_management_t cdc_acm; cdc_desc_func_union_t cdc_union; tusb_descriptor_endpoint_t cdc_endpoint_notification; diff --git a/tinyusb/class/cdc/cdc_device.c b/tinyusb/class/cdc/cdc_device.c index 9867b9e6..f15255e4 100644 --- a/tinyusb/class/cdc/cdc_device.c +++ b/tinyusb/class/cdc/cdc_device.c @@ -103,7 +103,13 @@ void cdcd_init(void) // default line coding is : stop bit = 1, parity = none, data bits = 8 memclr_(cdcd_line_coding, sizeof(cdc_line_coding_t)*CONTROLLER_DEVICE_NUMBER); - for(uint8_t i=0; iwValue == ACTIVE_DTE_PRESENT) + { + // terminal connected + } + else if (p_request->wValue == ACTIVE_DTE_NOT_PRESENT) + { + // terminal disconnected + }else + { + // De-active --> disconnected + } + } break; default: return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index 4b3620ab..936fd78f 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -244,7 +244,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t tusb_error_t error; error = TUSB_ERROR_NONE; - //------------- Standard Control such as those in enumeration -------------// + //------------- Standard Control e.g in enumeration -------------// if( TUSB_REQUEST_RECIPIENT_DEVICE == p_request->bmRequestType_bit.recipient && TUSB_REQUEST_TYPE_STANDARD == p_request->bmRequestType_bit.type ) {