├── .clang-format ├── .cmake-format.json ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ └── 1-bug-report.yml └── workflows │ ├── cppcheck.yml │ └── deploy-docs.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yaml ├── CMakeLists.txt ├── CherryUSB.svg ├── Kconfig ├── Kconfig.rtt ├── Kconfig.rttpkg ├── LICENSE ├── README.md ├── README_zh.md ├── SConscript ├── VERSION ├── cherryusb.cmake ├── cherryusb_config_template.h ├── class ├── adb │ ├── usbd_adb.c │ └── usbd_adb.h ├── aoa │ ├── usb_aoa.h │ ├── usbh_aoa.c │ └── usbh_aoa.h ├── audio │ ├── usb_audio.h │ ├── usbd_audio.c │ ├── usbd_audio.h │ ├── usbh_audio.c │ └── usbh_audio.h ├── cdc │ ├── usb_cdc.h │ ├── usbd_cdc.h │ ├── usbd_cdc_acm.c │ ├── usbd_cdc_acm.h │ ├── usbd_cdc_ecm.c │ ├── usbd_cdc_ecm.h │ ├── usbh_cdc_acm.c │ ├── usbh_cdc_acm.h │ ├── usbh_cdc_ecm.c │ ├── usbh_cdc_ecm.h │ ├── usbh_cdc_ncm.c │ └── usbh_cdc_ncm.h ├── dfu │ ├── usb_dfu.h │ ├── usbd_dfu.c │ └── usbd_dfu.h ├── hid │ ├── usb_hid.h │ ├── usbd_hid.c │ ├── usbd_hid.h │ ├── usbh_hid.c │ └── usbh_hid.h ├── hub │ ├── usb_hub.h │ ├── usbh_hub.c │ └── usbh_hub.h ├── midi │ └── usb_midi.h ├── msc │ ├── usb_msc.h │ ├── usb_scsi.h │ ├── usbd_msc.c │ ├── usbd_msc.h │ ├── usbh_msc.c │ └── usbh_msc.h ├── mtp │ ├── usb_mtp.h │ ├── usbd_mtp.h │ └── usbd_mtp_support.h ├── template │ ├── usb_xxx.h │ ├── usbd_xxx.c │ ├── usbd_xxx.h │ ├── usbh_xxx.c │ └── usbh_xxx.h ├── vendor │ ├── net │ │ ├── usbh_asix.c │ │ ├── usbh_asix.h │ │ ├── usbh_rtl8152.c │ │ └── usbh_rtl8152.h │ ├── serial │ │ ├── usbh_ch34x.c │ │ ├── usbh_ch34x.h │ │ ├── usbh_cp210x.c │ │ ├── usbh_cp210x.h │ │ ├── usbh_ftdi.c │ │ ├── usbh_ftdi.h │ │ ├── usbh_pl2303.c │ │ └── usbh_pl2303.h │ ├── wifi │ │ ├── README.md │ │ ├── usbh_bl616.c │ │ └── usbh_bl616.h │ └── xbox │ │ ├── usbh_xbox.c │ │ └── usbh_xbox.h ├── video │ ├── usb_video.h │ ├── usbd_video.c │ ├── usbd_video.h │ ├── usbh_video.c │ └── usbh_video.h └── wireless │ ├── ndis.h │ ├── rndis_protocol.h │ ├── usbd_rndis.c │ ├── usbd_rndis.h │ ├── usbh_bluetooth.c │ ├── usbh_bluetooth.h │ ├── usbh_rndis.c │ └── usbh_rndis.h ├── common ├── usb_dc.h ├── usb_dcache.h ├── usb_def.h ├── usb_errno.h ├── usb_hc.h ├── usb_list.h ├── usb_log.h ├── usb_memcpy.h ├── usb_osal.h ├── usb_otg.h ├── usb_util.h └── usb_version.h ├── core ├── usbd_core.c ├── usbd_core.h ├── usbh_core.c ├── usbh_core.h ├── usbotg_core.c └── usbotg_core.h ├── demo ├── CherryUSB.h264 ├── CherryUSB.jpg ├── CherryUSB_64x48.YUYV ├── adb │ ├── cherryadb.png │ ├── cherrysh_port.c │ └── usbd_adb_template.c ├── audio_v1_mic_multichan_template.c ├── audio_v1_mic_speaker_multichan_template.c ├── audio_v2_mic_multichan_template.c ├── audio_v2_mic_speaker_multichan_template.c ├── audio_v2_speaker_multichan_template.c ├── bootuf2 │ ├── bootuf2_config.h │ ├── cherryuf2.png │ └── msc_bootuf2_template.c ├── cdc_acm_hid_msc_template.c ├── cdc_acm_msc_template.c ├── cdc_acm_multi_template.c ├── cdc_acm_template.c ├── cdc_ecm_template.c ├── cdc_rndis_template.c ├── cherryusb_h264.h ├── cherryusb_mjpeg.h ├── cherryusb_yuyv.h ├── dfu_st_cubemx_main.c ├── dfu_with_st_tool_template.c ├── hid_custom_inout_template.c ├── hid_keyboard_template.c ├── hid_mouse_template.c ├── hid_remote_wakeup_template.c ├── midi_template.c ├── msc_ram_template.c ├── mtp_template.c ├── music_16k_ac2.h ├── usb_host.c ├── video_audiov1_hid_template.c ├── video_static_h264_template.c ├── video_static_mjpeg_template.c ├── video_static_yuyv_template.c ├── webusb_hid_template.c ├── winusb1.0_template.c ├── winusb2.0_cdc_template.c └── winusb2.0_hid_template.c ├── docs ├── .gitignore ├── Makefile ├── assets │ ├── actions.jpg │ ├── artinchip.jpg │ ├── bekencorp.jpg │ ├── bouffalolab.jpg │ ├── canaan.jpg │ ├── eastsoft.jpg │ ├── espressif.png │ ├── hpmicro.jpg │ ├── nationstech.jpg │ ├── nuvoton.jpg │ ├── nxp.png │ ├── phytium.jpg │ ├── rtthread.jpg │ ├── sophgo.jpg │ └── thead.jpg ├── make.bat ├── requirements.txt └── source │ ├── api │ ├── api_config.rst │ ├── api_device.rst │ ├── api_host.rst │ ├── api_port.rst │ └── img │ │ ├── api_device1.png │ │ ├── api_host1.png │ │ └── api_host2.png │ ├── class │ ├── class_audio.rst │ ├── class_cdc.rst │ ├── class_hid.rst │ ├── class_msc.rst │ ├── class_video.rst │ └── winusb.rst │ ├── conf.py │ ├── demo │ ├── usbd_audiov1.rst │ ├── usbd_audiov2.rst │ ├── usbd_cdc_acm.rst │ ├── usbd_ecm.rst │ ├── usbd_hid.rst │ ├── usbd_msc.rst │ ├── usbd_rndis.rst │ ├── usbd_vendor.rst │ ├── usbd_video.rst │ ├── usbd_webusb.rst │ ├── usbd_winusb.rst │ ├── usbh_bluetooth.rst │ ├── usbh_hid.rst │ ├── usbh_msc.rst │ ├── usbh_net.rst │ ├── usbh_serial.rst │ ├── usbh_vendor.rst │ └── usbh_wifi.rst │ ├── index.rst │ ├── opensource.rst │ ├── q&a.rst │ ├── quick_start │ ├── demo.rst │ ├── esp.rst │ ├── img │ │ ├── env0.png │ │ ├── env1.png │ │ ├── env2.png │ │ ├── esp1.png │ │ ├── esp2.png │ │ ├── esp3.png │ │ ├── esp4.png │ │ ├── stm32_1.png │ │ ├── stm32_10.png │ │ ├── stm32_11.png │ │ ├── stm32_12.png │ │ ├── stm32_13.png │ │ ├── stm32_14.png │ │ ├── stm32_15.png │ │ ├── stm32_16.png │ │ ├── stm32_18.png │ │ ├── stm32_19.png │ │ ├── stm32_2.png │ │ ├── stm32_21.png │ │ ├── stm32_3.png │ │ ├── stm32_3_1.png │ │ ├── stm32_4.png │ │ ├── stm32_4_1.png │ │ ├── stm32_5.png │ │ ├── stm32_6.png │ │ ├── stm32_7.png │ │ ├── stm32_8.png │ │ ├── stm32_init.png │ │ ├── stm32_init2.png │ │ ├── stm32cubemx0.png │ │ ├── stm32cubemx1.png │ │ ├── stm32cubemx2.png │ │ └── stm32cubemx_clk.png │ ├── rtthread.rst │ ├── start.rst │ └── transplant.rst │ ├── share.rst │ ├── show │ ├── img │ │ ├── usbdev_msc.png │ │ ├── usbdev_rndis_linux.png │ │ ├── usbdev_rndis_lwip.png │ │ ├── usbdev_rndis_lwip2.png │ │ ├── usbdev_rndis_wifi.png │ │ ├── usbdev_rndis_wifi2.png │ │ ├── usbdev_rndis_win.png │ │ ├── usbdev_uvc_mjpeg.png │ │ ├── usbdev_uvc_yuv.png │ │ ├── usbhost_hub.png │ │ ├── usbhost_hub2.png │ │ ├── usbhost_msc.png │ │ ├── usbhost_msc_xhci.png │ │ ├── usbhost_rndis.png │ │ ├── usbhost_rndis2.png │ │ ├── usbhost_uvc.gif │ │ └── usbhost_wifi.png │ └── index.rst │ ├── support │ ├── img │ │ ├── dwc2_hostuac.png │ │ ├── dwc2_hostuvc.png │ │ ├── dwc2_hostuvc1.png │ │ ├── dwc2_hostuvc2.png │ │ ├── ehci_hostuvc1.png │ │ ├── ehci_hostuvc2.png │ │ ├── mtpdev.png │ │ ├── ohci.png │ │ ├── rndisrx.png │ │ └── rndistx.png │ └── index.rst │ ├── tools │ ├── img │ │ ├── chrytool1.png │ │ ├── chrytool2.png │ │ ├── chrytool3.png │ │ ├── chrytool4.png │ │ ├── chrytool5.png │ │ ├── chrytool6.png │ │ └── chrytool7.png │ └── index.rst │ ├── usb │ ├── img │ │ ├── 1.png │ │ ├── 10.png │ │ ├── 11.png │ │ ├── 12.png │ │ ├── 13.png │ │ ├── 14.png │ │ ├── 15.png │ │ ├── 16.png │ │ ├── 17.png │ │ ├── 18.png │ │ ├── 19.png │ │ ├── 2.png │ │ ├── 20.png │ │ ├── 21.png │ │ ├── 22.png │ │ ├── 23.png │ │ ├── 24.png │ │ ├── 25.png │ │ ├── 26.png │ │ ├── 27.png │ │ ├── 28.png │ │ ├── 29.png │ │ ├── 3.png │ │ ├── 30.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ ├── 8.png │ │ ├── 9.png │ │ ├── overview1.png │ │ ├── overview2.png │ │ ├── usb_enum.png │ │ └── usb_request.png │ ├── usb2.0_basic.rst │ ├── usb3.0_basic.rst │ ├── usb_desc.rst │ ├── usb_enum.rst │ ├── usb_ext.rst │ └── usb_request.rst │ ├── usbdev.svg │ ├── usbhost.svg │ ├── usbip │ ├── cdns2.rst │ ├── cdns3.rst │ ├── chipidea.rst │ ├── dwc2.rst │ ├── dwc3.rst │ ├── ehci.rst │ ├── fotg210.rst │ ├── musb.rst │ ├── ohci.rst │ └── xhci.rst │ └── version.rst ├── idf_component.yml ├── osal ├── idf │ ├── linker.lf │ ├── usb_config.h │ ├── usb_osal_idf.c │ └── usbh_class_info.ld ├── usb_osal_freertos.c ├── usb_osal_liteos_m.c ├── usb_osal_nuttx.c ├── usb_osal_rtems.c ├── usb_osal_rtthread.c ├── usb_osal_threadx.c ├── usb_osal_yoc.c └── usb_osal_zephyr.c ├── platform ├── README.md ├── blackmagic │ └── bmp_port_cdc_acm.c ├── daplink │ ├── dap_main.c │ └── dap_main.h ├── fatfs │ ├── usbd_fatfs_mtp.c │ └── usbh_fatfs.c ├── lvgl │ ├── image_cursor.c │ ├── usbh_hid_lvgl.c │ └── usbh_hid_lvgl.h ├── lwip │ └── usbh_lwip.c ├── nuttx │ ├── usbd_cdcacm.c │ ├── usbd_fs.c │ ├── usbh_fs.c │ ├── usbh_net.c │ └── usbh_serial.c ├── qmk │ └── .gitkeep ├── rtthread │ ├── usb_check.c │ ├── usb_msh.c │ ├── usbh_dfs.c │ └── usbh_lwip.c ├── threadx │ └── usbh_msc_filex.c ├── uf2 │ ├── bootuf2.c │ └── bootuf2.h └── zephyr │ └── usb_cmd.c ├── port ├── aic │ ├── usb_dc_aic.c │ ├── usb_dc_aic_ll.c │ └── usb_dc_aic_reg.h ├── bouffalolab │ ├── README.md │ └── usb_dc_bl.c ├── ch32 │ ├── README.md │ ├── ch585_usbhs_dc.c │ ├── ch585_usbhs_reg.h │ ├── usb_ch32_usbfs_reg.h │ ├── usb_ch32_usbhs_reg.h │ ├── usb_ch58x_dc_usbfs.c │ ├── usb_ch58x_usbfs_reg.h │ ├── usb_dc_usbfs.c │ └── usb_dc_usbhs.c ├── chipidea │ ├── README.md │ ├── usb_chipidea_reg.h │ └── usb_dc_chipidea.c ├── dwc2 │ ├── README.md │ ├── usb_dc_dwc2.c │ ├── usb_dwc2_reg.h │ ├── usb_glue_at.c │ ├── usb_glue_esp.c │ ├── usb_glue_gd.c │ ├── usb_glue_hc.c │ ├── usb_glue_kendryte.c │ ├── usb_glue_nation.c │ ├── usb_glue_st.c │ └── usb_hc_dwc2.c ├── ehci │ ├── README.md │ ├── usb_ehci_reg.h │ ├── usb_glue_aic.c │ ├── usb_glue_bouffalo.c │ ├── usb_glue_intel.c │ ├── usb_glue_ma35d0.c │ ├── usb_glue_nuc980.c │ ├── usb_glue_t113.c │ ├── usb_hc_ehci.c │ └── usb_hc_ehci.h ├── fsdev │ ├── README.md │ ├── usb_dc_fsdev.c │ ├── usb_fsdev_reg.h │ └── usb_glue_st.c ├── hpmicro │ ├── README.md │ ├── usb_dc_hpm.c │ ├── usb_glue_hpm.c │ ├── usb_glue_hpm.h │ └── usb_hc_hpm.c ├── kinetis │ ├── README.md │ ├── usb_dc_kinetis.c │ ├── usb_glue_mcx.c │ ├── usb_glue_mm32.c │ ├── usb_hc_kinetis.c │ └── usb_kinetis_reg.h ├── musb │ ├── README.md │ ├── usb_dc_musb.c │ ├── usb_glue_bk.c │ ├── usb_glue_es.c │ ├── usb_glue_sunxi.c │ ├── usb_hc_musb.c │ └── usb_musb_reg.h ├── nuvoton │ ├── README.md │ └── usb_dc_usbfs.c ├── nxp │ ├── README.md │ └── usb_glue_mcx.c ├── ohci │ ├── README.md │ ├── usb_glue_lpc.c │ ├── usb_hc_ohci.c │ ├── usb_hc_ohci.h │ └── usb_ohci_reg.h ├── pusb2 │ ├── README.md │ ├── freertos │ │ ├── usb_config.h │ │ ├── usb_dc_glue_phytium.c │ │ └── usb_hc_glue_phytium.c │ ├── libpusb2_dc_a32_hardfp.a │ ├── libpusb2_dc_a32_softfp_crypto_neon.a │ ├── libpusb2_dc_a32_softfp_neon.a │ ├── libpusb2_dc_a64.a │ ├── libpusb2_hc_a32_hardfp.a │ ├── libpusb2_hc_a32_softfp_crypto_neon.a │ ├── libpusb2_hc_a32_softfp_neon.a │ ├── libpusb2_hc_a64.a │ ├── rt-thread │ │ ├── usb_config.h │ │ ├── usb_dc_glue_phytium.c │ │ └── usb_hc_glue_phytium.c │ └── standalone │ │ ├── usb_config.h │ │ └── usb_dc_glue_phytium.c ├── rp2040 │ ├── README.md │ ├── usb_dc_rp2040.c │ └── usb_hc_rp2040.c ├── template │ ├── usb_dc.c │ └── usb_hc.c └── xhci │ └── phytium │ ├── README.md │ ├── freertos │ ├── usb_config.h │ ├── usb_glue_phytium.c │ ├── usb_glue_phytium_pcie.c │ └── usb_glue_phytium_plat.c │ ├── libxhci_a32_hardfp.a │ ├── libxhci_a32_softfp_crypto_neon.a │ ├── libxhci_a32_softfp_neon.a │ ├── libxhci_a64.a │ └── rt-thread │ ├── usb_config.h │ ├── usb_glue_phytium.c │ └── usb_glue_phytium_plat.c ├── third_party ├── FreeRTOS-10.4 │ ├── croutine.c │ ├── event_groups.c │ ├── include │ │ ├── FreeRTOS.h │ │ ├── StackMacros.h │ │ ├── atomic.h │ │ ├── croutine.h │ │ ├── deprecated_definitions.h │ │ ├── event_groups.h │ │ ├── list.h │ │ ├── message_buffer.h │ │ ├── mpu_prototypes.h │ │ ├── mpu_wrappers.h │ │ ├── portable.h │ │ ├── projdefs.h │ │ ├── queue.h │ │ ├── semphr.h │ │ ├── stack_macros.h │ │ ├── stream_buffer.h │ │ ├── task.h │ │ └── timers.h │ ├── list.c │ ├── portable │ │ ├── GCC │ │ │ ├── ARM_CM0 │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ │ ├── ARM_CM3 │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ │ ├── ARM_CM3_MPU │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ │ ├── ARM_CM4F │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ │ ├── ARM_CM4_MPU │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ │ └── ARM_CM7 │ │ │ │ ├── ReadMe.txt │ │ │ │ └── r0p1 │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ ├── IAR │ │ │ ├── ARM_CM0 │ │ │ │ ├── port.c │ │ │ │ ├── portasm.s │ │ │ │ └── portmacro.h │ │ │ ├── ARM_CM3 │ │ │ │ ├── port.c │ │ │ │ ├── portasm.s │ │ │ │ └── portmacro.h │ │ │ ├── ARM_CM4F │ │ │ │ ├── port.c │ │ │ │ ├── portasm.s │ │ │ │ └── portmacro.h │ │ │ ├── ARM_CM4F_MPU │ │ │ │ ├── port.c │ │ │ │ ├── portasm.s │ │ │ │ └── portmacro.h │ │ │ └── ARM_CM7 │ │ │ │ ├── ReadMe.txt │ │ │ │ └── r0p1 │ │ │ │ ├── port.c │ │ │ │ ├── portasm.s │ │ │ │ └── portmacro.h │ │ ├── MemMang │ │ │ ├── heap_1.c │ │ │ ├── heap_2.c │ │ │ ├── heap_3.c │ │ │ ├── heap_4.c │ │ │ └── heap_5.c │ │ └── RVDS │ │ │ ├── ARM_CM0 │ │ │ ├── port.c │ │ │ └── portmacro.h │ │ │ ├── ARM_CM3 │ │ │ ├── port.c │ │ │ └── portmacro.h │ │ │ ├── ARM_CM4F │ │ │ ├── port.c │ │ │ └── portmacro.h │ │ │ ├── ARM_CM4_MPU │ │ │ ├── port.c │ │ │ └── portmacro.h │ │ │ └── ARM_CM7 │ │ │ ├── ReadMe.txt │ │ │ └── r0p1 │ │ │ ├── port.c │ │ │ └── portmacro.h │ ├── queue.c │ ├── stream_buffer.c │ ├── tasks.c │ └── timers.c ├── cherrymp │ ├── LICENSE │ ├── README.md │ ├── chry_mempool.c │ ├── chry_mempool.h │ ├── chry_mempool_osal_freertos.c │ ├── chry_mempool_osal_nonos.c │ └── chry_mempool_osal_rtthread.c ├── cherryrb │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── README_zh.md │ ├── chry_ringbuffer.c │ └── chry_ringbuffer.h ├── dhcp-server │ ├── dhserver.c │ └── dhserver.h ├── dns-server │ ├── dnserver.c │ └── dnserver.h ├── fatfs-0.14 │ ├── LICENSE.txt │ └── source │ │ ├── 00history.txt │ │ ├── 00readme.txt │ │ ├── diskio.c │ │ ├── diskio.h │ │ ├── ff.c │ │ ├── ff.h │ │ ├── ffconf.h │ │ ├── ffsystem.c │ │ ├── ffunicode.c │ │ └── port │ │ └── fatfs_usbd.c ├── lwip-2.1.2 │ └── .gitkeep ├── nimble-1.6.0 │ ├── README.md │ ├── ble_hci_usbh.c │ ├── nimble │ │ └── .gitkeep │ └── porting │ │ ├── nimble │ │ ├── include │ │ │ ├── mem │ │ │ │ └── mem.h │ │ │ ├── nimble │ │ │ │ └── nimble_port.h │ │ │ ├── os │ │ │ │ ├── endian.h │ │ │ │ ├── os.h │ │ │ │ ├── os_cputime.h │ │ │ │ ├── os_error.h │ │ │ │ ├── os_mbuf.h │ │ │ │ ├── os_mempool.h │ │ │ │ ├── os_trace_api.h │ │ │ │ ├── queue.h │ │ │ │ └── util.h │ │ │ ├── stats │ │ │ │ └── stats.h │ │ │ ├── sysflash │ │ │ │ └── sysflash.h │ │ │ └── sysinit │ │ │ │ └── sysinit.h │ │ └── src │ │ │ ├── endian.c │ │ │ ├── mem.c │ │ │ ├── nimble_port.c │ │ │ ├── os_mbuf.c │ │ │ ├── os_mempool.c │ │ │ └── os_msys_init.c │ │ └── npl │ │ └── freertos │ │ ├── include │ │ ├── console │ │ │ └── console.h │ │ ├── nimble │ │ │ ├── nimble_npl_os.h │ │ │ ├── nimble_npl_os_log.h │ │ │ ├── nimble_port_freertos.h │ │ │ └── npl_freertos.h │ │ └── syscfg │ │ │ └── syscfg.h │ │ └── src │ │ ├── nimble_port_freertos.c │ │ └── npl_os_freertos.c └── zephyr_bluetooth-2.7.5 │ ├── ble_hci_usbh.c │ ├── hci_usb_h4_nrf52840dk_nrf52840.hex │ ├── hci_usb_nrf52840dk_nrf52840.hex │ └── usbhci_h4_peripheral_hids_capture.txt ├── tools ├── audacity │ └── url ├── chryusb_configurator │ └── url ├── packet capture │ └── url ├── stm32_dfuse │ └── url ├── test_srcipts │ ├── test_cdc_speed.py │ └── test_hid_inout.py └── uf2 │ └── uf2conv.py └── zephyr ├── module.yml └── usbh_class_info.ld /.gitattributes: -------------------------------------------------------------------------------- 1 | *.c linguist-language=C 2 | *.C linguist-language=C 3 | *.h linguist-language=C 4 | *.H linguist-language=C 5 | 6 | * text=auto 7 | 8 | *.S text 9 | *.asm text 10 | *.c text 11 | *.cc text 12 | *.cpp text 13 | *.cxx text 14 | *.h text 15 | *.htm text 16 | *.html text 17 | *.in text 18 | *.ld text 19 | *.m4 text 20 | *.mak text 21 | *.mk text 22 | *.py text 23 | *.rb text 24 | *.s text 25 | *.sct text 26 | *.sh text 27 | *.txt text 28 | *.xml text 29 | SConscript text 30 | Makefile text 31 | AUTHORS text 32 | COPYING text 33 | 34 | *.LZO -text 35 | *.Opt -text 36 | *.Uv2 -text 37 | *.ewp -text 38 | *.eww -text 39 | *.vcproj -text 40 | *.bat -text 41 | *.dos -text 42 | *.icf -text 43 | *.inf -text 44 | *.ini -text 45 | *.sct -text 46 | *.xsd -text 47 | Jamfile -text -------------------------------------------------------------------------------- /.github/workflows/cppcheck.yml: -------------------------------------------------------------------------------- 1 | name: Cppcheck action 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | build: 9 | name: cppcheck 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: cppcheck 14 | shell: bash 15 | run: | 16 | sudo apt install cppcheck 17 | cppcheck --enable=warning,portability,performance --language=c --platform=unix32 --std=c99 --force . -i third_party/ -i class/template -i port/template/ 18 | -------------------------------------------------------------------------------- /.github/workflows/deploy-docs.yml: -------------------------------------------------------------------------------- 1 | name: Deploy docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | deploy: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | submodules: true 20 | - uses: ammaraskar/sphinx-action@8.0.2 21 | with: 22 | docs-folder: "docs/" 23 | - uses: JamesIves/github-pages-deploy-action@v4 24 | with: 25 | branch: gh-pages 26 | folder: docs/build/html 27 | 28 | 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | **/Drivers/** 3 | **/MDK-ARM/DebugConfig/** 4 | **/MDK-ARM/RTE/** 5 | **/obj/** 6 | **/RET/** 7 | **/Listings/** 8 | **/Objects/** 9 | *.map 10 | *.o 11 | *.d 12 | *.htm 13 | *.dep 14 | *.lnp 15 | *.iex 16 | *.lst 17 | *.axf 18 | *.crf 19 | *.hex 20 | *.Bak 21 | *.uvguix.* 22 | *.scvd 23 | *.usb.tmp -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/zephyr_bluetooth-2.7.5/zephyr_bluetooth"] 2 | path = third_party/zephyr_bluetooth-2.7.5/zephyr_bluetooth 3 | url = https://github.com/sakumisu/zephyr_bluetooth.git 4 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for Sphinx projects 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | # Required 5 | version: 2 6 | 7 | # Set the OS, Python version and other tools you might need 8 | build: 9 | os: ubuntu-22.04 10 | tools: 11 | python: "3.11" 12 | # You can also specify other tool versions: 13 | # nodejs: "20" 14 | # rust: "1.70" 15 | # golang: "1.20" 16 | 17 | # Build documentation in the "docs/" directory with Sphinx 18 | sphinx: 19 | configuration: docs/source/conf.py 20 | # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs 21 | # builder: "dirhtml" 22 | # Fail on all warnings to avoid broken references 23 | # fail_on_warning: true 24 | 25 | # Optionally build your docs in additional formats such as PDF and ePub 26 | # formats: 27 | # - pdf 28 | # - epub 29 | 30 | # Optional but recommended, declare the Python requirements required 31 | # to build your documentation 32 | # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html 33 | python: 34 | install: 35 | - requirements: docs/requirements.txt -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | VERSION_MAJOR = 1 2 | VERSION_MINOR = 5 3 | PATCHLEVEL = 0 4 | VERSION_TWEAK = 0 5 | EXTRAVERSION = 0 6 | -------------------------------------------------------------------------------- /class/adb/usbd_adb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_ADB_H 7 | #define USBD_ADB_H 8 | 9 | #include 10 | 11 | #define ADB_SHELL_LOALID 0x01 12 | #define ADB_FILE_LOALID 0x02 13 | 14 | // clang-format off 15 | #define ADB_DESCRIPTOR_INIT(bFirstInterface, in_ep, out_ep, wMaxPacketSize) \ 16 | USB_INTERFACE_DESCRIPTOR_INIT(bFirstInterface, 0x00, 0x02, 0xff, 0x42, 0x01, 0x02), \ 17 | USB_ENDPOINT_DESCRIPTOR_INIT(in_ep, 0x02, wMaxPacketSize, 0x00), \ 18 | USB_ENDPOINT_DESCRIPTOR_INIT(out_ep, 0x02, wMaxPacketSize, 0x00) 19 | // clang-format on 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | struct usbd_interface *usbd_adb_init_intf(uint8_t busid, struct usbd_interface *intf, uint8_t in_ep, uint8_t out_ep); 26 | 27 | void usbd_adb_notify_shell_read(uint8_t *data, uint32_t len); 28 | void usbd_adb_notify_file_read(uint8_t *data, uint32_t len); 29 | void usbd_adb_notify_write_done(void); 30 | bool usbd_adb_can_write(void); 31 | int usbd_abd_write(uint32_t localid, const uint8_t *data, uint32_t len); 32 | void usbd_adb_close(uint32_t localid); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* USBD_ADB_H */ -------------------------------------------------------------------------------- /class/aoa/usb_aoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USB_AOA_H 7 | #define USB_AOA_H 8 | 9 | //AOA 1.0 10 | #define AOA_ACCESSORY_VENDOR_ID 0x18D1 11 | #define AOA_ACCESSORY_PRODUCT_ID 0x2D00 12 | #define AOA_ACCESSORY_ADB_PRODUCT_ID 0x2D01 13 | 14 | //AOA 2.0 15 | #define AOA_AUDIO_PRODUCT_ID 0x2D02 16 | #define AOA_AUDIO_ADB_PRODUCT_ID 0x2D03 17 | #define AOA_ACCESSORY_AUDIO_PRODUCT_ID 0x2D04 18 | #define AOA_ACCESSORY_AUDIO_ADB_PRODUCT_ID 0x2D05 19 | 20 | //AOA 1.0 21 | #define AOA_ACCESSORY_GET_PROTOCOL 51 22 | #define AOA_ACCESSORY_SEND_STRING 52 23 | #define AOA_ACCESSORY_START 53 24 | 25 | //AOA 2.0 26 | #define AOA_ACCESSORY_REGISTER_HID 54 27 | #define AOA_ACCESSORY_UNREGISTER_HID 55 28 | #define AOA_ACCESSORY_SET_HID_REPORT_DESC 56 29 | #define AOA_ACCESSORY_SEND_HID_EVENT 57 30 | #define AOA_ACCESSORY_SET_AUDIO_MODE 58 31 | 32 | #define AOA_ACCESSORY_STRING_MANUFACTURER 0 33 | #define AOA_ACCESSORY_STRING_MODEL 1 34 | #define AOA_ACCESSORY_STRING_DESCRIPTION 2 35 | #define AOA_ACCESSORY_STRING_VERSION 3 36 | #define AOA_ACCESSORY_STRING_URI 4 37 | #define AOA_ACCESSORY_STRING_SERIAL 5 38 | 39 | struct aoa_string_info { 40 | char acc_manufacturer[64]; 41 | char acc_model[64]; 42 | char acc_description[64]; 43 | char acc_version[64]; 44 | char acc_uri[64]; 45 | char acc_serial[64]; 46 | }; 47 | 48 | #endif /* USB_AOA_H */ -------------------------------------------------------------------------------- /class/aoa/usbh_aoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_AOA_H 7 | #define USBH_AOA_H 8 | 9 | #include "usb_aoa.h" 10 | 11 | struct usbh_aoa { 12 | struct usbh_hubport *hport; 13 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 14 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 15 | 16 | struct usbh_urb bulkout_urb; 17 | struct usbh_urb bulkin_urb; 18 | 19 | uint8_t intf; 20 | uint8_t minor; 21 | 22 | void *user_data; 23 | }; 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | int usbh_aoa_switch(struct usbh_hubport *hport, struct aoa_string_info *info); 30 | int usbh_aoa_register_hid(struct usbh_aoa *aoa_class, uint16_t id, uint8_t *report, uint32_t report_len); 31 | int usbh_aoa_send_hid_event(struct usbh_aoa *aoa_class, uint16_t id, uint8_t *event, uint32_t event_len); 32 | 33 | void usbh_aoa_run(struct usbh_aoa *aoa_class); 34 | void usbh_aoa_stop(struct usbh_aoa *aoa_class); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* USBH_AOA_H */ -------------------------------------------------------------------------------- /class/audio/usbd_audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_AUDIO_H 7 | #define USBD_AUDIO_H 8 | 9 | #include "usb_audio.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | struct audio_entity_info { 16 | uint8_t bDescriptorSubtype; 17 | uint8_t bEntityId; 18 | uint8_t ep; 19 | }; 20 | 21 | /* Init audio interface driver */ 22 | struct usbd_interface *usbd_audio_init_intf(uint8_t busid, struct usbd_interface *intf, 23 | uint16_t uac_version, 24 | struct audio_entity_info *table, 25 | uint8_t num); 26 | 27 | void usbd_audio_open(uint8_t busid, uint8_t intf); 28 | void usbd_audio_close(uint8_t busid, uint8_t intf); 29 | 30 | void usbd_audio_set_volume(uint8_t busid, uint8_t ep, uint8_t ch, int volume_db); 31 | int usbd_audio_get_volume(uint8_t busid, uint8_t ep, uint8_t ch); 32 | void usbd_audio_set_mute(uint8_t busid, uint8_t ep, uint8_t ch, bool mute); 33 | bool usbd_audio_get_mute(uint8_t busid, uint8_t ep, uint8_t ch); 34 | void usbd_audio_set_sampling_freq(uint8_t busid, uint8_t ep, uint32_t sampling_freq); 35 | uint32_t usbd_audio_get_sampling_freq(uint8_t busid, uint8_t ep); 36 | 37 | void usbd_audio_get_sampling_freq_table(uint8_t busid, uint8_t ep, uint8_t **sampling_freq_table); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* USBD_AUDIO_H */ 44 | -------------------------------------------------------------------------------- /class/audio/usbh_audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_AUDIO_H 7 | #define USBH_AUDIO_H 8 | 9 | #include "usb_audio.h" 10 | 11 | #ifndef CONFIG_USBHOST_AUDIO_MAX_STREAMS 12 | #define CONFIG_USBHOST_AUDIO_MAX_STREAMS 3 13 | #endif 14 | 15 | struct usbh_audio_ac_msg { 16 | struct audio_cs_if_ac_input_terminal_descriptor ac_input; 17 | struct audio_cs_if_ac_feature_unit_descriptor ac_feature_unit; 18 | struct audio_cs_if_ac_output_terminal_descriptor ac_output; 19 | }; 20 | 21 | struct usbh_audio_as_msg { 22 | const char *stream_name; 23 | uint8_t stream_intf; 24 | uint8_t input_terminal_id; 25 | uint8_t feature_terminal_id; 26 | uint8_t output_terminal_id; 27 | uint8_t ep_attr; 28 | uint8_t num_of_altsetting; 29 | uint16_t volume_min; 30 | uint16_t volume_max; 31 | uint16_t volume_res; 32 | uint16_t volume_cur; 33 | bool mute; 34 | struct audio_cs_if_as_general_descriptor as_general; 35 | struct audio_cs_if_as_format_type_descriptor as_format[CONFIG_USBHOST_MAX_INTF_ALTSETTINGS]; 36 | }; 37 | 38 | struct usbh_audio { 39 | struct usbh_hubport *hport; 40 | struct usb_endpoint_descriptor *isoin; /* ISO IN endpoint */ 41 | struct usb_endpoint_descriptor *isoout; /* ISO OUT endpoint */ 42 | 43 | uint8_t ctrl_intf; /* interface number */ 44 | uint8_t minor; 45 | uint16_t isoin_mps; 46 | uint16_t isoout_mps; 47 | bool is_opened; 48 | uint16_t bcdADC; 49 | uint8_t bInCollection; 50 | uint8_t stream_intf_num; 51 | struct usbh_audio_as_msg as_msg_table[CONFIG_USBHOST_AUDIO_MAX_STREAMS]; 52 | 53 | void *user_data; 54 | }; 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | int usbh_audio_open(struct usbh_audio *audio_class, const char *name, uint32_t samp_freq, uint8_t bitresolution); 61 | int usbh_audio_close(struct usbh_audio *audio_class, const char *name); 62 | int usbh_audio_set_volume(struct usbh_audio *audio_class, const char *name, uint8_t ch, int volume_db); 63 | int usbh_audio_set_mute(struct usbh_audio *audio_class, const char *name, uint8_t ch, bool mute); 64 | 65 | void usbh_audio_run(struct usbh_audio *audio_class); 66 | void usbh_audio_stop(struct usbh_audio *audio_class); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* USBH_AUDIO_H */ 73 | -------------------------------------------------------------------------------- /class/cdc/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_CDC_H 7 | #define USBD_CDC_H 8 | 9 | // legacy for old version 10 | 11 | #include "usbd_cdc_acm.h" 12 | 13 | #endif -------------------------------------------------------------------------------- /class/cdc/usbd_cdc_acm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_CDC_ACM_H 7 | #define USBD_CDC_ACM_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Init cdc acm interface driver */ 16 | struct usbd_interface *usbd_cdc_acm_init_intf(uint8_t busid, struct usbd_interface *intf); 17 | 18 | /* Setup request command callback api */ 19 | void usbd_cdc_acm_set_line_coding(uint8_t busid, uint8_t intf, struct cdc_line_coding *line_coding); 20 | void usbd_cdc_acm_get_line_coding(uint8_t busid, uint8_t intf, struct cdc_line_coding *line_coding); 21 | void usbd_cdc_acm_set_dtr(uint8_t busid, uint8_t intf, bool dtr); 22 | void usbd_cdc_acm_set_rts(uint8_t busid, uint8_t intf, bool rts); 23 | void usbd_cdc_acm_send_break(uint8_t busid, uint8_t intf); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* USBD_CDC_ACM_H */ 30 | -------------------------------------------------------------------------------- /class/cdc/usbd_cdc_ecm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_CDC_ECM_H 7 | #define USBD_CDC_ECM_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Init cdc ecm interface driver */ 16 | struct usbd_interface *usbd_cdc_ecm_init_intf(struct usbd_interface *intf, const uint8_t int_ep, const uint8_t out_ep, const uint8_t in_ep); 17 | 18 | int usbd_cdc_ecm_set_connect(bool connect, uint32_t speed[2]); 19 | 20 | void usbd_cdc_ecm_data_recv_done(uint32_t len); 21 | void usbd_cdc_ecm_data_send_done(uint32_t len); 22 | int usbd_cdc_ecm_start_write(uint8_t *buf, uint32_t len); 23 | int usbd_cdc_ecm_start_read(uint8_t *buf, uint32_t len); 24 | 25 | #ifdef CONFIG_USBDEV_CDC_ECM_USING_LWIP 26 | #include "lwip/netif.h" 27 | #include "lwip/pbuf.h" 28 | struct pbuf *usbd_cdc_ecm_eth_rx(void); 29 | int usbd_cdc_ecm_eth_tx(struct pbuf *p); 30 | #endif 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* USBD_CDC_ECM_H */ 37 | -------------------------------------------------------------------------------- /class/cdc/usbh_cdc_acm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_CDC_ACM_H 7 | #define USBH_CDC_ACM_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | struct usbh_cdc_acm { 12 | struct usbh_hubport *hport; 13 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 14 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 15 | #ifdef CONFIG_USBHOST_CDC_ACM_NOTIFY 16 | struct usb_endpoint_descriptor *intin; /* INTR IN endpoint (optional) */ 17 | #endif 18 | struct usbh_urb bulkout_urb; 19 | struct usbh_urb bulkin_urb; 20 | #ifdef CONFIG_USBHOST_CDC_ACM_NOTIFY 21 | struct usbh_urb intin_urb; 22 | #endif 23 | 24 | struct cdc_line_coding linecoding; 25 | 26 | uint8_t intf; 27 | uint8_t minor; 28 | 29 | void *user_data; 30 | }; 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | int usbh_cdc_acm_set_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding); 37 | int usbh_cdc_acm_get_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding); 38 | int usbh_cdc_acm_set_line_state(struct usbh_cdc_acm *cdc_acm_class, bool dtr, bool rts); 39 | 40 | int usbh_cdc_acm_bulk_in_transfer(struct usbh_cdc_acm *cdc_acm_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); 41 | int usbh_cdc_acm_bulk_out_transfer(struct usbh_cdc_acm *cdc_acm_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); 42 | 43 | void usbh_cdc_acm_run(struct usbh_cdc_acm *cdc_acm_class); 44 | void usbh_cdc_acm_stop(struct usbh_cdc_acm *cdc_acm_class); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* USBH_CDC_ACM_H */ 51 | -------------------------------------------------------------------------------- /class/cdc/usbh_cdc_ecm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_CDC_ECM_H 7 | #define USBH_CDC_ECM_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | struct usbh_cdc_ecm { 12 | struct usbh_hubport *hport; 13 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 14 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 15 | struct usb_endpoint_descriptor *intin; /* Interrupt IN endpoint */ 16 | struct usbh_urb bulkout_urb; /* Bulk out endpoint */ 17 | struct usbh_urb bulkin_urb; /* Bulk IN endpoint */ 18 | struct usbh_urb intin_urb; /* Interrupt IN endpoint */ 19 | 20 | uint8_t ctrl_intf; /* Control interface number */ 21 | uint8_t data_intf; /* Data interface number */ 22 | uint8_t minor; 23 | 24 | uint8_t mac[6]; 25 | bool connect_status; 26 | uint16_t max_segment_size; 27 | uint32_t speed[2]; 28 | 29 | void *user_data; 30 | }; 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | int usbh_cdc_ecm_get_connect_status(struct usbh_cdc_ecm *cdc_ecm_class); 37 | 38 | void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class); 39 | void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class); 40 | 41 | uint8_t *usbh_cdc_ecm_get_eth_txbuf(void); 42 | int usbh_cdc_ecm_eth_output(uint32_t buflen); 43 | void usbh_cdc_ecm_eth_input(uint8_t *buf, uint32_t buflen); 44 | void usbh_cdc_ecm_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* USBH_CDC_ECM_H */ 51 | -------------------------------------------------------------------------------- /class/cdc/usbh_cdc_ncm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_CDC_NCM_H 7 | #define USBH_CDC_NCM_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | struct usbh_cdc_ncm { 12 | struct usbh_hubport *hport; 13 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 14 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 15 | struct usb_endpoint_descriptor *intin; /* Interrupt IN endpoint */ 16 | struct usbh_urb bulkout_urb; /* Bulk out endpoint */ 17 | struct usbh_urb bulkin_urb; /* Bulk IN endpoint */ 18 | struct usbh_urb intin_urb; /* Interrupt IN endpoint */ 19 | 20 | uint8_t ctrl_intf; /* Control interface number */ 21 | uint8_t data_intf; /* Data interface number */ 22 | uint8_t minor; 23 | 24 | struct cdc_ncm_ntb_parameters ntb_param; 25 | uint16_t bulkin_sequence; 26 | uint16_t bulkout_sequence; 27 | 28 | uint8_t mac[6]; 29 | bool connect_status; 30 | uint16_t max_segment_size; 31 | uint32_t speed[2]; 32 | 33 | void *user_data; 34 | }; 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | int usbh_cdc_ncm_get_connect_status(struct usbh_cdc_ncm *cdc_ncm_class); 41 | 42 | void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class); 43 | void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class); 44 | 45 | uint8_t *usbh_cdc_ncm_get_eth_txbuf(void); 46 | int usbh_cdc_ncm_eth_output(uint32_t buflen); 47 | void usbh_cdc_ncm_eth_input(uint8_t *buf, uint32_t buflen); 48 | void usbh_cdc_ncm_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif /* USBH_CDC_NCM_H */ 55 | -------------------------------------------------------------------------------- /class/dfu/usbd_dfu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_DFU_H 7 | #define USBD_DFU_H 8 | 9 | #include "usb_dfu.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Init dfu interface driver */ 16 | struct usbd_interface *usbd_dfu_init_intf(struct usbd_interface *intf); 17 | 18 | /* Interface functions that need to be implemented by the user */ 19 | uint8_t *dfu_read_flash(uint8_t *src, uint8_t *dest, uint32_t len); 20 | uint16_t dfu_write_flash(uint8_t *src, uint8_t *dest, uint32_t len); 21 | uint16_t dfu_erase_flash(uint32_t add); 22 | void dfu_leave(void); 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif /* USBD_DFU_H */ 28 | -------------------------------------------------------------------------------- /class/hid/usbd_hid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_HID_H 7 | #define USBD_HID_H 8 | 9 | #include "usb_hid.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Init hid interface driver */ 16 | struct usbd_interface *usbd_hid_init_intf(uint8_t busid, struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len); 17 | 18 | /* Setup request command callback api */ 19 | void usbd_hid_get_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t **data, uint32_t *len); 20 | uint8_t usbd_hid_get_idle(uint8_t busid, uint8_t intf, uint8_t report_id); 21 | uint8_t usbd_hid_get_protocol(uint8_t busid, uint8_t intf); 22 | void usbd_hid_set_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t *report, uint32_t report_len); 23 | void usbd_hid_set_idle(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t duration); 24 | void usbd_hid_set_protocol(uint8_t busid, uint8_t intf, uint8_t protocol); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif /* USBD_HID_H */ 31 | -------------------------------------------------------------------------------- /class/hid/usbh_hid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_HID_H 7 | #define USBH_HID_H 8 | 9 | #include "usb_hid.h" 10 | 11 | struct usbh_hid { 12 | struct usbh_hubport *hport; 13 | struct usb_endpoint_descriptor *intin; /* INTR IN endpoint */ 14 | struct usb_endpoint_descriptor *intout; /* INTR OUT endpoint */ 15 | struct usbh_urb intin_urb; /* INTR IN urb */ 16 | struct usbh_urb intout_urb; /* INTR OUT urb */ 17 | 18 | uint16_t report_size; 19 | 20 | uint8_t protocol; 21 | uint8_t intf; /* interface number */ 22 | uint8_t minor; 23 | 24 | void *user_data; 25 | }; 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | int usbh_hid_get_report_descriptor(struct usbh_hid *hid_class, uint8_t *buffer, uint32_t buflen); 32 | int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t duration); 33 | int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer); 34 | int usbh_hid_set_protocol(struct usbh_hid *hid_class, uint8_t protocol); 35 | int usbh_hid_get_protocol(struct usbh_hid *hid_class, uint8_t *protocol); 36 | int usbh_hid_set_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen); 37 | int usbh_hid_get_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen); 38 | 39 | void usbh_hid_run(struct usbh_hid *hid_class); 40 | void usbh_hid_stop(struct usbh_hid *hid_class); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* USBH_HID_H */ 47 | -------------------------------------------------------------------------------- /class/hub/usbh_hub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_HUB_H 7 | #define USBH_HUB_H 8 | 9 | #include "usb_hub.h" 10 | 11 | struct usbh_hub; 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | int usbh_hub_set_feature(struct usbh_hub *hub, uint8_t port, uint8_t feature); 18 | int usbh_hub_clear_feature(struct usbh_hub *hub, uint8_t port, uint8_t feature); 19 | 20 | void usbh_hub_thread_wakeup(struct usbh_hub *hub); 21 | 22 | int usbh_hub_initialize(struct usbh_bus *bus); 23 | int usbh_hub_deinitialize(struct usbh_bus *bus); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* USBH_HUB_H */ 30 | -------------------------------------------------------------------------------- /class/msc/usbd_msc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * Copyright (c) 2024, zhihong chen 4 | * 5 | * SPDX-License-Identifier: Apache-2.0 6 | */ 7 | #ifndef USBD_MSC_H 8 | #define USBD_MSC_H 9 | 10 | #include "usb_msc.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /* Init msc interface driver */ 17 | struct usbd_interface *usbd_msc_init_intf(uint8_t busid, struct usbd_interface *intf, 18 | const uint8_t out_ep, 19 | const uint8_t in_ep); 20 | 21 | void usbd_msc_get_cap(uint8_t busid, uint8_t lun, uint32_t *block_num, uint32_t *block_size); 22 | int usbd_msc_sector_read(uint8_t busid, uint8_t lun, uint32_t sector, uint8_t *buffer, uint32_t length); 23 | int usbd_msc_sector_write(uint8_t busid, uint8_t lun, uint32_t sector, uint8_t *buffer, uint32_t length); 24 | 25 | void usbd_msc_set_readonly(uint8_t busid, bool readonly); 26 | bool usbd_msc_get_popup(uint8_t busid); 27 | 28 | void usbd_msc_polling(uint8_t busid); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* USBD_MSC_H */ 35 | -------------------------------------------------------------------------------- /class/msc/usbh_msc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_MSC_H 7 | #define USBH_MSC_H 8 | 9 | #include "usb_msc.h" 10 | #include "usb_scsi.h" 11 | 12 | struct usbh_msc { 13 | struct usbh_hubport *hport; 14 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 15 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 16 | struct usbh_urb bulkin_urb; /* Bulk IN urb */ 17 | struct usbh_urb bulkout_urb; /* Bulk OUT urb */ 18 | 19 | uint8_t intf; /* Data interface number */ 20 | uint8_t sdchar; 21 | uint32_t blocknum; /* Number of blocks on the USB mass storage device */ 22 | uint16_t blocksize; /* Block size of USB mass storage device */ 23 | 24 | void *user_data; 25 | }; 26 | 27 | struct usbh_msc_modeswitch_config { 28 | const char *name; 29 | uint16_t vid; /* Vendor ID (for vendor/product specific devices) */ 30 | uint16_t pid; /* Product ID (for vendor/product specific devices) */ 31 | const uint8_t *message_content; 32 | }; 33 | 34 | void usbh_msc_modeswitch_enable(struct usbh_msc_modeswitch_config *config); 35 | int usbh_msc_scsi_init(struct usbh_msc *msc_class); 36 | int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors); 37 | int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors); 38 | 39 | void usbh_msc_run(struct usbh_msc *msc_class); 40 | void usbh_msc_stop(struct usbh_msc *msc_class); 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* USBH_MSC_H */ 51 | -------------------------------------------------------------------------------- /class/mtp/usbd_mtp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_MTP_H 7 | #define USBD_MTP_H 8 | 9 | #include "usb_mtp.h" 10 | #include 11 | #include 12 | 13 | /* gcc toolchain does not implement dirent.h, so we define our own MTP_DIR and mtp_dirent */ 14 | 15 | typedef void MTP_DIR; 16 | 17 | struct mtp_statfs { 18 | size_t f_bsize; /* block size */ 19 | size_t f_blocks; /* total data blocks in file system */ 20 | size_t f_bfree; /* free blocks in file system */ 21 | }; 22 | 23 | struct mtp_dirent { 24 | uint8_t d_type; /* The type of the file */ 25 | uint8_t d_namlen; /* The length of the not including the terminating null file name */ 26 | uint16_t d_reclen; /* length of this record */ 27 | char d_name[CONFIG_USBDEV_MTP_MAX_PATHNAME]; /* The null-terminated file name */ 28 | }; 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | struct usbd_interface *usbd_mtp_init_intf(struct usbd_interface *intf, 35 | const uint8_t out_ep, 36 | const uint8_t in_ep, 37 | const uint8_t int_ep); 38 | 39 | const char *usbd_mtp_fs_root_path(void); 40 | const char *usbd_mtp_fs_description(void); 41 | 42 | int usbd_mtp_mkdir(const char *path); 43 | int usbd_mtp_rmdir(const char *path); 44 | MTP_DIR *usbd_mtp_opendir(const char *name); 45 | int usbd_mtp_closedir(MTP_DIR *d); 46 | struct mtp_dirent *usbd_mtp_readdir(MTP_DIR *d); 47 | 48 | int usbd_mtp_statfs(const char *path, struct mtp_statfs *buf); 49 | int usbd_mtp_stat(const char *file, struct stat *buf); 50 | 51 | int usbd_mtp_open(const char *path, uint8_t mode); 52 | int usbd_mtp_close(int fd); 53 | int usbd_mtp_read(int fd, void *buf, size_t len); 54 | int usbd_mtp_write(int fd, const void *buf, size_t len); 55 | 56 | int usbd_mtp_unlink(const char *path); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* USBD_MTP_H */ 63 | -------------------------------------------------------------------------------- /class/template/usb_xxx.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_XXX_H 2 | #define _USB_XXX_H 3 | 4 | #endif -------------------------------------------------------------------------------- /class/template/usbd_xxx.c: -------------------------------------------------------------------------------- 1 | #include "usbd_core.h" 2 | #include "usbd_xxx.h" 3 | 4 | static int xxx_class_interface_request_handler(uint8_t busid, struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) 5 | { 6 | USB_LOG_WRN("XXX Class request: " 7 | "bRequest 0x%02x\r\n", 8 | setup->bRequest); 9 | 10 | switch (setup->bRequest) { 11 | default: 12 | USB_LOG_WRN("Unhandled XXX Class bRequest 0x%02x\r\n", setup->bRequest); 13 | return -1; 14 | } 15 | 16 | return 0; 17 | } 18 | 19 | static void xxx_notify_handler(uint8_t busid, uint8_t event, void *arg) 20 | { 21 | switch (event) { 22 | case USBD_EVENT_RESET: 23 | 24 | break; 25 | 26 | default: 27 | break; 28 | } 29 | } 30 | 31 | struct usbd_interface *usbd_xxx_init_intf(uint8_t busid, struct usbd_interface *intf) 32 | { 33 | intf->class_interface_handler = xxx_class_interface_request_handler; 34 | intf->class_endpoint_handler = NULL; 35 | intf->vendor_handler = NULL; 36 | intf->notify_handler = xxx_notify_handler; 37 | 38 | return intf; 39 | } 40 | -------------------------------------------------------------------------------- /class/template/usbd_xxx.h: -------------------------------------------------------------------------------- 1 | #ifndef _USBD_XXX_H_ 2 | #define _USBD_XXX_H_ 3 | 4 | #include "usb_xxx.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | struct usbd_interface *usbd_xxx_init_intf(uint8_t busid, struct usbd_interface *intf); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif /* _USBD_XXX_H_ */ 17 | -------------------------------------------------------------------------------- /class/template/usbh_xxx.h: -------------------------------------------------------------------------------- 1 | #ifndef _USBH_XXX_H 2 | #define _USBH_XXX_H 3 | 4 | #include "usb_xxx.h" 5 | 6 | struct usbh_xxx { 7 | struct usbh_hubport *hport; 8 | struct usb_endpoint_descriptor *xxxin; 9 | struct usb_endpoint_descriptor *xxxout; 10 | struct usbh_urb xxxin_urb; 11 | struct usbh_urb xxxout_urb; 12 | 13 | uint8_t intf; /* interface number */ 14 | uint8_t minor; 15 | 16 | void *user_data; 17 | }; 18 | 19 | void usbh_xxx_run(struct usbh_xxx *xxx_class); 20 | void usbh_xxx_stop(struct usbh_xxx *xxx_class); 21 | 22 | #endif -------------------------------------------------------------------------------- /class/vendor/net/usbh_rtl8152.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_RTL8152_H 7 | #define USBH_RTL8152_H 8 | 9 | struct usbh_rtl8152 { 10 | struct usbh_hubport *hport; 11 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 12 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 13 | struct usb_endpoint_descriptor *intin; /* INTR IN endpoint */ 14 | struct usbh_urb bulkout_urb; 15 | struct usbh_urb bulkin_urb; 16 | struct usbh_urb intin_urb; 17 | 18 | uint8_t intf; 19 | 20 | uint8_t mac[6]; 21 | bool connect_status; 22 | uint32_t speed[2]; 23 | 24 | uint8_t version; 25 | uint8_t eee_adv; 26 | uint8_t eee_en; 27 | uint8_t supports_gmii; 28 | uint16_t min_mtu; 29 | uint16_t max_mtu; 30 | uint16_t ocp_base; 31 | uint32_t saved_wolopts; 32 | uint32_t rx_buf_sz; 33 | 34 | struct rtl_ops { 35 | void (*init)(struct usbh_rtl8152 *tp); 36 | int (*enable)(struct usbh_rtl8152 *tp); 37 | void (*disable)(struct usbh_rtl8152 *tp); 38 | void (*up)(struct usbh_rtl8152 *tp); 39 | void (*down)(struct usbh_rtl8152 *tp); 40 | void (*unload)(struct usbh_rtl8152 *tp); 41 | bool (*in_nway)(struct usbh_rtl8152 *tp); 42 | void (*hw_phy_cfg)(struct usbh_rtl8152 *tp); 43 | void (*autosuspend_en)(struct usbh_rtl8152 *tp, bool enable); 44 | void (*change_mtu)(struct usbh_rtl8152 *tp); 45 | } rtl_ops; 46 | 47 | void *user_data; 48 | }; 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | int usbh_rtl8152_get_connect_status(struct usbh_rtl8152 *rtl8152_class); 55 | 56 | void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class); 57 | void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class); 58 | 59 | uint8_t *usbh_rtl8152_get_eth_txbuf(void); 60 | int usbh_rtl8152_eth_output(uint32_t buflen); 61 | void usbh_rtl8152_eth_input(uint8_t *buf, uint32_t buflen); 62 | void usbh_rtl8152_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* USBH_RTL8152_H */ -------------------------------------------------------------------------------- /class/vendor/serial/usbh_ch34x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_CH34X_H 7 | #define USBH_CH34X_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | /* Requests */ 12 | #define CH34X_READ_VERSION 0x5F 13 | #define CH34X_WRITE_REG 0x9A 14 | #define CH34X_READ_REG 0x95 15 | #define CH34X_SERIAL_INIT 0xA1 16 | #define CH34X_MODEM_CTRL 0xA4 17 | 18 | // modem control bits 19 | #define CH34X_BIT_RTS (1 << 6) 20 | #define CH34X_BIT_DTR (1 << 5) 21 | 22 | #define CH341_CTO_O 0x10 23 | #define CH341_CTO_D 0x20 24 | #define CH341_CTO_R 0x40 25 | #define CH341_CTI_C 0x01 26 | #define CH341_CTI_DS 0x02 27 | #define CH341_CTRL_RI 0x04 28 | #define CH341_CTI_DC 0x08 29 | #define CH341_CTI_ST 0x0f 30 | 31 | #define CH341_L_ER 0x80 32 | #define CH341_L_ET 0x40 33 | #define CH341_L_PS 0x38 34 | #define CH341_L_PM 0x28 35 | #define CH341_L_PE 0x18 36 | #define CH341_L_PO 0x08 37 | #define CH341_L_SB 0x04 38 | #define CH341_L_D8 0x03 39 | #define CH341_L_D7 0x02 40 | #define CH341_L_D6 0x01 41 | #define CH341_L_D5 0x00 42 | 43 | struct usbh_ch34x { 44 | struct usbh_hubport *hport; 45 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 46 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 47 | struct usbh_urb bulkout_urb; 48 | struct usbh_urb bulkin_urb; 49 | 50 | struct cdc_line_coding line_coding; 51 | 52 | uint8_t intf; 53 | uint8_t minor; 54 | 55 | void *user_data; 56 | }; 57 | 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | int usbh_ch34x_set_line_coding(struct usbh_ch34x *ch34x_class, struct cdc_line_coding *line_coding); 63 | int usbh_ch34x_get_line_coding(struct usbh_ch34x *ch34x_class, struct cdc_line_coding *line_coding); 64 | int usbh_ch34x_set_line_state(struct usbh_ch34x *ch34x_class, bool dtr, bool rts); 65 | 66 | int usbh_ch34x_bulk_in_transfer(struct usbh_ch34x *ch34x_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); 67 | int usbh_ch34x_bulk_out_transfer(struct usbh_ch34x *ch34x_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); 68 | 69 | void usbh_ch34x_run(struct usbh_ch34x *ch34x_class); 70 | void usbh_ch34x_stop(struct usbh_ch34x *ch34x_class); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* USBH_CH34X_H */ 77 | -------------------------------------------------------------------------------- /class/vendor/serial/usbh_pl2303.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_PL2303_H 7 | #define USBH_PL2303_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | #define PL2303_SET_REQUEST 0x01 12 | #define PL2303_SET_REQUEST_PL2303HXN 0x80 13 | #define PL2303_SET_CRTSCTS 0x41 14 | #define PL2303_SET_CRTSCTS_PL2303X 0x61 15 | #define PL2303_SET_CRTSCTS_PL2303HXN 0xFA 16 | #define PL2303_CLEAR_CRTSCTS_PL2303HXN 0xFF 17 | #define PL2303_CRTSCTS_REG_PL2303HXN 0x0A 18 | #define PL2303_STATUS_REG_PL2303HX 0x8080 19 | 20 | /* Different PL2303 IC types */ 21 | #define USBH_PL2303_TYPE_UNKNOWN 0 22 | #define USBH_PL2303_TYPE_PL2303 1 23 | #define USBH_PL2303_TYPE_PL2303HX 2 24 | #define USBH_PL2303_TYPE_PL2303HXD 3 25 | #define USBH_PL2303_TYPE_PL2303HXN 4 26 | 27 | struct usbh_pl2303 { 28 | struct usbh_hubport *hport; 29 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 30 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 31 | 32 | struct usbh_urb bulkout_urb; 33 | struct usbh_urb bulkin_urb; 34 | 35 | struct cdc_line_coding linecoding; 36 | 37 | uint8_t intf; 38 | uint8_t minor; 39 | uint8_t chiptype; 40 | 41 | void *user_data; 42 | }; 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | int usbh_pl2303_set_line_coding(struct usbh_pl2303 *pl2303_class, struct cdc_line_coding *line_coding); 49 | int usbh_pl2303_get_line_coding(struct usbh_pl2303 *pl2303_class, struct cdc_line_coding *line_coding); 50 | int usbh_pl2303_set_line_state(struct usbh_pl2303 *pl2303_class, bool dtr, bool rts); 51 | 52 | int usbh_pl2303_bulk_in_transfer(struct usbh_pl2303 *pl2303_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); 53 | int usbh_pl2303_bulk_out_transfer(struct usbh_pl2303 *pl2303_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); 54 | 55 | void usbh_pl2303_run(struct usbh_pl2303 *pl2303_class); 56 | void usbh_pl2303_stop(struct usbh_pl2303 *pl2303_class); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* USBH_PL2303_H */ 63 | -------------------------------------------------------------------------------- /class/vendor/wifi/README.md: -------------------------------------------------------------------------------- 1 | # BL616 USB WIFI 2 | 3 | Usbwifi firmware please contact bouffalolab. You can purchase a module in the following ways: 4 | 5 | - https://iot.mi.com/moduleBrowser.html 6 | - https://docs.ai-thinker.com/ai_m61 -------------------------------------------------------------------------------- /class/vendor/xbox/usbh_xbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, Till Harbaum 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_XBOX_H 7 | #define USBH_XBOX_H 8 | 9 | struct usbh_xbox { 10 | struct usbh_hubport *hport; 11 | struct usb_endpoint_descriptor *intin; /* INTR IN endpoint */ 12 | struct usb_endpoint_descriptor *intout; /* INTR OUT endpoint */ 13 | struct usbh_urb intin_urb; /* INTR IN urb */ 14 | struct usbh_urb intout_urb; /* INTR OUT urb */ 15 | 16 | uint8_t intf; /* interface number */ 17 | uint8_t minor; 18 | }; 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | void usbh_xbox_run(struct usbh_xbox *xbox_class); 25 | void usbh_xbox_stop(struct usbh_xbox *xbox_class); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* USBH_XBOX_H */ 32 | -------------------------------------------------------------------------------- /class/video/usbd_video.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_VIDEO_H 7 | #define USBD_VIDEO_H 8 | 9 | #include "usb_video.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Init video interface driver */ 16 | struct usbd_interface *usbd_video_init_intf(uint8_t busid, struct usbd_interface *intf, 17 | uint32_t dwFrameInterval, 18 | uint32_t dwMaxVideoFrameSize, 19 | uint32_t dwMaxPayloadTransferSize); 20 | 21 | void usbd_video_open(uint8_t busid, uint8_t intf); 22 | void usbd_video_close(uint8_t busid, uint8_t intf); 23 | 24 | bool usbd_video_stream_split_transfer(uint8_t busid, uint8_t ep); 25 | int usbd_video_stream_start_write(uint8_t busid, uint8_t ep, uint8_t *ep_buf, uint8_t *stream_buf, uint32_t stream_len, bool do_copy); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* USBD_VIDEO_H */ 32 | -------------------------------------------------------------------------------- /class/wireless/usbd_rndis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBD_RNDIS_H 7 | #define USBD_RNDIS_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Init rndis interface driver */ 16 | struct usbd_interface *usbd_rndis_init_intf(struct usbd_interface *intf, 17 | const uint8_t out_ep, 18 | const uint8_t in_ep, 19 | const uint8_t int_ep, uint8_t mac[6]); 20 | 21 | int usbd_rndis_set_connect(bool connect); 22 | 23 | void usbd_rndis_data_recv_done(uint32_t len); 24 | void usbd_rndis_data_send_done(uint32_t len); 25 | int usbd_rndis_start_write(uint8_t *buf, uint32_t len); 26 | int usbd_rndis_start_read(uint8_t *buf, uint32_t len); 27 | 28 | #ifdef CONFIG_USBDEV_RNDIS_USING_LWIP 29 | struct pbuf *usbd_rndis_eth_rx(void); 30 | int usbd_rndis_eth_tx(struct pbuf *p); 31 | #endif 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* USBD_RNDIS_H */ 38 | -------------------------------------------------------------------------------- /class/wireless/usbh_bluetooth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_BLUETOOTH_H 7 | #define USBH_BLUETOOTH_H 8 | 9 | #define USB_BLUETOOTH_HCI_NONE 0x00 10 | #define USB_BLUETOOTH_HCI_CMD 0x01 11 | #define USB_BLUETOOTH_HCI_ACL 0x02 12 | #define USB_BLUETOOTH_HCI_SCO 0x03 13 | #define USB_BLUETOOTH_HCI_EVT 0x04 14 | #define USB_BLUETOOTH_HCI_ISO 0x05 15 | 16 | struct usbh_bluetooth { 17 | struct usbh_hubport *hport; 18 | uint8_t intf; 19 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 20 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 21 | struct usbh_urb bulkin_urb; /* Bulk IN urb */ 22 | struct usbh_urb bulkout_urb; /* Bulk OUT urb */ 23 | #ifndef CONFIG_USBHOST_BLUETOOTH_HCI_H4 24 | struct usb_endpoint_descriptor *intin; /* INTR endpoint */ 25 | struct usb_endpoint_descriptor *isoin; /* Bulk IN endpoint */ 26 | struct usb_endpoint_descriptor *isoout; /* Bulk OUT endpoint */ 27 | struct usbh_urb intin_urb; /* INTR IN urb */ 28 | struct usbh_urb *isoin_urb; /* Bulk IN urb */ 29 | struct usbh_urb *isoout_urb; /* Bulk OUT urb */ 30 | uint8_t num_of_intf_altsettings; 31 | #endif 32 | 33 | void *user_data; 34 | }; 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | int usbh_bluetooth_hci_write(uint8_t hci_type, uint8_t *buffer, uint32_t buflen); 41 | void usbh_bluetooth_hci_read_callback(uint8_t *data, uint32_t len); 42 | #ifdef CONFIG_USBHOST_BLUETOOTH_HCI_H4 43 | void usbh_bluetooth_hci_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV); 44 | #else 45 | void usbh_bluetooth_hci_evt_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV); 46 | void usbh_bluetooth_hci_acl_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV); 47 | #endif 48 | 49 | void usbh_bluetooth_run(struct usbh_bluetooth *bluetooth_class); 50 | void usbh_bluetooth_stop(struct usbh_bluetooth *bluetooth_class); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* USBH_BLUETOOTH_H */ 57 | -------------------------------------------------------------------------------- /class/wireless/usbh_rndis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_RNDIS_H 7 | #define USBH_RNDIS_H 8 | 9 | #include "usb_cdc.h" 10 | 11 | struct usbh_rndis { 12 | struct usbh_hubport *hport; 13 | struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */ 14 | struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */ 15 | struct usb_endpoint_descriptor *intin; /* INTR endpoint */ 16 | struct usbh_urb bulkin_urb; /* Bulk IN urb */ 17 | struct usbh_urb bulkout_urb; /* Bulk OUT urb */ 18 | struct usbh_urb intin_urb; /* INTR IN urb */ 19 | 20 | uint8_t ctrl_intf; /* Control interface number */ 21 | uint8_t data_intf; /* Data interface number */ 22 | uint8_t minor; 23 | 24 | uint32_t request_id; 25 | uint32_t tx_offset; 26 | uint32_t max_transfer_pkts; /* max packets in one transfer */ 27 | uint32_t max_transfer_size; /* max size in one transfer */ 28 | 29 | uint32_t link_speed; 30 | bool connect_status; 31 | uint8_t mac[6]; 32 | 33 | void *user_data; 34 | }; 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | int usbh_rndis_get_connect_status(struct usbh_rndis *rndis_class); 41 | int usbh_rndis_keepalive(struct usbh_rndis *rndis_class); 42 | 43 | void usbh_rndis_run(struct usbh_rndis *rndis_class); 44 | void usbh_rndis_stop(struct usbh_rndis *rndis_class); 45 | 46 | uint8_t *usbh_rndis_get_eth_txbuf(void); 47 | int usbh_rndis_eth_output(uint32_t buflen); 48 | void usbh_rndis_eth_input(uint8_t *buf, uint32_t buflen); 49 | void usbh_rndis_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* USBH_RNDIS_H */ 56 | -------------------------------------------------------------------------------- /common/usb_dcache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USB_DCACHE_H 7 | #define USB_DCACHE_H 8 | 9 | #ifdef CONFIG_USB_DCACHE_ENABLE 10 | #if CONFIG_USB_ALIGN_SIZE % 32 11 | #error "CONFIG_USB_ALIGN_SIZE must be multiple of 32" 12 | #endif 13 | #else 14 | #define usb_dcache_clean(addr, size) 15 | #define usb_dcache_invalidate(addr, size) 16 | #define usb_dcache_flush(addr, size) 17 | #endif 18 | 19 | #endif /* USB_DCACHE_H */ 20 | -------------------------------------------------------------------------------- /common/usb_errno.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USB_ERRNO_H 7 | #define USB_ERRNO_H 8 | 9 | #define USB_ERR_NOMEM 1 10 | #define USB_ERR_INVAL 2 11 | #define USB_ERR_NODEV 3 12 | #define USB_ERR_NOTCONN 4 13 | #define USB_ERR_NOTSUPP 5 14 | #define USB_ERR_BUSY 6 15 | #define USB_ERR_RANGE 7 16 | #define USB_ERR_STALL 8 17 | #define USB_ERR_BABBLE 9 18 | #define USB_ERR_NAK 10 19 | #define USB_ERR_DT 11 20 | #define USB_ERR_IO 12 21 | #define USB_ERR_SHUTDOWN 13 22 | #define USB_ERR_TIMEOUT 14 23 | 24 | #endif /* USB_ERRNO_H */ 25 | -------------------------------------------------------------------------------- /common/usb_memcpy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USB_MEMCPY_H 7 | #define USB_MEMCPY_H 8 | 9 | #include 10 | #include 11 | 12 | #define ALIGN_UP_DWORD(x) ((uint32_t)(uintptr_t)(x) & (sizeof(uint32_t) - 1)) 13 | 14 | static inline void dword2array(char *addr, uint32_t w) 15 | { 16 | addr[0] = w; 17 | addr[1] = w >> 8; 18 | addr[2] = w >> 16; 19 | addr[3] = w >> 24; 20 | } 21 | 22 | static inline void *usb_memcpy(void *s1, const void *s2, size_t n) 23 | { 24 | char *b1 = (char *)s1; 25 | const char *b2 = (const char *)s2; 26 | uint32_t *w1; 27 | const uint32_t *w2; 28 | 29 | if (ALIGN_UP_DWORD(b1) == ALIGN_UP_DWORD(b2)) { 30 | while (ALIGN_UP_DWORD(b1) != 0 && n > 0) { 31 | *b1++ = *b2++; 32 | --n; 33 | } 34 | 35 | w1 = (uint32_t *)b1; 36 | w2 = (const uint32_t *)b2; 37 | 38 | while (n >= 4 * sizeof(uint32_t)) { 39 | *w1++ = *w2++; 40 | *w1++ = *w2++; 41 | *w1++ = *w2++; 42 | *w1++ = *w2++; 43 | n -= 4 * sizeof(uint32_t); 44 | } 45 | 46 | while (n >= sizeof(uint32_t)) { 47 | *w1++ = *w2++; 48 | n -= sizeof(uint32_t); 49 | } 50 | 51 | b1 = (char *)w1; 52 | b2 = (const char *)w2; 53 | 54 | while (n--) { 55 | *b1++ = *b2++; 56 | } 57 | } else { 58 | while (n > 0 && ALIGN_UP_DWORD(b2) != 0) { 59 | *b1++ = *b2++; 60 | --n; 61 | } 62 | 63 | w2 = (const uint32_t *)b2; 64 | 65 | while (n >= 4 * sizeof(uint32_t)) { 66 | dword2array(b1, *w2++); 67 | b1 += sizeof(uint32_t); 68 | dword2array(b1, *w2++); 69 | b1 += sizeof(uint32_t); 70 | dword2array(b1, *w2++); 71 | b1 += sizeof(uint32_t); 72 | dword2array(b1, *w2++); 73 | b1 += sizeof(uint32_t); 74 | n -= 4 * sizeof(uint32_t); 75 | } 76 | 77 | while (n >= sizeof(uint32_t)) { 78 | dword2array(b1, *w2++); 79 | b1 += sizeof(uint32_t); 80 | n -= sizeof(uint32_t); 81 | } 82 | 83 | b2 = (const char *)w2; 84 | 85 | while (n--) { 86 | *b1++ = *b2++; 87 | } 88 | } 89 | return s1; 90 | } 91 | 92 | #ifndef CONFIG_USB_MEMCPY_DISABLE 93 | #define memcpy usb_memcpy 94 | #endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /common/usb_otg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USB_OTG_H 7 | #define USB_OTG_H 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /** 16 | * @brief usb otg controller hardware or gpio id simulator init. 17 | * 18 | * @return On success will return 0, and others indicate fail. 19 | */ 20 | int usb_otg_init(uint8_t busid); 21 | /** 22 | * @brief usb otg controller hardware or gpio id simulator deinit. 23 | * 24 | * @return On success will return 0, and others indicate fail. 25 | */ 26 | int usb_otg_deinit(uint8_t busid); 27 | /** 28 | * @brief get current role mode. 29 | * 30 | * @return return USBOTG_MODE_HOST or USBOTG_MODE_DEVICE. 31 | */ 32 | uint8_t usbotg_get_current_mode(uint8_t busid); 33 | 34 | /* called by user */ 35 | void USBOTG_IRQHandler(uint8_t busid); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* USB_OTG_H */ -------------------------------------------------------------------------------- /common/usb_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USB_VERSION_H 7 | #define USB_VERSION_H 8 | 9 | #ifdef CHERRYUSB_VERSION 10 | #warning "Please do not define CHERRYUSB_VERSION in usb_config.h" 11 | #undef CHERRYUSB_VERSION 12 | #endif 13 | #ifdef CHERRYUSB_VERSION_STR 14 | #warning "Please do not define CHERRYUSB_VERSION_STR in usb_config.h" 15 | #undef CHERRYUSB_VERSION_STR 16 | #endif 17 | 18 | #define CHERRYUSB_VERSION 0x010500 19 | #define CHERRYUSB_VERSION_STR "v1.5.0" 20 | 21 | #endif -------------------------------------------------------------------------------- /core/usbotg_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBOTG_CORE_H 7 | #define USBOTG_CORE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #define USBOTG_MODE_UNKNOWN 0 14 | #define USBOTG_MODE_OTG 1 15 | #define USBOTG_MODE_HOST 2 16 | #define USBOTG_MODE_DEVICE 3 17 | 18 | #include "usbd_core.h" 19 | #include "usbh_core.h" 20 | #include "usb_otg.h" 21 | 22 | int usbotg_initialize(uint8_t otg_mode, uint8_t busid, uint32_t reg_base, 23 | int (*usbh_initialize)(uint8_t busid, uint32_t reg_base), 24 | int (*usbd_initialize)(uint8_t busid, uint32_t reg_base)); 25 | int usbotg_deinitialize(uint8_t busid, uint32_t reg_base); 26 | 27 | /* called by user */ 28 | void usbotg_trigger_role_change(uint8_t busid); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* USBOTG_CORE_H */ -------------------------------------------------------------------------------- /demo/CherryUSB.h264: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/demo/CherryUSB.h264 -------------------------------------------------------------------------------- /demo/CherryUSB.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/demo/CherryUSB.jpg -------------------------------------------------------------------------------- /demo/CherryUSB_64x48.YUYV: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/demo/CherryUSB_64x48.YUYV -------------------------------------------------------------------------------- /demo/adb/cherryadb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/demo/adb/cherryadb.png -------------------------------------------------------------------------------- /demo/bootuf2/bootuf2_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef BOOTUF2_CONFIG_H 7 | #define BOOTUF2_CONFIG_H 8 | 9 | #define CONFIG_PRODUCT "CherryUSB" 10 | #define CONFIG_BOARD "CherryUSB BOARD" 11 | #define CONFIG_BOOTUF2_INDEX_URL "https://github.com/cherry-embedded" 12 | #define CONFIG_BOOTUF2_JOIN_URL "http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=GyH2M5XfWTHQzmZis4ClpgvfdObPrvtk&authKey=LmcLhfno%2BiW51wmgVC%2F8WoYwUXqiclzWDHMU1Jy1d6S8cECJ4Q7bfJ%2FTe67RLakI&noverify=0&group_code=642693751" 13 | 14 | #define CONFIG_BOOTUF2_CACHE_SIZE 4096 15 | #define CONFIG_BOOTUF2_SECTOR_SIZE 512 16 | #define CONFIG_BOOTUF2_SECTOR_PER_CLUSTER 2 17 | #define CONFIG_BOOTUF2_SECTOR_RESERVED 1 18 | #define CONFIG_BOOTUF2_NUM_OF_FAT 2 19 | #define CONFIG_BOOTUF2_ROOT_ENTRIES 64 20 | 21 | #define CONFIG_BOOTUF2_FAMILYID 0xFFFFFFFF 22 | #define CONFIG_BOOTUF2_FLASHMAX 0x800000 23 | #define CONFIG_BOOTUF2_PAGE_COUNTMAX 1024 24 | 25 | #endif -------------------------------------------------------------------------------- /demo/bootuf2/cherryuf2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/demo/bootuf2/cherryuf2.png -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | *build -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/assets/actions.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/actions.jpg -------------------------------------------------------------------------------- /docs/assets/artinchip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/artinchip.jpg -------------------------------------------------------------------------------- /docs/assets/bekencorp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/bekencorp.jpg -------------------------------------------------------------------------------- /docs/assets/bouffalolab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/bouffalolab.jpg -------------------------------------------------------------------------------- /docs/assets/canaan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/canaan.jpg -------------------------------------------------------------------------------- /docs/assets/eastsoft.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/eastsoft.jpg -------------------------------------------------------------------------------- /docs/assets/espressif.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/espressif.png -------------------------------------------------------------------------------- /docs/assets/hpmicro.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/hpmicro.jpg -------------------------------------------------------------------------------- /docs/assets/nationstech.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/nationstech.jpg -------------------------------------------------------------------------------- /docs/assets/nuvoton.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/nuvoton.jpg -------------------------------------------------------------------------------- /docs/assets/nxp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/nxp.png -------------------------------------------------------------------------------- /docs/assets/phytium.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/phytium.jpg -------------------------------------------------------------------------------- /docs/assets/rtthread.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/rtthread.jpg -------------------------------------------------------------------------------- /docs/assets/sophgo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/sophgo.jpg -------------------------------------------------------------------------------- /docs/assets/thead.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/assets/thead.jpg -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # markdown suport 2 | recommonmark 3 | # markdown table suport 4 | sphinx-markdown-tables 5 | 6 | # theme default rtd 7 | 8 | # crate-docs-theme 9 | sphinx-rtd-theme -------------------------------------------------------------------------------- /docs/source/api/img/api_device1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/api/img/api_device1.png -------------------------------------------------------------------------------- /docs/source/api/img/api_host1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/api/img/api_host1.png -------------------------------------------------------------------------------- /docs/source/api/img/api_host2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/api/img/api_host2.png -------------------------------------------------------------------------------- /docs/source/class/class_audio.rst: -------------------------------------------------------------------------------- 1 | UAC 2 | ========================= 3 | 4 | 参考官方 audio 相关 pdf -------------------------------------------------------------------------------- /docs/source/class/class_cdc.rst: -------------------------------------------------------------------------------- 1 | CDC 2 | ========================= 3 | 4 | 参考官方 cdc 相关 pdf -------------------------------------------------------------------------------- /docs/source/class/class_hid.rst: -------------------------------------------------------------------------------- 1 | HID 2 | ========================= 3 | 4 | 参考官方 hid 相关 pdf -------------------------------------------------------------------------------- /docs/source/class/class_msc.rst: -------------------------------------------------------------------------------- 1 | MSC 2 | ========================= 3 | 4 | 参考官方 msc 相关 pdf -------------------------------------------------------------------------------- /docs/source/class/class_video.rst: -------------------------------------------------------------------------------- 1 | UVC 2 | ========================= 3 | 4 | 参考官方 video 相关 pdf -------------------------------------------------------------------------------- /docs/source/class/winusb.rst: -------------------------------------------------------------------------------- 1 | WINUSB 2 | ========================= 3 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | 3 | # -- Project information 4 | 5 | project = 'CherryUSB' 6 | copyright = '2022 ~ 2025, sakumisu' 7 | author = 'sakumisu' 8 | 9 | release = '1.5.0' 10 | version = '1.5.0' 11 | 12 | # -- General configuration 13 | 14 | extensions = [ 15 | 'sphinx.ext.duration', 16 | 'sphinx.ext.doctest', 17 | 'sphinx.ext.autodoc', 18 | 'sphinx.ext.autosummary', 19 | 'sphinx.ext.intersphinx', 20 | 'recommonmark', 21 | 'sphinx_markdown_tables' 22 | ] 23 | 24 | intersphinx_mapping = { 25 | # 'python': ('https://docs.python.org/3/', None), 26 | # 'sphinx': ('https://www.sphinx-doc.org/en/master/', None), 27 | } 28 | intersphinx_disabled_domains = ['std'] 29 | 30 | templates_path = ['_templates'] 31 | 32 | # -- Options for HTML output 33 | 34 | html_theme = 'sphinx_rtd_theme' 35 | 36 | # -- Options for EPUB output 37 | epub_show_urls = 'footnote' 38 | -------------------------------------------------------------------------------- /docs/source/demo/usbd_audiov1.rst: -------------------------------------------------------------------------------- 1 | usbd_audiov1 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/demo/usbd_audiov2.rst: -------------------------------------------------------------------------------- 1 | usbd_audiov2 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/demo/usbd_ecm.rst: -------------------------------------------------------------------------------- 1 | usbd_cdc_ecm 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/demo/usbd_hid.rst: -------------------------------------------------------------------------------- 1 | usbd_hid 2 | =============== 3 | 4 | HID 功能比较简单,因此不作赘述,需要注意,使用 hid custom 例程时,需要搭配 `tools/test_srcipts/test_hid_inout.py` 使用。 -------------------------------------------------------------------------------- /docs/source/demo/usbd_msc.rst: -------------------------------------------------------------------------------- 1 | usbd_msc 2 | =============== 3 | 4 | 本节主要演示 USB 模拟 U 盘功能。默认使用RAM 作为存储介质模拟 U 盘。 5 | 6 | - 实现 U 盘的读写和获取容量接口,注意,容量 block_num 为虚拟的,实际没有这么多 block,读写的数据超过 BLOCK_COUNT 会丢弃。 7 | 8 | block_size 一般为 512/2048/4096。 9 | 10 | .. code-block:: C 11 | 12 | void usbd_msc_get_cap(uint8_t busid, uint8_t lun, uint32_t *block_num, uint32_t *block_size) 13 | { 14 | *block_num = 1000; //Pretend having so many buffer,not has actually. 15 | *block_size = BLOCK_SIZE; 16 | } 17 | int usbd_msc_sector_read(uint8_t busid, uint8_t lun, uint32_t sector, uint8_t *buffer, uint32_t length) 18 | { 19 | if (sector < BLOCK_COUNT) 20 | memcpy(buffer, mass_block[sector].BlockSpace, length); 21 | return 0; 22 | } 23 | 24 | int usbd_msc_sector_write(uint8_t busid, uint8_t lun, uint32_t sector, uint8_t *buffer, uint32_t length) 25 | { 26 | if (sector < BLOCK_COUNT) 27 | memcpy(mass_block[sector].BlockSpace, buffer, length); 28 | return 0; 29 | } 30 | 31 | - 默认上述 API 在中断中执行,如果需要在非中断中执行,可以选择如下: 32 | 33 | 1,裸机下开启 `CONFIG_USBDEV_MSC_POLLING` 并在 while1 中调用 `usbd_msc_polling`,则读写函数在 while1 中执行。 34 | 35 | 2, OS 下开启 `CONFIG_USBDEV_MSC_THREAD`,则读写函数在线程中执行。 36 | 37 | - 修改 `CONFIG_USBDEV_MSC_BUFSIZE` 会影响 U 盘的读写速度,必须是 block_size 的整数倍,当然,也会增加 RAM 的占用。 38 | 39 | - 如果 RAM 例程可以用,但是介质更换成 SD 或者 FLASH 后不可用,则一定是介质驱动问题。 -------------------------------------------------------------------------------- /docs/source/demo/usbd_rndis.rst: -------------------------------------------------------------------------------- 1 | usbd_rndis 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/demo/usbd_vendor.rst: -------------------------------------------------------------------------------- 1 | vendor device 驱动编写 2 | =========================== 3 | 4 | 本节主要介绍如何编写一个 vendor device 驱动。 5 | 6 | - 首先复制一份 class/template/usbd_xxx.c 文件 7 | - 实现以下三个回调函数,通常来说,vendor 驱动只需要实现 vendor_handler 8 | 9 | .. code-block:: C 10 | 11 | intf->class_interface_handler = xxx_class_interface_request_handler; 12 | intf->class_endpoint_handler = NULL; 13 | intf->vendor_handler = NULL; 14 | intf->notify_handler = xxx_notify_handler; 15 | 16 | - 举例如下 17 | 18 | case1 演示对于主机 IN 数据的处理,将数据拷贝到 *data 中,并指定*len 的长度。协议栈会自动发送给主机,不需要用户手动调用发送 API。 19 | 20 | case2 演示对于主机 OUT 数据的处理,当执行到此函数时,说明数据都已经接收完成,可以直接读取 *data 中的数据,长度为 *len。 21 | 22 | .. code-block:: C 23 | 24 | static int xxx_vendor_request_handler(uint8_t busid, struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) 25 | { 26 | USB_LOG_WRN("XXX Class request: " 27 | "bRequest 0x%02x\r\n", 28 | setup->bRequest); 29 | 30 | switch (setup->bRequest) { 31 | case 1: 32 | memcpy(*data, xxx, sizeof(xxx)); 33 | *len = sizeof(xxx); 34 | case 2: 35 | hexdump(*data, *len); 36 | default: 37 | USB_LOG_WRN("Unhandled XXX Class bRequest 0x%02x\r\n", setup->bRequest); 38 | return -1; 39 | } 40 | 41 | return 0; 42 | } 43 | 44 | - 最后使用形如 usbd_add_interface(busid, usbd_xxx_init_intf(&intf)) 注册接口 -------------------------------------------------------------------------------- /docs/source/demo/usbd_webusb.rst: -------------------------------------------------------------------------------- 1 | usbd_webusb 2 | =============== 3 | 4 | 本 demo 主要演示 webusb 功能,webusb 主要用于弹出网页并对 USB 设备进行访问。示例使用 webusb_hid_template.c。 5 | 6 | - 在注册描述符时注册 BOS, MSOSV2, WEBUSB 描述符即可。 7 | 8 | .. code-block:: C 9 | 10 | usbd_bos_desc_register(busid, &bos_desc); 11 | usbd_msosv2_desc_register(busid, &msosv2_desc); 12 | usbd_webusb_desc_register(busid, &webusb_url_desc); 13 | 14 | - 增加一个接口描述符用于 webusb 15 | 16 | .. code-block:: C 17 | 18 | USB_INTERFACE_DESCRIPTOR_INIT(USBD_WEBUSB_INTF_NUM, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00) 19 | 20 | - 其余使用 hid 描述符,不再赘述 21 | - 枚举完成后,电脑右下角会弹出网页信息,点击即可打开网页 -------------------------------------------------------------------------------- /docs/source/demo/usbd_winusb.rst: -------------------------------------------------------------------------------- 1 | usbd_winusb 2 | =============== 3 | 4 | 本节主要介绍 winusb 驱动。winusb 是 windows 为了让用户友好的访问 USB 自定义类设备提供的一套通用驱动,其实本质就是 CDC ACM。 5 | WINUSB 版本根据 USB 版本分为 V1/V2 版本,V2 版本需要包含 BOS 描述符,V1 版本不需要。V2 版本需要在设备描述符中设置为 USB2.1 的版本号。 6 | 7 | - V1 版本注册描述符 8 | 9 | .. code-block:: C 10 | 11 | usbd_msosv1_desc_register(busid, &msosv1_desc); 12 | 13 | - V2 版本注册描述符 14 | 15 | .. code-block:: C 16 | 17 | usbd_bos_desc_register(busid, &bos_desc); 18 | usbd_msosv2_desc_register(busid, &msosv2_desc); 19 | 20 | 21 | - 接口描述符注册 22 | 23 | .. code-block:: C 24 | 25 | /* Interface 0 */ 26 | USB_INTERFACE_DESCRIPTOR_INIT(0x00, 0x00, 0x02, 0xFF, 0x00, 0x00, 0x02), 27 | /* Endpoint OUT 2 */ 28 | USB_ENDPOINT_DESCRIPTOR_INIT(WINUSB_OUT_EP, USB_ENDPOINT_TYPE_BULK, WINUSB_EP_MPS, 0x00), 29 | /* Endpoint IN 1 */ 30 | USB_ENDPOINT_DESCRIPTOR_INIT(WINUSB_IN_EP, USB_ENDPOINT_TYPE_BULK, WINUSB_EP_MPS, 0x00), 31 | 32 | - 其余操作与 CDC ACM 相同,不再赘述 -------------------------------------------------------------------------------- /docs/source/demo/usbh_bluetooth.rst: -------------------------------------------------------------------------------- 1 | usbh_bluetooth 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/demo/usbh_hid.rst: -------------------------------------------------------------------------------- 1 | usbh_hid 2 | =============== 3 | 4 | 本节主要介绍 HID 类的使用。 5 | 6 | - HID 枚举完成回调中创建一次性线程 7 | 8 | .. code-block:: C 9 | 10 | 11 | void usbh_hid_run(struct usbh_hid *hid_class) 12 | { 13 | usb_osal_thread_create("usbh_hid", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_hid_thread, hid_class); 14 | } 15 | 16 | void usbh_hid_stop(struct usbh_hid *hid_class) 17 | { 18 | } 19 | 20 | 21 | - 这里我们使用 usbh_submit_urb 的异步操作,在中断中处理数据并继续接收下一次数据。 22 | 23 | .. code-block:: C 24 | 25 | static void usbh_hid_thread(void *argument) 26 | { 27 | int ret; 28 | struct usbh_hid *hid_class = (struct usbh_hid *)argument; 29 | ; 30 | 31 | /* test with only one buffer, if you have more hid class, modify by yourself */ 32 | 33 | /* Suggest you to use timer for int transfer and use ep interval */ 34 | 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); 35 | ret = usbh_submit_urb(&hid_class->intin_urb); 36 | if (ret < 0) { 37 | goto delete; 38 | } 39 | // clang-format off 40 | delete: 41 | usb_osal_thread_delete(NULL); 42 | // clang-format on 43 | } 44 | 45 | - 当然,也可以不使用异步操作,而是使用 timeout 的同步操作。 46 | - HID 使用的是中断传输,因此正常来说,我们需要根据 **bInterval** 来设置定时器,定时触发中断传输,demo 这里没有使用,如果对时间有精确要求,可以选择使用定时器来触发异步发送。 47 | - 以 hub 通信为例,采用的是一次性定时器,也可以使用周期性定时器。 48 | 49 | .. code-block:: C 50 | 51 | hub->int_timer = usb_osal_timer_create("hubint_tim", USBH_GET_URB_INTERVAL(hub->intin->bInterval, hport->speed), hub_int_timeout, hub, 0); 52 | -------------------------------------------------------------------------------- /docs/source/demo/usbh_msc.rst: -------------------------------------------------------------------------------- 1 | usbh_msc 2 | =============== 3 | 4 | 本节主要介绍主机 MSC 使用。借助 FATFS 实现读写功能。 5 | 6 | - 在 msc 枚举完成的回调中注册一个线程,用于读写操作。 7 | 8 | .. code-block:: C 9 | 10 | void usbh_msc_run(struct usbh_msc *msc_class) 11 | { 12 | usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_msc_thread, msc_class); 13 | } 14 | 15 | void usbh_msc_stop(struct usbh_msc *msc_class) 16 | { 17 | } 18 | 19 | 20 | - 不使用 fatfs,则直接使用 usbh_msc_scsi_read10 或者 usbh_msc_scsi_write10 函数进行读写操作。 21 | - 如果使用 fatfs,则需要在 usbh_msc_thread 中调用 fatfs 的接口进行读写操作。msc读写适配fatfs 参考 `platform/none/usbh_fatfs.c` 22 | 23 | .. code-block:: C 24 | 25 | static void usbh_msc_thread(void *argument) 26 | { 27 | int ret; 28 | struct usbh_msc *msc_class = (struct usbh_msc *)argument; 29 | 30 | /* test with only one buffer, if you have more msc class, modify by yourself */ 31 | #if 1 32 | /* get the partition table */ 33 | ret = usbh_msc_scsi_read10(msc_class, 0, partition_table, 1); 34 | if (ret < 0) { 35 | USB_LOG_RAW("scsi_read10 error,ret:%d\r\n", ret); 36 | goto delete; 37 | } 38 | for (uint32_t i = 0; i < 512; i++) { 39 | if (i % 16 == 0) { 40 | USB_LOG_RAW("\r\n"); 41 | } 42 | USB_LOG_RAW("%02x ", partition_table[i]); 43 | } 44 | USB_LOG_RAW("\r\n"); 45 | #endif 46 | 47 | #if TEST_USBH_MSC_FATFS 48 | usb_msc_fatfs_test(); 49 | #endif 50 | // clang-format off 51 | delete: 52 | usb_osal_thread_delete(NULL); 53 | // clang-format on 54 | } 55 | 56 | - 最后处理完成或者失败后,删除线程。 -------------------------------------------------------------------------------- /docs/source/demo/usbh_serial.rst: -------------------------------------------------------------------------------- 1 | usbh_serial 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/demo/usbh_wifi.rst: -------------------------------------------------------------------------------- 1 | usbh_wifi 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/opensource.rst: -------------------------------------------------------------------------------- 1 | 官方开源项目分享 2 | ==================== 3 | 4 | 除了基本的厂家 SDK 支持以外,我们还对一些火热的开源项目进行了支持,以便于开发者更好的使用这些项目。下面列举适配的 demo 工程链接,具体适配层参考 https://github.com/cherry-embedded/CherryUSB/tree/master/platform 。 5 | 6 | DAPLINK 7 | -------------- 8 | 9 | 适配链接:https://github.com/cherry-embedded/CherryDAP 10 | 11 | Blackmagic 12 | -------------- 13 | 14 | 适配链接:https://github.com/zhangjiance/bmp-hpm-port 15 | 16 | RT-Thread 17 | -------------- 18 | 19 | 适配链接:https://github.com/RT-Thread/rt-thread 20 | 21 | NUTTX/VELA 22 | -------------- 23 | 24 | 适配链接:https://github.com/CherryUSB/cherryusb_nuttx 25 | 26 | Zephyr 27 | -------------- 28 | 29 | 适配链接:https://github.com/hpmicro/zephyr_sdk_glue 30 | 31 | Cangaroo 32 | -------------- 33 | 34 | Cangaroo is an open source can bus analyzer software. We provide four-channel CANFD analyzer based on hpmicro hpm5361 35 | 36 | 适配上位机链接:https://github.com/RCSN/cangaroo_hpmicro_canfd_analyzer 37 | 适配下位机链接:https://github.com/RCSN/hpm_sdk_extra/tree/main/demos/cangaroo_hpmicro 38 | 39 | LVGL 40 | -------------- 41 | 42 | 适配链接:https://github.com/cherry-embedded/CherryUSB/tree/master/platform/lvgl 43 | 44 | QMK 45 | -------------- 46 | 47 | QMK is an open-source keyboard firmware for Atmel AVR and Arm USB families. 48 | 49 | 适配链接:待开放 50 | 51 | Klipper 52 | -------------- 53 | 54 | Klipper is a 3d-printer firmware. 55 | 56 | 适配链接:待开放 57 | 58 | 59 | -------------------------------------------------------------------------------- /docs/source/quick_start/esp.rst: -------------------------------------------------------------------------------- 1 | 基于 ESP-Registry 开发指南 2 | =========================== 3 | 4 | ESP-Registry 可以参考官方文档,推荐使用 vscode + esp-idf 的开发环境。 5 | 6 | - ctrl + shift + p 选择 ESP-IDF 欢迎界面,然后选择 Component mananger 7 | 8 | .. figure:: img/esp1.png 9 | 10 | - 找到 cherryusb 并安装 11 | 12 | .. figure:: img/esp2.png 13 | 14 | - 打开 menuconfig,并打开 cherryusb 的配置,根据实际情况选择主机或者从机模式 15 | 16 | .. figure:: img/esp3.png 17 | .. figure:: img/esp4.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/env0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/env0.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/env1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/env1.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/env2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/env2.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/esp1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/esp1.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/esp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/esp2.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/esp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/esp3.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/esp4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/esp4.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_1.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_10.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_11.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_12.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_13.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_14.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_15.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_16.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_18.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_19.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_2.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_21.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_3.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_3_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_3_1.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_4.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_4_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_4_1.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_5.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_6.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_7.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_8.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_init.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32_init2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32_init2.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32cubemx0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32cubemx0.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32cubemx1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32cubemx1.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32cubemx2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32cubemx2.png -------------------------------------------------------------------------------- /docs/source/quick_start/img/stm32cubemx_clk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/quick_start/img/stm32cubemx_clk.png -------------------------------------------------------------------------------- /docs/source/quick_start/start.rst: -------------------------------------------------------------------------------- 1 | 入门必看 2 | ================== 3 | 4 | 首先欢迎大家来到 usb 的世界,在这里你可以学习到 usb 各种知识以及 cherryusb 的移植使用进阶等等。但是呢,刚进来的你,一定很懵懂,因为 USB 很难(其实当你学会了 cherryusb以后,你会发现,USB 一点都不难), 5 | 那么这种情况下,你的学习路线,应该是怎么样呢?在这里,我推荐大家是按照我得学习路线来学习,这样对你的 USB 成长是最有帮助的,并且你也不会中途放弃。 6 | 7 | 首先,不允许上来就看概念,有句古诗说的好, **纸上得来终觉浅,绝知此事要躬行** ,光看纸面上的东西,你是学不到什么的,只有当自己实践了,你才能更深入的了解这些概念。那么作为初学者,你应该怎么做呢?请看以下步骤。 8 | 9 | 10 | 第一步 11 | ------------- 12 | 13 | 你需要学过 C 语言,UART, DMA,这是基础,如果没学过,请去学习,不然你会很吃力。你会问 USB 跟 UART/DMA 有什么关系? 我只能说两个字, **等价** 14 | 15 | 第二步 16 | ------------- 17 | 18 | 下载 demo 工程并跑通能运行, **建议学习慢的,使用 demo 同型号芯片**,学习快的,可以选择自己移植相关支持的型号的芯片。你连 demo 都跑不通,你学什么 USB,你说对不对? 19 | 20 | 第三步 21 | --------- 22 | 23 | 非常好,到这步,说明你已经能熟练移植和跑通所有示例了,那么接下来,你应该学习什么呢? **事务**, **请求** 和 **描述符** (在 USB 的学习过程中,你只需要知道这三个,其余都不需要知道)。 24 | 25 | 第四步 26 | ---------- 27 | 28 | 首先我们需要知道 USB 事务包含 SETUP/IN/OUT,其实就是等价于发送命令,发送数据和接收数据,很简单。至于下面枚举中你在外面的网络中所听到的控制阶段,数据阶段,状态阶段,他不是事务,他只是用多个事务代表了一个阶段而已。 29 | 30 | 第五步 31 | ---------- 32 | 33 | 然后你再去看 **USB 枚举** 章节并且知道了一个概念: **描述符** ,这个时候,你就可以去简单看看什么是描述符,有哪些描述符,然后你需要记住, **设备、配置、接口、端点描述符的组成**,并背下来,其余的你都不需要知道,因为其他都是固定的,后续都是 CV 。群文件有各类设备枚举的抓包,可以下下来看看。 34 | 35 | 第六步 36 | ---------- 37 | 38 | 然后呢,你可以再去看看什么是 **请求** ,请求结构体的组成,看看有哪些请求,简单了解即可,为什么呢?因为它不过就是 8 字节的数据格式,大家都会写一个 UART + 自定义协议,那么 USB 的请求也是一样的,只不过是规定好了而已。 39 | 40 | 第七步 41 | ---------- 42 | 43 | 这个时候,你该去熟悉下协议栈的一些 API 了,参考 **API 手册** 章节。并且你需要知道中断完成的条件是什么,什么时候算接收完成,什么时候算发送完成,可以参考 **USB 知识点拓展** 章节。 44 | 45 | 第八步 46 | ---------- 47 | 48 | 到这步呢,你肯定已经非常懂了,然后就可以开始你的一些小功能小项目了,在此期间呢,请循环查看 **USB 知识点拓展** 章节,直到你真的理解了,因为这些内容是非常重要的,会影响我们代码的执行结果。 49 | 50 | 第九步 51 | ---------- 52 | 53 | 都到这步了,你应该不需要我了,这个时候,你可以去看看 USB 概念,看看 USB 的一些细节,看看 CherryUSB 的代码流程了。然后就是巩固巩固再巩固了。恭喜你,出师了!!! 54 | -------------------------------------------------------------------------------- /docs/source/share.rst: -------------------------------------------------------------------------------- 1 | 开发者经验/开源项目分享 2 | ======================== 3 | 4 | - `RT-Thread-CherryUSB - RT-Thread `_ 5 | 6 | - `[HPM-DIY]hpm6750 USB开源协议栈性能对比-cherryusb or tinyusb? `_ 7 | 8 | - `RT-Thread-CherryUSB移植笔记(一):APM32F407VGT6 DWC2移植 Port.A Full-Speed + Por.B High-SpeedRT-Thread问答社区 - RT-Thread `_ 9 | 10 | - `华大HC32F460XXX移植cherryusb协议栈,实现USB CDC ACM_cherryusb移植教程-CSDN博客 `_ 11 | 12 | - `rt-thread使用cherryusb实现虚拟串口-CSDN博客 `_ 13 | 14 | - `F1C100S+rtt+CherryUSB的USB HOST成功读到U盘 / 全志 SOC / WhyCan Forum(哇酷开发者社区) `_ 15 | 16 | - `模仿stm32标准库风格写的库文件(f1c100s/f1c200s),且已移植了rt-thread、lvgl、fatfs、cherryusb / 全志 SOC / WhyCan Forum(哇酷开发者社区) `_ 17 | 18 | - `printalyzer-timer: F-Stop enlarging timer and print exposure meter `_ 19 | 20 | - `MiSTeryNano: Atari STE MiSTery core for the Tang Nano 20k FPGA `_ 21 | 22 | - `Cherryuf2 `_ 23 | 24 | - `PicoPiFi: Driverless RNDIS USB WIFI Dongle `_ 25 | 26 | - `phobia: Phobia Motor Controller `_ 27 | 28 | -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_msc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_msc.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_rndis_linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_rndis_linux.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_rndis_lwip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_rndis_lwip.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_rndis_lwip2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_rndis_lwip2.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_rndis_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_rndis_wifi.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_rndis_wifi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_rndis_wifi2.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_rndis_win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_rndis_win.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_uvc_mjpeg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_uvc_mjpeg.png -------------------------------------------------------------------------------- /docs/source/show/img/usbdev_uvc_yuv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbdev_uvc_yuv.png -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_hub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_hub.png -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_hub2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_hub2.png -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_msc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_msc.png -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_msc_xhci.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_msc_xhci.png -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_rndis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_rndis.png -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_rndis2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_rndis2.png -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_uvc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_uvc.gif -------------------------------------------------------------------------------- /docs/source/show/img/usbhost_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/show/img/usbhost_wifi.png -------------------------------------------------------------------------------- /docs/source/show/index.rst: -------------------------------------------------------------------------------- 1 | .. _performace_show: 2 | 3 | 性能展示 4 | ============================== 5 | 6 | 以下演示了 CherryUSB 在不同应用中的性能表现。主要演示高速模式,全速看不出什么性能差异。 7 | 8 | CDC ACM 通信 9 | ---------------- 10 | 11 | 可以达到硬件极限性能,当然需要硬件理论支持到这速度,CherryUSB 就支持到这速度,举例如下: 12 | 13 | - HPM 系列(从机可以到 42MB/S, 主机 44MB/S, 已经达到硬件极限) 14 | - BL 系列(从机 32MB/S, 主机 25MB/S, 已经达到硬件极限) 15 | - STM32F4 全速(从机 900KB/S, 主机 1.12MB/S, 已经达到硬件极限) 16 | 17 | 从机测速demo: cdc_acm_template.c 并且关闭 log,脚本使用 `tools/test_srcipts/test_cdc_speed.py` 18 | 主机测速demo: usb_host.c 中 TEST_USBH_CDC_SPEED=1 19 | 20 | USB Device MSC 21 | ----------------- 22 | 23 | 演示 USB Device MSC 使用 SDXC3.0 + EMMC 测试。 24 | 25 | .. figure:: img/usbdev_msc.png 26 | 27 | USB Device RNDIS 28 | ----------------------- 29 | 30 | .. note:: 默认 rndis 仅支持单包,因此下面速度为最低速度。多包支持需要联系作者。 31 | 32 | 演示 USB Device RNDIS 局域网下搭配 lwip 的速度。 33 | 34 | 作为 client 35 | 36 | .. figure:: img/usbdev_rndis_lwip.png 37 | 38 | 作为 server 39 | 40 | .. figure:: img/usbdev_rndis_lwip2.png 41 | 42 | 演示 USB Device RNDIS + WIFI 透传测试。 43 | 44 | .. figure:: img/usbdev_rndis_wifi.png 45 | .. figure:: img/usbdev_rndis_wifi2.png 46 | 47 | 演示 USB Device RNDIS + 百兆以太网透传测试。 48 | 49 | .. figure:: img/usbdev_rndis_win.png 50 | .. figure:: img/usbdev_rndis_linux.png 51 | 52 | USB Device UVC 53 | ----------------------- 54 | 55 | 演示 USB Device UVC + 摄像头传输 YUYV/MJPEG 640 * 480 图像。FPS 30。 56 | 57 | .. figure:: img/usbdev_uvc_mjpeg.png 58 | .. figure:: img/usbdev_uvc_yuv.png 59 | 60 | USB Host HUB 61 | ----------------------- 62 | 63 | 多级 hub 支持,演示 1托 7 HUB 64 | 65 | .. figure:: img/usbhost_hub.png 66 | .. figure:: img/usbhost_hub2.png 67 | 68 | USB Host MSC 69 | ----------------------- 70 | 71 | 演示 USB Host MSC 在 USB2.0 和 USB3.0 下的速度,U盘推荐使用固态测试。 72 | 73 | .. figure:: img/usbhost_msc.png 74 | .. figure:: img/usbhost_msc_xhci.png 75 | 76 | USB Host UVC 77 | ----------------------- 78 | 79 | 演示 USB Host UVC 驱动 648 * 480 YUV 摄像头。FPS 30。 80 | 81 | .. figure:: img/usbhost_uvc.gif 82 | 83 | USB Host WIFI 84 | ----------------------- 85 | 86 | 演示 USB Host 驱动 BL616 USB WIFI。 87 | 88 | .. figure:: img/usbhost_wifi.png 89 | -------------------------------------------------------------------------------- /docs/source/support/img/dwc2_hostuac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/dwc2_hostuac.png -------------------------------------------------------------------------------- /docs/source/support/img/dwc2_hostuvc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/dwc2_hostuvc.png -------------------------------------------------------------------------------- /docs/source/support/img/dwc2_hostuvc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/dwc2_hostuvc1.png -------------------------------------------------------------------------------- /docs/source/support/img/dwc2_hostuvc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/dwc2_hostuvc2.png -------------------------------------------------------------------------------- /docs/source/support/img/ehci_hostuvc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/ehci_hostuvc1.png -------------------------------------------------------------------------------- /docs/source/support/img/ehci_hostuvc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/ehci_hostuvc2.png -------------------------------------------------------------------------------- /docs/source/support/img/mtpdev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/mtpdev.png -------------------------------------------------------------------------------- /docs/source/support/img/ohci.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/ohci.png -------------------------------------------------------------------------------- /docs/source/support/img/rndisrx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/rndisrx.png -------------------------------------------------------------------------------- /docs/source/support/img/rndistx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/support/img/rndistx.png -------------------------------------------------------------------------------- /docs/source/support/index.rst: -------------------------------------------------------------------------------- 1 | 商业支持 2 | ============================== 3 | 4 | 以下内容为商业收费类,如需支持,请邮件到 1203593632@qq.com。 5 | 6 | - OHCI 驱动 7 | 8 | .. figure:: img/ohci.png 9 | 10 | - 主机 UVC & UAC 类 EHCI IP 中 ISO 驱动和 UAC/UVC 框架 11 | 12 | .. figure:: img/ehci_hostuvc1.png 13 | .. figure:: img/ehci_hostuvc2.png 14 | 15 | - 主机 UVC & UAC 类 DWC2 IP 中 ISO 驱动和 UAC/UVC 框架 16 | 17 | .. figure:: img/dwc2_hostuvc1.png 18 | .. figure:: img/dwc2_hostuvc2.png 19 | .. figure:: img/dwc2_hostuac.png 20 | 21 | - 主机 UVC & UAC 类 MUSB IP 中 ISO 驱动和 UAC/UVC 框架, MUSB 需要为 mentor 公司制定的标准 IP 22 | 23 | - 从机 MTP 类驱动, 支持多文件和多文件夹 24 | 25 | .. figure:: img/mtpdev.png 26 | 27 | - USB 网卡类高性能版本优化,包含 CDC-NCM, CDC-RNDIS, 私有类驱动(支持多包发送和接收),下面举例 RNDIS 28 | 29 | .. figure:: img/rndistx.png 30 | .. figure:: img/rndisrx.png 31 | 32 | - 定制化 class 驱动或者 IP 驱动 33 | - 技术支持相关 -------------------------------------------------------------------------------- /docs/source/tools/img/chrytool1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/tools/img/chrytool1.png -------------------------------------------------------------------------------- /docs/source/tools/img/chrytool2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/tools/img/chrytool2.png -------------------------------------------------------------------------------- /docs/source/tools/img/chrytool3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/tools/img/chrytool3.png -------------------------------------------------------------------------------- /docs/source/tools/img/chrytool4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/tools/img/chrytool4.png -------------------------------------------------------------------------------- /docs/source/tools/img/chrytool5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/tools/img/chrytool5.png -------------------------------------------------------------------------------- /docs/source/tools/img/chrytool6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/tools/img/chrytool6.png -------------------------------------------------------------------------------- /docs/source/tools/img/chrytool7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/tools/img/chrytool7.png -------------------------------------------------------------------------------- /docs/source/tools/index.rst: -------------------------------------------------------------------------------- 1 | chryusb_configurator 2 | -------------------------- 3 | 4 | `chryusb_configurator `_ 主要服务在使用设备协议栈时,生成描述符数组,从而调用 `usbd_desc_register` 进行注册。 5 | 6 | - 首先我们从 github 下载 chryusb_configurator.exe,然后一路安装就可以了。然后双击打开,点击 `工程`,并点击 `新建工程` 7 | 8 | .. figure:: img/chrytool1.png 9 | 10 | - 新建完成以后,会生成默认的描述符配置,包含 **设备描述符**、 **配置描述符**、 **字符串描述符**,并且 **字符串描述符** 默认支持三个 11 | 12 | .. figure:: img/chrytool2.png 13 | 14 | - 然后我们可以根据需要修改相关描述符的信息,比如 **设备描述符** 中的 vid、pid,class 参数, **配置描述符** 中的 **Power** 等等 15 | 16 | - 然后是 class 的添加,需要点击 `文件`,并点击 `新建文件` 17 | 18 | .. figure:: img/chrytool3.png 19 | 20 | - 然后右侧提供了一些 class 的描述符模板,选择一个进行初始化 21 | 22 | .. figure:: img/chrytool4.png 23 | 24 | - 如果是多个 class ,则上述两步重复操作就可以了 25 | 26 | - 然后我们根据需要修改相关端点的参数,比如方向、地址、size、interval 27 | 28 | .. figure:: img/chrytool5.png 29 | 30 | - 最后点击 `文件` 并保存文件,后缀为 `.chry` 31 | - 切换到工程文件,后缀是 `.chrybase`, 然后点击 `添加分组配置` 导入刚刚配置好的 class 文件 32 | 33 | .. figure:: img/chrytool6.png 34 | 35 | - 点击 `工程` 并点击 `保存工程` 36 | - 点击 `编译`,生成描述符数组 37 | 38 | .. figure:: img/chrytool7.png 39 | 40 | - 复制编译后的文件到自己的工程中使用即可 41 | 42 | 43 | 力科 USB Protocol Suite 44 | -------------------------- 45 | 46 | Wireshark 47 | -------------------------- 48 | 49 | Audacity 50 | -------------------------- 51 | -------------------------------------------------------------------------------- /docs/source/usb/img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/1.png -------------------------------------------------------------------------------- /docs/source/usb/img/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/10.png -------------------------------------------------------------------------------- /docs/source/usb/img/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/11.png -------------------------------------------------------------------------------- /docs/source/usb/img/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/12.png -------------------------------------------------------------------------------- /docs/source/usb/img/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/13.png -------------------------------------------------------------------------------- /docs/source/usb/img/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/14.png -------------------------------------------------------------------------------- /docs/source/usb/img/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/15.png -------------------------------------------------------------------------------- /docs/source/usb/img/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/16.png -------------------------------------------------------------------------------- /docs/source/usb/img/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/17.png -------------------------------------------------------------------------------- /docs/source/usb/img/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/18.png -------------------------------------------------------------------------------- /docs/source/usb/img/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/19.png -------------------------------------------------------------------------------- /docs/source/usb/img/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/2.png -------------------------------------------------------------------------------- /docs/source/usb/img/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/20.png -------------------------------------------------------------------------------- /docs/source/usb/img/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/21.png -------------------------------------------------------------------------------- /docs/source/usb/img/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/22.png -------------------------------------------------------------------------------- /docs/source/usb/img/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/23.png -------------------------------------------------------------------------------- /docs/source/usb/img/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/24.png -------------------------------------------------------------------------------- /docs/source/usb/img/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/25.png -------------------------------------------------------------------------------- /docs/source/usb/img/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/26.png -------------------------------------------------------------------------------- /docs/source/usb/img/27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/27.png -------------------------------------------------------------------------------- /docs/source/usb/img/28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/28.png -------------------------------------------------------------------------------- /docs/source/usb/img/29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/29.png -------------------------------------------------------------------------------- /docs/source/usb/img/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/3.png -------------------------------------------------------------------------------- /docs/source/usb/img/30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/30.png -------------------------------------------------------------------------------- /docs/source/usb/img/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/4.png -------------------------------------------------------------------------------- /docs/source/usb/img/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/5.png -------------------------------------------------------------------------------- /docs/source/usb/img/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/6.png -------------------------------------------------------------------------------- /docs/source/usb/img/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/7.png -------------------------------------------------------------------------------- /docs/source/usb/img/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/8.png -------------------------------------------------------------------------------- /docs/source/usb/img/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/9.png -------------------------------------------------------------------------------- /docs/source/usb/img/overview1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/overview1.png -------------------------------------------------------------------------------- /docs/source/usb/img/overview2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/overview2.png -------------------------------------------------------------------------------- /docs/source/usb/img/usb_enum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/usb_enum.png -------------------------------------------------------------------------------- /docs/source/usb/img/usb_request.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/docs/source/usb/img/usb_request.png -------------------------------------------------------------------------------- /docs/source/usb/usb3.0_basic.rst: -------------------------------------------------------------------------------- 1 | USB 基本概念(3.0 为主) 2 | =========================== 3 | 4 | 5 | 简介 6 | ------------ 7 | 8 | 9 | 10 | 与 USB 2.0 相同和不同点 11 | -------------------------- 12 | 13 | 14 | Link Layer 15 | -------------------- 16 | 17 | LCW 18 | ^^^^^^^^^^ 19 | 20 | Protocol Layer 21 | -------------------- 22 | 23 | LMP 24 | ^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | TP 27 | ^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | DP 30 | ^^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | ITP 33 | ^^^^^^^^^^^^^^^^^^^^^^^^ -------------------------------------------------------------------------------- /docs/source/usb/usb_desc.rst: -------------------------------------------------------------------------------- 1 | USB 描述符 2 | =========================== 3 | 4 | 本节参考官方 usb2.0 pdf 9.5 节即可。 5 | 6 | 设备描述符 7 | --------------------- 8 | 9 | 配置描述符 10 | --------------------- 11 | 12 | 接口描述符 13 | --------------------- 14 | 15 | 端点描述符 16 | --------------------- 17 | 18 | 字符串描述符 19 | --------------------- 20 | 21 | 接口关联描述符 22 | --------------------- 23 | 24 | 设备限定描述符 25 | --------------------- 26 | 27 | 其他速度描述符 28 | --------------------- 29 | 30 | BOS 描述符 31 | --------------------- 32 | 33 | 超高速端点伴随描述符 34 | --------------------- 35 | 36 | 增加型超高速同步端点伴随描述符 37 | ------------------------------- 38 | -------------------------------------------------------------------------------- /docs/source/usb/usb_enum.rst: -------------------------------------------------------------------------------- 1 | USB 枚举 2 | =========================== 3 | 4 | 当我们了解了 usb 设备请求以后,就可以来学习下 USB 设备的整个枚举过程了,看看是如何枚举出一个串口、鼠标、u盘等设备了。枚举过程中主机会发送设备请求来获取相关信息(也就是描述符),具体发送哪些,参考下图。 5 | 6 | .. figure:: img/usb_enum.png 7 | 8 | - 首先设备接上 USB 线,然后插上电脑 9 | - 设备插上以后上电,处于供电状态 10 | - 主机通过 D+/D- 识别到设备插入 11 | - 对设备进行复位 12 | - 主机发送 **获取设备描述符请求** 13 | - 可选的复位操作 14 | - 主机发送 **设置设备地址请求** 15 | - 主机发送 **获取配置描述符请求**,可能会获取多次,无所谓 16 | - 主机发送 **获取字符串描述符请求**,正常会获取3个字符串,如果后面的描述符中指定了字符串,则继续获取指定的字符串 17 | - 主机发送 **获取设备限定描述符请求**,用来获取在设备工作在其他速度上的请求,如果设备只能工作在全速模式,则必须回复 stall,并且协议栈中一定会打印该请求告诉你此命令设备不支持。 18 | - 主机发送 **设置配置请求**,对设备的端点进行配置,通常是根据端点描述符中的配置进行设置。 19 | - 到此标准的设备请求结束 20 | - 主机根据接口描述符加载对应支持的 class 驱动,如果主机不支持,则会提示该设备找不到驱动 21 | - 加载完成以后,开始执行该 class 相关的请求 22 | - 最终进行 class 的数据流传输 -------------------------------------------------------------------------------- /docs/source/usb/usb_ext.rst: -------------------------------------------------------------------------------- 1 | .. _usb_ext: 2 | 3 | USB 知识点拓展 4 | =========================== 5 | 6 | 什么是分包 7 | ------------- 8 | 9 | 由于 USB 协议中规定了每个包的最大长度,所以当我们发送的数据长度超过了最大包长度时,就需要分包发送,这就是分包。比如 ep mps 为 64,数据长度为 129,则 USB 会按照 64 + 64 + 1 的形式传输。 10 | 而对于 USB IP 来说,分包分为软件分包和硬件分包,软件分包就是用户代码自行分包,这种 ip 一般都使用 FIFO 来进行,因为 FIFO 深度是有限的;第二种 11 | 则是使用硬件分包,这种 USB IP 一般带 DMA 或者描述符 DMA 功能,那么这种 IP 的效率无疑是最高的,cherryusb 中充分利用了这点,使得 USB 速度能够达到最高。 12 | 13 | 对于软件分包来说,一次发送的长度即使是 16K, **内部也是通过软件分包的,在这种情况下,发送长度的多少不会对速度有任何提升**。 14 | 对于硬件分包来说,发送的长度会影响速度,因为硬件分包是通过 DMA 来进行的, **一次发送的长度越大,DMA 的效率就越高,速度也就越快**。(当然,其他协议栈虽然使用了 dma,但是部分代码实现还是按照一个包进行,等于没用,这也是速度低的一个原因) 15 | 16 | 什么是短包 17 | ---------------- 18 | 19 | 在上面我们讲了分包之后,短包就是分包的最后一个包(并且长度小于 EP MPS).比如发送 129 字节的数据,那么 USB 会按照 64 + 64 + 1 的形式传输,最后一个包是1个字节,这1个字节就是短包。 20 | 21 | 什么是 ZLP 22 | ------------- 23 | 24 | ZLP,顾名思义,零长度数据包,也就是数据长度为0 的短包。是 USB 设备在数据传输结束时,如果数据长度正好是最大包长度的整数倍,那么就需要发送一个 ZLP 数据包,用来告诉对方数据传输结束。 25 | 26 | .. caution:: ZLP 功能仅限于 CONTROL 和 BULK 传输 27 | 28 | 什么时候算中断完成 29 | -------------------- 30 | 31 | 从机接收:接收的长度与设置的长度相等;接收的最后一个包为短包。 32 | 从机发送:发送的长度与设置的长度相等,如果发送的长度是 EP MPS 的整数倍,需要再发送一个 ZLP(仅限 control 和 bulk 传输)。 33 | 34 | 主机接收:同从机接收 35 | 主机发送:发送的长度与设置的长度相等 36 | 37 | .. note:: 对于从机接收,并且是 bulk 传输,接收长度通常设计为 EP MPS,以下三种情况可以修改为多个 EP MPS: 固定长度;自定义协议并携带长度(例如 MSC); 主机手动发送 ZLP 或者短包(例如 RNDIS) -------------------------------------------------------------------------------- /docs/source/usb/usb_request.rst: -------------------------------------------------------------------------------- 1 | USB 设备请求 2 | =========================== 3 | 4 | 本节参考官方 usb2.0 pdf 9.3、9.4 节即可。 5 | 6 | .. figure:: img/usb_request.png 7 | -------------------------------------------------------------------------------- /docs/source/usbip/cdns2.rst: -------------------------------------------------------------------------------- 1 | CDNS2 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/usbip/cdns3.rst: -------------------------------------------------------------------------------- 1 | CDNS3 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/usbip/chipidea.rst: -------------------------------------------------------------------------------- 1 | CHIPIDEA 2 | ================= -------------------------------------------------------------------------------- /docs/source/usbip/dwc2.rst: -------------------------------------------------------------------------------- 1 | DWC2 2 | ================= -------------------------------------------------------------------------------- /docs/source/usbip/dwc3.rst: -------------------------------------------------------------------------------- 1 | DWC3 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/usbip/ehci.rst: -------------------------------------------------------------------------------- 1 | EHCI 2 | ================= -------------------------------------------------------------------------------- /docs/source/usbip/fotg210.rst: -------------------------------------------------------------------------------- 1 | FOTG210 2 | =============== 3 | -------------------------------------------------------------------------------- /docs/source/usbip/musb.rst: -------------------------------------------------------------------------------- 1 | MUSB 2 | ================= -------------------------------------------------------------------------------- /docs/source/usbip/ohci.rst: -------------------------------------------------------------------------------- 1 | OHCI 2 | ================= -------------------------------------------------------------------------------- /docs/source/usbip/xhci.rst: -------------------------------------------------------------------------------- 1 | XHCI 2 | ================= -------------------------------------------------------------------------------- /idf_component.yml: -------------------------------------------------------------------------------- 1 | version: "1.5.0" 2 | description: CherryUSB is a tiny and portable USB Stack (device & host) for embedded system with USB IP 3 | tags: 4 | - usb 5 | - usb-device 6 | - usb-host 7 | - cdc_acm 8 | - cdc_ecm 9 | - cdc_ncm 10 | - hid 11 | - msc 12 | - rndis 13 | - uvc 14 | - uac 15 | - winusb 16 | url: https://github.com/cherry-embedded/CherryUSB 17 | repository: https://github.com/cherry-embedded/CherryUSB.git 18 | documentation: https://cherryusb.readthedocs.io/ 19 | issues: https://github.com/cherry-embedded/CherryUSB/issues 20 | dependencies: 21 | idf: ">=5.0" 22 | targets: 23 | - esp32s2 24 | - esp32s3 25 | - esp32p4 -------------------------------------------------------------------------------- /osal/idf/linker.lf: -------------------------------------------------------------------------------- 1 | [sections:usbh_class_info] 2 | entries: 3 | .usbh_class_info+ 4 | 5 | [scheme:usbh_class_info_array] 6 | entries: 7 | usbh_class_info -> flash_rodata 8 | 9 | [mapping:usbh_class_info_table] 10 | archive: * 11 | entries: 12 | * (usbh_class_info_array); 13 | usbh_class_info -> flash_rodata KEEP() SURROUND(usbh_class_info) -------------------------------------------------------------------------------- /osal/idf/usbh_class_info.ld: -------------------------------------------------------------------------------- 1 | __usbh_class_info_start__ = _usbh_class_info_start; 2 | __usbh_class_info_end__ = _usbh_class_info_end; -------------------------------------------------------------------------------- /platform/README.md: -------------------------------------------------------------------------------- 1 | # Platform Support 2 | 3 | This is a platform support for other opensource projects. 4 | 5 | 6 | ## Fatfs 7 | 8 | - Fatfs support with usb host msc. 9 | - Fatfs support with usb device mtp. 10 | 11 | ## lwip 12 | 13 | lwip support with usb host net class(cdc_ecm/cdc_ncm/cdc_rndis/asix/rtl8152/bl616_wifi). 14 | 15 | ## RT-Thread 16 | 17 | - rt_device support with usb device msc. 18 | - DFS support with usb host msc. 19 | - lwip support with usb host net class(cdc_ecm/cdc_ncm/cdc_rndis/asix/rtl8152/bl616_wifi). 20 | - msh support with lsusb 21 | 22 | 23 | ## Nuttx 24 | 25 | - char device support fowithr usb device cdc acm. 26 | - char device support with usb host cdc acm. 27 | - fs support with usb device msc. 28 | - fs support with usb host msc. 29 | - net support with usb host net class(cdc_rndis). 30 | 31 | ## Threadx 32 | 33 | - filx support with usb host msc. 34 | 35 | ## Zephyr 36 | 37 | - shell support with lsusb 38 | 39 | ## LVGL 40 | 41 | - lvgl indev support with usb host mouse and keyboard. support both LVGL8.x.x and LVGL9.x.x 42 | 43 | ## Blackmagic 44 | 45 | Blackmagic support with usb device cdc acm. 46 | 47 | ## DAPLINK 48 | 49 | DAPLINK v2.1 support with usb device cdc acm + winusb(hid and msc optional). 50 | 51 | ## UF2 52 | 53 | UF2 support with usb device msc. 54 | 55 | ## QMK 56 | 57 | QMK support with usb device hid. -------------------------------------------------------------------------------- /platform/fatfs/usbh_fatfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "ff.h" 7 | #include "diskio.h" 8 | #include "usbh_core.h" 9 | #include "usbh_msc.h" 10 | 11 | struct usbh_msc *active_msc_class; 12 | 13 | int USB_disk_status(void) 14 | { 15 | return RES_OK; 16 | } 17 | 18 | int USB_disk_initialize(void) 19 | { 20 | active_msc_class = (struct usbh_msc *)usbh_find_class_instance("/dev/sda"); 21 | if (active_msc_class == NULL) { 22 | printf("do not find /dev/sda\r\n"); 23 | return RES_NOTRDY; 24 | } 25 | if (usbh_msc_scsi_init(active_msc_class) < 0) { 26 | return RES_NOTRDY; 27 | } 28 | return RES_OK; 29 | } 30 | 31 | int USB_disk_read(BYTE *buff, LBA_t sector, UINT count) 32 | { 33 | return usbh_msc_scsi_read10(active_msc_class, sector, buff, count); 34 | } 35 | 36 | int USB_disk_write(const BYTE *buff, LBA_t sector, UINT count) 37 | { 38 | return usbh_msc_scsi_write10(active_msc_class, sector, buff, count); 39 | } 40 | 41 | int USB_disk_ioctl(BYTE cmd, void *buff) 42 | { 43 | int result = 0; 44 | 45 | switch (cmd) { 46 | case CTRL_SYNC: 47 | result = RES_OK; 48 | break; 49 | 50 | case GET_SECTOR_SIZE: 51 | *(WORD *)buff = active_msc_class->blocksize; 52 | result = RES_OK; 53 | break; 54 | 55 | case GET_BLOCK_SIZE: 56 | *(DWORD *)buff = 1; 57 | result = RES_OK; 58 | break; 59 | 60 | case GET_SECTOR_COUNT: 61 | *(DWORD *)buff = active_msc_class->blocknum; 62 | result = RES_OK; 63 | break; 64 | 65 | default: 66 | result = RES_PARERR; 67 | break; 68 | } 69 | 70 | return result; 71 | } 72 | -------------------------------------------------------------------------------- /platform/lvgl/usbh_hid_lvgl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef USBH_HID_LVGL_H 7 | #define USBH_HID_LVGL_H 8 | 9 | #include "lvgl.h" 10 | 11 | lv_indev_t *usbh_hid_lvgl_add_mouse(uint8_t sensitivity); 12 | lv_indev_t *usbh_hid_lvgl_add_keyboard(void); 13 | 14 | #endif -------------------------------------------------------------------------------- /platform/nuttx/usbd_fs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include 7 | 8 | #include "usbd_core.h" 9 | #include "usbd_msc.h" 10 | 11 | #ifndef CONFIG_USBDEV_MSC_THREAD 12 | #error "CONFIG_USBDEV_MSC_THREAD must be enabled" 13 | #endif 14 | 15 | static FAR struct inode *inode; 16 | static struct geometry geo; 17 | static char devpath[32]; 18 | 19 | void usbd_msc_get_cap(uint8_t busid, uint8_t lun, uint32_t *block_num, uint32_t *block_size) 20 | { 21 | int ret; 22 | 23 | /* Open the block driver */ 24 | 25 | ret = open_blockdriver(devpath, 0, &inode); 26 | if (ret < 0) { 27 | *block_num = 0; 28 | *block_size = 0; 29 | return; 30 | } 31 | 32 | /* Get the drive geometry */ 33 | 34 | if (!inode || !inode->u.i_bops || !inode->u.i_bops->geometry || 35 | inode->u.i_bops->geometry(inode, &geo) != OK || !geo.geo_available) { 36 | *block_num = 0; 37 | *block_size = 0; 38 | return; 39 | } 40 | 41 | *block_num = geo.geo_nsectors; 42 | *block_size = geo.geo_sectorsize; 43 | 44 | USB_LOG_INFO("block_num: %ld, block_size: %ld\n", *block_num, *block_size); 45 | } 46 | 47 | int usbd_msc_sector_read(uint8_t busid, uint8_t lun, uint32_t sector, uint8_t *buffer, uint32_t length) 48 | { 49 | if (inode->u.i_bops->read) { 50 | inode->u.i_bops->read(inode, buffer, sector, length / geo.geo_sectorsize); 51 | } 52 | 53 | return 0; 54 | } 55 | 56 | int usbd_msc_sector_write(uint8_t busid, uint8_t lun, uint32_t sector, uint8_t *buffer, uint32_t length) 57 | { 58 | if (inode->u.i_bops->write) { 59 | inode->u.i_bops->write(inode, buffer, sector, length / geo.geo_sectorsize); 60 | } 61 | 62 | return 0; 63 | } 64 | 65 | static struct usbd_interface intf0; 66 | 67 | void usbd_msc_init(uint8_t busid, char *path, uint8_t outep, uint8_t inep) 68 | { 69 | memset(devpath, 0, sizeof(devpath)); 70 | strncpy(devpath, path, sizeof(devpath) - 1); 71 | usbd_add_interface(busid, usbd_msc_init_intf(busid, &intf0, outep, inep)); 72 | } -------------------------------------------------------------------------------- /platform/qmk/.gitkeep: -------------------------------------------------------------------------------- 1 | TODO Release -------------------------------------------------------------------------------- /platform/rtthread/usb_check.c: -------------------------------------------------------------------------------- 1 | #include "rtthread.h" 2 | 3 | #if defined(PKG_CHERRYUSB_HOST) || defined(RT_CHERRYUSB_HOST) 4 | 5 | #ifndef RT_USING_TIMER_SOFT 6 | #error must enable RT_USING_TIMER_SOFT to support timer callback in thread 7 | #endif 8 | 9 | #if RT_TIMER_THREAD_STACK_SIZE < 2048 10 | #error "RT_TIMER_THREAD_STACK_SIZE must be >= 2048" 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /platform/rtthread/usb_msh.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "rtthread.h" 7 | 8 | #if defined(PKG_CHERRYUSB_HOST) || defined(RT_CHERRYUSB_HOST) 9 | 10 | #include "usbh_core.h" 11 | 12 | int usbh_init(int argc, char **argv) 13 | { 14 | uint8_t busid; 15 | uint32_t reg_base; 16 | 17 | if (argc < 3) { 18 | USB_LOG_ERR("please input correct command: usbh_init \r\n"); 19 | return -1; 20 | } 21 | 22 | busid = atoi(argv[1]); 23 | reg_base = strtoll(argv[2], NULL, 16); 24 | usbh_initialize(busid, reg_base); 25 | 26 | return 0; 27 | } 28 | 29 | int usbh_deinit(int argc, char **argv) 30 | { 31 | uint8_t busid; 32 | 33 | if (argc < 2) { 34 | USB_LOG_ERR("please input correct command: usbh_deinit \r\n"); 35 | return -1; 36 | } 37 | 38 | busid = atoi(argv[1]); 39 | usbh_deinitialize(busid); 40 | 41 | return 0; 42 | } 43 | 44 | MSH_CMD_EXPORT(usbh_init, init usb host); 45 | MSH_CMD_EXPORT(usbh_deinit, deinit usb host); 46 | MSH_CMD_EXPORT(lsusb, ls usb devices); 47 | #endif 48 | -------------------------------------------------------------------------------- /platform/zephyr/usb_cmd.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if CONFIG_CHERRYUSB_HOST 4 | #include "usbh_core.h" 5 | static void shell_lsusb_handle(const struct shell *sh, size_t argc, char **argv) 6 | { 7 | ARG_UNUSED(sh); 8 | lsusb(argc, argv); 9 | } 10 | 11 | SHELL_CMD_REGISTER(lsusb, NULL, "Usage: lsusb [options]...\r\n", shell_lsusb_handle); 12 | #endif -------------------------------------------------------------------------------- /port/aic/usb_dc_aic_ll.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include "usbd_core.h" 11 | #include "usb_dc_aic_reg.h" 12 | 13 | extern irqreturn_t USBD_IRQHandler(int irq, void * data); 14 | 15 | uint32_t usbd_clk; 16 | static unsigned char dma_sync_buffer[CACHE_LINE_SIZE] __attribute__((aligned(CACHE_LINE_SIZE))); 17 | 18 | void usb_dc_sync_dma(void) 19 | { 20 | asm volatile("sw t0, (%0)" : : "r"(dma_sync_buffer)); 21 | csi_dcache_clean_range((phy_addr_t)(ptr_t)dma_sync_buffer, CACHE_LINE_SIZE); 22 | } 23 | 24 | void usb_dc_low_level_init(void) 25 | { 26 | /* set usb0 phy switch: Host/Device */ 27 | #if defined(AIC_USING_USB0_DEVICE) || defined(AIC_USING_USB0_OTG) 28 | hal_syscfg_usb_phy0_sw_host(0); 29 | #endif 30 | /* set pin-mux */ 31 | 32 | /* enable clock */ 33 | hal_clk_enable(CONFIG_USB_AIC_DC_PHY_CLK); 34 | hal_clk_enable(CONFIG_USB_AIC_DC_CLK); 35 | aicos_udelay(300); 36 | hal_reset_assert(CONFIG_USB_AIC_DC_PHY_RESET); 37 | hal_reset_assert(CONFIG_USB_AIC_DC_RESET); 38 | aicos_udelay(300); 39 | hal_reset_deassert(CONFIG_USB_AIC_DC_PHY_RESET); 40 | hal_reset_deassert(CONFIG_USB_AIC_DC_RESET); 41 | aicos_udelay(300); 42 | 43 | usbd_clk = hal_clk_get_freq(CONFIG_USB_AIC_DC_CLK); 44 | 45 | /* register interrupt callback */ 46 | aicos_request_irq(CONFIG_USB_AIC_DC_IRQ_NUM, USBD_IRQHandler, 47 | 0, "usb_device", NULL); 48 | aicos_irq_enable(CONFIG_USB_AIC_DC_IRQ_NUM); 49 | } 50 | 51 | void usb_dc_low_level_deinit(void) 52 | { 53 | aicos_irq_disable(CONFIG_USB_AIC_DC_IRQ_NUM); 54 | 55 | hal_reset_assert(CONFIG_USB_AIC_DC_PHY_RESET); 56 | hal_reset_assert(CONFIG_USB_AIC_DC_RESET); 57 | hal_clk_disable(CONFIG_USB_AIC_DC_PHY_CLK); 58 | hal_clk_disable(CONFIG_USB_AIC_DC_CLK); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /port/bouffalolab/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | - BL616/BL808 6 | -------------------------------------------------------------------------------- /port/ch32/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | - CH32V30x 6 | -------------------------------------------------------------------------------- /port/chipidea/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | ### NXP 6 | 7 | Modify USB_NOCACHE_RAM_SECTION 8 | 9 | ``` 10 | #define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable"))) 11 | ``` 12 | 13 | - IMRT10XX/IMRT11XX (chipidea + EHCI) 14 | - MCXN9XX/MCXN236 (chipidea + EHCI) 15 | -------------------------------------------------------------------------------- /port/dwc2/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | If you are using more than one port, all ip parameters must be the same(like fifo num, endpoint num, dma support and so on), otherwise give up using multi ports. 4 | 5 | ## Support Chip List 6 | 7 | ## STM32 8 | 9 | - STM32F105xc、STM32F107xc 10 | - STM32F205xx、STM32F207xx、STM32F215xx、STM32F217xx 11 | - STM32F401xc、STM32F401xe、STM32F405xx、STM32F407xx、STM32F411xe、STM32F412cx、STM32F412rx、STM32F412vx、STM32F412zx、STM32F413xx、STM32F415xx、STM32F417xx、STM32F423xx、STM32F423xx、STM32F429xx、STM32F437xx、STM32F439xx、STM32F446xx、STM32F469xx、STM32F479xx 12 | - STM32F7xx 13 | - STM32H7xx 14 | - STM32L4xx 15 | - STM32MPxx 16 | 17 | ## AT32 18 | 19 | - AT32F402xx、AT32F405xx、AT32F415xx、AT32F423xx、AT32F425xx、AT32F435xx、AT32F437xx 20 | 21 | ## GD32 22 | 23 | CONFIG_USBDEV_EP_NUM 必须为4 或者 6,并删除 usb_dc_dwc2.c 中 while(1){} 24 | 25 | 当 CONFIG_USBDEV_EP_NUM 为4 时,fifo_num 不得大于 320 字 26 | 当 CONFIG_USBDEV_EP_NUM 为6 时,fifo_num 不得大于 1280 字 27 | 28 | - GD32F30X_CL 29 | - GD32F405、GD32F407 30 | - GD32F350、GD32F450 31 | 32 | ## HC32 33 | 34 | - HC32F4A0 35 | 36 | ## Espressif 37 | 38 | - ESP32S2、ESP32S3、ESP32P4 39 | 40 | ## Sophgo 41 | 42 | - CV18xx 43 | 44 | ## Kendryte 45 | 46 | - K230 47 | 48 | ## Nationstech 49 | 50 | - N32H4X -------------------------------------------------------------------------------- /port/dwc2/usb_glue_at.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "usb_config.h" 7 | #include "stdint.h" 8 | #include "usb_dwc2_reg.h" 9 | 10 | extern unsigned int system_core_clock; 11 | 12 | uint32_t SystemCoreClock; 13 | /* you can find this config in function: usb_global_init, file:at32fxxx_usb.c, for example: 14 | * 15 | * usbx->gccfg_bit.pwrdown = TRUE; 16 | * usbx->gccfg_bit.avalidsesen = TRUE; 17 | * usbx->gccfg_bit.bvalidsesen = TRUE; 18 | * 19 | */ 20 | 21 | uint32_t usbd_get_dwc2_gccfg_conf(uint32_t reg_base) 22 | { 23 | SystemCoreClock = system_core_clock; 24 | #ifdef CONFIG_USB_HS 25 | return ((1 << 16) | (1 << 21)); 26 | #else 27 | // AT32F415 28 | #if defined(AT32F415RCT7) || defined(AT32F415RCT7_7) || defined(AT32F415CCT7) || \ 29 | defined(AT32F415CCU7) || defined(AT32F415KCU7_4) || defined(AT32F415RBT7) || \ 30 | defined(AT32F415RBT7_7) || defined(AT32F415CBT7) || defined(AT32F415CBU7) || \ 31 | defined(AT32F415KBU7_4) || defined(AT32F415R8T7) || defined(AT32F415R8T7_7) || \ 32 | defined(AT32F415C8T7) || defined(AT32F415K8U7_4) 33 | return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21)); 34 | #else 35 | return ((1 << 16) | (1 << 21)); 36 | #endif 37 | #endif 38 | } 39 | 40 | uint32_t usbh_get_dwc2_gccfg_conf(uint32_t reg_base) 41 | { 42 | SystemCoreClock = system_core_clock; 43 | #ifdef CONFIG_USB_HS 44 | return ((1 << 16) | (1 << 21)); 45 | #else 46 | // AT32F415 47 | #if defined(AT32F415RCT7) || defined(AT32F415RCT7_7) || defined(AT32F415CCT7) || \ 48 | defined(AT32F415CCU7) || defined(AT32F415KCU7_4) || defined(AT32F415RBT7) || \ 49 | defined(AT32F415RBT7_7) || defined(AT32F415CBT7) || defined(AT32F415CBU7) || \ 50 | defined(AT32F415KBU7_4) || defined(AT32F415R8T7) || defined(AT32F415R8T7_7) || \ 51 | defined(AT32F415C8T7) || defined(AT32F415K8U7_4) 52 | return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21)); 53 | #else 54 | return ((1 << 16) | (1 << 21)); 55 | #endif 56 | #endif 57 | } 58 | 59 | extern uint32_t SystemCoreClock; 60 | 61 | void usbd_dwc2_delay_ms(uint8_t ms) 62 | { 63 | uint32_t count = SystemCoreClock / 1000 * ms; 64 | while (count--) { 65 | __asm volatile("nop"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /port/dwc2/usb_glue_gd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "usb_config.h" 7 | #include "stdint.h" 8 | #include "usb_dwc2_reg.h" 9 | 10 | #if CONFIG_USBDEV_EP_NUM != 4 && CONFIG_USBDEV_EP_NUM != 6 11 | #error "gd32 only has 4 endpoints for pa11/pa12 and 6 endpoints for pb14/pb15" 12 | #endif 13 | 14 | /* you can find this config in function:usb_core_init, file:drv_usb_core.c, for example: 15 | * 16 | * usb_regs->gr->GCCFG |= GCCFG_PWRON | GCCFG_VBUSACEN | GCCFG_VBUSBCEN; 17 | * 18 | */ 19 | 20 | uint32_t usbd_get_dwc2_gccfg_conf(uint32_t reg_base) 21 | { 22 | #ifdef CONFIG_USB_HS 23 | return 0; 24 | #else 25 | return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21)); 26 | #endif 27 | } 28 | 29 | uint32_t usbh_get_dwc2_gccfg_conf(uint32_t reg_base) 30 | { 31 | #ifdef CONFIG_USB_HS 32 | return 0; 33 | #else 34 | return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21)); 35 | #endif 36 | } 37 | 38 | extern uint32_t SystemCoreClock; 39 | 40 | void usbd_dwc2_delay_ms(uint8_t ms) 41 | { 42 | uint32_t count = SystemCoreClock / 1000 * ms; 43 | while (count--) { 44 | __asm volatile("nop"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /port/dwc2/usb_glue_hc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "usb_config.h" 7 | #include "usb_dwc2_reg.h" 8 | 9 | /* When using [GPIO_SetFunc(USBF_VBUS_PORT, USBF_VBUS_PIN, USBF_VBUS_FUNC);], there is no need to configure GOTGCTL */ 10 | 11 | #define USB_OTG_GLB ((DWC2_GlobalTypeDef *)(reg_base)) 12 | 13 | uint32_t usbd_get_dwc2_gccfg_conf(uint32_t reg_base) 14 | { 15 | 16 | USB_OTG_GLB->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; 17 | USB_OTG_GLB->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; 18 | return 0; 19 | } 20 | 21 | uint32_t usbh_get_dwc2_gccfg_conf(uint32_t reg_base) 22 | { 23 | USB_OTG_GLB->GOTGCTL &= ~USB_OTG_GOTGCTL_BVALOEN; 24 | USB_OTG_GLB->GOTGCTL &= ~USB_OTG_GOTGCTL_BVALOVAL; 25 | return 0; 26 | } 27 | 28 | extern uint32_t SystemCoreClock; 29 | 30 | void usbd_dwc2_delay_ms(uint8_t ms) 31 | { 32 | uint32_t count = SystemCoreClock / 1000 * ms; 33 | while (count--) { 34 | __asm volatile("nop"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /port/ehci/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | ### BouffaloLab 6 | 7 | - BouffaloLab BL616/BL808 (bouffalolab + EHCI) 8 | 9 | ### HPMicro 10 | 11 | - HPM all series (hpmicro + EHCI) 12 | 13 | ### AllwinnerTech 14 | 15 | - F133/T113 16 | 17 | ### Nuvoton 18 | 19 | - Nuvoton all series 20 | 21 | ### Artinchip 22 | 23 | - d13x, d21x 24 | 25 | ### NXP 26 | 27 | Modify USB_NOCACHE_RAM_SECTION 28 | 29 | ``` 30 | #define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable"))) 31 | ``` 32 | 33 | - IMRT10XX/IMRT11XX (chipidea + EHCI) 34 | - MCXN9XX/MCXN236 (chipidea + EHCI) 35 | 36 | ### Intel 37 | 38 | - Intel 6 Series Chipset and Intel C200 Series Chipset 39 | -------------------------------------------------------------------------------- /port/ehci/usb_glue_intel.c: -------------------------------------------------------------------------------- 1 | #ifdef __rtems__ 2 | 3 | #include 4 | #include 5 | #include 6 | #include "usbh_core.h" 7 | 8 | uint32_t echi_base; 9 | static int ehci_bus; 10 | static int ehci_slot; 11 | static int ehci_function; 12 | static int ehci_vector; 13 | 14 | extern void USBH_IRQHandler(uint8_t busid); 15 | 16 | void ehci_pci_scan(int bus, int slot, int fun, int vector) 17 | { 18 | ehci_bus = bus; 19 | ehci_slot = slot; 20 | ehci_function = fun; 21 | ehci_vector = vector; 22 | pci_read_config_dword(bus, slot, fun, PCI_BASE_ADDRESS_0, &echi_base); 23 | } 24 | void usb_hc_low_level_init(struct usbh_bus *bus) 25 | { 26 | //set software own ehci 27 | uint32_t legacy_val; 28 | pci_write_config_dword(ehci_bus, ehci_slot, ehci_function, 0x68, 1 << 24); 29 | pci_read_config_dword(ehci_bus, ehci_slot, ehci_function, 0x68, &legacy_val); 30 | if ((legacy_val & 0x01010000) == 0x01000000) 31 | printf("OS owned echi\n"); 32 | else 33 | printf("BIOS owned echi\n"); 34 | 35 | rtems_status_code sc; 36 | sc = rtems_interrupt_handler_install( 37 | ehci_vector, 38 | "USBirq", 39 | RTEMS_INTERRUPT_SHARED, 40 | USBH_IRQHandler, 41 | (void *)0); 42 | 43 | if (sc != RTEMS_SUCCESSFUL) { 44 | printf("USB install isr falied,%s\n", rtems_status_text(sc)); 45 | return; 46 | } 47 | } 48 | 49 | uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port) 50 | { 51 | printf("USB_SPEED_HIGH present\n"); 52 | return USB_SPEED_HIGH; 53 | } 54 | 55 | #endif -------------------------------------------------------------------------------- /port/ehci/usb_glue_nuc980.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ /** 2 | * 3 | * @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved. 4 | * 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Change Logs: 8 | * Date Author Notes 9 | * 2023-8-8 Wayne First version 10 | * 11 | ******************************************************************************/ 12 | #include "rtthread.h" 13 | 14 | #include "NuMicro.h" 15 | #include "rthw.h" 16 | #include "drv_sys.h" 17 | 18 | #define LOG_TAG "drv.cherry" 19 | #define DBG_ENABLE 20 | #define DBG_SECTION_NAME LOG_TAG 21 | #define DBG_LEVEL DBG_LOG 22 | #define DBG_COLOR 23 | #include 24 | 25 | #if defined(PKG_CHERRYUSB_HOST) 26 | #include "usbh_core.h" 27 | 28 | static void nu_ehci_isr(int vector, void *param) 29 | { 30 | extern void USBH_IRQHandler(uint8_t busid); 31 | USBH_IRQHandler(0); 32 | } 33 | 34 | void usb_hc_low_level_init(struct usbh_bus *bus) 35 | { 36 | LOG_D("%s %d", __FUNCTION__, __LINE__); 37 | 38 | rt_hw_interrupt_mask(IRQ_EHCI); 39 | 40 | /* Enable USBH clock */ 41 | nu_sys_ipclk_enable(USBHCKEN); 42 | nu_sys_ip_reset(USBHRST); 43 | 44 | outpw(0xB0015000 + 0xC4, 0x160); //HSUSBH->USBPCR0 = 0x160; /* enable PHY 0 */ 45 | outpw(0xB0015000 + 0xC8, 0x520); //HSUSBH->USBPCR1 = 0x520; /* enable PHY 1 */ 46 | 47 | //USBH->HcMiscControl |= USBH_HcMiscControl_OCAL_Msk; /* Over-current active low */ 48 | //outpw(0xB0017000 + 0x204, inpw(0xB0017000 + 0x204) | (0x1ul << 3)); 49 | 50 | //USBH->HcMiscControl &= ~USBH_HcMiscControl_OCAL_Msk; /* Over-current active high */ 51 | outpw(0xB0017000 + 0x204, inpw(0xB0017000 + 0x204) & (~(0x1ul << 3))); 52 | 53 | rt_hw_interrupt_install(IRQ_EHCI, nu_ehci_isr, NULL, "ehci-1"); 54 | rt_hw_interrupt_set_priority(IRQ_EHCI, IRQ_LEVEL_1); 55 | rt_hw_interrupt_umask(IRQ_EHCI); 56 | } 57 | 58 | uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port) 59 | { 60 | return USB_SPEED_HIGH; 61 | } 62 | #endif -------------------------------------------------------------------------------- /port/fsdev/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | ## STM32 6 | 7 | - STM32F042x6、STM32F048xx、STM32F070x6、STM32F070xb、STM32F072xb、STM32F078xx 8 | - STM32F102x6、STM32F102xb、STM32F103x6、STM32F103xb、STM32F103xe、STM32F103xg 9 | - STM32F302x8、STM32F302xc、STM32F302xe、STM32F373xc 10 | - STM32g431xx、STM32g441xx、STM32g471xx、STM32g483xx、STM32g484xx、STM32gbk1cb 11 | - STM32l052xx、STM32l053xx、STM32l062xx、STM32l063xx、STM32l072xx、STM32l073xx、STM32l082xx、STM32l083xx 12 | - STM32l100xb、STM32l100xba、STM32l100xc、STM32l151xb、STM32l151xba、STM32l151xc、STM32l151xca、STM32l151xd、STM32l151xdx、STM32l151xe、STM32l152xb、STM32l152xba、STM32l152xc、STM32l152xa、STM32l152xd、STM32l152xdx、STM32l152xe、STM32l162xc、STM32l162xca、STM32l162xd、STM32l162xdx、STM32l162xe 13 | - STM32l412xx、STM32l422xx、STM32l432xx、STM32l433xx、STM32l442xx、STM32l452xx、STM32l462xx 14 | - STM32wb5mxx、STM32wb35xx、STM32wb55xx 15 | 16 | ## AT32 17 | 18 | - AT32F403xx、AT32F407xx、AT32F413xx 19 | 20 | ## APM32 21 | 22 | - APM32f10x 23 | 24 | ## GD32 25 | 26 | - GD32F10X 27 | 28 | ## CH32 29 | 30 | - CH32F10x、CH32V10x 31 | -------------------------------------------------------------------------------- /port/fsdev/usb_glue_st.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "usbd_core.h" 7 | 8 | #if __has_include("stm32f0xx_hal.h") 9 | #include "stm32f0xx_hal.h" 10 | #elif __has_include("stm32f1xx_hal.h") 11 | #include "stm32f1xx_hal.h" 12 | #elif __has_include("stm32f3xx_hal.h") 13 | #include "stm32f3xx_hal.h" 14 | #elif __has_include("stm32g0xx_hal.h") 15 | #include "stm32g0xx_hal.h" 16 | #elif __has_include("stm32g4xx_hal.h") 17 | #include "stm32g4xx_hal.h" 18 | #elif __has_include("stm32l0xx_hal.h") 19 | #include "stm32l0xx_hal.h" 20 | #elif __has_include("stm32l1xx_hal.h") 21 | #include "stm32l1xx_hal.h" 22 | #elif __has_include("stm32l4xx_hal.h") 23 | #include "stm32l4xx_hal.h" 24 | #elif __has_include("stm32l5xx_hal.h") 25 | #include "stm32l5xx_hal.h" 26 | #endif 27 | 28 | #if !defined(HAL_PCD_MODULE_ENABLED) 29 | #error please define HAL_PCD_MODULE_ENABLED in stm32xxx_hal_conf.h 30 | #endif 31 | 32 | #ifndef CONFIG_USBDEV_FSDEV_PMA_ACCESS 33 | #error "please define CONFIG_USBDEV_FSDEV_PMA_ACCESS in usb_config.h" 34 | #endif 35 | 36 | #if CONFIG_USBDEV_FSDEV_PMA_ACCESS != PMA_ACCESS 37 | #error "CONFIG_USBDEV_FSDEV_PMA_ACCESS must be equal PMA_ACCESS" 38 | #endif 39 | 40 | struct fsdev_instance { 41 | USB_TypeDef *Instance; 42 | }; 43 | 44 | static struct fsdev_instance g_fsdev_instance; 45 | 46 | void usb_dc_low_level_init(uint8_t busid) 47 | { 48 | g_fsdev_instance.Instance = (USB_TypeDef *)g_usbdev_bus[busid].reg_base; 49 | HAL_PCD_MspInit((PCD_HandleTypeDef *)&g_fsdev_instance); 50 | } 51 | 52 | void usb_dc_low_level_deinit(uint8_t busid) 53 | { 54 | g_fsdev_instance.Instance = (USB_TypeDef *)g_usbdev_bus[busid].reg_base; 55 | HAL_PCD_MspDeInit((PCD_HandleTypeDef *)&g_fsdev_instance); 56 | } 57 | 58 | void USB_IRQHandler(void) 59 | { 60 | USBD_IRQHandler(0); 61 | } 62 | 63 | void USB_LP_IRQHandler(void) 64 | { 65 | USBD_IRQHandler(0); 66 | } -------------------------------------------------------------------------------- /port/hpmicro/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | - HPM all series (HPMicro + EHCI) 6 | -------------------------------------------------------------------------------- /port/hpmicro/usb_glue_hpm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2025 HPMicro 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | * 6 | */ 7 | #include "hpm_common.h" 8 | #include "hpm_soc.h" 9 | 10 | void (*g_usb_hpm_irq[2])(uint8_t busid); 11 | uint8_t g_usb_hpm_busid[2]; 12 | 13 | ATTR_WEAK void hpm_usb_isr_enable(uint32_t base) 14 | { 15 | if (base == HPM_USB0_BASE) { 16 | intc_m_enable_irq(IRQn_USB0); 17 | } else { 18 | #ifdef HPM_USB1_BASE 19 | intc_m_enable_irq(IRQn_USB1); 20 | #endif 21 | } 22 | } 23 | 24 | ATTR_WEAK void hpm_usb_isr_disable(uint32_t base) 25 | { 26 | if (base == HPM_USB0_BASE) { 27 | intc_m_disable_irq(IRQn_USB0); 28 | } else { 29 | #ifdef HPM_USB1_BASE 30 | intc_m_disable_irq(IRQn_USB1); 31 | #endif 32 | } 33 | } 34 | 35 | #ifndef CONFIG_CHERRYUSB_CUSTOM_IRQ_HANDLER 36 | SDK_DECLARE_EXT_ISR_M(IRQn_USB0, hpm_isr_usb0) 37 | #endif 38 | void hpm_isr_usb0(void) 39 | { 40 | g_usb_hpm_irq[0](g_usb_hpm_busid[0]); 41 | } 42 | 43 | #ifdef HPM_USB1_BASE 44 | #ifndef CONFIG_CHERRYUSB_CUSTOM_IRQ_HANDLER 45 | SDK_DECLARE_EXT_ISR_M(IRQn_USB1, hpm_isr_usb1) 46 | #endif 47 | void hpm_isr_usb1(void) 48 | { 49 | g_usb_hpm_irq[1](g_usb_hpm_busid[1]); 50 | } 51 | #endif -------------------------------------------------------------------------------- /port/hpmicro/usb_glue_hpm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2025 HPMicro 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | * 6 | */ 7 | 8 | #ifndef _HPM_USB_GLUE_HPM_H_ 9 | #define _HPM_USB_GLUE_HPM_H_ 10 | 11 | extern void (*g_usb_hpm_irq[2])(uint8_t busid); 12 | extern uint8_t g_usb_hpm_busid[2]; 13 | 14 | void hpm_usb_isr_enable(uint32_t base); 15 | void hpm_usb_isr_disable(uint32_t base); 16 | void hpm_isr_usb0(void); 17 | void hpm_isr_usb1(void); 18 | 19 | #endif /* _HPM_USB_GLUE_HPM_H_ */ -------------------------------------------------------------------------------- /port/kinetis/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | ### NXP 6 | 7 | Modify USB_NOCACHE_RAM_SECTION 8 | 9 | ``` 10 | #define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable"))) 11 | ``` 12 | 13 | - MCXC444/MCXA153/MCXA156 (device only) 14 | - MCXN947 15 | 16 | ### MM32 17 | 18 | - MM32F3/MM32F5 19 | -------------------------------------------------------------------------------- /port/kinetis/usb_glue_mcx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "usbd_core.h" 7 | #include "fsl_common.h" 8 | #include "usb_kinetis_reg.h" 9 | 10 | #define USB_OTG_DEV ((KINETIS_MCX_TypeDef *)g_usbdev_bus[busid].reg_base) 11 | 12 | #if defined(MCXC444_H_) 13 | #define USBD_IRQ USB0_IRQHandler 14 | void USB_ClockInit(void) 15 | { 16 | SystemCoreClockUpdate(); 17 | CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcIrc48M, 48000000U); 18 | } 19 | #elif defined(MCXA153_H_) 20 | #define USBD_IRQ USB0_IRQHandler 21 | void USB_ClockInit(void) 22 | { 23 | RESET_PeripheralReset(kUSB0_RST_SHIFT_RSTn); 24 | CLOCK_EnableUsbfsClock(); 25 | } 26 | #elif defined(MCXN947_CM33_CORE0_H_) 27 | #define USBD_IRQ USB0_FS_IRQHandler 28 | void USB_ClockInit(void) 29 | { 30 | CLOCK_AttachClk(kCLK_48M_to_USB0); 31 | CLOCK_EnableClock(kCLOCK_Usb0Ram); 32 | CLOCK_EnableClock(kCLOCK_Usb0Fs); 33 | CLOCK_EnableUsbfsClock(); 34 | } 35 | #elif defined(MCXA156_H_) 36 | #define USBD_IRQ USB0_IRQHandler 37 | void USB_ClockInit(void) 38 | { 39 | RESET_PeripheralReset(kUSB0_RST_SHIFT_RSTn); 40 | CLOCK_EnableUsbfsClock(); 41 | } 42 | #else 43 | #error "Unsupported MCU with Kinetis IP" 44 | #endif 45 | 46 | void USBD_IRQ(void) 47 | { 48 | extern void USBD_IRQHandler(uint8_t busid); 49 | USBD_IRQHandler(0); 50 | } 51 | 52 | void usb_dc_low_level_init(uint8_t busid) 53 | { 54 | USB_ClockInit(); 55 | 56 | uint8_t irqNumber; 57 | 58 | uint8_t usbDeviceKhciIrq[] = USB_IRQS; 59 | irqNumber = usbDeviceKhciIrq[0]; 60 | 61 | /* Install isr, set priority, and enable IRQ. */ 62 | NVIC_SetPriority((IRQn_Type)irqNumber, 3); 63 | EnableIRQ((IRQn_Type)irqNumber); 64 | 65 | USB_OTG_DEV->USBTRC0 |= USB_USBTRC0_USBRESET_MASK; 66 | while (USB_OTG_DEV->USBTRC0 & USB_USBTRC0_USBRESET_MASK); 67 | 68 | USB_OTG_DEV->USBTRC0 |= USB_USBTRC0_VREGIN_STS(1); /* software must set this bit to 1 */ 69 | USB_OTG_DEV->USBCTRL = 0; 70 | USB_OTG_DEV->CONTROL |= USB_CONTROL_DPPULLUPNONOTG_MASK; 71 | } 72 | 73 | void usb_dc_low_level_deinit(uint8_t busid) 74 | { 75 | USB_OTG_DEV->CONTROL &= ~USB_CONTROL_DPPULLUPNONOTG_MASK; 76 | #if defined(MCXN947_CM33_CORE0_H_) 77 | DisableIRQ((IRQn_Type)USB0_FS_IRQn); 78 | #else 79 | DisableIRQ((IRQn_Type)USB0_IRQn); 80 | #endif 81 | } 82 | 83 | void usbd_kinetis_delay_ms(uint8_t ms) 84 | { 85 | } -------------------------------------------------------------------------------- /port/kinetis/usb_glue_mm32.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "mm32_device.h" 5 | #include "hal_rcc.h" 6 | #include "usbd_core.h" 7 | 8 | void usb_dc_low_level_init(uint8_t busid) 9 | { 10 | /* Select USBCLK source */ 11 | // RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1); 12 | RCC->CFGR &= ~(0x3 << 22); 13 | RCC->CFGR |= (0x1 << 22); 14 | 15 | /* Enable USB clock */ 16 | RCC->AHB2ENR |= 0x1 << 7; 17 | 18 | #define USB_DEVICE_INTERRUPT_PRIORITY (7U) 19 | NVIC_SetPriority((IRQn_Type)USB_OTGFS_IRQn, USB_DEVICE_INTERRUPT_PRIORITY); 20 | NVIC_EnableIRQ(USB_OTGFS_IRQn); 21 | } 22 | 23 | void usb_dc_low_level_deinit(uint8_t busid) 24 | { 25 | RCC->AHB2ENR &= ~(0x1 << 7); 26 | } 27 | 28 | void USB_OTGFS_IRQHandler(void) 29 | { 30 | USBD_IRQHandler(0); 31 | } 32 | 33 | void usbd_kinetis_delay_ms(uint8_t ms) 34 | { 35 | //delay_ms(ms); 36 | } 37 | -------------------------------------------------------------------------------- /port/kinetis/usb_hc_kinetis.c: -------------------------------------------------------------------------------- 1 | TODO -------------------------------------------------------------------------------- /port/musb/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | ### Eastsoft 6 | 7 | - ES32F3xx 8 | 9 | ### TI 10 | 11 | - MSP432E4x 12 | 13 | ### Bekencorp 14 | 15 | - BK7256/BK7258 16 | 17 | ### AllwinnerTech 18 | 19 | - F1Cxxx, F2Cxxx 20 | -------------------------------------------------------------------------------- /port/musb/usb_glue_es.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "usb_config.h" 7 | #include "stdint.h" 8 | #include "usb_musb_reg.h" 9 | 10 | #if CONFIG_USBDEV_EP_NUM != 6 11 | #error es32 chips only support 6 endpoints 12 | #endif 13 | 14 | #if CONFIG_USBHOST_PIPE_NUM != 6 15 | #error es32 chips only support 6 pipes 16 | #endif 17 | 18 | // clang-format off 19 | static struct musb_fifo_cfg musb_device_table[] = { 20 | { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, }, 21 | { .ep_num = 1, .style = FIFO_TXRX, .maxpacket = 1024, }, 22 | { .ep_num = 2, .style = FIFO_TXRX, .maxpacket = 512, }, 23 | { .ep_num = 3, .style = FIFO_TXRX, .maxpacket = 512, }, 24 | { .ep_num = 4, .style = FIFO_TXRX, .maxpacket = 512, }, 25 | { .ep_num = 5, .style = FIFO_TXRX, .maxpacket = 512, }, 26 | }; 27 | 28 | static struct musb_fifo_cfg musb_host_table[] = { 29 | { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, }, 30 | { .ep_num = 1, .style = FIFO_TXRX, .maxpacket = 1024, }, 31 | { .ep_num = 2, .style = FIFO_TXRX, .maxpacket = 512, }, 32 | { .ep_num = 3, .style = FIFO_TXRX, .maxpacket = 512, }, 33 | { .ep_num = 4, .style = FIFO_TXRX, .maxpacket = 512, }, 34 | { .ep_num = 5, .style = FIFO_TXRX, .maxpacket = 512, }, 35 | }; 36 | // clang-format on 37 | 38 | uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg) 39 | { 40 | *cfg = musb_device_table; 41 | return sizeof(musb_device_table) / sizeof(musb_device_table[0]); 42 | } 43 | 44 | uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg) 45 | { 46 | *cfg = musb_host_table; 47 | return sizeof(musb_host_table) / sizeof(musb_host_table[0]); 48 | } 49 | 50 | uint32_t usb_get_musb_ram_size(void) 51 | { 52 | return 4096; 53 | } 54 | 55 | void usbd_musb_delay_ms(uint8_t ms) 56 | { 57 | /* implement later */ 58 | } 59 | -------------------------------------------------------------------------------- /port/musb/usb_glue_sunxi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "usb_config.h" 7 | #include "stdint.h" 8 | #include "usb_musb_reg.h" 9 | 10 | #ifndef CONFIG_USB_MUSB_SUNXI 11 | #error must define CONFIG_USB_MUSB_SUNXI when use sunxi chips 12 | #endif 13 | 14 | #if CONFIG_USBDEV_EP_NUM != 4 15 | #error sunxi chips only support 4 endpoints 16 | #endif 17 | 18 | #if CONFIG_USBHOST_PIPE_NUM != 4 19 | #error sunxi chips only support 4 pipes 20 | #endif 21 | 22 | // clang-format off 23 | static struct musb_fifo_cfg musb_device_table[] = { 24 | { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, }, 25 | { .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, }, 26 | { .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, }, 27 | { .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 28 | { .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, }, 29 | { .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, }, 30 | { .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, }, 31 | }; 32 | 33 | static struct musb_fifo_cfg musb_host_table[] = { 34 | { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, }, 35 | { .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, }, 36 | { .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, }, 37 | { .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 38 | { .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, }, 39 | { .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, }, 40 | { .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, }, 41 | }; 42 | // clang-format on 43 | 44 | uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg) 45 | { 46 | *cfg = musb_device_table; 47 | return sizeof(musb_device_table) / sizeof(musb_device_table[0]); 48 | } 49 | 50 | uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg) 51 | { 52 | *cfg = musb_host_table; 53 | return sizeof(musb_host_table) / sizeof(musb_host_table[0]); 54 | } 55 | 56 | uint32_t usb_get_musb_ram_size(void) 57 | { 58 | return 8192; 59 | } 60 | 61 | void usbd_musb_delay_ms(uint8_t ms) 62 | { 63 | /* implement later */ 64 | } 65 | -------------------------------------------------------------------------------- /port/nuvoton/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | - M032 Series 6 | - M480 Series 7 | 8 | -------------------------------------------------------------------------------- /port/nxp/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | ### MCX 6 | 7 | Modify USB_NOCACHE_RAM_SECTION 8 | 9 | ``` 10 | #define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable"))) 11 | ``` 12 | 13 | - MCXN9XX/MCXN236 (chipidea + EHCI) 14 | 15 | ## IMRT 16 | 17 | - IMRT10XX/IMRT11XX (chipidea + EHCI) -------------------------------------------------------------------------------- /port/ohci/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | This OHCI is a companion controller of EHCI. But you can use OHCI only without CONFIG_USB_EHCI_WITH_OHCI definition. 4 | 5 | **And you need to pay for using OHCI driver**. 6 | 7 | ## Support Chip List 8 | 9 | ### AllwinnerTech 10 | 11 | - F133(EHCI + OHCI) 12 | 13 | ### Nuvoton 14 | 15 | - Nuvoton all series(EHCI + OHCI, OHCI only) 16 | 17 | ### Artinchip 18 | 19 | - d13x, d21x(EHCI + OHCI) 20 | 21 | ### NXP 22 | 23 | - LPC4X/LPC5X(OHCI only) -------------------------------------------------------------------------------- /port/ohci/usb_glue_lpc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "fsl_device_registers.h" 7 | #include "fsl_power.h" 8 | #include "usbh_core.h" 9 | 10 | #if defined(CONFIG_USB_EHCI_WITH_OHCI) 11 | #error "lpc does not have ehci" 12 | #endif 13 | 14 | void usb_hc_low_level_init(struct usbh_bus *bus) 15 | { 16 | #if ((defined FSL_FEATURE_SOC_SYSMPU_COUNT) && (FSL_FEATURE_SOC_SYSMPU_COUNT)) 17 | SYSMPU_Enable(SYSMPU, 0); 18 | #endif /* FSL_FEATURE_SOC_SYSMPU_COUNT */ 19 | 20 | NVIC_ClearPendingIRQ(USB0_IRQn); 21 | NVIC_ClearPendingIRQ(USB0_NEEDCLK_IRQn); 22 | 23 | POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*< Turn on USB0 Phy */ 24 | 25 | RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn); 26 | RESET_PeripheralReset(kUSB0HSL_RST_SHIFT_RSTn); 27 | RESET_PeripheralReset(kUSB0HMR_RST_SHIFT_RSTn); 28 | 29 | CLOCK_EnableUsbfs0HostClock(kCLOCK_UsbfsSrcPll1, 48000000U); 30 | 31 | NVIC_SetPriority(USB0_IRQn, 3); 32 | EnableIRQ(USB0_IRQn); 33 | } 34 | 35 | 36 | void usb_hc_low_level_deinit(struct usbh_bus *bus) 37 | { 38 | DisableIRQ(USB0_IRQn); 39 | } 40 | 41 | void USB0_IRQHandler(void) 42 | { 43 | extern void USBH_IRQHandler(uint8_t busid); 44 | USBH_IRQHandler(0); 45 | } -------------------------------------------------------------------------------- /port/pusb2/libpusb2_dc_a32_hardfp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_dc_a32_hardfp.a -------------------------------------------------------------------------------- /port/pusb2/libpusb2_dc_a32_softfp_crypto_neon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_dc_a32_softfp_crypto_neon.a -------------------------------------------------------------------------------- /port/pusb2/libpusb2_dc_a32_softfp_neon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_dc_a32_softfp_neon.a -------------------------------------------------------------------------------- /port/pusb2/libpusb2_dc_a64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_dc_a64.a -------------------------------------------------------------------------------- /port/pusb2/libpusb2_hc_a32_hardfp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_hc_a32_hardfp.a -------------------------------------------------------------------------------- /port/pusb2/libpusb2_hc_a32_softfp_crypto_neon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_hc_a32_softfp_crypto_neon.a -------------------------------------------------------------------------------- /port/pusb2/libpusb2_hc_a32_softfp_neon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_hc_a32_softfp_neon.a -------------------------------------------------------------------------------- /port/pusb2/libpusb2_hc_a64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/pusb2/libpusb2_hc_a64.a -------------------------------------------------------------------------------- /port/pusb2/rt-thread/usb_dc_glue_phytium.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright : (C) 2024 Phytium Information Technology, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Modify History: 7 | * Ver   Who        Date         Changes 8 | * ----- ------     --------    -------------------------------------- 9 | * 1.0 zhugengyu 2024/6/26 first commit 10 | */ 11 | #include "rtthread.h" 12 | #include "interrupt.h" 13 | 14 | #include "fparameters.h" 15 | 16 | #include "usbd_core.h" 17 | 18 | void USBD_IRQHandler(uint8_t busid); 19 | 20 | void usb_assert(const char *filename, int linenum) 21 | { 22 | rt_assert_handler("", filename, linenum); 23 | } 24 | 25 | static void usb_dc_pusb2_interrupt_handler(int irqno, void *param) 26 | { 27 | USBD_IRQHandler(CONFIG_USB_PUSB2_BUS_ID); 28 | } 29 | 30 | static void usb_dc_setup_pusb2_interrupt(uint32_t id) 31 | { 32 | uint32_t irq_num = FUSB2_0_VHUB_IRQ_NUM; 33 | 34 | rt_hw_interrupt_set_priority(irq_num, 0U); 35 | rt_hw_interrupt_install(irq_num, usb_dc_pusb2_interrupt_handler, NULL, "pusb2-dc"); 36 | rt_hw_interrupt_umask(irq_num); 37 | } 38 | 39 | static void usb_dc_revoke_pusb2_interrupt(uint32_t id) 40 | { 41 | uint32_t irq_num = FUSB2_0_VHUB_IRQ_NUM; 42 | 43 | rt_hw_interrupt_mask(irq_num); 44 | } 45 | 46 | unsigned long usb_dc_get_register_base(uint32_t id) 47 | { 48 | USB_ASSERT(id == FUSB2_ID_VHUB_0); 49 | return FUSB2_0_VHUB_BASE_ADDR; 50 | } 51 | 52 | void usb_dc_low_level_init() 53 | { 54 | usb_dc_setup_pusb2_interrupt(CONFIG_USB_PUSB2_BUS_ID); 55 | } 56 | 57 | void usb_dc_low_level_deinit(void) 58 | { 59 | usb_dc_revoke_pusb2_interrupt(CONFIG_USB_PUSB2_BUS_ID); 60 | } 61 | 62 | void *usb_sys_mem_malloc(size_t size) 63 | { 64 | void *buf = rt_malloc(size); 65 | 66 | if (buf) { 67 | rt_memset(buf, 0, size); 68 | } 69 | 70 | return buf; 71 | } 72 | 73 | void usb_sys_mem_free(void *ptr) 74 | { 75 | if (ptr) { 76 | rt_free(ptr); 77 | } 78 | } 79 | 80 | void *usb_sys_malloc_align(size_t align, size_t size) 81 | { 82 | void *buf = rt_malloc_align(size, align); 83 | 84 | if (buf) { 85 | rt_memset(buf, 0, size); 86 | } 87 | 88 | return buf; 89 | } 90 | 91 | int usbd_set_remote_wakeup(uint8_t busid) 92 | { 93 | return -1; 94 | } -------------------------------------------------------------------------------- /port/rp2040/README.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | ## Support Chip List 4 | 5 | - RP2040/RP2350 -------------------------------------------------------------------------------- /port/xhci/phytium/freertos/usb_glue_phytium_plat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright : (C) 2024 Phytium Information Technology, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Modify History: 7 | * Ver   Who        Date         Changes 8 | * ----- ------     --------    -------------------------------------- 9 | * 1.0 zhugengyu 2024/6/26 first commit 10 | */ 11 | /***************************** Include Files *********************************/ 12 | #include 13 | #include 14 | 15 | #include "sdkconfig.h" 16 | 17 | #include "fassert.h" 18 | #include "finterrupt.h" 19 | #include "fcpu_info.h" 20 | #include "fdebug.h" 21 | #include "fcache.h" 22 | #include "fmemory_pool.h" 23 | 24 | #include "usbh_core.h" 25 | 26 | /************************** Constant Definitions *****************************/ 27 | 28 | /**************************** Type Definitions *******************************/ 29 | 30 | /************************** Variable Definitions *****************************/ 31 | static void usb_hc_xhci_interrupt_handler(s32 vector, void *param) 32 | { 33 | extern void USBH_IRQHandler(uint8_t busid); 34 | USBH_IRQHandler((uint8_t)(uintptr_t)param); 35 | } 36 | 37 | void usb_hc_setup_xhci_interrupt(u32 id) 38 | { 39 | u32 cpu_id; 40 | u32 irq_num = (id == FUSB3_ID_0) ? FUSB3_0_IRQ_NUM : FUSB3_1_IRQ_NUM; 41 | u32 irq_priority = 13U; 42 | 43 | GetCpuId(&cpu_id); 44 | InterruptSetTargetCpus(irq_num, cpu_id); 45 | 46 | InterruptSetPriority(irq_num, irq_priority); 47 | 48 | /* register intr callback */ 49 | InterruptInstall(irq_num, 50 | usb_hc_xhci_interrupt_handler, 51 | (void *)(uintptr_t)id, 52 | NULL); 53 | 54 | /* enable irq */ 55 | InterruptUmask(irq_num); 56 | } 57 | 58 | unsigned long usb_hc_get_register_base(uint32_t id) 59 | { 60 | if (FUSB3_ID_0 == id) 61 | return FUSB3_0_BASE_ADDR + FUSB3_XHCI_OFFSET; 62 | else 63 | return FUSB3_1_BASE_ADDR + FUSB3_XHCI_OFFSET; 64 | } -------------------------------------------------------------------------------- /port/xhci/phytium/libxhci_a32_hardfp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/xhci/phytium/libxhci_a32_hardfp.a -------------------------------------------------------------------------------- /port/xhci/phytium/libxhci_a32_softfp_crypto_neon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/xhci/phytium/libxhci_a32_softfp_crypto_neon.a -------------------------------------------------------------------------------- /port/xhci/phytium/libxhci_a32_softfp_neon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/xhci/phytium/libxhci_a32_softfp_neon.a -------------------------------------------------------------------------------- /port/xhci/phytium/libxhci_a64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/port/xhci/phytium/libxhci_a64.a -------------------------------------------------------------------------------- /port/xhci/phytium/rt-thread/usb_glue_phytium.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright : (C) 2024 Phytium Information Technology, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Modify History: 7 | * Ver   Who        Date         Changes 8 | * ----- ------     --------    -------------------------------------- 9 | * 1.0 zhugengyu 2024/6/26 first commit 10 | */ 11 | #include "rtthread.h" 12 | #include "usbh_core.h" 13 | 14 | #include "usb_config.h" 15 | 16 | void usb_hc_setup_xhci_interrupt(uint32_t id); 17 | void usb_hc_revoke_xhci_interrupt(uint32_t id); 18 | 19 | void *xhci_mem_malloc(size_t align, size_t size) 20 | { 21 | void *result = rt_malloc_align(size, align); 22 | 23 | if (result) 24 | { 25 | memset(result, 0U, size); 26 | } 27 | 28 | return result; 29 | } 30 | 31 | void xhci_mem_free(void *ptr) 32 | { 33 | if (NULL != ptr) 34 | { 35 | rt_free(ptr); 36 | } 37 | } 38 | 39 | void xhci_dcache_sync(void *ptr, size_t len, uint32_t flags) 40 | { 41 | if (flags & XHCI_DCACHE_FLUSH) 42 | { 43 | rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, ptr, len); 44 | } 45 | else if (flags & XHCI_DCACHE_INVALIDATE) 46 | { 47 | rt_hw_cpu_dcache_ops(RT_HW_CACHE_INVALIDATE, ptr, len); 48 | } 49 | } 50 | 51 | void usb_assert(const char *filename, int linenum) 52 | { 53 | rt_assert_handler("", filename, linenum); 54 | } 55 | 56 | void usb_hc_low_level_init(struct usbh_bus *bus) 57 | { 58 | /* platform XHCI controller */ 59 | usb_hc_setup_xhci_interrupt(bus->busid); 60 | } 61 | 62 | void usb_hc_low_level_deinit(struct usbh_bus *bus) 63 | { 64 | usb_hc_revoke_xhci_interrupt(bus->busid); 65 | } -------------------------------------------------------------------------------- /port/xhci/phytium/rt-thread/usb_glue_phytium_plat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright : (C) 2024 Phytium Information Technology, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Modify History: 7 | * Ver   Who        Date         Changes 8 | * ----- ------     --------    -------------------------------------- 9 | * 1.0 zhugengyu 2024/6/26 first commit 10 | */ 11 | #include "rtthread.h" 12 | #include "interrupt.h" 13 | 14 | #include "fparameters.h" 15 | 16 | void USBH_IRQHandler(uint8_t busid); 17 | 18 | static void usb_hc_xhci_interrupt_handler(int irqno, void *param) 19 | { 20 | if (irqno == FUSB3_0_IRQ_NUM) { 21 | USBH_IRQHandler(FUSB3_ID_0); 22 | } else if (irqno == FUSB3_1_IRQ_NUM) { 23 | USBH_IRQHandler(FUSB3_ID_1); 24 | } 25 | } 26 | 27 | void usb_hc_setup_xhci_interrupt(uint32_t id) 28 | { 29 | uint32_t irq_num = (id == FUSB3_ID_0) ? FUSB3_0_IRQ_NUM : FUSB3_1_IRQ_NUM; 30 | rt_hw_interrupt_set_priority(irq_num, 0xd0); 31 | rt_hw_interrupt_install(irq_num, usb_hc_xhci_interrupt_handler, 32 | NULL, "xhci"); 33 | rt_hw_interrupt_umask(irq_num); 34 | } 35 | 36 | void usb_hc_revoke_xhci_interrupt(uint32_t id) 37 | { 38 | uint32_t irq_num = (id == FUSB3_ID_0) ? FUSB3_0_IRQ_NUM : FUSB3_1_IRQ_NUM; 39 | 40 | rt_hw_interrupt_mask(irq_num); 41 | } 42 | 43 | unsigned long usb_hc_get_register_base(uint32_t id) 44 | { 45 | if (FUSB3_ID_0 == id) 46 | return FUSB3_0_BASE_ADDR + FUSB3_XHCI_OFFSET; 47 | else 48 | return FUSB3_1_BASE_ADDR + FUSB3_XHCI_OFFSET; 49 | } -------------------------------------------------------------------------------- /third_party/FreeRTOS-10.4/include/StackMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.4.6 3 | * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * SPDX-License-Identifier: MIT 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | * this software and associated documentation files (the "Software"), to deal in 9 | * the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do so, 12 | * subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | * https://www.FreeRTOS.org 25 | * https://github.com/FreeRTOS 26 | * 27 | */ 28 | 29 | 30 | #ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ 31 | #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. 32 | #endif 33 | 34 | #include "stack_macros.h" 35 | -------------------------------------------------------------------------------- /third_party/FreeRTOS-10.4/portable/GCC/ARM_CM7/ReadMe.txt: -------------------------------------------------------------------------------- 1 | There are two options for running FreeRTOS on ARM Cortex-M7 microcontrollers. 2 | The best option depends on the revision of the ARM Cortex-M7 core in use. The 3 | revision is specified by an 'r' number, and a 'p' number, so will look something 4 | like 'r0p1'. Check the documentation for the microcontroller in use to find the 5 | revision of the Cortex-M7 core used in that microcontroller. If in doubt, use 6 | the FreeRTOS port provided specifically for r0p1 revisions, as that can be used 7 | with all core revisions. 8 | 9 | The first option is to use the ARM Cortex-M4F port, and the second option is to 10 | use the Cortex-M7 r0p1 port - the latter containing a minor errata workaround. 11 | 12 | If the revision of the ARM Cortex-M7 core is not r0p1 then either option can be 13 | used, but it is recommended to use the FreeRTOS ARM Cortex-M4F port located in 14 | the /FreeRTOS/Source/portable/GCC/ARM_CM4F directory. 15 | 16 | If the revision of the ARM Cortex-M7 core is r0p1 then use the FreeRTOS ARM 17 | Cortex-M7 r0p1 port located in the /FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1 18 | directory. -------------------------------------------------------------------------------- /third_party/FreeRTOS-10.4/portable/IAR/ARM_CM7/ReadMe.txt: -------------------------------------------------------------------------------- 1 | There are two options for running FreeRTOS on ARM Cortex-M7 microcontrollers. 2 | The best option depends on the revision of the ARM Cortex-M7 core in use. The 3 | revision is specified by an 'r' number, and a 'p' number, so will look something 4 | like 'r0p1'. Check the documentation for the microcontroller in use to find the 5 | revision of the Cortex-M7 core used in that microcontroller. If in doubt, use 6 | the FreeRTOS port provided specifically for r0p1 revisions, as that can be used 7 | with all core revisions. 8 | 9 | The first option is to use the ARM Cortex-M4F port, and the second option is to 10 | use the Cortex-M7 r0p1 port - the latter containing a minor errata workaround. 11 | 12 | If the revision of the ARM Cortex-M7 core is not r0p1 then either option can be 13 | used, but it is recommended to use the FreeRTOS ARM Cortex-M4F port located in 14 | the /FreeRTOS/Source/portable/IAR/ARM_CM4F directory. 15 | 16 | If the revision of the ARM Cortex-M7 core is r0p1 then use the FreeRTOS ARM 17 | Cortex-M7 r0p1 port located in the /FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1 18 | directory. -------------------------------------------------------------------------------- /third_party/FreeRTOS-10.4/portable/RVDS/ARM_CM7/ReadMe.txt: -------------------------------------------------------------------------------- 1 | There are two options for running FreeRTOS on ARM Cortex-M7 microcontrollers. 2 | The best option depends on the revision of the ARM Cortex-M7 core in use. The 3 | revision is specified by an 'r' number, and a 'p' number, so will look something 4 | like 'r0p1'. Check the documentation for the microcontroller in use to find the 5 | revision of the Cortex-M7 core used in that microcontroller. If in doubt, use 6 | the FreeRTOS port provided specifically for r0p1 revisions, as that can be used 7 | with all core revisions. 8 | 9 | The first option is to use the ARM Cortex-M4F port, and the second option is to 10 | use the Cortex-M7 r0p1 port - the latter containing a minor errata workaround. 11 | 12 | If the revision of the ARM Cortex-M7 core is not r0p1 then either option can be 13 | used, but it is recommended to use the FreeRTOS ARM Cortex-M4F port located in 14 | the /FreeRTOS/Source/portable/RVDS/ARM_CM4F directory. 15 | 16 | If the revision of the ARM Cortex-M7 core is r0p1 then use the FreeRTOS ARM 17 | Cortex-M7 r0p1 port located in the /FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1 18 | directory. -------------------------------------------------------------------------------- /third_party/cherrymp/README.md: -------------------------------------------------------------------------------- 1 | # CherryMempool 2 | 3 | CherryMempool is a tiny block memory pool based on CherryRB, support nonos or os(but we suggest you use in os), and only transfer data address not data content. 4 | -------------------------------------------------------------------------------- /third_party/cherrymp/chry_mempool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef CHRY_MEMPOOL_H 7 | #define CHRY_MEMPOOL_H 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "chry_ringbuffer.h" 14 | 15 | typedef void *chry_mempool_osal_sem_t; 16 | 17 | #ifndef CONFIG_CHRY_MEMPOOL_MAX_BLOCK_COUNT 18 | #define CONFIG_CHRY_MEMPOOL_MAX_BLOCK_COUNT 128 19 | #endif 20 | 21 | struct chry_mempool { 22 | chry_ringbuffer_t in; 23 | chry_ringbuffer_t out; 24 | chry_mempool_osal_sem_t out_sem; 25 | 26 | void *block; 27 | uint32_t block_size; 28 | uint32_t block_count; 29 | uint8_t in_buf[sizeof(uintptr_t) * CONFIG_CHRY_MEMPOOL_MAX_BLOCK_COUNT]; 30 | uint8_t out_buf[sizeof(uintptr_t) * CONFIG_CHRY_MEMPOOL_MAX_BLOCK_COUNT]; 31 | }; 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | chry_mempool_osal_sem_t chry_mempool_osal_sem_create(uint32_t max_count); 38 | void chry_mempool_osal_sem_delete(chry_mempool_osal_sem_t sem); 39 | int chry_mempool_osal_sem_take(chry_mempool_osal_sem_t sem, uint32_t timeout); 40 | int chry_mempool_osal_sem_give(chry_mempool_osal_sem_t sem); 41 | 42 | int chry_mempool_create(struct chry_mempool *pool, void *block, uint32_t block_size, uint32_t block_count); 43 | uintptr_t *chry_mempool_alloc(struct chry_mempool *pool); 44 | int chry_mempool_free(struct chry_mempool *pool, uintptr_t *item); 45 | int chry_mempool_send(struct chry_mempool *pool, uintptr_t *item); 46 | int chry_mempool_recv(struct chry_mempool *pool, uintptr_t **item, uint32_t timeout); 47 | void chry_mempool_reset(struct chry_mempool *pool); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif -------------------------------------------------------------------------------- /third_party/cherrymp/chry_mempool_osal_freertos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "chry_mempool.h" 7 | #include 8 | #include "semphr.h" 9 | 10 | chry_mempool_osal_sem_t chry_mempool_osal_sem_create(uint32_t max_count) 11 | { 12 | return (chry_mempool_osal_sem_t)xSemaphoreCreateCounting(max_count, 0); 13 | } 14 | 15 | void chry_mempool_osal_sem_delete(chry_mempool_osal_sem_t sem) 16 | { 17 | vSemaphoreDelete((SemaphoreHandle_t)sem); 18 | } 19 | 20 | int chry_mempool_osal_sem_take(chry_mempool_osal_sem_t sem, uint32_t timeout) 21 | { 22 | BaseType_t xHigherPriorityTaskWoken = pdFALSE; 23 | int ret; 24 | 25 | if (xPortIsInsideInterrupt()) { 26 | ret = xSemaphoreTakeFromISR((SemaphoreHandle_t)sem, &xHigherPriorityTaskWoken); 27 | if (ret == pdPASS) { 28 | portYIELD_FROM_ISR(xHigherPriorityTaskWoken); 29 | } 30 | return (ret == pdPASS) ? 0 : -1; 31 | } else { 32 | return (xSemaphoreTake((SemaphoreHandle_t)sem, pdMS_TO_TICKS(timeout)) == pdPASS) ? 0 : -1; 33 | } 34 | } 35 | 36 | int chry_mempool_osal_sem_give(chry_mempool_osal_sem_t sem) 37 | { 38 | BaseType_t xHigherPriorityTaskWoken = pdFALSE; 39 | int ret; 40 | 41 | if (xPortIsInsideInterrupt()) { 42 | ret = xSemaphoreGiveFromISR((SemaphoreHandle_t)sem, &xHigherPriorityTaskWoken); 43 | if (ret == pdPASS) { 44 | portYIELD_FROM_ISR(xHigherPriorityTaskWoken); 45 | } 46 | } else { 47 | ret = xSemaphoreGive((SemaphoreHandle_t)sem); 48 | } 49 | 50 | return (ret == pdPASS) ? 0 : -1; 51 | } -------------------------------------------------------------------------------- /third_party/cherrymp/chry_mempool_osal_nonos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "chry_mempool.h" 7 | #include "stdlib.h" 8 | 9 | chry_mempool_osal_sem_t chry_mempool_osal_sem_create(uint32_t max_count) 10 | { 11 | return (chry_mempool_osal_sem_t)1; 12 | } 13 | 14 | void chry_mempool_osal_sem_delete(chry_mempool_osal_sem_t sem) 15 | { 16 | } 17 | 18 | int chry_mempool_osal_sem_take(chry_mempool_osal_sem_t sem, uint32_t timeout) 19 | { 20 | return 0; 21 | } 22 | 23 | int chry_mempool_osal_sem_give(chry_mempool_osal_sem_t sem) 24 | { 25 | return 0; 26 | } 27 | 28 | void *chry_mempool_osal_malloc(size_t size) 29 | { 30 | return malloc(size); 31 | } 32 | 33 | void chry_mempool_osal_free(void *ptr) 34 | { 35 | free(ptr); 36 | } -------------------------------------------------------------------------------- /third_party/cherrymp/chry_mempool_osal_rtthread.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, sakumisu 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "chry_mempool.h" 7 | #include 8 | #include 9 | 10 | chry_mempool_osal_sem_t chry_mempool_osal_sem_create(uint32_t max_count) 11 | { 12 | return (chry_mempool_osal_sem_t)rt_sem_create("chry_mempoolh_sem", max_count, RT_IPC_FLAG_FIFO); 13 | } 14 | 15 | void chry_mempool_osal_sem_delete(chry_mempool_osal_sem_t sem) 16 | { 17 | rt_sem_delete((rt_sem_t)sem); 18 | } 19 | 20 | int chry_mempool_osal_sem_take(chry_mempool_osal_sem_t sem, uint32_t timeout) 21 | { 22 | int ret = 0; 23 | rt_err_t result = RT_EOK; 24 | 25 | if (timeout == 0xfffffff) { 26 | result = rt_sem_take((rt_sem_t)sem, RT_WAITING_FOREVER); 27 | } else { 28 | result = rt_sem_take((rt_sem_t)sem, rt_tick_from_millisecond(timeout)); 29 | } 30 | if (result == -RT_ETIMEOUT) { 31 | ret = -1; 32 | } else if (result == -RT_ERROR) { 33 | ret = -1; 34 | } else { 35 | ret = 0; 36 | } 37 | 38 | return (int)ret; 39 | } 40 | 41 | int chry_mempool_osal_sem_give(chry_mempool_osal_sem_t sem) 42 | { 43 | return (int)rt_sem_release((rt_sem_t)sem); 44 | } 45 | 46 | void *chry_mempool_osal_malloc(size_t size) 47 | { 48 | return rt_malloc(size); 49 | } 50 | 51 | void chry_mempool_osal_free(void *ptr) 52 | { 53 | rt_free(ptr); 54 | } -------------------------------------------------------------------------------- /third_party/cherryrb/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [1.0.0] - 2023-06-28: 4 | 5 | All changes 6 | 7 | ### Added 8 | - first commit 9 | - add linear r/w setup done api, for dma use -------------------------------------------------------------------------------- /third_party/cherryrb/chry_ringbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Egahp 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef CHRY_RINGBUFFER_H 8 | #define CHRY_RINGBUFFER_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | typedef struct { 18 | uint32_t in; /*!< Define the write pointer. */ 19 | uint32_t out; /*!< Define the read pointer. */ 20 | uint32_t mask; /*!< Define the write and read pointer mask. */ 21 | void *pool; /*!< Define the memory pointer. */ 22 | } chry_ringbuffer_t; 23 | 24 | extern int chry_ringbuffer_init(chry_ringbuffer_t *rb, void *pool, uint32_t size); 25 | extern void chry_ringbuffer_reset(chry_ringbuffer_t *rb); 26 | extern void chry_ringbuffer_reset_read(chry_ringbuffer_t *rb); 27 | 28 | extern uint32_t chry_ringbuffer_get_size(chry_ringbuffer_t *rb); 29 | extern uint32_t chry_ringbuffer_get_used(chry_ringbuffer_t *rb); 30 | extern uint32_t chry_ringbuffer_get_free(chry_ringbuffer_t *rb); 31 | 32 | extern bool chry_ringbuffer_check_full(chry_ringbuffer_t *rb); 33 | extern bool chry_ringbuffer_check_empty(chry_ringbuffer_t *rb); 34 | 35 | extern bool chry_ringbuffer_write_byte(chry_ringbuffer_t *rb, uint8_t byte); 36 | extern bool chry_ringbuffer_overwrite_byte(chry_ringbuffer_t *rb, uint8_t byte); 37 | extern bool chry_ringbuffer_peek_byte(chry_ringbuffer_t *rb, uint8_t *byte); 38 | extern bool chry_ringbuffer_read_byte(chry_ringbuffer_t *rb, uint8_t *byte); 39 | extern bool chry_ringbuffer_drop_byte(chry_ringbuffer_t *rb); 40 | 41 | extern uint32_t chry_ringbuffer_write(chry_ringbuffer_t *rb, void *data, uint32_t size); 42 | extern uint32_t chry_ringbuffer_overwrite(chry_ringbuffer_t *rb, void *data, uint32_t size); 43 | extern uint32_t chry_ringbuffer_peek(chry_ringbuffer_t *rb, void *data, uint32_t size); 44 | extern uint32_t chry_ringbuffer_read(chry_ringbuffer_t *rb, void *data, uint32_t size); 45 | extern uint32_t chry_ringbuffer_drop(chry_ringbuffer_t *rb, uint32_t size); 46 | 47 | extern void *chry_ringbuffer_linear_write_setup(chry_ringbuffer_t *rb, uint32_t *size); 48 | extern void *chry_ringbuffer_linear_read_setup(chry_ringbuffer_t *rb, uint32_t *size); 49 | extern uint32_t chry_ringbuffer_linear_write_done(chry_ringbuffer_t *rb, uint32_t size); 50 | extern uint32_t chry_ringbuffer_linear_read_done(chry_ringbuffer_t *rb, uint32_t size); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /third_party/dhcp-server/dhserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 by Sergey Fetisov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | /* 26 | * version: 1.0 demo (7.02.2015) 27 | * brief: tiny dhcp ipv4 server using lwip (pcb) 28 | * ref: https://lists.gnu.org/archive/html/lwip-users/2012-12/msg00016.html 29 | */ 30 | 31 | #ifndef DHSERVER_H 32 | #define DHSERVER_H 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include "lwip/err.h" 39 | #include "lwip/udp.h" 40 | #include "netif/etharp.h" 41 | 42 | typedef struct dhcp_entry { 43 | uint8_t mac[6]; 44 | uint8_t addr[4]; 45 | uint8_t subnet[4]; 46 | uint32_t lease; 47 | } dhcp_entry_t; 48 | 49 | typedef struct dhcp_config { 50 | uint8_t addr[4]; 51 | uint16_t port; 52 | uint8_t dns[4]; 53 | const char *domain; 54 | int num_entry; 55 | dhcp_entry_t *entries; 56 | } dhcp_config_t; 57 | 58 | err_t dhserv_init(dhcp_config_t *config); 59 | void dhserv_free(void); 60 | 61 | #endif /* DHSERVER_H */ 62 | -------------------------------------------------------------------------------- /third_party/dns-server/dnserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 by Sergey Fetisov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | /* 26 | * version: 1.0 demo (7.02.2015) 27 | * brief: tiny dns ipv4 server using lwip (pcb) 28 | */ 29 | 30 | #ifndef DNSERVER 31 | #define DNSERVER 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include "lwip/def.h" 38 | #include "lwip/err.h" 39 | #include "lwip/udp.h" 40 | #include "netif/etharp.h" 41 | 42 | typedef bool (*dns_query_proc_t)(const char *name, ip_addr_t *addr); 43 | 44 | err_t dnserv_init(const ip_addr_t *bind, uint16_t port, dns_query_proc_t query_proc); 45 | void dnserv_free(void); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /third_party/fatfs-0.14/LICENSE.txt: -------------------------------------------------------------------------------- 1 | FatFs License 2 | 3 | FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that heading the source files. 4 | 5 | /*----------------------------------------------------------------------------/ 6 | / FatFs - Generic FAT Filesystem Module Rx.xx / 7 | /-----------------------------------------------------------------------------/ 8 | / 9 | / Copyright (C) 20xx, ChaN, all right reserved. 10 | / 11 | / FatFs module is an open source software. Redistribution and use of FatFs in 12 | / source and binary forms, with or without modification, are permitted provided 13 | / that the following condition is met: 14 | / 15 | / 1. Redistributions of source code must retain the above copyright notice, 16 | / this condition and the following disclaimer. 17 | / 18 | / This software is provided by the copyright holder and contributors "AS IS" 19 | / and any warranties related to this software are DISCLAIMED. 20 | / The copyright owner or contributors be NOT LIABLE for any damages caused 21 | / by use of this software. 22 | /----------------------------------------------------------------------------*/ 23 | 24 | Therefore FatFs license is one of the BSD-style licenses, but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, do not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses include GNU GPL. When you redistribute the FatFs source code with changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that not conflict with FatFs license. 25 | -------------------------------------------------------------------------------- /third_party/fatfs-0.14/source/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.14b 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | 00history.txt Revision history. 8 | ff.c FatFs module. 9 | ffconf.h Configuration file of FatFs module. 10 | ff.h Common include file for FatFs and application module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | ffunicode.c Optional Unicode utility functions. 14 | ffsystem.c An example of optional O/S related functions. 15 | 16 | 17 | Low level disk I/O module is not included in this archive because the FatFs 18 | module is only a generic file system layer and it does not depend on any specific 19 | storage device. You need to provide a low level disk I/O module written to 20 | control the storage device that attached to the target system. 21 | 22 | -------------------------------------------------------------------------------- /third_party/fatfs-0.14/source/port/fatfs_usbd.c: -------------------------------------------------------------------------------- 1 | #include "diskio.h" 2 | #include "string.h" 3 | #include "hal_flash.h" 4 | 5 | #define FLASH_START_ADDR 0x00040000 /*addr start from 256k */ 6 | #define FLASH_BLOCK_SIZE 4096 7 | #define FLASH_BLOCK_COUNT 64 8 | 9 | extern const char *FR_Table[]; 10 | 11 | int USB_disk_status(void) 12 | { 13 | return 0; 14 | } 15 | int USB_disk_initialize(void) 16 | { 17 | return RES_OK; 18 | } 19 | int USB_disk_read(BYTE *buff, LBA_t sector, UINT count) 20 | { 21 | flash_read(FLASH_START_ADDR + sector * FLASH_BLOCK_SIZE, (uint8_t *)buff, count * FLASH_BLOCK_SIZE); 22 | return 0; 23 | } 24 | int USB_disk_write(const BYTE *buff, LBA_t sector, UINT count) 25 | { 26 | flash_erase(FLASH_START_ADDR + sector * FLASH_BLOCK_SIZE, 4096); 27 | flash_write(FLASH_START_ADDR + sector * FLASH_BLOCK_SIZE, (uint8_t *)buff, count * FLASH_BLOCK_SIZE); 28 | return 0; 29 | } 30 | int USB_disk_ioctl(BYTE cmd, void *buff) 31 | { 32 | int result = 0; 33 | 34 | switch (cmd) { 35 | case CTRL_SYNC: 36 | result = RES_OK; 37 | break; 38 | 39 | case GET_SECTOR_SIZE: 40 | *(WORD *)buff = FLASH_BLOCK_SIZE; 41 | result = RES_OK; 42 | break; 43 | 44 | case GET_BLOCK_SIZE: 45 | *(DWORD *)buff = 1; 46 | result = RES_OK; 47 | break; 48 | 49 | case GET_SECTOR_COUNT: 50 | *(DWORD *)buff = FLASH_BLOCK_COUNT; 51 | result = RES_OK; 52 | break; 53 | 54 | default: 55 | result = RES_PARERR; 56 | break; 57 | } 58 | 59 | return result; 60 | } -------------------------------------------------------------------------------- /third_party/lwip-2.1.2/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cherry-embedded/CherryUSB/8cb16bc11d2d264cb614b899cf552eea49e94244/third_party/lwip-2.1.2/.gitkeep -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/nimble/.gitkeep: -------------------------------------------------------------------------------- 1 | https://github.com/sakumisu/mynewt-nimble -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/include/nimble/nimble_port.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _NIMBLE_PORT_H 21 | #define _NIMBLE_PORT_H 22 | 23 | #include "nimble/nimble_npl.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | void nimble_port_init(void); 30 | 31 | void nimble_port_run(void); 32 | 33 | struct ble_npl_eventq *nimble_port_get_dflt_eventq(void); 34 | 35 | #if NIMBLE_CFG_CONTROLLER 36 | void nimble_port_ll_task_func(void *arg); 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* _NIMBLE_PORT_H */ 44 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/include/os/os.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _OS_H 21 | #define _OS_H 22 | 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include "syscfg/syscfg.h" 30 | #include "nimble/nimble_npl.h" 31 | 32 | #define OS_ALIGN(__n, __a) ( \ 33 | (((__n) & ((__a) - 1)) == 0) ? \ 34 | (__n) : \ 35 | ((__n) + ((__a) - ((__n) & ((__a) - 1)))) \ 36 | ) 37 | #define OS_ALIGNMENT (BLE_NPL_OS_ALIGNMENT) 38 | 39 | typedef uint32_t os_sr_t; 40 | #define OS_ENTER_CRITICAL(_sr) (_sr = ble_npl_hw_enter_critical()) 41 | #define OS_EXIT_CRITICAL(_sr) (ble_npl_hw_exit_critical(_sr)) 42 | #define OS_ASSERT_CRITICAL() assert(ble_npl_hw_is_in_critical()) 43 | 44 | /* Mynewt components (not abstracted in NPL) */ 45 | #include "os/endian.h" 46 | #include "os/queue.h" 47 | #include "os/os_error.h" 48 | #include "os/os_mbuf.h" 49 | #include "os/os_mempool.h" 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _OS_H */ 56 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/include/os/os_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef H_OS_ERROR_ 21 | #define H_OS_ERROR_ 22 | 23 | #include "os/os.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* OS error enumerations */ 30 | enum os_error { 31 | OS_OK = 0, 32 | OS_ENOMEM = 1, 33 | OS_EINVAL = 2, 34 | OS_INVALID_PARM = 3, 35 | OS_MEM_NOT_ALIGNED = 4, 36 | OS_BAD_MUTEX = 5, 37 | OS_TIMEOUT = 6, 38 | OS_ERR_IN_ISR = 7, /* Function cannot be called from ISR */ 39 | OS_ERR_PRIV = 8, /* Privileged access error */ 40 | OS_NOT_STARTED = 9, /* OS must be started to call this function, but isn't */ 41 | OS_ENOENT = 10, /* No such thing */ 42 | OS_EBUSY = 11, /* Resource busy */ 43 | OS_ERROR = 12, /* Generic Error */ 44 | }; 45 | 46 | typedef enum os_error os_error_t; 47 | 48 | /** 49 | * @brief Converts an OS error code (`OS_[...]`) to an equivalent system error 50 | * code (`SYS_E[...]`). 51 | * 52 | * @param os_error The OS error code to convert. 53 | * 54 | * @return The equivalent system error code. 55 | */ 56 | int os_error_to_sys(os_error_t os_error); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/include/os/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef H_OS_UTIL_ 21 | #define H_OS_UTIL_ 22 | 23 | /* Helpers to pass integers as pointers and vice-versa */ 24 | #define POINTER_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) 25 | #define UINT_TO_POINTER(u) ((void *) ((uintptr_t) (u))) 26 | #define POINTER_TO_INT(p) ((int) ((intptr_t) (p))) 27 | #define INT_TO_POINTER(u) ((void *) ((intptr_t) (u))) 28 | 29 | /* Helper to retrieve pointer to "parent" object in structure */ 30 | #define CONTAINER_OF(ptr, type, field) \ 31 | ((type *)(((char *)(ptr)) - offsetof(type, field))) 32 | 33 | /* Helper to calculate number of elements in array */ 34 | #ifndef ARRAY_SIZE 35 | #define ARRAY_SIZE(array) \ 36 | (sizeof(array) / sizeof((array)[0])) 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/include/stats/stats.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef __STATS_H__ 21 | #define __STATS_H__ 22 | 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define STATS_SECT_DECL(__name) struct stats_ ## __name 30 | #define STATS_SECT_END }; 31 | 32 | #define STATS_SECT_START(__name) STATS_SECT_DECL(__name) { 33 | #define STATS_SECT_VAR(__var) 34 | 35 | #define STATS_HDR(__sectname) NULL 36 | 37 | #define STATS_SECT_ENTRY(__var) 38 | #define STATS_SECT_ENTRY16(__var) 39 | #define STATS_SECT_ENTRY32(__var) 40 | #define STATS_SECT_ENTRY64(__var) 41 | #define STATS_RESET(__var) 42 | 43 | #define STATS_SIZE_INIT_PARMS(__sectvarname, __size) \ 44 | 0, 0 45 | 46 | #define STATS_INC(__sectvarname, __var) 47 | #define STATS_INCN(__sectvarname, __var, __n) 48 | #define STATS_CLEAR(__sectvarname, __var) 49 | 50 | #define STATS_NAME_START(__name) 51 | #define STATS_NAME(__name, __entry) 52 | #define STATS_NAME_END(__name) 53 | #define STATS_NAME_INIT_PARMS(__name) NULL, 0 54 | 55 | static inline int 56 | stats_init(void *a, uint8_t b, uint8_t c, void *d, uint8_t e) 57 | { 58 | /* dummy */ 59 | return 0; 60 | } 61 | 62 | static inline int 63 | stats_register(void *a, void *b) 64 | { 65 | /* dummy */ 66 | return 0; 67 | } 68 | 69 | static inline int 70 | stats_init_and_reg(void *a, uint8_t b, uint8_t c, void *d, uint8_t e, void *f) 71 | { 72 | /* dummy */ 73 | return 0; 74 | } 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* __STATS_H__ */ 81 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/include/sysflash/sysflash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was generated by Apache newt version: 1.12.0-dev 3 | */ 4 | 5 | #ifndef H_MYNEWT_SYSFLASH_ 6 | #define H_MYNEWT_SYSFLASH_ 7 | 8 | #include "flash_map/flash_map.h" 9 | 10 | #define FLASH_AREA_COUNT 6 11 | 12 | /** 13 | * This flash map definition is used for two purposes: 14 | * 1. To locate the meta area, which contains the true flash map definition. 15 | * 2. As a fallback in case the meta area cannot be read from flash. 16 | */ 17 | extern const struct flash_area sysflash_map_dflt[FLASH_AREA_COUNT]; 18 | 19 | /* Flash map was defined in @apache-mynewt-core/hw/bsp/native */ 20 | 21 | #define FLASH_AREA_BOOTLOADER 0 22 | #define FLASH_AREA_BOOTLOADER_DEVICE 0 23 | #define FLASH_AREA_BOOTLOADER_OFFSET 0x00000000 24 | #define FLASH_AREA_BOOTLOADER_SIZE 16384 25 | 26 | #define FLASH_AREA_IMAGE_0 1 27 | #define FLASH_AREA_IMAGE_0_DEVICE 0 28 | #define FLASH_AREA_IMAGE_0_OFFSET 0x00020000 29 | #define FLASH_AREA_IMAGE_0_SIZE 393216 30 | 31 | #define FLASH_AREA_IMAGE_1 2 32 | #define FLASH_AREA_IMAGE_1_DEVICE 0 33 | #define FLASH_AREA_IMAGE_1_OFFSET 0x00080000 34 | #define FLASH_AREA_IMAGE_1_SIZE 393216 35 | 36 | #define FLASH_AREA_IMAGE_SCRATCH 3 37 | #define FLASH_AREA_IMAGE_SCRATCH_DEVICE 0 38 | #define FLASH_AREA_IMAGE_SCRATCH_OFFSET 0x000e0000 39 | #define FLASH_AREA_IMAGE_SCRATCH_SIZE 131072 40 | 41 | #define FLASH_AREA_REBOOT_LOG 16 42 | #define FLASH_AREA_REBOOT_LOG_DEVICE 0 43 | #define FLASH_AREA_REBOOT_LOG_OFFSET 0x00004000 44 | #define FLASH_AREA_REBOOT_LOG_SIZE 16384 45 | 46 | #define FLASH_AREA_NFFS 17 47 | #define FLASH_AREA_NFFS_DEVICE 0 48 | #define FLASH_AREA_NFFS_OFFSET 0x00008000 49 | #define FLASH_AREA_NFFS_SIZE 32768 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/include/sysinit/sysinit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef __SYSINIT_H__ 21 | #define __SYSINIT_H__ 22 | 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define SYSINIT_ASSERT_ACTIVE() 30 | 31 | #define SYSINIT_PANIC_ASSERT(rc) assert(rc) 32 | #define SYSINIT_PANIC_ASSERT_MSG(rc, msg) assert(rc) 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* __SYSINIT_H__ */ 39 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/nimble/src/nimble_port.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | #include "os/os.h" 22 | #include "sysinit/sysinit.h" 23 | #include "host/ble_hs.h" 24 | #include "nimble/nimble_port.h" 25 | #include "nimble/transport.h" 26 | #if NIMBLE_CFG_CONTROLLER 27 | #include "controller/ble_ll.h" 28 | #endif 29 | 30 | static struct ble_npl_eventq g_eventq_dflt; 31 | 32 | extern void os_msys_init(void); 33 | extern void os_mempool_module_init(void); 34 | 35 | void 36 | nimble_port_init(void) 37 | { 38 | /* Initialize default event queue */ 39 | ble_npl_eventq_init(&g_eventq_dflt); 40 | /* Initialize the global memory pool */ 41 | os_mempool_module_init(); 42 | os_msys_init(); 43 | /* Initialize transport */ 44 | ble_transport_init(); 45 | /* Initialize the host */ 46 | ble_transport_hs_init(); 47 | 48 | #if NIMBLE_CFG_CONTROLLER 49 | #ifndef RIOT_VERSION 50 | hal_timer_init(5, NULL); 51 | os_cputime_init(32768); 52 | #endif 53 | #endif 54 | 55 | /* Initialize the controller */ 56 | ble_transport_ll_init(); 57 | } 58 | 59 | void 60 | nimble_port_run(void) 61 | { 62 | struct ble_npl_event *ev; 63 | 64 | while (1) { 65 | ev = ble_npl_eventq_get(&g_eventq_dflt, BLE_NPL_TIME_FOREVER); 66 | ble_npl_event_run(ev); 67 | } 68 | } 69 | 70 | struct ble_npl_eventq * 71 | nimble_port_get_dflt_eventq(void) 72 | { 73 | return &g_eventq_dflt; 74 | } 75 | 76 | #if NIMBLE_CFG_CONTROLLER 77 | void 78 | nimble_port_ll_task_func(void *arg) 79 | { 80 | extern void ble_ll_task(void *); 81 | 82 | ble_ll_task(arg); 83 | } 84 | #endif 85 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/npl/freertos/include/console/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef _CONSOLE_H 8 | #define _CONSOLE_H 9 | 10 | #include 11 | 12 | #define console_printf printf 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/npl/freertos/include/nimble/nimble_npl_os_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _NIMBLE_NPL_OS_LOG_H_ 21 | #define _NIMBLE_NPL_OS_LOG_H_ 22 | 23 | #include 24 | 25 | #define BLE_HS_LOG_DEBUG(...) printf(__VA_ARGS__) 26 | #define BLE_HS_LOG_INFO(...) printf(__VA_ARGS__) 27 | #define BLE_HS_LOG_WARN(...) printf(__VA_ARGS__) 28 | #define BLE_HS_LOG_ERROR(...) printf(__VA_ARGS__) 29 | #define BLE_HS_LOG_CRITICAL(...) printf(__VA_ARGS__) 30 | #define BLE_HS_LOG_DISABLED(...) printf(__VA_ARGS__) 31 | 32 | #define BLE_EATT_LOG_DEBUG(...) printf(__VA_ARGS__) 33 | #define BLE_EATT_LOG_ERROR(...) printf(__VA_ARGS__) 34 | 35 | #endif /* _NIMBLE_NPL_OS_LOG_H_ */ 36 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/npl/freertos/include/nimble/nimble_port_freertos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _NIMBLE_PORT_FREERTOS_H 21 | #define _NIMBLE_PORT_FREERTOS_H 22 | 23 | #include "nimble/nimble_npl.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | void nimble_port_freertos_init(TaskFunction_t host_task_fn); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* _NIMBLE_PORT_FREERTOS_H */ 36 | -------------------------------------------------------------------------------- /third_party/nimble-1.6.0/porting/npl/freertos/src/nimble_port_freertos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | #include "FreeRTOS.h" 22 | #include "task.h" 23 | #include "nimble/nimble_port.h" 24 | 25 | #if NIMBLE_CFG_CONTROLLER 26 | static TaskHandle_t ll_task_h; 27 | #endif 28 | static TaskHandle_t host_task_h; 29 | 30 | void 31 | nimble_port_freertos_init(TaskFunction_t host_task_fn) 32 | { 33 | #if NIMBLE_CFG_CONTROLLER 34 | /* 35 | * Create task where NimBLE LL will run. This one is required as LL has its 36 | * own event queue and should have highest priority. The task function is 37 | * provided by NimBLE and in case of FreeRTOS it does not need to be wrapped 38 | * since it has compatible prototype. 39 | */ 40 | xTaskCreate(nimble_port_ll_task_func, "ll", configMINIMAL_STACK_SIZE + 400, 41 | NULL, configMAX_PRIORITIES - 1, &ll_task_h); 42 | #endif 43 | 44 | /* 45 | * Create task where NimBLE host will run. It is not strictly necessary to 46 | * have separate task for NimBLE host, but since something needs to handle 47 | * default queue it is just easier to make separate task which does this. 48 | */ 49 | xTaskCreate(host_task_fn, "ble", configMINIMAL_STACK_SIZE + 400, 50 | NULL, tskIDLE_PRIORITY + 1, &host_task_h); 51 | } 52 | -------------------------------------------------------------------------------- /tools/audacity/url: -------------------------------------------------------------------------------- 1 | https://audacity.onl/ -------------------------------------------------------------------------------- /tools/chryusb_configurator/url: -------------------------------------------------------------------------------- 1 | https://github.com/Egahp/chryusb_configurator/releases/tag/1.0.0 -------------------------------------------------------------------------------- /tools/packet capture/url: -------------------------------------------------------------------------------- 1 | QQ群内获取 2 | 3 | Get it after joining the qq chat -------------------------------------------------------------------------------- /tools/stm32_dfuse/url: -------------------------------------------------------------------------------- 1 | http://www.st.com/en/development-tools/stsw-stm32080.html -------------------------------------------------------------------------------- /tools/test_srcipts/test_cdc_speed.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import time 3 | try: 4 | from serial.tools.list_ports import comports 5 | except ImportError: 6 | raise serial.serialutil.SerialException 7 | 8 | 9 | test_comx = 'COM66' 10 | test_baudrate = 2000000 11 | test_maxsize = 10*1024*1024 12 | 13 | test_data = '0xAA' * 4096 14 | 15 | test_serial = serial.Serial(test_comx, test_baudrate, timeout = 1) 16 | 17 | def test_cdc_out(): 18 | send_count = 0 19 | begin = time.time() 20 | 21 | while True: 22 | if send_count < test_maxsize: 23 | txdatalen = test_serial.write(test_data.encode("utf-8")) 24 | send_count += txdatalen 25 | else: 26 | print("cdc out speed %f MB/s" %(send_count//1024//1024/(time.time() - begin))) 27 | break 28 | 29 | def test_cdc_in(): 30 | read_count = 0 31 | begin = time.time() 32 | 33 | while True: 34 | if read_count < test_maxsize: 35 | data = test_serial.read(test_maxsize).decode(encoding='utf-8',errors='ignore') 36 | read_count += len(data) 37 | else: 38 | print("cdc in speed %f MB/s" %(read_count//1024//1024/(time.time() - begin))) 39 | break 40 | 41 | if __name__ == '__main__': 42 | print('test cdc out speed') 43 | 44 | test_serial.setDTR(0) 45 | test_cdc_out() 46 | 47 | print('test cdc in speed') 48 | test_serial.setDTR(1) 49 | test_cdc_in() -------------------------------------------------------------------------------- /tools/test_srcipts/test_hid_inout.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 HPMicro 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | import pywinusb.hid as hid 5 | import os 6 | import time 7 | import sys 8 | import operator 9 | 10 | # VID and PID customization changes here... 11 | 12 | VID = 0xFFFF 13 | PID = 0xFFFF 14 | 15 | # Send buffer 16 | buffer = [0xff]*64 17 | 18 | # Const 19 | TIMEOUT = -1 20 | PASS = 0 21 | FAIL = 1 22 | 23 | # Result 24 | result = TIMEOUT 25 | 26 | def search_dev(): 27 | filter = hid.HidDeviceFilter(vendor_id = VID, product_id = PID) 28 | hid_device = filter.get_devices() 29 | return hid_device 30 | 31 | def recv_data(data): 32 | print("<=================== USB HID Read ========================>") 33 | for i in range(0, len(data)): 34 | print("0x{0:02x}" .format(data[i]), end=" ") 35 | print("\n") 36 | 37 | global result 38 | result = (PASS if (operator.eq(data[1:-1], buffer[1:-1]) == True) else FAIL) 39 | 40 | return None 41 | 42 | def send_data(report): 43 | print("<=================== USB HID Write ========================>") 44 | buffer[0] = report[0].report_id 45 | print("0x{0:02x}" .format(buffer[0]), end=" ") 46 | 47 | for i in range(1,64): 48 | buffer[i] = i % 256 49 | print("0x{0:02x}" .format(buffer[i]), end=" ") 50 | print("\n") 51 | 52 | report[0].set_raw_data(buffer) 53 | report[0].send() 54 | return None 55 | 56 | if __name__ == '__main__': 57 | device = search_dev()[0] 58 | device.open() 59 | device.set_raw_data_handler(recv_data) 60 | send_data(device.find_output_reports()) 61 | time.sleep(1) 62 | 63 | if result == PASS: 64 | print("USB hid echo passed!") 65 | elif result == FAIL: 66 | print("USB HID echo failed!") 67 | else: 68 | print("USB HID echo timed out!") -------------------------------------------------------------------------------- /zephyr/module.yml: -------------------------------------------------------------------------------- 1 | name: CherryUSB 2 | build: 3 | cmake: . 4 | kconfig: Kconfig -------------------------------------------------------------------------------- /zephyr/usbh_class_info.ld: -------------------------------------------------------------------------------- 1 | SECTION_DATA_PROLOGUE(usbh_class_info,,) 2 | { 3 | . = ALIGN(4); 4 | __usbh_class_info_start__ = .; 5 | KEEP(*(.usbh_class_info)) 6 | __usbh_class_info_end__ = .; 7 | } GROUP_LINK_IN(ROMABLE_REGION) --------------------------------------------------------------------------------