diff options
| author | sakumisu <[email protected]> | 2024-01-06 22:16:58 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2024-01-08 22:47:28 +0800 |
| commit | 1158fc3d8c1a71ae89cb9dbd7504712114352af2 (patch) | |
| tree | 7055e86bbb804672e94905b8fe3eddd02e7e6824 /docs/source/quick_start/rt-thread | |
| parent | d517f2594e079295c984b008a36baf2fcf51da58 (diff) | |
support multi USB IP for host
Diffstat (limited to 'docs/source/quick_start/rt-thread')
| -rw-r--r-- | docs/source/quick_start/rt-thread/rtthread.rst | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/docs/source/quick_start/rt-thread/rtthread.rst b/docs/source/quick_start/rt-thread/rtthread.rst index 4cfb965b..28a4631f 100644 --- a/docs/source/quick_start/rt-thread/rtthread.rst +++ b/docs/source/quick_start/rt-thread/rtthread.rst @@ -35,7 +35,7 @@ .. figure:: img/config_file.png -* 使用 `scons --target=mdk` 或者 `scons` 进行编译 +* 使用 `scons --target=mdk5` 或者 `scons` 进行编译 主机配置 -------------------------- @@ -48,15 +48,36 @@ .. figure:: img/env8.png -* 默认使能除了 hub 之外的所有 class 驱动。 -* 设置 psc 线程的线程栈以及线程优先级。 +* 根据需要勾选 class 驱动 * 最后退出保存即可。 -* 退出以后不急着编译,需要在代码中实现 `usb_hc_low_level_init` 函数。 * 复制一份 `usb_config.h` 到自己的目录中,并实现以下内容, 禁止包含 `"rtthread.h"` : .. figure:: img/config_file.png -* 使用 `scons --target=mdk` 或者 `scons` 进行编译 +* 在代码中实现 `usb_hc_low_level_init` 函数,USB 中断中调用 `USBH_IRQHandler`, +* 应用中调用 `usbh_alloc_bus` 和 `usbh_initialize`, +* 以上内容我们推荐放在 **board.c** 中,如下代码: + +.. code-block:: C + + struct usbh_bus *usb_otg_hs_bus; + + void OTG_HS_IRQHandler(void) + { + extern void USBH_IRQHandler(struct usbh_bus *bus); + USBH_IRQHandler(usb_otg_hs_bus); + } + + int usbh_init(void) + { + usb_otg_hs_bus = usbh_alloc_bus(0, USB_OTG_HS_PERIPH_BASE); + usbh_initialize(usb_otg_hs_bus); + return 0; + } + + INIT_APP_EXPORT(usbh_init); + +* 使用 `scons --target=mdk5` 或者 `scons` 进行编译,需要使用 AC6 编译器 * 如果使用的是 GCC ,需要在链接脚本(ld)中添加如下代码: .. code-block:: C @@ -71,17 +92,17 @@ 借助 STM32CubeMX 生成 USB 初始化 ---------------------------------- -使用 STM32CubeMX 主要是用来生成 usb 时钟、引脚、中断的配置。我们需要点击如图所示文件,并配置好 USB 的时钟、中断,点击 `Generate Code`。生成的时钟配置在 `main.c` 中的 `SystemClock_Config` 文件,将其拷贝到 `board.c` 中。 +使用 STM32CubeMX 主要是用来生成 usb 时钟、引脚、中断的配置。我们需要点击如图所示文件,并配置好 USB 的时钟、中断,点击 `Generate Code`。 .. figure:: img/stm32cubemx0.png .. figure:: img/stm32cubemx1.png .. figure:: img/stm32cubemx2.png .. figure:: img/stm32cubemx_clk.png -然后将 `stm32xxxx_hal_msp.c` 中的 `HAL_PCD_MspInit` 或者是 `HAL_HCD_MspInit` 中的内容复制到 `usb_dc_low_level_init` 和 `usb_hc_low_level_init` 函数中,举例如下: +- 将 `main.c` 中的 `SystemClock_Config` 替换掉 `board.c` 中的配置 -.. figure:: img/stm32_init.png +.. figure:: img/stm32_init2.png -其次将 `main.c` 中的 `SystemClock_Config` 替换掉 `board.c` 中的配置 +- 将 `stm32xxxx_hal_msp.c` 中的 `HAL_PCD_MspInit` 或者是 `HAL_HCD_MspInit` 中的内容复制到 `usb_dc_low_level_init` 和 `usb_hc_low_level_init` 函数中,举例如下: -.. figure:: img/stm32_init2.png
\ No newline at end of file +.. figure:: img/stm32_init.png |
