usb_glue_at.c 1.7 KB

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