diff options
| author | Stefan Kerkmann <[email protected]> | 2021-08-07 08:54:32 +0200 |
|---|---|---|
| committer | Stefan Kerkmann <[email protected]> | 2021-08-07 08:55:25 +0200 |
| commit | c6d495d6436c797b4efd029bd16ee8f19ff0a9f0 (patch) | |
| tree | 20dbd820d2701b01bcd1f86666b19228fe468ec9 | |
| parent | 3eb54d878af0492a85fab2811b5f84187c2f703c (diff) | |
Remove dependencies to external libraries for the dcd driver
The core of tinyusb must be as independent as possible, we previously
relied on nuclei-sdk or the GD32VF103 firmware library for the synopsys
driver to work with the GD32VF103. Fortunatly we needed very few parts
from them so we implement them here.
| -rw-r--r-- | src/portable/st/synopsys/dcd_synopsys.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c index 4b39844a1..7545ef6f7 100644 --- a/src/portable/st/synopsys/dcd_synopsys.c +++ b/src/portable/st/synopsys/dcd_synopsys.c @@ -94,16 +94,28 @@ #define EP_FIFO_SIZE_FS 1280 #elif CFG_TUSB_MCU == OPT_MCU_GD32VF103 -#define STM32F1_SYNOPSYS -#include "gd32vf103.h" -#include "nmsis_core.h" -#include "core_feature_eclic.h" #include "synopsys_common.h" + +// These numbers are the same for the whole GD32VF103 family. +#define OTG_FS_IRQn 86 #define EP_MAX_FS 4 #define EP_FIFO_SIZE_FS 1280 -#define OTG_FS_IRQn USBFS_IRQn -#define NVIC_EnableIRQ ECLIC_EnableIRQ -#define NVIC_DisableIRQ ECLIC_DisableIRQ + +// The GD32VF103 is a RISC-V MCU, which implements the ECLIC Core-Local +// Interrupt Controller by Nuclei. It is nearly API compatible to the +// NVIC used by ARM MCUs. +#define ECLIC_INTERRUPT_ENABLE_BASE 0xD2001001UL + +#define NVIC_EnableIRQ __eclic_enable_interrupt +#define NVIC_DisableIRQ __eclic_disable_interrupt + +static inline void __eclic_enable_interrupt (uint32_t irq) { + *(volatile uint8_t*)(ECLIC_INTERRUPT_ENABLE_BASE + (irq * 4)) = 1; +} + +static inline void __eclic_disable_interrupt (uint32_t irq){ + *(volatile uint8_t*)(ECLIC_INTERRUPT_ENABLE_BASE + (irq * 4)) = 0; +} #else #error "Unsupported MCUs" |
