vbus_drv.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 <vbus.h>
  14. #include <board.h>
  15. struct rt_vbus_ring rt_vbus_rings[2] rt_section("vbus_ring");
  16. int rt_vbus_do_init(void)
  17. {
  18. return rt_vbus_init(&rt_vbus_rings[0], &rt_vbus_rings[1]);
  19. }
  20. INIT_COMPONENT_EXPORT(rt_vbus_do_init);
  21. int rt_vbus_hw_init(void)
  22. {
  23. NVIC_ClearPendingIRQ(M0CORE_IRQn);
  24. NVIC_EnableIRQ(M0CORE_IRQn);
  25. return 0;
  26. }
  27. void M0CORE_IRQHandler(void)
  28. {
  29. LPC_CREG->M0TXEVENT = 0;
  30. rt_vbus_isr(M0CORE_IRQn, RT_NULL);
  31. }
  32. int rt_vbus_hw_eoi(int irqnr, void *param)
  33. {
  34. /* Nothing to do here as we cleared the interrupt in IRQHandler. */
  35. return 0;
  36. }
  37. struct rt_vbus_dev rt_vbus_chn_devx[] = {
  38. {
  39. .req =
  40. {
  41. .prio = 30,
  42. .name = "vecho",
  43. .is_server = 1,
  44. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  45. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  46. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  47. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  48. }
  49. },
  50. {
  51. .req =
  52. {
  53. .name = RT_NULL,
  54. }
  55. },
  56. };
  57. #endif /* RT_USING_VBUS */