Deploying to gh-pages from @ cherry-embedded/CherryUSB@3784ddc389 🚀
This commit is contained in:
@@ -36,12 +36,7 @@ ST 命名为 USB_OTG_FS, USB_OTG_HS,并不是说明本身是高速或者全速
|
||||
GD IP 问题
|
||||
------------------
|
||||
|
||||
GD IP 采用 DWC2,但是读取的硬件参数都是 0(我也不懂为什么不给人知道),因此需要用户自行知道硬件信息,以下列举 GD32F4 的信息:
|
||||
|
||||
CONFIG_USBDEV_EP_NUM pa11/pa12 引脚必须为 4,PB14/PB15 引脚必须为 6,并删除 usb_dc_dwc2.c 中 while(1){}
|
||||
|
||||
- 当 CONFIG_USBDEV_EP_NUM 为4 时,fifo_num 不得大于 320 字
|
||||
- 当 CONFIG_USBDEV_EP_NUM 为6 时,fifo_num 不得大于 1280 字
|
||||
GD IP 采用 DWC2,但是读取的硬件参数都是 0(我也不懂为什么不给人知道),因此需要用户自行知道硬件信息,从 1.5.0 开始由于需要读取硬件信息,因此无法直接使用。
|
||||
|
||||
其次 GD 复位以后无法使用 EPDIS 功能关闭端点,需要用户删除 reset 中断中的以下代码:
|
||||
|
||||
@@ -50,11 +45,6 @@ CONFIG_USBDEV_EP_NUM pa11/pa12 引脚必须为 4,PB14/PB15 引脚必须为 6
|
||||
USB_OTG_INEP(i)->DIEPCTL = (USB_OTG_DIEPCTL_EPDIS | USB_OTG_DIEPCTL_SNAK);
|
||||
USB_OTG_OUTEP(i)->DOEPCTL = (USB_OTG_DOEPCTL_EPDIS | USB_OTG_DOEPCTL_SNAK);
|
||||
|
||||
dwc2 has less endpoints than config, please check
|
||||
---------------------------------------------------------------
|
||||
|
||||
该 IP 硬件上没有这么多端点,请修改 `CONFIG_USBDEV_EP_NUM`
|
||||
|
||||
Ep addr XXX overflow
|
||||
------------------------------
|
||||
|
||||
@@ -84,6 +74,4 @@ Failed to enable port
|
||||
移植 usb host 出现 urb 返回 -12/-14
|
||||
----------------------------------------------------------------
|
||||
|
||||
-12 就检查 phy 配置,通信不良
|
||||
|
||||
-14 就检查 phy 配置,cache 配置(如果有),fifo配置,寄存器地址, IP 是否真的标准等等
|
||||
检查 phy 配置,cache 配置(如果有),电源供电(建议自供电)
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
仓库参考:https://github.com/CherryUSB/cherryusb_bouffalolab
|
||||
|
||||
- BL616/BL808 是一个 USB2.0 并且内置高速 PHY 芯片,共 5个端点(包含端点0)。支持主从机。
|
||||
- BL616/BL808:USB2.0 内置 HS phy 芯片,支持主从机。device 支持 5 个端点(包括端点0),不支持双向同时使用。
|
||||
- USB 的相关应用位于 `examples/usbdev` 和 `examples/usbhost` 目录下,根据官方环境搭建完成后,即可编译使用。
|
||||
|
||||
基于 HPMicro 系列芯片
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
仓库参考:https://github.com/CherryUSB/cherryusb_hpmicro
|
||||
|
||||
- HPM 系列芯片均 USB 2.0 并且内置高速 PHY,支持主从机,端点共 8/16 个,并且可以同时使用双向,不同芯片个数有差异
|
||||
- HPM 系列: USB2.0 内置 HS phy 芯片,支持主从机。device 支持 8/16 端点(包括端点0),并且可以同时使用双向,不同芯片个数有差异。
|
||||
- USB 的相关应用位于 `samples/cherryusb` ,根据官方环境搭建完成后,即可编译使用。
|
||||
|
||||
基于 esp32s2/s3/p4 系列芯片
|
||||
@@ -25,8 +25,9 @@
|
||||
|
||||
仓库参考:https://github.com/CherryUSB/cherryusb_esp32
|
||||
|
||||
- esp32s2/s3 支持全速主从机,esp32p4 支持高速主从机
|
||||
- 默认提供主机 demo,并且使用 esp 组件库进行开发, 在 https://components.espressif.com/ 中搜索 cherryusb 即可
|
||||
- esp32s2/s3:USB2.0 内置全速 PHY 芯片,支持主从机,device 支持 7 个端点(包括端点0),并且可以同时使用双向。
|
||||
- esp32p4:一个 USB2.0 内置全速 PHY 芯片,一个 USB2.0 内置高速 PHY 芯片,支持主从机。
|
||||
- 默认 demo 采用组件库安装的形式,在 https://components.espressif.com/ 中搜索 cherryusb 即可
|
||||
|
||||
基于飞腾派系列芯片
|
||||
---------------------------
|
||||
@@ -41,23 +42,28 @@
|
||||
|
||||
仓库参考:https://github.com/CherryUSB/cherryusb_es32
|
||||
|
||||
- 支持全速和高速主从机
|
||||
- 支持全速和高速主从机。device 支持 6 个端点(包括端点0),并且可以同时使用双向。
|
||||
|
||||
基于 NXP MCX系列芯片
|
||||
---------------------------
|
||||
|
||||
仓库参考:https://github.com/CherryUSB/cherryusb_mcx 或者 https://github.com/RT-Thread/rt-thread/tree/master/bsp/nxp/mcx
|
||||
|
||||
- 支持全速 IP 和高速 IP, 高速 IP 支持主机和从机
|
||||
|
||||
- 支持全速和高速主从机
|
||||
- 支持全速 IP 和高速 IP, 高速 IP 支持主机和从机。device 支持 8 个端点(包括端点0),并且可以同时使用双向。
|
||||
|
||||
基于 Artinchip 系列芯片
|
||||
---------------------------
|
||||
|
||||
仓库参考:https://gitee.com/artinchip/luban-lite
|
||||
|
||||
- 支持全速和高速主从机,主机采用 EHCI + OHCI。
|
||||
- 支持全速和高速主从机,主机采用 EHCI + OHCI。device 支持 8 个端点(包括端点0),并且可以同时使用双向。
|
||||
|
||||
基于 canmv-k230 芯片
|
||||
---------------------------
|
||||
|
||||
仓库参考:https://github.com/CherryUSB/k230_sdk
|
||||
|
||||
- K230: 两个 USB2.0 内置 HS PHY 芯片,支持主从机。device 支持 16 个端点(包括端点0),并且可以同时使用双向。
|
||||
|
||||
基于 ST 系列芯片
|
||||
---------------------------
|
||||
@@ -67,8 +73,8 @@
|
||||
默认提供以下 demo 工程:
|
||||
|
||||
- F103 使用 fsdev ip
|
||||
- F429 主从使用 USB1, 引脚 pb14/pb15, 并且都使用 dma 模式
|
||||
- H7 设备使用 USB0, 引脚 pa11/pa12,没有开DMA 模式。主机使用 USB1 ,引脚 pb14/pb15,并且需要做 nocache 处理
|
||||
- F429 主从使用 USB1, 引脚 pb14/pb15, 默认从机没有开启 DMA 模式
|
||||
- H7 设备使用 USB0, 引脚 pa11/pa12,没有开 DMA 模式。主机使用 USB1 ,引脚 pb14/pb15,并且需要做 nocache 处理
|
||||
|
||||
demo 底下提供了 **stm32xxx.ioc** 文件,双击打开,点击 **Generate Code** 即可。
|
||||
|
||||
@@ -78,7 +84,7 @@ demo 底下提供了 **stm32xxx.ioc** 文件,双击打开,点击 **Generate
|
||||
|
||||
- usb ip 区别:F1使用 fsdev,F4/H7使用 dwc2
|
||||
- dwc2 ip 区别: USB0 (引脚是 PA11/PA12) 和 USB1 (引脚是 PB14/PB15), 其中 USB1 默认全速,可以接外部PHY 形成高速主机,并且带 dma 功能
|
||||
- F4 无cache,H7 有 cache
|
||||
- F4 无 cache,H7 有 cache
|
||||
|
||||
如果是 STM32F7/STM32H7 这种带 cache 功能,需要将 usb 使用到的 ram 定位到 no cache ram 区域。举例如下
|
||||
|
||||
@@ -154,11 +160,10 @@ USB Device 移植要点
|
||||
#define CONFIG_USB_DWC2_TX4_FIFO_SIZE (64 / 4)
|
||||
#define CONFIG_USB_DWC2_TX5_FIFO_SIZE (64 / 4)
|
||||
|
||||
- 如果使用 fsdev ip,(V1.5.0 开始需要增加 **fsdev/usb_glue_st.c**) 在 `usb_config.h` 中实现以下宏:
|
||||
- 如果使用 fsdev ip,(V1.5.0 开始需要增加 **fsdev/usb_glue_st.c**) 在 `usb_config.h` 中实现以下宏,具体数值不同芯片不一样:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define CONFIG_USBDEV_EP_NUM 8
|
||||
#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2
|
||||
|
||||
- 编译器推荐使用 **AC6**。勾选 **Microlib**,并实现 **printf** ,方便后续查看 log。
|
||||
@@ -188,7 +193,7 @@ USB Host 移植要点
|
||||
|
||||
前面 6 步与 Device 一样。需要注意,host 驱动只支持带 dma 的 hs port (引脚是 PB14/PB15),所以 fs port (引脚是 PA11/PA12)不做支持(没有 dma 你玩什么主机)。
|
||||
|
||||
- 添加 CherryUSB 必须要的源码( **usbh_core.c** 、 **usbh_hub.c** 、 **usb_hc_dwc2.c** 、以及 **osal** 目录下的适配层文件),以及想要使用的 class 驱动,并且可以将对应的 **usb host.c** 添加方便测试。
|
||||
- 添加 CherryUSB 必须要的源码( **usbh_core.c** 、 **usbh_hub.c** 、 **usb_hc_dwc2.c** 、 **usb_glue_st.c** 以及 **osal** 目录下的适配层文件),以及想要使用的 class 驱动,并且可以将对应的 **usb host.c** 添加方便测试。
|
||||
|
||||
.. figure:: img/stm32_16.png
|
||||
|
||||
@@ -199,17 +204,6 @@ USB Host 移植要点
|
||||
|
||||
- 复制一份 **cherryusb_config_template.h**,放到 `Core/Inc` 目录下,并命名为 `usb_config.h`
|
||||
|
||||
- 增加 **usb_glue_st.c** 文件,并在 `usb_config.h` 中实现以下宏:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
// 以下细节如有出入,请对照 stm32xxx.h 文件修改
|
||||
// 需要根据硬件实际的 fifo 深度进行修改,默认是最基础的配置
|
||||
#define CONFIG_USBHOST_PIPE_NUM 12
|
||||
#define CONFIG_USB_DWC2_NPTX_FIFO_SIZE (512 / 4)
|
||||
#define CONFIG_USB_DWC2_PTX_FIFO_SIZE (1024 / 4)
|
||||
#define CONFIG_USB_DWC2_RX_FIFO_SIZE ((1012 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE) / 4)
|
||||
|
||||
.. note :: 以下两个步骤从 V1.5.0 开始不再需要,**fsdev/usb_glue_st.c**, **dwc2/usb_glue_st.c** 文件中已经实现
|
||||
|
||||
- 拷贝 **xxx_msp.c** 中的 `HAL_HCD_MspInit` 函数中的内容到 `usb_hc_low_level_init` 函数中,屏蔽 st 生成的 usb 初始化
|
||||
|
||||
15
q&a.html
15
q&a.html
@@ -55,7 +55,6 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="#cherryusb">CherryUSB 性能能到多少</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#st-ip">ST IP 命名问题</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#gd-ip">GD IP 问题</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#dwc2-has-less-endpoints-than-config-please-check">dwc2 has less endpoints than config, please check</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#ep-addr-xxx-overflow">Ep addr XXX overflow</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#this-dwc2-version-does-not-support-dma-mode-so-stop-working">This dwc2 version does not support dma mode, so stop working</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#has-include">__has_include 报错</a></li>
|
||||
@@ -203,22 +202,13 @@
|
||||
</section>
|
||||
<section id="gd-ip">
|
||||
<h2>GD IP 问题<a class="headerlink" href="#gd-ip" title="Link to this heading"></a></h2>
|
||||
<p>GD IP 采用 DWC2,但是读取的硬件参数都是 0(我也不懂为什么不给人知道),因此需要用户自行知道硬件信息,以下列举 GD32F4 的信息:</p>
|
||||
<p>CONFIG_USBDEV_EP_NUM pa11/pa12 引脚必须为 4,PB14/PB15 引脚必须为 6,并删除 usb_dc_dwc2.c 中 while(1){}</p>
|
||||
<ul class="simple">
|
||||
<li><p>当 CONFIG_USBDEV_EP_NUM 为4 时,fifo_num 不得大于 320 字</p></li>
|
||||
<li><p>当 CONFIG_USBDEV_EP_NUM 为6 时,fifo_num 不得大于 1280 字</p></li>
|
||||
</ul>
|
||||
<p>GD IP 采用 DWC2,但是读取的硬件参数都是 0(我也不懂为什么不给人知道),因此需要用户自行知道硬件信息,从 1.5.0 开始由于需要读取硬件信息,因此无法直接使用。</p>
|
||||
<p>其次 GD 复位以后无法使用 EPDIS 功能关闭端点,需要用户删除 reset 中断中的以下代码:</p>
|
||||
<div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="n">USB_OTG_INEP</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">-></span><span class="n">DIEPCTL</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">USB_OTG_DIEPCTL_EPDIS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">USB_OTG_DIEPCTL_SNAK</span><span class="p">);</span>
|
||||
<span class="n">USB_OTG_OUTEP</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">-></span><span class="n">DOEPCTL</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">USB_OTG_DOEPCTL_EPDIS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">USB_OTG_DOEPCTL_SNAK</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="dwc2-has-less-endpoints-than-config-please-check">
|
||||
<h2>dwc2 has less endpoints than config, please check<a class="headerlink" href="#dwc2-has-less-endpoints-than-config-please-check" title="Link to this heading"></a></h2>
|
||||
<p>该 IP 硬件上没有这么多端点,请修改 <cite>CONFIG_USBDEV_EP_NUM</cite></p>
|
||||
</section>
|
||||
<section id="ep-addr-xxx-overflow">
|
||||
<h2>Ep addr XXX overflow<a class="headerlink" href="#ep-addr-xxx-overflow" title="Link to this heading"></a></h2>
|
||||
<p>该 IP 硬件上没有这么多端点, 请更换 IP or 减少端点使用。并且默认 demo 不做双向功能,考虑到不是所有的 IP 都支持,因此默认是 81 02 这样的而不是 81 01,
|
||||
@@ -242,8 +232,7 @@
|
||||
</section>
|
||||
<section id="usb-host-urb-12-14">
|
||||
<h2>移植 usb host 出现 urb 返回 -12/-14<a class="headerlink" href="#usb-host-urb-12-14" title="Link to this heading"></a></h2>
|
||||
<p>-12 就检查 phy 配置,通信不良</p>
|
||||
<p>-14 就检查 phy 配置,cache 配置(如果有),fifo配置,寄存器地址, IP 是否真的标准等等</p>
|
||||
<p>检查 phy 配置,cache 配置(如果有),电源供电(建议自供电)</p>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="#essemi">基于 Essemi 系列芯片</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#nxp-mcx">基于 NXP MCX系列芯片</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#artinchip">基于 Artinchip 系列芯片</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#canmv-k230">基于 canmv-k230 芯片</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#st">基于 ST 系列芯片</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#usb-device">USB Device 移植要点</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#usb-host">USB Host 移植要点</a></li>
|
||||
@@ -179,7 +180,7 @@
|
||||
<h2>基于 bouffalolab 系列芯片<a class="headerlink" href="#bouffalolab" title="Link to this heading"></a></h2>
|
||||
<p>仓库参考:<a class="reference external" href="https://github.com/CherryUSB/cherryusb_bouffalolab">https://github.com/CherryUSB/cherryusb_bouffalolab</a></p>
|
||||
<ul class="simple">
|
||||
<li><p>BL616/BL808 是一个 USB2.0 并且内置高速 PHY 芯片,共 5个端点(包含端点0)。支持主从机。</p></li>
|
||||
<li><p>BL616/BL808:USB2.0 内置 HS phy 芯片,支持主从机。device 支持 5 个端点(包括端点0),不支持双向同时使用。</p></li>
|
||||
<li><p>USB 的相关应用位于 <cite>examples/usbdev</cite> 和 <cite>examples/usbhost</cite> 目录下,根据官方环境搭建完成后,即可编译使用。</p></li>
|
||||
</ul>
|
||||
</section>
|
||||
@@ -187,7 +188,7 @@
|
||||
<h2>基于 HPMicro 系列芯片<a class="headerlink" href="#hpmicro" title="Link to this heading"></a></h2>
|
||||
<p>仓库参考:<a class="reference external" href="https://github.com/CherryUSB/cherryusb_hpmicro">https://github.com/CherryUSB/cherryusb_hpmicro</a></p>
|
||||
<ul class="simple">
|
||||
<li><p>HPM 系列芯片均 USB 2.0 并且内置高速 PHY,支持主从机,端点共 8/16 个,并且可以同时使用双向,不同芯片个数有差异</p></li>
|
||||
<li><p>HPM 系列: USB2.0 内置 HS phy 芯片,支持主从机。device 支持 8/16 端点(包括端点0),并且可以同时使用双向,不同芯片个数有差异。</p></li>
|
||||
<li><p>USB 的相关应用位于 <cite>samples/cherryusb</cite> ,根据官方环境搭建完成后,即可编译使用。</p></li>
|
||||
</ul>
|
||||
</section>
|
||||
@@ -195,8 +196,9 @@
|
||||
<h2>基于 esp32s2/s3/p4 系列芯片<a class="headerlink" href="#esp32s2-s3-p4" title="Link to this heading"></a></h2>
|
||||
<p>仓库参考:<a class="reference external" href="https://github.com/CherryUSB/cherryusb_esp32">https://github.com/CherryUSB/cherryusb_esp32</a></p>
|
||||
<ul class="simple">
|
||||
<li><p>esp32s2/s3 支持全速主从机,esp32p4 支持高速主从机</p></li>
|
||||
<li><p>默认提供主机 demo,并且使用 esp 组件库进行开发, 在 <a class="reference external" href="https://components.espressif.com/">https://components.espressif.com/</a> 中搜索 cherryusb 即可</p></li>
|
||||
<li><p>esp32s2/s3:USB2.0 内置全速 PHY 芯片,支持主从机,device 支持 7 个端点(包括端点0),并且可以同时使用双向。</p></li>
|
||||
<li><p>esp32p4:一个 USB2.0 内置全速 PHY 芯片,一个 USB2.0 内置高速 PHY 芯片,支持主从机。</p></li>
|
||||
<li><p>默认 demo 采用组件库安装的形式,在 <a class="reference external" href="https://components.espressif.com/">https://components.espressif.com/</a> 中搜索 cherryusb 即可</p></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="id1">
|
||||
@@ -211,22 +213,28 @@
|
||||
<h2>基于 Essemi 系列芯片<a class="headerlink" href="#essemi" title="Link to this heading"></a></h2>
|
||||
<p>仓库参考:<a class="reference external" href="https://github.com/CherryUSB/cherryusb_es32">https://github.com/CherryUSB/cherryusb_es32</a></p>
|
||||
<ul class="simple">
|
||||
<li><p>支持全速和高速主从机</p></li>
|
||||
<li><p>支持全速和高速主从机。device 支持 6 个端点(包括端点0),并且可以同时使用双向。</p></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="nxp-mcx">
|
||||
<h2>基于 NXP MCX系列芯片<a class="headerlink" href="#nxp-mcx" title="Link to this heading"></a></h2>
|
||||
<p>仓库参考:<a class="reference external" href="https://github.com/CherryUSB/cherryusb_mcx">https://github.com/CherryUSB/cherryusb_mcx</a> 或者 <a class="reference external" href="https://github.com/RT-Thread/rt-thread/tree/master/bsp/nxp/mcx">https://github.com/RT-Thread/rt-thread/tree/master/bsp/nxp/mcx</a></p>
|
||||
<ul class="simple">
|
||||
<li><p>支持全速 IP 和高速 IP, 高速 IP 支持主机和从机</p></li>
|
||||
<li><p>支持全速和高速主从机</p></li>
|
||||
<li><p>支持全速 IP 和高速 IP, 高速 IP 支持主机和从机。device 支持 8 个端点(包括端点0),并且可以同时使用双向。</p></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="artinchip">
|
||||
<h2>基于 Artinchip 系列芯片<a class="headerlink" href="#artinchip" title="Link to this heading"></a></h2>
|
||||
<p>仓库参考:<a class="reference external" href="https://gitee.com/artinchip/luban-lite">https://gitee.com/artinchip/luban-lite</a></p>
|
||||
<ul class="simple">
|
||||
<li><p>支持全速和高速主从机,主机采用 EHCI + OHCI。</p></li>
|
||||
<li><p>支持全速和高速主从机,主机采用 EHCI + OHCI。device 支持 8 个端点(包括端点0),并且可以同时使用双向。</p></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="canmv-k230">
|
||||
<h2>基于 canmv-k230 芯片<a class="headerlink" href="#canmv-k230" title="Link to this heading"></a></h2>
|
||||
<p>仓库参考:<a class="reference external" href="https://github.com/CherryUSB/k230_sdk">https://github.com/CherryUSB/k230_sdk</a></p>
|
||||
<ul class="simple">
|
||||
<li><p>K230: 两个 USB2.0 内置 HS PHY 芯片,支持主从机。device 支持 16 个端点(包括端点0),并且可以同时使用双向。</p></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="st">
|
||||
@@ -235,8 +243,8 @@
|
||||
<p>默认提供以下 demo 工程:</p>
|
||||
<ul class="simple">
|
||||
<li><p>F103 使用 fsdev ip</p></li>
|
||||
<li><p>F429 主从使用 USB1, 引脚 pb14/pb15, 并且都使用 dma 模式</p></li>
|
||||
<li><p>H7 设备使用 USB0, 引脚 pa11/pa12,没有开DMA 模式。主机使用 USB1 ,引脚 pb14/pb15,并且需要做 nocache 处理</p></li>
|
||||
<li><p>F429 主从使用 USB1, 引脚 pb14/pb15, 默认从机没有开启 DMA 模式</p></li>
|
||||
<li><p>H7 设备使用 USB0, 引脚 pa11/pa12,没有开 DMA 模式。主机使用 USB1 ,引脚 pb14/pb15,并且需要做 nocache 处理</p></li>
|
||||
</ul>
|
||||
<p>demo 底下提供了 <strong>stm32xxx.ioc</strong> 文件,双击打开,点击 <strong>Generate Code</strong> 即可。</p>
|
||||
<div class="admonition caution">
|
||||
@@ -247,7 +255,7 @@
|
||||
<ul class="simple">
|
||||
<li><p>usb ip 区别:F1使用 fsdev,F4/H7使用 dwc2</p></li>
|
||||
<li><p>dwc2 ip 区别: USB0 (引脚是 PA11/PA12) 和 USB1 (引脚是 PB14/PB15), 其中 USB1 默认全速,可以接外部PHY 形成高速主机,并且带 dma 功能</p></li>
|
||||
<li><p>F4 无cache,H7 有 cache</p></li>
|
||||
<li><p>F4 无 cache,H7 有 cache</p></li>
|
||||
</ul>
|
||||
<p>如果是 STM32F7/STM32H7 这种带 cache 功能,需要将 usb 使用到的 ram 定位到 no cache ram 区域。举例如下</p>
|
||||
<div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="n">cpu_mpu_config</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="n">MPU_Normal_NonCache</span><span class="p">,</span><span class="w"> </span><span class="mh">0x24070000</span><span class="p">,</span><span class="w"> </span><span class="n">MPU_REGION_SIZE_64KB</span><span class="p">);</span>
|
||||
@@ -339,10 +347,9 @@
|
||||
</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>如果使用 fsdev ip,(V1.5.0 开始需要增加 <strong>fsdev/usb_glue_st.c</strong>) 在 <cite>usb_config.h</cite> 中实现以下宏:</p></li>
|
||||
<li><p>如果使用 fsdev ip,(V1.5.0 开始需要增加 <strong>fsdev/usb_glue_st.c</strong>) 在 <cite>usb_config.h</cite> 中实现以下宏,具体数值不同芯片不一样:</p></li>
|
||||
</ul>
|
||||
<div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="cp">#define CONFIG_USBDEV_EP_NUM 8</span>
|
||||
<span class="cp">#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2</span>
|
||||
<div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="cp">#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
@@ -385,7 +392,7 @@
|
||||
<h3>USB Host 移植要点<a class="headerlink" href="#usb-host" title="Link to this heading"></a></h3>
|
||||
<p>前面 6 步与 Device 一样。需要注意,host 驱动只支持带 dma 的 hs port (引脚是 PB14/PB15),所以 fs port (引脚是 PA11/PA12)不做支持(没有 dma 你玩什么主机)。</p>
|
||||
<ul class="simple">
|
||||
<li><p>添加 CherryUSB 必须要的源码( <strong>usbh_core.c</strong> 、 <strong>usbh_hub.c</strong> 、 <strong>usb_hc_dwc2.c</strong> 、以及 <strong>osal</strong> 目录下的适配层文件),以及想要使用的 class 驱动,并且可以将对应的 <strong>usb host.c</strong> 添加方便测试。</p></li>
|
||||
<li><p>添加 CherryUSB 必须要的源码( <strong>usbh_core.c</strong> 、 <strong>usbh_hub.c</strong> 、 <strong>usb_hc_dwc2.c</strong> 、 <strong>usb_glue_st.c</strong> 以及 <strong>osal</strong> 目录下的适配层文件),以及想要使用的 class 驱动,并且可以将对应的 <strong>usb host.c</strong> 添加方便测试。</p></li>
|
||||
</ul>
|
||||
<figure class="align-default">
|
||||
<img alt="../_images/stm32_16.png" src="../_images/stm32_16.png" />
|
||||
@@ -401,16 +408,7 @@
|
||||
</figure>
|
||||
<ul class="simple">
|
||||
<li><p>复制一份 <strong>cherryusb_config_template.h</strong>,放到 <cite>Core/Inc</cite> 目录下,并命名为 <cite>usb_config.h</cite></p></li>
|
||||
<li><p>增加 <strong>usb_glue_st.c</strong> 文件,并在 <cite>usb_config.h</cite> 中实现以下宏:</p></li>
|
||||
</ul>
|
||||
<div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="c1">// 以下细节如有出入,请对照 stm32xxx.h 文件修改</span>
|
||||
<span class="c1">// 需要根据硬件实际的 fifo 深度进行修改,默认是最基础的配置</span>
|
||||
<span class="cp">#define CONFIG_USBHOST_PIPE_NUM 12</span>
|
||||
<span class="cp">#define CONFIG_USB_DWC2_NPTX_FIFO_SIZE (512 / 4)</span>
|
||||
<span class="cp">#define CONFIG_USB_DWC2_PTX_FIFO_SIZE (1024 / 4)</span>
|
||||
<span class="cp">#define CONFIG_USB_DWC2_RX_FIFO_SIZE ((1012 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE) / 4)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>以下两个步骤从 V1.5.0 开始不再需要,<strong>fsdev/usb_glue_st.c</strong>, <strong>dwc2/usb_glue_st.c</strong> 文件中已经实现</p>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user