Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
rev: v2.2.4
hooks:
- id: codespell
#args: [-w]
args: [-w]
exclude: ^lib/

- repo: local
Expand Down
2 changes: 1 addition & 1 deletion examples/dual/host_hid_to_device_cdc/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
// max device support (excluding hub device)
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) // hub typically has 4 ports

#define CFG_TUH_HID 4
#define CFG_TUH_HID (3*CFG_TUH_DEVICE_MAX)
#define CFG_TUH_HID_EPIN_BUFSIZE 64
#define CFG_TUH_HID_EPOUT_BUFSIZE 64

Expand Down
8 changes: 4 additions & 4 deletions examples/host/cdc_msc_hid/src/cdc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ void tuh_cdc_rx_cb(uint8_t idx)

void tuh_cdc_mount_cb(uint8_t idx)
{
tuh_cdc_itf_info_t itf_info = { 0 };
tuh_itf_info_t itf_info = { 0 };
tuh_cdc_itf_get_info(idx, &itf_info);

printf("CDC Interface is mounted: address = %u, itf_num = %u\r\n", itf_info.daddr, itf_info.bInterfaceNumber);
printf("CDC Interface is mounted: address = %u, itf_num = %u\r\n", itf_info.daddr, itf_info.desc.bInterfaceNumber);

#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
// CFG_TUH_CDC_LINE_CODING_ON_ENUM must be defined for line coding is set by tinyusb in enumeration
Expand All @@ -106,8 +106,8 @@ void tuh_cdc_mount_cb(uint8_t idx)

void tuh_cdc_umount_cb(uint8_t idx)
{
tuh_cdc_itf_info_t itf_info = { 0 };
tuh_itf_info_t itf_info = { 0 };
tuh_cdc_itf_get_info(idx, &itf_info);

printf("CDC Interface is unmounted: address = %u, itf_num = %u\r\n", itf_info.daddr, itf_info.bInterfaceNumber);
printf("CDC Interface is unmounted: address = %u, itf_num = %u\r\n", itf_info.daddr, itf_info.desc.bInterfaceNumber);
}
4 changes: 2 additions & 2 deletions examples/host/cdc_msc_hid/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#if CFG_TUSB_MCU == OPT_MCU_RP2040
// change to 1 if using pico-pio-usb as host controller for raspberry rp2040
#define CFG_TUH_RPI_PIO_USB 0
#define CFG_TUH_RPI_PIO_USB 1
#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB
#endif

Expand Down Expand Up @@ -97,7 +97,7 @@

#define CFG_TUH_HUB 1 // number of supported hubs
#define CFG_TUH_CDC 1
#define CFG_TUH_HID 4 // typical keyboard + mouse device can have 3-4 HID interfaces
#define CFG_TUH_HID (3*CFG_TUH_DEVICE_MAX) // typical keyboard + mouse device can have 3-4 HID interfaces
#define CFG_TUH_MSC 1
#define CFG_TUH_VENDOR 0

Expand Down
2 changes: 1 addition & 1 deletion examples/host/hid_controller/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

#define CFG_TUH_HUB 0
#define CFG_TUH_CDC 0
#define CFG_TUH_HID 4 // typical keyboard + mouse device can have 3-4 HID interfaces
#define CFG_TUH_HID (3*CFG_TUH_DEVICE_MAX) // typical keyboard + mouse device can have 3-4 HID interfaces
#define CFG_TUH_MSC 0
#define CFG_TUH_VENDOR 0

Expand Down
20 changes: 15 additions & 5 deletions src/class/cdc/cdc_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 1 addition & 9 deletions src/class/cdc/cdc_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading