Skip to content

Commit

Permalink
update(port/dwc2/usb_glue_gd): add check for ep
Browse files Browse the repository at this point in the history
  • Loading branch information
sakumisu committed Dec 19, 2024
1 parent effee4d commit 75e6dc6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
14 changes: 13 additions & 1 deletion docs/source/q&a.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,19 @@ ST 命名为 USB_OTG_FS, USB_OTG_HS,并不是说明本身是高速或者全速
GD IP 问题
------------------

GD IP 采用 DWC2,但是读取的硬件参数都是 0(我也不懂为什么不给人知道),因此需要用户自行知道硬件信息,并修改代码下面 check 的内容,然后删除 while1。
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 复位以后无法使用 EPDIS 功能关闭端点,需要用户删除 reset 中断中的以下代码:

.. code-block:: C
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
---------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion docs/source/share.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@

- `printalyzer-timer: F-Stop enlarging timer and print exposure meter <https://github.com/dektronics/printalyzer-timer>`_

- `MiSTeryNano: Atari STE MiSTery core for the Tang Nano 20k FPGA <https://github.com/harbaum/MiSTeryNano>`_
- `MiSTeryNano: Atari STE MiSTery core for the Tang Nano 20k FPGA <https://github.com/harbaum/MiSTeryNano>`_

- `Cherryuf2 <https://github.com/zhaqian12/Cherryuf2>`_
5 changes: 5 additions & 0 deletions port/dwc2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ If you are using more than one port, all ip parameters must be the same(like fif

## GD32

CONFIG_USBDEV_EP_NUM 必须为4 或者 6,并删除 usb_dc_dwc2.c 中 while(1){}

当 CONFIG_USBDEV_EP_NUM 为4 时,fifo_num 不得大于 320 字
当 CONFIG_USBDEV_EP_NUM 为6 时,fifo_num 不得大于 1280 字

- GD32F30X_CL
- GD32F405、GD32F407
- GD32F450
Expand Down
4 changes: 4 additions & 0 deletions port/dwc2/usb_glue_gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "stdint.h"
#include "usb_dwc2_reg.h"

#if CONFIG_USBDEV_EP_NUM != 4 && CONFIG_USBDEV_EP_NUM != 6
#error "gd32 only has 4 endpoints for pa11/pa12 and 6 endpoints for pb14/pb15"
#endif

/* you can find this config in function:usb_core_init, file:drv_usb_core.c, for example:
*
* usb_regs->gr->GCCFG |= GCCFG_PWRON | GCCFG_VBUSACEN | GCCFG_VBUSBCEN;
Expand Down

0 comments on commit 75e6dc6

Please sign in to comment.