Skip to content

Commit 938cae8

Browse files
authored
Merge pull request #2417 from hathach/serialhost-change-ftdi-cp210x-pid-list
change serila host FTDI/CP210X pid list to vid/pid list
2 parents 4b3b401 + aa58cdc commit 938cae8

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

.idea/cmake.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/class/cdc/cdc_host.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ static bool acm_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate, tuh_xfe
9191
#if CFG_TUH_CDC_FTDI
9292
#include "serial/ftdi_sio.h"
9393

94-
static uint16_t const ftdi_pids[] = { CFG_TUH_CDC_FTDI_PID_LIST };
94+
static uint16_t const ftdi_vid_pid_list[][2] = {CFG_TUH_CDC_FTDI_VID_PID_LIST };
9595
enum {
96-
FTDI_PID_COUNT = sizeof(ftdi_pids) / sizeof(ftdi_pids[0])
96+
FTDI_PID_COUNT = sizeof(ftdi_vid_pid_list) / sizeof(ftdi_vid_pid_list[0])
9797
};
9898

9999
// Store last request baudrate since divisor to baudrate is not easy
@@ -110,9 +110,9 @@ static bool ftdi_sio_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate, tu
110110
#if CFG_TUH_CDC_CP210X
111111
#include "serial/cp210x.h"
112112

113-
static uint16_t const cp210x_pids[] = { CFG_TUH_CDC_CP210X_PID_LIST };
113+
static uint16_t const cp210x_vid_pid_list[][2] = {CFG_TUH_CDC_CP210X_VID_PID_LIST };
114114
enum {
115-
CP210X_PID_COUNT = sizeof(cp210x_pids) / sizeof(cp210x_pids[0])
115+
CP210X_PID_COUNT = sizeof(cp210x_vid_pid_list) / sizeof(cp210x_vid_pid_list[0])
116116
};
117117

118118
static bool cp210x_open(uint8_t daddr, tusb_desc_interface_t const *itf_desc, uint16_t max_len);
@@ -647,21 +647,17 @@ bool cdch_open(uint8_t rhport, uint8_t daddr, tusb_desc_interface_t const *itf_d
647647
TU_VERIFY(tuh_vid_pid_get(daddr, &vid, &pid));
648648

649649
#if CFG_TUH_CDC_FTDI
650-
if (TU_FTDI_VID == vid) {
651-
for (size_t i = 0; i < FTDI_PID_COUNT; i++) {
652-
if (ftdi_pids[i] == pid) {
653-
return ftdi_open(daddr, itf_desc, max_len);
654-
}
650+
for (size_t i = 0; i < FTDI_PID_COUNT; i++) {
651+
if (ftdi_vid_pid_list[i][0] == vid && ftdi_vid_pid_list[i][1] == pid) {
652+
return ftdi_open(daddr, itf_desc, max_len);
655653
}
656654
}
657655
#endif
658656

659657
#if CFG_TUH_CDC_CP210X
660-
if (TU_CP210X_VID == vid) {
661-
for (size_t i = 0; i < CP210X_PID_COUNT; i++) {
662-
if (cp210x_pids[i] == pid) {
663-
return cp210x_open(daddr, itf_desc, max_len);
664-
}
658+
for (size_t i = 0; i < CP210X_PID_COUNT; i++) {
659+
if (cp210x_vid_pid_list[i][0] == vid && cp210x_vid_pid_list[i][1] == pid) {
660+
return cp210x_open(daddr, itf_desc, max_len);
665661
}
666662
}
667663
#endif

src/tusb_option.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,21 +453,23 @@
453453
#define CFG_TUH_CDC_FTDI 0
454454
#endif
455455

456-
#ifndef CFG_TUH_CDC_FTDI_PID_LIST
457-
// List of product IDs that can use the FTDI CDC driver
458-
#define CFG_TUH_CDC_FTDI_PID_LIST \
459-
0x6001, 0x6006, 0x6010, 0x6011, 0x6014, 0x6015, 0x8372, 0xFBFA, 0xCD18
456+
#ifndef CFG_TUH_CDC_FTDI_VID_PID_LIST
457+
// List of product IDs that can use the FTDI CDC driver. 0x0403 is FTDI's VID
458+
#define CFG_TUH_CDC_FTDI_VID_PID_LIST \
459+
{0x0403, 0x6001}, {0x0403, 0x6006}, {0x0403, 0x6010}, {0x0403, 0x6011}, \
460+
{0x0403, 0x6014}, {0x0403, 0x6015}, {0x0403, 0x8372}, {0x0403, 0xFBFA}, \
461+
{0x0403, 0xCD18}
460462
#endif
461463

462464
#ifndef CFG_TUH_CDC_CP210X
463465
// CP210X is not part of CDC class, only to re-use CDC driver API
464466
#define CFG_TUH_CDC_CP210X 0
465467
#endif
466468

467-
#ifndef CFG_TUH_CDC_CP210X_PID_LIST
468-
// List of product IDs that can use the CP210X CDC driver
469-
#define CFG_TUH_CDC_CP210X_PID_LIST \
470-
0xEA60, 0xEA70
469+
#ifndef CFG_TUH_CDC_CP210X_VID_PID_LIST
470+
// List of product IDs that can use the CP210X CDC driver. 0x10C4 is Silicon Labs' VID
471+
#define CFG_TUH_CDC_CP210X_VID_PID_LIST \
472+
{0x10C4, 0xEA60}, {0x10C4, 0xEA70}
471473
#endif
472474

473475
#ifndef CFG_TUH_HID

0 commit comments

Comments
 (0)