Update cherryusb to v1.3.1 (#9122)
* fix(hpmicro): remove duplicate usb variable * update(cherryusb): update to v1.3.1
This commit is contained in:
parent
c018a3e3fd
commit
cc853de5f3
|
@ -111,12 +111,6 @@ SECTIONS
|
|||
KEEP (*(.fini))
|
||||
. = ALIGN(8);
|
||||
|
||||
/* section information for usbh class */
|
||||
. = ALIGN(8);
|
||||
__usbh_class_info_start__ = .;
|
||||
KEEP(*(.usbh_class_info))
|
||||
__usbh_class_info_end__ = .;
|
||||
|
||||
/*********************************************
|
||||
*
|
||||
* RT-Thread related sections - Start
|
||||
|
|
|
@ -36,12 +36,16 @@ if RT_USING_CHERRYUSB
|
|||
bool "dwc2_at"
|
||||
config RT_CHERRYUSB_DEVICE_DWC2_GD
|
||||
bool "dwc2_gd"
|
||||
config RT_CHERRYUSB_DEVICE_DWC2_HC
|
||||
bool "dwc2_hc"
|
||||
config RT_CHERRYUSB_DEVICE_DWC2_CUSTOM
|
||||
bool "dwc2_custom"
|
||||
config RT_CHERRYUSB_DEVICE_MUSB_STANDARD
|
||||
bool "musb_standard"
|
||||
config RT_CHERRYUSB_DEVICE_MUSB_ES
|
||||
bool "musb_es"
|
||||
config RT_CHERRYUSB_DEVICE_MUSB_SUNXI
|
||||
bool "musb_sunxi"
|
||||
config RT_CHERRYUSB_DEVICE_MUSB_BK
|
||||
bool "musb_bk"
|
||||
config RT_CHERRYUSB_DEVICE_MUSB_CUSTOM
|
||||
bool "musb_custom"
|
||||
config RT_CHERRYUSB_DEVICE_BL
|
||||
|
@ -170,10 +174,12 @@ if RT_USING_CHERRYUSB
|
|||
bool "dwc2_esp"
|
||||
config RT_CHERRYUSB_HOST_DWC2_CUSTOM
|
||||
bool "dwc2_custom"
|
||||
config RT_CHERRYUSB_HOST_MUSB_STANDARD
|
||||
bool "musb_standard"
|
||||
config RT_CHERRYUSB_HOST_MUSB_ES
|
||||
bool "musb_es"
|
||||
config RT_CHERRYUSB_HOST_MUSB_SUNXI
|
||||
bool "musb_sunxi"
|
||||
config RT_CHERRYUSB_HOST_MUSB_BK
|
||||
bool "musb_bk"
|
||||
config RT_CHERRYUSB_HOST_MUSB_CUSTOM
|
||||
bool "musb_custom"
|
||||
config RT_CHERRYUSB_HOST_PUSB2
|
||||
|
@ -242,7 +248,7 @@ if RT_USING_CHERRYUSB
|
|||
prompt "Enable usb asix driver"
|
||||
select RT_USING_LWIP
|
||||
select RT_USING_LWIP212
|
||||
select CONFIG_USBHOST_PLATFORM_CDC_ASIX
|
||||
select CONFIG_USBHOST_PLATFORM_ASIX
|
||||
default n
|
||||
|
||||
config RT_CHERRYUSB_HOST_RTL8152
|
||||
|
@ -250,7 +256,7 @@ if RT_USING_CHERRYUSB
|
|||
prompt "Enable usb rtl8152 driver"
|
||||
select RT_USING_LWIP
|
||||
select RT_USING_LWIP212
|
||||
select CONFIG_USBHOST_PLATFORM_CDC_RTL8152
|
||||
select CONFIG_USBHOST_PLATFORM_RTL8152
|
||||
default n
|
||||
|
||||
config RT_CHERRYUSB_HOST_FTDI
|
||||
|
@ -285,7 +291,7 @@ if RT_USING_CHERRYUSB
|
|||
config CONFIG_USBHOST_PLATFORM_ASIX
|
||||
bool
|
||||
|
||||
config CONFIG_USBHOST_PLATFORM_RTL152
|
||||
config CONFIG_USBHOST_PLATFORM_RTL8152
|
||||
bool
|
||||
|
||||
config CHERRYUSB_HOST_TEMPLATE
|
||||
|
|
|
@ -36,12 +36,16 @@ if CHERRYUSB
|
|||
bool "dwc2_at"
|
||||
config CHERRYUSB_DEVICE_DWC2_GD
|
||||
bool "dwc2_gd"
|
||||
config CHERRYUSB_DEVICE_DWC2_HC
|
||||
bool "dwc2_hc"
|
||||
config CHERRYUSB_DEVICE_DWC2_CUSTOM
|
||||
bool "dwc2_custom"
|
||||
config CHERRYUSB_DEVICE_MUSB_STANDARD
|
||||
bool "musb_standard"
|
||||
config CHERRYUSB_DEVICE_MUSB_ES
|
||||
bool "musb_es"
|
||||
config CHERRYUSB_DEVICE_MUSB_SUNXI
|
||||
bool "musb_sunxi"
|
||||
config CHERRYUSB_DEVICE_MUSB_BK
|
||||
bool "musb_bk"
|
||||
config CHERRYUSB_DEVICE_MUSB_CUSTOM
|
||||
bool "musb_custom"
|
||||
config CHERRYUSB_DEVICE_BL
|
||||
|
@ -168,12 +172,16 @@ if CHERRYUSB
|
|||
bool "dwc2_st"
|
||||
config CHERRYUSB_HOST_DWC2_ESP
|
||||
bool "dwc2_esp"
|
||||
config CHERRYUSB_HOST_DWC2_HC
|
||||
bool "dwc2_hc"
|
||||
config CHERRYUSB_HOST_DWC2_CUSTOM
|
||||
bool "dwc2_custom"
|
||||
config CHERRYUSB_HOST_MUSB_STANDARD
|
||||
bool "musb_standard"
|
||||
config CHERRYUSB_HOST_MUSB_ES
|
||||
bool "musb_es"
|
||||
config CHERRYUSB_HOST_MUSB_SUNXI
|
||||
bool "musb_sunxi"
|
||||
config CHERRYUSB_HOST_MUSB_BK
|
||||
bool "musb_bk"
|
||||
config CHERRYUSB_HOST_MUSB_CUSTOM
|
||||
bool "musb_custom"
|
||||
config CHERRYUSB_HOST_PUSB2
|
||||
|
@ -274,7 +282,7 @@ if CHERRYUSB
|
|||
config USBHOST_PLATFORM_ASIX
|
||||
bool
|
||||
|
||||
config USBHOST_PLATFORM_RTL152
|
||||
config USBHOST_PLATFORM_RTL8152
|
||||
bool
|
||||
|
||||
config CHERRYUSB_HOST_TEMPLATE
|
||||
|
@ -295,7 +303,7 @@ if CHERRYUSB
|
|||
depends on CHERRYUSB_HOST_HID
|
||||
config TEST_USBH_MSC
|
||||
int
|
||||
prompt "demo for test msc, do not enable because it has used dfs instead"
|
||||
prompt "demo for test msc"
|
||||
default 0
|
||||
depends on CHERRYUSB_HOST_MSC
|
||||
endif
|
||||
|
|
|
@ -94,8 +94,8 @@ CherryUSB Host Stack has the following functions:
|
|||
- Support Communication Device Class (CDC_ACM, CDC_ECM)
|
||||
- Support Human Interface Device (HID)
|
||||
- Support Mass Storage Class (MSC)
|
||||
- Support USB Video CLASS (commercial charge)
|
||||
- Support USB Audio CLASS (commercial charge)
|
||||
- Support USB Video CLASS (UVC1.0、UVC1.5)
|
||||
- Support USB Audio CLASS (UAC1.0)
|
||||
- Support Remote NDIS (RNDIS)
|
||||
- Support USB Bluetooth class (support nimble and zephyr bluetooth stack, support **CLASS:0xE0** or vendor class like cdc acm)
|
||||
- Support Vendor class
|
||||
|
@ -115,7 +115,7 @@ CherryUSB Host Stack resource usage (GCC 10.2 with -O2):
|
|||
|usbh_hid.c | ~1000 | 128 | 4 + sizeof(struct usbh_hid) * x | 0 |
|
||||
|usbh_video.c | ~3700 | 128 | 4 + sizeof(struct usbh_video) * x | 0 |
|
||||
|usbh_audio.c | ~3100 | 128 | 4 + sizeof(struct usbh_audio) * x | 0 |
|
||||
|usbh_rndis.c | ~3900 | 4096 + 2 * 2048 | sizeof(struct usbh_rndis) * 1 | 0 |
|
||||
|usbh_rndis.c | ~3900 | 4096 + 2 * 2048(default)| sizeof(struct usbh_rndis) * 1 | 0 |
|
||||
|usbh_cdc_ecm.c | ~2500 | 2 * 1514 | sizeof(struct usbh_cdc_ecm) * 1 | 0 |
|
||||
|usbh_bluetooth.c | ~2300 | 2 * 2048(default) | sizeof(struct usbh_bluetooth) * 1 | 0 |
|
||||
|
||||
|
@ -178,13 +178,18 @@ USB basic concepts and how the CherryUSB Device stack is implemented, see [Cherr
|
|||
|HPMicro | HPM6750 | hpm/ehci |[hpm_sdk](https://github.com/CherryUSB/hpm_sdk)|<= latest | Long-term |
|
||||
|Essemi | ES32F36xx | musb |[es32f369_repo](https://github.com/CherryUSB/cherryusb_es32)|<= latest | Long-term |
|
||||
|Phytium | e2000 | pusb2/xhci |[phytium_repo](https://gitee.com/phytium_embedded/phytium-free-rtos-sdk)|v0.10.2 | Long-term |
|
||||
|artinchip | d12x/d13x/d21x | aic/ehci/ohci |[luban-lite](https://gitee.com/artinchip/luban-lite)|<= latest | Long-term |
|
||||
|Artinchip | d12x/d13x/d21x | aic/ehci/ohci |[luban-lite](https://gitee.com/artinchip/luban-lite)|<= latest | Long-term |
|
||||
|Espressif | esp32s2/esp32s3 | dwc2 |[esp32_repo](https://github.com/CherryUSB/cherryusb_esp32)|<= latest | the same with ST |
|
||||
|AllwinnerTech | F1C100S/F1C200S | musb |[cherryusb_rtt_f1c100s](https://github.com/CherryUSB/cherryusb_rtt_f1c100s)|<= latest | the same with Essemi |
|
||||
|Bekencorp | bk7256/bk7258 | musb |[bk_idk](https://github.com/CherryUSB/bk_idk)| v0.7.0 | the same with Essemi |
|
||||
|Sophgo | cv18xx | dwc2 |[cvi_alios_open](https://github.com/CherryUSB/cvi_alios_open)| v0.7.0 | the same with ST |
|
||||
|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2 | TBD |
|
||||
|Nordicsemi | Nrf52840 | nrf5x |[nrf5x_repo](https://github.com/CherryUSB/cherryusb_nrf5x)|<= v0.10.2 | No more updated |
|
||||
|Raspberry pi | rp2040 | rp2040 |[pico-examples](https://github.com/CherryUSB/pico-examples)|<= v0.10.2 | No more updated |
|
||||
|
||||
## Commercial Support
|
||||
|
||||
Refer to https://cherryusb.readthedocs.io/zh-cn/latest/support/index.html.
|
||||
|
||||
## Contact
|
||||
|
||||
CherryUSB discord: https://discord.com/invite/wFfvrSAey8.
|
||||
|
@ -193,4 +198,4 @@ CherryUSB discord: https://discord.com/invite/wFfvrSAey8.
|
|||
|
||||
Thanks to the following companies for their support (in no particular order).
|
||||
|
||||
<img src="docs/assets/bouffalolab.jpg" width="100" height="100"/> <img src="docs/assets/hpmicro.jpg" width="100" height="100" /> <img src="docs/assets/eastsoft.jpg" width="100" height="100" /> <img src="docs/assets/rtthread.jpg" width="100" height="100" /> <img src="docs/assets/sophgo.jpg" width="100" height="100" /> <img src="docs/assets/phytium.jpg" width="100" height="100" /> <img src="docs/assets/thead.jpg" width="100" height="100" /> <img src="docs/assets/nuvoton.jpg" width="100" height="100" /> <img src="docs/assets/artinchip.jpg" width="100" height="100" />
|
||||
<img src="docs/assets/bouffalolab.jpg" width="100" height="100"/> <img src="docs/assets/hpmicro.jpg" width="100" height="100" /> <img src="docs/assets/eastsoft.jpg" width="100" height="100" /> <img src="docs/assets/rtthread.jpg" width="100" height="100" /> <img src="docs/assets/sophgo.jpg" width="100" height="100" /> <img src="docs/assets/phytium.jpg" width="100" height="100" /> <img src="docs/assets/thead.jpg" width="100" height="100" /> <img src="docs/assets/nuvoton.jpg" width="100" height="100" /> <img src="docs/assets/artinchip.jpg" width="100" height="100" /> <img src="docs/assets/bekencorp.jpg" width="100" height="100" />
|
|
@ -94,8 +94,8 @@ CherryUSB Host 协议栈当前实现以下功能:
|
|||
- 支持 Communication Device Class (CDC_ACM, CDC_ECM)
|
||||
- 支持 Human Interface Device (HID)
|
||||
- 支持 Mass Storage Class (MSC)
|
||||
- Support USB Video CLASS(商业收费)
|
||||
- Support USB Audio CLASS(商业收费)
|
||||
- Support USB Video CLASS (UVC1.0、UVC1.5)
|
||||
- Support USB Audio CLASS (UAC1.0)
|
||||
- 支持 Remote NDIS (RNDIS)
|
||||
- 支持 USB Bluetooth (支持 nimble and zephyr bluetooth 协议栈,支持 **CLASS: 0xE0** 或者厂家自定义类,类似于 cdc acm 功能)
|
||||
- 支持 Vendor 类 class
|
||||
|
@ -115,7 +115,7 @@ CherryUSB Host 协议栈资源占用说明(GCC 10.2 with -O2):
|
|||
|usbh_hid.c | ~1000 | 128 | 4 + sizeof(struct usbh_hid) * x | 0 |
|
||||
|usbh_video.c | ~3700 | 128 | 4 + sizeof(struct usbh_video) * x | 0 |
|
||||
|usbh_audio.c | ~3100 | 128 | 4 + sizeof(struct usbh_audio) * x | 0 |
|
||||
|usbh_rndis.c | ~3900 | 4096 + 2 * 2048 | sizeof(struct usbh_rndis) * 1 | 0 |
|
||||
|usbh_rndis.c | ~3900 | 4096 + 2 * 2048(default)| sizeof(struct usbh_rndis) * 1 | 0 |
|
||||
|usbh_cdc_ecm.c | ~2500 | 2 * 1514 | sizeof(struct usbh_cdc_ecm) * 1 | 0 |
|
||||
|usbh_bluetooth.c | ~2300 | 2 * 2048(default) | sizeof(struct usbh_bluetooth) * 1 | 0 |
|
||||
|
||||
|
@ -179,14 +179,19 @@ CherryUSB 快速入门、USB 基本概念,API 手册,Class 基本概念和
|
|||
|HPMicro | HPM6750 | hpm/ehci |[hpm_sdk](https://github.com/CherryUSB/hpm_sdk)|<= latest | Long-term |
|
||||
|Essemi | ES32F36xx | musb |[es32f369_repo](https://github.com/CherryUSB/cherryusb_es32)|<= latest | Long-term |
|
||||
|Phytium | e2000 | pusb2/xhci |[phytium_repo](https://gitee.com/phytium_embedded/phytium-free-rtos-sdk)|v0.10.2 | Long-term |
|
||||
|artinchip | d12x/d13x/d21x | aic/ehci/ohci |[luban-lite](https://gitee.com/artinchip/luban-lite)|<= latest | Long-term |
|
||||
|Artinchip | d12x/d13x/d21x | aic/ehci/ohci |[luban-lite](https://gitee.com/artinchip/luban-lite)|<= latest | Long-term |
|
||||
|Espressif | esp32s2/esp32s3 | dwc2 |[esp32_repo](https://github.com/CherryUSB/cherryusb_esp32)|<= latest | the same with ST |
|
||||
|AllwinnerTech | F1C100S/F1C200S | musb |[cherryusb_rtt_f1c100s](https://github.com/CherryUSB/cherryusb_rtt_f1c100s)|<= latest | the same with Essemi |
|
||||
|Bekencorp | bk7256/bk7258 | musb |[bk_idk](https://github.com/CherryUSB/bk_idk)| v0.7.0 | the same with Essemi |
|
||||
|Sophgo | cv18xx | dwc2 |[cvi_alios_open](https://github.com/CherryUSB/cvi_alios_open)| v0.7.0 | the same with ST |
|
||||
|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2 | TBD |
|
||||
|Nordicsemi | Nrf52840 | nrf5x |[nrf5x_repo](https://github.com/CherryUSB/cherryusb_nrf5x)|<= v0.10.2 | No more updated |
|
||||
|Raspberry pi | rp2040 | rp2040 |[pico-examples](https://github.com/CherryUSB/pico-examples)|<= v0.10.2 | No more updated |
|
||||
|
||||
## Contact
|
||||
## 商业支持
|
||||
|
||||
参考 https://cherryusb.readthedocs.io/zh-cn/latest/support/index.html。
|
||||
|
||||
## 联系
|
||||
|
||||
CherryUSB QQ 群:642693751
|
||||
CherryUSB 微信群:与我联系后邀请加入
|
||||
|
@ -195,4 +200,4 @@ CherryUSB 微信群:与我联系后邀请加入
|
|||
|
||||
感谢以下企业支持(顺序不分先后)。
|
||||
|
||||
<img src="docs/assets/bouffalolab.jpg" width="100" height="100"/> <img src="docs/assets/hpmicro.jpg" width="100" height="100" /> <img src="docs/assets/eastsoft.jpg" width="100" height="100" /> <img src="docs/assets/rtthread.jpg" width="100" height="100" /> <img src="docs/assets/sophgo.jpg" width="100" height="100" /> <img src="docs/assets/phytium.jpg" width="100" height="100" /> <img src="docs/assets/thead.jpg" width="100" height="100" /> <img src="docs/assets/nuvoton.jpg" width="100" height="100" /> <img src="docs/assets/artinchip.jpg" width="100" height="100" />
|
||||
<img src="docs/assets/bouffalolab.jpg" width="100" height="100"/> <img src="docs/assets/hpmicro.jpg" width="100" height="100" /> <img src="docs/assets/eastsoft.jpg" width="100" height="100" /> <img src="docs/assets/rtthread.jpg" width="100" height="100" /> <img src="docs/assets/sophgo.jpg" width="100" height="100" /> <img src="docs/assets/phytium.jpg" width="100" height="100" /> <img src="docs/assets/thead.jpg" width="100" height="100" /> <img src="docs/assets/nuvoton.jpg" width="100" height="100" /> <img src="docs/assets/artinchip.jpg" width="100" height="100" /> <img src="docs/assets/bekencorp.jpg" width="100" height="100" />
|
||||
|
|
|
@ -40,13 +40,20 @@ if GetDepend(['RT_CHERRYUSB_DEVICE']):
|
|||
if GetDepend(['RT_CHERRYUSB_DEVICE_DWC2_GD']):
|
||||
src += Glob('port/dwc2/usb_dc_dwc2.c')
|
||||
src += Glob('port/dwc2/usb_glue_gd.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_DWC2_HC']):
|
||||
src += Glob('port/dwc2/usb_dc_dwc2.c')
|
||||
src += Glob('port/dwc2/usb_glue_hc.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_DWC2_CUSTOM']):
|
||||
src += Glob('port/dwc2/usb_dc_dwc2.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_MUSB_STANDARD']):
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_MUSB_ES']):
|
||||
src += Glob('port/musb/usb_dc_musb.c')
|
||||
src += Glob('port/musb/usb_glue_es.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_MUSB_SUNXI']):
|
||||
src += Glob('port/musb/usb_dc_musb.c')
|
||||
src += Glob('port/musb/usb_glue_sunxi.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_MUSB_BK']):
|
||||
src += Glob('port/musb/usb_dc_musb.c')
|
||||
src += Glob('port/musb/usb_glue_bk.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_MUSB_CUSTOM']):
|
||||
src += Glob('port/musb/usb_dc_musb.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_BL']):
|
||||
|
@ -151,9 +158,15 @@ if GetDepend(['RT_CHERRYUSB_HOST']):
|
|||
src += Glob('port/dwc2/usb_hc_dwc2.c')
|
||||
if GetDepend(['RT_CHERRYUSB_HOST_MUSB_STANDARD']):
|
||||
src += Glob('port/musb/usb_hc_musb.c')
|
||||
if GetDepend(['RT_CHERRYUSB_HOST_MUSB_ES']):
|
||||
src += Glob('port/musb/usb_hc_musb.c')
|
||||
src += Glob('port/musb/usb_glue_es.c')
|
||||
if GetDepend(['RT_CHERRYUSB_HOST_MUSB_SUNXI']):
|
||||
src += Glob('port/musb/usb_hc_musb.c')
|
||||
src += Glob('port/musb/usb_glue_sunxi.c')
|
||||
if GetDepend(['RT_CHERRYUSB_HOST_MUSB_BK']):
|
||||
src += Glob('port/musb/usb_hc_musb.c')
|
||||
src += Glob('port/musb/usb_glue_bk.c')
|
||||
if GetDepend(['RT_CHERRYUSB_HOST_MUSB_CUSTOM']):
|
||||
src += Glob('port/musb/usb_hc_musb.c')
|
||||
|
||||
|
@ -197,8 +210,8 @@ if GetDepend(['RT_CHERRYUSB_HOST']):
|
|||
if GetDepend('RT_CHERRYUSB_HOST_CDC_ECM') \
|
||||
or GetDepend('RT_CHERRYUSB_HOST_CDC_RNDIS') \
|
||||
or GetDepend('RT_CHERRYUSB_HOST_CDC_NCM') \
|
||||
or GetDepend('RT_CHERRYUSB_HOST_CDC_ASIX') \
|
||||
or GetDepend('RT_CHERRYUSB_HOST_CDC_RTL8152'):
|
||||
or GetDepend('RT_CHERRYUSB_HOST_ASIX') \
|
||||
or GetDepend('RT_CHERRYUSB_HOST_RTL8152'):
|
||||
src += Glob('platform/rtthread/usbh_lwip.c')
|
||||
|
||||
src += Glob('platform/rtthread/usb_msh.c')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
VERSION_MAJOR = 1
|
||||
VERSION_MINOR = 3
|
||||
PATCHLEVEL = 0
|
||||
PATCHLEVEL = 1
|
||||
VERSION_TWEAK = 0
|
||||
EXTRAVERSION = 0
|
||||
|
|
|
@ -71,26 +71,39 @@ if(CONFIG_CHERRYUSB_DEVICE)
|
|||
endif()
|
||||
|
||||
if(DEFINED CONFIG_CHERRYUSB_DEVICE_DCD)
|
||||
if("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_st")
|
||||
if("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "fsdev")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/fsdev/usb_dc_fsdev.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_st")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_st.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_esp")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_esp.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_aic")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_aic.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_at")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_at.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "fsdev")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/fsdev/usb_dc_fsdev.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_gd")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_gd.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_hc")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_hc.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "musb_es")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_es.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "musb_sunxi")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_sunxi.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "musb_bk")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_bk.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "hpm")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpm/usb_dc_hpm.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "bl")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/bouffalolab/usb_dc_bl.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "musb")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
|
||||
elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "aic")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/aic/usb_dc_aic.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/aic/usb_dc_aic_ll.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -223,8 +236,18 @@ if(CONFIG_CHERRYUSB_HOST)
|
|||
elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "dwc2_esp")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_esp.c)
|
||||
elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "musb")
|
||||
elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "dwc2_hc")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_hc.c)
|
||||
elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "musb_es")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_es.c)
|
||||
elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "musb_sunxi")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_sunxi.c)
|
||||
elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "musb_bk")
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_bk.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#ifndef CHERRYUSB_CONFIG_H
|
||||
#define CHERRYUSB_CONFIG_H
|
||||
|
||||
#define CHERRYUSB_VERSION 0x010300
|
||||
#define CHERRYUSB_VERSION_STR "v1.3.0"
|
||||
#define CHERRYUSB_VERSION 0x010301
|
||||
#define CHERRYUSB_VERSION_STR "v1.3.1"
|
||||
|
||||
/* ================ USB common Configuration ================ */
|
||||
|
||||
|
@ -168,6 +168,17 @@
|
|||
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
|
||||
*/
|
||||
#ifndef CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE
|
||||
#define CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE (2048)
|
||||
#endif
|
||||
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
|
||||
#ifndef CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE
|
||||
#define CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
|
||||
*/
|
||||
|
@ -203,7 +214,11 @@
|
|||
//#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2 // maybe 1 or 2, many chips may have a difference
|
||||
|
||||
/* ---------------- DWC2 Configuration ---------------- */
|
||||
/* (5 * number of control endpoints + 8) + ((largest USB packet used / 4) + 1 for
|
||||
* status information) + (2 * number of OUT endpoints) + 1 for Global NAK
|
||||
*/
|
||||
// #define CONFIG_USB_DWC2_RXALL_FIFO_SIZE (1024 / 4)
|
||||
/* IN Endpoints Max packet Size / 4 */
|
||||
// #define CONFIG_USB_DWC2_TX0_FIFO_SIZE (64 / 4)
|
||||
// #define CONFIG_USB_DWC2_TX1_FIFO_SIZE (512 / 4)
|
||||
// #define CONFIG_USB_DWC2_TX2_FIFO_SIZE (64 / 4)
|
||||
|
|
|
@ -57,7 +57,7 @@ static void usbh_audio_class_free(struct usbh_audio *audio_class)
|
|||
|
||||
int usbh_audio_open(struct usbh_audio *audio_class, const char *name, uint32_t samp_freq)
|
||||
{
|
||||
struct usb_setup_packet *setup = audio_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
struct usb_endpoint_descriptor *ep_desc;
|
||||
uint8_t mult;
|
||||
uint16_t mps;
|
||||
|
@ -65,6 +65,11 @@ int usbh_audio_open(struct usbh_audio *audio_class, const char *name, uint32_t s
|
|||
uint8_t intf = 0xff;
|
||||
uint8_t altsetting = 1;
|
||||
|
||||
if (!audio_class || !audio_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = audio_class->hport->setup;
|
||||
|
||||
if (audio_class->is_opened) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -129,12 +134,17 @@ freq_found:
|
|||
|
||||
int usbh_audio_close(struct usbh_audio *audio_class, const char *name)
|
||||
{
|
||||
struct usb_setup_packet *setup = audio_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
struct usb_endpoint_descriptor *ep_desc;
|
||||
int ret;
|
||||
uint8_t intf = 0xff;
|
||||
uint8_t altsetting = 1;
|
||||
|
||||
if (!audio_class || !audio_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = audio_class->hport->setup;
|
||||
|
||||
for (size_t i = 0; i < audio_class->module_num; i++) {
|
||||
if (strcmp(name, audio_class->module[i].name) == 0) {
|
||||
intf = audio_class->module[i].data_intf;
|
||||
|
@ -172,12 +182,17 @@ int usbh_audio_close(struct usbh_audio *audio_class, const char *name)
|
|||
|
||||
int usbh_audio_set_volume(struct usbh_audio *audio_class, const char *name, uint8_t ch, uint8_t volume)
|
||||
{
|
||||
struct usb_setup_packet *setup = audio_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
uint8_t intf = 0xff;
|
||||
uint8_t feature_id = 0xff;
|
||||
uint16_t volume_hex;
|
||||
|
||||
if (!audio_class || !audio_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = audio_class->hport->setup;
|
||||
|
||||
for (size_t i = 0; i < audio_class->module_num; i++) {
|
||||
if (strcmp(name, audio_class->module[i].name) == 0) {
|
||||
intf = audio_class->ctrl_intf;
|
||||
|
@ -205,11 +220,16 @@ int usbh_audio_set_volume(struct usbh_audio *audio_class, const char *name, uint
|
|||
|
||||
int usbh_audio_set_mute(struct usbh_audio *audio_class, const char *name, uint8_t ch, bool mute)
|
||||
{
|
||||
struct usb_setup_packet *setup = audio_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
uint8_t intf = 0xff;
|
||||
uint8_t feature_id = 0xff;
|
||||
|
||||
if (!audio_class || !audio_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = audio_class->hport->setup;
|
||||
|
||||
for (size_t i = 0; i < audio_class->module_num; i++) {
|
||||
if (strcmp(name, audio_class->module[i].name) == 0) {
|
||||
intf = audio_class->ctrl_intf;
|
||||
|
@ -367,9 +387,9 @@ static int usbh_audio_ctrl_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||
audio_class->module[format_offset].altsetting[cur_alt_setting].sampfreq_num = desc->bSamFreqType;
|
||||
|
||||
for (uint8_t j = 0; j < desc->bSamFreqType; j++) {
|
||||
audio_class->module[format_offset].altsetting[cur_alt_setting].sampfreq[j] = (uint32_t)(p[10 + j] << 16) |
|
||||
(uint32_t)(p[9 + j] << 8) |
|
||||
(uint32_t)(p[8 + j] << 0);
|
||||
audio_class->module[format_offset].altsetting[cur_alt_setting].sampfreq[j] = (uint32_t)(p[10 + j * 3] << 16) |
|
||||
(uint32_t)(p[9 + j * 3] << 8) |
|
||||
(uint32_t)(p[8 + j * 3] << 0);
|
||||
}
|
||||
if (cur_alt_setting == (hport->config.intf[intf + 1].altsetting_num - 1)) {
|
||||
format_offset++;
|
||||
|
|
|
@ -588,7 +588,7 @@ eth_statistics, wMaxSegmentSize, wNumberMCFilters, bNumberPowerFilters, str_idx)
|
|||
CDC_FUNC_DESC_ETHERNET_NETWORKING, /* Ethernet Networking functional descriptor subtype */\
|
||||
str_idx, /* Device's MAC string index */\
|
||||
DBVAL_BE(eth_statistics), /* Ethernet statistics (bitmap) */\
|
||||
WBVAL(wMaxPacketSize),/* wMaxSegmentSize: Ethernet Maximum Segment size, typically 1514 bytes */\
|
||||
WBVAL(wMaxSegmentSize),/* wMaxSegmentSize: Ethernet Maximum Segment size, typically 1514 bytes */\
|
||||
WBVAL(wNumberMCFilters), /* wNumberMCFilters: the number of multicast filters */\
|
||||
bNumberPowerFilters, /* bNumberPowerFilters: the number of wakeup power filters */\
|
||||
0x07, /* bLength */ \
|
||||
|
|
|
@ -167,7 +167,7 @@ void usbd_cdc_ecm_start_read_next(void)
|
|||
{
|
||||
g_cdc_ecm_rx_data_length = 0;
|
||||
g_cdc_ecm_rx_data_buffer = NULL;
|
||||
usbd_ep_start_read(0, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr, g_cdc_ecm_rx_buffer, usbd_get_ep_mps(busid, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr));
|
||||
usbd_ep_start_read(0, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr, g_cdc_ecm_rx_buffer, usbd_get_ep_mps(0, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USBDEV_CDC_ECM_USING_LWIP
|
||||
|
@ -183,7 +183,7 @@ struct pbuf *usbd_cdc_ecm_eth_rx(void)
|
|||
usbd_cdc_ecm_start_read_next();
|
||||
return NULL;
|
||||
}
|
||||
memcpy(p->payload, (uint8_t *)g_cdc_ecm_rx_buffer, g_cdc_ecm_rx_data_length);
|
||||
usb_memcpy(p->payload, (uint8_t *)g_cdc_ecm_rx_buffer, g_cdc_ecm_rx_data_length);
|
||||
p->len = g_cdc_ecm_rx_data_length;
|
||||
|
||||
USB_LOG_DBG("rxlen:%d\r\n", g_cdc_ecm_rx_data_length);
|
||||
|
@ -206,13 +206,11 @@ int usbd_cdc_ecm_eth_tx(struct pbuf *p)
|
|||
|
||||
buffer = g_cdc_ecm_tx_buffer;
|
||||
for (q = p; q != NULL; q = q->next) {
|
||||
memcpy(buffer, q->payload, q->len);
|
||||
usb_memcpy(buffer, q->payload, q->len);
|
||||
buffer += q->len;
|
||||
}
|
||||
|
||||
g_cdc_ecm_tx_data_length = p->tot_len;
|
||||
|
||||
return usbd_cdc_ecm_start_write(g_cdc_ecm_tx_buffer, g_cdc_ecm_tx_data_length);
|
||||
return usbd_cdc_ecm_start_write(g_cdc_ecm_tx_buffer, p->tot_len);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -44,7 +44,12 @@ static void usbh_cdc_acm_class_free(struct usbh_cdc_acm *cdc_acm_class)
|
|||
|
||||
int usbh_cdc_acm_set_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding)
|
||||
{
|
||||
struct usb_setup_packet *setup = cdc_acm_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!cdc_acm_class || !cdc_acm_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cdc_acm_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_SET_LINE_CODING;
|
||||
|
@ -59,9 +64,14 @@ int usbh_cdc_acm_set_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_
|
|||
|
||||
int usbh_cdc_acm_get_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding)
|
||||
{
|
||||
struct usb_setup_packet *setup = cdc_acm_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!cdc_acm_class || !cdc_acm_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cdc_acm_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_GET_LINE_CODING;
|
||||
setup->wValue = 0;
|
||||
|
@ -78,7 +88,12 @@ int usbh_cdc_acm_get_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_
|
|||
|
||||
int usbh_cdc_acm_set_line_state(struct usbh_cdc_acm *cdc_acm_class, bool dtr, bool rts)
|
||||
{
|
||||
struct usb_setup_packet *setup = cdc_acm_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!cdc_acm_class || !cdc_acm_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cdc_acm_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_SET_CONTROL_LINE_STATE;
|
||||
|
|
|
@ -32,7 +32,12 @@ static struct usbh_cdc_ecm g_cdc_ecm_class;
|
|||
|
||||
static int usbh_cdc_ecm_set_eth_packet_filter(struct usbh_cdc_ecm *cdc_ecm_class, uint16_t filter_value)
|
||||
{
|
||||
struct usb_setup_packet *setup = cdc_ecm_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!cdc_ecm_class || !cdc_ecm_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cdc_ecm_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_SET_ETHERNET_PACKET_FILTER;
|
||||
|
@ -188,7 +193,7 @@ get_mac:
|
|||
}
|
||||
USB_LOG_INFO("Set CDC ECM packet filter:%04x\r\n", CONFIG_USBHOST_CDC_ECM_PKT_FILTER);
|
||||
|
||||
memcpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
strncpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
|
||||
USB_LOG_INFO("Register CDC ECM Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
|
||||
|
@ -246,30 +251,33 @@ find_class:
|
|||
usb_osal_msleep(100);
|
||||
goto find_class;
|
||||
}
|
||||
usb_osal_msleep(128);
|
||||
}
|
||||
|
||||
g_cdc_ecm_rx_length = 0;
|
||||
while (1) {
|
||||
usbh_bulk_urb_fill(&g_cdc_ecm_class.bulkin_urb, g_cdc_ecm_class.hport, g_cdc_ecm_class.bulkin, &g_cdc_ecm_rx_buffer[g_cdc_ecm_rx_length], CONFIG_USBHOST_CDC_ECM_ETH_MAX_SIZE, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
usbh_bulk_urb_fill(&g_cdc_ecm_class.bulkin_urb, g_cdc_ecm_class.hport, g_cdc_ecm_class.bulkin, g_cdc_ecm_rx_buffer, CONFIG_USBHOST_CDC_ECM_ETH_MAX_SIZE, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
ret = usbh_submit_urb(&g_cdc_ecm_class.bulkin_urb);
|
||||
if (ret < 0) {
|
||||
goto find_class;
|
||||
}
|
||||
|
||||
g_cdc_ecm_rx_length += g_cdc_ecm_class.bulkin_urb.actual_length;
|
||||
g_cdc_ecm_rx_length = g_cdc_ecm_class.bulkin_urb.actual_length;
|
||||
|
||||
if (g_cdc_ecm_rx_length % USB_GET_MAXPACKETSIZE(g_cdc_ecm_class.bulkin->wMaxPacketSize)) {
|
||||
/* A transfer is complete because last packet is a short packet.
|
||||
* Short packet is not zero, match g_cdc_ecm_rx_length % USB_GET_MAXPACKETSIZE(g_cdc_ecm_class.bulkin->wMaxPacketSize).
|
||||
* Short packet is zero, check if g_cdc_ecm_class.bulkin_urb.actual_length < transfer_size, for example transfer is complete with size is 512 < 1514.
|
||||
* This case is always true
|
||||
*/
|
||||
if (g_cdc_ecm_rx_length % USB_GET_MAXPACKETSIZE(g_cdc_ecm_class.bulkin->wMaxPacketSize) ||
|
||||
(g_cdc_ecm_class.bulkin_urb.actual_length < CONFIG_USBHOST_CDC_ECM_ETH_MAX_SIZE)) {
|
||||
USB_LOG_DBG("rxlen:%d\r\n", g_cdc_ecm_rx_length);
|
||||
|
||||
usbh_cdc_ecm_eth_input(g_cdc_ecm_rx_buffer, g_cdc_ecm_rx_length);
|
||||
|
||||
g_cdc_ecm_rx_length = 0;
|
||||
} else {
|
||||
/* read continue util read short packet */
|
||||
if (g_cdc_ecm_rx_length > CONFIG_USBHOST_CDC_ECM_ETH_MAX_SIZE) {
|
||||
USB_LOG_ERR("Rx packet is overflow\r\n");
|
||||
g_cdc_ecm_rx_length = 0;
|
||||
}
|
||||
/* There's no way to run here. */
|
||||
}
|
||||
}
|
||||
// clang-format off
|
||||
|
@ -279,16 +287,17 @@ delete:
|
|||
// clang-format on
|
||||
}
|
||||
|
||||
int usbh_cdc_ecm_eth_output(uint8_t *buf, uint32_t buflen)
|
||||
uint8_t *usbh_cdc_ecm_get_eth_txbuf(void)
|
||||
{
|
||||
uint8_t *buffer = g_cdc_ecm_tx_buffer;
|
||||
return g_cdc_ecm_tx_buffer;
|
||||
}
|
||||
|
||||
int usbh_cdc_ecm_eth_output(uint32_t buflen)
|
||||
{
|
||||
if (g_cdc_ecm_class.connect_status == false) {
|
||||
return -USB_ERR_NOTCONN;
|
||||
}
|
||||
|
||||
memcpy(buffer, buf, buflen);
|
||||
|
||||
USB_LOG_DBG("txlen:%d\r\n", buflen);
|
||||
|
||||
usbh_bulk_urb_fill(&g_cdc_ecm_class.bulkout_urb, g_cdc_ecm_class.hport, g_cdc_ecm_class.bulkout, g_cdc_ecm_tx_buffer, buflen, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
|
|
|
@ -38,7 +38,8 @@ int usbh_cdc_ecm_get_connect_status(struct usbh_cdc_ecm *cdc_ecm_class);
|
|||
void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class);
|
||||
void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class);
|
||||
|
||||
int usbh_cdc_ecm_eth_output(uint8_t *buf, uint32_t buflen);
|
||||
uint8_t *usbh_cdc_ecm_get_eth_txbuf(void);
|
||||
int usbh_cdc_ecm_eth_output(uint32_t buflen);
|
||||
void usbh_cdc_ecm_eth_input(uint8_t *buf, uint32_t buflen);
|
||||
void usbh_cdc_ecm_rx_thread(void *argument);
|
||||
|
||||
|
|
|
@ -33,9 +33,14 @@ static struct usbh_cdc_ncm g_cdc_ncm_class;
|
|||
|
||||
static int usbh_cdc_ncm_get_ntb_parameters(struct usbh_cdc_ncm *cdc_ncm_class, struct cdc_ncm_ntb_parameters *param)
|
||||
{
|
||||
struct usb_setup_packet *setup = cdc_ncm_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!cdc_ncm_class || !cdc_ncm_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cdc_ncm_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_GET_NTB_PARAMETERS;
|
||||
setup->wValue = 0;
|
||||
|
@ -206,7 +211,7 @@ get_mac:
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
strncpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
|
||||
USB_LOG_INFO("Register CDC NCM Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
|
||||
|
@ -248,6 +253,11 @@ void usbh_cdc_ncm_rx_thread(void *argument)
|
|||
{
|
||||
uint32_t g_cdc_ncm_rx_length;
|
||||
int ret;
|
||||
#if CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
uint32_t transfer_size = CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE;
|
||||
#else
|
||||
uint32_t transfer_size = (16 * 1024);
|
||||
#endif
|
||||
|
||||
USB_LOG_INFO("Create cdc ncm rx thread\r\n");
|
||||
// clang-format off
|
||||
|
@ -268,7 +278,7 @@ find_class:
|
|||
|
||||
g_cdc_ncm_rx_length = 0;
|
||||
while (1) {
|
||||
usbh_bulk_urb_fill(&g_cdc_ncm_class.bulkin_urb, g_cdc_ncm_class.hport, g_cdc_ncm_class.bulkin, &g_cdc_ncm_rx_buffer[g_cdc_ncm_rx_length], (CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE > (16 * 1024)) ? (16 * 1024) : CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
usbh_bulk_urb_fill(&g_cdc_ncm_class.bulkin_urb, g_cdc_ncm_class.hport, g_cdc_ncm_class.bulkin, &g_cdc_ncm_rx_buffer[g_cdc_ncm_rx_length], transfer_size, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
ret = usbh_submit_urb(&g_cdc_ncm_class.bulkin_urb);
|
||||
if (ret < 0) {
|
||||
goto find_class;
|
||||
|
@ -276,7 +286,12 @@ find_class:
|
|||
|
||||
g_cdc_ncm_rx_length += g_cdc_ncm_class.bulkin_urb.actual_length;
|
||||
|
||||
if (g_cdc_ncm_rx_length % USB_GET_MAXPACKETSIZE(g_cdc_ncm_class.bulkin->wMaxPacketSize)) {
|
||||
/* A transfer is complete because last packet is a short packet.
|
||||
* Short packet is not zero, match g_cdc_ncm_rx_length % USB_GET_MAXPACKETSIZE(g_cdc_ncm_class.bulkin->wMaxPacketSize).
|
||||
* Short packet is zero, check if g_cdc_ncm_class.bulkin_urb.actual_length < transfer_size, for example transfer is complete with size is 1024 < 2048.
|
||||
*/
|
||||
if ((g_cdc_ncm_rx_length % USB_GET_MAXPACKETSIZE(g_cdc_ncm_class.bulkin->wMaxPacketSize)) ||
|
||||
(g_cdc_ncm_class.bulkin_urb.actual_length < transfer_size)) {
|
||||
USB_LOG_DBG("rxlen:%d\r\n", g_cdc_ncm_rx_length);
|
||||
|
||||
struct cdc_ncm_nth16 *nth16 = (struct cdc_ncm_nth16 *)&g_cdc_ncm_rx_buffer[0];
|
||||
|
@ -309,11 +324,15 @@ find_class:
|
|||
}
|
||||
|
||||
g_cdc_ncm_rx_length = 0;
|
||||
|
||||
} else {
|
||||
if (g_cdc_ncm_rx_length > CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE) {
|
||||
USB_LOG_ERR("Rx packet is overflow\r\n");
|
||||
g_cdc_ncm_rx_length = 0;
|
||||
#if CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
if (g_cdc_ncm_rx_length == CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE) {
|
||||
#else
|
||||
if ((g_cdc_ncm_rx_length + (16 * 1024)) > CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE) {
|
||||
#endif
|
||||
USB_LOG_ERR("Rx packet is overflow, please ruduce tcp window size or increase CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE\r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,9 +343,13 @@ delete:
|
|||
// clang-format on
|
||||
}
|
||||
|
||||
int usbh_cdc_ncm_eth_output(uint8_t *buf, uint32_t buflen)
|
||||
uint8_t *usbh_cdc_ncm_get_eth_txbuf(void)
|
||||
{
|
||||
return &g_cdc_ncm_tx_buffer[16];
|
||||
}
|
||||
|
||||
int usbh_cdc_ncm_eth_output(uint32_t buflen)
|
||||
{
|
||||
uint8_t *buffer;
|
||||
struct cdc_ncm_ndp16_datagram *ndp16_datagram;
|
||||
|
||||
if (g_cdc_ncm_class.connect_status == false) {
|
||||
|
@ -355,9 +378,6 @@ int usbh_cdc_ncm_eth_output(uint8_t *buf, uint32_t buflen)
|
|||
ndp16_datagram->wDatagramIndex = 0;
|
||||
ndp16_datagram->wDatagramLength = 0;
|
||||
|
||||
buffer = &g_cdc_ncm_tx_buffer[16];
|
||||
memcpy(buffer, buf, buflen);
|
||||
|
||||
USB_LOG_DBG("txlen:%d\r\n", nth16->wBlockLength);
|
||||
|
||||
usbh_bulk_urb_fill(&g_cdc_ncm_class.bulkout_urb, g_cdc_ncm_class.hport, g_cdc_ncm_class.bulkout, g_cdc_ncm_tx_buffer, nth16->wBlockLength, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
|
|
|
@ -42,7 +42,8 @@ int usbh_cdc_ncm_get_connect_status(struct usbh_cdc_ncm *cdc_ncm_class);
|
|||
void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class);
|
||||
void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class);
|
||||
|
||||
int usbh_cdc_ncm_eth_output(uint8_t *buf, uint32_t buflen);
|
||||
uint8_t *usbh_cdc_ncm_get_eth_txbuf(void);
|
||||
int usbh_cdc_ncm_eth_output(uint32_t buflen);
|
||||
void usbh_cdc_ncm_eth_input(uint8_t *buf, uint32_t buflen);
|
||||
void usbh_cdc_ncm_rx_thread(void *argument);
|
||||
|
||||
|
|
|
@ -44,9 +44,14 @@ static void usbh_hid_class_free(struct usbh_hid *hid_class)
|
|||
|
||||
static int usbh_hid_get_report_descriptor(struct usbh_hid *hid_class, uint8_t *buffer)
|
||||
{
|
||||
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!hid_class || !hid_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = hid_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = USB_REQUEST_GET_DESCRIPTOR;
|
||||
setup->wValue = HID_DESCRIPTOR_TYPE_HID_REPORT << 8;
|
||||
|
@ -63,7 +68,12 @@ static int usbh_hid_get_report_descriptor(struct usbh_hid *hid_class, uint8_t *b
|
|||
|
||||
int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t duration)
|
||||
{
|
||||
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!hid_class || !hid_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = hid_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = HID_REQUEST_SET_IDLE;
|
||||
|
@ -76,9 +86,14 @@ int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t dur
|
|||
|
||||
int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer)
|
||||
{
|
||||
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!hid_class || !hid_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = hid_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = HID_REQUEST_GET_IDLE;
|
||||
setup->wValue = 0;
|
||||
|
@ -95,7 +110,12 @@ int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer)
|
|||
|
||||
int usbh_hid_set_protocol(struct usbh_hid *hid_class, uint8_t protocol)
|
||||
{
|
||||
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!hid_class || !hid_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = hid_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = HID_REQUEST_SET_PROTOCOL;
|
||||
|
@ -108,7 +128,12 @@ int usbh_hid_set_protocol(struct usbh_hid *hid_class, uint8_t protocol)
|
|||
|
||||
int usbh_hid_set_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen)
|
||||
{
|
||||
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!hid_class || !hid_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = hid_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = HID_REQUEST_SET_REPORT;
|
||||
|
@ -121,7 +146,12 @@ int usbh_hid_set_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t
|
|||
|
||||
int usbh_hid_get_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen)
|
||||
{
|
||||
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!hid_class || !hid_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = hid_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = HID_REQUEST_GET_REPORT;
|
||||
|
|
|
@ -27,13 +27,6 @@ extern void usbh_hubport_release(struct usbh_hubport *hport);
|
|||
|
||||
static const char *speed_table[] = { "error-speed", "low-speed", "full-speed", "high-speed", "wireless-speed", "super-speed", "superplus-speed" };
|
||||
|
||||
#ifdef CONFIG_USBHOST_XHCI
|
||||
struct usbh_hubport *usbh_get_roothub_port(unsigned int port)
|
||||
{
|
||||
return &roothub.child[port - 1];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
|
||||
static struct usbh_hub g_hub_class[CONFIG_USBHOST_MAX_EXTHUBS];
|
||||
static uint32_t g_devinuse = 0;
|
||||
|
@ -373,8 +366,6 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||
hub->connected = true;
|
||||
snprintf(hport->config.intf[intf].devname, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, hub->index);
|
||||
|
||||
usb_slist_add_tail(&hub->bus->hub_list, &hub->list);
|
||||
|
||||
USB_LOG_INFO("Register HUB Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
|
||||
hub->int_buffer = g_hub_intbuf[hub->bus->busid][hub->index - 1];
|
||||
|
@ -412,7 +403,6 @@ static int usbh_hub_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||
|
||||
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||
USB_LOG_INFO("Unregister HUB Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
usb_slist_remove(&hub->bus->hub_list, &hub->list);
|
||||
}
|
||||
|
||||
usbh_hub_class_free(hub);
|
||||
|
@ -421,18 +411,6 @@ static int usbh_hub_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void usbh_hubport_enumerate_thread(void *argument)
|
||||
{
|
||||
struct usbh_hubport *child = (struct usbh_hubport *)argument;
|
||||
|
||||
if (usbh_enumerate(child) < 0) {
|
||||
/** release child sources */
|
||||
usbh_hubport_release(child);
|
||||
USB_LOG_ERR("Port %u enumerate fail\r\n", child->port);
|
||||
}
|
||||
usb_osal_thread_delete(NULL);
|
||||
}
|
||||
|
||||
static void usbh_hub_events(struct usbh_hub *hub)
|
||||
{
|
||||
struct usbh_hubport *child;
|
||||
|
@ -444,13 +422,16 @@ static void usbh_hub_events(struct usbh_hub *hub)
|
|||
uint16_t feat;
|
||||
uint8_t speed;
|
||||
int ret;
|
||||
size_t flags;
|
||||
|
||||
if (!hub->connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
portchange_index = hub->int_buffer[0];
|
||||
hub->int_buffer[0] &= ~portchange_index;
|
||||
usb_osal_leave_critical_section(flags);
|
||||
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
USB_LOG_DBG("Port change:0x%02x\r\n", portchange_index);
|
||||
|
@ -562,25 +543,9 @@ static void usbh_hub_events(struct usbh_hub *hub)
|
|||
speed = USB_SPEED_HIGH;
|
||||
} else if (portstatus & HUB_PORT_STATUS_LOW_SPEED) {
|
||||
speed = USB_SPEED_LOW;
|
||||
}
|
||||
#ifdef CONFIG_USBHOST_XHCI
|
||||
else {
|
||||
extern uint8_t usbh_get_port_speed(struct usbh_hub * hub, const uint8_t port);
|
||||
|
||||
/* USB3.0 speed cannot get from portstatus, checkout port speed instead */
|
||||
uint8_t super_speed = usbh_get_port_speed(hub, port + 1);
|
||||
if (super_speed > USB_SPEED_HIGH) {
|
||||
/* assert that when using USB 3.0 ports, attached device must also be USB 3.0 speed */
|
||||
speed = super_speed;
|
||||
} else {
|
||||
speed = USB_SPEED_FULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
else {
|
||||
speed = USB_SPEED_FULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
child = &hub->child[port];
|
||||
/** release child sources first */
|
||||
|
@ -596,8 +561,11 @@ static void usbh_hub_events(struct usbh_hub *hub)
|
|||
|
||||
USB_LOG_INFO("New %s device on Bus %u, Hub %u, Port %u connected\r\n", speed_table[speed], hub->bus->busid, hub->index, port + 1);
|
||||
|
||||
/* create disposable thread to enumerate device on current hport, do not block hub thread */
|
||||
usb_osal_thread_create("usbh_enum", CONFIG_USBHOST_PSC_STACKSIZE, CONFIG_USBHOST_PSC_PRIO + 1, usbh_hubport_enumerate_thread, (void *)child);
|
||||
if (usbh_enumerate(child) < 0) {
|
||||
/** release child sources */
|
||||
usbh_hubport_release(child);
|
||||
USB_LOG_ERR("Port %u enumerate fail\r\n", child->port);
|
||||
}
|
||||
} else {
|
||||
child = &hub->child[port];
|
||||
/** release child sources */
|
||||
|
@ -648,6 +616,17 @@ void usbh_hub_thread_wakeup(struct usbh_hub *hub)
|
|||
int usbh_hub_initialize(struct usbh_bus *bus)
|
||||
{
|
||||
char thread_name[32] = { 0 };
|
||||
struct usbh_hub *hub;
|
||||
|
||||
hub = &bus->hcd.roothub;
|
||||
hub->connected = true;
|
||||
hub->index = 1;
|
||||
hub->is_roothub = true;
|
||||
hub->parent = NULL;
|
||||
hub->hub_addr = 1;
|
||||
hub->hub_desc.bNbrPorts = CONFIG_USBHOST_MAX_RHPORTS;
|
||||
hub->int_buffer = bus->hcd.roothub_intbuf;
|
||||
hub->bus = bus;
|
||||
|
||||
bus->hub_mq = usb_osal_mq_create(7);
|
||||
if (bus->hub_mq == NULL) {
|
||||
|
@ -666,22 +645,18 @@ int usbh_hub_initialize(struct usbh_bus *bus)
|
|||
|
||||
int usbh_hub_deinitialize(struct usbh_bus *bus)
|
||||
{
|
||||
usb_slist_t *hub_list;
|
||||
struct usbh_hubport *hport;
|
||||
struct usbh_hub *hub;
|
||||
size_t flags;
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
|
||||
usb_slist_for_each(hub_list, &bus->hub_list)
|
||||
{
|
||||
struct usbh_hub *hub = usb_slist_entry(hub_list, struct usbh_hub, list);
|
||||
|
||||
hub = &bus->hcd.roothub;
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
hport = &hub->child[port];
|
||||
|
||||
usbh_hubport_release(hport);
|
||||
}
|
||||
}
|
||||
|
||||
usb_hc_deinit(bus);
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#define DEV_FORMAT "/dev/sd%c"
|
||||
|
||||
#define MSC_INQUIRY_TIMEOUT 500
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_msc_buf[64];
|
||||
|
||||
static struct usbh_msc g_msc_class[CONFIG_USBHOST_MAX_MSC_CLASS];
|
||||
|
@ -46,7 +48,12 @@ static void usbh_msc_class_free(struct usbh_msc *msc_class)
|
|||
|
||||
static int usbh_msc_get_maxlun(struct usbh_msc *msc_class, uint8_t *buffer)
|
||||
{
|
||||
struct usb_setup_packet *setup = msc_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!msc_class || !msc_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = msc_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = MSC_REQUEST_GET_MAX_LUN;
|
||||
|
@ -113,14 +120,14 @@ static inline int usbh_msc_bulk_out_transfer(struct usbh_msc *msc_class, uint8_t
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int usbh_bulk_cbw_csw_xfer(struct usbh_msc *msc_class, struct CBW *cbw, struct CSW *csw, uint8_t *buffer)
|
||||
static int usbh_bulk_cbw_csw_xfer(struct usbh_msc *msc_class, struct CBW *cbw, struct CSW *csw, uint8_t *buffer, uint32_t timeout)
|
||||
{
|
||||
int nbytes;
|
||||
|
||||
usbh_msc_cbw_dump(cbw);
|
||||
|
||||
/* Send the CBW */
|
||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, timeout);
|
||||
if (nbytes < 0) {
|
||||
USB_LOG_ERR("cbw transfer error\r\n");
|
||||
goto __err_exit;
|
||||
|
@ -128,16 +135,16 @@ static int usbh_bulk_cbw_csw_xfer(struct usbh_msc *msc_class, struct CBW *cbw, s
|
|||
|
||||
if (cbw->dDataLength != 0) {
|
||||
if (cbw->CB[0] == SCSI_CMD_WRITE10) {
|
||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, buffer, cbw->dDataLength, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, buffer, cbw->dDataLength, timeout);
|
||||
} else if (cbw->CB[0] == SCSI_CMD_READCAPACITY10) {
|
||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, buffer, cbw->dDataLength, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, buffer, cbw->dDataLength, timeout);
|
||||
if (nbytes >= 0) {
|
||||
/* Save the capacity information */
|
||||
msc_class->blocknum = GET_BE32(&buffer[0]) + 1;
|
||||
msc_class->blocksize = GET_BE32(&buffer[4]);
|
||||
}
|
||||
} else {
|
||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, buffer, cbw->dDataLength, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, buffer, cbw->dDataLength, timeout);
|
||||
}
|
||||
|
||||
if (nbytes < 0) {
|
||||
|
@ -148,7 +155,7 @@ static int usbh_bulk_cbw_csw_xfer(struct usbh_msc *msc_class, struct CBW *cbw, s
|
|||
|
||||
/* Receive the CSW */
|
||||
memset(csw, 0, USB_SIZEOF_MSC_CSW);
|
||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, (uint8_t *)csw, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, (uint8_t *)csw, USB_SIZEOF_MSC_CSW, timeout);
|
||||
if (nbytes < 0) {
|
||||
USB_LOG_ERR("csw transfer error\r\n");
|
||||
goto __err_exit;
|
||||
|
@ -182,7 +189,7 @@ static inline int usbh_msc_scsi_testunitready(struct usbh_msc *msc_class)
|
|||
cbw->bCBLength = SCSICMD_TESTUNITREADY_SIZEOF;
|
||||
cbw->CB[0] = SCSI_CMD_TESTUNITREADY;
|
||||
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, NULL);
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, NULL, MSC_INQUIRY_TIMEOUT);
|
||||
}
|
||||
|
||||
static inline int usbh_msc_scsi_requestsense(struct usbh_msc *msc_class)
|
||||
|
@ -200,7 +207,7 @@ static inline int usbh_msc_scsi_requestsense(struct usbh_msc *msc_class)
|
|||
cbw->CB[0] = SCSI_CMD_REQUESTSENSE;
|
||||
cbw->CB[4] = SCSIRESP_FIXEDSENSEDATA_SIZEOF;
|
||||
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf);
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf, MSC_INQUIRY_TIMEOUT);
|
||||
}
|
||||
|
||||
static inline int usbh_msc_scsi_inquiry(struct usbh_msc *msc_class)
|
||||
|
@ -218,7 +225,7 @@ static inline int usbh_msc_scsi_inquiry(struct usbh_msc *msc_class)
|
|||
cbw->CB[0] = SCSI_CMD_INQUIRY;
|
||||
cbw->CB[4] = SCSIRESP_INQUIRY_SIZEOF;
|
||||
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf);
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf, MSC_INQUIRY_TIMEOUT);
|
||||
}
|
||||
|
||||
static inline int usbh_msc_scsi_readcapacity10(struct usbh_msc *msc_class)
|
||||
|
@ -235,7 +242,7 @@ static inline int usbh_msc_scsi_readcapacity10(struct usbh_msc *msc_class)
|
|||
cbw->bCBLength = SCSICMD_READCAPACITY10_SIZEOF;
|
||||
cbw->CB[0] = SCSI_CMD_READCAPACITY10;
|
||||
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf);
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf, MSC_INQUIRY_TIMEOUT);
|
||||
}
|
||||
|
||||
static inline void usbh_msc_modeswitch(struct usbh_msc *msc_class, const uint8_t *message)
|
||||
|
@ -247,7 +254,7 @@ static inline void usbh_msc_modeswitch(struct usbh_msc *msc_class, const uint8_t
|
|||
|
||||
memcpy(g_msc_buf, message, 31);
|
||||
|
||||
usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, NULL);
|
||||
usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, NULL, MSC_INQUIRY_TIMEOUT);
|
||||
}
|
||||
|
||||
static int usbh_msc_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
|
@ -380,7 +387,7 @@ int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, con
|
|||
SET_BE32(&cbw->CB[2], start_sector);
|
||||
SET_BE16(&cbw->CB[7], nsectors);
|
||||
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, (uint8_t *)buffer);
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, (uint8_t *)buffer, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||
}
|
||||
|
||||
int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors)
|
||||
|
@ -400,7 +407,7 @@ int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, cons
|
|||
SET_BE32(&cbw->CB[2], start_sector);
|
||||
SET_BE16(&cbw->CB[7], nsectors);
|
||||
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, (uint8_t *)buffer);
|
||||
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, (uint8_t *)buffer, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||
}
|
||||
|
||||
void usbh_msc_modeswitch_enable(struct usbh_msc_modeswitch_config *config)
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
#define DEV_FORMAT "/dev/asix"
|
||||
|
||||
static struct usbh_asix g_asix_class;
|
||||
#define CONFIG_USBHOST_ASIX_ETH_MAX_SIZE (1514U + 8)
|
||||
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_asix_rx_buffer[CONFIG_USBHOST_ASIX_ETH_MAX_SIZE];
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_asix_tx_buffer[CONFIG_USBHOST_ASIX_ETH_MAX_SIZE];
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_asix_rx_buffer[CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE];
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_asix_tx_buffer[CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE];
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_asix_inttx_buffer[16];
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_asix_buf[32];
|
||||
|
||||
|
@ -56,9 +55,14 @@ static int usbh_asix_read_cmd(struct usbh_asix *asix_class,
|
|||
void *data,
|
||||
uint16_t size)
|
||||
{
|
||||
struct usb_setup_packet *setup = asix_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!asix_class || !asix_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = asix_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = cmd;
|
||||
setup->wValue = value;
|
||||
|
@ -81,7 +85,12 @@ static int usbh_asix_write_cmd(struct usbh_asix *asix_class,
|
|||
void *data,
|
||||
uint16_t size)
|
||||
{
|
||||
struct usb_setup_packet *setup = asix_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!asix_class || !asix_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = asix_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = cmd;
|
||||
|
@ -263,6 +272,15 @@ static int usbh_asix_write_gpio(struct usbh_asix *asix_class, uint16_t value, in
|
|||
static void usbh_asix_set_multicast(struct usbh_asix *asix_class)
|
||||
{
|
||||
uint16_t rx_ctl = AX_DEFAULT_RX_CTL | AX_RX_CTL_AM;
|
||||
#if CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE == 4096
|
||||
rx_ctl |= AX_RX_CTL_MFB_4096;
|
||||
#elif CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE == 8192
|
||||
rx_ctl |= AX_RX_CTL_MFB_8192;
|
||||
#elif CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE == 16384
|
||||
rx_ctl |= AX_RX_CTL_MFB_16384;
|
||||
#else
|
||||
rx_ctl |= AX_RX_CTL_MFB_2048;
|
||||
#endif
|
||||
const uint8_t multi_filter[] = { 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x00, 0x40 };
|
||||
|
||||
usbh_asix_write_cmd(asix_class, AX_CMD_WRITE_MULTI_FILTER, 0, 0, (uint8_t *)multi_filter, AX_MCAST_FILTER_SIZE);
|
||||
|
@ -589,7 +607,7 @@ static int usbh_asix_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||
|
||||
USB_LOG_INFO("Init %s done\r\n", asix_class->name);
|
||||
|
||||
memcpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
strncpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
|
||||
USB_LOG_INFO("Register ASIX Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
usbh_asix_run(asix_class);
|
||||
|
@ -655,6 +673,12 @@ void usbh_asix_rx_thread(void *argument)
|
|||
int ret;
|
||||
uint16_t len;
|
||||
uint16_t len_crc;
|
||||
uint32_t data_offset;
|
||||
#if CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
uint32_t transfer_size = CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE;
|
||||
#else
|
||||
uint32_t transfer_size = (16 * 1024);
|
||||
#endif
|
||||
|
||||
USB_LOG_INFO("Create asix rx thread\r\n");
|
||||
// clang-format off
|
||||
|
@ -671,11 +695,12 @@ find_class:
|
|||
usb_osal_msleep(100);
|
||||
goto find_class;
|
||||
}
|
||||
usb_osal_msleep(128);
|
||||
}
|
||||
|
||||
g_asix_rx_length = 0;
|
||||
while (1) {
|
||||
usbh_bulk_urb_fill(&g_asix_class.bulkin_urb, g_asix_class.hport, g_asix_class.bulkin, &g_asix_rx_buffer[g_asix_rx_length], CONFIG_USBHOST_ASIX_ETH_MAX_SIZE, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
usbh_bulk_urb_fill(&g_asix_class.bulkin_urb, g_asix_class.hport, g_asix_class.bulkin, &g_asix_rx_buffer[g_asix_rx_length], transfer_size, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
ret = usbh_submit_urb(&g_asix_class.bulkin_urb);
|
||||
if (ret < 0) {
|
||||
goto find_class;
|
||||
|
@ -683,24 +708,43 @@ find_class:
|
|||
|
||||
g_asix_rx_length += g_asix_class.bulkin_urb.actual_length;
|
||||
|
||||
if (g_asix_rx_length % USB_GET_MAXPACKETSIZE(g_asix_class.bulkin->wMaxPacketSize)) {
|
||||
len = ((uint16_t)g_asix_rx_buffer[0] | ((uint16_t)(g_asix_rx_buffer[1]) << 8)) & 0x7ff;
|
||||
len_crc = g_asix_rx_buffer[2] | ((uint16_t)(g_asix_rx_buffer[3]) << 8);
|
||||
/* A transfer is complete because last packet is a short packet.
|
||||
* Short packet is not zero, match g_asix_rx_length % USB_GET_MAXPACKETSIZE(g_asix_class.bulkin->wMaxPacketSize).
|
||||
* Short packet is zero, check if g_asix_class.bulkin_urb.actual_length < transfer_size, for example transfer is complete with size is 1024 < 2048.
|
||||
*/
|
||||
if (g_asix_rx_length % USB_GET_MAXPACKETSIZE(g_asix_class.bulkin->wMaxPacketSize) ||
|
||||
(g_asix_class.bulkin_urb.actual_length < transfer_size)) {
|
||||
USB_LOG_DBG("rxlen:%d\r\n", g_asix_rx_length);
|
||||
|
||||
data_offset = 0;
|
||||
while (g_asix_rx_length > 0) {
|
||||
len = ((uint16_t)g_asix_rx_buffer[data_offset + 0] | ((uint16_t)(g_asix_rx_buffer[data_offset + 1]) << 8)) & 0x7ff;
|
||||
len_crc = g_asix_rx_buffer[data_offset + 2] | ((uint16_t)(g_asix_rx_buffer[data_offset + 3]) << 8);
|
||||
|
||||
if (len != (~len_crc & 0x7ff)) {
|
||||
USB_LOG_ERR("asix rx header error\r\n");
|
||||
USB_LOG_ERR("rx header error\r\n");
|
||||
g_asix_rx_length = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
USB_LOG_DBG("rxlen:%d\r\n", g_asix_rx_length);
|
||||
|
||||
uint8_t *buf = (uint8_t *)&g_asix_rx_buffer[4];
|
||||
uint8_t *buf = (uint8_t *)&g_asix_rx_buffer[data_offset + 4];
|
||||
usbh_asix_eth_input(buf, len);
|
||||
g_asix_rx_length -= (len + 4);
|
||||
data_offset += (len + 4);
|
||||
|
||||
if (g_asix_rx_length < 4) {
|
||||
g_asix_rx_length = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (g_asix_rx_length > CONFIG_USBHOST_ASIX_ETH_MAX_SIZE) {
|
||||
USB_LOG_ERR("Rx packet is overflow\r\n");
|
||||
g_asix_rx_length = 0;
|
||||
#if CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
if (g_asix_rx_length == CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE) {
|
||||
#else
|
||||
if ((g_asix_rx_length + (16 * 1024)) > CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE) {
|
||||
#endif
|
||||
USB_LOG_ERR("Rx packet is overflow, please ruduce tcp window size or increase CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE\r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -711,18 +755,19 @@ delete:
|
|||
// clang-format on
|
||||
}
|
||||
|
||||
int usbh_asix_eth_output(uint8_t *buf, uint32_t buflen)
|
||||
uint8_t *usbh_asix_get_eth_txbuf(void)
|
||||
{
|
||||
return &g_asix_tx_buffer[4];
|
||||
}
|
||||
|
||||
int usbh_asix_eth_output(uint32_t buflen)
|
||||
{
|
||||
uint16_t actual_len;
|
||||
uint8_t *buffer;
|
||||
|
||||
if (g_asix_class.connect_status == false) {
|
||||
return -USB_ERR_NOTCONN;
|
||||
}
|
||||
|
||||
buffer = &g_asix_tx_buffer[4];
|
||||
memcpy(buffer, buf, buflen);
|
||||
|
||||
g_asix_tx_buffer[0] = buflen & 0xff;
|
||||
g_asix_tx_buffer[1] = (buflen >> 8) & 0xff;
|
||||
g_asix_tx_buffer[2] = ~g_asix_tx_buffer[0];
|
||||
|
|
|
@ -165,7 +165,8 @@ int usbh_asix_get_connect_status(struct usbh_asix *asix_class);
|
|||
void usbh_asix_run(struct usbh_asix *asix_class);
|
||||
void usbh_asix_stop(struct usbh_asix *asix_class);
|
||||
|
||||
int usbh_asix_eth_output(uint8_t *buf, uint32_t buflen);
|
||||
uint8_t *usbh_asix_get_eth_txbuf(void);
|
||||
int usbh_asix_eth_output(uint32_t buflen);
|
||||
void usbh_asix_eth_input(uint8_t *buf, uint32_t buflen);
|
||||
void usbh_asix_rx_thread(void *argument);
|
||||
|
||||
|
|
|
@ -946,9 +946,14 @@ static int usbh_rtl8152_read_regs(struct usbh_rtl8152 *rtl8152_class,
|
|||
uint16_t size,
|
||||
void *data)
|
||||
{
|
||||
struct usb_setup_packet *setup = rtl8152_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!rtl8152_class || !rtl8152_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = rtl8152_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = RTL8152_REQ_GET_REGS;
|
||||
setup->wValue = value;
|
||||
|
@ -970,7 +975,12 @@ static int usbh_rtl8152_write_regs(struct usbh_rtl8152 *rtl8152_class,
|
|||
uint16_t size,
|
||||
void *data)
|
||||
{
|
||||
struct usb_setup_packet *setup = rtl8152_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!rtl8152_class || !rtl8152_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = rtl8152_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = RTL8152_REQ_SET_REGS;
|
||||
|
@ -2080,7 +2090,7 @@ static int usbh_rtl8152_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
strncpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
|
||||
USB_LOG_INFO("Register RTL8152 Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
|
||||
|
@ -2124,6 +2134,11 @@ void usbh_rtl8152_rx_thread(void *argument)
|
|||
int ret;
|
||||
uint16_t len;
|
||||
uint16_t data_offset;
|
||||
#if CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
uint32_t transfer_size = CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE;
|
||||
#else
|
||||
uint32_t transfer_size = (16 * 1024);
|
||||
#endif
|
||||
|
||||
USB_LOG_INFO("Create rtl8152 rx thread\r\n");
|
||||
// clang-format off
|
||||
|
@ -2154,7 +2169,7 @@ find_class:
|
|||
|
||||
g_rtl8152_rx_length = 0;
|
||||
while (1) {
|
||||
usbh_bulk_urb_fill(&g_rtl8152_class.bulkin_urb, g_rtl8152_class.hport, g_rtl8152_class.bulkin, &g_rtl8152_rx_buffer[g_rtl8152_rx_length], (CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE > (16 * 1024)) ? (16 * 1024) : CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
usbh_bulk_urb_fill(&g_rtl8152_class.bulkin_urb, g_rtl8152_class.hport, g_rtl8152_class.bulkin, &g_rtl8152_rx_buffer[g_rtl8152_rx_length], transfer_size, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
ret = usbh_submit_urb(&g_rtl8152_class.bulkin_urb);
|
||||
if (ret < 0) {
|
||||
goto find_class;
|
||||
|
@ -2162,7 +2177,12 @@ find_class:
|
|||
|
||||
g_rtl8152_rx_length += g_rtl8152_class.bulkin_urb.actual_length;
|
||||
|
||||
if (g_rtl8152_rx_length % USB_GET_MAXPACKETSIZE(g_rtl8152_class.bulkin->wMaxPacketSize)) {
|
||||
/* A transfer is complete because last packet is a short packet.
|
||||
* Short packet is not zero, match g_rtl8152_rx_length % USB_GET_MAXPACKETSIZE(g_rtl8152_class.bulkin->wMaxPacketSize).
|
||||
* Short packet is zero, check if g_rtl8152_class.bulkin_urb.actual_length < transfer_size, for example transfer is complete with size is 1024 < 2048.
|
||||
*/
|
||||
if (g_rtl8152_rx_length % USB_GET_MAXPACKETSIZE(g_rtl8152_class.bulkin->wMaxPacketSize) ||
|
||||
(g_rtl8152_class.bulkin_urb.actual_length < transfer_size)) {
|
||||
data_offset = 0;
|
||||
|
||||
USB_LOG_DBG("rxlen:%d\r\n", g_rtl8152_rx_length);
|
||||
|
@ -2185,9 +2205,14 @@ find_class:
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (g_rtl8152_rx_length > CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE) {
|
||||
USB_LOG_ERR("Rx packet is overflow\r\n");
|
||||
g_rtl8152_rx_length = 0;
|
||||
#if CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
if (g_rtl8152_rx_length == CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE) {
|
||||
#else
|
||||
if ((g_rtl8152_rx_length + (16 * 1024)) > CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE) {
|
||||
#endif
|
||||
USB_LOG_ERR("Rx packet is overflow, please ruduce tcp window size or increase CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE\r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2198,9 +2223,13 @@ delete:
|
|||
// clang-format on
|
||||
}
|
||||
|
||||
int usbh_rtl8152_eth_output(uint8_t *buf, uint32_t buflen)
|
||||
uint8_t *usbh_rtl8152_get_eth_txbuf(void)
|
||||
{
|
||||
return (g_rtl8152_tx_buffer + sizeof(struct tx_desc));
|
||||
}
|
||||
|
||||
int usbh_rtl8152_eth_output(uint32_t buflen)
|
||||
{
|
||||
uint8_t *buffer;
|
||||
struct tx_desc *tx_desc;
|
||||
|
||||
if (g_rtl8152_class.connect_status == false) {
|
||||
|
@ -2211,9 +2240,6 @@ int usbh_rtl8152_eth_output(uint8_t *buf, uint32_t buflen)
|
|||
tx_desc->opts1 = buflen | TX_FS | TX_LS;
|
||||
tx_desc->opts2 = 0;
|
||||
|
||||
buffer = g_rtl8152_tx_buffer + sizeof(struct tx_desc);
|
||||
memcpy(buffer, buf, buflen);
|
||||
|
||||
USB_LOG_DBG("txlen:%d\r\n", buflen + sizeof(struct tx_desc));
|
||||
|
||||
usbh_bulk_urb_fill(&g_rtl8152_class.bulkout_urb, g_rtl8152_class.hport, g_rtl8152_class.bulkout, g_rtl8152_tx_buffer, buflen + sizeof(struct tx_desc), USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
|
|
|
@ -56,7 +56,8 @@ int usbh_rtl8152_get_connect_status(struct usbh_rtl8152 *rtl8152_class);
|
|||
void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class);
|
||||
void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class);
|
||||
|
||||
int usbh_rtl8152_eth_output(uint8_t *buf, uint32_t buflen);
|
||||
uint8_t *usbh_rtl8152_get_eth_txbuf(void);
|
||||
int usbh_rtl8152_eth_output(uint32_t buflen);
|
||||
void usbh_rtl8152_eth_input(uint8_t *buf, uint32_t buflen);
|
||||
void usbh_rtl8152_rx_thread(void *argument);
|
||||
|
||||
|
|
|
@ -90,9 +90,14 @@ static int usbh_ch34x_get_baudrate_div(uint32_t baudrate, uint8_t *factor, uint8
|
|||
|
||||
static int usbh_ch34x_get_version(struct usbh_ch34x *ch34x_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = ch34x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!ch34x_class || !ch34x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ch34x_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = CH34X_READ_VERSION;
|
||||
setup->wValue = 0;
|
||||
|
@ -110,7 +115,12 @@ static int usbh_ch34x_get_version(struct usbh_ch34x *ch34x_class)
|
|||
|
||||
static int usbh_ch34x_flow_ctrl(struct usbh_ch34x *ch34x_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = ch34x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!ch34x_class || !ch34x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ch34x_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = CH34X_WRITE_REG;
|
||||
|
@ -123,12 +133,17 @@ static int usbh_ch34x_flow_ctrl(struct usbh_ch34x *ch34x_class)
|
|||
|
||||
int usbh_ch34x_set_line_coding(struct usbh_ch34x *ch34x_class, struct cdc_line_coding *line_coding)
|
||||
{
|
||||
struct usb_setup_packet *setup = ch34x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
uint16_t reg_value = 0;
|
||||
uint16_t value = 0;
|
||||
uint8_t factor = 0;
|
||||
uint8_t divisor = 0;
|
||||
|
||||
if (!ch34x_class || !ch34x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ch34x_class->hport->setup;
|
||||
|
||||
memcpy((uint8_t *)&ch34x_class->line_coding, line_coding, sizeof(struct cdc_line_coding));
|
||||
|
||||
/* refer to https://github.com/WCHSoftGroup/ch341ser_linux/blob/main/driver/ch341.c */
|
||||
|
@ -197,7 +212,12 @@ int usbh_ch34x_get_line_coding(struct usbh_ch34x *ch34x_class, struct cdc_line_c
|
|||
|
||||
int usbh_ch34x_set_line_state(struct usbh_ch34x *ch34x_class, bool dtr, bool rts)
|
||||
{
|
||||
struct usb_setup_packet *setup = ch34x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!ch34x_class || !ch34x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ch34x_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = CH34X_MODEM_CTRL;
|
||||
|
|
|
@ -42,7 +42,12 @@ static void usbh_cp210x_class_free(struct usbh_cp210x *cp210x_class)
|
|||
|
||||
static int usbh_cp210x_enable(struct usbh_cp210x *cp210x_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = cp210x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!cp210x_class || !cp210x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cp210x_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CP210X_IFC_ENABLE;
|
||||
|
@ -55,7 +60,12 @@ static int usbh_cp210x_enable(struct usbh_cp210x *cp210x_class)
|
|||
|
||||
static int usbh_cp210x_set_flow(struct usbh_cp210x *cp210x_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = cp210x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!cp210x_class || !cp210x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cp210x_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CP210X_SET_FLOW;
|
||||
|
@ -70,7 +80,12 @@ static int usbh_cp210x_set_flow(struct usbh_cp210x *cp210x_class)
|
|||
|
||||
static int usbh_cp210x_set_chars(struct usbh_cp210x *cp210x_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = cp210x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!cp210x_class || !cp210x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cp210x_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CP210X_SET_CHARS;
|
||||
|
@ -87,7 +102,12 @@ static int usbh_cp210x_set_chars(struct usbh_cp210x *cp210x_class)
|
|||
|
||||
static int usbh_cp210x_set_baudrate(struct usbh_cp210x *cp210x_class, uint32_t baudrate)
|
||||
{
|
||||
struct usb_setup_packet *setup = cp210x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!cp210x_class || !cp210x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cp210x_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CP210X_SET_BAUDRATE;
|
||||
|
@ -101,9 +121,14 @@ static int usbh_cp210x_set_baudrate(struct usbh_cp210x *cp210x_class, uint32_t b
|
|||
|
||||
static int usbh_cp210x_set_data_format(struct usbh_cp210x *cp210x_class, uint8_t databits, uint8_t parity, uint8_t stopbits)
|
||||
{
|
||||
struct usb_setup_packet *setup = cp210x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
uint16_t value;
|
||||
|
||||
if (!cp210x_class || !cp210x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cp210x_class->hport->setup;
|
||||
|
||||
value = ((databits & 0x0F) << 8) | ((parity & 0x0f) << 4) | ((stopbits & 0x03) << 0);
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
|
@ -117,9 +142,14 @@ static int usbh_cp210x_set_data_format(struct usbh_cp210x *cp210x_class, uint8_t
|
|||
|
||||
static int usbh_cp210x_set_mhs(struct usbh_cp210x *cp210x_class, uint8_t dtr, uint8_t rts, uint8_t dtr_mask, uint8_t rts_mask)
|
||||
{
|
||||
struct usb_setup_packet *setup = cp210x_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
uint16_t value;
|
||||
|
||||
if (!cp210x_class || !cp210x_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = cp210x_class->hport->setup;
|
||||
|
||||
value = ((dtr & 0x01) << 0) | ((rts & 0x01) << 1) | ((dtr_mask & 0x01) << 8) | ((rts_mask & 0x01) << 9);
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
|
|
|
@ -71,7 +71,12 @@ static void usbh_ftdi_caculate_baudrate(uint32_t *itdf_divisor, uint32_t actual_
|
|||
|
||||
int usbh_ftdi_reset(struct usbh_ftdi *ftdi_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = ftdi_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!ftdi_class || !ftdi_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ftdi_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = SIO_RESET_REQUEST;
|
||||
|
@ -84,7 +89,12 @@ int usbh_ftdi_reset(struct usbh_ftdi *ftdi_class)
|
|||
|
||||
static int usbh_ftdi_set_modem(struct usbh_ftdi *ftdi_class, uint16_t value)
|
||||
{
|
||||
struct usb_setup_packet *setup = ftdi_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!ftdi_class || !ftdi_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ftdi_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = SIO_SET_MODEM_CTRL_REQUEST;
|
||||
|
@ -97,11 +107,16 @@ static int usbh_ftdi_set_modem(struct usbh_ftdi *ftdi_class, uint16_t value)
|
|||
|
||||
static int usbh_ftdi_set_baudrate(struct usbh_ftdi *ftdi_class, uint32_t baudrate)
|
||||
{
|
||||
struct usb_setup_packet *setup = ftdi_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
uint32_t itdf_divisor;
|
||||
uint16_t value;
|
||||
uint8_t baudrate_high;
|
||||
|
||||
if (!ftdi_class || !ftdi_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ftdi_class->hport->setup;
|
||||
|
||||
usbh_ftdi_caculate_baudrate(&itdf_divisor, baudrate);
|
||||
value = itdf_divisor & 0xFFFF;
|
||||
baudrate_high = (itdf_divisor >> 16) & 0xff;
|
||||
|
@ -123,10 +138,15 @@ static int usbh_ftdi_set_data_format(struct usbh_ftdi *ftdi_class, uint8_t datab
|
|||
* D11-D12 STOP_BIT_1=0, STOP_BIT_15=1, STOP_BIT_2=2
|
||||
* D14 BREAK_OFF=0, BREAK_ON=1
|
||||
**/
|
||||
struct usb_setup_packet *setup;
|
||||
uint16_t value;
|
||||
|
||||
uint16_t value = ((isbreak & 0x01) << 14) | ((stopbits & 0x03) << 11) | ((parity & 0x0f) << 8) | (databits & 0x0f);
|
||||
if (!ftdi_class || !ftdi_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ftdi_class->hport->setup;
|
||||
|
||||
struct usb_setup_packet *setup = ftdi_class->hport->setup;
|
||||
value = ((isbreak & 0x01) << 14) | ((stopbits & 0x03) << 11) | ((parity & 0x0f) << 8) | (databits & 0x0f);
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = SIO_SET_DATA_REQUEST;
|
||||
|
@ -139,7 +159,12 @@ static int usbh_ftdi_set_data_format(struct usbh_ftdi *ftdi_class, uint8_t datab
|
|||
|
||||
static int usbh_ftdi_set_latency_timer(struct usbh_ftdi *ftdi_class, uint16_t value)
|
||||
{
|
||||
struct usb_setup_packet *setup = ftdi_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!ftdi_class || !ftdi_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ftdi_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = SIO_SET_LATENCY_TIMER_REQUEST;
|
||||
|
@ -152,7 +177,12 @@ static int usbh_ftdi_set_latency_timer(struct usbh_ftdi *ftdi_class, uint16_t va
|
|||
|
||||
static int usbh_ftdi_set_flow_ctrl(struct usbh_ftdi *ftdi_class, uint16_t value)
|
||||
{
|
||||
struct usb_setup_packet *setup = ftdi_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!ftdi_class || !ftdi_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ftdi_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = SIO_SET_FLOW_CTRL_REQUEST;
|
||||
|
@ -165,9 +195,14 @@ static int usbh_ftdi_set_flow_ctrl(struct usbh_ftdi *ftdi_class, uint16_t value)
|
|||
|
||||
static int usbh_ftdi_read_modem_status(struct usbh_ftdi *ftdi_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = ftdi_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!ftdi_class || !ftdi_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = ftdi_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_VENDOR | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = SIO_POLL_MODEM_STATUS_REQUEST;
|
||||
setup->wValue = 0x0000;
|
||||
|
|
|
@ -131,7 +131,12 @@ static int usbh_pl2303_do(struct usbh_pl2303 *pl2303_class,
|
|||
uint8_t req_type, uint8_t request, uint16_t value, uint16_t index,
|
||||
uint16_t length)
|
||||
{
|
||||
struct usb_setup_packet *setup = pl2303_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!pl2303_class || !pl2303_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = pl2303_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = req_type;
|
||||
setup->bRequest = request;
|
||||
|
@ -144,7 +149,12 @@ static int usbh_pl2303_do(struct usbh_pl2303 *pl2303_class,
|
|||
|
||||
int usbh_pl2303_set_line_coding(struct usbh_pl2303 *pl2303_class, struct cdc_line_coding *line_coding)
|
||||
{
|
||||
struct usb_setup_packet *setup = pl2303_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!pl2303_class || !pl2303_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = pl2303_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_SET_LINE_CODING;
|
||||
|
@ -159,9 +169,14 @@ int usbh_pl2303_set_line_coding(struct usbh_pl2303 *pl2303_class, struct cdc_lin
|
|||
|
||||
int usbh_pl2303_get_line_coding(struct usbh_pl2303 *pl2303_class, struct cdc_line_coding *line_coding)
|
||||
{
|
||||
struct usb_setup_packet *setup = pl2303_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!pl2303_class || !pl2303_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = pl2303_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_GET_LINE_CODING;
|
||||
setup->wValue = 0;
|
||||
|
@ -178,7 +193,12 @@ int usbh_pl2303_get_line_coding(struct usbh_pl2303 *pl2303_class, struct cdc_lin
|
|||
|
||||
int usbh_pl2303_set_line_state(struct usbh_pl2303 *pl2303_class, bool dtr, bool rts)
|
||||
{
|
||||
struct usb_setup_packet *setup = pl2303_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!pl2303_class || !pl2303_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = pl2303_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = CDC_REQUEST_SET_CONTROL_LINE_STATE;
|
||||
|
|
|
@ -806,14 +806,15 @@ struct video_still_probe_and_commit_controls {
|
|||
struct video_cs_if_vc_header_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t bcdVDC;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint16_t bcdUVC;
|
||||
uint16_t wTotalLength;
|
||||
uint32_t dwClockFrequency;
|
||||
uint8_t bInCollection;
|
||||
uint8_t baInterfaceNr[];
|
||||
} __PACKED;
|
||||
|
||||
#define VIDEO_SIZEOF_VC_HEADER_DESC(n) (11 + n)
|
||||
#define VIDEO_SIZEOF_VC_HEADER_DESC(n) (12 + n)
|
||||
|
||||
struct video_cs_if_vc_input_terminal_descriptor {
|
||||
uint8_t bLength;
|
||||
|
@ -860,6 +861,22 @@ struct video_cs_if_vc_output_terminal_descriptor {
|
|||
|
||||
#define VIDEO_SIZEOF_VC_OUTPUT_TERMINAL_DESC 9
|
||||
|
||||
struct video_cs_if_vc_extension_unit_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bUnitID;
|
||||
uint8_t guidExtensionCode[16];
|
||||
uint8_t bNumControls;
|
||||
uint8_t bNrInPins;
|
||||
// uint8_t baSourceID[];
|
||||
uint8_t bControlSize;
|
||||
// uint8_t bmControls[]
|
||||
uint8_t iExtension;
|
||||
} __PACKED;
|
||||
|
||||
#define VIDEO_SIZEOF_VC_EXTENSION_UNIT_DESC(p, n) (24 + p + n)
|
||||
|
||||
struct video_cs_ep_vc_ep_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
|
@ -922,7 +939,7 @@ struct video_cs_if_vs_frame_uncompressed_descriptor {
|
|||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
|
@ -931,10 +948,10 @@ struct video_cs_if_vs_frame_uncompressed_descriptor {
|
|||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwFrameInterval;
|
||||
uint32_t dwFrameInterval[];
|
||||
} __PACKED;
|
||||
|
||||
#define VIDEO_SIZEOF_VS_FRAME_UNCOMPRESSED_DESC 30
|
||||
#define VIDEO_SIZEOF_VS_FRAME_UNCOMPRESSED_DESC(n) (26 + 4 * (n))
|
||||
|
||||
struct video_cs_if_vs_format_mjpeg_descriptor {
|
||||
uint8_t bLength;
|
||||
|
@ -956,7 +973,7 @@ struct video_cs_if_vs_frame_mjpeg_descriptor {
|
|||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
|
@ -965,11 +982,48 @@ struct video_cs_if_vs_frame_mjpeg_descriptor {
|
|||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwFrameInterval1;
|
||||
uint32_t dwFrameInterval2;
|
||||
uint32_t dwFrameInterval[];
|
||||
} __PACKED;
|
||||
|
||||
#define VIDEO_SIZEOF_VS_FRAME_MJPEG_DESC(n) (26 + n)
|
||||
#define VIDEO_SIZEOF_VS_FRAME_MJPEG_DESC(n) (26 + 4 * (n))
|
||||
|
||||
/* H264 Payload - 3.1.1. H264 Video Format Descriptor */
|
||||
struct video_cs_if_vs_format_h26x_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
uint8_t guidFormat[16];
|
||||
uint8_t bBitsPerPixel;
|
||||
uint8_t bDefaultFrameIndex;
|
||||
uint8_t bAspectRatioX;
|
||||
uint8_t bAspectRatioY;
|
||||
uint8_t bmInterfaceFlags;
|
||||
uint8_t bCopyProtect;
|
||||
uint8_t bVariableSize;
|
||||
} __PACKED;
|
||||
|
||||
#define VIDEO_SIZEOF_VS_FORMAT_H264_DESC 28
|
||||
|
||||
/* H264 Payload - 3.1.2. H264 Video Frame Descriptor */
|
||||
struct video_cs_if_vs_frame_h26x_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwBytesPerLine;
|
||||
uint32_t dwFrameInterval[];
|
||||
} __PACKED;
|
||||
|
||||
#define VIDEO_SIZEOF_VS_FRAME_H264_DESC(n) (26 + 4 * (n))
|
||||
|
||||
struct video_cs_if_vs_colorformat_descriptor {
|
||||
uint8_t bLength;
|
||||
|
@ -1041,11 +1095,19 @@ struct video_autoexposure_mode {
|
|||
|
||||
#define VIDEO_GUID_YUY2 0x59, 0x55, 0x59, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
#define VIDEO_GUID_NV12 0x4E, 0x56, 0x31, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
#define VIDEO_GUID_NV21 0x4E, 0x56, 0x32, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
#define VIDEO_GUID_M420 0x4D, 0x34, 0x32, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
#define VIDEO_GUID_I420 0x49, 0x34, 0x32, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
#define VIDEO_GUID_H264 0x48, 0x32, 0x36, 0x34, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
|
||||
#define VIDEO_VC_TERMINAL_LEN (13 + 18 + 12 + 9)
|
||||
|
||||
/*Length of template descriptor: 81 bytes*/
|
||||
#define VIDEO_VC_DESCRIPTOR_LEN (8 + 9 + VIDEO_VC_TERMINAL_LEN + 7 + 5)
|
||||
#define VIDEO_VC_NOEP_DESCRIPTOR_LEN (8 + 9 + VIDEO_VC_TERMINAL_LEN)
|
||||
|
||||
// clang-format off
|
||||
#define VIDEO_VC_DESCRIPTOR_INIT(bFirstInterface, bNumEndpoints, bcdUVC, wTotalLength, dwClockFrequency, stridx) \
|
||||
#define VIDEO_VC_DESCRIPTOR_INIT(bFirstInterface, bEndpointAddress, bcdUVC, wTotalLength, dwClockFrequency, stridx) \
|
||||
/* Interface Association Descriptor */ \
|
||||
0x08, \
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION, \
|
||||
|
@ -1054,18 +1116,16 @@ struct video_autoexposure_mode {
|
|||
USB_DEVICE_CLASS_VIDEO, \
|
||||
VIDEO_SC_VIDEO_INTERFACE_COLLECTION, \
|
||||
0x00, \
|
||||
0x00, \
|
||||
/* VideoControl Interface Descriptor */ \
|
||||
0x00, /* VideoControl Interface Descriptor */ \
|
||||
0x09, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
|
||||
0x00, /* bInterfaceNumber */ \
|
||||
0x00, /* bAlternateSetting */ \
|
||||
bNumEndpoints, /* bNumEndpoints:1 endpoint (interrupt endpoint) */ \
|
||||
0x01, /* bNumEndpoints:1 endpoint (interrupt endpoint) */ \
|
||||
USB_DEVICE_CLASS_VIDEO, /* bInterfaceClass : CC_VIDEO */ \
|
||||
VIDEO_SC_VIDEOCONTROL, /* bInterfaceSubClass : SC_VIDEOCONTROL */ \
|
||||
VIDEO_PC_PROTOCOL_UNDEFINED, /* bInterfaceProtocol : PC_PROTOCOL_UNDEFINED */ \
|
||||
stridx, /* iInterface:Index to string descriptor that contains the string <Your Product Name> */ \
|
||||
/*Class-specific VideoControl Interface Descriptor */ \
|
||||
stridx, /* iInterface:Index to string descriptor that contains the string <Your Product Name> */ /*Class-specific VideoControl Interface Descriptor */ \
|
||||
0x0d, /* bLength */ \
|
||||
0x24, /* bDescriptorType : CS_INTERFACE */ \
|
||||
VIDEO_VC_HEADER_DESCRIPTOR_SUBTYPE, /* bDescriptorSubType : VC_HEADER subtype */ \
|
||||
|
@ -1073,8 +1133,7 @@ struct video_autoexposure_mode {
|
|||
WBVAL(wTotalLength), /* wTotalLength */ \
|
||||
DBVAL(dwClockFrequency), /* dwClockFrequency : 0x005b8d80 -> 6,000,000 == 6MHz*/ \
|
||||
0x01, /* bInCollection : Number of streaming interfaces. */ \
|
||||
(uint8_t)(bFirstInterface + 1), /* baInterfaceNr(0) : VideoStreaming interface 1 belongs to this VideoControl interface.*/ \
|
||||
/* Input Terminal 1 -> Processing Unit 2 -> Output Terminal 3 */ \
|
||||
(uint8_t)(bFirstInterface + 1), /* baInterfaceNr(0) : VideoStreaming interface 1 belongs to this VideoControl interface.*/ /* Input Terminal 1 -> Processing Unit 2 -> Output Terminal 3 */ \
|
||||
0x12, \
|
||||
0x24, \
|
||||
VIDEO_VC_INPUT_TERMINAL_DESCRIPTOR_SUBTYPE, \
|
||||
|
@ -1104,7 +1163,73 @@ struct video_autoexposure_mode {
|
|||
WBVAL(VIDEO_TT_STREAMING), \
|
||||
0x00, /* bAssocTerminal */ \
|
||||
0x02, /* bSourceID */ \
|
||||
0x00 /* iTerminal */
|
||||
0x00, /* iTerminal */ \
|
||||
0x07, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
|
||||
bEndpointAddress, /* bEndpointAddress */ \
|
||||
0x03, /* bmAttributes */ \
|
||||
0x10, 0x00, /* wMaxPacketSize */ \
|
||||
0x08, /* bInterval */ \
|
||||
/* Class-specific VC Interrupt Endpoint Descriptor */ \
|
||||
0x05, 0x25, 0x03, 0x10, 0x00
|
||||
|
||||
#define VIDEO_VC_NOEP_DESCRIPTOR_INIT(bFirstInterface, bEndpointAddress, bcdUVC, wTotalLength, dwClockFrequency, stridx) \
|
||||
/* Interface Association Descriptor */ \
|
||||
0x08, \
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION, \
|
||||
bFirstInterface, \
|
||||
0x02, \
|
||||
USB_DEVICE_CLASS_VIDEO, \
|
||||
VIDEO_SC_VIDEO_INTERFACE_COLLECTION, \
|
||||
0x00, \
|
||||
0x00, /* VideoControl Interface Descriptor */ \
|
||||
0x09, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
|
||||
0x00, /* bInterfaceNumber */ \
|
||||
0x00, /* bAlternateSetting */ \
|
||||
0x00, /* bNumEndpoints:1 endpoint (interrupt endpoint) */ \
|
||||
USB_DEVICE_CLASS_VIDEO, /* bInterfaceClass : CC_VIDEO */ \
|
||||
VIDEO_SC_VIDEOCONTROL, /* bInterfaceSubClass : SC_VIDEOCONTROL */ \
|
||||
VIDEO_PC_PROTOCOL_UNDEFINED, /* bInterfaceProtocol : PC_PROTOCOL_UNDEFINED */ \
|
||||
stridx, /* iInterface:Index to string descriptor that contains the string <Your Product Name> */ /*Class-specific VideoControl Interface Descriptor */ \
|
||||
0x0d, /* bLength */ \
|
||||
0x24, /* bDescriptorType : CS_INTERFACE */ \
|
||||
VIDEO_VC_HEADER_DESCRIPTOR_SUBTYPE, /* bDescriptorSubType : VC_HEADER subtype */ \
|
||||
WBVAL(bcdUVC), /* bcdUVC : Revision of class specification that this device is based upon.*/ \
|
||||
WBVAL(wTotalLength), /* wTotalLength */ \
|
||||
DBVAL(dwClockFrequency), /* dwClockFrequency : 0x005b8d80 -> 6,000,000 == 6MHz*/ \
|
||||
0x01, /* bInCollection : Number of streaming interfaces. */ \
|
||||
(uint8_t)(bFirstInterface + 1), /* baInterfaceNr(0) : VideoStreaming interface 1 belongs to this VideoControl interface.*/ /* Input Terminal 1 -> Processing Unit 2 -> Output Terminal 3 */ \
|
||||
0x12, \
|
||||
0x24, \
|
||||
VIDEO_VC_INPUT_TERMINAL_DESCRIPTOR_SUBTYPE, \
|
||||
0x01, /* bTerminalID */ \
|
||||
WBVAL(VIDEO_ITT_CAMERA), /* wTerminalType : 0x0201 Camera Sensor*/ \
|
||||
0x00, /* bAssocTerminal */ \
|
||||
0x00, /* iTerminal */ \
|
||||
WBVAL(0x0000), /* wObjectiveFocalLengthMin */ \
|
||||
WBVAL(0x0000), /* wObjectiveFocalLengthMax */ \
|
||||
WBVAL(0x0000), /* wOcularFocalLength */ \
|
||||
0x03, /* bControlSize */ \
|
||||
0x00, 0x00, 0x00, /* bmControls */ \
|
||||
0x0c, \
|
||||
0x24, \
|
||||
VIDEO_VC_PROCESSING_UNIT_DESCRIPTOR_SUBTYPE, \
|
||||
0x02, /* bUnitID */ \
|
||||
0x01, /* bSourceID */ \
|
||||
0x00, 0x00, /* wMaxMultiplier */ \
|
||||
0x02, /* bControlSize */ \
|
||||
0x00, 0x00, /* bmControls */ \
|
||||
0x00, /* iProcessing */ \
|
||||
0x00, /* bmVideoStandards */ \
|
||||
0x09, \
|
||||
0x24, \
|
||||
VIDEO_VC_OUTPUT_TERMINAL_DESCRIPTOR_SUBTYPE, \
|
||||
0x03, /* bTerminalID */ \
|
||||
WBVAL(VIDEO_TT_STREAMING), \
|
||||
0x00, /* bAssocTerminal */ \
|
||||
0x02, /* bSourceID */ \
|
||||
0x00 /* iTerminal */ \
|
||||
|
||||
#define VIDEO_VS_DESCRIPTOR_INIT(bInterfaceNumber, bAlternateSetting, bNumEndpoints) \
|
||||
/* Video Streaming (VS) Interface Descriptor */ \
|
||||
|
@ -1118,7 +1243,7 @@ struct video_autoexposure_mode {
|
|||
0x00, /* bInterfaceProtocol : PC_PROTOCOL_UNDEFINED */ \
|
||||
0x00 /* iInterface : unused */
|
||||
|
||||
#define VIDEO_VS_HEADER_DESCRIPTOR_INIT(bNumFormats, wTotalLength, bEndpointAddress, ...) \
|
||||
#define VIDEO_VS_INPUT_HEADER_DESCRIPTOR_INIT(bNumFormats, wTotalLength, bEndpointAddress, ...) \
|
||||
/*Class-specific VideoStream Header Descriptor (Input) */ \
|
||||
0x0d + PP_NARG(__VA_ARGS__), \
|
||||
0x24, \
|
||||
|
@ -1131,6 +1256,22 @@ struct video_autoexposure_mode {
|
|||
0x00, /* bStillCaptureMethod : Device supports still image capture method 0. */ \
|
||||
0x00, /* bTriggerSupport : Hardware trigger supported for still image capture */ \
|
||||
0x00, /* bTriggerUsage : Hardware trigger should initiate a still image capture. */ \
|
||||
0x01, /* bControlSize : Size of the bmaControls field */ \
|
||||
__VA_ARGS__ /* bmaControls : No VideoStreaming specific controls are supported.*/
|
||||
|
||||
#define VIDEO_VS_OUTPUT_HEADER_DESCRIPTOR_INIT(bNumFormats, wTotalLength, bEndpointAddress, ...) \
|
||||
/*Class-specific VideoStream Header Descriptor (Input) */ \
|
||||
0x0d + PP_NARG(__VA_ARGS__), \
|
||||
0x24, \
|
||||
VIDEO_VS_OUTPUT_HEADER_DESCRIPTOR_SUBTYPE, \
|
||||
bNumFormats, /* bNumFormats : One format descriptor follows. */ \
|
||||
WBVAL(wTotalLength), \
|
||||
bEndpointAddress, \
|
||||
0x00, /* bmInfo : No dynamic format change supported. */ \
|
||||
0x03, /* bTerminalLink : This VideoStreaming interface supplies terminal ID 2 (Output Terminal). */ \
|
||||
0x00, /* bStillCaptureMethod : Device supports still image capture method 0. */ \
|
||||
0x00, /* bTriggerSupport : Hardware trigger supported for still image capture */ \
|
||||
0x00, /* bTriggerUsage : Hardware trigger should initiate a still image capture. */ \
|
||||
PP_NARG(__VA_ARGS__), /* bControlSize : Size of the bmaControls field */ \
|
||||
__VA_ARGS__ /* bmaControls : No VideoStreaming specific controls are supported.*/
|
||||
|
||||
|
@ -1142,7 +1283,7 @@ struct video_autoexposure_mode {
|
|||
bFormatIndex, /* bFormatIndex : First (and only) format descriptor */ \
|
||||
bNumFrameDescriptors, /* bNumFrameDescriptors : One frame descriptor for this format follows. */ \
|
||||
GUIDFormat, /* GUID Format YUY2 {32595559-0000-0010-8000-00AA00389B71} */ \
|
||||
0x0c, /* bBitsPerPixel : Number of bits per pixel used to specify color in the decoded video frame - 16 for yuy2*/ \
|
||||
0x10, /* bBitsPerPixel : Number of bits per pixel used to specify color in the decoded video frame - 16 for yuy2*/ \
|
||||
0x01, /* bDefaultFrameIndex : Default frame index is 1. */ \
|
||||
0x00, /* bAspectRatioX : Non-interlaced stream not required. */ \
|
||||
0x00, /* bAspectRatioY : Non-interlaced stream not required. */ \
|
||||
|
@ -1150,8 +1291,8 @@ struct video_autoexposure_mode {
|
|||
0x00 /* bCopyProtect : No restrictions imposed on the duplication of this video stream. */
|
||||
|
||||
#define VIDEO_VS_FRAME_UNCOMPRESSED_DESCRIPTOR_INIT(bFrameIndex, wWidth, wHeight, dwMinBitRate, dwMaxBitRate, \
|
||||
dwMaxVideoFrameBufferSize, dwDefaultFrameInterval, dwFrameInterval) \
|
||||
0x1e, \
|
||||
dwMaxVideoFrameBufferSize, dwDefaultFrameInterval, bFrameIntervalType, ...) \
|
||||
0x1a + PP_NARG(__VA_ARGS__), \
|
||||
0x24, \
|
||||
VIDEO_VS_FRAME_UNCOMPRESSED_DESCRIPTOR_SUBTYPE, \
|
||||
bFrameIndex, \
|
||||
|
@ -1161,9 +1302,9 @@ struct video_autoexposure_mode {
|
|||
DBVAL(dwMinBitRate), \
|
||||
DBVAL(dwMaxBitRate), \
|
||||
DBVAL(dwMaxVideoFrameBufferSize), \
|
||||
DBVAL(dwDefaultFrameInterval), \
|
||||
0x01, \
|
||||
DBVAL(dwFrameInterval)
|
||||
dwDefaultFrameInterval, /* dwDefaultFrameInterval : 1,000,000 * 100ns -> 10 FPS */ \
|
||||
bFrameIntervalType, /* bFrameIntervalType : Indicates how the frame interval can be programmed. 0: Continuous frame interval 1..255: The number of discrete frame */ \
|
||||
__VA_ARGS__
|
||||
|
||||
#define VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_INIT(bFormatIndex, bNumFrameDescriptors) \
|
||||
/*Payload Format(MJPEG) Descriptor */ \
|
||||
|
@ -1194,5 +1335,46 @@ struct video_autoexposure_mode {
|
|||
dwDefaultFrameInterval, /* dwDefaultFrameInterval : 1,000,000 * 100ns -> 10 FPS */ \
|
||||
bFrameIntervalType, /* bFrameIntervalType : Indicates how the frame interval can be programmed. 0: Continuous frame interval 1..255: The number of discrete frame */ \
|
||||
__VA_ARGS__
|
||||
|
||||
#define VIDEO_VS_FORMAT_H264_DESCRIPTOR_INIT(bFormatIndex, bNumFrameDescriptors) \
|
||||
/*Payload Format(H.264) Descriptor */ \
|
||||
0x1c, /* bLength */ \
|
||||
0x24, /* bDescriptorType : CS_INTERFACE */ \
|
||||
VIDEO_VS_FORMAT_FRAME_BASED_DESCRIPTOR_SUBTYPE, /* bDescriptorSubType : VS_FORMAT_FRAME_BASED subtype */\
|
||||
bFormatIndex, /* bFormatIndex : First (and only) format descriptor */ \
|
||||
bNumFrameDescriptors, /* bNumFrameDescriptors : One frame descriptor for this format follows. */ \
|
||||
VIDEO_GUID_H264, \
|
||||
0x00, /* bmFlags : Uses fixed size samples.. */ \
|
||||
0x01, /* bDefaultFrameIndex : Default frame index is 1. */ \
|
||||
0x00, /* bAspectRatioX : Non-interlaced stream – not required. */ \
|
||||
0x00, /* bAspectRatioY : Non-interlaced stream – not required. */ \
|
||||
0x00, /* bmInterlaceFlags : Non-interlaced stream */ \
|
||||
0x00, /* bCopyProtect : No restrictions imposed on the duplication of this video stream. */ \
|
||||
0x00 /* Variable size: False */
|
||||
|
||||
#define VIDEO_VS_FRAME_H264_DESCRIPTOR_INIT(bFrameIndex, wWidth, wHeight, dwMinBitRate, dwMaxBitRate, \
|
||||
dwDefaultFrameInterval, bFrameIntervalType, ...) \
|
||||
0x1a + PP_NARG(__VA_ARGS__), /* bLength */ \
|
||||
0x24, /* bDescriptorType : CS_INTERFACE */ \
|
||||
VIDEO_VS_FRAME_FRAME_BASED_DESCRIPTOR_SUBTYPE, /* bDescriptorSubType : VS_FRAME_BASED */ \
|
||||
bFrameIndex, /* bFrameIndex : First (and only) frame descriptor */ \
|
||||
0x00, /* bmCapabilities : Still images using capture method 0 are supported at this frame setting.D1: Fixed frame-rate. */ \
|
||||
WBVAL(wWidth), /* wWidth (2bytes): Width of frame is 128 pixels. */ \
|
||||
WBVAL(wHeight), /* wHeight (2bytes): Height of frame is 64 pixels. */ \
|
||||
DBVAL(dwMinBitRate), /* dwMinBitRate (4bytes): Min bit rate in bits/s */ \
|
||||
DBVAL(dwMaxBitRate), /* dwMaxBitRate (4bytes): Max bit rate in bits/s */ \
|
||||
dwDefaultFrameInterval, /* dwDefaultFrameInterval : 1,000,000 * 100ns -> 10 FPS */ \
|
||||
bFrameIntervalType, /* bFrameIntervalType : Indicates how the frame interval can be programmed. 0: Continuous frame interval 1..255: The number of discrete frame */ \
|
||||
DBVAL(0x00), /* dwBytesPerLine (4bytes) */ \
|
||||
__VA_ARGS__
|
||||
|
||||
#define VIDEO_VS_COLOR_MATCHING_DESCRIPTOR_INIT() \
|
||||
0x06, /* bLength */ \
|
||||
0x24, /* bDescriptorType : CS_INTERFACE */ \
|
||||
VIDEO_VS_COLORFORMAT_DESCRIPTOR_SUBTYPE, /* bDescriptorSubType : VS_COLORFORMAT */ \
|
||||
0x01, /* bColorPrimaries */ \
|
||||
0x01, /* bTransferCharacteristics */ \
|
||||
0x04 /* bMatrixCoefficients */
|
||||
|
||||
// clang-format on
|
||||
#endif /*USB_VIDEO_H */
|
|
@ -295,8 +295,7 @@ static int usbd_video_control_unit_terminal_request_handler(uint8_t busid, struc
|
|||
case VIDEO_PU_BRIGHTNESS_CONTROL:
|
||||
switch (setup->bRequest) {
|
||||
case VIDEO_REQUEST_SET_CUR: {
|
||||
uint16_t wBrightness = (uint16_t)(*data)[1] << 8 | (uint16_t)(*data)[0];
|
||||
USB_LOG_INFO("Video set brightness:%d\r\n", wBrightness);
|
||||
//uint16_t wBrightness = (uint16_t)(*data)[1] << 8 | (uint16_t)(*data)[0];
|
||||
} break;
|
||||
case VIDEO_REQUEST_GET_CUR: {
|
||||
uint16_t wBrightness = 0x0080;
|
||||
|
@ -762,7 +761,7 @@ struct usbd_interface *usbd_video_init_intf(uint8_t busid, struct usbd_interface
|
|||
return intf;
|
||||
}
|
||||
|
||||
uint32_t usbd_video_mjpeg_payload_fill(uint8_t busid, uint8_t *input, uint32_t input_len, uint8_t *output, uint32_t *out_len)
|
||||
uint32_t usbd_video_payload_fill(uint8_t busid, uint8_t *input, uint32_t input_len, uint8_t *output, uint32_t *out_len)
|
||||
{
|
||||
uint32_t packets;
|
||||
uint32_t last_packet_size;
|
||||
|
|
|
@ -20,7 +20,7 @@ struct usbd_interface *usbd_video_init_intf(uint8_t busid, struct usbd_interface
|
|||
|
||||
void usbd_video_open(uint8_t busid, uint8_t intf);
|
||||
void usbd_video_close(uint8_t busid, uint8_t intf);
|
||||
uint32_t usbd_video_mjpeg_payload_fill(uint8_t busid, uint8_t *input, uint32_t input_len, uint8_t *output, uint32_t *out_len);
|
||||
uint32_t usbd_video_payload_fill(uint8_t busid, uint8_t *input, uint32_t input_len, uint8_t *output, uint32_t *out_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -59,10 +59,15 @@ static void usbh_video_class_free(struct usbh_video *video_class)
|
|||
|
||||
int usbh_video_get(struct usbh_video *video_class, uint8_t request, uint8_t intf, uint8_t entity_id, uint8_t cs, uint8_t *buf, uint16_t len)
|
||||
{
|
||||
struct usb_setup_packet *setup = video_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
uint8_t retry;
|
||||
|
||||
if (!video_class || !video_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = video_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = request;
|
||||
setup->wValue = cs << 8;
|
||||
|
@ -91,9 +96,14 @@ int usbh_video_get(struct usbh_video *video_class, uint8_t request, uint8_t intf
|
|||
|
||||
int usbh_video_set(struct usbh_video *video_class, uint8_t request, uint8_t intf, uint8_t entity_id, uint8_t cs, uint8_t *buf, uint16_t len)
|
||||
{
|
||||
struct usb_setup_packet *setup = video_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret;
|
||||
|
||||
if (!video_class || !video_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = video_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||
setup->bRequest = request;
|
||||
setup->wValue = cs << 8;
|
||||
|
@ -136,7 +146,7 @@ int usbh_video_open(struct usbh_video *video_class,
|
|||
uint16_t wHeight,
|
||||
uint8_t altsetting)
|
||||
{
|
||||
struct usb_setup_packet *setup = video_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
struct usb_endpoint_descriptor *ep_desc;
|
||||
uint8_t mult;
|
||||
uint16_t mps;
|
||||
|
@ -146,6 +156,11 @@ int usbh_video_open(struct usbh_video *video_class,
|
|||
uint8_t frameidx = 0;
|
||||
uint8_t step;
|
||||
|
||||
if (!video_class || !video_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = video_class->hport->setup;
|
||||
|
||||
if (video_class->is_opened) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -265,9 +280,14 @@ errout:
|
|||
|
||||
int usbh_video_close(struct usbh_video *video_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = video_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret = 0;
|
||||
|
||||
if (!video_class || !video_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = video_class->hport->setup;
|
||||
|
||||
USB_LOG_INFO("Close video device\r\n");
|
||||
|
||||
video_class->is_opened = false;
|
||||
|
|
|
@ -217,7 +217,7 @@ static int rndis_query_cmd_handler(uint8_t *data, uint32_t len)
|
|||
case OID_GEN_MAXIMUM_FRAME_SIZE:
|
||||
case OID_GEN_TRANSMIT_BLOCK_SIZE:
|
||||
case OID_GEN_RECEIVE_BLOCK_SIZE:
|
||||
RNDIS_INQUIRY_PUT_LE32(0x05DC);
|
||||
RNDIS_INQUIRY_PUT_LE32(0x05DC); /* mtu 1500 */
|
||||
infomation_len = 4;
|
||||
break;
|
||||
case OID_GEN_VENDOR_ID:
|
||||
|
@ -255,7 +255,7 @@ static int rndis_query_cmd_handler(uint8_t *data, uint32_t len)
|
|||
infomation_len = 4;
|
||||
break;
|
||||
case OID_GEN_MAXIMUM_TOTAL_SIZE:
|
||||
RNDIS_INQUIRY_PUT_LE32(CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE + CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE);
|
||||
RNDIS_INQUIRY_PUT_LE32(0x0616); /* 1514 + 44 */
|
||||
infomation_len = 4;
|
||||
break;
|
||||
case OID_GEN_MEDIA_CONNECT_STATUS:
|
||||
|
@ -488,7 +488,7 @@ struct pbuf *usbd_rndis_eth_rx(void)
|
|||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memcpy(p->payload, (uint8_t *)g_rndis_rx_data_buffer, g_rndis_rx_data_length);
|
||||
usb_memcpy(p->payload, (uint8_t *)g_rndis_rx_data_buffer, g_rndis_rx_data_length);
|
||||
p->len = g_rndis_rx_data_length;
|
||||
|
||||
USB_LOG_DBG("rxlen:%d\r\n", g_rndis_rx_data_length);
|
||||
|
@ -518,7 +518,7 @@ int usbd_rndis_eth_tx(struct pbuf *p)
|
|||
|
||||
buffer = (uint8_t *)(g_rndis_tx_buffer + sizeof(rndis_data_packet_t));
|
||||
for (q = p; q != NULL; q = q->next) {
|
||||
memcpy(buffer, q->payload, q->len);
|
||||
usb_memcpy(buffer, q->payload, q->len);
|
||||
buffer += q->len;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ static int usbh_bluetooth_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||
}
|
||||
USB_LOG_INFO("Bluetooth select altsetting 0\r\n");
|
||||
#endif
|
||||
snprintf(hport->config.intf[intf].devname, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT);
|
||||
strncpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
USB_LOG_INFO("Register Bluetooth Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
usbh_bluetooth_run(bluetooth_class);
|
||||
return ret;
|
||||
|
@ -234,7 +234,12 @@ delete :
|
|||
static int usbh_bluetooth_hci_cmd(uint8_t *buffer, uint32_t buflen)
|
||||
{
|
||||
struct usbh_bluetooth *bluetooth_class = &g_bluetooth_class;
|
||||
struct usb_setup_packet *setup = bluetooth_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
|
||||
if (!bluetooth_class || !bluetooth_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = bluetooth_class->hport->setup;
|
||||
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
setup->bRequest = 0x00;
|
||||
|
|
|
@ -40,11 +40,16 @@ static int usbh_rndis_get_notification(struct usbh_rndis *rndis_class)
|
|||
|
||||
static int usbh_rndis_init_msg_transfer(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = rndis_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret = 0;
|
||||
rndis_initialize_msg_t *cmd;
|
||||
rndis_initialize_cmplt_t *resp;
|
||||
|
||||
if (!rndis_class || !rndis_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = rndis_class->hport->setup;
|
||||
|
||||
cmd = (rndis_initialize_msg_t *)g_rndis_buf;
|
||||
|
||||
cmd->MessageType = REMOTE_NDIS_INITIALIZE_MSG;
|
||||
|
@ -82,16 +87,26 @@ static int usbh_rndis_init_msg_transfer(struct usbh_rndis *rndis_class)
|
|||
return ret;
|
||||
}
|
||||
|
||||
rndis_class->max_transfer_pkts = resp->MaxPacketsPerTransfer;
|
||||
rndis_class->max_transfer_size = resp->MaxTransferSize;
|
||||
USB_LOG_INFO("MaxPacketsPerTransfer:%d\r\n", resp->MaxPacketsPerTransfer);
|
||||
USB_LOG_INFO("MaxTransferSize:%d\r\n", resp->MaxTransferSize);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int usbh_rndis_query_msg_transfer(struct usbh_rndis *rndis_class, uint32_t oid, uint32_t query_len, uint8_t *info, uint32_t *info_len)
|
||||
{
|
||||
struct usb_setup_packet *setup = rndis_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret = 0;
|
||||
rndis_query_msg_t *cmd;
|
||||
rndis_query_cmplt_t *resp;
|
||||
|
||||
if (!rndis_class || !rndis_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = rndis_class->hport->setup;
|
||||
|
||||
cmd = (rndis_query_msg_t *)g_rndis_buf;
|
||||
|
||||
cmd->MessageType = REMOTE_NDIS_QUERY_MSG;
|
||||
|
@ -138,11 +153,16 @@ int usbh_rndis_query_msg_transfer(struct usbh_rndis *rndis_class, uint32_t oid,
|
|||
|
||||
static int usbh_rndis_set_msg_transfer(struct usbh_rndis *rndis_class, uint32_t oid, uint8_t *info, uint32_t info_len)
|
||||
{
|
||||
struct usb_setup_packet *setup = rndis_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret = 0;
|
||||
rndis_set_msg_t *cmd;
|
||||
rndis_set_cmplt_t *resp;
|
||||
|
||||
if (!rndis_class || !rndis_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = rndis_class->hport->setup;
|
||||
|
||||
cmd = (rndis_set_msg_t *)g_rndis_buf;
|
||||
|
||||
cmd->MessageType = REMOTE_NDIS_SET_MSG;
|
||||
|
@ -205,11 +225,16 @@ int usbh_rndis_get_connect_status(struct usbh_rndis *rndis_class)
|
|||
|
||||
int usbh_rndis_keepalive(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
struct usb_setup_packet *setup = rndis_class->hport->setup;
|
||||
struct usb_setup_packet *setup;
|
||||
int ret = 0;
|
||||
rndis_keepalive_msg_t *cmd;
|
||||
rndis_keepalive_cmplt_t *resp;
|
||||
|
||||
if (!rndis_class || !rndis_class->hport) {
|
||||
return -USB_ERR_INVAL;
|
||||
}
|
||||
setup = rndis_class->hport->setup;
|
||||
|
||||
cmd = (rndis_keepalive_msg_t *)g_rndis_buf;
|
||||
|
||||
cmd->MessageType = REMOTE_NDIS_KEEPALIVE_MSG;
|
||||
|
@ -382,7 +407,7 @@ static int usbh_rndis_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||
rndis_class->mac[4],
|
||||
rndis_class->mac[5]);
|
||||
|
||||
memcpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
strncpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
||||
|
||||
USB_LOG_INFO("Register RNDIS Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
usbh_rndis_run(rndis_class);
|
||||
|
@ -429,6 +454,11 @@ void usbh_rndis_rx_thread(void *argument)
|
|||
uint32_t pmg_offset;
|
||||
rndis_data_packet_t *pmsg;
|
||||
rndis_data_packet_t temp;
|
||||
#if CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
uint32_t transfer_size = CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE;
|
||||
#else
|
||||
uint32_t transfer_size = (16 * 1024);
|
||||
#endif
|
||||
|
||||
USB_LOG_INFO("Create rndis rx thread\r\n");
|
||||
// clang-format off
|
||||
|
@ -445,17 +475,23 @@ find_class:
|
|||
usb_osal_msleep(100);
|
||||
goto find_class;
|
||||
}
|
||||
usb_osal_msleep(128);
|
||||
}
|
||||
|
||||
g_rndis_rx_length = 0;
|
||||
while (1) {
|
||||
usbh_bulk_urb_fill(&g_rndis_class.bulkin_urb, g_rndis_class.hport, g_rndis_class.bulkin, g_rndis_rx_buffer, (CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE > (16 * 1024)) ? (16 * 1024) : CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
usbh_bulk_urb_fill(&g_rndis_class.bulkin_urb, g_rndis_class.hport, g_rndis_class.bulkin, &g_rndis_rx_buffer[g_rndis_rx_length], transfer_size, USB_OSAL_WAITING_FOREVER, NULL, NULL);
|
||||
ret = usbh_submit_urb(&g_rndis_class.bulkin_urb);
|
||||
if (ret < 0) {
|
||||
goto find_class;
|
||||
}
|
||||
|
||||
g_rndis_rx_length += g_rndis_class.bulkin_urb.actual_length;
|
||||
|
||||
/* A transfer is complete because last packet is a short packet.
|
||||
* Short packet is not zero, match g_rndis_rx_length % USB_GET_MAXPACKETSIZE(g_rndis_class.bulkin->wMaxPacketSize).
|
||||
* Short packet cannot be zero.
|
||||
*/
|
||||
if (g_rndis_rx_length % USB_GET_MAXPACKETSIZE(g_rndis_class.bulkin->wMaxPacketSize)) {
|
||||
pmg_offset = 0;
|
||||
|
||||
|
@ -468,7 +504,7 @@ find_class:
|
|||
|
||||
/* Not word-aligned case */
|
||||
if (pmg_offset & 0x3) {
|
||||
memcpy(&temp, pmsg, sizeof(rndis_data_packet_t));
|
||||
usb_memcpy(&temp, pmsg, sizeof(rndis_data_packet_t));
|
||||
pmsg = &temp;
|
||||
}
|
||||
|
||||
|
@ -490,9 +526,14 @@ find_class:
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (g_rndis_rx_length > CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE) {
|
||||
USB_LOG_ERR("Rx packet is overflow\r\n");
|
||||
g_rndis_rx_length = 0;
|
||||
#if CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE <= (16 * 1024)
|
||||
if (g_rndis_rx_length == CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE) {
|
||||
#else
|
||||
if ((g_rndis_rx_length + (16 * 1024)) > CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE) {
|
||||
#endif
|
||||
USB_LOG_ERR("Rx packet is overflow, please ruduce tcp window size or increase CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE\r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -504,9 +545,13 @@ delete:
|
|||
// clang-format on
|
||||
}
|
||||
|
||||
int usbh_rndis_eth_output(uint8_t *buf, uint32_t buflen)
|
||||
uint8_t *usbh_rndis_get_eth_txbuf(void)
|
||||
{
|
||||
return (g_rndis_tx_buffer + sizeof(rndis_data_packet_t));
|
||||
}
|
||||
|
||||
int usbh_rndis_eth_output(uint32_t buflen)
|
||||
{
|
||||
uint8_t *buffer;
|
||||
rndis_data_packet_t *hdr;
|
||||
uint32_t len;
|
||||
|
||||
|
@ -522,12 +567,9 @@ int usbh_rndis_eth_output(uint8_t *buf, uint32_t buflen)
|
|||
hdr->DataOffset = sizeof(rndis_data_packet_t) - sizeof(rndis_generic_msg_t);
|
||||
hdr->DataLength = buflen;
|
||||
|
||||
buffer = (uint8_t *)(g_rndis_tx_buffer + sizeof(rndis_data_packet_t));
|
||||
memcpy(buffer, buf, buflen);
|
||||
|
||||
len = hdr->MessageLength;
|
||||
/* if message length is the multiple of wMaxPacketSize, we should add a short packet to tell device transfer is over. */
|
||||
if (!(hdr->MessageLength % g_rndis_class.bulkout->wMaxPacketSize)) {
|
||||
if (!(len % g_rndis_class.bulkout->wMaxPacketSize)) {
|
||||
len += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ struct usbh_rndis {
|
|||
uint8_t minor;
|
||||
|
||||
uint32_t request_id;
|
||||
uint32_t tx_offset;
|
||||
uint32_t max_transfer_pkts; /* max packets in one transfer */
|
||||
uint32_t max_transfer_size; /* max size in one transfer */
|
||||
|
||||
uint32_t link_speed;
|
||||
bool connect_status;
|
||||
|
@ -40,7 +43,8 @@ int usbh_rndis_keepalive(struct usbh_rndis *rndis_class);
|
|||
void usbh_rndis_run(struct usbh_rndis *rndis_class);
|
||||
void usbh_rndis_stop(struct usbh_rndis *rndis_class);
|
||||
|
||||
int usbh_rndis_eth_output(uint8_t *buf, uint32_t buflen);
|
||||
uint8_t *usbh_rndis_get_eth_txbuf(void);
|
||||
int usbh_rndis_eth_output(uint32_t buflen);
|
||||
void usbh_rndis_eth_input(uint8_t *buf, uint32_t buflen);
|
||||
void usbh_rndis_rx_thread(void *argument);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ struct usbh_iso_frame_packet {
|
|||
* Structure containing the USB Urb configuration.
|
||||
*/
|
||||
struct usbh_urb {
|
||||
usb_slist_t list;
|
||||
void *hcpriv;
|
||||
struct usbh_hubport *hport;
|
||||
struct usb_endpoint_descriptor *ep;
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef USB_MEMCPY_H
|
||||
#define USB_MEMCPY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define ALIGN_UP_DWORD(x) ((uint32_t)(uintptr_t)(x) & (sizeof(uint32_t) - 1))
|
||||
|
||||
static inline void dword2array(char *addr, uint32_t w)
|
||||
{
|
||||
addr[0] = w;
|
||||
addr[1] = w >> 8;
|
||||
addr[2] = w >> 16;
|
||||
addr[3] = w >> 24;
|
||||
}
|
||||
|
||||
static inline void *usb_memcpy(void *s1, const void *s2, size_t n)
|
||||
{
|
||||
char *b1 = (char *)s1;
|
||||
const char *b2 = (const char *)s2;
|
||||
uint32_t *w1;
|
||||
const uint32_t *w2;
|
||||
|
||||
if (ALIGN_UP_DWORD(b1) == ALIGN_UP_DWORD(b2)) {
|
||||
while (ALIGN_UP_DWORD(b1) != 0 && n > 0) {
|
||||
*b1++ = *b2++;
|
||||
--n;
|
||||
}
|
||||
|
||||
w1 = (uint32_t *)b1;
|
||||
w2 = (const uint32_t *)b2;
|
||||
|
||||
while (n >= 4 * sizeof(uint32_t)) {
|
||||
*w1++ = *w2++;
|
||||
*w1++ = *w2++;
|
||||
*w1++ = *w2++;
|
||||
*w1++ = *w2++;
|
||||
n -= 4 * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
while (n >= sizeof(uint32_t)) {
|
||||
*w1++ = *w2++;
|
||||
n -= sizeof(uint32_t);
|
||||
}
|
||||
|
||||
b1 = (char *)w1;
|
||||
b2 = (const char *)w2;
|
||||
|
||||
while (n--) {
|
||||
*b1++ = *b2++;
|
||||
}
|
||||
} else {
|
||||
while (n > 0 && ALIGN_UP_DWORD(b2) != 0) {
|
||||
*b1++ = *b2++;
|
||||
--n;
|
||||
}
|
||||
|
||||
w2 = (const uint32_t *)b2;
|
||||
|
||||
while (n >= 4 * sizeof(uint32_t)) {
|
||||
dword2array(b1, *w2++);
|
||||
b1 += sizeof(uint32_t);
|
||||
dword2array(b1, *w2++);
|
||||
b1 += sizeof(uint32_t);
|
||||
dword2array(b1, *w2++);
|
||||
b1 += sizeof(uint32_t);
|
||||
dword2array(b1, *w2++);
|
||||
b1 += sizeof(uint32_t);
|
||||
n -= 4 * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
while (n >= sizeof(uint32_t)) {
|
||||
dword2array(b1, *w2++);
|
||||
b1 += sizeof(uint32_t);
|
||||
n -= sizeof(uint32_t);
|
||||
}
|
||||
|
||||
b2 = (const char *)w2;
|
||||
|
||||
while (n--) {
|
||||
*b1++ = *b2++;
|
||||
}
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
#endif
|
|
@ -57,7 +57,7 @@ USB_NOCACHE_RAM_SECTION struct usbd_core_priv {
|
|||
#ifdef CONFIG_USBDEV_TEST_MODE
|
||||
bool test_req;
|
||||
#endif
|
||||
struct usbd_interface *intf[8];
|
||||
struct usbd_interface *intf[16];
|
||||
uint8_t intf_offset;
|
||||
|
||||
struct usbd_tx_rx_msg tx_msg[CONFIG_USBDEV_EP_NUM];
|
||||
|
@ -98,7 +98,7 @@ static bool is_device_configured(uint8_t busid)
|
|||
*/
|
||||
static bool usbd_set_endpoint(uint8_t busid, const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
USB_LOG_INFO("Open ep:0x%02x type:%u mps:%u\r\n",
|
||||
USB_LOG_DBG("Open ep:0x%02x type:%u mps:%u\r\n",
|
||||
ep->bEndpointAddress,
|
||||
USB_GET_ENDPOINT_TYPE(ep->bmAttributes),
|
||||
USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize));
|
||||
|
@ -125,7 +125,7 @@ static bool usbd_set_endpoint(uint8_t busid, const struct usb_endpoint_descripto
|
|||
*/
|
||||
static bool usbd_reset_endpoint(uint8_t busid, const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
USB_LOG_INFO("Close ep:0x%02x type:%u\r\n",
|
||||
USB_LOG_DBG("Close ep:0x%02x type:%u\r\n",
|
||||
ep->bEndpointAddress,
|
||||
USB_GET_ENDPOINT_TYPE(ep->bmAttributes));
|
||||
|
||||
|
@ -177,8 +177,6 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
|
|||
break;
|
||||
case USB_DESCRIPTOR_TYPE_STRING:
|
||||
if (index == USB_OSDESC_STRING_DESC_INDEX) {
|
||||
USB_LOG_INFO("read MS OS 2.0 descriptor string\r\n");
|
||||
|
||||
if (!g_usbd_core[busid].descriptors->msosv1_descriptor) {
|
||||
found = false;
|
||||
break;
|
||||
|
@ -244,8 +242,6 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
|
|||
break;
|
||||
|
||||
case USB_DESCRIPTOR_TYPE_BINARY_OBJECT_STORE:
|
||||
USB_LOG_INFO("read BOS descriptor string\r\n");
|
||||
|
||||
if (!g_usbd_core[busid].descriptors->bos_descriptor) {
|
||||
found = false;
|
||||
break;
|
||||
|
@ -283,8 +279,6 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
|
|||
index = LO_BYTE(type_index);
|
||||
|
||||
if ((type == USB_DESCRIPTOR_TYPE_STRING) && (index == USB_OSDESC_STRING_DESC_INDEX)) {
|
||||
USB_LOG_INFO("read MS OS 2.0 descriptor string\r\n");
|
||||
|
||||
if (!g_usbd_core[busid].msosv1_desc) {
|
||||
return false;
|
||||
}
|
||||
|
@ -295,8 +289,6 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da
|
|||
|
||||
return true;
|
||||
} else if (type == USB_DESCRIPTOR_TYPE_BINARY_OBJECT_STORE) {
|
||||
USB_LOG_INFO("read BOS descriptor string\r\n");
|
||||
|
||||
if (!g_usbd_core[busid].bos_desc) {
|
||||
return false;
|
||||
}
|
||||
|
@ -623,8 +615,6 @@ static bool usbd_std_interface_req_handler(uint8_t busid, struct usb_setup_packe
|
|||
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
if (type == 0x22) { /* HID_DESCRIPTOR_TYPE_HID_REPORT */
|
||||
USB_LOG_INFO("read hid report descriptor\r\n");
|
||||
|
||||
for (uint8_t i = 0; i < g_usbd_core[busid].intf_offset; i++) {
|
||||
struct usbd_interface *intf = g_usbd_core[busid].intf[i];
|
||||
|
||||
|
@ -813,7 +803,6 @@ static int usbd_vendor_request_handler(uint8_t busid, struct usb_setup_packet *s
|
|||
if (setup->bRequest == g_usbd_core[busid].descriptors->msosv1_descriptor->vendor_code) {
|
||||
switch (setup->wIndex) {
|
||||
case 0x04:
|
||||
USB_LOG_INFO("get Compat ID\r\n");
|
||||
desclen = g_usbd_core[busid].descriptors->msosv1_descriptor->compat_id[0] +
|
||||
(g_usbd_core[busid].descriptors->msosv1_descriptor->compat_id[1] << 8) +
|
||||
(g_usbd_core[busid].descriptors->msosv1_descriptor->compat_id[2] << 16) +
|
||||
|
@ -824,7 +813,6 @@ static int usbd_vendor_request_handler(uint8_t busid, struct usb_setup_packet *s
|
|||
*len = desclen;
|
||||
return 0;
|
||||
case 0x05:
|
||||
USB_LOG_INFO("get Compat id properties\r\n");
|
||||
desclen = g_usbd_core[busid].descriptors->msosv1_descriptor->comp_id_property[setup->wValue][0] +
|
||||
(g_usbd_core[busid].descriptors->msosv1_descriptor->comp_id_property[setup->wValue][1] << 8) +
|
||||
(g_usbd_core[busid].descriptors->msosv1_descriptor->comp_id_property[setup->wValue][2] << 16) +
|
||||
|
@ -843,8 +831,6 @@ static int usbd_vendor_request_handler(uint8_t busid, struct usb_setup_packet *s
|
|||
if (setup->bRequest == g_usbd_core[busid].descriptors->msosv2_descriptor->vendor_code) {
|
||||
switch (setup->wIndex) {
|
||||
case WINUSB_REQUEST_GET_DESCRIPTOR_SET:
|
||||
USB_LOG_INFO("GET MS OS 2.0 Descriptor\r\n");
|
||||
|
||||
desclen = g_usbd_core[busid].descriptors->msosv2_descriptor->compat_id_len;
|
||||
*data = (uint8_t *)g_usbd_core[busid].descriptors->msosv2_descriptor->compat_id;
|
||||
//memcpy(*data, g_usbd_core[busid].descriptors->msosv2_descriptor->compat_id, desclen);
|
||||
|
@ -859,8 +845,6 @@ static int usbd_vendor_request_handler(uint8_t busid, struct usb_setup_packet *s
|
|||
if (setup->bRequest == g_usbd_core[busid].descriptors->webusb_url_descriptor->vendor_code) {
|
||||
switch (setup->wIndex) {
|
||||
case WINUSB_REQUEST_GET_DESCRIPTOR_SET:
|
||||
USB_LOG_INFO("GET Webusb url Descriptor\r\n");
|
||||
|
||||
desclen = g_usbd_core[busid].descriptors->webusb_url_descriptor->string_len;
|
||||
*data = (uint8_t *)g_usbd_core[busid].descriptors->webusb_url_descriptor->string;
|
||||
//memcpy(*data, g_usbd_core[busid].descriptors->webusb_url_descriptor->string, desclen);
|
||||
|
@ -877,7 +861,6 @@ static int usbd_vendor_request_handler(uint8_t busid, struct usb_setup_packet *s
|
|||
if (setup->bRequest == g_usbd_core[busid].msosv1_desc->vendor_code) {
|
||||
switch (setup->wIndex) {
|
||||
case 0x04:
|
||||
USB_LOG_INFO("get Compat ID\r\n");
|
||||
*data = (uint8_t *)g_usbd_core[busid].msosv1_desc->compat_id;
|
||||
desclen = g_usbd_core[busid].msosv1_desc->compat_id[0] +
|
||||
(g_usbd_core[busid].msosv1_desc->compat_id[1] << 8) +
|
||||
|
@ -887,7 +870,6 @@ static int usbd_vendor_request_handler(uint8_t busid, struct usb_setup_packet *s
|
|||
*len = desclen;
|
||||
return 0;
|
||||
case 0x05:
|
||||
USB_LOG_INFO("get Compat id properties\r\n");
|
||||
*data = (uint8_t *)g_usbd_core[busid].msosv1_desc->comp_id_property[setup->wValue];
|
||||
desclen = g_usbd_core[busid].msosv1_desc->comp_id_property[setup->wValue][0] +
|
||||
(g_usbd_core[busid].msosv1_desc->comp_id_property[setup->wValue][1] << 8) +
|
||||
|
@ -905,7 +887,6 @@ static int usbd_vendor_request_handler(uint8_t busid, struct usb_setup_packet *s
|
|||
if (setup->bRequest == g_usbd_core[busid].msosv2_desc->vendor_code) {
|
||||
switch (setup->wIndex) {
|
||||
case WINUSB_REQUEST_GET_DESCRIPTOR_SET:
|
||||
USB_LOG_INFO("GET MS OS 2.0 Descriptor\r\n");
|
||||
*data = (uint8_t *)g_usbd_core[busid].msosv2_desc->compat_id;
|
||||
//memcpy(*data, g_usbd_core[busid].msosv2_desc->compat_id, g_usbd_core[busid].msosv2_desc->compat_id_len);
|
||||
*len = g_usbd_core[busid].msosv2_desc->compat_id_len;
|
||||
|
|
|
@ -22,6 +22,7 @@ extern "C" {
|
|||
#include "usb_list.h"
|
||||
#include "usb_log.h"
|
||||
#include "usb_dc.h"
|
||||
#include "usb_memcpy.h"
|
||||
|
||||
enum usbd_event_type {
|
||||
/* USB DCD IRQ */
|
||||
|
|
|
@ -81,13 +81,9 @@ static int __usbh_free_devaddr(struct usbh_devaddr_map *devgen, uint8_t devaddr)
|
|||
|
||||
static int usbh_free_devaddr(struct usbh_hubport *hport)
|
||||
{
|
||||
#ifndef CONFIG_USBHOST_XHCI
|
||||
if (hport->dev_addr > 0) {
|
||||
__usbh_free_devaddr(&hport->bus->devgen, hport->dev_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
hport->dev_addr = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -398,23 +394,12 @@ int usbh_enumerate(struct usbh_hubport *hport)
|
|||
/* Reconfigure EP0 with the correct maximum packet size */
|
||||
ep->wMaxPacketSize = ep_mps;
|
||||
|
||||
#ifdef CONFIG_USBHOST_XHCI
|
||||
extern int usbh_get_xhci_devaddr(usbh_pipe_t * pipe);
|
||||
|
||||
/* Assign a function address to the device connected to this port */
|
||||
dev_addr = usbh_get_xhci_devaddr(hport->ep0);
|
||||
if (dev_addr < 0) {
|
||||
USB_LOG_ERR("Failed to allocate devaddr,errorcode:%d\r\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
#else
|
||||
/* Assign a function address to the device connected to this port */
|
||||
dev_addr = usbh_allocate_devaddr(&hport->bus->devgen);
|
||||
if (dev_addr < 0) {
|
||||
USB_LOG_ERR("Failed to allocate devaddr,errorcode:%d\r\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set the USB device address */
|
||||
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_DEVICE;
|
||||
|
@ -617,8 +602,6 @@ void usbh_hubport_release(struct usbh_hubport *hport)
|
|||
|
||||
static void usbh_bus_init(struct usbh_bus *bus, uint8_t busid, uint32_t reg_base)
|
||||
{
|
||||
struct usbh_hub *hub;
|
||||
|
||||
memset(bus, 0, sizeof(struct usbh_bus));
|
||||
bus->busid = busid;
|
||||
bus->hcd.hcd_id = busid;
|
||||
|
@ -627,20 +610,6 @@ static void usbh_bus_init(struct usbh_bus *bus, uint8_t busid, uint32_t reg_base
|
|||
/* devaddr 1 is for roothub */
|
||||
bus->devgen.next = 2;
|
||||
|
||||
usb_slist_init(&bus->hub_list);
|
||||
|
||||
hub = &bus->hcd.roothub;
|
||||
hub->connected = true;
|
||||
hub->index = 1;
|
||||
hub->is_roothub = true;
|
||||
hub->parent = NULL;
|
||||
hub->hub_addr = 1;
|
||||
hub->hub_desc.bNbrPorts = CONFIG_USBHOST_MAX_RHPORTS;
|
||||
hub->int_buffer = bus->hcd.roothub_intbuf;
|
||||
hub->bus = bus;
|
||||
|
||||
usb_slist_init(&bus->hub_list);
|
||||
usb_slist_add_tail(&bus->hub_list, &hub->list);
|
||||
usb_slist_add_tail(&g_bus_head, &bus->list);
|
||||
}
|
||||
|
||||
|
@ -684,7 +653,6 @@ int usbh_deinitialize(uint8_t busid)
|
|||
|
||||
usbh_hub_deinitialize(bus);
|
||||
|
||||
usb_slist_init(&bus->hub_list);
|
||||
usb_slist_remove(&g_bus_head, &bus->list);
|
||||
|
||||
return 0;
|
||||
|
@ -757,24 +725,29 @@ int usbh_set_interface(struct usbh_hubport *hport, uint8_t intf, uint8_t altsett
|
|||
return usbh_control_transfer(hport, setup, NULL);
|
||||
}
|
||||
|
||||
void *usbh_find_class_instance(const char *devname)
|
||||
static void *usbh_list_all_interface_name(struct usbh_hub *hub, const char *devname)
|
||||
{
|
||||
struct usbh_hubport *hport;
|
||||
usb_slist_t *hub_list;
|
||||
usb_slist_t *bus_list;
|
||||
struct usbh_hub *hub_next;
|
||||
void *priv;
|
||||
|
||||
usb_slist_for_each(bus_list, &g_bus_head)
|
||||
{
|
||||
struct usbh_bus *bus = usb_slist_entry(bus_list, struct usbh_bus, list);
|
||||
usb_slist_for_each(hub_list, &bus->hub_list)
|
||||
{
|
||||
struct usbh_hub *hub = usb_slist_entry(hub_list, struct usbh_hub, list);
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
hport = &hub->child[port];
|
||||
if (hport->connected) {
|
||||
for (uint8_t itf = 0; itf < hport->config.config_desc.bNumInterfaces; itf++) {
|
||||
if (hport->config.intf[itf].class_driver && hport->config.intf[itf].class_driver->driver_name) {
|
||||
if ((strncmp(hport->config.intf[itf].devname, devname, CONFIG_USBHOST_DEV_NAMELEN) == 0) && hport->config.intf[itf].priv)
|
||||
return hport->config.intf[itf].priv;
|
||||
|
||||
if (strcmp(hport->config.intf[itf].class_driver->driver_name, "hub") == 0) {
|
||||
hub_next = hport->config.intf[itf].priv;
|
||||
|
||||
if (hub_next && hub_next->connected) {
|
||||
priv = usbh_list_all_interface_name(hub_next, devname);
|
||||
if (priv) {
|
||||
return priv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -783,11 +756,101 @@ void *usbh_find_class_instance(const char *devname)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void usbh_list_all_interface_driver(struct usbh_hub *hub)
|
||||
{
|
||||
struct usbh_hubport *hport;
|
||||
struct usbh_hub *hub_next;
|
||||
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
hport = &hub->child[port];
|
||||
if (hport->connected) {
|
||||
for (uint8_t itf = 0; itf < hport->config.config_desc.bNumInterfaces; itf++) {
|
||||
if (hport->config.intf[itf].class_driver && hport->config.intf[itf].class_driver->driver_name) {
|
||||
for (uint8_t j = 0; j < hub->index; j++) {
|
||||
USB_LOG_RAW("\t");
|
||||
}
|
||||
|
||||
USB_LOG_RAW("|__Port %u, dev addr:0x%02x, If %u, ClassDriver=%s\r\n",
|
||||
hport->port,
|
||||
hport->dev_addr,
|
||||
itf,
|
||||
hport->config.intf[itf].class_driver->driver_name);
|
||||
|
||||
if (strcmp(hport->config.intf[itf].class_driver->driver_name, "hub") == 0) {
|
||||
hub_next = hport->config.intf[itf].priv;
|
||||
|
||||
if (hub_next && hub_next->connected) {
|
||||
usbh_list_all_interface_driver(hub_next);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void usbh_list_all_interface_desc(struct usbh_bus *bus, struct usbh_hub *hub)
|
||||
{
|
||||
struct usbh_hubport *hport;
|
||||
struct usbh_hub *hub_next;
|
||||
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
hport = &hub->child[port];
|
||||
if (hport->connected) {
|
||||
USB_LOG_RAW("\r\nBus %u, Hub %u, Port %u, dev addr:0x%02x, VID:PID 0x%04x:0x%04x\r\n",
|
||||
bus->busid,
|
||||
hub->index,
|
||||
hport->port,
|
||||
hport->dev_addr,
|
||||
hport->device_desc.idVendor,
|
||||
hport->device_desc.idProduct);
|
||||
usbh_print_hubport_info(hport);
|
||||
|
||||
for (uint8_t itf = 0; itf < hport->config.config_desc.bNumInterfaces; itf++) {
|
||||
if (hport->config.intf[itf].class_driver && hport->config.intf[itf].class_driver->driver_name) {
|
||||
if (strcmp(hport->config.intf[itf].class_driver->driver_name, "hub") == 0) {
|
||||
hub_next = hport->config.intf[itf].priv;
|
||||
|
||||
if (hub_next && hub_next->connected) {
|
||||
usbh_list_all_interface_desc(bus, hub_next);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *usbh_find_class_instance(const char *devname)
|
||||
{
|
||||
usb_slist_t *bus_list;
|
||||
struct usbh_hub *hub;
|
||||
struct usbh_bus *bus;
|
||||
void *priv;
|
||||
size_t flags;
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
usb_slist_for_each(bus_list, &g_bus_head)
|
||||
{
|
||||
bus = usb_slist_entry(bus_list, struct usbh_bus, list);
|
||||
hub = &bus->hcd.roothub;
|
||||
|
||||
priv = usbh_list_all_interface_name(hub, devname);
|
||||
if (priv) {
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return priv;
|
||||
}
|
||||
}
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int lsusb(int argc, char **argv)
|
||||
{
|
||||
usb_slist_t *hub_list;
|
||||
usb_slist_t *bus_list;
|
||||
struct usbh_hubport *hport;
|
||||
struct usbh_hub *hub;
|
||||
struct usbh_bus *bus;
|
||||
size_t flags;
|
||||
|
||||
if (argc < 2) {
|
||||
USB_LOG_RAW("Usage: lsusb [options]...\r\n");
|
||||
|
@ -810,69 +873,36 @@ int lsusb(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
|
||||
if (strcmp(argv[1], "-V") == 0) {
|
||||
USB_LOG_RAW("CherryUSB Version %s\r\n", CHERRYUSB_VERSION_STR);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-t") == 0) {
|
||||
usb_slist_for_each(bus_list, &g_bus_head)
|
||||
{
|
||||
struct usbh_bus *bus = usb_slist_entry(bus_list, struct usbh_bus, list);
|
||||
usb_slist_for_each(hub_list, &bus->hub_list)
|
||||
{
|
||||
struct usbh_hub *hub = usb_slist_entry(hub_list, struct usbh_hub, list);
|
||||
bus = usb_slist_entry(bus_list, struct usbh_bus, list);
|
||||
hub = &bus->hcd.roothub;
|
||||
|
||||
if (hub->is_roothub) {
|
||||
USB_LOG_RAW("/: Bus %u, Hub %u, ports=%u, is roothub\r\n",
|
||||
bus->busid,
|
||||
hub->index,
|
||||
hub->hub_desc.bNbrPorts);
|
||||
} else {
|
||||
USB_LOG_RAW("/: Bus %u, Hub %u, ports=%u, mounted on Hub %02u:Port %u\r\n",
|
||||
bus->busid,
|
||||
hub->index,
|
||||
hub->hub_desc.bNbrPorts,
|
||||
hub->parent->parent->index,
|
||||
hub->parent->port);
|
||||
}
|
||||
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
hport = &hub->child[port];
|
||||
if (hport->connected) {
|
||||
for (uint8_t i = 0; i < hport->config.config_desc.bNumInterfaces; i++) {
|
||||
if (hport->config.intf[i].class_driver && hport->config.intf[i].class_driver->driver_name) {
|
||||
USB_LOG_RAW("\t|__Port %u, dev addr:0x%02x, If %u, ClassDriver=%s\r\n",
|
||||
hport->port,
|
||||
hport->dev_addr,
|
||||
i,
|
||||
hport->config.intf[i].class_driver->driver_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
usbh_list_all_interface_driver(hub);
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-v") == 0) {
|
||||
usb_slist_for_each(bus_list, &g_bus_head)
|
||||
{
|
||||
struct usbh_bus *bus = usb_slist_entry(bus_list, struct usbh_bus, list);
|
||||
usb_slist_for_each(hub_list, &bus->hub_list)
|
||||
{
|
||||
struct usbh_hub *hub = usb_slist_entry(hub_list, struct usbh_hub, list);
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
hport = &hub->child[port];
|
||||
if (hport->connected) {
|
||||
USB_LOG_RAW("Bus %u, Hub %02u, Port %u, dev addr:0x%02x, VID:PID 0x%04x:0x%04x\r\n",
|
||||
bus->busid,
|
||||
hub->index,
|
||||
hport->port,
|
||||
hport->dev_addr,
|
||||
hport->device_desc.idVendor,
|
||||
hport->device_desc.idProduct);
|
||||
usbh_print_hubport_info(hport);
|
||||
}
|
||||
}
|
||||
}
|
||||
bus = usb_slist_entry(bus_list, struct usbh_bus, list);
|
||||
hub = &bus->hcd.roothub;
|
||||
|
||||
usbh_list_all_interface_desc(bus, hub);
|
||||
}
|
||||
}
|
||||
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "usb_hc.h"
|
||||
#include "usb_osal.h"
|
||||
#include "usbh_hub.h"
|
||||
#include "usb_memcpy.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -51,10 +52,10 @@ extern "C" {
|
|||
ep = ep_desc; \
|
||||
USB_LOG_INFO("Ep=%02x Attr=%02u Mps=%d Interval=%02u Mult=%02u\r\n", \
|
||||
ep_desc->bEndpointAddress, \
|
||||
USB_GET_ENDPOINT_TYPE(ep_desc->bmAttributes), \
|
||||
ep_desc->bmAttributes, \
|
||||
USB_GET_MAXPACKETSIZE(ep_desc->wMaxPacketSize), \
|
||||
ep_desc->bInterval, \
|
||||
USB_GET_MULT(ep_desc->bmAttributes)); \
|
||||
USB_GET_MULT(ep_desc->wMaxPacketSize)); \
|
||||
} while (0)
|
||||
|
||||
struct usbh_class_info {
|
||||
|
@ -109,16 +110,12 @@ struct usbh_hubport {
|
|||
struct usb_setup_packet *setup;
|
||||
struct usbh_hub *parent;
|
||||
struct usbh_bus *bus;
|
||||
#ifdef CONFIG_USBHOST_XHCI
|
||||
uint32_t protocol; /* port protocol, for xhci, some ports are USB2.0, others are USB3.0 */
|
||||
#endif
|
||||
struct usb_endpoint_descriptor ep0;
|
||||
struct usbh_urb ep0_urb;
|
||||
usb_osal_mutex_t mutex;
|
||||
};
|
||||
|
||||
struct usbh_hub {
|
||||
usb_slist_t list;
|
||||
bool connected;
|
||||
bool is_roothub;
|
||||
uint8_t index;
|
||||
|
@ -159,7 +156,6 @@ struct usbh_bus {
|
|||
struct usbh_devaddr_map devgen;
|
||||
usb_osal_thread_t hub_thread;
|
||||
usb_osal_mq_t hub_mq;
|
||||
usb_slist_t hub_list;
|
||||
};
|
||||
|
||||
static inline void usbh_control_urb_fill(struct usbh_urb *urb,
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
File diff suppressed because one or more lines are too long
|
@ -194,11 +194,11 @@ void usbd_audio_open(uint8_t busid, uint8_t intf)
|
|||
void usbd_audio_close(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
if (intf == 1) {
|
||||
rx_flag = 1;
|
||||
ep_tx_busy_flag = false;
|
||||
rx_flag = 0;
|
||||
printf("CLOSE1\r\n");
|
||||
} else {
|
||||
tx_flag = 0;
|
||||
ep_tx_busy_flag = false;
|
||||
printf("CLOSE2\r\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ void usbd_audio_open(uint8_t busid, uint8_t intf)
|
|||
void usbd_audio_close(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
if (intf == 1) {
|
||||
rx_flag = 1;
|
||||
rx_flag = 0;
|
||||
USB_LOG_RAW("CLOSE1\r\n");
|
||||
} else {
|
||||
tx_flag = 0;
|
||||
|
|
|
@ -215,6 +215,7 @@ void cdc_ecm_lwip_init(void)
|
|||
|
||||
netif->hwaddr_len = 6;
|
||||
memcpy(netif->hwaddr, mac, 6);
|
||||
netif->hwaddr[5] = ~netif->hwaddr[5]; /* device mac can't same as host. */
|
||||
|
||||
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, cdc_ecm_if_init, netif_input);
|
||||
netif_set_default(netif);
|
||||
|
|
|
@ -143,7 +143,11 @@ static rt_err_t rt_usbd_rndis_control(rt_device_t dev, int cmd, void *args)
|
|||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, mac, 6);
|
||||
{
|
||||
uint8_t *mac_dev = (uint8_t *)args;
|
||||
rt_memcpy(mac_dev, mac, 6);
|
||||
mac_dev[5] = ~mac_dev[5]; /* device mac can't same as host. */
|
||||
}
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
|
@ -247,6 +251,7 @@ void rndis_lwip_init(void)
|
|||
|
||||
netif->hwaddr_len = 6;
|
||||
memcpy(netif->hwaddr, mac, 6);
|
||||
netif->hwaddr[5] = ~netif->hwaddr[5]; /* device mac can't same as host. */
|
||||
|
||||
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, rndisif_init, netif_input);
|
||||
netif_set_default(netif);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,514 @@
|
|||
const unsigned char cherryusb_yuyv[6144] = {
|
||||
0x68, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC6, 0x63, 0x69, 0x63, 0xC2,
|
||||
0x63, 0x69, 0x63, 0xBF, 0x63, 0x69, 0x63, 0xC8, 0x63, 0x6A, 0x64, 0xC4,
|
||||
0x64, 0x69, 0x63, 0xC5, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x63, 0xC7,
|
||||
0x63, 0x68, 0x63, 0xC7, 0x63, 0x68, 0x68, 0xC7, 0x68, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x6C, 0x83, 0xB5, 0x61, 0x70, 0x7E, 0xAA, 0x8C, 0x72, 0xD9, 0x9F,
|
||||
0x64, 0x70, 0x6A, 0xAF, 0xD2, 0x72, 0x6A, 0xA3, 0xC3, 0x6F, 0x67, 0xB2,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0, 0x67, 0x68, 0x67, 0xC0,
|
||||
0x67, 0x68, 0x68, 0xC0, 0x68, 0x68, 0x67, 0xC4, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6C, 0x67, 0xC4,
|
||||
0x67, 0x6D, 0x67, 0xC2, 0x68, 0x6B, 0x67, 0xC0, 0x69, 0x6D, 0x67, 0xBA,
|
||||
0x67, 0x6D, 0x67, 0xBD, 0x67, 0x6C, 0x67, 0xC0, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2,
|
||||
0x67, 0x6B, 0x67, 0xC2, 0x67, 0x6B, 0x67, 0xC2, 0x67, 0x68, 0x67, 0xC4,
|
||||
0x78, 0x70, 0x76, 0xC0, 0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF,
|
||||
0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF,
|
||||
0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF,
|
||||
0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF,
|
||||
0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF, 0x76, 0x70, 0x76, 0xBF,
|
||||
0x76, 0x6D, 0x76, 0xBB, 0x76, 0x6F, 0x76, 0xBB, 0x76, 0x6F, 0x76, 0xBF,
|
||||
0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF,
|
||||
0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF,
|
||||
0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF,
|
||||
0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6F, 0x76, 0xBF,
|
||||
0x76, 0x6F, 0x76, 0xBF, 0x76, 0x6B, 0x78, 0xC0, 0xF7, 0x6D, 0x93, 0x7E,
|
||||
0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A,
|
||||
0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A,
|
||||
0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A,
|
||||
0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A,
|
||||
0x91, 0x60, 0x91, 0x7A, 0x91, 0x60, 0x91, 0x7A, 0x91, 0x68, 0x8D, 0x7B,
|
||||
0x7F, 0x96, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A,
|
||||
0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A,
|
||||
0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A,
|
||||
0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A,
|
||||
0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A, 0x83, 0x9D, 0x83, 0x7A,
|
||||
0x85, 0x91, 0xF6, 0x7F, 0xFC, 0x71, 0x93, 0x77, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x64, 0xCD, 0x6D, 0xBD, 0x6B, 0x96, 0x6E,
|
||||
0xA1, 0x6C, 0xCB, 0x6E, 0xCC, 0x66, 0x93, 0x6D, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x68, 0x8E, 0x6D, 0x86, 0x98, 0x85, 0x6D,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x99, 0xC7, 0x6B,
|
||||
0xCE, 0x94, 0x98, 0x6E, 0xD0, 0x8F, 0xCC, 0x6F, 0x85, 0x9C, 0x85, 0x69,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x86, 0x8F, 0xFA, 0x77,
|
||||
0xFD, 0x7D, 0xF5, 0x7B, 0xF6, 0x79, 0xF6, 0x7C, 0xF6, 0x79, 0xF6, 0x7C,
|
||||
0xF6, 0x79, 0xF6, 0x7C, 0xF6, 0x79, 0xF6, 0x7C, 0xF6, 0x79, 0xF6, 0x7C,
|
||||
0xF6, 0x79, 0xF6, 0x7C, 0xF7, 0x7C, 0xF4, 0x7B, 0xF6, 0x7D, 0xF7, 0x7B,
|
||||
0xF7, 0x7A, 0xF6, 0x7C, 0xF6, 0x79, 0xF6, 0x7C, 0xF6, 0x79, 0xF6, 0x7C,
|
||||
0xF6, 0x79, 0xF6, 0x7C, 0xF6, 0x79, 0xF6, 0x7C, 0xF6, 0x79, 0xF6, 0x7C,
|
||||
0xF4, 0x7A, 0xE2, 0x7B, 0xDF, 0x85, 0xF5, 0x7B, 0xF4, 0x86, 0xF4, 0x7B,
|
||||
0xF4, 0x86, 0xF4, 0x7B, 0xF4, 0x86, 0xF4, 0x7B, 0xF4, 0x86, 0xF4, 0x7B,
|
||||
0xF4, 0x86, 0xF4, 0x7B, 0xF4, 0x86, 0xF5, 0x7B, 0xF5, 0x85, 0xF6, 0x7B,
|
||||
0xF4, 0x85, 0xF5, 0x7B, 0xF5, 0x86, 0xF4, 0x7A, 0xF4, 0x86, 0xF4, 0x7B,
|
||||
0xF4, 0x86, 0xF4, 0x7B, 0xF4, 0x86, 0xF4, 0x7B, 0xF4, 0x86, 0xF4, 0x7B,
|
||||
0xF4, 0x86, 0xF4, 0x7B, 0xF6, 0x81, 0xFC, 0x7B, 0xFC, 0x7F, 0xF3, 0x7C,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x80, 0x30, 0x7D, 0xEF, 0x81, 0x30, 0x7E, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x7D, 0xE8, 0x7D,
|
||||
0xE7, 0x82, 0x2D, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x82, 0xEF, 0x7E, 0x33, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D,
|
||||
0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x83, 0x30, 0x7F,
|
||||
0x30, 0x83, 0x30, 0x80, 0x62, 0x83, 0x39, 0x80, 0x87, 0x83, 0x9A, 0x80,
|
||||
0x6D, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x7F, 0x30, 0x7D,
|
||||
0xEC, 0x81, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x29, 0x83, 0x94, 0x80, 0x31, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x7E, 0xE8, 0x7D, 0xE7, 0x83, 0x2C, 0x7E,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x40, 0x83, 0x92, 0x80,
|
||||
0x22, 0x83, 0x30, 0x80, 0x83, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x82, 0xEF, 0x7E, 0x33, 0x85, 0x30, 0x7E, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x3F, 0x83, 0x8B, 0x80, 0x36, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C,
|
||||
0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x30, 0x7F, 0x30, 0x7D, 0xEC, 0x81, 0x30, 0x7D,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x2F, 0x7E, 0xE8, 0x7E, 0xE7, 0x83, 0x2C, 0x7E, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x82, 0xEF, 0x7E,
|
||||
0x33, 0x85, 0x30, 0x7E, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7E, 0xF6, 0x7C,
|
||||
0xEF, 0x7F, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E,
|
||||
0xEF, 0x81, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E,
|
||||
0xEF, 0x7E, 0xEE, 0x7E, 0xFA, 0x7E, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E,
|
||||
0xEF, 0x81, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E,
|
||||
0xEF, 0x81, 0xEF, 0x7E, 0xEF, 0x81, 0xEF, 0x7E, 0xEA, 0x7E, 0xE8, 0x7D,
|
||||
0xE7, 0x82, 0xEE, 0x7E, 0xEB, 0x83, 0xEB, 0x7E, 0xEB, 0x83, 0xEB, 0x7E,
|
||||
0xEB, 0x83, 0xEB, 0x7E, 0xEB, 0x83, 0xEB, 0x7E, 0xEB, 0x83, 0xEB, 0x7E,
|
||||
0xEB, 0x83, 0xEB, 0x7E, 0xEC, 0x82, 0xFD, 0x7E, 0xED, 0x83, 0xEB, 0x7E,
|
||||
0xEB, 0x83, 0xEB, 0x7E, 0xEB, 0x83, 0xEB, 0x7E, 0xEB, 0x83, 0xEB, 0x7E,
|
||||
0xEB, 0x83, 0xEB, 0x7E, 0xEB, 0x83, 0xEB, 0x7E, 0xEB, 0x83, 0xEB, 0x7E,
|
||||
0xFA, 0x81, 0xFD, 0x7C, 0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x83, 0x30, 0x7F,
|
||||
0x30, 0x83, 0x30, 0x80, 0x2B, 0x83, 0x5B, 0x80, 0x37, 0x83, 0x49, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x7F, 0x30, 0x7D,
|
||||
0xEC, 0x81, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x29, 0x83, 0x48, 0x80, 0x5D, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x7E, 0xE8, 0x7D, 0xE7, 0x83, 0x2C, 0x7E,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x2B, 0x83, 0x62, 0x80,
|
||||
0x64, 0x83, 0x60, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x82, 0xEF, 0x7E, 0x33, 0x85, 0x30, 0x7E, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x2F, 0x83, 0x55, 0x80, 0x33, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C,
|
||||
0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x83, 0x30, 0x7F, 0x30, 0x83, 0x30, 0x80,
|
||||
0x31, 0x83, 0x2F, 0x80, 0x30, 0x83, 0x37, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x7F, 0x30, 0x7D, 0xEC, 0x81, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x35, 0x83, 0x2E, 0x80,
|
||||
0x28, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x7E, 0xE8, 0x7D, 0xE7, 0x83, 0x2C, 0x7E, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x2E, 0x80, 0x2A, 0x83, 0x32, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x82, 0xEF, 0x7E,
|
||||
0x33, 0x85, 0x30, 0x7E, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x39, 0x83, 0x27, 0x80, 0x2A, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7F, 0xF3, 0x7C,
|
||||
0xAC, 0x7D, 0xAC, 0x7D, 0xAC, 0x7C, 0xAC, 0x7D, 0xAC, 0x7C, 0xAC, 0x7D,
|
||||
0xAC, 0x7C, 0xAC, 0x7D, 0xAC, 0x7C, 0xAC, 0x7D, 0xAC, 0x7C, 0xAC, 0x7D,
|
||||
0xAC, 0x7D, 0xAB, 0x7D, 0xF9, 0x7E, 0xAC, 0x7E, 0xAC, 0x7C, 0xAC, 0x7D,
|
||||
0xAC, 0x7C, 0xAC, 0x7D, 0xAC, 0x7C, 0xAC, 0x7D, 0xAC, 0x7C, 0xAC, 0x7D,
|
||||
0xAC, 0x7C, 0xAC, 0x7D, 0xAC, 0x7C, 0xAC, 0x7D, 0xAA, 0x7D, 0xE8, 0x7D,
|
||||
0xE7, 0x82, 0xC9, 0x7E, 0xCB, 0x83, 0xCB, 0x7E, 0xCB, 0x83, 0xCB, 0x7E,
|
||||
0xCB, 0x83, 0xCB, 0x7E, 0xCB, 0x83, 0xCB, 0x7E, 0xCB, 0x83, 0xCB, 0x7E,
|
||||
0xCB, 0x83, 0xCB, 0x7E, 0xCC, 0x82, 0xF8, 0x7D, 0xCC, 0x84, 0xCB, 0x7E,
|
||||
0xCB, 0x83, 0xCB, 0x7E, 0xCB, 0x83, 0xCB, 0x7E, 0xCB, 0x83, 0xCB, 0x7E,
|
||||
0xCB, 0x83, 0xCB, 0x7E, 0xCB, 0x83, 0xCB, 0x7E, 0xCB, 0x83, 0xCB, 0x7E,
|
||||
0xF4, 0x81, 0xFD, 0x7C, 0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x82, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x35, 0x7F, 0x34, 0x82, 0x2F, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F, 0x30, 0x7F, 0x30, 0x7D,
|
||||
0xEC, 0x81, 0x30, 0x7D, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x30, 0x82, 0x33, 0x7F, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x2F, 0x7E, 0xE8, 0x7E, 0xE7, 0x83, 0x2C, 0x7E,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x33, 0x80,
|
||||
0x31, 0x83, 0x33, 0x7F, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x82, 0xEF, 0x7E, 0x33, 0x85, 0x30, 0x7E, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x2E, 0x83, 0x2D, 0x7F, 0x2F, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C,
|
||||
0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x83, 0x30, 0x7F, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x33, 0x80, 0xAB, 0x83, 0x35, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x7F, 0x30, 0x7D, 0xEC, 0x81, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x6D, 0x83, 0x4F, 0x80,
|
||||
0x31, 0x83, 0x31, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x7E, 0xE8, 0x7D, 0xE7, 0x83, 0x2C, 0x7E, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x33, 0x80, 0x77, 0x83, 0x34, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x82, 0xEF, 0x7E,
|
||||
0x33, 0x85, 0x30, 0x7E, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x63, 0x83, 0x9A, 0x80, 0x34, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7F, 0xF3, 0x7C,
|
||||
0x30, 0x81, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x80, 0x30, 0x7D, 0xEB, 0x81, 0x30, 0x7E, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x2F, 0x7E, 0xE8, 0x7E,
|
||||
0xE7, 0x82, 0x2D, 0x7D, 0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D,
|
||||
0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D,
|
||||
0x30, 0x85, 0x30, 0x7D, 0x30, 0x83, 0xEF, 0x7E, 0x33, 0x87, 0x30, 0x7D,
|
||||
0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D,
|
||||
0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D,
|
||||
0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7F, 0xFC, 0x7C, 0xFC, 0x7E, 0xFC, 0x7E,
|
||||
0xFC, 0x7D, 0xFC, 0x7E, 0xFC, 0x7D, 0xFC, 0x7E, 0xFC, 0x7C, 0xFC, 0x7D,
|
||||
0xFC, 0x7D, 0xFC, 0x7E, 0xFC, 0x7D, 0xFC, 0x7E, 0xFC, 0x7F, 0xFE, 0x7E,
|
||||
0xFD, 0x80, 0xFB, 0x7D, 0xFC, 0x7D, 0xFC, 0x7E, 0xFC, 0x7D, 0xFC, 0x7E,
|
||||
0xFC, 0x7C, 0xFC, 0x7D, 0xFC, 0x7C, 0xFC, 0x7E, 0xFC, 0x7D, 0xFC, 0x7E,
|
||||
0xFC, 0x7D, 0xFC, 0x7E, 0xF8, 0x7E, 0xE8, 0x7E, 0xE7, 0x81, 0xFD, 0x7E,
|
||||
0xFB, 0x80, 0xFB, 0x7E, 0xFB, 0x80, 0xFB, 0x7E, 0xFB, 0x80, 0xFB, 0x7D,
|
||||
0xFB, 0x80, 0xFB, 0x7D, 0xFB, 0x80, 0xFB, 0x7E, 0xFB, 0x80, 0xFB, 0x7E,
|
||||
0xFB, 0x82, 0xF8, 0x7E, 0xFC, 0x7D, 0xFB, 0x7E, 0xFB, 0x80, 0xFB, 0x7E,
|
||||
0xFB, 0x80, 0xFB, 0x7E, 0xFB, 0x80, 0xFB, 0x7D, 0xFB, 0x80, 0xFB, 0x7D,
|
||||
0xFB, 0x80, 0xFB, 0x7E, 0xFB, 0x80, 0xFB, 0x7E, 0xFC, 0x81, 0xFD, 0x7C,
|
||||
0xFC, 0x7F, 0xF3, 0x7C, 0x30, 0x87, 0x30, 0x7D, 0x30, 0x88, 0x30, 0x7D,
|
||||
0x30, 0x88, 0x30, 0x7D, 0x37, 0x86, 0x36, 0x7F, 0x30, 0x88, 0x30, 0x7D,
|
||||
0x30, 0x88, 0x30, 0x7D, 0x30, 0x81, 0x30, 0x7D, 0xEB, 0x81, 0x30, 0x7E,
|
||||
0x30, 0x88, 0x30, 0x7D, 0x30, 0x88, 0x30, 0x7D, 0x31, 0x86, 0x2E, 0x7E,
|
||||
0x2B, 0x86, 0x30, 0x7D, 0x30, 0x88, 0x30, 0x7D, 0x30, 0x88, 0x30, 0x7D,
|
||||
0x2F, 0x7E, 0xE8, 0x7E, 0xE7, 0x82, 0x2D, 0x7D, 0x30, 0x85, 0x30, 0x7D,
|
||||
0x30, 0x85, 0x30, 0x7D, 0x2D, 0x82, 0x33, 0x7E, 0x32, 0x82, 0x2C, 0x7E,
|
||||
0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D, 0x30, 0x82, 0xEF, 0x7E,
|
||||
0x33, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D, 0x30, 0x85, 0x30, 0x7D,
|
||||
0x31, 0x82, 0x3B, 0x7E, 0x37, 0x85, 0x30, 0x7F, 0x30, 0x85, 0x30, 0x7D,
|
||||
0x30, 0x85, 0x30, 0x7D, 0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7E, 0xF2, 0x7C,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x35, 0x7D,
|
||||
0x2F, 0x83, 0x31, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x84, 0x30, 0x7D, 0xEB, 0x81, 0x30, 0x7E, 0x30, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x36, 0x83, 0x34, 0x7D, 0x33, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x2F, 0x7E, 0xE8, 0x7E,
|
||||
0xE7, 0x82, 0x2D, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x2F, 0x7D, 0x36, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x82, 0xEF, 0x7E, 0x33, 0x85, 0x30, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x2C, 0x83, 0x32, 0x7D,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x30, 0x84, 0x30, 0x7D,
|
||||
0xEF, 0x81, 0xFD, 0x7C, 0xFC, 0x7E, 0xF6, 0x7C, 0x99, 0x7D, 0x99, 0x7D,
|
||||
0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D,
|
||||
0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x9C, 0x7D,
|
||||
0xF4, 0x80, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D,
|
||||
0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D, 0x99, 0x7D,
|
||||
0x99, 0x7D, 0x99, 0x7D, 0x9B, 0x7E, 0xE8, 0x7E, 0xE7, 0x82, 0xB8, 0x7E,
|
||||
0xB6, 0x83, 0xB6, 0x7D, 0xB6, 0x83, 0xB6, 0x7D, 0xB6, 0x83, 0xB6, 0x7D,
|
||||
0xB6, 0x83, 0xB6, 0x7D, 0xB6, 0x83, 0xB6, 0x7D, 0xB6, 0x83, 0xB6, 0x7D,
|
||||
0xB6, 0x82, 0xF4, 0x7D, 0xB8, 0x85, 0xB6, 0x7D, 0xB6, 0x83, 0xB6, 0x7D,
|
||||
0xB6, 0x83, 0xB6, 0x7D, 0xB6, 0x83, 0xB6, 0x7D, 0xB6, 0x83, 0xB6, 0x7D,
|
||||
0xB6, 0x83, 0xB6, 0x7D, 0xB6, 0x84, 0xB6, 0x7D, 0xF8, 0x81, 0xFD, 0x7C,
|
||||
0xFB, 0x7F, 0xFE, 0x7D, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x7E, 0xE9, 0x80, 0xE7, 0x81, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFD, 0x80, 0xFC, 0x7E, 0xFB, 0x7F, 0xFE, 0x7D,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFD, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x7E, 0xE9, 0x80,
|
||||
0xE7, 0x81, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFD, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFD, 0x80, 0xFC, 0x7E, 0xFB, 0x7F, 0xFE, 0x7D, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x7E, 0xE9, 0x80, 0xE7, 0x81, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFD, 0x80, 0xFC, 0x7E,
|
||||
0xFC, 0x7E, 0xFA, 0x7C, 0xFC, 0x7F, 0xFD, 0x7E, 0xFD, 0x7E, 0xFD, 0x7D,
|
||||
0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D,
|
||||
0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D,
|
||||
0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D,
|
||||
0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D, 0xFD, 0x7E, 0xFD, 0x7D,
|
||||
0xF9, 0x7E, 0xE8, 0x7E, 0xE7, 0x82, 0xF9, 0x7E, 0xFD, 0x81, 0xFD, 0x7D,
|
||||
0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D,
|
||||
0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D,
|
||||
0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D,
|
||||
0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D,
|
||||
0xFD, 0x81, 0xFD, 0x7D, 0xF9, 0x80, 0xFD, 0x7C, 0xFC, 0x7F, 0xF3, 0x7C,
|
||||
0x30, 0x82, 0x30, 0x7D, 0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E,
|
||||
0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E,
|
||||
0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E,
|
||||
0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E,
|
||||
0x30, 0x84, 0x30, 0x7E, 0x30, 0x84, 0x30, 0x7E, 0x2F, 0x7E, 0xE8, 0x7E,
|
||||
0xE7, 0x82, 0x2D, 0x7D, 0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E,
|
||||
0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E,
|
||||
0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E,
|
||||
0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E,
|
||||
0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7E, 0x30, 0x7F, 0x30, 0x7D,
|
||||
0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x83, 0x30, 0x7F,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x7C, 0x80, 0x31, 0x83, 0x46, 0x80, 0x47, 0x83, 0x72, 0x80,
|
||||
0x5E, 0x83, 0x44, 0x80, 0x85, 0x83, 0x5F, 0x80, 0x38, 0x83, 0x34, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x7E, 0xE8, 0x7D, 0xE7, 0x83, 0x2C, 0x7E,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x58, 0x80, 0xB1, 0x83, 0x3E, 0x80,
|
||||
0x97, 0x83, 0x5F, 0x80, 0x41, 0x83, 0xA3, 0x80, 0x61, 0x83, 0x3E, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C,
|
||||
0xFC, 0x7E, 0xF2, 0x7C, 0x30, 0x83, 0x30, 0x7F, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x7E, 0xE8, 0x7D, 0xE7, 0x83, 0x2C, 0x7E, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x7F, 0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7E, 0xF2, 0x7C,
|
||||
0x30, 0x83, 0x30, 0x7F, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x7E, 0xE8, 0x7D,
|
||||
0xE7, 0x83, 0x2C, 0x7E, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x7F,
|
||||
0xEF, 0x80, 0xFD, 0x7C, 0xFC, 0x7F, 0xFB, 0x7C, 0xFB, 0x7E, 0xFB, 0x7E,
|
||||
0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E,
|
||||
0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E,
|
||||
0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E,
|
||||
0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E, 0xFB, 0x7E,
|
||||
0xFB, 0x7E, 0xFB, 0x7E, 0xF9, 0x7E, 0xE8, 0x7E, 0xE7, 0x82, 0xFB, 0x7D,
|
||||
0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E,
|
||||
0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E,
|
||||
0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E,
|
||||
0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E,
|
||||
0xFE, 0x81, 0xFE, 0x7E, 0xFE, 0x81, 0xFE, 0x7E, 0xFD, 0x81, 0xFC, 0x7E,
|
||||
0xFC, 0x80, 0x2E, 0x7C, 0x30, 0x82, 0x30, 0x80, 0x30, 0x82, 0x30, 0x80,
|
||||
0x30, 0x82, 0x30, 0x80, 0x30, 0x82, 0x30, 0x80, 0x30, 0x82, 0x59, 0x7F,
|
||||
0x30, 0x83, 0x30, 0x7D, 0x2D, 0x83, 0x31, 0x80, 0x36, 0x83, 0x37, 0x7D,
|
||||
0x30, 0x80, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x80,
|
||||
0x30, 0x82, 0x30, 0x80, 0x30, 0x82, 0x30, 0x80, 0x30, 0x82, 0x30, 0x80,
|
||||
0x30, 0x82, 0x30, 0x80, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x30, 0x7F,
|
||||
0x2D, 0x83, 0x30, 0x7D, 0x30, 0x82, 0x30, 0x7D, 0x2F, 0x7F, 0x35, 0x7D,
|
||||
0x3B, 0x7F, 0x2F, 0x7D, 0x30, 0x83, 0x30, 0x7D, 0x52, 0x84, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F, 0x31, 0x82, 0x31, 0x7F,
|
||||
0x31, 0x82, 0x31, 0x7F, 0x2E, 0x80, 0xFC, 0x7D, 0xFC, 0x80, 0x2E, 0x7C,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x7E, 0x5A, 0x7F, 0x2F, 0x82, 0x2F, 0x7D,
|
||||
0x2A, 0x7E, 0x35, 0x7C, 0x2F, 0x7E, 0x37, 0x7D, 0x2F, 0x81, 0x2F, 0x7D,
|
||||
0x2F, 0x83, 0x31, 0x7D, 0x30, 0x83, 0x30, 0x80, 0x32, 0x83, 0x2A, 0x80,
|
||||
0x32, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x31, 0x83, 0x30, 0x80,
|
||||
0x34, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x35, 0x83, 0x34, 0x80,
|
||||
0x31, 0x83, 0x29, 0x80, 0x30, 0x83, 0x31, 0x80, 0x2C, 0x87, 0x32, 0x7D,
|
||||
0x32, 0x87, 0x32, 0x7D, 0x31, 0x85, 0x37, 0x7D, 0x39, 0x85, 0x2E, 0x7D,
|
||||
0x32, 0x86, 0x32, 0x7D, 0x52, 0x84, 0x30, 0x7F, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x2E, 0x80, 0xFC, 0x7D, 0xFC, 0x80, 0x2E, 0x7C, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x32, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x52, 0x83, 0x85, 0x80, 0xB0, 0x83, 0x56, 0x80,
|
||||
0x67, 0x83, 0x73, 0x80, 0x44, 0x83, 0x71, 0x80, 0x2F, 0x83, 0x8D, 0x80,
|
||||
0x54, 0x83, 0x6C, 0x80, 0x75, 0x83, 0x5E, 0x80, 0xB6, 0x83, 0x2F, 0x80,
|
||||
0x2C, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x2E, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x2E, 0x80, 0xFC, 0x7D,
|
||||
0xFC, 0x80, 0x2E, 0x7D, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x2D, 0x83, 0x30, 0x80, 0x30, 0x83, 0x2B, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x2E, 0x80, 0xFC, 0x7D, 0xFD, 0x81, 0x55, 0x7F,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80, 0x58, 0x83, 0x58, 0x80,
|
||||
0x53, 0x80, 0xFC, 0x7E, 0xFC, 0x72, 0x91, 0x77, 0x91, 0x61, 0x91, 0x6B,
|
||||
0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B,
|
||||
0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B,
|
||||
0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B,
|
||||
0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B, 0x91, 0x61, 0x91, 0x6B,
|
||||
0x91, 0x61, 0x91, 0x6B, 0x91, 0x68, 0x90, 0x70, 0x83, 0x95, 0x83, 0x6D,
|
||||
0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68,
|
||||
0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68,
|
||||
0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68,
|
||||
0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68,
|
||||
0x83, 0x9D, 0x83, 0x68, 0x83, 0x9D, 0x83, 0x68, 0x84, 0x8F, 0xFA, 0x77,
|
||||
0xFC, 0x72, 0x93, 0x77, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B,
|
||||
0x92, 0x68, 0x8E, 0x70, 0x86, 0x95, 0x85, 0x6D, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x86, 0x8F, 0xFA, 0x77, 0xFC, 0x71, 0x93, 0x77,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x62, 0x96, 0x6B,
|
||||
0xB1, 0x6B, 0xC5, 0x73, 0xA2, 0x69, 0x8E, 0x70, 0xD1, 0x69, 0xBD, 0x6E,
|
||||
0xC2, 0x6B, 0xAA, 0x73, 0xAF, 0x68, 0x91, 0x6B, 0xAB, 0x69, 0xCD, 0x70,
|
||||
0xA2, 0x68, 0xA8, 0x70, 0xAF, 0x67, 0x9F, 0x6E, 0x8F, 0x63, 0x92, 0x6B,
|
||||
0x92, 0x61, 0x92, 0x6B, 0x92, 0x61, 0x92, 0x6B, 0x92, 0x68, 0x8E, 0x6D,
|
||||
0x86, 0x98, 0x85, 0x6D, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x86, 0x9D, 0x88, 0x6B, 0xC6, 0x93, 0xA9, 0x71, 0x84, 0x96, 0xC0, 0x6C,
|
||||
0xB3, 0x92, 0xB7, 0x70, 0xA3, 0x92, 0xB3, 0x73, 0x86, 0x96, 0xBF, 0x6D,
|
||||
0xC2, 0x93, 0xBB, 0x70, 0x7F, 0x97, 0x93, 0x6D, 0xAB, 0x98, 0xA7, 0x6B,
|
||||
0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68, 0x85, 0x9D, 0x85, 0x68,
|
||||
0x86, 0x8F, 0xFA, 0x77, 0xFC, 0x74, 0x93, 0x7A, 0x92, 0x64, 0x92, 0x69,
|
||||
0x92, 0x64, 0x92, 0x69, 0x92, 0x64, 0x92, 0x69, 0x92, 0x64, 0x92, 0x68,
|
||||
0x92, 0x64, 0x92, 0x68, 0x92, 0x64, 0x92, 0x69, 0x92, 0x64, 0x92, 0x68,
|
||||
0x92, 0x63, 0x92, 0x69, 0x92, 0x64, 0x92, 0x68, 0x92, 0x64, 0x92, 0x68,
|
||||
0x92, 0x64, 0x92, 0x69, 0x92, 0x64, 0x92, 0x69, 0x92, 0x64, 0x92, 0x69,
|
||||
0x92, 0x64, 0x92, 0x69, 0x92, 0x67, 0x8E, 0x6E, 0x86, 0x97, 0x85, 0x6E,
|
||||
0x85, 0x98, 0x85, 0x69, 0x85, 0x98, 0x85, 0x69, 0x85, 0x98, 0x85, 0x69,
|
||||
0x85, 0x99, 0x85, 0x68, 0x85, 0x99, 0x85, 0x69, 0x85, 0x99, 0x85, 0x68,
|
||||
0x85, 0x99, 0x85, 0x68, 0x85, 0x98, 0x85, 0x68, 0x86, 0x99, 0x85, 0x68,
|
||||
0x85, 0x98, 0x85, 0x69, 0x85, 0x98, 0x85, 0x69, 0x85, 0x98, 0x85, 0x69,
|
||||
0x85, 0x98, 0x85, 0x69, 0x85, 0x98, 0x85, 0x69, 0x85, 0x8C, 0xFB, 0x7A,
|
||||
0xFB, 0x78, 0xAE, 0x7C, 0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75,
|
||||
0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75,
|
||||
0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75,
|
||||
0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75,
|
||||
0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75, 0xAE, 0x70, 0xAE, 0x75,
|
||||
0xAE, 0x71, 0xB3, 0x76, 0xAF, 0x8C, 0xA6, 0x76, 0xA5, 0x92, 0xA5, 0x75,
|
||||
0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75,
|
||||
0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75,
|
||||
0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75,
|
||||
0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75, 0xA5, 0x92, 0xA5, 0x75,
|
||||
0xA5, 0x92, 0xA5, 0x75, 0xA6, 0x88, 0xFC, 0x7B, 0xFD, 0x88, 0x88, 0x82,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x97, 0x89, 0x86, 0x88, 0x99, 0x85, 0x85,
|
||||
0x88, 0x99, 0x88, 0x85, 0x88, 0x9A, 0x89, 0x89, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88, 0x89, 0x95, 0x89, 0x88,
|
||||
0x88, 0x87, 0xFD, 0x82, 0xFC, 0x8C, 0x89, 0x81, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x98, 0x88, 0x86, 0x7E, 0x9C, 0x8B, 0x85, 0x88, 0x9C, 0x8C, 0x85,
|
||||
0x88, 0x98, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88,
|
||||
0x88, 0x94, 0x88, 0x88, 0x88, 0x94, 0x88, 0x88, 0x89, 0x8E, 0xFD, 0x81,
|
||||
0xFC, 0x7E, 0xF0, 0x7F, 0x30, 0x82, 0x30, 0x81, 0x30, 0x82, 0x30, 0x7F,
|
||||
0x30, 0x83, 0x33, 0x82, 0xFD, 0x7F, 0x30, 0x81, 0x30, 0x82, 0x30, 0x7F,
|
||||
0x30, 0x82, 0x30, 0x7F, 0x34, 0x82, 0xFD, 0x81, 0x30, 0x82, 0x30, 0x7F,
|
||||
0x30, 0x82, 0x30, 0x7F, 0x30, 0x82, 0x30, 0x81, 0xFE, 0x81, 0x30, 0x81,
|
||||
0x30, 0x82, 0x30, 0x7F, 0x30, 0x82, 0x30, 0x7F, 0x30, 0x81, 0xFE, 0x80,
|
||||
0x30, 0x82, 0x30, 0x7F, 0x30, 0x82, 0x30, 0x7F, 0x30, 0x82, 0x30, 0x81,
|
||||
0xFC, 0x82, 0x2D, 0x82, 0x30, 0x82, 0x30, 0x7F, 0x30, 0x82, 0x30, 0x7F,
|
||||
0x30, 0x82, 0xC4, 0x81, 0x2F, 0x82, 0x30, 0x81, 0x30, 0x82, 0x30, 0x7F,
|
||||
0x30, 0x81, 0x30, 0x7F, 0x5E, 0x81, 0x2F, 0x82, 0x30, 0x82, 0x30, 0x81,
|
||||
0x30, 0x82, 0x30, 0x7F, 0x30, 0x81, 0x30, 0x7F, 0xFE, 0x80, 0xFE, 0x81,
|
||||
0xFE, 0x80, 0xFE, 0x81, 0xFD, 0x7D, 0xFC, 0x7F, 0xFD, 0x80, 0xEF, 0x7E,
|
||||
0x30, 0x83, 0x31, 0x80, 0x2E, 0x83, 0x35, 0x80, 0x30, 0x85, 0x33, 0x80,
|
||||
0xFD, 0x82, 0x30, 0x80, 0x2F, 0x83, 0x30, 0x80, 0x2D, 0x83, 0x31, 0x80,
|
||||
0x34, 0x82, 0xFE, 0x80, 0x30, 0x83, 0x30, 0x80, 0x2E, 0x83, 0x2F, 0x80,
|
||||
0x2E, 0x83, 0x30, 0x80, 0xFE, 0x82, 0x30, 0x80, 0x2B, 0x83, 0x2B, 0x80,
|
||||
0x2E, 0x83, 0x31, 0x80, 0x30, 0x82, 0xFE, 0x80, 0x30, 0x83, 0x34, 0x80,
|
||||
0x2D, 0x83, 0x34, 0x80, 0x30, 0x83, 0x30, 0x80, 0xFD, 0x82, 0x2D, 0x80,
|
||||
0x30, 0x83, 0x32, 0x80, 0x30, 0x83, 0x31, 0x80, 0x30, 0x83, 0xC4, 0x80,
|
||||
0x2F, 0x83, 0x30, 0x80, 0x2B, 0x83, 0x32, 0x80, 0x34, 0x83, 0x30, 0x80,
|
||||
0x5E, 0x83, 0x2F, 0x80, 0x30, 0x83, 0x30, 0x80, 0x2B, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0xFF, 0x7F, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80,
|
||||
0xFD, 0x7F, 0xFD, 0x7F, 0xFD, 0x80, 0xEF, 0x7E, 0x30, 0x83, 0x91, 0x80,
|
||||
0x2D, 0x83, 0x35, 0x80, 0x30, 0x85, 0x33, 0x80, 0xFD, 0x82, 0x30, 0x80,
|
||||
0x39, 0x83, 0x68, 0x80, 0x33, 0x83, 0x31, 0x80, 0x34, 0x82, 0xFE, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x96, 0x83, 0x31, 0x80, 0x2E, 0x83, 0x30, 0x80,
|
||||
0xFE, 0x82, 0x30, 0x80, 0x64, 0x83, 0xD1, 0x80, 0x55, 0x83, 0x31, 0x80,
|
||||
0x30, 0x82, 0xFE, 0x80, 0x30, 0x83, 0x2C, 0x80, 0x3C, 0x83, 0x49, 0x80,
|
||||
0x5B, 0x83, 0x30, 0x80, 0xFD, 0x82, 0x2D, 0x80, 0x74, 0x83, 0x25, 0x80,
|
||||
0x8D, 0x83, 0x52, 0x80, 0x30, 0x83, 0xC4, 0x80, 0x2F, 0x83, 0x30, 0x80,
|
||||
0x33, 0x83, 0x31, 0x80, 0x84, 0x83, 0x30, 0x80, 0x5E, 0x83, 0x2F, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x72, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0xFF, 0x7F, 0xFD, 0x80, 0xFF, 0x80, 0xFF, 0x80, 0xFD, 0x7F, 0xFD, 0x7F,
|
||||
0xFD, 0x80, 0xEF, 0x7E, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x85, 0x33, 0x80, 0xFD, 0x82, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x34, 0x82, 0xFE, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0xFE, 0x82, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x82, 0xFE, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0xFD, 0x82, 0x2D, 0x80, 0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0xC4, 0x80, 0x2F, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x5E, 0x83, 0x2F, 0x80, 0x30, 0x83, 0x30, 0x80,
|
||||
0x30, 0x83, 0x30, 0x80, 0x30, 0x83, 0x30, 0x80, 0xFF, 0x7F, 0xFF, 0x80,
|
||||
0xFF, 0x80, 0xFF, 0x80, 0xFD, 0x7F, 0xFD, 0x7F, 0xFA, 0x7E, 0xF0, 0x7B,
|
||||
0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x8B, 0x5D, 0x7F,
|
||||
0xFF, 0x81, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F,
|
||||
0x5B, 0x80, 0xFB, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F,
|
||||
0x5E, 0x8A, 0x5E, 0x7F, 0xF8, 0x85, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F,
|
||||
0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x85, 0xFB, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F,
|
||||
0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x88, 0x5E, 0x7F, 0xF3, 0x85, 0x5E, 0x80,
|
||||
0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x85, 0xC4, 0x7F,
|
||||
0x5C, 0x85, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F,
|
||||
0x81, 0x85, 0x5B, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F, 0x5E, 0x8A, 0x5E, 0x7F,
|
||||
0x5E, 0x8A, 0x5E, 0x7F, 0xFD, 0x81, 0xFD, 0x7D, 0xFD, 0x81, 0xFD, 0x7D,
|
||||
0xFC, 0x7E, 0xFA, 0x7B, 0xF7, 0x7E, 0xFC, 0x7D, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFC, 0x82, 0xFC, 0x7F, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x82, 0xFC, 0x7F, 0xFC, 0x82, 0xFC, 0x7F, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E, 0xFD, 0x81, 0xFD, 0x7E,
|
||||
0xFD, 0x81, 0xFD, 0x7F, 0xFD, 0x81, 0xFD, 0x7F, 0xFC, 0x7D, 0xF7, 0x7E
|
||||
};
|
|
@ -28,6 +28,11 @@
|
|||
#define HIDRAW_OUT_EP_INTERVAL 10
|
||||
#endif
|
||||
|
||||
#define USBD_VID 0xffff
|
||||
#define USBD_PID 0xffff
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
/*!< config descriptor size */
|
||||
#define USB_HID_CONFIG_DESC_SIZ (9 + 9 + 9 + 7 + 7)
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -31,24 +31,13 @@
|
|||
#ifndef TEST_USBH_VIDEO
|
||||
#define TEST_USBH_VIDEO 0
|
||||
#endif
|
||||
#ifndef TEST_USBH_CDC_ECM
|
||||
#define TEST_USBH_CDC_ECM 0
|
||||
#endif
|
||||
#ifndef TEST_USBH_CDC_NCM
|
||||
#define TEST_USBH_CDC_NCM 0
|
||||
#endif
|
||||
#ifndef TEST_USBH_CDC_RNDIS
|
||||
#define TEST_USBH_CDC_RNDIS 0
|
||||
#endif
|
||||
#ifndef TEST_USBH_ASIX
|
||||
#define TEST_USBH_ASIX 0
|
||||
#endif
|
||||
#ifndef TEST_USBH_RTL8152
|
||||
#define TEST_USBH_RTL8152 0
|
||||
|
||||
#if defined(TEST_USBH_CDC_ECM) || defined(TEST_USBH_CDC_RNDIS) || defined(TEST_USBH_ASIX) || defined(TEST_USBH_RTL8152)
|
||||
#error we have move those class implements into platform/none/usbh_lwip.c, and you should call tcpip_init(NULL, NULL) in your app
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_CDC_ACM
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t cdc_buffer[512];
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t cdc_buffer[4096];
|
||||
|
||||
#if TEST_USBH_CDC_SPEED
|
||||
#define TEST_LEN (16 * 1024)
|
||||
|
@ -96,12 +85,10 @@ static void usbh_cdc_acm_thread(void *argument)
|
|||
USB_LOG_RAW("per packet len:%d, out speed:%f MB/S\r\n", test_len[j], (test_len[j] * TEST_COUNT / 1024 / 1024) * 1000 / ((float)time_ms));
|
||||
}
|
||||
#endif
|
||||
memset(cdc_buffer, 0, 512);
|
||||
memset(cdc_buffer, 0x55, 4096);
|
||||
|
||||
const uint8_t data1[10] = { 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x08, 0x14 };
|
||||
|
||||
memcpy(cdc_buffer, data1, 10);
|
||||
usbh_bulk_urb_fill(&cdc_acm_class->bulkout_urb, cdc_acm_class->hport, cdc_acm_class->bulkout, cdc_buffer, 10, 3000, NULL, NULL);
|
||||
/* for common, we use timeout with 0xffffffff, this is just a test */
|
||||
usbh_bulk_urb_fill(&cdc_acm_class->bulkout_urb, cdc_acm_class->hport, cdc_acm_class->bulkout, cdc_buffer, sizeof(cdc_buffer), 3000, NULL, NULL);
|
||||
ret = usbh_submit_urb(&cdc_acm_class->bulkout_urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_RAW("bulk out error,ret:%d\r\n", ret);
|
||||
|
@ -110,6 +97,7 @@ static void usbh_cdc_acm_thread(void *argument)
|
|||
USB_LOG_RAW("send over:%d\r\n", cdc_acm_class->bulkout_urb.actual_length);
|
||||
}
|
||||
|
||||
/* we can change cdc_acm_class->bulkin->wMaxPacketSize with 4096 for testing zlp, default is ep mps */
|
||||
usbh_bulk_urb_fill(&cdc_acm_class->bulkin_urb, cdc_acm_class->hport, cdc_acm_class->bulkin, cdc_buffer, cdc_acm_class->bulkin->wMaxPacketSize, 0xffffffff, usbh_cdc_acm_callback, cdc_acm_class);
|
||||
ret = usbh_submit_urb(&cdc_acm_class->bulkin_urb);
|
||||
if (ret < 0) {
|
||||
|
@ -136,8 +124,10 @@ void usbh_hid_callback(void *arg, int nbytes)
|
|||
USB_LOG_RAW("0x%02x ", hid_buffer[i]);
|
||||
}
|
||||
USB_LOG_RAW("nbytes:%d\r\n", nbytes);
|
||||
usbh_int_urb_fill(&hid_class->intin_urb, hid_class->hport, hid_class->intin, hid_buffer, hid_class->intin->wMaxPacketSize, 0, usbh_hid_callback, hid_class);
|
||||
usbh_submit_urb(&hid_class->intin_urb);
|
||||
} else if (nbytes == -USB_ERR_NAK) { /* only dwc2 should do this */
|
||||
usbh_int_urb_fill(&hid_class->intin_urb, hid_class->hport, hid_class->intin, hid_buffer, hid_class->intin->wMaxPacketSize, 0, usbh_hid_callback, hid_class);
|
||||
usbh_submit_urb(&hid_class->intin_urb);
|
||||
} else {
|
||||
}
|
||||
|
@ -264,786 +254,6 @@ delete:
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void usbh_videostreaming_parse_mjpeg(struct usbh_urb *urb, struct usbh_videostreaming *stream)
|
||||
{
|
||||
struct usbh_iso_frame_packet *iso_packet;
|
||||
uint32_t num_of_iso_packets;
|
||||
uint8_t data_offset;
|
||||
uint32_t data_len;
|
||||
uint8_t header_len = 0;
|
||||
|
||||
num_of_iso_packets = urb->num_of_iso_packets;
|
||||
iso_packet = urb->iso_packet;
|
||||
|
||||
for (uint32_t i = 0; i < num_of_iso_packets; i++) {
|
||||
/*
|
||||
uint8_t frameIdentifier : 1U;
|
||||
uint8_t endOfFrame : 1U;
|
||||
uint8_t presentationTimeStamp : 1U;
|
||||
uint8_t sourceClockReference : 1U;
|
||||
uint8_t reserved : 1U;
|
||||
uint8_t stillImage : 1U;
|
||||
uint8_t errorBit : 1U;
|
||||
uint8_t endOfHeader : 1U;
|
||||
*/
|
||||
if (iso_packet[i].actual_length == 0) { /* skip no data */
|
||||
continue;
|
||||
}
|
||||
|
||||
header_len = iso_packet[i].transfer_buffer[0];
|
||||
|
||||
if ((header_len > 12) || (header_len == 0)) { /* do not be illegal */
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
if (iso_packet[i].transfer_buffer[1] & (1 << 6)) { /* error bit, re-receive */
|
||||
stream->bufoffset = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((stream->bufoffset == 0) && ((iso_packet[i].transfer_buffer[header_len] != 0xff) || (iso_packet[i].transfer_buffer[header_len + 1] != 0xd8))) {
|
||||
stream->bufoffset = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
data_offset = header_len;
|
||||
data_len = iso_packet[i].actual_length - header_len;
|
||||
|
||||
/** do something here */
|
||||
|
||||
stream->bufoffset += data_len;
|
||||
|
||||
if (iso_packet[i].transfer_buffer[1] & (1 << 1)) {
|
||||
if ((iso_packet[i].transfer_buffer[iso_packet[i].actual_length - 2] != 0xff) || (iso_packet[i].transfer_buffer[iso_packet[i].actual_length - 1] != 0xd9)) {
|
||||
stream->bufoffset = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
/** do something here */
|
||||
|
||||
if (stream->video_one_frame_callback) {
|
||||
stream->video_one_frame_callback(stream);
|
||||
}
|
||||
stream->bufoffset = 0;
|
||||
}
|
||||
}
|
||||
/** do something here */
|
||||
}
|
||||
|
||||
void usbh_videostreaming_parse_yuyv2(struct usbh_urb *urb, struct usbh_videostreaming *stream)
|
||||
{
|
||||
struct usbh_iso_frame_packet *iso_packet;
|
||||
uint32_t num_of_iso_packets;
|
||||
uint8_t data_offset;
|
||||
uint32_t data_len;
|
||||
uint8_t header_len = 0;
|
||||
|
||||
num_of_iso_packets = urb->num_of_iso_packets;
|
||||
iso_packet = urb->iso_packet;
|
||||
|
||||
for (uint32_t i = 0; i < num_of_iso_packets; i++) {
|
||||
/*
|
||||
uint8_t frameIdentifier : 1U;
|
||||
uint8_t endOfFrame : 1U;
|
||||
uint8_t presentationTimeStamp : 1U;
|
||||
uint8_t sourceClockReference : 1U;
|
||||
uint8_t reserved : 1U;
|
||||
uint8_t stillImage : 1U;
|
||||
uint8_t errorBit : 1U;
|
||||
uint8_t endOfHeader : 1U;
|
||||
*/
|
||||
|
||||
if (iso_packet[i].actual_length == 0) { /* skip no data */
|
||||
continue;
|
||||
}
|
||||
|
||||
header_len = iso_packet[i].transfer_buffer[0];
|
||||
|
||||
if ((header_len > 12) || (header_len == 0)) { /* do not be illegal */
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
if (iso_packet[i].transfer_buffer[1] & (1 << 6)) { /* error bit, re-receive */
|
||||
stream->bufoffset = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
data_offset = header_len;
|
||||
data_len = iso_packet[i].actual_length - header_len;
|
||||
|
||||
/** do something here */
|
||||
|
||||
stream->bufoffset += data_len;
|
||||
|
||||
if (iso_packet[i].transfer_buffer[1] & (1 << 1)) {
|
||||
/** do something here */
|
||||
|
||||
if (stream->video_one_frame_callback && (stream->bufoffset == stream->buflen)) {
|
||||
stream->video_one_frame_callback(stream);
|
||||
}
|
||||
stream->bufoffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** do something here */
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_CDC_ECM || TEST_USBH_CDC_NCM || TEST_USBH_CDC_RNDIS || TEST_USBH_ASIX || TEST_USBH_RTL8152
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#if LWIP_DHCP
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/prot/dhcp.h"
|
||||
#endif
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <netif/ethernetif.h>
|
||||
|
||||
#else
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#include "timers.h"
|
||||
|
||||
TimerHandle_t dhcp_handle;
|
||||
|
||||
static void dhcp_timeout(TimerHandle_t xTimer)
|
||||
{
|
||||
struct netif *netif = (struct netif *)pvTimerGetTimerID(xTimer);
|
||||
struct dhcp *dhcp;
|
||||
|
||||
if (netif_is_up(netif)) {
|
||||
dhcp = netif_dhcp_data(netif);
|
||||
|
||||
if (dhcp && (dhcp->state == DHCP_STATE_BOUND)) {
|
||||
USB_LOG_INFO("IPv4 Address : %s\r\n", ipaddr_ntoa(&netif->ip_addr));
|
||||
USB_LOG_INFO("IPv4 Subnet mask : %s\r\n", ipaddr_ntoa(&netif->netmask));
|
||||
USB_LOG_INFO("IPv4 Gateway : %s\r\n\r\n", ipaddr_ntoa(&netif->gw));
|
||||
|
||||
xTimerStop(xTimer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_CDC_ECM
|
||||
#include "usbh_cdc_ecm.h"
|
||||
|
||||
struct netif g_cdc_ecm_netif;
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
static struct eth_device cdc_ecm_dev;
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ecm_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_cdc_ecm *cdc_ecm_class = (struct usbh_cdc_ecm *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, cdc_ecm_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ecm_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
return usbh_cdc_ecm_linkoutput(NULL, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
static err_t usbh_cdc_ecm_if_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
netif->mtu = 1500;
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_UP;
|
||||
netif->state = NULL;
|
||||
netif->name[0] = 'E';
|
||||
netif->name[1] = 'X';
|
||||
netif->output = etharp_output;
|
||||
netif->linkoutput = usbh_cdc_ecm_linkoutput;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
memset(&cdc_ecm_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
cdc_ecm_dev.parent.control = rt_usbh_cdc_ecm_control;
|
||||
cdc_ecm_dev.eth_rx = NULL;
|
||||
cdc_ecm_dev.eth_tx = rt_usbh_cdc_ecm_eth_tx;
|
||||
cdc_ecm_dev.parent.user_data = cdc_ecm_class;
|
||||
|
||||
eth_device_init(&cdc_ecm_dev, "u0");
|
||||
eth_device_linkchange(&cdc_ecm_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, cdc_ecm_dev.netif);
|
||||
#else
|
||||
struct netif *netif = &g_cdc_ecm_netif;
|
||||
|
||||
netif->hwaddr_len = 6;
|
||||
memcpy(netif->hwaddr, cdc_ecm_class->mac, 6);
|
||||
|
||||
IP4_ADDR(&cdc_ecm_class->ipaddr, 0, 0, 0, 0);
|
||||
IP4_ADDR(&cdc_ecm_class->netmask, 0, 0, 0, 0);
|
||||
IP4_ADDR(&cdc_ecm_class->gateway, 0, 0, 0, 0);
|
||||
|
||||
netif = netif_add(netif, &cdc_ecm_class->ipaddr, &cdc_ecm_class->netmask, &cdc_ecm_class->gateway, NULL, usbh_cdc_ecm_if_init, tcpip_input);
|
||||
netif_set_default(netif);
|
||||
while (!netif_is_up(netif)) {
|
||||
}
|
||||
|
||||
dhcp_handle = xTimerCreate((const char *)"dhcp", (TickType_t)200, (UBaseType_t)pdTRUE, (void *const)netif, (TimerCallbackFunction_t)dhcp_timeout);
|
||||
if (dhcp_handle == NULL) {
|
||||
USB_LOG_ERR("timer creation failed! \r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, netif);
|
||||
#if LWIP_DHCP
|
||||
dhcp_start(netif);
|
||||
xTimerStart(dhcp_handle, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
eth_device_deinit(&cdc_ecm_dev);
|
||||
#else
|
||||
struct netif *netif = &g_cdc_ecm_netif;
|
||||
#if LWIP_DHCP
|
||||
dhcp_stop(netif);
|
||||
dhcp_cleanup(netif);
|
||||
xTimerStop(dhcp_handle, 0);
|
||||
xTimerDelete(dhcp_handle, 0);
|
||||
#endif
|
||||
netif_set_down(netif);
|
||||
netif_remove(netif);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_CDC_NCM
|
||||
#include "usbh_cdc_ncm.h"
|
||||
|
||||
struct netif g_cdc_ncm_netif;
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
static struct eth_device cdc_ncm_dev;
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ncm_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_cdc_ncm *cdc_ncm_class = (struct usbh_cdc_ncm *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, cdc_ncm_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ncm_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
return usbh_cdc_ncm_linkoutput(NULL, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
static err_t usbh_cdc_ncm_if_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
netif->mtu = 1500;
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_UP;
|
||||
netif->state = NULL;
|
||||
netif->name[0] = 'E';
|
||||
netif->name[1] = 'X';
|
||||
netif->output = etharp_output;
|
||||
netif->linkoutput = usbh_cdc_ncm_linkoutput;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
memset(&cdc_ncm_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
cdc_ncm_dev.parent.control = rt_usbh_cdc_ncm_control;
|
||||
cdc_ncm_dev.eth_rx = NULL;
|
||||
cdc_ncm_dev.eth_tx = rt_usbh_cdc_ncm_eth_tx;
|
||||
cdc_ncm_dev.parent.user_data = cdc_ncm_class;
|
||||
|
||||
eth_device_init(&cdc_ncm_dev, "u1");
|
||||
eth_device_linkchange(&cdc_ncm_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ncm_rx_thread, cdc_ncm_dev.netif);
|
||||
#else
|
||||
struct netif *netif = &g_cdc_ncm_netif;
|
||||
|
||||
netif->hwaddr_len = 6;
|
||||
memcpy(netif->hwaddr, cdc_ncm_class->mac, 6);
|
||||
|
||||
IP4_ADDR(&cdc_ncm_class->ipaddr, 0, 0, 0, 0);
|
||||
IP4_ADDR(&cdc_ncm_class->netmask, 0, 0, 0, 0);
|
||||
IP4_ADDR(&cdc_ncm_class->gateway, 0, 0, 0, 0);
|
||||
|
||||
netif = netif_add(netif, &cdc_ncm_class->ipaddr, &cdc_ncm_class->netmask, &cdc_ncm_class->gateway, NULL, usbh_cdc_ncm_if_init, tcpip_input);
|
||||
netif_set_default(netif);
|
||||
while (!netif_is_up(netif)) {
|
||||
}
|
||||
|
||||
dhcp_handle = xTimerCreate((const char *)"dhcp", (TickType_t)200, (UBaseType_t)pdTRUE, (void *const)netif, (TimerCallbackFunction_t)dhcp_timeout);
|
||||
if (dhcp_handle == NULL) {
|
||||
USB_LOG_ERR("timer creation failed! \r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ncm_rx_thread, netif);
|
||||
#if LWIP_DHCP
|
||||
dhcp_start(netif);
|
||||
xTimerStart(dhcp_handle, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
eth_device_deinit(&cdc_ncm_dev);
|
||||
#else
|
||||
struct netif *netif = &g_cdc_ncm_netif;
|
||||
#if LWIP_DHCP
|
||||
dhcp_stop(netif);
|
||||
dhcp_cleanup(netif);
|
||||
xTimerStop(dhcp_handle, 0);
|
||||
xTimerDelete(dhcp_handle, 0);
|
||||
#endif
|
||||
netif_set_down(netif);
|
||||
netif_remove(netif);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_CDC_RNDIS
|
||||
#include "usbh_rndis.h"
|
||||
|
||||
struct netif g_rndis_netif;
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
static struct eth_device rndis_dev;
|
||||
|
||||
static rt_timer_t keep_timer = RT_NULL;
|
||||
|
||||
static void rndis_dev_keepalive_timeout(void *parameter)
|
||||
{
|
||||
struct usbh_rndis *rndis_class = (struct usbh_rndis *)parameter;
|
||||
usbh_rndis_keepalive(rndis_class);
|
||||
}
|
||||
|
||||
static void timer_init(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
keep_timer = rt_timer_create("keep",
|
||||
rndis_dev_keepalive_timeout,
|
||||
rndis_class,
|
||||
5000,
|
||||
RT_TIMER_FLAG_PERIODIC |
|
||||
RT_TIMER_FLAG_SOFT_TIMER);
|
||||
|
||||
rt_timer_start(keep_timer);
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_rndis_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_rndis *rndis_class = (struct usbh_rndis *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, rndis_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_rndis_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
return usbh_rndis_linkoutput(NULL, p);
|
||||
}
|
||||
|
||||
#else
|
||||
TimerHandle_t timer_handle;
|
||||
|
||||
static void rndis_dev_keepalive_timeout(TimerHandle_t xTimer)
|
||||
{
|
||||
struct usbh_rndis *rndis_class = (struct usbh_rndis *)pvTimerGetTimerID(xTimer);
|
||||
usbh_rndis_keepalive(rndis_class);
|
||||
}
|
||||
|
||||
void timer_init(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
timer_handle = xTimerCreate((const char *)NULL, (TickType_t)5000, (UBaseType_t)pdTRUE, (void *const)rndis_class, (TimerCallbackFunction_t)rndis_dev_keepalive_timeout);
|
||||
if (NULL != timer_handle) {
|
||||
xTimerStart(timer_handle, 0);
|
||||
} else {
|
||||
USB_LOG_ERR("timer creation failed! \r\n");
|
||||
for (;;) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static err_t usbh_rndis_if_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
netif->mtu = 1500;
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_UP;
|
||||
netif->state = NULL;
|
||||
netif->name[0] = 'E';
|
||||
netif->name[1] = 'X';
|
||||
netif->output = etharp_output;
|
||||
netif->linkoutput = usbh_rndis_linkoutput;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void usbh_rndis_run(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
memset(&rndis_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
rndis_dev.parent.control = rt_usbh_rndis_control;
|
||||
rndis_dev.eth_rx = NULL;
|
||||
rndis_dev.eth_tx = rt_usbh_rndis_eth_tx;
|
||||
rndis_dev.parent.user_data = rndis_class;
|
||||
|
||||
eth_device_init(&rndis_dev, "u2");
|
||||
eth_device_linkchange(&rndis_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, rndis_dev.netif);
|
||||
//timer_init(rndis_class);
|
||||
#else
|
||||
struct netif *netif = &g_rndis_netif;
|
||||
|
||||
netif->hwaddr_len = 6;
|
||||
memcpy(netif->hwaddr, rndis_class->mac, 6);
|
||||
|
||||
IP4_ADDR(&rndis_class->ipaddr, 0, 0, 0, 0);
|
||||
IP4_ADDR(&rndis_class->netmask, 0, 0, 0, 0);
|
||||
IP4_ADDR(&rndis_class->gateway, 0, 0, 0, 0);
|
||||
|
||||
netif = netif_add(netif, &rndis_class->ipaddr, &rndis_class->netmask, &rndis_class->gateway, NULL, usbh_rndis_if_init, tcpip_input);
|
||||
netif_set_default(netif);
|
||||
while (!netif_is_up(netif)) {
|
||||
}
|
||||
|
||||
dhcp_handle = xTimerCreate((const char *)"dhcp2", (TickType_t)200, (UBaseType_t)pdTRUE, (void *const)netif, (TimerCallbackFunction_t)dhcp_timeout);
|
||||
if (dhcp_handle == NULL) {
|
||||
USB_LOG_ERR("timer creation failed! \r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, netif);
|
||||
//timer_init(rndis_class);
|
||||
|
||||
#if LWIP_DHCP
|
||||
dhcp_start(netif);
|
||||
xTimerStart(dhcp_handle, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void usbh_rndis_stop(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
eth_device_deinit(&rndis_dev);
|
||||
// rt_timer_stop(keep_timer);
|
||||
// rt_timer_delete(keep_timer);
|
||||
#else
|
||||
struct netif *netif = &g_rndis_netif;
|
||||
#if LWIP_DHCP
|
||||
dhcp_stop(netif);
|
||||
dhcp_cleanup(netif);
|
||||
xTimerStop(dhcp_handle, 0);
|
||||
xTimerDelete(dhcp_handle, 0);
|
||||
#endif
|
||||
netif_set_down(netif);
|
||||
netif_remove(netif);
|
||||
// xTimerStop(timer_handle, 0);
|
||||
// xTimerDelete(timer_handle, 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_ASIX
|
||||
#include "usbh_asix.h"
|
||||
|
||||
struct netif g_asix_netif;
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
static struct eth_device asix_dev;
|
||||
|
||||
static rt_err_t rt_usbh_asix_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_asix *asix_class = (struct usbh_asix *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, asix_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_asix_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
return usbh_asix_linkoutput(NULL, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
static err_t usbh_asix_if_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
netif->mtu = 1500;
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_UP;
|
||||
netif->state = NULL;
|
||||
netif->name[0] = 'E';
|
||||
netif->name[1] = 'X';
|
||||
netif->output = etharp_output;
|
||||
netif->linkoutput = usbh_asix_linkoutput;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void usbh_asix_run(struct usbh_asix *asix_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
memset(&asix_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
asix_dev.parent.control = rt_usbh_asix_control;
|
||||
asix_dev.eth_rx = NULL;
|
||||
asix_dev.eth_tx = rt_usbh_asix_eth_tx;
|
||||
asix_dev.parent.user_data = asix_class;
|
||||
|
||||
eth_device_init(&asix_dev, "u3");
|
||||
eth_device_linkchange(&asix_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_asix_rx_thread, asix_dev.netif);
|
||||
#else
|
||||
struct netif *netif = &g_asix_netif;
|
||||
|
||||
netif->hwaddr_len = 6;
|
||||
memcpy(netif->hwaddr, asix_class->mac, 6);
|
||||
|
||||
IP4_ADDR(&asix_class->ipaddr, 0, 0, 0, 0);
|
||||
IP4_ADDR(&asix_class->netmask, 0, 0, 0, 0);
|
||||
IP4_ADDR(&asix_class->gateway, 0, 0, 0, 0);
|
||||
|
||||
netif = netif_add(netif, &asix_class->ipaddr, &asix_class->netmask, &asix_class->gateway, NULL, usbh_asix_if_init, tcpip_input);
|
||||
netif_set_default(netif);
|
||||
while (!netif_is_up(netif)) {
|
||||
}
|
||||
|
||||
dhcp_handle = xTimerCreate((const char *)"dhcp", (TickType_t)200, (UBaseType_t)pdTRUE, (void *const)netif, (TimerCallbackFunction_t)dhcp_timeout);
|
||||
if (dhcp_handle == NULL) {
|
||||
USB_LOG_ERR("timer creation failed! \r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_asix_rx_thread, netif);
|
||||
#if LWIP_DHCP
|
||||
dhcp_start(netif);
|
||||
xTimerStart(dhcp_handle, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void usbh_asix_stop(struct usbh_asix *asix_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
eth_device_deinit(&asix_dev);
|
||||
#else
|
||||
struct netif *netif = &g_asix_netif;
|
||||
#if LWIP_DHCP
|
||||
dhcp_stop(netif);
|
||||
dhcp_cleanup(netif);
|
||||
xTimerStop(dhcp_handle, 0);
|
||||
xTimerDelete(dhcp_handle, 0);
|
||||
#endif
|
||||
netif_set_down(netif);
|
||||
netif_remove(netif);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_RTL8152
|
||||
#include "usbh_rtl8152.h"
|
||||
|
||||
struct netif g_rtl8152_netif;
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
static struct eth_device rtl8152_dev;
|
||||
|
||||
static rt_err_t rt_usbh_rtl8152_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_rtl8152 *rtl8152_class = (struct usbh_rtl8152 *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, rtl8152_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_rtl8152_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
return usbh_rtl8152_linkoutput(NULL, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
static err_t usbh_rtl8152_if_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
netif->mtu = 1500;
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_UP;
|
||||
netif->state = NULL;
|
||||
netif->name[0] = 'E';
|
||||
netif->name[1] = 'X';
|
||||
netif->output = etharp_output;
|
||||
netif->linkoutput = usbh_rtl8152_linkoutput;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
memset(&rtl8152_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
rtl8152_dev.parent.control = rt_usbh_rtl8152_control;
|
||||
rtl8152_dev.eth_rx = NULL;
|
||||
rtl8152_dev.eth_tx = rt_usbh_rtl8152_eth_tx;
|
||||
rtl8152_dev.parent.user_data = rtl8152_class;
|
||||
|
||||
eth_device_init(&rtl8152_dev, "u4");
|
||||
eth_device_linkchange(&rtl8152_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rtl8152_rx_thread, rtl8152_dev.netif);
|
||||
#else
|
||||
struct netif *netif = &g_rtl8152_netif;
|
||||
|
||||
netif->hwaddr_len = 6;
|
||||
memcpy(netif->hwaddr, rtl8152_class->mac, 6);
|
||||
|
||||
IP4_ADDR(&rtl8152_class->ipaddr, 0, 0, 0, 0);
|
||||
IP4_ADDR(&rtl8152_class->netmask, 0, 0, 0, 0);
|
||||
IP4_ADDR(&rtl8152_class->gateway, 0, 0, 0, 0);
|
||||
|
||||
netif = netif_add(netif, &rtl8152_class->ipaddr, &rtl8152_class->netmask, &rtl8152_class->gateway, NULL, usbh_rtl8152_if_init, tcpip_input);
|
||||
netif_set_default(netif);
|
||||
while (!netif_is_up(netif)) {
|
||||
}
|
||||
|
||||
dhcp_handle = xTimerCreate((const char *)"dhcp", (TickType_t)200, (UBaseType_t)pdTRUE, (void *const)netif, (TimerCallbackFunction_t)dhcp_timeout);
|
||||
if (dhcp_handle == NULL) {
|
||||
USB_LOG_ERR("timer creation failed! \r\n");
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rtl8152_rx_thread, netif);
|
||||
#if LWIP_DHCP
|
||||
dhcp_start(netif);
|
||||
xTimerStart(dhcp_handle, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
eth_device_deinit(&rtl8152_dev);
|
||||
#else
|
||||
struct netif *netif = &g_rtl8152_netif;
|
||||
#if LWIP_DHCP
|
||||
dhcp_stop(netif);
|
||||
dhcp_cleanup(netif);
|
||||
xTimerStop(dhcp_handle, 0);
|
||||
xTimerDelete(dhcp_handle, 0);
|
||||
#endif
|
||||
netif_set_down(netif);
|
||||
netif_remove(netif);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void usbh_cdc_acm_run(struct usbh_cdc_acm *cdc_acm_class)
|
||||
{
|
||||
#if TEST_USBH_CDC_ACM
|
||||
|
@ -1066,7 +276,6 @@ void usbh_hid_stop(struct usbh_hid *hid_class)
|
|||
{
|
||||
}
|
||||
|
||||
#ifndef __RTTHREAD__
|
||||
void usbh_msc_run(struct usbh_msc *msc_class)
|
||||
{
|
||||
#if TEST_USBH_MSC
|
||||
|
@ -1077,24 +286,11 @@ void usbh_msc_run(struct usbh_msc *msc_class)
|
|||
void usbh_msc_stop(struct usbh_msc *msc_class)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_AUDIO
|
||||
#error "if you want to use iso, please contact with me"
|
||||
#error "commercial charge"
|
||||
#endif
|
||||
|
||||
#if TEST_USBH_VIDEO
|
||||
#error "if you want to use iso, please contact with me"
|
||||
#error "commercial charge"
|
||||
#endif
|
||||
|
||||
void usbh_class_test(void)
|
||||
{
|
||||
#ifdef __RTTHREAD__
|
||||
/* do nothing */
|
||||
#else
|
||||
#if TEST_USBH_CDC_ECM || TEST_USBH_CDC_NCM || TEST_USBH_CDC_RNDIS || TEST_USBH_ASIX || TEST_USBH_RTL8152
|
||||
/* Initialize the LwIP stack */
|
||||
tcpip_init(NULL, NULL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,513 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_video.h"
|
||||
#include "usbd_audio.h"
|
||||
#include "usbd_hid.h"
|
||||
#include "cherryusb_mjpeg.h"
|
||||
|
||||
#define VIDEO_IN_EP 0x81
|
||||
#define VIDEO_INT_EP 0x86
|
||||
|
||||
#ifdef CONFIG_USB_HS
|
||||
#define MAX_PAYLOAD_SIZE 1024 // for high speed with one transcations every one micro frame
|
||||
#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
|
||||
|
||||
// #define MAX_PAYLOAD_SIZE 2048 // for high speed with two transcations every one micro frame
|
||||
// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 2)) | (0x01 << 11))
|
||||
|
||||
// #define MAX_PAYLOAD_SIZE 3072 // for high speed with three transcations every one micro frame
|
||||
// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 3)) | (0x02 << 11))
|
||||
|
||||
#else
|
||||
#define MAX_PAYLOAD_SIZE 1020
|
||||
#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
|
||||
#endif
|
||||
|
||||
#define WIDTH (unsigned int)(640)
|
||||
#define HEIGHT (unsigned int)(480)
|
||||
|
||||
#define CAM_FPS (30)
|
||||
#define INTERVAL (unsigned long)(10000000 / CAM_FPS)
|
||||
#define MIN_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS) //16 bit
|
||||
#define MAX_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS)
|
||||
#define MAX_FRAME_SIZE (unsigned long)(WIDTH * HEIGHT * 2)
|
||||
|
||||
#define VS_HEADER_SIZ (unsigned int)(VIDEO_SIZEOF_VS_INPUT_HEADER_DESC(1, 1) + VIDEO_SIZEOF_VS_FORMAT_MJPEG_DESC + VIDEO_SIZEOF_VS_FRAME_MJPEG_DESC(1))
|
||||
|
||||
#define USB_VIDEO_DESC_SIZ (unsigned long)(9 + \
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_LEN + \
|
||||
9 + \
|
||||
VS_HEADER_SIZ + \
|
||||
9 + \
|
||||
7 + \
|
||||
AUDIO_AC_DESCRIPTOR_INIT_LEN(2) + \
|
||||
AUDIO_SIZEOF_AC_INPUT_TERMINAL_DESC + \
|
||||
AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(2, 1) + \
|
||||
AUDIO_SIZEOF_AC_OUTPUT_TERMINAL_DESC + \
|
||||
AUDIO_SIZEOF_AC_INPUT_TERMINAL_DESC + \
|
||||
AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(2, 1) + \
|
||||
AUDIO_SIZEOF_AC_OUTPUT_TERMINAL_DESC + \
|
||||
AUDIO_AS_DESCRIPTOR_INIT_LEN(1) + \
|
||||
AUDIO_AS_DESCRIPTOR_INIT_LEN(1) + \
|
||||
25)
|
||||
|
||||
#define USBD_VID 0xffff
|
||||
#define USBD_PID 0xffff
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
#ifdef CONFIG_USB_HS
|
||||
#define EP_INTERVAL 0x04
|
||||
#else
|
||||
#define EP_INTERVAL 0x01
|
||||
#endif
|
||||
|
||||
#define AUDIO_IN_EP 0x82
|
||||
#define AUDIO_OUT_EP 0x03
|
||||
|
||||
#define AUDIO_IN_FU_ID 0x02
|
||||
#define AUDIO_OUT_FU_ID 0x05
|
||||
|
||||
/* AUDIO Class Config */
|
||||
#define AUDIO_SPEAKER_FREQ 16000U
|
||||
#define AUDIO_SPEAKER_FRAME_SIZE_BYTE 2u
|
||||
#define AUDIO_SPEAKER_RESOLUTION_BIT 16u
|
||||
#define AUDIO_MIC_FREQ 16000U
|
||||
#define AUDIO_MIC_FRAME_SIZE_BYTE 2u
|
||||
#define AUDIO_MIC_RESOLUTION_BIT 16u
|
||||
|
||||
#define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16))
|
||||
|
||||
/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
|
||||
#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_SPEAKER_FREQ * AUDIO_SPEAKER_FRAME_SIZE_BYTE * 2) / 1000))
|
||||
/* 16bit(2 Bytes) 双声道(Mono:2) */
|
||||
#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_MIC_FREQ * AUDIO_MIC_FRAME_SIZE_BYTE * 2) / 1000))
|
||||
|
||||
#define AUDIO_AC_SIZ (AUDIO_SIZEOF_AC_HEADER_DESC(2) + \
|
||||
AUDIO_SIZEOF_AC_INPUT_TERMINAL_DESC + \
|
||||
AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(2, 1) + \
|
||||
AUDIO_SIZEOF_AC_OUTPUT_TERMINAL_DESC + \
|
||||
AUDIO_SIZEOF_AC_INPUT_TERMINAL_DESC + \
|
||||
AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(2, 1) + \
|
||||
AUDIO_SIZEOF_AC_OUTPUT_TERMINAL_DESC)
|
||||
|
||||
#define HID_INT_EP 0x84
|
||||
#define HID_INT_EP_SIZE 8
|
||||
#define HID_INT_EP_INTERVAL 10
|
||||
|
||||
#define HID_KEYBOARD_REPORT_DESC_SIZE 63
|
||||
|
||||
const uint8_t video_audio_hid_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xef, 0x02, 0x01, USBD_VID, USBD_PID, 0x0001, 0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_VIDEO_DESC_SIZ, 0x06, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
||||
//VIDEO_VC_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x00, 0x00),
|
||||
VIDEO_VS_INPUT_HEADER_DESCRIPTOR_INIT(0x01, VS_HEADER_SIZ, VIDEO_IN_EP, 0x00),
|
||||
VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_INIT(0x01, 0x01),
|
||||
VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, DBVAL(INTERVAL), 0x01, DBVAL(INTERVAL)),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x01, 0x01),
|
||||
/* 1.2.2.2 Standard VideoStream Isochronous Video Data Endpoint Descriptor */
|
||||
USB_ENDPOINT_DESCRIPTOR_INIT(VIDEO_IN_EP, 0x05, VIDEO_PACKET_SIZE, 0x01),
|
||||
AUDIO_AC_DESCRIPTOR_INIT(0x02, 0x03, AUDIO_AC_SIZ, 0x00, 0x03, 0x04),
|
||||
AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x01, AUDIO_INTERM_MIC, 0x02, 0x0003),
|
||||
AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x02, 0x01, 0x01, 0x03, 0x00, 0x00),
|
||||
AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x03, AUDIO_TERMINAL_STREAMING, 0x02),
|
||||
AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x04, AUDIO_TERMINAL_STREAMING, 0x02, 0x0003),
|
||||
AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x05, 0x04, 0x01, 0x03, 0x00, 0x00),
|
||||
AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x06, AUDIO_OUTTERM_SPEAKER, 0x05),
|
||||
AUDIO_AS_DESCRIPTOR_INIT(0x03, 0x04, 0x02, AUDIO_SPEAKER_FRAME_SIZE_BYTE, AUDIO_SPEAKER_RESOLUTION_BIT, AUDIO_OUT_EP, 0x09, AUDIO_OUT_PACKET,
|
||||
EP_INTERVAL, AUDIO_SAMPLE_FREQ_3B(AUDIO_SPEAKER_FREQ)),
|
||||
AUDIO_AS_DESCRIPTOR_INIT(0x04, 0x03, 0x02, AUDIO_MIC_FRAME_SIZE_BYTE, AUDIO_MIC_RESOLUTION_BIT, AUDIO_IN_EP, 0x05, AUDIO_IN_PACKET,
|
||||
EP_INTERVAL, AUDIO_SAMPLE_FREQ_3B(AUDIO_MIC_FREQ)),
|
||||
/************** Descriptor of Joystick Mouse interface ****************/
|
||||
/* 09 */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */
|
||||
0x05, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x01, /* bNumEndpoints */
|
||||
0x03, /* bInterfaceClass: HID */
|
||||
0x01, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
|
||||
0x01, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
|
||||
0, /* iInterface: Index of string descriptor */
|
||||
/******************** Descriptor of Joystick Mouse HID ********************/
|
||||
/* 18 */
|
||||
0x09, /* bLength: HID Descriptor size */
|
||||
HID_DESCRIPTOR_TYPE_HID, /* bDescriptorType: HID */
|
||||
0x11, /* bcdHID: HID Class Spec release number */
|
||||
0x01,
|
||||
0x00, /* bCountryCode: Hardware target country */
|
||||
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
|
||||
0x22, /* bDescriptorType */
|
||||
HID_KEYBOARD_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
|
||||
0x00,
|
||||
/******************** Descriptor of Mouse endpoint ********************/
|
||||
/* 27 */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType: */
|
||||
HID_INT_EP, /* bEndpointAddress: Endpoint Address (IN) */
|
||||
0x03, /* bmAttributes: Interrupt endpoint */
|
||||
HID_INT_EP_SIZE, /* wMaxPacketSize: 4 Byte max */
|
||||
0x00,
|
||||
HID_INT_EP_INTERVAL, /* bInterval: Polling Interval */
|
||||
/* 34 */
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
///////////////////////////////////////
|
||||
USB_LANGID_INIT(USBD_LANGID_STRING),
|
||||
///////////////////////////////////////
|
||||
/// string1 descriptor
|
||||
///////////////////////////////////////
|
||||
0x14, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'C', 0x00, /* wcChar0 */
|
||||
'h', 0x00, /* wcChar1 */
|
||||
'e', 0x00, /* wcChar2 */
|
||||
'r', 0x00, /* wcChar3 */
|
||||
'r', 0x00, /* wcChar4 */
|
||||
'y', 0x00, /* wcChar5 */
|
||||
'U', 0x00, /* wcChar6 */
|
||||
'S', 0x00, /* wcChar7 */
|
||||
'B', 0x00, /* wcChar8 */
|
||||
///////////////////////////////////////
|
||||
/// string2 descriptor
|
||||
///////////////////////////////////////
|
||||
0x26, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'C', 0x00, /* wcChar0 */
|
||||
'h', 0x00, /* wcChar1 */
|
||||
'e', 0x00, /* wcChar2 */
|
||||
'r', 0x00, /* wcChar3 */
|
||||
'r', 0x00, /* wcChar4 */
|
||||
'y', 0x00, /* wcChar5 */
|
||||
'U', 0x00, /* wcChar6 */
|
||||
'S', 0x00, /* wcChar7 */
|
||||
'B', 0x00, /* wcChar8 */
|
||||
' ', 0x00, /* wcChar9 */
|
||||
'U', 0x00, /* wcChar10 */
|
||||
'A', 0x00, /* wcChar11 */
|
||||
'C', 0x00, /* wcChar12 */
|
||||
' ', 0x00, /* wcChar13 */
|
||||
'D', 0x00, /* wcChar14 */
|
||||
'E', 0x00, /* wcChar15 */
|
||||
'M', 0x00, /* wcChar16 */
|
||||
'O', 0x00, /* wcChar17 */
|
||||
///////////////////////////////////////
|
||||
/// string3 descriptor
|
||||
///////////////////////////////////////
|
||||
0x16, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'2', 0x00, /* wcChar0 */
|
||||
'0', 0x00, /* wcChar1 */
|
||||
'2', 0x00, /* wcChar2 */
|
||||
'4', 0x00, /* wcChar3 */
|
||||
'0', 0x00, /* wcChar4 */
|
||||
'3', 0x00, /* wcChar5 */
|
||||
'1', 0x00, /* wcChar6 */
|
||||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
0x0a,
|
||||
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
static const uint8_t hid_keyboard_report_desc[HID_KEYBOARD_REPORT_DESC_SIZE] = {
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x06, // USAGE (Keyboard)
|
||||
0xa1, 0x01, // COLLECTION (Application)
|
||||
0x05, 0x07, // USAGE_PAGE (Keyboard)
|
||||
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
|
||||
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x95, 0x08, // REPORT_COUNT (8)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
0x95, 0x01, // REPORT_COUNT (1)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
||||
0x95, 0x05, // REPORT_COUNT (5)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x05, 0x08, // USAGE_PAGE (LEDs)
|
||||
0x19, 0x01, // USAGE_MINIMUM (Num Lock)
|
||||
0x29, 0x05, // USAGE_MAXIMUM (Kana)
|
||||
0x91, 0x02, // OUTPUT (Data,Var,Abs)
|
||||
0x95, 0x01, // REPORT_COUNT (1)
|
||||
0x75, 0x03, // REPORT_SIZE (3)
|
||||
0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
|
||||
0x95, 0x06, // REPORT_COUNT (6)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0xFF, // LOGICAL_MAXIMUM (255)
|
||||
0x05, 0x07, // USAGE_PAGE (Keyboard)
|
||||
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
|
||||
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
|
||||
0x81, 0x00, // INPUT (Data,Ary,Abs)
|
||||
0xc0 // END_COLLECTION
|
||||
};
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t audio_read_buffer[AUDIO_OUT_PACKET];
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t audio_write_buffer[AUDIO_IN_PACKET];
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t video_packet_buffer[40 * 1024];
|
||||
|
||||
volatile bool video_tx_flag = 0;
|
||||
volatile bool audio_tx_flag = 0;
|
||||
volatile bool audio_rx_flag = 0;
|
||||
volatile bool video_iso_tx_busy = false;
|
||||
volatile bool audio_iso_tx_busy = false;
|
||||
|
||||
#define HID_STATE_IDLE 0
|
||||
#define HID_STATE_BUSY 1
|
||||
|
||||
/*!< hid state ! Data can be sent only when state is idle */
|
||||
static volatile uint8_t hid_state = HID_STATE_IDLE;
|
||||
|
||||
static void usbd_event_handler(uint8_t busid, uint8_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case USBD_EVENT_RESET:
|
||||
break;
|
||||
case USBD_EVENT_CONNECTED:
|
||||
break;
|
||||
case USBD_EVENT_DISCONNECTED:
|
||||
break;
|
||||
case USBD_EVENT_RESUME:
|
||||
break;
|
||||
case USBD_EVENT_SUSPEND:
|
||||
break;
|
||||
case USBD_EVENT_CONFIGURED:
|
||||
video_tx_flag = 0;
|
||||
audio_tx_flag = 0;
|
||||
audio_rx_flag = 0;
|
||||
video_iso_tx_busy = false;
|
||||
audio_iso_tx_busy = false;
|
||||
hid_state = HID_STATE_IDLE;
|
||||
break;
|
||||
case USBD_EVENT_SET_REMOTE_WAKEUP:
|
||||
break;
|
||||
case USBD_EVENT_CLR_REMOTE_WAKEUP:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_video_open(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
if (intf == 1) {
|
||||
video_tx_flag = 1;
|
||||
USB_LOG_RAW("OPEN\r\n");
|
||||
video_iso_tx_busy = false;
|
||||
}
|
||||
}
|
||||
void usbd_video_close(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
if (intf == 1) {
|
||||
USB_LOG_RAW("CLOSE\r\n");
|
||||
video_tx_flag = 0;
|
||||
video_iso_tx_busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_video_iso_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
//USB_LOG_RAW("actual in len:%d\r\n", nbytes);
|
||||
video_iso_tx_busy = false;
|
||||
}
|
||||
|
||||
static struct usbd_endpoint video_in_ep = {
|
||||
.ep_cb = usbd_video_iso_callback,
|
||||
.ep_addr = VIDEO_IN_EP
|
||||
};
|
||||
|
||||
void usbd_audio_open(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
if (intf == 3) {
|
||||
audio_rx_flag = 1;
|
||||
/* setup first out ep read transfer */
|
||||
usbd_ep_start_read(busid, AUDIO_OUT_EP, audio_read_buffer, AUDIO_OUT_PACKET);
|
||||
printf("OPEN1\r\n");
|
||||
} else if (intf == 4) {
|
||||
audio_tx_flag = 1;
|
||||
audio_iso_tx_busy = false;
|
||||
printf("OPEN2\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_audio_close(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
if (intf == 3) {
|
||||
audio_rx_flag = 0;
|
||||
printf("CLOSE1\r\n");
|
||||
} else if (intf == 4) {
|
||||
audio_tx_flag = 0;
|
||||
audio_iso_tx_busy = false;
|
||||
printf("CLOSE2\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_audio_out_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
USB_LOG_RAW("actual out len:%d\r\n", nbytes);
|
||||
usbd_ep_start_read(busid, AUDIO_OUT_EP, audio_read_buffer, AUDIO_OUT_PACKET);
|
||||
}
|
||||
|
||||
void usbd_audio_in_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
USB_LOG_RAW("actual in len:%d\r\n", nbytes);
|
||||
audio_iso_tx_busy = false;
|
||||
}
|
||||
|
||||
static struct usbd_endpoint audio_in_ep = {
|
||||
.ep_cb = usbd_audio_in_callback,
|
||||
.ep_addr = AUDIO_IN_EP
|
||||
};
|
||||
|
||||
static struct usbd_endpoint audio_out_ep = {
|
||||
.ep_cb = usbd_audio_out_callback,
|
||||
.ep_addr = AUDIO_OUT_EP
|
||||
};
|
||||
|
||||
void usbd_hid_int_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
hid_state = HID_STATE_IDLE;
|
||||
}
|
||||
|
||||
static struct usbd_endpoint hid_in_ep = {
|
||||
.ep_cb = usbd_hid_int_callback,
|
||||
.ep_addr = HID_INT_EP
|
||||
};
|
||||
|
||||
struct usbd_interface intf0;
|
||||
struct usbd_interface intf1;
|
||||
|
||||
struct usbd_interface intf2;
|
||||
struct usbd_interface intf3;
|
||||
struct usbd_interface intf4;
|
||||
|
||||
struct usbd_interface intf5;
|
||||
|
||||
struct audio_entity_info audio_entity_table[] = {
|
||||
{ .bEntityId = AUDIO_IN_FU_ID,
|
||||
.bDescriptorSubtype = AUDIO_CONTROL_FEATURE_UNIT,
|
||||
.ep = AUDIO_IN_EP },
|
||||
{ .bEntityId = AUDIO_OUT_FU_ID,
|
||||
.bDescriptorSubtype = AUDIO_CONTROL_FEATURE_UNIT,
|
||||
.ep = AUDIO_OUT_EP },
|
||||
};
|
||||
|
||||
void composite_init(uint8_t busid, uint32_t reg_base)
|
||||
{
|
||||
usbd_desc_register(busid, video_audio_hid_descriptor);
|
||||
usbd_add_interface(busid, usbd_video_init_intf(busid, &intf0, INTERVAL, MAX_FRAME_SIZE, MAX_PAYLOAD_SIZE));
|
||||
usbd_add_interface(busid, usbd_video_init_intf(busid, &intf1, INTERVAL, MAX_FRAME_SIZE, MAX_PAYLOAD_SIZE));
|
||||
usbd_add_endpoint(busid, &video_in_ep);
|
||||
|
||||
usbd_add_interface(busid, usbd_audio_init_intf(busid, &intf2, 0x0100, audio_entity_table, 2));
|
||||
usbd_add_interface(busid, usbd_audio_init_intf(busid, &intf3, 0x0100, audio_entity_table, 2));
|
||||
usbd_add_interface(busid, usbd_audio_init_intf(busid, &intf4, 0x0100, audio_entity_table, 2));
|
||||
usbd_add_endpoint(busid, &audio_in_ep);
|
||||
usbd_add_endpoint(busid, &audio_out_ep);
|
||||
|
||||
usbd_add_interface(busid, usbd_hid_init_intf(busid, &intf0, hid_keyboard_report_desc, HID_KEYBOARD_REPORT_DESC_SIZE));
|
||||
usbd_add_endpoint(busid, &hid_in_ep);
|
||||
|
||||
usbd_initialize(busid, reg_base, usbd_event_handler);
|
||||
}
|
||||
|
||||
/* just for test, rewrite by yourself */
|
||||
void audio_test(uint8_t busid)
|
||||
{
|
||||
while (1) {
|
||||
if (audio_tx_flag) {
|
||||
memset(audio_write_buffer, 'a', AUDIO_IN_PACKET);
|
||||
audio_iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, AUDIO_IN_EP, audio_write_buffer, AUDIO_IN_PACKET);
|
||||
while (audio_iso_tx_busy) {
|
||||
if (audio_tx_flag == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t hid_write_buffer[64];
|
||||
|
||||
void hid_keyboard_test(uint8_t busid)
|
||||
{
|
||||
const uint8_t sendbuffer[8] = { 0x00, 0x00, HID_KBD_USAGE_A, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
memcpy(hid_write_buffer, sendbuffer, 8);
|
||||
int ret = usbd_ep_start_write(busid, HID_INT_EP, hid_write_buffer, 8);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
hid_state = HID_STATE_BUSY;
|
||||
while (hid_state == HID_STATE_BUSY) {
|
||||
}
|
||||
}
|
||||
|
||||
void video_test(uint8_t busid)
|
||||
{
|
||||
uint32_t out_len;
|
||||
uint32_t packets;
|
||||
|
||||
(void)packets;
|
||||
memset(video_packet_buffer, 0, 40 * 1024);
|
||||
while (1) {
|
||||
if (video_tx_flag) {
|
||||
packets = usbd_video_payload_fill(busid, (uint8_t *)cherryusb_mjpeg, sizeof(cherryusb_mjpeg), video_packet_buffer, &out_len);
|
||||
#if 1
|
||||
video_iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, video_packet_buffer, out_len);
|
||||
while (video_iso_tx_busy) {
|
||||
if (video_tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* dwc2 must use this method */
|
||||
for (uint32_t i = 0; i < packets; i++) {
|
||||
if (i == (packets - 1)) {
|
||||
video_iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, &video_packet_buffer[i * MAX_PAYLOAD_SIZE], out_len - (packets - 1) * MAX_PAYLOAD_SIZE);
|
||||
while (video_iso_tx_busy) {
|
||||
if (video_tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
video_iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, &video_packet_buffer[i * MAX_PAYLOAD_SIZE], MAX_PAYLOAD_SIZE);
|
||||
while (video_iso_tx_busy) {
|
||||
if (video_tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_video.h"
|
||||
#include "cherryusb_h264.h"
|
||||
|
||||
#define VIDEO_IN_EP 0x81
|
||||
#define VIDEO_INT_EP 0x83
|
||||
|
||||
#ifdef CONFIG_USB_HS
|
||||
#define MAX_PAYLOAD_SIZE 1024 // for high speed with one transcations every one micro frame
|
||||
#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
|
||||
|
||||
// #define MAX_PAYLOAD_SIZE 2048 // for high speed with two transcations every one micro frame
|
||||
// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 2)) | (0x01 << 11))
|
||||
|
||||
// #define MAX_PAYLOAD_SIZE 3072 // for high speed with three transcations every one micro frame
|
||||
// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 3)) | (0x02 << 11))
|
||||
|
||||
#else
|
||||
#define MAX_PAYLOAD_SIZE 1020
|
||||
#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
|
||||
#endif
|
||||
|
||||
#define WIDTH (unsigned int)(640)
|
||||
#define HEIGHT (unsigned int)(480)
|
||||
|
||||
#define CAM_FPS (30)
|
||||
#define INTERVAL (unsigned long)(10000000 / CAM_FPS)
|
||||
#define MIN_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS) //16 bit
|
||||
#define MAX_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS)
|
||||
#define MAX_FRAME_SIZE (unsigned long)(WIDTH * HEIGHT * 2)
|
||||
|
||||
#define VS_HEADER_SIZ (unsigned int)(VIDEO_SIZEOF_VS_INPUT_HEADER_DESC(1,1) + VIDEO_SIZEOF_VS_FORMAT_H264_DESC + VIDEO_SIZEOF_VS_FRAME_H264_DESC(1))
|
||||
|
||||
#define USB_VIDEO_DESC_SIZ (unsigned long)(9 + \
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_LEN + \
|
||||
9 + \
|
||||
VS_HEADER_SIZ + \
|
||||
9 + \
|
||||
7)
|
||||
|
||||
#define USBD_VID 0xffff
|
||||
#define USBD_PID 0xffff
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
const uint8_t video_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xef, 0x02, 0x01, USBD_VID, USBD_PID, 0x0001, 0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_VIDEO_DESC_SIZ, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
||||
//VIDEO_VC_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x00, 0x00),
|
||||
VIDEO_VS_INPUT_HEADER_DESCRIPTOR_INIT(0x01, VS_HEADER_SIZ, VIDEO_IN_EP, 0x00),
|
||||
VIDEO_VS_FORMAT_H264_DESCRIPTOR_INIT(0x01, 0x01),
|
||||
VIDEO_VS_FRAME_H264_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, DBVAL(INTERVAL), 0x01, DBVAL(INTERVAL)),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x01, 0x01),
|
||||
/* 1.2.2.2 Standard VideoStream Isochronous Video Data Endpoint Descriptor */
|
||||
USB_ENDPOINT_DESCRIPTOR_INIT(VIDEO_IN_EP, 0x05, VIDEO_PACKET_SIZE, 0x01),
|
||||
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
///////////////////////////////////////
|
||||
USB_LANGID_INIT(USBD_LANGID_STRING),
|
||||
///////////////////////////////////////
|
||||
/// string1 descriptor
|
||||
///////////////////////////////////////
|
||||
0x14, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'C', 0x00, /* wcChar0 */
|
||||
'h', 0x00, /* wcChar1 */
|
||||
'e', 0x00, /* wcChar2 */
|
||||
'r', 0x00, /* wcChar3 */
|
||||
'r', 0x00, /* wcChar4 */
|
||||
'y', 0x00, /* wcChar5 */
|
||||
'U', 0x00, /* wcChar6 */
|
||||
'S', 0x00, /* wcChar7 */
|
||||
'B', 0x00, /* wcChar8 */
|
||||
///////////////////////////////////////
|
||||
/// string2 descriptor
|
||||
///////////////////////////////////////
|
||||
0x26, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'C', 0x00, /* wcChar0 */
|
||||
'h', 0x00, /* wcChar1 */
|
||||
'e', 0x00, /* wcChar2 */
|
||||
'r', 0x00, /* wcChar3 */
|
||||
'r', 0x00, /* wcChar4 */
|
||||
'y', 0x00, /* wcChar5 */
|
||||
'U', 0x00, /* wcChar6 */
|
||||
'S', 0x00, /* wcChar7 */
|
||||
'B', 0x00, /* wcChar8 */
|
||||
' ', 0x00, /* wcChar9 */
|
||||
'U', 0x00, /* wcChar10 */
|
||||
'V', 0x00, /* wcChar11 */
|
||||
'C', 0x00, /* wcChar12 */
|
||||
' ', 0x00, /* wcChar13 */
|
||||
'D', 0x00, /* wcChar14 */
|
||||
'E', 0x00, /* wcChar15 */
|
||||
'M', 0x00, /* wcChar16 */
|
||||
'O', 0x00, /* wcChar17 */
|
||||
///////////////////////////////////////
|
||||
/// string3 descriptor
|
||||
///////////////////////////////////////
|
||||
0x16, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'2', 0x00, /* wcChar0 */
|
||||
'0', 0x00, /* wcChar1 */
|
||||
'2', 0x00, /* wcChar2 */
|
||||
'1', 0x00, /* wcChar3 */
|
||||
'0', 0x00, /* wcChar4 */
|
||||
'3', 0x00, /* wcChar5 */
|
||||
'1', 0x00, /* wcChar6 */
|
||||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
0x0a,
|
||||
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
volatile bool tx_flag = 0;
|
||||
volatile bool iso_tx_busy = false;
|
||||
|
||||
static void usbd_event_handler(uint8_t busid, uint8_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case USBD_EVENT_RESET:
|
||||
break;
|
||||
case USBD_EVENT_CONNECTED:
|
||||
break;
|
||||
case USBD_EVENT_DISCONNECTED:
|
||||
break;
|
||||
case USBD_EVENT_RESUME:
|
||||
break;
|
||||
case USBD_EVENT_SUSPEND:
|
||||
break;
|
||||
case USBD_EVENT_CONFIGURED:
|
||||
tx_flag = 0;
|
||||
iso_tx_busy = false;
|
||||
break;
|
||||
case USBD_EVENT_SET_REMOTE_WAKEUP:
|
||||
break;
|
||||
case USBD_EVENT_CLR_REMOTE_WAKEUP:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_video_open(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
tx_flag = 1;
|
||||
USB_LOG_RAW("OPEN\r\n");
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
void usbd_video_close(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
USB_LOG_RAW("CLOSE\r\n");
|
||||
tx_flag = 0;
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
|
||||
void usbd_video_iso_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
//USB_LOG_RAW("actual in len:%d\r\n", nbytes);
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
|
||||
static struct usbd_endpoint video_in_ep = {
|
||||
.ep_cb = usbd_video_iso_callback,
|
||||
.ep_addr = VIDEO_IN_EP
|
||||
};
|
||||
|
||||
struct usbd_interface intf0;
|
||||
struct usbd_interface intf1;
|
||||
|
||||
void video_init(uint8_t busid, uint32_t reg_base)
|
||||
{
|
||||
usbd_desc_register(busid, video_descriptor);
|
||||
usbd_add_interface(busid, usbd_video_init_intf(busid, &intf0, INTERVAL, MAX_FRAME_SIZE, MAX_PAYLOAD_SIZE));
|
||||
usbd_add_interface(busid, usbd_video_init_intf(busid, &intf1, INTERVAL, MAX_FRAME_SIZE, MAX_PAYLOAD_SIZE));
|
||||
usbd_add_endpoint(busid, &video_in_ep);
|
||||
|
||||
usbd_initialize(busid, reg_base, usbd_event_handler);
|
||||
}
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t packet_buffer[40 * 1024];
|
||||
|
||||
void video_test(uint8_t busid)
|
||||
{
|
||||
uint32_t out_len;
|
||||
uint32_t packets;
|
||||
|
||||
(void)packets;
|
||||
memset(packet_buffer, 0, 40 * 1024);
|
||||
while (1) {
|
||||
if (tx_flag) {
|
||||
packets = usbd_video_payload_fill(busid, (uint8_t *)cherryusb_h264, sizeof(cherryusb_h264), packet_buffer, &out_len);
|
||||
#if 1
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, packet_buffer, out_len);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* dwc2 must use this method */
|
||||
for (uint32_t i = 0; i < packets; i++) {
|
||||
if (i == (packets - 1)) {
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], out_len - (packets - 1) * MAX_PAYLOAD_SIZE);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], MAX_PAYLOAD_SIZE);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,9 +5,10 @@
|
|||
*/
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_video.h"
|
||||
#include "pic_data.h"
|
||||
#include "cherryusb_mjpeg.h"
|
||||
|
||||
#define VIDEO_IN_EP 0x81
|
||||
#define VIDEO_INT_EP 0x83
|
||||
|
||||
#ifdef CONFIG_USB_HS
|
||||
#define MAX_PAYLOAD_SIZE 1024 // for high speed with one transcations every one micro frame
|
||||
|
@ -33,23 +34,15 @@
|
|||
#define MAX_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS)
|
||||
#define MAX_FRAME_SIZE (unsigned long)(WIDTH * HEIGHT * 2)
|
||||
|
||||
#define VS_HEADER_SIZ (unsigned int)(VIDEO_SIZEOF_VS_INPUT_HEADER_DESC(1,1) + VIDEO_SIZEOF_VS_FORMAT_MJPEG_DESC + VIDEO_SIZEOF_VS_FRAME_MJPEG_DESC(1))
|
||||
|
||||
#define USB_VIDEO_DESC_SIZ (unsigned long)(9 + \
|
||||
8 + \
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_LEN + \
|
||||
9 + \
|
||||
13 + \
|
||||
18 + \
|
||||
9 + \
|
||||
12 + \
|
||||
9 + \
|
||||
14 + \
|
||||
11 + \
|
||||
30 + \
|
||||
VS_HEADER_SIZ + \
|
||||
9 + \
|
||||
7)
|
||||
|
||||
#define VC_TERMINAL_SIZ (unsigned int)(13 + 18 + 12 + 9)
|
||||
#define VS_HEADER_SIZ (unsigned int)(13 + 1 + 11 + 30)
|
||||
|
||||
#define USBD_VID 0xffff
|
||||
#define USBD_PID 0xffff
|
||||
#define USBD_MAX_POWER 100
|
||||
|
@ -58,19 +51,15 @@
|
|||
const uint8_t video_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xef, 0x02, 0x01, USBD_VID, USBD_PID, 0x0001, 0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_VIDEO_DESC_SIZ, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
||||
VIDEO_VC_DESCRIPTOR_INIT(0x00, 0, 0x0100, VC_TERMINAL_SIZ, 48000000, 0x02),
|
||||
//VIDEO_VC_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x00, 0x00),
|
||||
VIDEO_VS_HEADER_DESCRIPTOR_INIT(0x01, VS_HEADER_SIZ, VIDEO_IN_EP, 0x00),
|
||||
VIDEO_VS_INPUT_HEADER_DESCRIPTOR_INIT(0x01, VS_HEADER_SIZ, VIDEO_IN_EP, 0x00),
|
||||
VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_INIT(0x01, 0x01),
|
||||
VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, DBVAL(INTERVAL), 0x01, DBVAL(INTERVAL)),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x01, 0x01),
|
||||
/* 1.2.2.2 Standard VideoStream Isochronous Video Data Endpoint Descriptor */
|
||||
0x07, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType: ENDPOINT */
|
||||
0x81, /* bEndpointAddress: IN endpoint 2 */
|
||||
0x01, /* bmAttributes: Isochronous transfer type. Asynchronous synchronization type. */
|
||||
WBVAL(VIDEO_PACKET_SIZE), /* wMaxPacketSize */
|
||||
0x01, /* bInterval: One frame interval */
|
||||
USB_ENDPOINT_DESCRIPTOR_INIT(VIDEO_IN_EP, 0x05, VIDEO_PACKET_SIZE, 0x01),
|
||||
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
|
@ -191,7 +180,7 @@ void usbd_video_close(uint8_t busid, uint8_t intf)
|
|||
|
||||
void usbd_video_iso_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
USB_LOG_RAW("actual in len:%d\r\n", nbytes);
|
||||
//USB_LOG_RAW("actual in len:%d\r\n", nbytes);
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
|
||||
|
@ -213,17 +202,19 @@ void video_init(uint8_t busid, uint32_t reg_base)
|
|||
usbd_initialize(busid, reg_base, usbd_event_handler);
|
||||
}
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t packet_buffer[10 * 1024];
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t packet_buffer[40 * 1024];
|
||||
|
||||
void video_test(uint8_t busid)
|
||||
{
|
||||
uint32_t out_len;
|
||||
uint32_t packets;
|
||||
memset(packet_buffer, 0, 10 * 1024);
|
||||
|
||||
(void)packets;
|
||||
memset(packet_buffer, 0, 40 * 1024);
|
||||
while (1) {
|
||||
if (tx_flag) {
|
||||
packets = usbd_video_mjpeg_payload_fill(busid, (uint8_t *)jpeg_data, sizeof(jpeg_data), packet_buffer, &out_len);
|
||||
#if 0
|
||||
packets = usbd_video_payload_fill(busid, (uint8_t *)cherryusb_mjpeg, sizeof(cherryusb_mjpeg), packet_buffer, &out_len);
|
||||
#if 1
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, packet_buffer, out_len);
|
||||
while (iso_tx_busy) {
|
||||
|
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_video.h"
|
||||
#include "cherryusb_yuyv.h"
|
||||
|
||||
#define VIDEO_IN_EP 0x81
|
||||
#define VIDEO_INT_EP 0x83
|
||||
|
||||
#ifdef CONFIG_USB_HS
|
||||
#define MAX_PAYLOAD_SIZE 1024 // for high speed with one transcations every one micro frame
|
||||
#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
|
||||
|
||||
// #define MAX_PAYLOAD_SIZE 2048 // for high speed with two transcations every one micro frame
|
||||
// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 2)) | (0x01 << 11))
|
||||
|
||||
// #define MAX_PAYLOAD_SIZE 3072 // for high speed with three transcations every one micro frame
|
||||
// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 3)) | (0x02 << 11))
|
||||
|
||||
#else
|
||||
#define MAX_PAYLOAD_SIZE 1020
|
||||
#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
|
||||
#endif
|
||||
|
||||
#define WIDTH (unsigned int)(64)
|
||||
#define HEIGHT (unsigned int)(48)
|
||||
|
||||
#define CAM_FPS (30)
|
||||
#define INTERVAL (unsigned long)(10000000 / CAM_FPS)
|
||||
#define MIN_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS) //16 bit
|
||||
#define MAX_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS)
|
||||
#define MAX_FRAME_SIZE (unsigned long)(WIDTH * HEIGHT * 2)
|
||||
|
||||
#define VS_HEADER_SIZ (unsigned int)(VIDEO_SIZEOF_VS_INPUT_HEADER_DESC(1,1) + VIDEO_SIZEOF_VS_FORMAT_UNCOMPRESSED_DESC + VIDEO_SIZEOF_VS_FRAME_UNCOMPRESSED_DESC(1))
|
||||
|
||||
#define USB_VIDEO_DESC_SIZ (unsigned long)(9 + \
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_LEN + \
|
||||
9 + \
|
||||
VS_HEADER_SIZ + \
|
||||
6 + \
|
||||
9 + \
|
||||
7)
|
||||
|
||||
#define USBD_VID 0xffff
|
||||
#define USBD_PID 0xffff
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
const uint8_t video_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xef, 0x02, 0x01, USBD_VID, USBD_PID, 0x0001, 0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_VIDEO_DESC_SIZ, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
||||
//VIDEO_VC_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VC_NOEP_DESCRIPTOR_INIT(0x00, VIDEO_INT_EP, 0x0100, VIDEO_VC_TERMINAL_LEN, 48000000, 0x02),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x00, 0x00),
|
||||
VIDEO_VS_INPUT_HEADER_DESCRIPTOR_INIT(0x01, VS_HEADER_SIZ, VIDEO_IN_EP, 0x00),
|
||||
VIDEO_VS_FORMAT_UNCOMPRESSED_DESCRIPTOR_INIT(0x01, 0x01, VIDEO_GUID_YUY2),
|
||||
VIDEO_VS_FRAME_UNCOMPRESSED_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, DBVAL(INTERVAL), 0x01, DBVAL(INTERVAL)),
|
||||
VIDEO_VS_COLOR_MATCHING_DESCRIPTOR_INIT(),
|
||||
VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x01, 0x01),
|
||||
/* 1.2.2.2 Standard VideoStream Isochronous Video Data Endpoint Descriptor */
|
||||
USB_ENDPOINT_DESCRIPTOR_INIT(VIDEO_IN_EP, 0x05, VIDEO_PACKET_SIZE, 0x01),
|
||||
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
///////////////////////////////////////
|
||||
USB_LANGID_INIT(USBD_LANGID_STRING),
|
||||
///////////////////////////////////////
|
||||
/// string1 descriptor
|
||||
///////////////////////////////////////
|
||||
0x14, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'C', 0x00, /* wcChar0 */
|
||||
'h', 0x00, /* wcChar1 */
|
||||
'e', 0x00, /* wcChar2 */
|
||||
'r', 0x00, /* wcChar3 */
|
||||
'r', 0x00, /* wcChar4 */
|
||||
'y', 0x00, /* wcChar5 */
|
||||
'U', 0x00, /* wcChar6 */
|
||||
'S', 0x00, /* wcChar7 */
|
||||
'B', 0x00, /* wcChar8 */
|
||||
///////////////////////////////////////
|
||||
/// string2 descriptor
|
||||
///////////////////////////////////////
|
||||
0x26, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'C', 0x00, /* wcChar0 */
|
||||
'h', 0x00, /* wcChar1 */
|
||||
'e', 0x00, /* wcChar2 */
|
||||
'r', 0x00, /* wcChar3 */
|
||||
'r', 0x00, /* wcChar4 */
|
||||
'y', 0x00, /* wcChar5 */
|
||||
'U', 0x00, /* wcChar6 */
|
||||
'S', 0x00, /* wcChar7 */
|
||||
'B', 0x00, /* wcChar8 */
|
||||
' ', 0x00, /* wcChar9 */
|
||||
'U', 0x00, /* wcChar10 */
|
||||
'V', 0x00, /* wcChar11 */
|
||||
'C', 0x00, /* wcChar12 */
|
||||
' ', 0x00, /* wcChar13 */
|
||||
'D', 0x00, /* wcChar14 */
|
||||
'E', 0x00, /* wcChar15 */
|
||||
'M', 0x00, /* wcChar16 */
|
||||
'O', 0x00, /* wcChar17 */
|
||||
///////////////////////////////////////
|
||||
/// string3 descriptor
|
||||
///////////////////////////////////////
|
||||
0x16, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'2', 0x00, /* wcChar0 */
|
||||
'0', 0x00, /* wcChar1 */
|
||||
'2', 0x00, /* wcChar2 */
|
||||
'1', 0x00, /* wcChar3 */
|
||||
'0', 0x00, /* wcChar4 */
|
||||
'3', 0x00, /* wcChar5 */
|
||||
'1', 0x00, /* wcChar6 */
|
||||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
0x0a,
|
||||
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
volatile bool tx_flag = 0;
|
||||
volatile bool iso_tx_busy = false;
|
||||
|
||||
static void usbd_event_handler(uint8_t busid, uint8_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case USBD_EVENT_RESET:
|
||||
break;
|
||||
case USBD_EVENT_CONNECTED:
|
||||
break;
|
||||
case USBD_EVENT_DISCONNECTED:
|
||||
break;
|
||||
case USBD_EVENT_RESUME:
|
||||
break;
|
||||
case USBD_EVENT_SUSPEND:
|
||||
break;
|
||||
case USBD_EVENT_CONFIGURED:
|
||||
tx_flag = 0;
|
||||
iso_tx_busy = false;
|
||||
break;
|
||||
case USBD_EVENT_SET_REMOTE_WAKEUP:
|
||||
break;
|
||||
case USBD_EVENT_CLR_REMOTE_WAKEUP:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_video_open(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
tx_flag = 1;
|
||||
USB_LOG_RAW("OPEN\r\n");
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
void usbd_video_close(uint8_t busid, uint8_t intf)
|
||||
{
|
||||
USB_LOG_RAW("CLOSE\r\n");
|
||||
tx_flag = 0;
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
|
||||
void usbd_video_iso_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
//USB_LOG_RAW("actual in len:%d\r\n", nbytes);
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
|
||||
static struct usbd_endpoint video_in_ep = {
|
||||
.ep_cb = usbd_video_iso_callback,
|
||||
.ep_addr = VIDEO_IN_EP
|
||||
};
|
||||
|
||||
struct usbd_interface intf0;
|
||||
struct usbd_interface intf1;
|
||||
|
||||
void video_init(uint8_t busid, uint32_t reg_base)
|
||||
{
|
||||
usbd_desc_register(busid, video_descriptor);
|
||||
usbd_add_interface(busid, usbd_video_init_intf(busid, &intf0, INTERVAL, MAX_FRAME_SIZE, MAX_PAYLOAD_SIZE));
|
||||
usbd_add_interface(busid, usbd_video_init_intf(busid, &intf1, INTERVAL, MAX_FRAME_SIZE, MAX_PAYLOAD_SIZE));
|
||||
usbd_add_endpoint(busid, &video_in_ep);
|
||||
|
||||
usbd_initialize(busid, reg_base, usbd_event_handler);
|
||||
}
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t packet_buffer[40 * 1024];
|
||||
|
||||
void video_test(uint8_t busid)
|
||||
{
|
||||
uint32_t out_len;
|
||||
uint32_t packets;
|
||||
|
||||
(void)packets;
|
||||
memset(packet_buffer, 0, 40 * 1024);
|
||||
while (1) {
|
||||
if (tx_flag) {
|
||||
packets = usbd_video_payload_fill(busid, (uint8_t *)cherryusb_yuyv, sizeof(cherryusb_yuyv), packet_buffer, &out_len);
|
||||
#if 1
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, packet_buffer, out_len);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* dwc2 must use this method */
|
||||
for (uint32_t i = 0; i < packets; i++) {
|
||||
if (i == (packets - 1)) {
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], out_len - (packets - 1) * MAX_PAYLOAD_SIZE);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(busid, VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], MAX_PAYLOAD_SIZE);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32F7) || \
|
||||
defined(SOC_HPM5000) || defined(SOC_HPM6000) || defined(BSP_USING_BL61X)
|
||||
defined(SOC_HPM5000) || defined(SOC_HPM6000) || defined(SOC_HPM6E00) || defined(BSP_USING_BL61X)
|
||||
#ifndef RT_USING_CACHE
|
||||
#error usbh msc must enable RT_USING_CACHE in this chip
|
||||
#endif
|
||||
|
|
|
@ -50,6 +50,18 @@
|
|||
// #define CONFIG_USBHOST_PLATFORM_ASIX
|
||||
// #define CONFIG_USBHOST_PLATFORM_RTL8152
|
||||
|
||||
void usbh_lwip_eth_output_common(struct pbuf *p, uint8_t *buf)
|
||||
{
|
||||
struct pbuf *q;
|
||||
uint8_t *buffer;
|
||||
|
||||
buffer = buf;
|
||||
for (q = p; q != NULL; q = q->next) {
|
||||
usb_memcpy(buffer, q->payload, q->len);
|
||||
buffer += q->len;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
|
||||
{
|
||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||
|
@ -65,7 +77,7 @@ void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
|
|||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||
p->payload = buf;
|
||||
#else
|
||||
memcpy(p->payload, buf, len);
|
||||
usb_memcpy(p->payload, buf, len);
|
||||
#endif
|
||||
err = netif->input(p, netif);
|
||||
if (err != ERR_OK) {
|
||||
|
@ -105,7 +117,10 @@ static rt_err_t rt_usbh_cdc_ecm_control(rt_device_t dev, int cmd, void *args)
|
|||
|
||||
static rt_err_t rt_usbh_cdc_ecm_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret = usbh_cdc_ecm_eth_output(p->payload, p->tot_len);
|
||||
int ret;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_cdc_ecm_get_eth_txbuf());
|
||||
ret = usbh_cdc_ecm_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
|
@ -188,7 +203,10 @@ static rt_err_t rt_usbh_rndis_control(rt_device_t dev, int cmd, void *args)
|
|||
|
||||
static rt_err_t rt_usbh_rndis_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret = usbh_rndis_eth_output(p->payload, p->tot_len);
|
||||
int ret;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_rndis_get_eth_txbuf());
|
||||
ret = usbh_rndis_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
|
@ -254,7 +272,10 @@ static rt_err_t rt_usbh_cdc_ncm_control(rt_device_t dev, int cmd, void *args)
|
|||
|
||||
static rt_err_t rt_usbh_cdc_ncm_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret = usbh_cdc_ncm_eth_output(p->payload, p->tot_len);
|
||||
int ret;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_cdc_ncm_get_eth_txbuf());
|
||||
ret = usbh_cdc_ncm_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
|
@ -317,7 +338,10 @@ static rt_err_t rt_usbh_asix_control(rt_device_t dev, int cmd, void *args)
|
|||
|
||||
static rt_err_t rt_usbh_asix_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret = usbh_asix_eth_output(p->payload, p->tot_len);
|
||||
int ret;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_asix_get_eth_txbuf());
|
||||
ret = usbh_asix_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
|
@ -380,7 +404,10 @@ static rt_err_t rt_usbh_rtl8152_control(rt_device_t dev, int cmd, void *args)
|
|||
|
||||
static rt_err_t rt_usbh_rtl8152_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret = usbh_rtl8152_eth_output(p->payload, p->tot_len);
|
||||
int ret;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_rtl8152_get_eth_txbuf());
|
||||
ret = usbh_rtl8152_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
|
|
|
@ -29,3 +29,11 @@
|
|||
## Espressif
|
||||
|
||||
- ESP32S2、ESP32S3
|
||||
|
||||
## Sophgo
|
||||
|
||||
- CV18xx
|
||||
|
||||
## Kendryte
|
||||
|
||||
- K230
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include "esp_intr_alloc.h"
|
||||
#include "esp_private/usb_phy.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include "usb_config.h"
|
||||
#include "usb_log.h"
|
||||
#include "usbd_core.h"
|
||||
#include "usbh_core.h"
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||
#define DEFAULT_CPU_FREQ_MHZ CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usb_config.h"
|
||||
#include "usb_dwc2_reg.h"
|
||||
|
||||
/* When using [GPIO_SetFunc(USBF_VBUS_PORT, USBF_VBUS_PIN, USBF_VBUS_FUNC);], there is no need to configure GOTGCTL */
|
||||
|
||||
#define USB_OTG_GLB ((DWC2_GlobalTypeDef *)(reg_base))
|
||||
|
||||
uint32_t usbd_get_dwc2_gccfg_conf(uint32_t reg_base)
|
||||
{
|
||||
|
||||
USB_OTG_GLB->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
|
||||
USB_OTG_GLB->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t usbh_get_dwc2_gccfg_conf(uint32_t reg_base)
|
||||
{
|
||||
USB_OTG_GLB->GOTGCTL &= ~USB_OTG_GOTGCTL_BVALOEN;
|
||||
USB_OTG_GLB->GOTGCTL &= ~USB_OTG_GOTGCTL_BVALOVAL;
|
||||
return 0;
|
||||
}
|
|
@ -322,15 +322,15 @@ static int dwc2_chan_alloc(struct usbh_bus *bus)
|
|||
size_t flags;
|
||||
int chidx;
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
for (chidx = 0; chidx < CONFIG_USBHOST_PIPE_NUM; chidx++) {
|
||||
if (!g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx].inuse) {
|
||||
flags = usb_osal_enter_critical_section();
|
||||
g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx].inuse = true;
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return chidx;
|
||||
}
|
||||
}
|
||||
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -736,14 +736,32 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||
return -USB_ERR_BUSY;
|
||||
}
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
|
||||
chidx = dwc2_chan_alloc(bus);
|
||||
if (chidx == -1) {
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return -USB_ERR_NOMEM;
|
||||
}
|
||||
|
||||
if (urb->ep->bEndpointAddress & 0x80) {
|
||||
/* Check if pipe rx fifo is overflow */
|
||||
if (USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) > (CONFIG_USB_DWC2_RX_FIFO_SIZE * 4)) {
|
||||
return -USB_ERR_RANGE;
|
||||
}
|
||||
} else {
|
||||
/* Check if intr and iso pipe tx fifo is overflow */
|
||||
if (((USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) == USB_ENDPOINT_TYPE_ISOCHRONOUS) ||
|
||||
(USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) == USB_ENDPOINT_TYPE_INTERRUPT)) &&
|
||||
USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) > (CONFIG_USB_DWC2_PTX_FIFO_SIZE * 4)) {
|
||||
return -USB_ERR_RANGE;
|
||||
} else {
|
||||
/* Check if control and bulk pipe tx fifo is overflow */
|
||||
if (USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) > (CONFIG_USB_DWC2_NPTX_FIFO_SIZE * 4)) {
|
||||
return -USB_ERR_RANGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
|
||||
chan = &g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx];
|
||||
chan->chidx = chidx;
|
||||
chan->urb = urb;
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
#define CONFIG_USB_EHCI_QTD_NUM 3
|
||||
#endif
|
||||
#ifndef CONFIG_USB_EHCI_ITD_NUM
|
||||
#define CONFIG_USB_EHCI_ITD_NUM 20
|
||||
#define CONFIG_USB_EHCI_ITD_NUM 5
|
||||
#endif
|
||||
#ifndef CONFIG_USB_EHCI_ISO_NUM
|
||||
#define CONFIG_USB_EHCI_ISO_NUM 4
|
||||
#endif
|
||||
|
||||
extern uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port);
|
||||
|
@ -52,12 +55,17 @@ struct ehci_itd_hw {
|
|||
uint8_t mf_unmask;
|
||||
uint8_t mf_valid;
|
||||
uint32_t pkt_idx[8];
|
||||
usb_slist_t list;
|
||||
} __attribute__((aligned(32)));
|
||||
|
||||
struct ehci_iso_hw
|
||||
{
|
||||
struct ehci_itd_hw itd_pool[CONFIG_USB_EHCI_ITD_NUM];
|
||||
uint32_t itd_num;
|
||||
};
|
||||
|
||||
struct ehci_hcd {
|
||||
bool ehci_qh_used[CONFIG_USB_EHCI_QH_NUM];
|
||||
bool ehci_itd_used[CONFIG_USB_EHCI_ITD_NUM];
|
||||
bool ehci_iso_used[CONFIG_USB_EHCI_ISO_NUM];
|
||||
bool ppc; /* Port Power Control */
|
||||
bool has_tt; /* if use tt instead of Companion Controller */
|
||||
uint8_t n_cc; /* Number of Companion Controller */
|
||||
|
@ -70,7 +78,7 @@ extern struct ehci_hcd g_ehci_hcd[CONFIG_USBHOST_MAX_BUS];
|
|||
extern uint32_t g_framelist[CONFIG_USBHOST_MAX_BUS][USB_ALIGN_UP(CONFIG_USB_EHCI_FRAME_LIST_SIZE, 1024)];
|
||||
|
||||
int ehci_iso_urb_init(struct usbh_bus *bus, struct usbh_urb *urb);
|
||||
void ehci_remove_itd_urb(struct usbh_bus *bus, struct usbh_urb *urb);
|
||||
void ehci_kill_iso_urb(struct usbh_bus *bus, struct usbh_urb *urb);
|
||||
void ehci_scan_isochronous_list(struct usbh_bus *bus);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,9 +32,9 @@ static struct ehci_qh_hw *ehci_qh_alloc(struct usbh_bus *bus)
|
|||
struct ehci_qtd_hw *qtd;
|
||||
size_t flags;
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
for (uint32_t i = 0; i < CONFIG_USB_EHCI_QH_NUM; i++) {
|
||||
if (!g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[i]) {
|
||||
flags = usb_osal_enter_critical_section();
|
||||
g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[i] = true;
|
||||
usb_osal_leave_critical_section(flags);
|
||||
|
||||
|
@ -56,6 +56,7 @@ static struct ehci_qh_hw *ehci_qh_alloc(struct usbh_bus *bus)
|
|||
return qh;
|
||||
}
|
||||
}
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1160,21 +1161,18 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||
if (qh == NULL) {
|
||||
return -USB_ERR_NOMEM;
|
||||
}
|
||||
urb->hcpriv = qh;
|
||||
break;
|
||||
case USB_ENDPOINT_TYPE_BULK:
|
||||
qh = ehci_bulk_urb_init(bus, urb, urb->transfer_buffer, urb->transfer_buffer_length);
|
||||
if (qh == NULL) {
|
||||
return -USB_ERR_NOMEM;
|
||||
}
|
||||
urb->hcpriv = qh;
|
||||
break;
|
||||
case USB_ENDPOINT_TYPE_INTERRUPT:
|
||||
qh = ehci_intr_urb_init(bus, urb, urb->transfer_buffer, urb->transfer_buffer_length);
|
||||
if (qh == NULL) {
|
||||
return -USB_ERR_NOMEM;
|
||||
}
|
||||
urb->hcpriv = qh;
|
||||
break;
|
||||
case USB_ENDPOINT_TYPE_ISOCHRONOUS:
|
||||
#ifdef CONFIG_USB_EHCI_ISO
|
||||
|
@ -1245,7 +1243,7 @@ int usbh_kill_urb(struct usbh_urb *urb)
|
|||
}
|
||||
} else {
|
||||
#ifdef CONFIG_USB_EHCI_ISO
|
||||
ehci_remove_itd_urb(bus, urb);
|
||||
ehci_kill_iso_urb(bus, urb);
|
||||
EHCI_HCOR->usbcmd |= (EHCI_USBCMD_PSEN | EHCI_USBCMD_ASEN);
|
||||
usb_osal_leave_critical_section(flags);
|
||||
return 0;
|
||||
|
@ -1346,8 +1344,8 @@ void USBH_IRQHandler(uint8_t busid)
|
|||
for (uint8_t index = 0; index < CONFIG_USB_EHCI_QH_NUM; index++) {
|
||||
g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[index] = false;
|
||||
}
|
||||
for (uint8_t index = 0; index < CONFIG_USB_EHCI_ITD_NUM; index++) {
|
||||
g_ehci_hcd[bus->hcd.hcd_id].ehci_itd_used[index] = false;
|
||||
for (uint8_t index = 0; index < CONFIG_USB_EHCI_ISO_NUM; index++) {
|
||||
g_ehci_hcd[bus->hcd.hcd_id].ehci_iso_used[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
## Support Chip List
|
||||
|
||||
### HEZHOU
|
||||
|
||||
- AIR105
|
||||
|
||||
### ES32
|
||||
### Eastsoft
|
||||
|
||||
- ES32F3xx
|
||||
|
||||
|
@ -14,6 +10,10 @@
|
|||
|
||||
- MSP432E4x
|
||||
|
||||
### Bekencorp
|
||||
|
||||
- BK7256/BK7258
|
||||
|
||||
### AllwinnerTech
|
||||
|
||||
- F1Cxxx, F2Cxxx
|
||||
|
|
|
@ -78,10 +78,6 @@
|
|||
|
||||
#define USB_FIFO_BASE(ep_idx) (USB_BASE + MUSB_FIFO_OFFSET + 0x4 * ep_idx)
|
||||
|
||||
#ifndef CONFIG_USBDEV_EP_NUM
|
||||
#define CONFIG_USBDEV_EP_NUM 8
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
USB_EP0_STATE_SETUP = 0x0, /**< SETUP DATA */
|
||||
USB_EP0_STATE_IN_DATA = 0x1, /**< IN DATA */
|
||||
|
@ -106,14 +102,12 @@ struct musb_ep_state {
|
|||
/* Driver state */
|
||||
struct musb_udc {
|
||||
volatile uint8_t dev_addr;
|
||||
volatile uint32_t fifo_size_offset;
|
||||
__attribute__((aligned(32))) struct usb_setup_packet setup;
|
||||
struct musb_ep_state in_ep[CONFIG_USBDEV_EP_NUM]; /*!< IN endpoint parameters*/
|
||||
struct musb_ep_state out_ep[CONFIG_USBDEV_EP_NUM]; /*!< OUT endpoint parameters */
|
||||
} g_musb_udc;
|
||||
|
||||
static volatile uint8_t usb_ep0_state = USB_EP0_STATE_SETUP;
|
||||
volatile bool zlp_flag = 0;
|
||||
|
||||
/* get current active ep */
|
||||
static uint8_t musb_get_active_ep(void)
|
||||
|
@ -205,6 +199,40 @@ static uint32_t musb_get_fifo_size(uint16_t mps, uint16_t *used)
|
|||
return USB_TXFIFOSZ_SIZE_8;
|
||||
}
|
||||
|
||||
static uint32_t usbd_musb_fifo_config(struct musb_fifo_cfg *cfg, uint32_t offset)
|
||||
{
|
||||
uint16_t fifo_used;
|
||||
uint8_t c_size;
|
||||
uint16_t c_off;
|
||||
|
||||
c_off = offset >> 3;
|
||||
c_size = musb_get_fifo_size(cfg->maxpacket, &fifo_used);
|
||||
|
||||
musb_set_active_ep(cfg->ep_num);
|
||||
|
||||
switch (cfg->style) {
|
||||
case FIFO_TX:
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = c_off;
|
||||
break;
|
||||
case FIFO_RX:
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = c_off;
|
||||
break;
|
||||
case FIFO_TXRX:
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = c_off;
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = c_off;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return (offset + fifo_used);
|
||||
}
|
||||
|
||||
__WEAK void usb_dc_low_level_init(void)
|
||||
{
|
||||
}
|
||||
|
@ -215,6 +243,10 @@ __WEAK void usb_dc_low_level_deinit(void)
|
|||
|
||||
int usb_dc_init(uint8_t busid)
|
||||
{
|
||||
uint16_t offset = 0;
|
||||
uint8_t cfg_num;
|
||||
struct musb_fifo_cfg *cfg;
|
||||
|
||||
usb_dc_low_level_init();
|
||||
|
||||
#ifdef CONFIG_USB_HS
|
||||
|
@ -228,6 +260,18 @@ int usb_dc_init(uint8_t busid)
|
|||
|
||||
HWREGB(USB_BASE + MUSB_DEVCTL_OFFSET) |= USB_DEVCTL_SESSION;
|
||||
|
||||
cfg_num = usbd_get_musb_fifo_cfg(&cfg);
|
||||
|
||||
for (uint8_t i = 0; i < cfg_num; i++) {
|
||||
offset = usbd_musb_fifo_config(&cfg[i], offset);
|
||||
}
|
||||
|
||||
if (offset > usb_get_musb_ram_size()) {
|
||||
USB_LOG_ERR("offset:%d is overflow, please check your table\r\n", offset);
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable USB interrupts */
|
||||
HWREGB(USB_BASE + MUSB_IE_OFFSET) = USB_IE_RESET;
|
||||
HWREGH(USB_BASE + MUSB_TXIE_OFFSET) = USB_TXIE_EP0;
|
||||
|
@ -266,16 +310,8 @@ uint8_t usbd_get_port_speed(uint8_t busid)
|
|||
return speed;
|
||||
}
|
||||
|
||||
uint8_t usbd_force_full_speed(const uint8_t port)
|
||||
{
|
||||
HWREGB(USB_BASE + MUSB_POWER_OFFSET) &= ~USB_POWER_HSENAB;
|
||||
return (HWREGB(USB_BASE + MUSB_POWER_OFFSET) & USB_POWER_HSENAB);
|
||||
}
|
||||
|
||||
int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint16_t used = 0;
|
||||
uint16_t fifo_size = 0;
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
uint8_t old_ep_idx;
|
||||
uint32_t ui32Flags = 0;
|
||||
|
@ -304,6 +340,11 @@ int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep)
|
|||
g_musb_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_musb_udc.out_ep[ep_idx].ep_enable = true;
|
||||
|
||||
if ((8 << HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET)) < g_musb_udc.out_ep[ep_idx].ep_mps) {
|
||||
USB_LOG_ERR("Ep %02x fifo is overflow\r\n", ep->bEndpointAddress);
|
||||
return -2;
|
||||
}
|
||||
|
||||
HWREGH(USB_BASE + MUSB_IND_RXMAP_OFFSET) = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
|
||||
//
|
||||
|
@ -343,18 +384,16 @@ int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep)
|
|||
HWREGB(USB_BASE + MUSB_IND_RXCSRL_OFFSET) = (USB_RXCSRL1_CLRDT | USB_RXCSRL1_FLUSH);
|
||||
else
|
||||
HWREGB(USB_BASE + MUSB_IND_RXCSRL_OFFSET) = USB_RXCSRL1_CLRDT;
|
||||
|
||||
fifo_size = musb_get_fifo_size(USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize), &used);
|
||||
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = fifo_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = (g_musb_udc.fifo_size_offset >> 3);
|
||||
|
||||
g_musb_udc.fifo_size_offset += used;
|
||||
} else {
|
||||
g_musb_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_musb_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_musb_udc.in_ep[ep_idx].ep_enable = true;
|
||||
|
||||
if ((8 << HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET)) < g_musb_udc.in_ep[ep_idx].ep_mps) {
|
||||
USB_LOG_ERR("Ep %02x fifo is overflow\r\n", ep->bEndpointAddress);
|
||||
return -2;
|
||||
}
|
||||
|
||||
HWREGH(USB_BASE + MUSB_IND_TXMAP_OFFSET) = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
|
||||
//
|
||||
|
@ -388,13 +427,6 @@ int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep)
|
|||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) = (USB_TXCSRL1_CLRDT | USB_TXCSRL1_FLUSH);
|
||||
else
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) = USB_TXCSRL1_CLRDT;
|
||||
|
||||
fifo_size = musb_get_fifo_size(USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize), &used);
|
||||
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = fifo_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = (g_musb_udc.fifo_size_offset >> 3);
|
||||
|
||||
g_musb_udc.fifo_size_offset += used;
|
||||
}
|
||||
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
|
@ -472,130 +504,6 @@ int usbd_ep_is_stalled(uint8_t busid, const uint8_t ep, uint8_t *stalled)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int usb_ep_out_data_avail(uint8_t ep_addr)
|
||||
{
|
||||
uint16_t old_ep_idx, length;
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_addr);
|
||||
|
||||
old_ep_idx = musb_get_active_ep();
|
||||
musb_set_active_ep(ep_idx);
|
||||
|
||||
if (ep_idx == 0) {
|
||||
if (!(HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) & USB_CSRL0_RXRDY)) {
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return 0;
|
||||
}
|
||||
length = HWREGH(USB_BASE + MUSB_IND_RXCOUNT_OFFSET);
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return length;
|
||||
} else {
|
||||
if (!(HWREGB(USB_BASE + MUSB_IND_RXCSRL_OFFSET) & USB_RXCSRL1_RXRDY)) {
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return 0;
|
||||
}
|
||||
length = HWREGH(USB_BASE + MUSB_IND_RXCOUNT_OFFSET);
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
int usb_ep_in_data_avail(uint8_t ep_addr)
|
||||
{
|
||||
uint16_t old_ep_idx, length;
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_addr);
|
||||
|
||||
old_ep_idx = musb_get_active_ep();
|
||||
musb_set_active_ep(ep_idx);
|
||||
|
||||
if (ep_idx == 0) {
|
||||
if (HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) & USB_CSRL0_TXRDY) {
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) & USB_TXCSRL1_TXRDY) {
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
length = HWREGH(USB_BASE + MUSB_IND_TXMAP_OFFSET);
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return length;
|
||||
}
|
||||
|
||||
int usb_ep_wait_in_data_avail(uint8_t ep_addr)
|
||||
{
|
||||
uint32_t cnt;
|
||||
|
||||
for (cnt = 0; cnt < 3000; cnt++) {
|
||||
if (usb_ep_in_data_avail(ep_addr))
|
||||
return cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbd_read_packet(uint8_t ep_addr, uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
uint16_t old_ep_idx, cnt;
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_addr);
|
||||
|
||||
old_ep_idx = musb_get_active_ep();
|
||||
musb_set_active_ep(ep_idx);
|
||||
if (ep_idx == 0) {
|
||||
if (!(HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) & USB_CSRL0_RXRDY)) {
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (!(HWREGB(USB_BASE + MUSB_IND_RXCSRL_OFFSET) & USB_RXCSRL1_RXRDY)) {
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
cnt = usb_ep_out_data_avail(ep_idx);
|
||||
if (cnt) {
|
||||
musb_read_packet(ep_idx, buffer, cnt);
|
||||
HWREGB(USB_BASE + MUSB_IND_RXCSRL_OFFSET) &= ~(USB_RXCSRL1_OVER | USB_RXCSRL1_ERROR | USB_RXCSRL1_STALL | USB_RXCSRL1_STALLED);
|
||||
HWREGB(USB_BASE + MUSB_IND_RXCSRL_OFFSET) &= ~(USB_RXCSRL1_RXRDY);
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
int usbd_write_packet(uint8_t ep_addr, uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
uint16_t old_ep_idx, cnt;
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_addr);
|
||||
|
||||
old_ep_idx = musb_get_active_ep();
|
||||
musb_set_active_ep(ep_idx);
|
||||
if (HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) & USB_TXCSRL1_UNDRN) {
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) &= ~USB_TXCSRL1_UNDRN;
|
||||
}
|
||||
if (HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) & USB_TXCSRL1_TXRDY) {
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!buffer && len) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (!len) {
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) |= USB_TXCSRL1_TXRDY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cnt = usb_ep_in_data_avail(ep_idx);
|
||||
if (cnt) {
|
||||
cnt = MIN(cnt, len);
|
||||
musb_write_packet(ep_idx, buffer, cnt);
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) |= USB_TXCSRL1_TXRDY;
|
||||
musb_set_active_ep(old_ep_idx);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
int usbd_ep_start_write(uint8_t busid, const uint8_t ep, const uint8_t *data, uint32_t data_len)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep);
|
||||
|
@ -787,18 +695,10 @@ void USBD_IRQHandler(uint8_t busid)
|
|||
/* Receive a reset signal from the USB bus */
|
||||
if (is & USB_IS_RESET) {
|
||||
memset(&g_musb_udc, 0, sizeof(struct musb_udc));
|
||||
g_musb_udc.fifo_size_offset = USB_CTRL_EP_MPS;
|
||||
usbd_event_reset_handler(0);
|
||||
HWREGH(USB_BASE + MUSB_TXIE_OFFSET) = USB_TXIE_EP0;
|
||||
HWREGH(USB_BASE + MUSB_RXIE_OFFSET) = 0;
|
||||
|
||||
for (uint8_t i = 1; i < CONFIG_USBDEV_EP_NUM; i++) {
|
||||
musb_set_active_ep(i);
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = 0;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = 0;
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = 0;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = 0;
|
||||
}
|
||||
usb_ep0_state = USB_EP0_STATE_SETUP;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,321 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sys_driver.h"
|
||||
#include "gpio_driver.h"
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/gpio_types.h>
|
||||
#include <driver/int.h>
|
||||
#include "bk_misc.h"
|
||||
#include "usbd_core.h"
|
||||
#include "usbh_core.h"
|
||||
#include "usb_musb_reg.h"
|
||||
|
||||
#define USB_BASE_ADDR SOC_USB_REG_BASE
|
||||
|
||||
#if (CONFIG_SOC_BK7271)
|
||||
#define REG_AHB2_USB_OTG_CFG (*((volatile unsigned char *)(USB_BASE_ADDR + 0x80)))
|
||||
#define REG_AHB2_USB_DMA_ENDP (*((volatile unsigned char *)(USB_BASE_ADDR + 0x84)))
|
||||
#define REG_AHB2_USB_VTH (*((volatile unsigned char *)(USB_BASE_ADDR + 0x88)))
|
||||
#define REG_AHB2_USB_GEN (*((volatile unsigned char *)(USB_BASE_ADDR + 0x8C)))
|
||||
#define REG_AHB2_USB_STAT (*((volatile unsigned char *)(USB_BASE_ADDR + 0x90)))
|
||||
#define REG_AHB2_USB_INT (*((volatile unsigned char *)(USB_BASE_ADDR + 0x94)))
|
||||
#define REG_AHB2_USB_RESET (*((volatile unsigned char *)(USB_BASE_ADDR + 0x98)))
|
||||
#define REG_AHB2_USB_DEV_CFG (*((volatile unsigned char *)(USB_BASE_ADDR + 0x9C)))
|
||||
#elif (CONFIG_SOC_BK7256XX)
|
||||
#define REG_AHB2_USB_OTG_CFG (*((volatile unsigned char *)(USB_BASE_ADDR + 0x280)))
|
||||
#define REG_AHB2_USB_DMA_ENDP (*((volatile unsigned char *)(USB_BASE_ADDR + 0x284)))
|
||||
#define REG_AHB2_USB_VTH (*((volatile unsigned char *)(USB_BASE_ADDR + 0x288)))
|
||||
#define REG_AHB2_USB_GEN (*((volatile unsigned char *)(USB_BASE_ADDR + 0x28C)))
|
||||
#define REG_AHB2_USB_STAT (*((volatile unsigned char *)(USB_BASE_ADDR + 0x290)))
|
||||
#define REG_AHB2_USB_INT (*((volatile unsigned char *)(USB_BASE_ADDR + 0x294)))
|
||||
#define REG_AHB2_USB_RESET (*((volatile unsigned char *)(USB_BASE_ADDR + 0x298)))
|
||||
#define REG_AHB2_USB_DEV_CFG (*((volatile unsigned char *)(USB_BASE_ADDR + 0x29C)))
|
||||
#elif (CONFIG_SOC_BK7236XX) || (CONFIG_SOC_BK7239XX) || (CONFIG_SOC_BK7286XX)
|
||||
#define REG_AHB2_USB_DEVICE_ID (*((volatile unsigned char *)(USB_BASE_ADDR + 0x280)))
|
||||
#define REG_AHB2_USB_VERSION_ID (*((volatile unsigned char *)(USB_BASE_ADDR + 0x284)))
|
||||
#define REG_AHB2_USB_GLOBAL_CTRL (*((volatile unsigned char *)(USB_BASE_ADDR + 0x288)))
|
||||
#define REG_AHB2_USB_DEVICE_STATUS (*((volatile unsigned char *)(USB_BASE_ADDR + 0x28c)))
|
||||
#define REG_AHB2_USB_OTG_CFG (*((volatile unsigned char *)(USB_BASE_ADDR + 0x290)))
|
||||
#define REG_AHB2_USB_DMA_ENDP (*((volatile unsigned char *)(USB_BASE_ADDR + 0x294)))
|
||||
#define REG_AHB2_USB_VTH (*((volatile unsigned char *)(USB_BASE_ADDR + 0x298)))
|
||||
#define REG_AHB2_USB_GEN (*((volatile unsigned char *)(USB_BASE_ADDR + 0x29C)))
|
||||
#define REG_AHB2_USB_STAT (*((volatile unsigned char *)(USB_BASE_ADDR + 0x2A0)))
|
||||
#define REG_AHB2_USB_INT (*((volatile unsigned char *)(USB_BASE_ADDR + 0x2A4)))
|
||||
#define REG_AHB2_USB_RESET (*((volatile unsigned char *)(USB_BASE_ADDR + 0x2A8)))
|
||||
#define REG_AHB2_USB_DEV_CFG (*((volatile unsigned char *)(USB_BASE_ADDR + 0x2AC)))
|
||||
|
||||
#define REG_USB_USR_700 (*((volatile unsigned long *)(USB_BASE_ADDR + 0x700)))
|
||||
#define REG_USB_USR_704 (*((volatile unsigned long *)(USB_BASE_ADDR + 0x704)))
|
||||
#define REG_USB_USR_708 (*((volatile unsigned long *)(USB_BASE_ADDR + 0x708)))
|
||||
#define REG_USB_USR_70C (*((volatile unsigned long *)(USB_BASE_ADDR + 0x70C)))
|
||||
#define REG_USB_USR_710 (*((volatile unsigned long *)(USB_BASE_ADDR + 0x710)))
|
||||
#define REG_USB_USR_714 (*((volatile unsigned long *)(USB_BASE_ADDR + 0x714)))
|
||||
#define REG_USB_PHY_00 (*((volatile unsigned long *)(USB_BASE_ADDR + 0x400)))
|
||||
#define REG_USB_PHY_01 (*((volatile unsigned long *)(USB_BASE_ADDR + 0x404)))
|
||||
#endif
|
||||
|
||||
#define USB_DP_CAPABILITY_VALUE (0xF)
|
||||
#define USB_DN_CAPABILITY_VALUE (0xF)
|
||||
|
||||
#define NANENG_PHY_FC_REG01 (0x01 * 4)
|
||||
#define NANENG_PHY_FC_REG02 (0x02 * 4)
|
||||
#define NANENG_PHY_FC_REG03 (0x03 * 4)
|
||||
#define NANENG_PHY_FC_REG04 (0x04 * 4)
|
||||
#define NANENG_PHY_FC_REG05 (0x05 * 4)
|
||||
#define NANENG_PHY_FC_REG06 (0x06 * 4)
|
||||
#define NANENG_PHY_FC_REG07 (0x07 * 4)
|
||||
#define NANENG_PHY_FC_REG08 (0x08 * 4)
|
||||
#define NANENG_PHY_FC_REG09 (0x09 * 4)
|
||||
#define NANENG_PHY_FC_REG0A (0x0A * 4)
|
||||
#define NANENG_PHY_FC_REG0B (0x0B * 4)
|
||||
#define NANENG_PHY_FC_REG0C (0x0C * 4)
|
||||
#define NANENG_PHY_FC_REG0D (0x0D * 4)
|
||||
#define NANENG_PHY_FC_REG0E (0x0E * 4)
|
||||
#define NANENG_PHY_FC_REG0F (0x0F * 4)
|
||||
#define NANENG_PHY_FC_REG0F_BYTE 0x0F
|
||||
|
||||
#define NANENG_PHY_FC_REG10 (0x10 * 4)
|
||||
#define NANENG_PHY_FC_REG11 (0x11 * 4)
|
||||
#define NANENG_PHY_FC_REG12 (0x12 * 4)
|
||||
#define NANENG_PHY_FC_REG13 (0x13 * 4)
|
||||
#define NANENG_PHY_FC_REG14 (0x14 * 4)
|
||||
#define NANENG_PHY_FC_REG15 (0x15 * 4)
|
||||
#define NANENG_PHY_FC_REG16 (0x16 * 4)
|
||||
#define NANENG_PHY_FC_REG17 (0x17 * 4)
|
||||
#define NANENG_PHY_FC_REG18 (0x18 * 4)
|
||||
#define NANENG_PHY_FC_REG19 (0x19 * 4)
|
||||
#define NANENG_PHY_FC_REG1A (0x1A * 4)
|
||||
#define NANENG_PHY_FC_REG1B (0x1B * 4)
|
||||
#define NANENG_PHY_FC_REG1C (0x1C * 4)
|
||||
#define NANENG_PHY_FC_REG1D (0x1D * 4)
|
||||
#define NANENG_PHY_FC_REG1E (0x1E * 4)
|
||||
#define NANENG_PHY_FC_REG1F (0x1F * 4)
|
||||
|
||||
#if CONFIG_USBDEV_EP_NUM != 8
|
||||
#error beken chips only support 8 endpoints
|
||||
#endif
|
||||
|
||||
#if CONFIG_USBHOST_PIPE_NUM != 8
|
||||
#error beken chips only support 8 pipes
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
static struct musb_fifo_cfg musb_device_table[] = {
|
||||
{ .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
|
||||
{ .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, },
|
||||
{ .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, },
|
||||
{ .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 4, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 4, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 5, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 5, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 6, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 7, .style = FIFO_TXRX, .maxpacket = 512, }
|
||||
};
|
||||
|
||||
static struct musb_fifo_cfg musb_host_table[] = {
|
||||
{ .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
|
||||
{ .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, },
|
||||
{ .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, },
|
||||
{ .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 4, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 4, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 5, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 5, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 6, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 7, .style = FIFO_TXRX, .maxpacket = 512, }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
|
||||
{
|
||||
*cfg = musb_device_table;
|
||||
return sizeof(musb_device_table) / sizeof(musb_device_table[0]);
|
||||
}
|
||||
|
||||
uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
|
||||
{
|
||||
*cfg = musb_host_table;
|
||||
return sizeof(musb_host_table) / sizeof(musb_host_table[0]);
|
||||
}
|
||||
|
||||
uint32_t usb_get_musb_ram_size(void)
|
||||
{
|
||||
return 8192;
|
||||
}
|
||||
|
||||
extern void USBD_IRQHandler(uint8_t busid);
|
||||
|
||||
void USBD_IRQ(void)
|
||||
{
|
||||
USBD_IRQHandler(0);
|
||||
}
|
||||
|
||||
static void bk_analog_layer_usb_sys_related_ops(uint32_t usb_mode, bool ops)
|
||||
{
|
||||
extern void delay(INT32 num);
|
||||
|
||||
#if 0
|
||||
sys_drv_usb_analog_phy_en(ops, NULL);
|
||||
sys_drv_usb_analog_speed_en(ops, NULL);
|
||||
sys_drv_usb_analog_ckmcu_en(ops, NULL);
|
||||
#endif
|
||||
if (ops) {
|
||||
sys_drv_usb_clock_ctrl(true, NULL);
|
||||
delay(100);
|
||||
#if 0
|
||||
sys_drv_usb_analog_deepsleep_en(false);
|
||||
#endif
|
||||
sys_drv_usb_analog_dp_capability(USB_DP_CAPABILITY_VALUE);
|
||||
sys_drv_usb_analog_dn_capability(USB_DN_CAPABILITY_VALUE);
|
||||
if (!sys_hal_psram_ldo_status()) {
|
||||
sys_drv_psram_ldo_enable(1);
|
||||
}
|
||||
sys_drv_usb_analog_phy_en(1, NULL);
|
||||
|
||||
if (usb_mode == 0) {
|
||||
REG_USB_USR_708 = 0x0;
|
||||
REG_USB_USR_710 &= ~(0x1 << 7);
|
||||
delay(100);
|
||||
|
||||
REG_USB_USR_710 |= (0x1 << 15);
|
||||
//REG_USB_USR_710 |= (0x1<<14);
|
||||
REG_USB_USR_710 |= (0x1 << 16);
|
||||
REG_USB_USR_710 |= (0x1 << 17);
|
||||
REG_USB_USR_710 |= (0x1 << 18);
|
||||
REG_USB_USR_710 |= (0x1 << 19);
|
||||
REG_USB_USR_710 &= ~(0x1 << 20);
|
||||
REG_USB_USR_710 |= (0x1 << 21);
|
||||
REG_USB_USR_710 |= (0x0 << 0);
|
||||
REG_USB_USR_710 |= (0x1 << 5);
|
||||
REG_USB_USR_710 |= (0x1 << 6);
|
||||
REG_USB_USR_710 |= (0x1 << 9);
|
||||
REG_USB_USR_710 |= (0x1 << 10);
|
||||
REG_USB_USR_710 |= (0x1 << 1);
|
||||
|
||||
REG_USB_USR_710 |= (0x1 << 7);
|
||||
REG_USB_USR_708 = 0x1;
|
||||
#if 0
|
||||
REG_USB_PHY_00 = 0x08;
|
||||
REG_USB_PHY_01 = 0x02;
|
||||
REG_USB_USR_710 |= (0x1<< 8);
|
||||
while(1){
|
||||
reg = REG_USB_USR_70C;
|
||||
if(reg & 0x100){
|
||||
USB_DRIVER_LOGI("SelfTest Fin!\r\n");
|
||||
USB_DRIVER_LOGI("test end!\r\n");
|
||||
break;
|
||||
} else {
|
||||
USB_DRIVER_LOGI("70c_reg:0x%x\r\n", reg);
|
||||
delay(10000);
|
||||
}
|
||||
}
|
||||
REG_USB_PHY_00 &= ~0x08;
|
||||
REG_USB_PHY_01 &= ~0x02;
|
||||
REG_USB_USR_710 &= ~(0x1<< 8);
|
||||
#endif
|
||||
} else {
|
||||
REG_USB_USR_710 |= (0x1 << 15);
|
||||
REG_USB_USR_710 |= (0x1 << 14);
|
||||
REG_USB_USR_710 |= (0x1 << 16);
|
||||
REG_USB_USR_710 |= (0x1 << 17);
|
||||
REG_USB_USR_710 |= (0x1 << 18);
|
||||
REG_USB_USR_710 |= (0x1 << 19);
|
||||
REG_USB_USR_710 &= ~(0x1 << 20);
|
||||
REG_USB_USR_710 |= (0x1 << 21);
|
||||
REG_USB_USR_710 |= (0x0 << 0);
|
||||
REG_USB_USR_710 |= (0x1 << 5);
|
||||
REG_USB_USR_710 |= (0x1 << 6);
|
||||
REG_USB_USR_710 |= (0x1 << 9);
|
||||
REG_USB_USR_710 |= (0x1 << 10);
|
||||
REG_USB_USR_710 |= (0x1 << 7);
|
||||
|
||||
REG_USB_USR_708 = 0x1;
|
||||
}
|
||||
} else {
|
||||
sys_drv_usb_analog_phy_en(0, NULL);
|
||||
sys_drv_usb_clock_ctrl(false, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void usb_dc_low_level_init(void)
|
||||
{
|
||||
#if CONFIG_SYS_CPU0
|
||||
bk_pm_module_vote_sleep_ctrl(PM_SLEEP_MODULE_NAME_USB_1, 0x0, 0x0);
|
||||
#endif
|
||||
bk_analog_layer_usb_sys_related_ops(1, true);
|
||||
bk_gpio_set_output_high(CONFIG_USB_VBAT_CONTROL_GPIO_ID);
|
||||
|
||||
bk_pm_module_vote_cpu_freq(PM_DEV_ID_USB_1, PM_CPU_FRQ_120M);
|
||||
|
||||
sys_hal_usb_analog_phy_en(true);
|
||||
|
||||
sys_drv_usb_clock_ctrl(true, NULL);
|
||||
sys_drv_int_enable(USB_INTERRUPT_CTRL_BIT);
|
||||
|
||||
bk_int_isr_register(INT_SRC_USB, USBD_IRQ, NULL);
|
||||
bk_int_set_priority(INT_SRC_USB, 2);
|
||||
}
|
||||
|
||||
void usb_dc_low_level_deinit(void)
|
||||
{
|
||||
bk_pm_module_vote_cpu_freq(PM_DEV_ID_USB_1, PM_CPU_FRQ_DEFAULT);
|
||||
sys_hal_usb_analog_phy_en(false);
|
||||
sys_drv_usb_clock_ctrl(false, NULL);
|
||||
sys_drv_int_disable(USB_INTERRUPT_CTRL_BIT);
|
||||
bk_int_isr_unregister(INT_SRC_USB);
|
||||
bk_analog_layer_usb_sys_related_ops(1, false);
|
||||
sys_drv_dev_clk_pwr_up(CLK_PWR_ID_USB_1, CLK_PWR_CTRL_PWR_DOWN);
|
||||
}
|
||||
|
||||
extern void USBH_IRQHandler(uint8_t busid);
|
||||
|
||||
void USBH_IRQ(void)
|
||||
{
|
||||
USBH_IRQHandler(0);
|
||||
}
|
||||
|
||||
#define NANENG_PHY_CFG 1
|
||||
#define USB_PHY_BASE (SOC_USB_REG_BASE + 0x400)
|
||||
|
||||
#define HWREG(x) \
|
||||
(*((volatile uint32_t *)(x)))
|
||||
#define HWREGH(x) \
|
||||
(*((volatile uint16_t *)(x)))
|
||||
#define HWREGB(x) \
|
||||
(*((volatile uint8_t *)(x)))
|
||||
|
||||
void usb_hc_low_level_init(struct usbh_bus *bus)
|
||||
{
|
||||
#if CONFIG_SYS_CPU0
|
||||
bk_pm_module_vote_sleep_ctrl(PM_SLEEP_MODULE_NAME_USB_1, 0x0, 0x0);
|
||||
#endif
|
||||
bk_analog_layer_usb_sys_related_ops(0, true);
|
||||
bk_gpio_set_output_high(CONFIG_USB_VBAT_CONTROL_GPIO_ID);
|
||||
|
||||
#if NANENG_PHY_CFG
|
||||
//NANENG_PHY_CFG_HSRX_TEST
|
||||
HWREGB(USB_PHY_BASE + NANENG_PHY_FC_REG0F) |= (0x1 << 4);
|
||||
//disconnect value 640mv
|
||||
HWREGB(USB_PHY_BASE + NANENG_PHY_FC_REG0B) = 0x7C;
|
||||
#endif
|
||||
bk_int_isr_register(INT_SRC_USB, USBH_IRQ, NULL);
|
||||
sys_drv_int_enable(USB_INTERRUPT_CTRL_BIT);
|
||||
}
|
||||
|
||||
void usb_hc_low_level_deinit(struct usbh_bus *bus)
|
||||
{
|
||||
sys_drv_int_disable(USB_INTERRUPT_CTRL_BIT);
|
||||
bk_int_isr_unregister(INT_SRC_USB);
|
||||
sys_drv_dev_clk_pwr_up(CLK_PWR_ID_USB_1, CLK_PWR_CTRL_PWR_DOWN);
|
||||
bk_analog_layer_usb_sys_related_ops(0, false);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usb_config.h"
|
||||
#include "stdint.h"
|
||||
#include "usb_musb_reg.h"
|
||||
|
||||
#if CONFIG_USBDEV_EP_NUM != 6
|
||||
#error es32 chips only support 6 endpoints
|
||||
#endif
|
||||
|
||||
#if CONFIG_USBHOST_PIPE_NUM != 6
|
||||
#error es32 chips only support 6 pipes
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
static struct musb_fifo_cfg musb_device_table[] = {
|
||||
{ .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
|
||||
{ .ep_num = 1, .style = FIFO_TXRX, .maxpacket = 1024, },
|
||||
{ .ep_num = 2, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 4, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 5, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
};
|
||||
|
||||
static struct musb_fifo_cfg musb_host_table[] = {
|
||||
{ .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
|
||||
{ .ep_num = 1, .style = FIFO_TXRX, .maxpacket = 1024, },
|
||||
{ .ep_num = 2, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 4, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
{ .ep_num = 5, .style = FIFO_TXRX, .maxpacket = 512, },
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
|
||||
{
|
||||
*cfg = musb_device_table;
|
||||
return sizeof(musb_device_table) / sizeof(musb_device_table[0]);
|
||||
}
|
||||
|
||||
uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
|
||||
{
|
||||
*cfg = musb_host_table;
|
||||
return sizeof(musb_host_table) / sizeof(musb_host_table[0]);
|
||||
}
|
||||
|
||||
uint32_t usb_get_musb_ram_size(void)
|
||||
{
|
||||
return 4096;
|
||||
}
|
|
@ -1,5 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usb_config.h"
|
||||
#include "stdint.h"
|
||||
#include "usb_musb_reg.h"
|
||||
|
||||
#ifndef CONFIG_USB_MUSB_SUNXI
|
||||
#error must define CONFIG_USB_MUSB_SUNXI when use sunxi chips
|
||||
#endif
|
||||
|
||||
#if CONFIG_USBDEV_EP_NUM != 4
|
||||
#error sunxi chips only support 4 endpoints
|
||||
#endif
|
||||
|
||||
#if CONFIG_USBHOST_PIPE_NUM != 4
|
||||
#error sunxi chips only support 4 pipes
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
static struct musb_fifo_cfg musb_device_table[] = {
|
||||
{ .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
|
||||
{ .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, },
|
||||
{ .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, },
|
||||
{ .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
|
||||
};
|
||||
|
||||
static struct musb_fifo_cfg musb_host_table[] = {
|
||||
{ .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
|
||||
{ .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, },
|
||||
{ .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, },
|
||||
{ .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
|
||||
{ .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
|
||||
{
|
||||
*cfg = musb_device_table;
|
||||
return sizeof(musb_device_table) / sizeof(musb_device_table[0]);
|
||||
}
|
||||
|
||||
uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
|
||||
{
|
||||
*cfg = musb_host_table;
|
||||
return sizeof(musb_host_table) / sizeof(musb_host_table[0]);
|
||||
}
|
||||
|
||||
uint32_t usb_get_musb_ram_size(void)
|
||||
{
|
||||
return 8192;
|
||||
}
|
|
@ -16,10 +16,6 @@
|
|||
|
||||
#define USB_BASE (bus->hcd.reg_base)
|
||||
|
||||
#if CONFIG_USBHOST_PIPE_NUM != 4
|
||||
#error musb host ip only supports 4 pipe num
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_MUSB_SUNXI
|
||||
#define MUSB_FADDR_OFFSET 0x98
|
||||
#define MUSB_POWER_OFFSET 0x40
|
||||
|
@ -124,10 +120,6 @@
|
|||
|
||||
#define USB_FIFO_BASE(ep_idx) (USB_BASE + MUSB_FIFO_OFFSET + 0x4 * ep_idx)
|
||||
|
||||
#ifndef CONIFG_USB_MUSB_PIPE_NUM
|
||||
#define CONIFG_USB_MUSB_PIPE_NUM 5
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
USB_EP0_STATE_SETUP = 0x0, /**< SETUP DATA */
|
||||
USB_EP0_STATE_IN_DATA, /**< IN DATA */
|
||||
|
@ -243,6 +235,56 @@ static void musb_read_packet(struct usbh_bus *bus, uint8_t ep_idx, uint8_t *buff
|
|||
}
|
||||
}
|
||||
|
||||
static uint32_t musb_get_fifo_size(uint16_t mps, uint16_t *used)
|
||||
{
|
||||
uint32_t size;
|
||||
|
||||
for (uint8_t i = USB_TXFIFOSZ_SIZE_8; i <= USB_TXFIFOSZ_SIZE_2048; i++) {
|
||||
size = (8 << i);
|
||||
if (mps <= size) {
|
||||
*used = size;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
*used = 0;
|
||||
return USB_TXFIFOSZ_SIZE_8;
|
||||
}
|
||||
|
||||
static uint32_t usbh_musb_fifo_config(struct usbh_bus *bus, struct musb_fifo_cfg *cfg, uint32_t offset)
|
||||
{
|
||||
uint16_t fifo_used;
|
||||
uint8_t c_size;
|
||||
uint16_t c_off;
|
||||
|
||||
c_off = offset >> 3;
|
||||
c_size = musb_get_fifo_size(cfg->maxpacket, &fifo_used);
|
||||
|
||||
musb_set_active_ep(bus, cfg->ep_num);
|
||||
|
||||
switch (cfg->style) {
|
||||
case FIFO_TX:
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = c_off;
|
||||
break;
|
||||
case FIFO_RX:
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = c_off;
|
||||
break;
|
||||
case FIFO_TXRX:
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = c_off;
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = c_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = c_off;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return (offset + fifo_used);
|
||||
}
|
||||
|
||||
void musb_control_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *urb, struct usb_setup_packet *setup, uint8_t *buffer, uint32_t buflen)
|
||||
{
|
||||
uint8_t old_ep_index;
|
||||
|
@ -269,7 +311,7 @@ void musb_control_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb
|
|||
musb_set_active_ep(bus, old_ep_index);
|
||||
}
|
||||
|
||||
void musb_bulk_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *urb, uint8_t *buffer, uint32_t buflen)
|
||||
int musb_bulk_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *urb, uint8_t *buffer, uint32_t buflen)
|
||||
{
|
||||
uint8_t old_ep_index;
|
||||
uint8_t speed = USB_TXTYPE1_SPEED_FULL;
|
||||
|
@ -286,6 +328,11 @@ void musb_bulk_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *ur
|
|||
}
|
||||
|
||||
if (urb->ep->bEndpointAddress & 0x80) {
|
||||
if ((8 << HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET)) < USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize)) {
|
||||
USB_LOG_ERR("Ep %02x fifo is overflow\r\n", urb->ep->bEndpointAddress);
|
||||
return -USB_ERR_RANGE;
|
||||
}
|
||||
|
||||
HWREGB(USB_RXADDR_BASE(chidx)) = urb->hport->dev_addr;
|
||||
HWREGB(USB_BASE + MUSB_IND_RXTYPE_OFFSET) = (urb->ep->bEndpointAddress & 0x0f) | speed | USB_TXTYPE1_PROTO_BULK;
|
||||
HWREGB(USB_BASE + MUSB_IND_RXINTERVAL_OFFSET) = 0;
|
||||
|
@ -296,6 +343,11 @@ void musb_bulk_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *ur
|
|||
|
||||
HWREGH(USB_BASE + MUSB_RXIE_OFFSET) |= (1 << chidx);
|
||||
} else {
|
||||
if ((8 << HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET)) < USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize)) {
|
||||
USB_LOG_ERR("Ep %02x fifo is overflow\r\n", urb->ep->bEndpointAddress);
|
||||
return -USB_ERR_RANGE;
|
||||
}
|
||||
|
||||
HWREGB(USB_TXADDR_BASE(chidx)) = urb->hport->dev_addr;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXTYPE_OFFSET) = (urb->ep->bEndpointAddress & 0x0f) | speed | USB_TXTYPE1_PROTO_BULK;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXINTERVAL_OFFSET) = 0;
|
||||
|
@ -307,16 +359,16 @@ void musb_bulk_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *ur
|
|||
}
|
||||
|
||||
musb_write_packet(bus, chidx, buffer, buflen);
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRH_OFFSET) &= ~USB_TXCSRH1_MODE;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRH_OFFSET) |= USB_TXCSRH1_MODE;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) = USB_TXCSRL1_TXRDY;
|
||||
|
||||
HWREGH(USB_BASE + MUSB_TXIE_OFFSET) |= (1 << chidx);
|
||||
}
|
||||
musb_set_active_ep(bus, old_ep_index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void musb_intr_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *urb, uint8_t *buffer, uint32_t buflen)
|
||||
int musb_intr_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *urb, uint8_t *buffer, uint32_t buflen)
|
||||
{
|
||||
uint8_t old_ep_index;
|
||||
uint8_t speed = USB_TXTYPE1_SPEED_FULL;
|
||||
|
@ -333,6 +385,11 @@ void musb_intr_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *ur
|
|||
}
|
||||
|
||||
if (urb->ep->bEndpointAddress & 0x80) {
|
||||
if ((8 << HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET)) < USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize)) {
|
||||
USB_LOG_ERR("Ep %02x fifo is overflow\r\n", urb->ep->bEndpointAddress);
|
||||
return -USB_ERR_RANGE;
|
||||
}
|
||||
|
||||
HWREGB(USB_RXADDR_BASE(chidx)) = urb->hport->dev_addr;
|
||||
HWREGB(USB_BASE + MUSB_IND_RXTYPE_OFFSET) = (urb->ep->bEndpointAddress & 0x0f) | speed | USB_TXTYPE1_PROTO_INT;
|
||||
HWREGB(USB_BASE + MUSB_IND_RXINTERVAL_OFFSET) = urb->ep->bInterval;
|
||||
|
@ -343,6 +400,11 @@ void musb_intr_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *ur
|
|||
|
||||
HWREGH(USB_BASE + MUSB_RXIE_OFFSET) |= (1 << chidx);
|
||||
} else {
|
||||
if ((8 << HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET)) < USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize)) {
|
||||
USB_LOG_ERR("Ep %02x fifo is overflow\r\n", urb->ep->bEndpointAddress);
|
||||
return -USB_ERR_RANGE;
|
||||
}
|
||||
|
||||
HWREGB(USB_TXADDR_BASE(chidx)) = urb->hport->dev_addr;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXTYPE_OFFSET) = (urb->ep->bEndpointAddress & 0x0f) | speed | USB_TXTYPE1_PROTO_INT;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXINTERVAL_OFFSET) = urb->ep->bInterval;
|
||||
|
@ -354,13 +416,13 @@ void musb_intr_urb_init(struct usbh_bus *bus, uint8_t chidx, struct usbh_urb *ur
|
|||
}
|
||||
|
||||
musb_write_packet(bus, chidx, buffer, buflen);
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRH_OFFSET) &= ~USB_TXCSRH1_MODE;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRH_OFFSET) |= USB_TXCSRH1_MODE;
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) = USB_TXCSRL1_TXRDY;
|
||||
|
||||
HWREGH(USB_BASE + MUSB_TXIE_OFFSET) |= (1 << chidx);
|
||||
}
|
||||
musb_set_active_ep(bus, old_ep_index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbh_reset_port(struct usbh_bus *bus, const uint8_t port)
|
||||
|
@ -422,7 +484,9 @@ __WEAK void usb_hc_low_level_deinit(struct usbh_bus *bus)
|
|||
int usb_hc_init(struct usbh_bus *bus)
|
||||
{
|
||||
uint8_t regval;
|
||||
uint32_t fifo_offset = 0;
|
||||
uint16_t offset = 0;
|
||||
uint8_t cfg_num;
|
||||
struct musb_fifo_cfg *cfg;
|
||||
|
||||
memset(&g_musb_hcd[bus->hcd.hcd_id], 0, sizeof(struct musb_hcd));
|
||||
|
||||
|
@ -432,21 +496,16 @@ int usb_hc_init(struct usbh_bus *bus)
|
|||
|
||||
usb_hc_low_level_init(bus);
|
||||
|
||||
musb_set_active_ep(bus, 0);
|
||||
HWREGB(USB_BASE + MUSB_IND_TXINTERVAL_OFFSET) = 0;
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = USB_TXFIFOSZ_SIZE_64;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = 0;
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = USB_TXFIFOSZ_SIZE_64;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = 0;
|
||||
fifo_offset += 64;
|
||||
cfg_num = usbh_get_musb_fifo_cfg(&cfg);
|
||||
|
||||
for (uint8_t i = 1; i < CONIFG_USB_MUSB_PIPE_NUM; i++) {
|
||||
musb_set_active_ep(bus, i);
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = USB_TXFIFOSZ_SIZE_512;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = fifo_offset;
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = USB_TXFIFOSZ_SIZE_512;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = fifo_offset;
|
||||
fifo_offset += 512;
|
||||
for (uint8_t i = 0; i < cfg_num; i++) {
|
||||
offset = usbh_musb_fifo_config(bus, &cfg[i], offset);
|
||||
}
|
||||
|
||||
if (offset > usb_get_musb_ram_size()) {
|
||||
USB_LOG_ERR("offset:%d is overflow, please check your table\r\n", offset);
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable USB interrupts */
|
||||
|
@ -625,8 +684,6 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||
|
||||
bus = urb->hport->bus;
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
|
||||
if (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes) == USB_ENDPOINT_TYPE_CONTROL) {
|
||||
chidx = 0;
|
||||
} else {
|
||||
|
@ -637,6 +694,8 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||
}
|
||||
}
|
||||
|
||||
flags = usb_osal_enter_critical_section();
|
||||
|
||||
pipe = &g_musb_hcd[bus->hcd.hcd_id].pipe_pool[chidx];
|
||||
pipe->chidx = chidx;
|
||||
pipe->urb = urb;
|
||||
|
@ -645,18 +704,22 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||
urb->errorcode = -USB_ERR_BUSY;
|
||||
urb->actual_length = 0;
|
||||
|
||||
usb_osal_sem_reset(pipe->waitsem);
|
||||
|
||||
switch (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes)) {
|
||||
case USB_ENDPOINT_TYPE_CONTROL:
|
||||
pipe->ep0_state = USB_EP0_STATE_SETUP;
|
||||
musb_control_urb_init(bus, 0, urb, urb->setup, urb->transfer_buffer, urb->transfer_buffer_length);
|
||||
break;
|
||||
case USB_ENDPOINT_TYPE_BULK:
|
||||
musb_bulk_urb_init(bus, chidx, urb, urb->transfer_buffer, urb->transfer_buffer_length);
|
||||
ret = musb_bulk_urb_init(bus, chidx, urb, urb->transfer_buffer, urb->transfer_buffer_length);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case USB_ENDPOINT_TYPE_INTERRUPT:
|
||||
musb_intr_urb_init(bus, chidx, urb, urb->transfer_buffer, urb->transfer_buffer_length);
|
||||
ret = musb_intr_urb_init(bus, chidx, urb, urb->transfer_buffer, urb->transfer_buffer_length);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case USB_ENDPOINT_TYPE_ISOCHRONOUS:
|
||||
return -USB_ERR_NOTSUPP;
|
||||
|
@ -920,7 +983,7 @@ void USBH_IRQHandler(uint8_t busid)
|
|||
handle_ep0(bus);
|
||||
}
|
||||
|
||||
for (ep_idx = 1; ep_idx < CONIFG_USB_MUSB_PIPE_NUM; ep_idx++) {
|
||||
for (ep_idx = 1; ep_idx < CONFIG_USBHOST_PIPE_NUM; ep_idx++) {
|
||||
if (txis & (1 << ep_idx)) {
|
||||
HWREGH(USB_BASE + MUSB_TXIS_OFFSET) = (1 << ep_idx);
|
||||
|
||||
|
@ -966,7 +1029,7 @@ void USBH_IRQHandler(uint8_t busid)
|
|||
}
|
||||
|
||||
rxis &= HWREGH(USB_BASE + MUSB_RXIE_OFFSET);
|
||||
for (ep_idx = 1; ep_idx < CONIFG_USB_MUSB_PIPE_NUM; ep_idx++) {
|
||||
for (ep_idx = 1; ep_idx < CONFIG_USBHOST_PIPE_NUM; ep_idx++) {
|
||||
if (rxis & (1 << ep_idx)) {
|
||||
HWREGH(USB_BASE + MUSB_RXIS_OFFSET) = (1 << ep_idx); // clear isr flag
|
||||
|
||||
|
|
|
@ -3868,4 +3868,19 @@ typedef struct { /*!< USB0 Structure
|
|||
#define USB_MODE_DEV 0x00000003
|
||||
#define USB_MODE_OTG 0x00000000
|
||||
|
||||
#define FIFO_TX 0
|
||||
#define FIFO_RX 1
|
||||
#define FIFO_TXRX 2
|
||||
|
||||
struct musb_fifo_cfg {
|
||||
uint8_t ep_num;
|
||||
uint8_t style;
|
||||
uint8_t mode;
|
||||
uint32_t maxpacket;
|
||||
};
|
||||
|
||||
uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg);
|
||||
uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg);
|
||||
uint32_t usb_get_musb_ram_size(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue