summaryrefslogtreecommitdiff
path: root/src/class/cdc
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2023-03-22 10:37:06 +0700
committerGitHub <[email protected]>2023-03-22 10:37:06 +0700
commit07976ad26d4fbcad0694aa3a08294af7fd5f759f (patch)
tree582a8f1274c33bbdd5b7da28994f897d842495b1 /src/class/cdc
parentec9c666107c0be0f8dc7c2a15e3bdea8c44a50b4 (diff)
parentf27486e19abcc020c93c0c938c71e3692c21b9f5 (diff)
Merge pull request #1968 from hathach/refactor-hid-host
Refactor hid host
Diffstat (limited to 'src/class/cdc')
-rw-r--r--src/class/cdc/cdc_host.c20
-rw-r--r--src/class/cdc/cdc_host.h10
2 files changed, 16 insertions, 14 deletions
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index d34662cb7..fee314823 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -127,15 +127,25 @@ uint8_t tuh_cdc_itf_get_index(uint8_t daddr, uint8_t itf_num)
return TUSB_INDEX_INVALID_8;
}
-bool tuh_cdc_itf_get_info(uint8_t idx, tuh_cdc_itf_info_t* info)
+bool tuh_cdc_itf_get_info(uint8_t idx, tuh_itf_info_t* info)
{
cdch_interface_t* p_cdc = get_itf(idx);
TU_VERIFY(p_cdc && info);
- info->daddr = p_cdc->daddr;
- info->bInterfaceNumber = p_cdc->bInterfaceNumber;
- info->bInterfaceSubClass = p_cdc->bInterfaceSubClass;
- info->bInterfaceProtocol = p_cdc->bInterfaceProtocol;
+ info->daddr = p_cdc->daddr;
+
+ // re-construct descriptor
+ tusb_desc_interface_t* desc = &info->desc;
+ desc->bLength = sizeof(tusb_desc_interface_t);
+ desc->bDescriptorType = TUSB_DESC_INTERFACE;
+
+ desc->bInterfaceNumber = p_cdc->bInterfaceNumber;
+ desc->bAlternateSetting = 0;
+ desc->bNumEndpoints = 2u + (p_cdc->ep_notif ? 1u : 0u);
+ desc->bInterfaceClass = TUSB_CLASS_CDC;
+ desc->bInterfaceSubClass = p_cdc->bInterfaceSubClass;
+ desc->bInterfaceProtocol = p_cdc->bInterfaceProtocol;
+ desc->iInterface = 0; // not used yet
return true;
}
diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h
index 03f32e542..a1e78f158 100644
--- a/src/class/cdc/cdc_host.h
+++ b/src/class/cdc/cdc_host.h
@@ -71,21 +71,13 @@
// Application API
//--------------------------------------------------------------------+
-typedef struct
-{
- uint8_t daddr;
- uint8_t bInterfaceNumber;
- uint8_t bInterfaceSubClass;
- uint8_t bInterfaceProtocol;
-} tuh_cdc_itf_info_t;
-
// Get Interface index from device address + interface number
// return TUSB_INDEX_INVALID_8 (0xFF) if not found
uint8_t tuh_cdc_itf_get_index(uint8_t daddr, uint8_t itf_num);
// Get Interface information
// return true if index is correct and interface is currently mounted
-bool tuh_cdc_itf_get_info(uint8_t idx, tuh_cdc_itf_info_t* info);
+bool tuh_cdc_itf_get_info(uint8_t idx, tuh_itf_info_t* info);
// Check if a interface is mounted
bool tuh_cdc_mounted(uint8_t idx);