usb_glue_es.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_musb_reg.h"
  9. #if CONFIG_USBDEV_EP_NUM != 6
  10. #error es32 chips only support 6 endpoints
  11. #endif
  12. #if CONFIG_USBHOST_PIPE_NUM != 6
  13. #error es32 chips only support 6 pipes
  14. #endif
  15. // clang-format off
  16. static struct musb_fifo_cfg musb_device_table[] = {
  17. { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
  18. { .ep_num = 1, .style = FIFO_TXRX, .maxpacket = 1024, },
  19. { .ep_num = 2, .style = FIFO_TXRX, .maxpacket = 512, },
  20. { .ep_num = 3, .style = FIFO_TXRX, .maxpacket = 512, },
  21. { .ep_num = 4, .style = FIFO_TXRX, .maxpacket = 512, },
  22. { .ep_num = 5, .style = FIFO_TXRX, .maxpacket = 512, },
  23. };
  24. static struct musb_fifo_cfg musb_host_table[] = {
  25. { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
  26. { .ep_num = 1, .style = FIFO_TXRX, .maxpacket = 1024, },
  27. { .ep_num = 2, .style = FIFO_TXRX, .maxpacket = 512, },
  28. { .ep_num = 3, .style = FIFO_TXRX, .maxpacket = 512, },
  29. { .ep_num = 4, .style = FIFO_TXRX, .maxpacket = 512, },
  30. { .ep_num = 5, .style = FIFO_TXRX, .maxpacket = 512, },
  31. };
  32. // clang-format on
  33. uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
  34. {
  35. *cfg = musb_device_table;
  36. return sizeof(musb_device_table) / sizeof(musb_device_table[0]);
  37. }
  38. uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
  39. {
  40. *cfg = musb_host_table;
  41. return sizeof(musb_host_table) / sizeof(musb_host_table[0]);
  42. }
  43. uint32_t usb_get_musb_ram_size(void)
  44. {
  45. return 4096;
  46. }
  47. void usbd_musb_delay_ms(uint8_t ms)
  48. {
  49. /* implement later */
  50. }