vbus_drv.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2015-01-07 Grissiom add comment
  9. */
  10. #include <rtthread.h>
  11. #ifdef RT_USING_VBUS
  12. #include <rtdevice.h>
  13. #include <rthw.h>
  14. #include <interrupt.h>
  15. #include <vbus.h>
  16. #include <board.h>
  17. int rt_vbus_do_init(void)
  18. {
  19. return rt_vbus_init((void*)_RT_VBUS_RING_BASE,
  20. (void*)(_RT_VBUS_RING_BASE + _RT_VBUS_RING_SZ));
  21. }
  22. INIT_COMPONENT_EXPORT(rt_vbus_do_init);
  23. static void _bus_resume_in_thread(int irqnr, void *param)
  24. {
  25. rt_vbus_isr(irqnr, RT_NULL);
  26. }
  27. int rt_vbus_hw_init(void)
  28. {
  29. rt_kprintf("install irq: %d\n", RT_VBUS_HOST_VIRQ);
  30. rt_hw_interrupt_install(RT_VBUS_HOST_VIRQ,
  31. _bus_resume_in_thread, RT_NULL,
  32. "vbusin");
  33. rt_hw_interrupt_umask(RT_VBUS_HOST_VIRQ);
  34. return 0;
  35. }
  36. int rt_vbus_hw_eoi(int irqnr, void *param)
  37. {
  38. rt_hw_interrupt_clear(irqnr);
  39. return 0;
  40. }
  41. #define RT_VBUS_SER_PRIO 20
  42. #define RT_VBUS_RFS_PRIO 19
  43. #define RT_VBUS_TASK2_PRIO 6
  44. #define RT_VBUS_INT_PRIO 4
  45. struct rt_vbus_dev rt_vbus_chn_devx[] = {
  46. {
  47. .req =
  48. {
  49. .prio = RT_VBUS_SER_PRIO,
  50. .name = RT_VBUS_SHELL_DEV_NAME,
  51. .is_server = 1,
  52. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  53. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  54. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  55. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  56. }
  57. },
  58. {
  59. .req =
  60. {
  61. .prio = 23,
  62. .name = RT_VBUS_RFS_DEV_NAME,
  63. .is_server = 0,
  64. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  65. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  66. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  67. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  68. }
  69. },
  70. {
  71. .req =
  72. {
  73. .prio = 30,
  74. .name = "vecho",
  75. .is_server = 1,
  76. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  77. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  78. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  79. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  80. }
  81. },
  82. {
  83. .req =
  84. {
  85. .name = RT_NULL,
  86. }
  87. },
  88. };
  89. #endif /* RT_USING_VBUS */