Skip to content

Commit 62dbf5e

Browse files
committed
refactor(serial): add host serial framework
Signed-off-by: sakumisu <1203593632@qq.com>
1 parent bf1d9db commit 62dbf5e

40 files changed

Lines changed: 4147 additions & 2387 deletions

‎CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if(BL_SDK_BASE)
2626
set(CONFIG_CHERRYUSB_HOST_CP210X 1)
2727
set(CONFIG_CHERRYUSB_HOST_FTDI 1)
2828
set(CONFIG_CHERRYUSB_HOST_PL2303 1)
29+
set(CONFIG_CHERRYUSB_HOST_GSM 1)
2930

3031
set(CONFIG_CHERRYUSB_DEVICE_BL 1)
3132
set(CONFIG_CHERRYUSB_HOST_EHCI_BL 1)
@@ -139,6 +140,9 @@ elseif(ESP_PLATFORM)
139140
if(CONFIG_CHERRYUSB_HOST_PL2303)
140141
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u pl2303_class_info")
141142
endif()
143+
if(CONFIG_CHERRYUSB_HOST_GSM)
144+
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u gsm_class_info")
145+
endif()
142146
endif()
143147

144148
if(CONFIG_CHERRYUSB)
@@ -194,6 +198,7 @@ elseif(HPM_SDK_BASE)
194198
set(CONFIG_CHERRYUSB_HOST_CP210X 1)
195199
set(CONFIG_CHERRYUSB_HOST_FTDI 1)
196200
set(CONFIG_CHERRYUSB_HOST_PL2303 1)
201+
set(CONFIG_CHERRYUSB_HOST_GSM 1)
197202

198203
set(CONFIG_CHERRYUSB_DEVICE_HPM 1)
199204
set(CONFIG_CHERRYUSB_HOST_EHCI_HPM 1)

‎Kconfig‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,11 @@ if CHERRYUSB
418418
default 500
419419

420420
menu "Select USB host template, please select class driver first"
421-
config TEST_USBH_CDC_ACM
421+
config TEST_USBH_SERIAL
422422
int
423-
prompt "demo for test cdc acm"
423+
prompt "demo for test serial"
424424
default 0
425-
depends on CHERRYUSB_HOST_CDC_ACM
425+
depends on CHERRYUSB_HOST_CDC_ACM || CHERRYUSB_HOST_FTDI || CHERRYUSB_HOST_CH34X || CHERRYUSB_HOST_CP210X || CHERRYUSB_HOST_PL2303
426426
config TEST_USBH_HID
427427
int
428428
prompt "demo for test hid"

‎Kconfig.rtt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,11 @@ if RT_USING_CHERRYUSB
445445
default "/"
446446

447447
menu "Select USB host template, please select class driver first"
448-
config CONFIG_TEST_USBH_CDC_ACM
448+
config CONFIG_TEST_USBH_SERIAL
449449
int
450-
prompt "demo for test cdc acm, cannot enable this demo, we have used serial framework instead"
450+
prompt "demo for test serial, cannot enable this demo, we have used serial framework instead"
451451
default 0
452-
depends on RT_CHERRYUSB_HOST_CDC_ACM
452+
depends on RT_CHERRYUSB_HOST_CDC_ACM || RT_CHERRYUSB_HOST_FTDI || RT_CHERRYUSB_HOST_CH34X || RT_CHERRYUSB_HOST_CP210X || RT_CHERRYUSB_HOST_PL2303
453453
config CONFIG_TEST_USBH_HID
454454
int
455455
prompt "demo for test hid"

‎Kconfig.rttpkg‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@ if PKG_USING_CHERRYUSB
444444
default "/"
445445

446446
menu "Select USB host template, please select class driver first"
447-
config CONFIG_TEST_USBH_CDC_ACM
447+
config CONFIG_TEST_USBH_SERIAL
448448
int
449-
prompt "demo for test cdc acm, cannot enable this demo, we have used serial framework instead"
449+
prompt "demo for test usb serial, cannot enable this demo, we have used serial framework instead"
450450
default 0
451-
depends on PKG_CHERRYUSB_HOST_CDC_ACM
451+
depends on PKG_CHERRYUSB_HOST_CDC_ACM || PKG_CHERRYUSB_HOST_FTDI || PKG_CHERRYUSB_HOST_CH34X || PKG_CHERRYUSB_HOST_CP210X || PKG_CHERRYUSB_HOST_PL2303
452452
config CONFIG_TEST_USBH_HID
453453
int
454454
prompt "demo for test hid"

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ CherryUSB Host Stack has the following functions:
112112
- Support USB Audio CLASS (UAC1.0)
113113
- Support Remote NDIS (RNDIS)
114114
- Support USB Bluetooth class (support nimble and zephyr bluetooth stack, support **CLASS:0xE0** or vendor class like cdc acm)
115-
- Support Vendor class (serial, net, wifi)
115+
- Support Vendor Serial Class(CH34X、CP210X、PL2303、FTDI、GSM)
116+
- Support Vendor network Class(RTL8152、AX88772)
116117
- Support USB modeswitch
117118
- Support Android Open Accessory
118119
- Support multi host with the same USB IP
@@ -150,7 +151,7 @@ Among them, `sizeof(struct usbh_hub)` and `sizeof(struct usbh_hubport)` are affe
150151
x is affected by the following macros:
151152

152153
```
153-
#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
154+
#define CONFIG_USBHOST_MAX_SERIAL_CLASS 4
154155
#define CONFIG_USBHOST_MAX_HID_CLASS 4
155156
#define CONFIG_USBHOST_MAX_MSC_CLASS 2
156157
#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1

‎README_zh.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ CherryUSB Host 协议栈当前实现以下功能:
112112
- Support USB Audio CLASS (UAC1.0)
113113
- 支持 Remote NDIS (RNDIS)
114114
- 支持 USB Bluetooth (支持 nimble and zephyr bluetooth 协议栈,支持 **CLASS: 0xE0** 或者厂家自定义类,类似于 cdc acm 功能)
115-
- 支持 Vendor 类 class (serial, net, wifi)
115+
- 支持 Vendor Serial 类(CH34X、CP210X、PL2303、FTDI、GSM)
116+
- 支持 Vendor network 类(RTL8152、AX88772)
116117
- 支持 USB modeswitch
117118
- 支持 Android Open Accessory
118119
- 支持相同 USB IP 的多主机
@@ -150,7 +151,7 @@ CherryUSB Host 协议栈资源占用说明(GCC 10.2 with -O2,关闭 log)
150151
x 受以下宏影响:
151152

152153
```
153-
#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
154+
#define CONFIG_USBHOST_MAX_SERIAL_CLASS 4
154155
#define CONFIG_USBHOST_MAX_HID_CLASS 4
155156
#define CONFIG_USBHOST_MAX_MSC_CLASS 2
156157
#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1

‎SConscript‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ path += [cwd + '/class/wireless']
1414
path += [cwd + '/class/midi']
1515
path += [cwd + '/class/adb']
1616
path += [cwd + '/class/dfu']
17-
path += [cwd + '/class/midi']
17+
path += [cwd + '/class/serial']
1818
path += [cwd + '/class/vendor/net']
1919
path += [cwd + '/class/vendor/serial']
2020
path += [cwd + '/class/vendor/wifi']
@@ -307,6 +307,7 @@ if GetDepend(['PKG_CHERRYUSB_HOST']):
307307
or GetDepend(['PKG_CHERRYUSB_HOST_CH34X']) \
308308
or GetDepend(['PKG_CHERRYUSB_HOST_CP210X']) \
309309
or GetDepend(['PKG_CHERRYUSB_HOST_PL2303']):
310+
src += Glob('class/serial/usbh_serial.c')
310311
src += Glob('platform/rtthread/usbh_serial.c')
311312

312313
if GetDepend('RT_USING_DFS') and GetDepend(['PKG_CHERRYUSB_HOST_MSC']):

‎cherryusb.cmake‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ list(
4747
${CMAKE_CURRENT_LIST_DIR}/class/midi
4848
${CMAKE_CURRENT_LIST_DIR}/class/adb
4949
${CMAKE_CURRENT_LIST_DIR}/class/dfu
50+
${CMAKE_CURRENT_LIST_DIR}/class/serial
5051
${CMAKE_CURRENT_LIST_DIR}/class/vendor/net
51-
${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial
5252
${CMAKE_CURRENT_LIST_DIR}/class/vendor/wifi
5353
${CMAKE_CURRENT_LIST_DIR}/class/aoa
5454
)
@@ -156,7 +156,7 @@ if(CONFIG_CHERRYUSB_HOST)
156156
)
157157

158158
if(CONFIG_CHERRYUSB_HOST_CDC_ACM)
159-
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_acm.c)
159+
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/serial/usbh_cdc_acm.c)
160160
endif()
161161
if(CONFIG_CHERRYUSB_HOST_CDC_ECM)
162162
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_ecm.c)
@@ -235,21 +235,34 @@ if(CONFIG_CHERRYUSB_HOST)
235235
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/net/usbh_rtl8152.c)
236236
endif()
237237
if(CONFIG_CHERRYUSB_HOST_CH34X)
238-
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_ch34x.c)
238+
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/serial/usbh_ch34x.c)
239239
endif()
240240
if(CONFIG_CHERRYUSB_HOST_CP210X)
241-
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_cp210x.c)
241+
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/serial/usbh_cp210x.c)
242242
endif()
243243
if(CONFIG_CHERRYUSB_HOST_FTDI)
244-
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_ftdi.c)
244+
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/serial/usbh_ftdi.c)
245245
endif()
246246
if(CONFIG_CHERRYUSB_HOST_PL2303)
247-
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_pl2303.c)
247+
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/serial/usbh_pl2303.c)
248+
endif()
249+
if(CONFIG_CHERRYUSB_HOST_GSM)
250+
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/serial/usbh_gsm.c)
248251
endif()
249252
if(CONFIG_CHERRYUSB_HOST_AOA)
250253
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/aoa/usbh_aoa.c)
251254
endif()
252255

256+
if(CONFIG_CHERRYUSB_HOST_CDC_ACM
257+
OR CONFIG_CHERRYUSB_HOST_CH34X
258+
OR CONFIG_CHERRYUSB_HOST_CP210X
259+
OR CONFIG_CHERRYUSB_HOST_FTDI
260+
OR CONFIG_CHERRYUSB_HOST_PL2303
261+
OR CONFIG_CHERRYUSB_HOST_GSM
262+
)
263+
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/serial/usbh_serial.c)
264+
endif()
265+
253266
if(CONFIG_CHERRYUSB_HOST_CDC_ECM
254267
OR CONFIG_CHERRYUSB_HOST_CDC_RNDIS
255268
OR CONFIG_CHERRYUSB_HOST_CDC_NCM

‎cherryusb_config_template.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
#define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 2
158158
#define CONFIG_USBHOST_MAX_ENDPOINTS 4
159159

160-
#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
160+
#define CONFIG_USBHOST_MAX_SERIAL_CLASS 4
161161
#define CONFIG_USBHOST_MAX_HID_CLASS 4
162162
#define CONFIG_USBHOST_MAX_MSC_CLASS 2
163163
#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1

0 commit comments

Comments
 (0)