summaryrefslogtreecommitdiff
path: root/docs/source/quick_start
diff options
context:
space:
mode:
Diffstat (limited to 'docs/source/quick_start')
-rw-r--r--docs/source/quick_start/demo.rst9
-rw-r--r--docs/source/quick_start/rtthread.rst103
-rw-r--r--docs/source/quick_start/transplant.rst28
3 files changed, 35 insertions, 105 deletions
diff --git a/docs/source/quick_start/demo.rst b/docs/source/quick_start/demo.rst
index a341211a..3ad3ca72 100644
--- a/docs/source/quick_start/demo.rst
+++ b/docs/source/quick_start/demo.rst
@@ -177,6 +177,8 @@ USB Device 移植要点
.. figure:: img/stm32_13.png
+- 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节
+
- 调用 template 的内容初始化,并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBDEV_MAX_BUS`
.. figure:: img/stm32_15.png
@@ -212,13 +214,10 @@ USB Host 移植要点
- 拷贝 **xxx_msp.c** 中的 `HAL_HCD_MspInit` 函数中的内容到 `usb_hc_low_level_init` 函数中,屏蔽 st 生成的 usb 初始化
- 在中断函数中调用 `USBH_IRQHandler`,并传入 `busid`
+- 链接脚本修改参考 :ref:`usbh_link_script` 章节
+- 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节
- 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS`
- 启动线程
.. figure:: img/stm32_18.png
.. figure:: img/stm32_19.png
-
-- 如果使用 **msc**,并且带文件系统,需要自行添加文件系统文件了,对应的 porting 编写参考 **fatfs_usbh.c** 文件。
-
-.. figure:: img/stm32_21.png
-
diff --git a/docs/source/quick_start/rtthread.rst b/docs/source/quick_start/rtthread.rst
index af1fecc6..e9c4df5b 100644
--- a/docs/source/quick_start/rtthread.rst
+++ b/docs/source/quick_start/rtthread.rst
@@ -28,35 +28,19 @@
#define CONFIG_USB_PRINTF(...) rt_kprintf(__VA_ARGS__)
* USB IP 相关的 config 需要用户自己根据芯片实际情况修改
-* 退出以后不急着编译,需要在代码中实现 `usb_dc_low_level_init` 函数。
+* 在代码中实现 `usb_dc_low_level_init` 函数
+* 在 USB 中断函数中调用 `USBD_IRQHandler`,并传入 `busid`
* 调用 `usbd_initialize` 并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBDEV_MAX_BUS`
-* 以上内容我们推荐放在 **board.c** 中,如下代码:
-
-.. code-block:: C
-
- void OTG_HS_IRQHandler(void)
- {
- extern void USBD_IRQHandler(uint8_t busid);
- USBD_IRQHandler(0);
- }
-
- int usbd_init(void)
- {
- xxx_template_init(0, USB_OTG_HS_PERIPH_BASE);
- return 0;
- }
-
- INIT_APP_EXPORT(usbd_init);
-
* 使用 `scons --target=mdk5` 或者 `scons` 进行编译,如果是mdk,需要使用 AC6 编译器
+* 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节
主机配置
--------------------------
-* 选择 Enable usb host mode 并敲回车进入。
-* 选择 USB host ip,不清楚自己芯片是哪个 ip 的可以参考 **port** 目录下对应的 readme。
+* 选择 Enable usb host mode 并敲回车进入
+* 选择 USB host ip,不清楚自己芯片是哪个 ip 的可以参考 **port** 目录下对应的 readme
* 根据需要勾选 class 驱动
-* 选择是否开启模板 demo,请注意, msc 禁止使能,因为默认对接到 dfs。
+* 选择是否开启模板 demo,推荐不用
.. figure:: img/env2.png
@@ -71,77 +55,8 @@
* 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`
-* 以上内容我们推荐放在 **board.c** 中,如下代码:
-
-.. code-block:: C
-
- void OTG_HS_IRQHandler(void)
- {
- extern void USBH_IRQHandler(uint8_t busid);
- USBH_IRQHandler(0);
- }
-
- int usbh_init(void)
- {
- usbh_initialize(0, USB_OTG_HS_PERIPH_BASE);
- return 0;
- }
-
- INIT_APP_EXPORT(usbh_init);
-
* 使用 `scons --target=mdk5` 或者 `scons` 进行编译,如果是mdk,需要使用 AC6 编译器
-* 如果使用的是 GCC ,需要在链接脚本(需要放在 flash 位置)中添加如下代码:
-
-.. code-block:: C
-
- /* section information for usbh class */
- . = ALIGN(4);
- __usbh_class_info_start__ = .;
- KEEP(*(.usbh_class_info))
- __usbh_class_info_end__ = .;
-
-
-举例如下:
-
-.. code-block:: C
-
- /* The program code and other data into "FLASH" Rom type memory */
- .text :
- {
- . = ALIGN(4);
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.glue_7) /* glue arm to thumb code */
- *(.glue_7t) /* glue thumb to arm code */
- *(.eh_frame)
-
- KEEP (*(.init))
- KEEP (*(.fini))
- . = ALIGN(4);
- __usbh_class_info_start__ = .;
- KEEP(*(.usbh_class_info))
- __usbh_class_info_end__ = .;
- . = ALIGN(4);
- _etext = .; /* define a global symbols at end of code */
- } > FLASH
-
-借助 STM32CubeMX 生成 USB 初始化
-----------------------------------
-
-使用 STM32CubeMX 主要是用来生成 usb 时钟、引脚、中断的配置。我们需要点击如图所示文件,并配置好 USB 的时钟、中断,点击 `Generate Code`。
-
-.. figure:: img/stm32cubemx0.png
-.. figure:: img/stm32cubemx1.png
-.. figure:: img/stm32cubemx2.png
-.. figure:: img/stm32cubemx_clk.png
-
-- 将 `main.c` 中的 `SystemClock_Config` 替换掉 `board.c` 中的配置
-
-.. figure:: img/stm32_init2.png
-
-.. note :: 下面步骤从 V1.5.0 开始不再需要,**fsdev/usb_glue_st.c**, **dwc2/usb_glue_st.c** 文件中已经实现
-
-- 将 `stm32xxxx_hal_msp.c` 中的 `HAL_PCD_MspInit` 或者是 `HAL_HCD_MspInit` 中的内容复制到 `usb_dc_low_level_init` 和 `usb_hc_low_level_init` 函数中,举例如下:
-
-.. figure:: img/stm32_init.png
+* 链接脚本修改参考 :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 bde9d830..1b401d15 100644
--- a/docs/source/quick_start/transplant.rst
+++ b/docs/source/quick_start/transplant.rst
@@ -12,6 +12,7 @@ USB Device 移植要点
- 描述符的注册、class的注册、接口的注册、端点中断的注册。不会的参考 demo 下的 template
- 调用 `usbd_initialize` 并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBDEV_MAX_BUS`
- 在中断函数中调用 `USBD_IRQHandler`,并传入 `busid`, 如果你的 SDK 中中断入口已经存在 `USBD_IRQHandler` ,请更改 USB 协议栈中的名称
+- 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节
- 编译使用。各个 class 如何使用,参考 demo 下的 template
USB Host 移植要点
@@ -22,7 +23,20 @@ USB Host 移植要点
- 实现 `usb_hc_low_level_init` 函数(该函数主要负责 USB 时钟、引脚、中断的初始化)。该函数可以放在你想要放的任何参与编译的 c 文件中。如何进行 USB 的时钟、引脚、中断等初始化,请自行根据你使用的芯片原厂提供的源码中进行添加。
- 调用 `usbh_initialize` 并填入 `busid` 和 USB IP 的 `reg base`, `busid` 从 0 开始,不能超过 `CONFIG_USBHOST_MAX_BUS`
- 在中断函数中调用 `USBH_IRQHandler`,并传入 `busid`, 如果你的 SDK 中中断入口已经存在 `USBH_IRQHandler` ,请更改 USB 协议栈中的名称
-- 如果使用的是 GCC ,需要在链接脚本中添加如下代码(需要放在 flash 位置):
+- 链接脚本修改参考 :ref:`usbh_link_script` 章节
+- 如果芯片带 cache,cache 修改参考 :ref:`usb_cache` 章节
+- 编译使用。基础的 cdc + hid + msc 参考 `usb_host.c` 文件,其余参考 **platform** 目录下适配
+
+.. _usbh_link_script:
+
+主机链接脚本修改
+-----------------------
+
+在使用主机时,如果没有修改链接脚本,会报 `__usbh_class_info_start__` 和 `__usbh_class_info_end__` 未定义的错误。因为主机协议栈需要在链接脚本中添加一个 section 来存储 class 信息。
+
+- 如果使用的是 KEIL 无需修改
+
+- 如果使用的是 GCC ,需要在链接脚本中添加如下代码(需要放在 flash 位置,建议放最后):
.. code-block:: C
@@ -68,15 +82,17 @@ GCC 举例如下:
place in AXI_SRAM { block cherryusb_usbh_class_info };
keep { section .usbh_class_info};
-- 编译使用。各个 class 如何使用,参考 demo 下的 `usb_host.c` 文件
-带 cache 功能的芯片使用注意
+.. _usb_cache:
+
+cache 配置修改
-------------------------------
-协议栈以及 port 中不会对 cache 区域的 ram 进行 clean 或者 invalid,所以需要使用一块非 cache 区域的 ram 来维护。 `USB_NOCACHE_RAM_SECTION` 宏表示将变量指定到非 cache ram上,
-因此,用户需要在对应的链接脚本中添加 no cache ram 的 section。默认 `USB_NOCACHE_RAM_SECTION` 定义为 `__attribute__((section(".noncacheable")))`。
+对于带 cache 的芯片,协议栈以及 port 中不会对 cache 区域的 ram 进行 clean 或者 invalid,所以需要使用一块非 cache 区域的 ram 来维护。
+`USB_NOCACHE_RAM_SECTION` 宏表示将变量指定到非 cache ram上,默认 `USB_NOCACHE_RAM_SECTION` 定义为 `__attribute__((section(".noncacheable")))`。
+因此,用户需要在对应的链接脚本中添加 no cache ram 的 section,并且 section 段包含 `.noncacheable`。
-.. note:: 需要注意,光指定 section 是不够的,还需要配置该 section 中的 ram 是真的 nocache,一般需要配置 mpu 属性(arm 的参考 stm32h7 demo)。
+.. note:: 需要注意,光修改链接脚本中的 nocache section 是不够的,还需要配置该 section 中的 ram 是真的 nocache,一般需要配置 mpu 属性(arm 的参考 stm32h7 demo)。
GCC: