usb_glue_gd.c 868 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2024, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "usb_config.h"
  7. #include "stdint.h"
  8. #include "usb_dwc2_reg.h"
  9. #if CONFIG_USBDEV_EP_NUM != 4 && CONFIG_USBDEV_EP_NUM != 6
  10. #error "gd32 only has 4 endpoints for pa11/pa12 and 6 endpoints for pb14/pb15"
  11. #endif
  12. /* you can find this config in function:usb_core_init, file:drv_usb_core.c, for example:
  13. *
  14. * usb_regs->gr->GCCFG |= GCCFG_PWRON | GCCFG_VBUSACEN | GCCFG_VBUSBCEN;
  15. *
  16. */
  17. uint32_t usbd_get_dwc2_gccfg_conf(uint32_t reg_base)
  18. {
  19. #ifdef CONFIG_USB_HS
  20. return 0;
  21. #else
  22. return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21));
  23. #endif
  24. }
  25. uint32_t usbh_get_dwc2_gccfg_conf(uint32_t reg_base)
  26. {
  27. #ifdef CONFIG_USB_HS
  28. return 0;
  29. #else
  30. return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21));
  31. #endif
  32. }
  33. void usbd_dwc2_delay_ms(uint8_t ms)
  34. {
  35. /* implement later */
  36. }