39 lines
1.0 KiB
C
39 lines
1.0 KiB
C
#ifndef CONFIGS_FLATUSB_CONFIG
|
|
#define CONFIGS_FLATUSB_CONFIG
|
|
#ifndef SRC_FLATUSB_CONFIG
|
|
#define SRC_FLATUSB_CONFIG
|
|
|
|
#include <ch32f20x_usb.h>
|
|
#include <ch32f20x_rcc.h>
|
|
#include <ch32f20x.h>
|
|
|
|
static inline void usbdrv_gpio_init(void) {
|
|
// turn ON GPIOA clocks
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
|
}
|
|
|
|
#define USB_IRQ_N OTG_FS_IRQn
|
|
#define USB_IRQ_HANDLER OTG_FS_IRQHandler
|
|
#define USB_IRQ_PRIORITY (8)
|
|
#define USB_IRQ_SET_PRIORITY(irq, priority) NVIC_SetPriority((irq),(priority))
|
|
#define USB_IRQ_ENABLE(irq) NVIC_EnableIRQ((irq))
|
|
#define USB_IRQ_DISABLE(irq) NVIC_DisableIRQ((irq))
|
|
|
|
// define USBG
|
|
#define USBG (USBOTG_FS)
|
|
|
|
#define USB_CLOCK_ENABLE() RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE);\
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE)
|
|
|
|
#include "embfmt/embformat.h"
|
|
#define SNPRINTF(str, n, fmt, ...) embfmt(str, n, fmt, __VA_ARGS__)
|
|
|
|
#ifdef USBDBGMSG
|
|
#define USBMSG(...) MSG(__VA_ARGS__)
|
|
#endif
|
|
|
|
#endif /* SRC_FLATUSB_CONFIG */
|
|
|
|
|
|
#endif /* CONFIGS_FLATUSB_CONFIG */
|