vbus_drv.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. * Change Logs:
  6. * Date Author Notes
  7. * 2015-01-07 Grissiom add comment
  8. */
  9. #include <rtthread.h>
  10. #ifdef RT_USING_VBUS
  11. #include <rtdevice.h>
  12. #include <vbus.h>
  13. #include <board.h>
  14. struct rt_vbus_ring rt_vbus_rings[2] SECTION("vbus_ring");
  15. int rt_vbus_do_init(void)
  16. {
  17. return rt_vbus_init(&rt_vbus_rings[0], &rt_vbus_rings[1]);
  18. }
  19. INIT_COMPONENT_EXPORT(rt_vbus_do_init);
  20. int rt_vbus_hw_init(void)
  21. {
  22. NVIC_ClearPendingIRQ(M0CORE_IRQn);
  23. NVIC_EnableIRQ(M0CORE_IRQn);
  24. return 0;
  25. }
  26. void M0CORE_IRQHandler(void)
  27. {
  28. LPC_CREG->M0TXEVENT = 0;
  29. rt_vbus_isr(M0CORE_IRQn, RT_NULL);
  30. }
  31. int rt_vbus_hw_eoi(int irqnr, void *param)
  32. {
  33. /* Nothing to do here as we cleared the interrupt in IRQHandler. */
  34. return 0;
  35. }
  36. struct rt_vbus_dev rt_vbus_chn_devx[] = {
  37. {
  38. .req =
  39. {
  40. .prio = 30,
  41. .name = "vecho",
  42. .is_server = 1,
  43. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  44. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  45. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  46. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  47. }
  48. },
  49. {
  50. .req =
  51. {
  52. .name = RT_NULL,
  53. }
  54. },
  55. };
  56. #endif /* RT_USING_VBUS */