Open FFBoard
Open source force feedback firmware
dwc2_gd32.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2021, Ha Thach (tinyusb.org)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27
28#ifndef DWC2_GD32_H_
29#define DWC2_GD32_H_
30
31#ifdef __cplusplus
32 extern "C" {
33#endif
34
35#define DWC2_REG_BASE 0x50000000UL
36#define DWC2_EP_MAX 4
37
38static const dwc2_controller_t _dwc2_controller[] =
39{
40 { .reg_base = DWC2_REG_BASE, .irqnum = 86, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 1280 }
41};
42
43extern uint32_t SystemCoreClock;
44
45// The GD32VF103 is a RISC-V MCU, which implements the ECLIC Core-Local
46// Interrupt Controller by Nuclei. It is nearly API compatible to the
47// NVIC used by ARM MCUs.
48#define ECLIC_INTERRUPT_ENABLE_BASE 0xD2001001UL
49
50TU_ATTR_ALWAYS_INLINE
51static inline void __eclic_enable_interrupt (uint32_t irq) {
52 *(volatile uint8_t*)(ECLIC_INTERRUPT_ENABLE_BASE + (irq * 4)) = 1;
53}
54
55TU_ATTR_ALWAYS_INLINE
56static inline void __eclic_disable_interrupt (uint32_t irq){
57 *(volatile uint8_t*)(ECLIC_INTERRUPT_ENABLE_BASE + (irq * 4)) = 0;
58}
59
60TU_ATTR_ALWAYS_INLINE
61static inline void dwc2_dcd_int_enable(uint8_t rhport)
62{
64}
65
66TU_ATTR_ALWAYS_INLINE
67static inline void dwc2_dcd_int_disable (uint8_t rhport)
68{
70}
71
72static inline void dwc2_remote_wakeup_delay(void)
73{
74 // try to delay for 1 ms
75 uint32_t count = SystemCoreClock / 1000;
76 while ( count-- ) __asm volatile ("nop");
77}
78
79// MCU specific PHY init, called BEFORE core reset
80static inline void dwc2_phy_init(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
81{
82 (void) dwc2;
83 (void) hs_phy_type;
84
85 // nothing to do
86}
87
88// MCU specific PHY update, it is called AFTER init() and core reset
89static inline void dwc2_phy_update(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
90{
91 (void) dwc2;
92 (void) hs_phy_type;
93
94 // nothing to do
95}
96
97#ifdef __cplusplus
98}
99#endif
100
101#endif /* DWC2_GD32_H_ */
static const dwc2_controller_t _dwc2_controller[]
Definition: dwc2_esp32.h:57
static TU_ATTR_ALWAYS_INLINE void __eclic_disable_interrupt(uint32_t irq)
Definition: dwc2_gd32.h:56
static void dwc2_remote_wakeup_delay(void)
Definition: dwc2_gd32.h:72
uint32_t SystemCoreClock
static void dwc2_phy_init(dwc2_regs_t *dwc2, uint8_t hs_phy_type)
Definition: dwc2_gd32.h:80
static TU_ATTR_ALWAYS_INLINE void dwc2_dcd_int_enable(uint8_t rhport)
Definition: dwc2_gd32.h:61
static void dwc2_phy_update(dwc2_regs_t *dwc2, uint8_t hs_phy_type)
Definition: dwc2_gd32.h:89
static TU_ATTR_ALWAYS_INLINE void __eclic_enable_interrupt(uint32_t irq)
Definition: dwc2_gd32.h:51
static TU_ATTR_ALWAYS_INLINE void dwc2_dcd_int_disable(uint8_t rhport)
Definition: dwc2_gd32.h:67