diff options
| author | Egahp <[email protected]> | 2025-08-30 19:24:02 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-30 19:24:02 +0800 |
| commit | 5d5b61a606b1d2ba5512ef3c71fb11975eed5e40 (patch) | |
| tree | 8f593c4a65226036b17b75d9d35c94718b5e431e /docs/source | |
| parent | 257b1d4d20d2ddc77de33dad041088ba7500400d (diff) | |
feat: host add event callback mechanism similar to device
* fix: fix warning for speed_table
* fix(port/dwc2/usb_hc_dwc2): add roothub.speed init
* feat(usbh_core): add event_callback
* fix(usbh_hub): fix event device reset port
* fix(usbh_hub): remove event init when init failed
* feat(usbh_core): add default dummy_event_callback
* fix(usbh_hub): emit reset event only on successful reset
* fix(usbh_core): emit interface start only on successful connect class driver
* feat(usbh_core): change event_callback to typedef
* feat(port): update port usbh init params
* doc: update usbh_initialize desc
* fix(usbh_core): check result from ret == 0 change to ret >= 0
---------
Signed-off-by: egahp <[email protected]>
Diffstat (limited to 'docs/source')
| -rw-r--r-- | docs/source/api/api_host.rst | 3 | ||||
| -rw-r--r-- | docs/source/quick_start/demo.rst | 2 | ||||
| -rw-r--r-- | docs/source/quick_start/rtthread.rst | 2 | ||||
| -rw-r--r-- | docs/source/quick_start/transplant.rst | 4 |
4 files changed, 6 insertions, 5 deletions
diff --git a/docs/source/api/api_host.rst b/docs/source/api/api_host.rst index 3368f47f..28287a0b 100644 --- a/docs/source/api/api_host.rst +++ b/docs/source/api/api_host.rst @@ -126,10 +126,11 @@ usbh_initialize .. code-block:: C - int usbh_initialize(uint8_t busid, uint32_t reg_base); + int usbh_initialize(uint8_t busid, uint32_t reg_base, usbh_event_handler_t event_handler); - **busid** bus id,从 0开始,不能超过 `CONFIG_USBHOST_MAX_BUS` - **reg_base** hcd 寄存器基地址 +- **event_handler** host 事件回调函数,可以为NULL - **return** 0 表示正常其他表示错误 usbh_find_class_instance diff --git a/docs/source/quick_start/demo.rst b/docs/source/quick_start/demo.rst index 9c5e6569..ebb211a9 100644 --- a/docs/source/quick_start/demo.rst +++ b/docs/source/quick_start/demo.rst @@ -203,7 +203,7 @@ USB Host 移植要点 - 链接脚本修改参考 :ref:`usbh_link_script` 章节 - 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节 -- 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` +- 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base` 还有 `event_handler` 可缺省为NULL, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` - 启动线程 .. figure:: img/stm32_18.png diff --git a/docs/source/quick_start/rtthread.rst b/docs/source/quick_start/rtthread.rst index e9c4df5b..132015d9 100644 --- a/docs/source/quick_start/rtthread.rst +++ b/docs/source/quick_start/rtthread.rst @@ -56,7 +56,7 @@ * USB IP 相关的 config 需要用户自己根据芯片实际情况修改 * 在代码中实现 `usb_hc_low_level_init` 函数 * 在 USB 中断函数中调用 `USBH_IRQHandler`,并传入 `busid` -* 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` +* 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base` 还有 `event_handler` 可缺省为NULL, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` * 使用 `scons --target=mdk5` 或者 `scons` 进行编译,如果是mdk,需要使用 AC6 编译器 * 链接脚本修改参考 :ref:`usbh_link_script` 章节 * 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节 diff --git a/docs/source/quick_start/transplant.rst b/docs/source/quick_start/transplant.rst index a6dcf14e..710497d4 100644 --- a/docs/source/quick_start/transplant.rst +++ b/docs/source/quick_start/transplant.rst @@ -19,11 +19,11 @@ USB Host 移植要点 - 拷贝 CherryUSB 源码到工程目录下,并按需添加源文件和头文件路径,头文件路径建议全部添加。其中 `usbh_core.c` 、 `usb_hc_xxx.c` 以及 **osal** 目录下源文件(根据不同的 os 选择对应的源文件)为必须添加项。而 `usb_hc_xxx.c` 是芯片所对应的 USB IP hcd 部分驱动,如果不知道自己芯片属于那个 USB IP,参考 **port** 目录下的不同 USB IP 的 readme。如果使用的 USB IP 没有支持,只能自己实现了 - 拷贝 `cherryusb_config_template.h` 文件到自己工程目录下,命名为 `usb_config.h`,并添加相应的目录头文件路径 - 实现 `usb_hc_low_level_init` 函数(该函数主要负责 USB 时钟、引脚、中断的初始化)。该函数可以放在你想要放的任何参与编译的 c 文件中。如何进行 USB 的时钟、引脚、中断等初始化,请自行根据你使用的芯片原厂提供的源码中进行添加。 -- 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` +- 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base` 还有 `event_handler` 可缺省为NULL, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` - 在中断函数中调用 `USBH_IRQHandler`,并传入 `busid`, 如果你的 SDK 中中断入口已经存在 `USBH_IRQHandler` ,请更改 USB 协议栈中的名称 - 链接脚本修改参考 :ref:`usbh_link_script` 章节 - 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节 -- 调用 `usbh_initialize` ,填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` 。基础的 cdc + hid + msc 参考 `usb_host.c` 文件,其余参考 **platform** 目录下适配 +- 调用 `usbh_initialize` ,填入 `busid` 和 USB IP 的 `reg base` 还有 `event_handler` 可缺省为NULL, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS` 。基础的 cdc + hid + msc 参考 `usb_host.c` 文件,其余参考 **platform** 目录下适配 .. _usbh_link_script: |
