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
11 #include <rtthread.h>
12
13 #ifdef RT_USING_VBUS
14 #include <rtdevice.h>
15 #include <vbus.h>
16 #include <board.h>
17
18 struct rt_vbus_ring rt_vbus_rings[2] rt_section("vbus_ring");
19
rt_vbus_do_init(void)20 int rt_vbus_do_init(void)
21 {
22 return rt_vbus_init(&rt_vbus_rings[1], &rt_vbus_rings[0]);
23 }
24 INIT_COMPONENT_EXPORT(rt_vbus_do_init);
25
rt_vbus_hw_init(void)26 int rt_vbus_hw_init(void)
27 {
28 NVIC_ClearPendingIRQ(M0_M4CORE_IRQn);
29 NVIC_EnableIRQ(M0_M4CORE_IRQn);
30 return 0;
31 }
32
M4CORE_IRQHandler(void)33 void M4CORE_IRQHandler(void)
34 {
35 LPC_CREG->M4TXEVENT = 0;
36 rt_vbus_isr(M0_M4CORE_IRQn, RT_NULL);
37 }
38
rt_vbus_hw_eoi(int irqnr,void * param)39 int rt_vbus_hw_eoi(int irqnr, void *param)
40 {
41 /* Nothing to do here as we cleared the interrupt in IRQHandler. */
42 return 0;
43 }
44
45 struct rt_vbus_dev rt_vbus_chn_devx[] = {
46 {
47 .req =
48 {
49 .prio = 30,
50 .name = "vecho",
51 .is_server = 0,
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 .name = RT_NULL,
62 }
63 },
64 };
65
66 #endif /* RT_USING_VBUS */
67
68