Skip to content

Commit 95d6d32

Browse files
authored
Enhance TinyUSB configuration for host support
Added host configuration options for TinyUSB.
1 parent 4aba966 commit 95d6d32

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

components/arduino_tinyusb/include/tusb_config.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ extern "C" {
7676
# define CONFIG_TINYUSB_NCM_ENABLED 0
7777
#endif
7878

79+
#if CONFIG_TINYUSB_ENABLED
80+
# define CFG_TUD_ENABLED 1
81+
#endif
82+
7983
/* */
8084
/* COMMON CONFIGURATION */
8185
/* */
@@ -84,6 +88,7 @@ extern "C" {
8488
#endif
8589
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
8690
#define CFG_TUSB_OS OPT_OS_FREERTOS
91+
#define BOARD_TUD_RHPORT 0
8792

8893
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
8994
* Tinyusb use follows macros to declare transferring memory so that they can be put
@@ -97,17 +102,23 @@ extern "C" {
97102
#endif
98103

99104
#ifndef CFG_TUSB_MEM_ALIGN
105+
#if CONFIG_IDF_TARGET_ESP32P4
106+
# define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(64)
107+
#else
100108
# define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
101109
#endif
110+
#endif
102111

103112
#if CONFIG_IDF_TARGET_ESP32P4
104113
#define CFG_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
105114
#else
106115
#define CFG_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
107116
#endif
108117

118+
#define BOARD_TUD_MAX_SPEED CFG_TUD_MAX_SPEED
119+
109120
/* */
110-
/* DRIVER CONFIGURATION */
121+
/* DEVICE CONFIGURATION */
111122
/* */
112123

113124
#define CFG_TUD_MAINTASK_SIZE 4096
@@ -155,6 +166,35 @@ extern "C" {
155166
#define CFG_TUD_VENDOR_RX_BUFSIZE CONFIG_TINYUSB_VENDOR_RX_BUFSIZE
156167
#define CFG_TUD_VENDOR_TX_BUFSIZE CONFIG_TINYUSB_VENDOR_TX_BUFSIZE
157168

169+
/* */
170+
/* HOST CONFIGURATION */
171+
/* */
172+
173+
#define CFG_TUH_ENABLED CFG_TUD_ENABLED
174+
#define CFG_TUSB_RHPORT1_MODE OPT_MODE_HOST
175+
#define BOARD_TUH_RHPORT 1
176+
#define BOARD_TUH_MAX_SPEED CFG_TUD_MAX_SPEED
177+
#define CFG_TUH_ENUMERATION_BUFSIZE 256
178+
179+
#define CFG_TUH_HUB 2 // number of supported hubs
180+
#define CFG_TUH_CDC 1 // CDC ACM
181+
#define CFG_TUH_CDC_FTDI 1 // FTDI Serial. FTDI is not part of CDC class, only to re-use CDC driver API
182+
#define CFG_TUH_CDC_CP210X 1 // CP210x Serial. CP210X is not part of CDC class, only to re-use CDC driver API
183+
#define CFG_TUH_CDC_CH34X 1 // CH340 or CH341 Serial. CH34X is not part of CDC class, only to re-use CDC driver API
184+
#define CFG_TUH_HID 1 // typical keyboard + mouse device can have 3-4 HID interfaces
185+
#define CFG_TUH_MSC 1
186+
//#define CFG_TUH_VENDOR 3
187+
188+
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
189+
190+
//------------- HID -------------//
191+
#define CFG_TUH_HID_EPIN_BUFSIZE 64
192+
#define CFG_TUH_HID_EPOUT_BUFSIZE 64
193+
194+
//------------- CDC -------------//
195+
#define CFG_TUH_CDC_LINE_CONTROL_ON_ENUM 0x03
196+
#define CFG_TUH_CDC_LINE_CODING_ON_ENUM { 115200, CDC_LINE_CODING_STOP_BITS_1, CDC_LINE_CODING_PARITY_NONE, 8 }
197+
158198
#ifdef __cplusplus
159199
}
160200
#endif

0 commit comments

Comments
 (0)