usb_glue_at.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. extern unsigned int system_core_clock;
  10. uint32_t SystemCoreClock;
  11. /* you can find this config in function: usb_global_init, file:at32fxxx_usb.c, for example:
  12. *
  13. * usbx->gccfg_bit.pwrdown = TRUE;
  14. * usbx->gccfg_bit.avalidsesen = TRUE;
  15. * usbx->gccfg_bit.bvalidsesen = TRUE;
  16. *
  17. */
  18. uint32_t usbd_get_dwc2_gccfg_conf(uint32_t reg_base)
  19. {
  20. SystemCoreClock = system_core_clock;
  21. #ifdef CONFIG_USB_HS
  22. return ((1 << 16) | (1 << 21));
  23. #else
  24. // AT32F415
  25. #if defined(AT32F415RCT7) || defined(AT32F415RCT7_7) || defined(AT32F415CCT7) || \
  26. defined(AT32F415CCU7) || defined(AT32F415KCU7_4) || defined(AT32F415RBT7) || \
  27. defined(AT32F415RBT7_7) || defined(AT32F415CBT7) || defined(AT32F415CBU7) || \
  28. defined(AT32F415KBU7_4) || defined(AT32F415R8T7) || defined(AT32F415R8T7_7) || \
  29. defined(AT32F415C8T7) || defined(AT32F415K8U7_4)
  30. return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21));
  31. #else
  32. return ((1 << 16) | (1 << 21));
  33. #endif
  34. #endif
  35. }
  36. uint32_t usbh_get_dwc2_gccfg_conf(uint32_t reg_base)
  37. {
  38. SystemCoreClock = system_core_clock;
  39. #ifdef CONFIG_USB_HS
  40. return ((1 << 16) | (1 << 21));
  41. #else
  42. // AT32F415
  43. #if defined(AT32F415RCT7) || defined(AT32F415RCT7_7) || defined(AT32F415CCT7) || \
  44. defined(AT32F415CCU7) || defined(AT32F415KCU7_4) || defined(AT32F415RBT7) || \
  45. defined(AT32F415RBT7_7) || defined(AT32F415CBT7) || defined(AT32F415CBU7) || \
  46. defined(AT32F415KBU7_4) || defined(AT32F415R8T7) || defined(AT32F415R8T7_7) || \
  47. defined(AT32F415C8T7) || defined(AT32F415K8U7_4)
  48. return ((1 << 16) | (1 << 18) | (1 << 19) | (1 << 21));
  49. #else
  50. return ((1 << 16) | (1 << 21));
  51. #endif
  52. #endif
  53. }
  54. void usbd_dwc2_delay_ms(uint8_t ms)
  55. {
  56. /* implement later */
  57. }