vbus_drv.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * VMM Bus Driver
  3. *
  4. * COPYRIGHT (C) 2015, Shanghai Real-Thread Technology Co., Ltd
  5. * http://www.rt-thread.com
  6. *
  7. * This file is part of RT-Thread (http://www.rt-thread.org)
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  24. *
  25. * Change Logs:
  26. * Date Author Notes
  27. * 2015-01-07 Grissiom add comment
  28. */
  29. #include <rtthread.h>
  30. #ifdef RT_USING_VBUS
  31. #include <rtdevice.h>
  32. #include <vbus.h>
  33. #include <board.h>
  34. struct rt_vbus_ring rt_vbus_rings[2] SECTION("vbus_ring");
  35. int rt_vbus_do_init(void)
  36. {
  37. return rt_vbus_init(&rt_vbus_rings[0], &rt_vbus_rings[1]);
  38. }
  39. INIT_COMPONENT_EXPORT(rt_vbus_do_init);
  40. int rt_vbus_hw_init(void)
  41. {
  42. NVIC_ClearPendingIRQ(M0CORE_IRQn);
  43. NVIC_EnableIRQ(M0CORE_IRQn);
  44. return 0;
  45. }
  46. void M0CORE_IRQHandler(void)
  47. {
  48. LPC_CREG->M0TXEVENT = 0;
  49. rt_vbus_isr(M0CORE_IRQn, RT_NULL);
  50. }
  51. int rt_vbus_hw_eoi(int irqnr, void *param)
  52. {
  53. /* Nothing to do here as we cleared the interrupt in IRQHandler. */
  54. return 0;
  55. }
  56. struct rt_vbus_dev rt_vbus_chn_devx[] = {
  57. {
  58. .req =
  59. {
  60. .prio = 30,
  61. .name = "vecho",
  62. .is_server = 1,
  63. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  64. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  65. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  66. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  67. }
  68. },
  69. {
  70. .req =
  71. {
  72. .name = RT_NULL,
  73. }
  74. },
  75. };
  76. #endif /* RT_USING_VBUS */