mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
Merge branch 'cdc_ch34x_support' of https://github.com/IngHK/tinyusb into cdc_ch34x_support
This commit is contained in:
commit
f7ef3c1b1c
2
.idea/cmake.xml
generated
2
.idea/cmake.xml
generated
@ -80,7 +80,7 @@
|
||||
<configuration PROFILE_NAME="ra6m5 PORT0" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=ra6m5_ek -DLOG=3 -DLOGGER=RTT -DTRACE_ETM=1 -DPORT=0" />
|
||||
<configuration PROFILE_NAME="uno_r4" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=uno_r4 -DLOG=4 -DLOGGER=RTT" />
|
||||
<configuration PROFILE_NAME="portenta_c33" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=portenta_c33 -DLOG=3" />
|
||||
<configuration PROFILE_NAME="lpcxpresso1769" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=lpcxpresso1769 -DLOG=3 -DLOGGER=RTT" />
|
||||
<configuration PROFILE_NAME="lpcxpresso1769" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=lpcxpresso1769 -DLOG=3 -DLOGGER=RTT" />
|
||||
</configurations>
|
||||
</component>
|
||||
</project>
|
@ -2,7 +2,6 @@
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
* Copyright (c) 2023 IngHK Heiko Kuester
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -23,6 +22,9 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*
|
||||
* Contribution
|
||||
* - Heiko Kuester: CH34x support
|
||||
*/
|
||||
|
||||
#include "tusb_option.h"
|
||||
@ -95,9 +97,9 @@ static bool acm_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate, tuh_xfe
|
||||
#if CFG_TUH_CDC_FTDI
|
||||
#include "serial/ftdi_sio.h"
|
||||
|
||||
static uint16_t const ftdi_pids[] = { CFG_TUH_CDC_FTDI_PID_LIST };
|
||||
static uint16_t const ftdi_vid_pid_list[][2] = {CFG_TUH_CDC_FTDI_VID_PID_LIST };
|
||||
enum {
|
||||
FTDI_PID_COUNT = sizeof(ftdi_pids) / sizeof(ftdi_pids[0])
|
||||
FTDI_PID_COUNT = TU_ARRAY_SIZE(ftdi_vid_pid_list)
|
||||
};
|
||||
|
||||
static bool ftdi_open(uint8_t daddr, const tusb_desc_interface_t *itf_desc, uint16_t max_len);
|
||||
@ -112,9 +114,9 @@ static bool ftdi_sio_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate, tu
|
||||
#if CFG_TUH_CDC_CP210X
|
||||
#include "serial/cp210x.h"
|
||||
|
||||
static uint16_t const cp210x_pids[] = { CFG_TUH_CDC_CP210X_PID_LIST };
|
||||
static uint16_t const cp210x_vid_pid_list[][2] = {CFG_TUH_CDC_CP210X_VID_PID_LIST };
|
||||
enum {
|
||||
CP210X_PID_COUNT = sizeof(cp210x_pids) / sizeof(cp210x_pids[0])
|
||||
CP210X_PID_COUNT = TU_ARRAY_SIZE(cp210x_vid_pid_list)
|
||||
};
|
||||
|
||||
static bool cp210x_open(uint8_t daddr, tusb_desc_interface_t const *itf_desc, uint16_t max_len);
|
||||
@ -129,9 +131,9 @@ static bool cp210x_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate, tuh_
|
||||
#if CFG_TUH_CDC_CH34X
|
||||
#include "serial/ch34x.h"
|
||||
|
||||
static uint16_t const ch34x_vids_pids[][2] = { CFG_TUH_CDC_CH34X_VID_PID_LIST };
|
||||
static uint16_t const ch34x_vid_pid_list[][2] = { CFG_TUH_CDC_CH34X_VID_PID_LIST };
|
||||
enum {
|
||||
CH34X_VID_PID_COUNT = sizeof ( ch34x_vids_pids ) / sizeof ( ch34x_vids_pids[0] )
|
||||
CH34X_VID_PID_COUNT = TU_ARRAY_SIZE(ch34x_vid_pid_list)
|
||||
};
|
||||
|
||||
static bool ch34x_open ( uint8_t daddr, tusb_desc_interface_t const *itf_desc, uint16_t max_len );
|
||||
@ -692,28 +694,24 @@ bool cdch_open(uint8_t rhport, uint8_t daddr, tusb_desc_interface_t const *itf_d
|
||||
TU_VERIFY(tuh_vid_pid_get(daddr, &vid, &pid));
|
||||
|
||||
#if CFG_TUH_CDC_FTDI
|
||||
if (TU_FTDI_VID == vid) {
|
||||
for (size_t i = 0; i < FTDI_PID_COUNT; i++) {
|
||||
if (ftdi_pids[i] == pid) {
|
||||
return ftdi_open(daddr, itf_desc, max_len);
|
||||
}
|
||||
for (size_t i = 0; i < FTDI_PID_COUNT; i++) {
|
||||
if (ftdi_vid_pid_list[i][0] == vid && ftdi_vid_pid_list[i][1] == pid) {
|
||||
return ftdi_open(daddr, itf_desc, max_len);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_CDC_CP210X
|
||||
if (TU_CP210X_VID == vid) {
|
||||
for (size_t i = 0; i < CP210X_PID_COUNT; i++) {
|
||||
if (cp210x_pids[i] == pid) {
|
||||
return cp210x_open(daddr, itf_desc, max_len);
|
||||
}
|
||||
for (size_t i = 0; i < CP210X_PID_COUNT; i++) {
|
||||
if (cp210x_vid_pid_list[i][0] == vid && cp210x_vid_pid_list[i][1] == pid) {
|
||||
return cp210x_open(daddr, itf_desc, max_len);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_CDC_CH34X
|
||||
for (size_t i = 0; i < CH34X_VID_PID_COUNT; i++) {
|
||||
if ( ch34x_vids_pids[i][0] == vid && ch34x_vids_pids[i][1] == pid ) {
|
||||
if ( ch34x_vid_pid_list[i][0] == vid && ch34x_vid_pid_list[i][1] == pid ) {
|
||||
return ch34x_open(daddr, itf_desc, max_len);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2023 IngHK Heiko Kuester (tinyusb.org)
|
||||
* Copyright (c) 2023 Heiko Kuester (tinyusb.org)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -37,6 +37,7 @@
|
||||
#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
|
||||
#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
|
||||
#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
|
||||
#define TU_DIV_CEIL(n, d) (((n) + (d) - 1) / (d))
|
||||
|
||||
#define TU_U16(_high, _low) ((uint16_t) (((_high) << 8) | (_low)))
|
||||
#define TU_U16_HIGH(_u16) ((uint8_t) (((_u16) >> 8) & 0x00ff))
|
||||
|
@ -453,10 +453,12 @@
|
||||
#define CFG_TUH_CDC_FTDI 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_CDC_FTDI_PID_LIST
|
||||
// List of product IDs that can use the FTDI CDC driver
|
||||
#define CFG_TUH_CDC_FTDI_PID_LIST \
|
||||
0x6001, 0x6006, 0x6010, 0x6011, 0x6014, 0x6015, 0x8372, 0xFBFA, 0xCD18
|
||||
#ifndef CFG_TUH_CDC_FTDI_VID_PID_LIST
|
||||
// List of product IDs that can use the FTDI CDC driver. 0x0403 is FTDI's VID
|
||||
#define CFG_TUH_CDC_FTDI_VID_PID_LIST \
|
||||
{0x0403, 0x6001}, {0x0403, 0x6006}, {0x0403, 0x6010}, {0x0403, 0x6011}, \
|
||||
{0x0403, 0x6014}, {0x0403, 0x6015}, {0x0403, 0x8372}, {0x0403, 0xFBFA}, \
|
||||
{0x0403, 0xCD18}
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_CDC_CP210X
|
||||
@ -464,10 +466,10 @@
|
||||
#define CFG_TUH_CDC_CP210X 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_CDC_CP210X_PID_LIST
|
||||
// List of product IDs that can use the CP210X CDC driver
|
||||
#define CFG_TUH_CDC_CP210X_PID_LIST \
|
||||
0xEA60, 0xEA70
|
||||
#ifndef CFG_TUH_CDC_CP210X_VID_PID_LIST
|
||||
// List of product IDs that can use the CP210X CDC driver. 0x10C4 is Silicon Labs' VID
|
||||
#define CFG_TUH_CDC_CP210X_VID_PID_LIST \
|
||||
{0x10C4, 0xEA60}, {0x10C4, 0xEA70}
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_CDC_CH34X
|
||||
@ -483,8 +485,8 @@
|
||||
{ 0x1a86, 0x5523 }, /* ch341 chip */ \
|
||||
{ 0x1a86, 0xe523 }, /* ch330 chip */ \
|
||||
{ 0x4348, 0x5523 }, /* ch340 custom chip */ \
|
||||
{ 0x2184, 0x0057 }, /* overtaken from Linux driver /drivers/usb/serial/ch341.c */ \
|
||||
{ 0x9986, 0x7523 } /* overtaken from Linux driver /drivers/usb/serial/ch341.c */
|
||||
{ 0x2184, 0x0057 }, /* overtaken from Linux Kernel driver /drivers/usb/serial/ch341.c */ \
|
||||
{ 0x9986, 0x7523 } /* overtaken from Linux Kernel driver /drivers/usb/serial/ch341.c */
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_HID
|
||||
|
Loading…
x
Reference in New Issue
Block a user